tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r543418 - in /incubator/openejb/trunk/openejb3: ./ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/config/ container/openejb-core/src/main/java/org/apache/openejb/core/mdb/ container/openejb-core/src/main/jav...
Date Fri, 01 Jun 2007 07:50:00 GMT
Author: dblevins
Date: Fri Jun  1 00:49:59 2007
New Revision: 543418

URL: http://svn.apache.org/viewvc?view=rev&rev=543418
Log:
Interceptor injection support

Modified:
    incubator/openejb/trunk/openejb3/container/openejb-core/pom.xml
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
    incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
    incubator/openejb/trunk/openejb3/pom.xml

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/pom.xml?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/pom.xml (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/pom.xml Fri Jun  1 00:49:59 2007
@@ -68,7 +68,7 @@
         <configuration>
           <forkMode>pertest</forkMode>
           <!-- DEBUG: Uncomment this line and comment out the next -->
-          <!--<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
-javaagent:${basedir}/target/openejb-javaagent-${version}.jar</argLine>-->
+          <!--<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
-javaagent:${basedir}/target/openejb-javaagent-${version}.jar -enableassertions</argLine>-->
           <argLine>-javaagent:${basedir}/target/openejb-javaagent-${version}.jar -enableassertions</argLine>
           <workingDirectory>${basedir}/target</workingDirectory>
           <systemProperties>

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Fri Jun  1 00:49:59 2007
@@ -731,6 +731,20 @@
                     ClassFinder inheritedClassFinder = createInheritedClassFinder(clazz);
 
                     processCallbacks(interceptor, inheritedClassFinder);
+
+                    buildAnnotatedRefs(interceptor, inheritedClassFinder);
+
+                    for (EnterpriseBean bean : enterpriseBeans) {
+                        // DMB: TODO, we should actually check to see if the ref exists in
the bean's enc.
+                        bean.getEnvEntry().addAll(interceptor.getEnvEntry());
+                        bean.getEjbRef().addAll(interceptor.getEjbRef());
+                        bean.getEjbLocalRef().addAll(interceptor.getEjbLocalRef());
+                        bean.getResourceRef().addAll(interceptor.getResourceRef());
+                        bean.getResourceEnvRef().addAll(interceptor.getResourceEnvRef());
+                        bean.getPersistenceContextRef().addAll(interceptor.getPersistenceContextRef());
+                        bean.getPersistenceUnitRef().addAll(interceptor.getPersistenceUnitRef());
+                        bean.getMessageDestinationRef().addAll(interceptor.getMessageDestinationRef());
+                    }
                 }
             }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbInstanceFactory.java
Fri Jun  1 00:49:59 2007
@@ -193,22 +193,9 @@
                 mdbContext = new MdbContext(transactionManager, securityService);
                 ctx.bind("java:comp/EJBContext",mdbContext);
             }
-            for (Injection injection : deploymentInfo.getInjections()) {
-                try {
-                    String jndiName = injection.getJndiName();
-                    Object object = ctx.lookup("java:comp/env/" + jndiName);
-                    if (object instanceof String) {
-                        String string = (String) object;
-                        // Pass it in raw so it could be potentially converted to
-                        // another data type by an xbean-reflect property editor
-                        objectRecipe.setProperty(injection.getName(), string);
-                    } else {
-                        objectRecipe.setProperty(injection.getName(), new StaticRecipe(object));
-                    }
-                } catch (NamingException e) {
-                    logger.warning("Injection data not found in enc: jndiName='"+injection.getJndiName()+"',
target="+injection.getTarget()+"/"+injection.getName());
-                }
-            }
+
+            fillInjectionProperties(objectRecipe, beanClass, deploymentInfo, ctx);
+
             // only in this case should the callback be used
             callContext.setCurrentOperation(Operation.INJECTION);
             callContext.setCurrentAllowedStates(MdbContext.getStates());
@@ -223,6 +210,11 @@
 
                 Class clazz = interceptorData.getInterceptorClass();
                 ObjectRecipe interceptorRecipe = new ObjectRecipe(clazz);
+                interceptorRecipe.allow(Option.FIELD_INJECTION);
+                interceptorRecipe.allow(Option.PRIVATE_PROPERTIES);
+                interceptorRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+
+                fillInjectionProperties(interceptorRecipe, clazz, deploymentInfo, ctx);
                 try {
                     Object interceptorInstance = interceptorRecipe.create(clazz.getClassLoader());
                     interceptorInstances.put(clazz.getName(), interceptorInstance);
@@ -267,6 +259,26 @@
             throw new UnavailableException(message, e);
         } finally {
             ThreadContext.exit(callContext);
+        }
+    }
+
+    private static void fillInjectionProperties(ObjectRecipe objectRecipe, Class clazz, CoreDeploymentInfo
deploymentInfo, Context context) {
+        for (Injection injection : deploymentInfo.getInjections()) {
+            if (!injection.getTarget().isAssignableFrom(clazz)) continue;
+            try {
+                String jndiName = injection.getJndiName();
+                Object object = context.lookup("java:comp/env/" + jndiName);
+                if (object instanceof String) {
+                    String string = (String) object;
+                    // Pass it in raw so it could be potentially converted to
+                    // another data type by an xbean-reflect property editor
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
string);
+                } else {
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
new StaticRecipe(object));
+                }
+            } catch (NamingException e) {
+                logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName()
+ "', target=" + injection.getTarget() + "/" + injection.getName());
+            }
         }
     }
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/StatefulInstanceManager.java
Fri Jun  1 00:49:59 2007
@@ -160,23 +160,11 @@
                 callContext.setCurrentOperation(Operation.INJECTION);
                 objectRecipe.setProperty("sessionContext", new StaticRecipe(sessionContext));
             }
-            for (Injection injection : deploymentInfo.getInjections()) {
-                try {
-                    String jndiName = injection.getJndiName();
-                    Object object = ctx.lookup("java:comp/env/" + jndiName);
-                    if (object instanceof String) {
-                        String string = (String) object;
-                        // Pass it in raw so it could be potentially converted to
-                        // another data type by an xbean-reflect property editor
-                        objectRecipe.setProperty(injection.getName(), string);
-                    } else {
-                        objectRecipe.setProperty(injection.getName(), new StaticRecipe(object));
-                    }
-                } catch (NamingException e) {
-                    logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName()
+ "', target=" + injection.getTarget() + "/" + injection.getName());
-                }
-            }
+
+            fillInjectionProperties(objectRecipe, beanClass, deploymentInfo, ctx);
+
             bean = objectRecipe.create(beanClass.getClassLoader());
+
             Map unsetProperties = objectRecipe.getUnsetProperties();
             if (unsetProperties.size() > 0) {
                 for (Object property : unsetProperties.keySet()) {
@@ -189,6 +177,12 @@
 
                 Class clazz = interceptorData.getInterceptorClass();
                 ObjectRecipe interceptorRecipe = new ObjectRecipe(clazz);
+                interceptorRecipe.allow(Option.FIELD_INJECTION);
+                interceptorRecipe.allow(Option.PRIVATE_PROPERTIES);
+                interceptorRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+
+                fillInjectionProperties(interceptorRecipe, clazz, deploymentInfo, ctx);
+
                 try {
                     Object interceptorInstance = interceptorRecipe.create(clazz.getClassLoader());
                     interceptorInstances.put(clazz.getName(), interceptorInstance);
@@ -226,6 +220,26 @@
         getBeanIndex(threadContext).put(primaryKey, entry);
 
         return bean;
+    }
+
+    private static void fillInjectionProperties(ObjectRecipe objectRecipe, Class clazz, CoreDeploymentInfo
deploymentInfo, Context context) {
+        for (Injection injection : deploymentInfo.getInjections()) {
+            if (!injection.getTarget().isAssignableFrom(clazz)) continue;
+            try {
+                String jndiName = injection.getJndiName();
+                Object object = context.lookup("java:comp/env/" + jndiName);
+                if (object instanceof String) {
+                    String string = (String) object;
+                    // Pass it in raw so it could be potentially converted to
+                    // another data type by an xbean-reflect property editor
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
string);
+                } else {
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
new StaticRecipe(object));
+                }
+            } catch (NamingException e) {
+                logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName()
+ "', target=" + injection.getTarget() + "/" + injection.getName());
+            }
+        }
     }
 
 

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessInstanceManager.java
Fri Jun  1 00:49:59 2007
@@ -123,23 +123,8 @@
                     wsContext = new EjbWebServiceContext(sessionContext);
                     ctx.bind("java:comp/WebServiceContext", wsContext);
                 }
-                
-                for (Injection injection : deploymentInfo.getInjections()) {
-                    try {
-                        String jndiName = injection.getJndiName();    
-                        Object object = ctx.lookup("java:comp/env/" + jndiName);
-                        if (object instanceof String) {
-                            String string = (String) object;
-                            // Pass it in raw so it could be potentially converted to
-                            // another data type by an xbean-reflect property editor
-                            objectRecipe.setProperty(injection.getName(), string);
-                        } else {
-                            objectRecipe.setProperty(injection.getName(), new StaticRecipe(object));
-                        }
-                    } catch (NamingException e) {
-                        logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName()
+ "', target=" + injection.getTarget() + "/" + injection.getName());
-                    }
-                }
+
+                fillInjectionProperties(objectRecipe, beanClass, deploymentInfo, ctx);
 
                 bean = objectRecipe.create(beanClass.getClassLoader());
                 Map unsetProperties = objectRecipe.getUnsetProperties();
@@ -155,6 +140,12 @@
 
                     Class clazz = interceptorData.getInterceptorClass();
                     ObjectRecipe interceptorRecipe = new ObjectRecipe(clazz);
+                    interceptorRecipe.allow(Option.FIELD_INJECTION);
+                    interceptorRecipe.allow(Option.PRIVATE_PROPERTIES);
+                    interceptorRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+
+                    fillInjectionProperties(interceptorRecipe, clazz, deploymentInfo, ctx);
+
                     try {
                         Object interceptorInstance = interceptorRecipe.create(clazz.getClassLoader());
                         interceptorInstances.put(clazz.getName(), interceptorInstance);
@@ -203,6 +194,26 @@
             }
         }
         return bean;
+    }
+
+    private static void fillInjectionProperties(ObjectRecipe objectRecipe, Class clazz, CoreDeploymentInfo
deploymentInfo, Context context) {
+        for (Injection injection : deploymentInfo.getInjections()) {
+            if (!injection.getTarget().isAssignableFrom(clazz)) continue;
+            try {
+                String jndiName = injection.getJndiName();
+                Object object = context.lookup("java:comp/env/" + jndiName);
+                if (object instanceof String) {
+                    String string = (String) object;
+                    // Pass it in raw so it could be potentially converted to
+                    // another data type by an xbean-reflect property editor
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
string);
+                } else {
+                    objectRecipe.setProperty(injection.getTarget().getName() + "/" + injection.getName(),
new StaticRecipe(object));
+                }
+            } catch (NamingException e) {
+                logger.warning("Injection data not found in enc: jndiName='" + injection.getJndiName()
+ "', target=" + injection.getTarget() + "/" + injection.getName());
+            }
+        }
     }
 
     private boolean hasSetSessionContext(Class beanClass) {

Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
(original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulContainerTest.java
Fri Jun  1 00:49:59 2007
@@ -194,7 +194,7 @@
         }
 
         @Resource
-        public void setSessionContext(SessionContext sessionContext){
+        public void setContext(SessionContext context){
             lifecycle.push(Lifecycle.INJECTION);
         }
 

Modified: incubator/openejb/trunk/openejb3/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/pom.xml?view=diff&rev=543418&r1=543417&r2=543418
==============================================================================
--- incubator/openejb/trunk/openejb3/pom.xml (original)
+++ incubator/openejb/trunk/openejb3/pom.xml Fri Jun  1 00:49:59 2007
@@ -646,7 +646,7 @@
       <dependency>
         <groupId>org.apache.xbean</groupId>
         <artifactId>xbean-reflect</artifactId>
-        <version>3.0-SNAPSHOT</version>
+        <version>3.1-SNAPSHOT</version>
         <exclusions>
           <exclusion>
             <groupId>mx4j</groupId>



Mime
View raw message