-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8d2e66
commit 12eca61
Showing
5 changed files
with
215 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...bm.ws.cdi.api_fat/fat/src/com/ibm/ws/cdi/api/fat/apps/threads/extension/CDIExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package com.ibm.ws.cdi.api.fat.apps.threads.extension; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.enterprise.inject.spi.AfterBeanDiscovery; | ||
import javax.enterprise.inject.spi.AfterDeploymentValidation; | ||
import javax.enterprise.inject.spi.AfterTypeDiscovery; | ||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.enterprise.inject.spi.BeforeBeanDiscovery; | ||
import javax.enterprise.inject.spi.CDI; | ||
import javax.enterprise.inject.spi.Extension; | ||
import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
import javax.enterprise.inject.spi.ProcessBean; | ||
import javax.enterprise.inject.spi.ProcessBeanAttributes; | ||
import javax.enterprise.inject.spi.ProcessInjectionPoint; | ||
import javax.enterprise.inject.spi.ProcessInjectionTarget; | ||
import javax.enterprise.inject.spi.ProcessManagedBean; | ||
|
||
/** | ||
* | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public class CDIExtension implements Extension { | ||
|
||
private final Set<String> duplicatesFilter = new HashSet<String>(); | ||
|
||
public void eventListener(@Observes BeforeBeanDiscovery event) { | ||
checkForBeanManagerInUnmanagedThread("BeforeBeanDiscovery"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessAnnotatedType event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessAnnotatedType"); | ||
} | ||
|
||
public void eventListener(@Observes AfterTypeDiscovery event) { | ||
checkForBeanManagerInUnmanagedThread("AfterTypeDiscovery"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessInjectionTarget event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessInjectionTarget"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessInjectionPoint event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessInjectionPoint"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessBeanAttributes event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessBeanAttributes"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessBean event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessBean"); | ||
} | ||
|
||
public void eventListener(@Observes ProcessManagedBean event) { | ||
checkForBeanManagerInUnmanagedThread("ProcessManagedBean"); | ||
} | ||
|
||
public void eventListener(@Observes AfterBeanDiscovery event) { | ||
checkForBeanManagerInUnmanagedThread("AfterBeanDiscovery"); | ||
} | ||
|
||
public void eventListener(@Observes AfterDeploymentValidation event) { | ||
checkForBeanManagerInUnmanagedThread("AfterDeploymentValidation"); | ||
} | ||
|
||
private void checkForBeanManagerInUnmanagedThread(final String eventName) { | ||
Thread thread = new Thread() { | ||
@Override | ||
public void run() { | ||
try { | ||
BeanManager bm = CDI.current().getBeanManager(); | ||
String s = "found beanmanager in " + eventName + " : " + (bm instanceof BeanManager); | ||
if (duplicatesFilter.add(s)) { | ||
System.out.println(s); | ||
} | ||
} catch (Exception e) { | ||
String s = "failed to find beanmanager in " + eventName + " : " + e.toString(); | ||
if (duplicatesFilter.add(s)) { | ||
System.out.println(s); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
thread.start(); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
....ibm.ws.cdi.api_fat/fat/src/com/ibm/ws/cdi/api/fat/apps/threads/extension/SimpleBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.cdi.api.fat.apps.threads.extension; | ||
|
||
import javax.enterprise.context.Dependent; | ||
|
||
import com.ibm.ws.cdi.api.fat.apps.current.sharedLib.ISimpleBean; | ||
|
||
/** | ||
* | ||
*/ | ||
@Dependent | ||
public class SimpleBean implements ISimpleBean { | ||
|
||
public static final String MSG = "bean exists"; | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public String test() { | ||
return MSG; | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...t/src/com/ibm/ws/cdi/api/fat/apps/threads/extension/javax.enterprise.inject.spi.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.ibm.ws.cdi.api.fat.apps.threads.extension.CDIExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters