You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2014/12/26 16:04:16 UTC
[1/2] tomee git commit: using parent interceptors as well
Repository: tomee
Updated Branches:
refs/heads/develop f09c41bd2 -> cdf0aa550
using parent interceptors as well
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b154923e
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b154923e
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b154923e
Branch: refs/heads/develop
Commit: b154923e4b66a916185fa061c0d02e2ce79b62d2
Parents: f09c41b
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Fri Dec 26 13:58:52 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Fri Dec 26 13:58:52 2014 +0100
----------------------------------------------------------------------
.../openejb/OpenEJBDeployableContainer.java | 2 +-
.../org/apache/openejb/cdi/WebappBeanManager.java | 15 +++++++++++++++
tck/cdi-embedded/src/test/resources/failing.xml | 4 +++-
3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b154923e/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
index d9cf807..b4d2637 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBDeployableContainer.java
@@ -248,8 +248,8 @@ public class OpenEJBDeployableContainer implements DeployableContainer<OpenEJBCo
}
if (http == null) {
http = HTTPContext.class.cast(metaData.getContexts().iterator().next());
- http.add(new Servlet(path.substring(path.lastIndexOf('!') + 2).replace(".class", "").replace("/", "."), webapp.contextRoot));
}
+ http.add(new Servlet(path.substring(path.lastIndexOf('!') + 2).replace(".class", "").replace("/", "."), webapp.contextRoot));
}
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b154923e/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
index 5e361a5..1ca36b9 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/WebappBeanManager.java
@@ -37,11 +37,14 @@ import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.ObserverMethod;
import javax.enterprise.inject.spi.PassivationCapable;
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -70,6 +73,18 @@ public class WebappBeanManager extends BeanManagerImpl {
}
@Override
+ public List<Interceptor<?>> resolveInterceptors(final InterceptionType type, final Annotation... interceptorBindings) {
+ final List<Interceptor<?>> interceptors = super.resolveInterceptors(type, interceptorBindings);
+ final List<Interceptor<?>> parentInterceptors = getParentBm().resolveInterceptors(type, interceptorBindings);
+ for (final Interceptor<?> i : parentInterceptors) {
+ if (!interceptors.contains(i)) {
+ interceptors.add(i);
+ }
+ }
+ return interceptors;
+ }
+
+ @Override
public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(final T event, final EventMetadataImpl metadata) {
final Set<ObserverMethod<? super T>> set = new HashSet<>();
set.addAll(getNotificationManager().resolveObservers(event, metadata, false));
http://git-wip-us.apache.org/repos/asf/tomee/blob/b154923e/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index ad1d852..7a0af87 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -23,9 +23,11 @@
-Dopenejb.cdi.filter.classloader=false
-Dopenejb.http.mock-request=true
-Dopenejb.http.default-content-type=text/plain
+ -Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName}
-->
<classes>
- <class name="org.jboss.cdi.tck.tests.context.application.ApplicationContextTest" />
+ <!--<class name="org.jboss.cdi.tck.tests.interceptors.definition.broken.interceptorForLifecycleTargetMethod.InterceptorForLifecycleTargetMethodTest" />-->
+ <class name="org.jboss.cdi.tck.interceptors.tests.contract.interceptorLifeCycle.environment.jndi.InterceptorEnvironmentJNDITest" />
</classes>
</test>
</suite>
[2/2] tomee git commit: ensuring bindings in LightweightWebAppBuilder
have ejb module ones - surely a TODO in TomcatWebappBuilder + keeping empty
env values for comp since it can be a contextual lookup + adding our JTA
interceptors only in root app (lib
Posted by rm...@apache.org.
ensuring bindings in LightweightWebAppBuilder have ejb module ones - surely a TODO in TomcatWebappBuilder + keeping empty env values for comp since it can be a contextual lookup + adding our JTA interceptors only in root app (lib part for ears) + fallback on WebContext when a lookup fails in OWB ResourceInjectionService + supporting contextual lookup of module/ for ejbs - surely a todo to move it to WebContext + supporting web.xml for ear webapps in openejb embedded arquillian adapter
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cdf0aa55
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cdf0aa55
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cdf0aa55
Branch: refs/heads/develop
Commit: cdf0aa550f98e315503e59ffdd9676c578ea88cf
Parents: b154923
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Fri Dec 26 16:02:54 2014 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Fri Dec 26 16:02:54 2014 +0100
----------------------------------------------------------------------
.../openejb/OpenEJBArchiveProcessor.java | 39 +++++++------
.../openejb/assembler/classic/Assembler.java | 7 ++-
.../openejb/assembler/classic/JndiBuilder.java | 48 +++++++++++++++-
.../cdi/CdiResourceInjectionService.java | 59 ++++++++++++++++----
.../java/org/apache/openejb/cdi/CdiScanner.java | 14 +++--
.../apache/openejb/cdi/OpenEJBLifecycle.java | 4 +-
.../apache/openejb/config/CleanEnvEntries.java | 3 +
.../openejb/config/JndiEncInfoBuilder.java | 4 +-
.../java/org/apache/openejb/util/AppFinder.java | 14 +++++
.../openejb/web/LightweightWebAppBuilder.java | 13 ++++-
10 files changed, 160 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
index d3cce71..dfdbfab 100644
--- a/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
+++ b/arquillian/arquillian-openejb-embedded-5/src/main/java/org/apache/openejb/arquillian/openejb/OpenEJBArchiveProcessor.java
@@ -149,23 +149,7 @@ public class OpenEJBArchiveProcessor {
appModule.setDelegateFirst(false);
appModule.setStandloneWebModule();
- WebApp webApp;
- final Node webXml = archive.get(WEB_INF + "web.xml");
- if (webXml == null) {
- webApp = new WebApp();
- } else {
- InputStream inputStream = null;
- try {
- inputStream = webXml.getAsset().openStream();
- webApp = Sxc.unmarshalJavaee(new WebApp$JAXB(), inputStream);
- } catch (final Exception e) {
- webApp = new WebApp();
- } finally {
- IO.close(inputStream);
- }
- }
-
- final WebModule webModule = new WebModule(webApp, contextRoot(archive.getName()), loader, "", appModule.getModuleId());
+ final WebModule webModule = new WebModule(createWebApp(archive), contextRoot(archive.getName()), loader, "", appModule.getModuleId());
webModule.setUrls(additionalPaths);
appModule.getWebModules().add(webModule);
} else if (isEar) { // mainly for CDI TCKs
@@ -203,7 +187,7 @@ public class OpenEJBArchiveProcessor {
finderArchive(beansXml, webArchive, webLoader, webAppArchive, webAppClassesByUrl, webAppBeansXml));
final String contextRoot = contextRoot(webArchive.getName());
- final WebModule webModule = new WebModule(new WebApp(), contextRoot, webLoader, "", appModule.getModuleId() + "_" + contextRoot);
+ final WebModule webModule = new WebModule(createWebApp(webArchive), contextRoot, webLoader, "", appModule.getModuleId() + "_" + contextRoot);
webModule.setUrls(Collections.<URL>emptyList());
webModule.setScannableUrls(Collections.<URL>emptyList());
webModule.setFinder(finder);
@@ -304,6 +288,25 @@ public class OpenEJBArchiveProcessor {
return appModule;
}
+ private static WebApp createWebApp(final Archive<?> archive) {
+ WebApp webApp;
+ final Node webXml = archive.get(WEB_INF + "web.xml");
+ if (webXml == null) {
+ webApp = new WebApp();
+ } else {
+ InputStream inputStream = null;
+ try {
+ inputStream = webXml.getAsset().openStream();
+ webApp = Sxc.unmarshalJavaee(new WebApp$JAXB(), inputStream);
+ } catch (final Exception e) {
+ webApp = new WebApp();
+ } finally {
+ IO.close(inputStream);
+ }
+ }
+ return webApp;
+ }
+
private static CompositeArchive analyzeLibs(final ClassLoader parent,
final List<URL> additionalPaths, final Map<URL, List<String>> earMap,
final List<Archive> earLibsArchives,
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 5750ec0..dcfef92 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1268,7 +1268,12 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
final List<BeanContext> ejbs = sort(allDeployments);
- appContext.getBeanContexts().addAll(ejbs);
+ for (final BeanContext b : ejbs) { // otherwise for ears we have duplicated beans
+ if (appContext.getBeanContexts().contains(b)) {
+ continue;
+ }
+ appContext.getBeanContexts().add(b);
+ }
return ejbs;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
index a8cd0fe..10230f1 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
@@ -697,8 +697,8 @@ public class JndiBuilder {
if (intrface != null) {
beanName = beanName + "!" + intrface.getName();
}
+ final String globalName = "global/" + appName + moduleName + beanName;
try {
- final String globalName = "global/" + appName + moduleName + beanName;
if (embeddedEjbContainerApi
&& !(beanInfo instanceof ManagedBeanInfo && ((ManagedBeanInfo) beanInfo).hidden)) {
@@ -716,8 +716,17 @@ public class JndiBuilder {
appContext.bind("app/" + moduleName + beanName, ref);
application.getBindings().put("app/" + moduleName + beanName, ref);
- moduleContext.bind("module/" + beanName, ref);
- application.getBindings().put("module/" + beanName, ref);
+ final String moduleJndi = "module/" + beanName;
+ moduleContext.bind(moduleJndi, ref);
+
+ // contextual if the same ejb (api) is deployed in 2 wars of an ear
+ ContextualEjbLookup contextual = ContextualEjbLookup.class.cast(application.getBindings().get(moduleJndi));
+ if (contextual == null) {
+ final Map<BeanContext, Object> potentials = new HashMap<>();
+ contextual = new ContextualEjbLookup(potentials, ref);
+ application.getBindings().put(moduleJndi, contextual); // TODO: we shouldn't do it but use web bindings
+ }
+ contextual.potentials.put(cdi, ref);
}
@@ -767,4 +776,37 @@ public class JndiBuilder {
return aIsRmote ? 1 : -1;
}
}
+
+ public static class ContextualEjbLookup extends org.apache.openejb.core.ivm.naming.Reference {
+ private final Map<BeanContext, Object> potentials;
+ private final Object defaultValue;
+
+ public ContextualEjbLookup(final Map<BeanContext, Object> potentials, final Object defaultValue) {
+ this.potentials = potentials;
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public Object getObject() throws NamingException {
+ if (potentials.size() == 1) {
+ return unwrap(defaultValue);
+ }
+ final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader != null) {
+ for (final Map.Entry<BeanContext, Object> o : potentials.entrySet()) {
+ if (loader.equals(o.getKey().getClassLoader())) {
+ return unwrap(o.getValue());
+ }
+ }
+ }
+ return unwrap(defaultValue);
+ }
+
+ private Object unwrap(final Object value) throws NamingException {
+ if (org.apache.openejb.core.ivm.naming.Reference.class.isInstance(value)) { // pretty sure
+ return org.apache.openejb.core.ivm.naming.Reference.class.cast(value).getObject();
+ }
+ return value;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiResourceInjectionService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiResourceInjectionService.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiResourceInjectionService.java
index f7244c4..e43f793 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiResourceInjectionService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiResourceInjectionService.java
@@ -41,6 +41,7 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
public class CdiResourceInjectionService implements ResourceInjectionService {
@@ -49,14 +50,21 @@ public class CdiResourceInjectionService implements ResourceInjectionService {
private final CdiPlugin ejbPlugin;
private final List<BeanContext> compContexts = new ArrayList<BeanContext>();
private volatile AppContext appCtx;
+ private volatile boolean ear;
public CdiResourceInjectionService(final WebBeansContext context) {
ejbPlugin = CdiPlugin.class.cast(context.getPluginLoader().getEjbPlugin());
}
- public void setAppContext(final AppContext appModule) {
+ public void setAppContext(final AppContext appModule, final Collection<BeanContext> ejbs) {
+ compContexts.clear();
+ ear = false;
for (final BeanContext beanContext : appModule.getBeanContexts()) {
- if (beanContext.getBeanClass().equals(BeanContext.Comp.class)) {
+ if (!ear) {
+ ear = beanContext.getEjbName().contains("ear-scoped-cdi-beans_");
+ }
+ if (beanContext.getBeanClass().equals(BeanContext.Comp.class)
+ && (ejbs == null || ear || ejbs.contains(beanContext))) {
compContexts.add(beanContext);
}
}
@@ -130,8 +138,19 @@ public class CdiResourceInjectionService implements ResourceInjectionService {
final boolean usePrefix = true;
final Class<?> clazz = managedBeanInstance.getClass();
- for (final BeanContext beanContext : compContexts) {
-
+ Collection<BeanContext> comps;
+ WebBeansContext webBeansContext = null;
+ if (ear) { // let it be contextual, ie use webapp context (env-entries...) to create ear libs interceptors...
+ try {
+ webBeansContext = WebBeansContext.currentInstance();
+ comps = CdiResourceInjectionService.class.cast(webBeansContext.getService(ResourceInjectionService.class)).compContexts;
+ } catch (final Exception e) {
+ comps = compContexts;
+ }
+ } else {
+ comps = compContexts;
+ }
+ for (final BeanContext beanContext : comps) {
for (final Injection injection : beanContext.getInjections()) {
if (injection.getTarget() == null) {
continue;
@@ -139,19 +158,35 @@ public class CdiResourceInjectionService implements ResourceInjectionService {
if (!injection.getTarget().isAssignableFrom(clazz)) {
continue;
}
+
+ final String prefix;
+ if (usePrefix) {
+ prefix = injection.getTarget().getName() + "/";
+ } else {
+ prefix = "";
+ }
+
try {
final Object value = lookup(beanContext, injection);
- final String prefix;
- if (usePrefix) {
- prefix = injection.getTarget().getName() + "/";
- } else {
- prefix = "";
- }
-
objectRecipe.setProperty(prefix + injection.getName(), value);
} catch (final NamingException e) {
- logger.warning("Injection data not found in JNDI context: jndiName='" + injection.getJndiName() + "', target=" + injection.getTarget().getName() + "/" + injection.getName());
+ boolean found = false;
+ if (webBeansContext != null) {
+ for (final WebContext w : appCtx.getWebContexts()) {
+ if (w.getWebBeansContext() == webBeansContext) {
+ final Object value = w.getBindings().get(injection.getJndiName());
+ if (value != null) {
+ objectRecipe.setProperty(prefix + injection.getName(), value);
+ found = true;
+ }
+ break;
+ }
+ }
+ }
+ if (!found) {
+ logger.warning("Injection data not found in JNDI context: jndiName='" + injection.getJndiName() + "', target=" + injection.getTarget().getName() + "/" + injection.getName());
+ }
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
index 12155aa..04a7864 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java
@@ -96,12 +96,6 @@ public class CdiScanner implements ScannerService {
final WebBeansContext webBeansContext = startupObject.getWebBeansContext();
final InterceptorsManager interceptorsManager = webBeansContext.getInterceptorsManager();
- // "manual" extension to avoid to add it through SPI mecanism
- classes.addAll(asList(TRANSACTIONAL_INTERCEPTORS));
- for (final Class<?> interceptor : TRANSACTIONAL_INTERCEPTORS) {
- interceptorsManager.addEnabledInterceptorClass(interceptor);
- }
-
// app beans
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
final BeansInfo beans = ejbJar.beans;
@@ -118,6 +112,14 @@ public class CdiScanner implements ScannerService {
continue;
}
+ if (appInfo.webAppAlone || !ejbJar.webapp) {
+ // "manual" extension to avoid to add it through SPI mecanism
+ classes.addAll(asList(TRANSACTIONAL_INTERCEPTORS));
+ for (final Class<?> interceptor : TRANSACTIONAL_INTERCEPTORS) {
+ interceptorsManager.addEnabledInterceptorClass(interceptor);
+ }
+ }
+
// here for ears we need to skip classes in the parent classloader
final ClassLoader scl = ClassLoader.getSystemClassLoader();
final boolean filterByClassLoader = "true".equals(
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
index 6d0766a..142b107 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBLifecycle.java
@@ -63,6 +63,7 @@ import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Properties;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -163,7 +164,8 @@ public class OpenEJBLifecycle implements ContainerLifecycle {
//Resournce Injection Service
final CdiResourceInjectionService injectionService = (CdiResourceInjectionService) webBeansContext.getService(ResourceInjectionService.class);
- injectionService.setAppContext(stuff.getAppContext());
+ // todo use startupObject allDeployments to find Comp in priority (otherwise we can keep N times comps and loose time at injection time
+ injectionService.setAppContext(stuff.getAppContext(), stuff.getBeanContexts() != null ? stuff.getBeanContexts() : Collections.<BeanContext>emptyList());
//Deploy the beans
CdiScanner cdiScanner = null;
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/config/CleanEnvEntries.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/CleanEnvEntries.java b/container/openejb-core/src/main/java/org/apache/openejb/config/CleanEnvEntries.java
index 7984f17..8e258ea 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/CleanEnvEntries.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/CleanEnvEntries.java
@@ -79,6 +79,9 @@ public class CleanEnvEntries implements DynamicDeployer {
}
for (final EnterpriseBean consumer : ejbJar.getEnterpriseBeans()) {
+ if (CompManagedBean.class.isInstance(consumer)) { // unused can be used by CDI (ear lib using webapp contextual binding)
+ continue;
+ }
removeUnsetEnvEntries(appEnvEntryMap, consumer);
}
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
index d135309..2b57c46 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
@@ -360,7 +360,9 @@ public class JndiEncInfoBuilder {
for (final EnvEntry env : item.getEnvEntry()) {
// ignore env entries without a value and lookup name
//If the the reference name of the environment entry is belong to those shareable JNDI name space, it somewhat is a valid one
- if (env.getEnvEntryValue() == null && env.getLookupName() == null && !isShareableJNDINamespace(env.getEnvEntryName())) {
+ if (env.getEnvEntryValue() == null && env.getLookupName() == null
+ && !isShareableJNDINamespace(env.getEnvEntryName())
+ && !CompManagedBean.class.isInstance(item) /* in this case we can desire to contextually lookup webapp value from an ear lib */) {
continue;
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/util/AppFinder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/AppFinder.java b/container/openejb-core/src/main/java/org/apache/openejb/util/AppFinder.java
index 0a83a70..b07657d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/AppFinder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/AppFinder.java
@@ -79,6 +79,20 @@ public final class AppFinder {
}
}
+ public static class AppOrWebContextTransformer implements Transformer<Object> {
+ public static final Transformer<AppContext> INSTANCE = new AppContextTransformer();
+
+ @Override
+ public Object from(final AppContext appCtx) {
+ return appCtx;
+ }
+
+ @Override
+ public Object from(final WebContext webCtx) {
+ return webCtx;
+ }
+ }
+
private AppFinder() {
// no-op
}
http://git-wip-us.apache.org/repos/asf/tomee/blob/cdf0aa55/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
index 3befe49..be948e5 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/web/LightweightWebAppBuilder.java
@@ -127,7 +127,16 @@ public class LightweightWebAppBuilder implements WebAppBuilder {
final Set<Injection> injections = new HashSet<Injection>(appContext.getInjections());
injections.addAll(new InjectionBuilder(classLoader).buildInjections(webAppInfo.jndiEnc));
- final Map<String, Object> bindings = new HashMap<String, Object>();
+ final List<BeanContext> beanContexts;
+ if (!appInfo.webAppAlone) { // add module bindings in app
+ final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
+ beanContexts = assembler.initEjbs(classLoader, appInfo, appContext, injections, new ArrayList<BeanContext>(), webAppInfo.moduleId);
+ appContext.getBeanContexts().addAll(beanContexts);
+ } else {
+ beanContexts = null;
+ }
+
+ final Map<String, Object> bindings = new HashMap<>();
bindings.putAll(appContext.getBindings());
bindings.putAll(new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader, appInfo.properties).buildBindings(JndiEncBuilder.JndiScope.comp));
@@ -148,8 +157,6 @@ public class LightweightWebAppBuilder implements WebAppBuilder {
if (!appInfo.webAppAlone) {
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
- final List<BeanContext> beanContexts = assembler.initEjbs(classLoader, appInfo, appContext, injections, new ArrayList<BeanContext>(), webAppInfo.moduleId);
- appContext.getBeanContexts().addAll(beanContexts);
new CdiBuilder().build(appInfo, appContext, beanContexts, webContext);
assembler.startEjbs(true, beanContexts);
}