You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2011/09/19 12:32:36 UTC

svn commit: r1172560 - in /openejb/trunk/openejb3: assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-core/src/main/java/org/apach...

Author: dblevins
Date: Mon Sep 19 10:32:35 2011
New Revision: 1172560

URL: http://svn.apache.org/viewvc?rev=1172560&view=rev
Log:
Injection implements equals/hashcode and usage now mostly is done with a Set, so List references were changed to Collection
Make AppContext hold a list of injection points and map of jndi bindings
Make WebContext hold a list of jndi bindings which are built shortly before the WebContext is created
TomcatJndiBuilder simply takes the full map version of the bindings and adds them right into Tomcat
Special care is take to ensure all "built in" types such as UserTransaction or BeanManager always have a 'lookup'

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/LinkBuiltInTypes.java
Modified:
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatJndiBuilder.java
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/Injection.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/HandlerResolverImpl.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BuiltInEnvironmentEntriesTest.java

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatJndiBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatJndiBuilder.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatJndiBuilder.java (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatJndiBuilder.java Mon Sep 19 10:32:35 2011
@@ -28,9 +28,11 @@ import java.util.List;
 import java.util.Map;
 import javax.naming.Binding;
 import javax.naming.Context;
+import javax.naming.LinkRef;
 import javax.naming.NameAlreadyBoundException;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
+import javax.naming.RefAddr;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.transaction.UserTransaction;
@@ -45,10 +47,7 @@ import org.apache.catalina.deploy.Naming
 import org.apache.naming.ContextAccessController;
 import org.apache.naming.ContextBindings;
 import org.apache.naming.factory.Constants;
-import org.apache.openejb.AppContext;
-import org.apache.openejb.BeanContext;
 import org.apache.openejb.Injection;
-import org.apache.openejb.ModuleContext;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
 import org.apache.openejb.assembler.classic.EjbReferenceInfo;
@@ -62,6 +61,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
 import org.apache.openejb.assembler.classic.WebAppInfo;
 import org.apache.openejb.assembler.classic.WsBuilder;
+import org.apache.openejb.core.WebContext;
 import org.apache.openejb.core.webservices.HandlerChainData;
 import org.apache.openejb.core.webservices.PortRefData;
 import org.apache.openejb.loader.SystemInstance;
@@ -101,12 +101,12 @@ public class TomcatJndiBuilder {
 
     private final StandardContext standardContext;
     private final WebAppInfo webAppInfo;
-    private final List<Injection> injections;
+    private final Collection<Injection> injections;
     private final boolean replaceEntry;
     private boolean useCrossClassLoaderRef = true;
     private NamingContextListener namingContextListener;
 
-    public TomcatJndiBuilder(StandardContext standardContext, WebAppInfo webAppInfo, List<Injection> injections) {
+    public TomcatJndiBuilder(StandardContext standardContext, WebAppInfo webAppInfo, Collection<Injection> injections) {
         this.injections = injections;
         this.standardContext = standardContext;
         this.namingContextListener = BackportUtil.getNamingContextListener(standardContext);
@@ -180,113 +180,72 @@ public class TomcatJndiBuilder {
             path = path.substring(1);
         }
 
-        for (BeanContext bc : cs.deployments()) {
-            if (!(bc.getDeploymentID() instanceof String && ((String) bc.getDeploymentID()).startsWith(path))) {
-                continue;
-            }
-
-            ModuleContext mc = bc.getModuleContext();
-            AppContext ac = mc.getAppContext();
+        final WebContext webContext = cs.getWebContext(path);
 
-            Context moduleContext = mc.getModuleJndiContext();
+        for (Map.Entry<String, Object> entry : webContext.getBindings().entrySet()) {
             try {
-                copyContext("", moduleContext, root, mc.getUniqueId());
-            } catch (NamingException ignored) {
-                // no-op
+                final String key = entry.getKey();
+                Object value = normalize(entry.getValue());
+                mkdirs(root, key);
+                root.rebind(key, value);
+            } catch (NamingException e) {
+                e.printStackTrace();
             }
+        }
 
-            Context appContext = ac.getAppJndiContext();
-            try {
-                copyContext("", appContext, root, null);
-            } catch (NamingException ignored) {
-                // no-op
-            }
+        ContextAccessController.setReadOnly(standardContext.getNamingContextListener().getName());
+    }
 
-            Context globalContext = ac.getGlobalJndiContext();
-            try {
-                copyContext("", globalContext, root, null);
-            } catch (NamingException ignored) {
-                // no-op
+    /**
+     * LinkRef addresses need to be prefixed with java: or they won't resolve
+     *
+     * OpenEJB is fine with this, but Tomcat needs them
+     *
+     * @param value
+     * @return
+     */
+    private static Object normalize(final Object value) {
+        try {
+
+            if (!(value instanceof LinkRef)) return value;
+
+            final LinkRef ref = (LinkRef) value;
+
+            final RefAddr refAddr = ref.getAll().nextElement();
+
+            final String address = refAddr.getContent().toString();
+
+            if (!address.startsWith("java:")) {
+                return new LinkRef("java:" + address);
             }
+
+        } catch (Exception e) {
         }
 
-        ContextAccessController.setReadOnly(standardContext.getNamingContextListener().getName());
+        return value;
     }
 
-    private static void copyContext(String prefix, Context from, Context to, String linkPrefix) throws NamingException {
-        String usedPrefix;
-        if (prefix.isEmpty()) {
-            usedPrefix = prefix;
-        } else {
-            usedPrefix = prefix + "/";
-        }
+    private static void mkdirs(Context context, String key) {
+        final String[] parts = key.split("/");
+
+        int i = 0;
+        for (String part : parts) {
+            if (++i == parts.length) return;
 
-        NamingEnumeration<Binding> bindings = from.listBindings("");
-        while (bindings.hasMoreElements()) {
-            Binding binding = bindings.nextElement();
-            Object object = binding.getObject();
-            if (object instanceof Context) {
-                String contextPrefix = usedPrefix + binding.getName();
+            try {
+                context = context.createSubcontext(part);
+            } catch (NamingException e) {
                 try {
-                    to.createSubcontext(contextPrefix);
-                } catch (NameAlreadyBoundException ne) {
-                    // ignored
-                }
-                copyContext(contextPrefix, (Context) object, to, linkPrefix);
-            } else {
-                String name = usedPrefix + binding.getName();
-                if (linkPrefix == null) {
-                    try {
-                        to.bind(name, object);
-                    } catch (NamingException ne) {
-                        // ignored
-                    }
-                } else {
-                    String link = ContextValue.linkName(linkPrefix, name);
-
-                    // create subcontexts if necessary
-                    String[] contexts = link.split("/");
-                    String current = "";
-                    for (int i = 0; i < contexts.length - 1; i++) {
-                        if (current.isEmpty()) {
-                            current += contexts[i];
-                        } else {
-                            current += "/" + contexts[i];
-                        }
-                        try {
-                            to.createSubcontext(current);
-                        } catch (NameAlreadyBoundException ne) {
-                            // ignored
-                        }
-                    }
-
-                    to.bind(link, object);
-
-                    // don't do a lookup here because it is a link!
-                    Map<String, ContextValueHelper> contextValues = CONTEXT_VALUES.get(to);
-                    if (contextValues == null) {
-                        contextValues = new HashMap<String, ContextValueHelper>();
-                        CONTEXT_VALUES.put(to, contextValues);
-                    }
-                    ContextValueHelper cvh = contextValues.get(name);
-                    if (cvh == null) {
-                        cvh = new ContextValueHelper(name);
-                        ContextValue cv = cvh.contextValue;
-                        try {
-                            to.bind(name, cv);
-                            contextValues.put(name, cvh);
-                        } catch (NamingException ignored) {
-                            // ignored
-                        }
-                    }
-                    cvh.addValue(name, link);
+                    context = (Context) context.lookup(part);
+                } catch (NamingException e1) {
+                    return;
                 }
             }
         }
     }
 
     public void mergeRef(NamingResources naming, EnvEntryInfo ref) {
-
+//        if (!ref.referenceName.startsWith("comp/")) return;
         if ("java.lang.Class".equals(ref.type)) {
             ContextResourceEnvRef resourceEnv = new ContextResourceEnvRef();
             resourceEnv.setName(ref.referenceName.replaceAll("^comp/env/", ""));

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-catalina/src/main/java/org/apache/openejb/tomcat/catalina/TomcatWebAppBuilder.java Mon Sep 19 10:32:35 2011
@@ -45,6 +45,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.ConnectorInfo;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.assembler.classic.InjectionBuilder;
+import org.apache.openejb.assembler.classic.JndiEncBuilder;
 import org.apache.openejb.assembler.classic.WebAppBuilder;
 import org.apache.openejb.assembler.classic.WebAppInfo;
 import org.apache.openejb.config.AppModule;
@@ -414,6 +415,7 @@ public class TomcatWebAppBuilder impleme
         AppContext appContext = null;
         //Look for context info, maybe context is already scanned
         ContextInfo contextInfo = getContextInfo(standardContext);
+        final ClassLoader classLoader = standardContext.getLoader().getClassLoader();
         if (contextInfo == null) {
             AppModule appModule = loadApplication(standardContext);
             if (appModule != null) {
@@ -422,7 +424,7 @@ public class TomcatWebAppBuilder impleme
                     AppInfo appInfo = configurationFactory.configureApplication(appModule);
                     contextInfo.appInfo = appInfo;
 
-                    appContext = a.createApplication(contextInfo.appInfo, standardContext.getLoader().getClassLoader());
+                    appContext = a.createApplication(contextInfo.appInfo, classLoader);
                     // todo add watched resources to context
                 } catch (Exception e) {
                     logger.error("Unable to deploy collapsed ear in war " + standardContext.getPath() + ": Exception: " + e.getMessage(), e);
@@ -461,24 +463,31 @@ public class TomcatWebAppBuilder impleme
             }
 
             try {
+
                 // determine the injections
-                InjectionBuilder injectionBuilder = new InjectionBuilder(standardContext.getLoader().getClassLoader());
-                List<Injection> injections = injectionBuilder.buildInjections(webAppInfo.jndiEnc);
+                final Set<Injection> injections = new HashSet<Injection>();
+                injections.addAll(appContext.getInjections());
+                injections.addAll(new InjectionBuilder(classLoader).buildInjections(webAppInfo.jndiEnc));
+
+                // jndi bindings
+                final Map<String, Object> bindings = new HashMap<String, Object>();
+                bindings.putAll(appContext.getBindings());
+                bindings.putAll(getJndiBuilder(classLoader, webAppInfo, injections).buildBindings(JndiEncBuilder.JndiScope.comp));
 
                 // merge OpenEJB jndi into Tomcat jndi
-                TomcatJndiBuilder jndiBuilder = new TomcatJndiBuilder(standardContext, webAppInfo, injections);
+                final TomcatJndiBuilder jndiBuilder = new TomcatJndiBuilder(standardContext, webAppInfo, injections);
                 jndiBuilder.mergeJndi();
 
                 // add WebDeploymentInfo to ContainerSystem
                 final WebContext webContext = new WebContext(appContext);
+                webContext.setClassLoader(classLoader);
                 webContext.setId(webAppInfo.moduleId);
-                final StandardContext context = standardContext;
-                webContext.setClassLoader(context.getLoader().getClassLoader());
+                webContext.setBindings(bindings);
                 webContext.getInjections().addAll(injections);
                 appContext.getWebContexts().add(webContext);
                 cs.addWebContext(webContext);
 
-                standardContext.setInstanceManager(new JavaeeInstanceManager(webContext, context));
+                standardContext.setInstanceManager(new JavaeeInstanceManager(webContext, standardContext));
                 standardContext.getServletContext().setAttribute(InstanceManager.class.getName(), standardContext.getInstanceManager());
 
             } catch (Exception e) {
@@ -499,6 +508,10 @@ public class TomcatWebAppBuilder impleme
         }
     }
 
+    private JndiEncBuilder getJndiBuilder(ClassLoader classLoader, WebAppInfo webAppInfo, Set<Injection> injections) throws OpenEJBException {
+        return new JndiEncBuilder(webAppInfo.jndiEnc, injections, webAppInfo.moduleId, "Bean", null, webAppInfo.uniqueId, classLoader);
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java Mon Sep 19 10:32:35 2011
@@ -24,7 +24,11 @@ import org.apache.webbeans.config.WebBea
 import javax.enterprise.inject.spi.BeanManager;
 import javax.naming.Context;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
@@ -44,13 +48,15 @@ public class AppContext extends Deployme
     private final Context appJndiContext;
     private final boolean standaloneModule;
     private WebBeansContext webBeansContext;
+    private final Collection<Injection> injections = new HashSet<Injection>();
+    private final Map<String, Object> bindings = new HashMap<String, Object>();
 
     private BlockingQueue<Runnable> blockingQueue;
     private ExecutorService asynchPool;
 
     // TODO perhaps to be deleted
     private final List<BeanContext> beanContexts = new ArrayList<BeanContext>();
-    private final List<WebContext> webcontexts = new ArrayList<WebContext>();
+    private final List<WebContext> webContexts = new ArrayList<WebContext>();
 
     public AppContext(String id, SystemInstance systemInstance, ClassLoader classLoader, Context globalJndiContext, Context appJndiContext, boolean standaloneModule) {
         super(id, systemInstance.getOptions());
@@ -63,6 +69,14 @@ public class AppContext extends Deployme
         this.asynchPool = new ThreadPoolExecutor(10, 20, 60, TimeUnit.SECONDS, blockingQueue, new DaemonThreadFactory("@Asynch", id));
     }
 
+    public Collection<Injection> getInjections() {
+        return injections;
+    }
+
+    public Map<String, Object> getBindings() {
+        return bindings;
+    }
+
     public BeanManager getBeanManager() {
         return webBeansContext.getBeanManagerImpl();
     }
@@ -76,7 +90,7 @@ public class AppContext extends Deployme
     }
 
     public List<WebContext> getWebContexts() {
-        return webcontexts;
+        return webContexts;
     }
 
     @Override

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/Injection.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/Injection.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/Injection.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/Injection.java Mon Sep 19 10:32:35 2011
@@ -50,4 +50,24 @@ public class Injection {
                 ", jndiName='" + jndiName + '\'' +
                 '}';
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof Injection)) return false;
+
+        Injection injection = (Injection) o;
+
+        if (name != null ? !name.equals(injection.name) : injection.name != null) return false;
+        if (target != null ? !target.equals(injection.target) : injection.target != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = target != null ? target.hashCode() : 0;
+        result = 31 * result + (name != null ? name.hashCode() : 0);
+        return result;
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Mon Sep 19 10:32:35 2011
@@ -61,7 +61,6 @@ import javax.resource.spi.ResourceAdapte
 import javax.resource.spi.ResourceAdapterInternalException;
 import javax.resource.spi.XATerminator;
 import javax.resource.spi.work.WorkManager;
-import javax.sql.DataSource;
 import javax.transaction.TransactionManager;
 import javax.transaction.TransactionSynchronizationRegistry;
 import javax.validation.ValidationException;
@@ -85,7 +84,6 @@ import org.apache.openejb.NoSuchApplicat
 import org.apache.openejb.OpenEJB;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.UndeployException;
-import org.apache.openejb.assembler.dynamic.PassthroughFactory;
 import org.apache.openejb.cdi.CdiAppContextsService;
 import org.apache.openejb.cdi.CdiBuilder;
 import org.apache.openejb.cdi.CdiResourceInjectionService;
@@ -529,11 +527,19 @@ public class Assembler extends Assembler
         }
 
         //Construct the global and app jndi contexts for this app
-        InjectionBuilder injectionBuilder = new InjectionBuilder(classLoader);
-        List<Injection> appInjections = injectionBuilder.buildInjections(appInfo.globalJndiEnc);
-        appInjections.addAll(injectionBuilder.buildInjections(appInfo.appJndiEnc));
-        Context globalJndiContext = new JndiEncBuilder(appInfo.globalJndiEnc, appInjections, null, null, GLOBAL_UNIQUE_ID, classLoader).build(JndiEncBuilder.JndiScope.global);
-        Context appJndiContext = new JndiEncBuilder(appInfo.appJndiEnc, appInjections, appInfo.appId, null, appInfo.appId, classLoader).build(JndiEncBuilder.JndiScope.app);
+        final InjectionBuilder injectionBuilder = new InjectionBuilder(classLoader);
+
+        Set<Injection> injections = new HashSet<Injection>();
+        injections.addAll(injectionBuilder.buildInjections(appInfo.globalJndiEnc));
+        injections.addAll(injectionBuilder.buildInjections(appInfo.appJndiEnc));
+
+        final JndiEncBuilder globalBuilder = new JndiEncBuilder(appInfo.globalJndiEnc, injections, null, null, GLOBAL_UNIQUE_ID, classLoader);
+        final Map<String, Object> globalBindings = globalBuilder.buildBindings(JndiEncBuilder.JndiScope.global);
+        final Context globalJndiContext = globalBuilder.build(globalBindings);
+
+        final JndiEncBuilder appBuilder = new JndiEncBuilder(appInfo.appJndiEnc, injections, appInfo.appId, null, appInfo.appId, classLoader);
+        final Map<String, Object> appBindings = appBuilder.buildBindings(JndiEncBuilder.JndiScope.app);
+        final Context appJndiContext = appBuilder.build(appBindings);
 
         try {
             // Generate the cmp2/cmp1 concrete subclasses
@@ -543,10 +549,14 @@ public class Assembler extends Assembler
                 classLoader = ClassLoaderUtil.createClassLoader(appInfo.path, new URL []{generatedJar.toURI().toURL()}, classLoader);
             }
 
-            AppContext appContext = new AppContext(appInfo.appId, SystemInstance.get(), classLoader, globalJndiContext, appJndiContext, appInfo.standaloneModule);
+            final AppContext appContext = new AppContext(appInfo.appId, SystemInstance.get(), classLoader, globalJndiContext, appJndiContext, appInfo.standaloneModule);
+            appContext.getInjections().addAll(injections);
+            appContext.getBindings().putAll(globalBindings);
+            appContext.getBindings().putAll(appBindings);
+
             containerSystem.addAppContext(appContext);
 
-            Context containerSystemContext = containerSystem.getJNDIContext();
+            final Context containerSystemContext = containerSystem.getJNDIContext();
             
             if (!SystemInstance.get().hasProperty("openejb.geronimo")) {
                 // Bean Validation
@@ -626,7 +636,7 @@ public class Assembler extends Assembler
             // EJB
             EjbJarBuilder ejbJarBuilder = new EjbJarBuilder(props, appContext);
             for (EjbJarInfo ejbJar : appInfo.ejbJars) {
-                HashMap<String, BeanContext> deployments = ejbJarBuilder.build(ejbJar, appInjections);
+                HashMap<String, BeanContext> deployments = ejbJarBuilder.build(ejbJar, injections);
 
                 JaccPermissionsBuilder jaccPermissionsBuilder = new JaccPermissionsBuilder();
                 PolicyContext policyContext = jaccPermissionsBuilder.build(ejbJar, deployments);
@@ -723,6 +733,7 @@ public class Assembler extends Assembler
             ensureWebBeansContext(appContext);
 
             appJndiContext.bind("app/BeanManager", appContext.getBeanManager());
+            appContext.getBindings().put("app/BeanManager", appContext.getBeanManager());
 
             // now that everything is configured, deploy to the container
             if (start) {
@@ -757,10 +768,10 @@ public class Assembler extends Assembler
             // App Client
             for (ClientInfo clientInfo : appInfo.clients) {
                 // determine the injections
-                List<Injection> injections = injectionBuilder.buildInjections(clientInfo.jndiEnc);
+                List<Injection> clientInjections = injectionBuilder.buildInjections(clientInfo.jndiEnc);
 
                 // build the enc
-                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, injections, "Bean", clientInfo.moduleId, null, clientInfo.uniqueId, classLoader);
+                JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(clientInfo.jndiEnc, clientInjections, "Bean", clientInfo.moduleId, null, clientInfo.uniqueId, classLoader);
                 // if there is at least a remote client classes
                 // or if there is no local client classes
                 // then, we can set the client flag
@@ -784,7 +795,7 @@ public class Assembler extends Assembler
                 if (clientInfo.callbackHandler != null) {
                     context.bind("info/callbackHandler", clientInfo.callbackHandler);
                 }
-                context.bind("info/injections", injections);
+                context.bind("info/injections", clientInjections);
 
                 for (String clientClassName : clientInfo.remoteClients) {
                     containerSystemContext.bind("openejb/client/" + clientClassName, clientInfo.moduleId);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EjbJarBuilder.java Mon Sep 19 10:32:35 2011
@@ -26,6 +26,7 @@ import org.apache.openejb.util.Messages;
 
 import javax.naming.Context;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Properties;
@@ -44,7 +45,7 @@ public class EjbJarBuilder {
         this.context = context;
     }
 
-    public HashMap<String, BeanContext> build(EjbJarInfo ejbJar, List<Injection> appInjections) throws OpenEJBException {
+    public HashMap<String, BeanContext> build(EjbJarInfo ejbJar, Collection<Injection> appInjections) throws OpenEJBException {
         InjectionBuilder injectionBuilder = new InjectionBuilder(context.getClassLoader());
         List<Injection> moduleInjections = injectionBuilder.buildInjections(ejbJar.moduleJndiEnc);
         moduleInjections.addAll(appInjections);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java Mon Sep 19 10:32:35 2011
@@ -26,6 +26,7 @@ import javax.naming.NameAlreadyBoundExce
 import javax.naming.Context;
 import javax.jms.MessageListener;
 
+import org.apache.openejb.AppContext;
 import org.apache.openejb.BeanContext;
 import org.apache.openejb.InterfaceType;
 import org.apache.openejb.ModuleContext;
@@ -611,11 +612,14 @@ public class JndiBuilder {
     //ee6 specified ejb bindings in module, app, and global contexts
 
     private void bindJava(BeanContext cdi, Class intrface, Reference ref, Bindings bindings, EnterpriseBeanInfo beanInfo) throws NamingException {
-        Context moduleContext = cdi.getModuleContext().getModuleJndiContext();
-        Context appContext = cdi.getModuleContext().getAppContext().getAppJndiContext();
-        Context globalContext = cdi.getModuleContext().getAppContext().getGlobalJndiContext();
+        final ModuleContext module = cdi.getModuleContext();
+        final AppContext application = module.getAppContext();
 
-        String appName = cdi.getModuleContext().getAppContext().isStandaloneModule() ? "" : cdi.getModuleContext().getAppContext().getId() + "/";
+        Context moduleContext = module.getModuleJndiContext();
+        Context appContext = application.getAppJndiContext();
+        Context globalContext = application.getGlobalJndiContext();
+
+        String appName = application.isStandaloneModule() ? "" : application.getId() + "/";
         String moduleName = cdi.getModuleName() + "/";
         String beanName = cdi.getEjbName();
         if (intrface != null) {
@@ -628,15 +632,19 @@ public class JndiBuilder {
                 logger.info(String.format("Jndi(name=\"java:%s\")", globalName));
             }
             globalContext.bind(globalName, ref);
+            application.getBindings().put(globalName, ref);
+
             bind("openejb/global/" + globalName, ref, bindings, beanInfo, intrface);
         } catch (NameAlreadyBoundException e) {
             //one interface in more than one role (e.g. both Local and Remote
             return;
         }
-        
+
         appContext.bind("app/" + moduleName + beanName, ref);
-        
+        application.getBindings().put("app/" + moduleName + beanName, ref);
+
         moduleContext.bind("module/" + beanName, ref);
+        application.getBindings().put("module/" + beanName, ref);
     }
     
     

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java Mon Sep 19 10:32:35 2011
@@ -19,6 +19,7 @@ package org.apache.openejb.assembler.cla
 import org.apache.openejb.Injection;
 import org.apache.openejb.InterfaceType;
 import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.SystemException;
 import org.apache.openejb.core.CoreUserTransaction;
 import org.apache.openejb.core.JndiFactory;
 import org.apache.openejb.core.TransactionSynchronizationRegistryWrapper;
@@ -73,6 +74,7 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -96,17 +98,17 @@ public class JndiEncBuilder {
     private final URI moduleUri;
     private final String moduleId;
     private final String uniqueId;
-    private final List<Injection> injections;
+    private final Collection<Injection> injections;
     private final ClassLoader classLoader;
 
     private boolean useCrossClassLoaderRef = true;
     private boolean client = false;
 
-    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String moduleId, URI moduleUri, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
+    public JndiEncBuilder(JndiEncInfo jndiEnc, Collection<Injection> injections, String moduleId, URI moduleUri, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
         this(jndiEnc, injections, null, moduleId, moduleUri, uniqueId, classLoader);
     }
 
-    public JndiEncBuilder(JndiEncInfo jndiEnc, List<Injection> injections, String transactionType, String moduleId, URI moduleUri, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
+    public JndiEncBuilder(JndiEncInfo jndiEnc, Collection<Injection> injections, String transactionType, String moduleId, URI moduleUri, String uniqueId, ClassLoader classLoader) throws OpenEJBException {
         this.jndiEnc = jndiEnc;
         this.injections = injections;
         beanManagedTransactions = transactionType != null && transactionType.equalsIgnoreCase("Bean");
@@ -135,12 +137,22 @@ public class JndiEncBuilder {
     }
 
     public Context build(JndiScope type) throws OpenEJBException {
+        Map<String, Object> bindings = buildBindings(type);
+
+        return build(bindings);
+    }
+
+    public Context build(Map<String, Object> bindings) throws SystemException {
         JndiFactory jndiFactory = SystemInstance.get().getComponent(JndiFactory.class);
 
         if (SystemInstance.get().hasProperty("openejb.geronimo")) {
             return jndiFactory.createComponentContext(new HashMap());
         }
 
+        return jndiFactory.createComponentContext(bindings);
+    }
+
+    public Map<String, Object> buildBindings(JndiScope type) throws OpenEJBException {
         Map<String, Object> bindings = buildMap();
         switch (type) {
             case comp:
@@ -156,8 +168,7 @@ public class JndiEncBuilder {
                 addSpecialGlobalBindings(bindings);
                 break;
         }
-
-        return jndiFactory.createComponentContext(bindings);
+        return bindings;
     }
 
     public Map<String, Object> buildMap() throws OpenEJBException {
@@ -321,7 +332,7 @@ public class JndiEncBuilder {
 
                 // TODO Bind the BeanManager
             } else if (BeanManager.class.equals(type)) {
-                String jndiName = "app/BeanManager";
+                String jndiName = "java:app/BeanManager";
                 reference = new LinkRef(jndiName);
 
             } else if (UserTransaction.class.equals(type)) {
@@ -495,9 +506,9 @@ public class JndiEncBuilder {
     }
 
     private void addSpecialModuleBindings(Map<String, Object> bindings) {
-//        if (moduleId != null) {
-//            bindings.put("module/ModuleName", moduleId);
-//        }
+        if (moduleId != null) {
+            bindings.put("module/ModuleName", moduleId);
+        }
         // ensure the bindings will be non-empty
         if (bindings.isEmpty()) {
             bindings.put("module/dummy", "dummy");
@@ -505,9 +516,9 @@ public class JndiEncBuilder {
     }
 
     private void addSpecialAppBindings(Map<String, Object> bindings) {
-//        if (moduleId != null) {
-//            bindings.put("app/AppName", moduleId);
-//        }
+        if (moduleId != null) {
+            bindings.put("app/AppName", moduleId);
+        }
         // ensure the bindings will be non-empty
         if (bindings.isEmpty()) {
             bindings.put("app/dummy", "dummy");

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Mon Sep 19 10:32:35 2011
@@ -1199,6 +1199,9 @@ public class AnnotationDeployer implemen
                 if (enterpriseBean instanceof SessionBean) {
                     SessionBean sessionBean = (SessionBean) enterpriseBean;
                     sessionBean.setSessionType(SessionType.MANAGED);
+
+                    final TransactionType transactionType = sessionBean.getTransactionType();
+                    if (transactionType == null) sessionBean.setTransactionType(TransactionType.BEAN);
                 }
             }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Mon Sep 19 10:32:35 2011
@@ -188,6 +188,7 @@ public class ConfigurationFactory implem
 
         chain.add(new ConvertDataSourceDefinitions());
         chain.add(new CleanEnvEntries());
+        chain.add(new LinkBuiltInTypes());
 
         if (offline) {
             AutoConfig autoConfig = new AutoConfig(this);

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/LinkBuiltInTypes.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/LinkBuiltInTypes.java?rev=1172560&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/LinkBuiltInTypes.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/LinkBuiltInTypes.java Mon Sep 19 10:32:35 2011
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.config;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.JndiReference;
+import org.apache.openejb.jee.ResourceRef;
+
+import javax.ejb.EJBContext;
+import javax.ejb.EntityContext;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.SessionContext;
+import javax.ejb.TimerService;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.UserTransaction;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.xml.ws.WebServiceContext;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LinkBuiltInTypes implements DynamicDeployer {
+
+    @Override
+    public AppModule deploy(AppModule appModule) throws OpenEJBException {
+
+        for (ClientModule module : appModule.getClientModules()) {
+            final JndiConsumer consumer = module.getApplicationClient();
+            if (consumer == null) continue;
+
+            link(consumer);
+        }
+
+        for (WebModule module : appModule.getWebModules()) {
+            final JndiConsumer consumer = module.getWebApp();
+            if (consumer == null) continue;
+
+            link(consumer);
+        }
+
+        for (EjbModule module : appModule.getEjbModules()) {
+            final EjbJar ejbJar = module.getEjbJar();
+            if (ejbJar == null) continue;
+
+            for (EnterpriseBean consumer : ejbJar.getEnterpriseBeans()) {
+                link(consumer);
+            }
+        }
+
+        return appModule;
+
+    }
+
+    private void link(JndiConsumer consumer) {
+
+
+        Map<String, String> links = new HashMap<String, String>();
+
+        add(links, BeanManager.class);
+        add(links, Validator.class);
+        add(links, ValidatorFactory.class);
+        add(links, EJBContext.class, EntityContext.class, SessionContext.class, MessageDrivenContext.class);
+        add(links, UserTransaction.class);
+        add(links, TransactionManager.class);
+        add(links, TransactionSynchronizationRegistry.class);
+        add(links, TimerService.class);
+        add(links, WebServiceContext.class);
+
+        List<JndiReference> refs = new ArrayList<JndiReference>();
+        refs.addAll(consumer.getResourceRef());
+        refs.addAll(consumer.getResourceEnvRef());
+
+        for (JndiReference ref : refs) {
+            final String link = links.get(ref.getType());
+
+            if (link == null) continue;
+
+            if (ref.getName().equals(link)) {
+                // make sure the user hasn't linked it to itself or anything else
+                ref.setLookupName(null);
+                continue;
+            }
+
+            ref.setLookupName(link);
+        }
+    }
+
+    private void add(Map<String, String> links, Class<?> type, Class... aliases) {
+        links.put(type.getName(), "java:comp/"+type.getSimpleName());
+
+        for (Class clazz : aliases) {
+            links.put(clazz.getName(), "java:comp/"+type.getSimpleName());
+        }
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/WebContext.java Mon Sep 19 10:32:35 2011
@@ -36,6 +36,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Map;
 
 public class WebContext {
     private String id;
@@ -43,6 +44,7 @@ public class WebContext {
     private final Collection<Injection> injections = new ArrayList<Injection>();
     private Context jndiEnc;
     private final AppContext appContext;
+    private Map<String,Object> bindings;
 
     public WebContext(AppContext appContext) {
         this.appContext = appContext;
@@ -165,4 +167,11 @@ public class WebContext {
         }
     }
 
+    public void setBindings(Map<String, Object> bindings) {
+        this.bindings = bindings;
+    }
+
+    public Map<String, Object> getBindings() {
+        return bindings;
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/JaxWsServiceReference.java Mon Sep 19 10:32:35 2011
@@ -34,6 +34,7 @@ import javax.xml.ws.handler.HandlerResol
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,11 +48,11 @@ public class JaxWsServiceReference exten
     private final Class<?> referenceClass;
     private final URL wsdlUrl;
     private final List<HandlerChainData> handlerChains = new ArrayList<HandlerChainData>();
-    private final List<Injection> injections;
+    private final Collection<Injection> injections;
     private PortAddressRegistry portAddressRegistry;
     private final List<PortRefData> portRefs = new ArrayList<PortRefData>();
 
-    public JaxWsServiceReference(String id, QName serviceQName, Class<? extends Service> serviceClass, QName portQName, Class<?> referenceClass, URL wsdlUrl, List<PortRefData> portRefs, List<HandlerChainData> handlerChains, List<Injection> injections) {
+    public JaxWsServiceReference(String id, QName serviceQName, Class<? extends Service> serviceClass, QName portQName, Class<?> referenceClass, URL wsdlUrl, List<PortRefData> portRefs, List<HandlerChainData> handlerChains, Collection<Injection> injections) {
         this.id = id;
         this.serviceQName = serviceQName;
         this.serviceClass = serviceClass;

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/HandlerResolverImpl.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/HandlerResolverImpl.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/HandlerResolverImpl.java Mon Sep 19 10:32:35 2011
@@ -28,17 +28,18 @@ import javax.xml.ws.handler.HandlerResol
 import javax.xml.ws.handler.LogicalHandler;
 import javax.xml.ws.handler.PortInfo;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
 public class HandlerResolverImpl implements HandlerResolver {
     private final List<HandlerChainData> handlerChains;
-    private final List<Injection> injections;
+    private final Collection<Injection> injections;
     private final Context context;
     private final List<InjectionProcessor<Handler>> handlerInstances = new ArrayList<InjectionProcessor<Handler>>();
 
-    public HandlerResolverImpl(List<HandlerChainData> handlerChains, List<Injection> injections, Context context) {
+    public HandlerResolverImpl(List<HandlerChainData> handlerChains, Collection<Injection> injections, Context context) {
         this.handlerChains = handlerChains;
         this.injections = injections;
         this.context = context;

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BuiltInEnvironmentEntriesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BuiltInEnvironmentEntriesTest.java?rev=1172560&r1=1172559&r2=1172560&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BuiltInEnvironmentEntriesTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/BuiltInEnvironmentEntriesTest.java Mon Sep 19 10:32:35 2011
@@ -47,16 +47,24 @@ public class BuiltInEnvironmentEntriesTe
     @EJB
     private Blue blue;
 
+    @EJB
+    private Red red;
+
     @Module
-    public SingletonBean fantastic() {
-        return new SingletonBean(Blue.class);
+    public Class[] fantastic() {
+        return new Class[]{Blue.class, Red.class};
     }
 
     @Test
-    public void test() throws Exception {
+    public void testBlue() throws Exception {
         blue.test();
     }
 
+    @Test
+    public void testRed() throws Exception {
+        red.test();
+    }
+
     @Singleton
     @TransactionManagement(value = TransactionManagementType.BEAN)
     public static class Blue {
@@ -106,4 +114,41 @@ public class BuiltInEnvironmentEntriesTe
         }
 
     }
+
+    @Singleton
+    @TransactionManagement(value = TransactionManagementType.BEAN)
+    public static class Red {
+
+        @Resource
+        private EJBContext ejbContext;
+
+        @Resource
+        private Validator validator;
+
+        @Resource
+        private ValidatorFactory validatorFactory;
+
+        @Resource
+        private TransactionManager transactionManager;
+
+        @Resource
+        private TransactionSynchronizationRegistry transactionSynchronizationRegistry;
+
+        @Resource
+        private UserTransaction userTransaction;
+
+        @Resource
+        private BeanManager beanManager;
+
+        public void test() throws Exception {
+
+            final Field[] fields = this.getClass().getDeclaredFields();
+
+            for (Field field : fields) {
+                SetAccessible.on(field);
+                Assert.assertNotNull(field.getName(), field.get(this));
+            }
+        }
+
+    }
 }