geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r512007 [1/2] - in /geronimo/server/trunk: ./ modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/ modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ modules/geronimo-corba-bu...
Date Mon, 26 Feb 2007 20:52:08 GMT
Author: djencks
Date: Mon Feb 26 12:52:05 2007
New Revision: 512007

URL: http://svn.apache.org/viewvc?view=rev&rev=512007
Log:
GERONIMO-2887 Start hooking up injection for jetty

Added:
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java   (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisServiceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
    geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6/pom.xml
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InjectionServletHandler.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletRegistration.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml
    geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
    geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
    geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisServiceRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisServiceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-axis-builder/src/main/java/org/apache/geronimo/axis/builder/AxisServiceRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -68,25 +68,26 @@
     protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) {
         return specDD.selectChildren(serviceRefQNameSet).length > 0;
     }
-    
+
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
         List<ServiceRefType> serviceRefsUntyped = convert(specDD.selectChildren(serviceRefQNameSet), JEE_CONVERTER, ServiceRefType.class, ServiceRefType.type);
-        XmlObject[] gerServiceRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_SERVICE_REF_QNAME_SET);
+        XmlObject[] gerServiceRefsUntyped = plan == null ? NO_REFS : plan.selectChildren(GER_SERVICE_REF_QNAME_SET);
         Map serviceRefMap = mapServiceRefs(gerServiceRefsUntyped);
-       
-        for (ServiceRefType serviceRef: serviceRefsUntyped) {
+
+        for (ServiceRefType serviceRef : serviceRefsUntyped) {
             String name = getStringValue(serviceRef.getServiceRefName());
+            addInjections(name, serviceRef.getInjectionTargetArray(), componentContext);
             GerServiceRefType serviceRefType = (GerServiceRefType) serviceRefMap.get(name);
             buildNaming(serviceRef, serviceRefType, module, componentContext);
         }
     }
 
     public void buildNaming(XmlObject serviceRef, GerServiceRefType gerServiceRefType, Module module, Map componentContext) throws DeploymentException {
-        ServiceRefType serviceRefType = 
-            (ServiceRefType)convert(serviceRef, JEE_CONVERTER, ServiceRefType.type);
+        ServiceRefType serviceRefType =
+                (ServiceRefType) convert(serviceRef, JEE_CONVERTER, ServiceRefType.type);
         buildNaming(serviceRefType, gerServiceRefType, module, componentContext);
     }
-    
+
     private void buildNaming(ServiceRefType serviceRef, GerServiceRefType serviceRefType, Module module, Map componentContext) throws DeploymentException {
         String name = getStringValue(serviceRef.getServiceRefName());
         ClassLoader cl = module.getEarContext().getClassLoader();
@@ -196,7 +197,7 @@
         }
         return handlerInfos;
     }
-    
+
     private static Map mapServiceRefs(XmlObject[] refs) {
         Map refMap = new HashMap();
         if (refs != null) {
@@ -227,7 +228,7 @@
         infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
         infoBuilder.addReference("AxisBuilder", AxisBuilder.class, NameFactory.MODULE_BUILDER);
 
-        infoBuilder.setConstructor(new String[] {"defaultEnvironment", "eeNamespaces", "AxisBuilder"});
+        infoBuilder.setConstructor(new String[]{"defaultEnvironment", "eeNamespaces", "AxisBuilder"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -42,9 +42,9 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
-import org.apache.geronimo.xbeans.j2ee.MessageDestinationRefType;
-import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
-import org.apache.geronimo.xbeans.j2ee.ResourceEnvRefType;
+import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
+import org.apache.geronimo.xbeans.javaee.MessageDestinationType;
+import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -73,7 +73,7 @@
     }
 
     public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
-        List<MessageDestinationType> specDestinations = convert(specDD.selectChildren(messageDestinationQNameSet), J2EE_CONVERTER, MessageDestinationType.class, MessageDestinationType.type);
+        List<MessageDestinationType> specDestinations = convert(specDD.selectChildren(messageDestinationQNameSet), JEE_CONVERTER, MessageDestinationType.class, MessageDestinationType.type);
         XmlObject[] gerDestinations = plan.selectChildren(GER_MESSAGE_DESTINATION_QNAME_SET);
             Map nameMap = new HashMap();
             for (int i = 0; i < gerDestinations.length; i++) {
@@ -96,12 +96,13 @@
 
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
-        List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet), J2EE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
+        List<ResourceEnvRefType> resourceEnvRefsUntyped = convert(specDD.selectChildren(adminOjbectRefQNameSet), JEE_CONVERTER, ResourceEnvRefType.class, ResourceEnvRefType.type);
         ClassLoader cl = module.getEarContext().getClassLoader();
         XmlObject[] gerResourceEnvRefsUntyped = plan == null? NO_REFS: plan.selectChildren(GER_ADMIN_OBJECT_REF_QNAME_SET);
         Map refMap = mapResourceEnvRefs(gerResourceEnvRefsUntyped);
         for (ResourceEnvRefType resourceEnvRef: resourceEnvRefsUntyped) {
             String name = resourceEnvRef.getResourceEnvRefName().getStringValue().trim();
+            addInjections(name, resourceEnvRef.getInjectionTargetArray(), componentContext);
             String type = resourceEnvRef.getResourceEnvRefType().getStringValue().trim();
             Class iface;
             try {
@@ -120,7 +121,7 @@
         }
 
         //message-destination-refs
-        List<MessageDestinationRefType> messageDestinationRefsUntyped = convert(specDD.selectChildren(messageDestinationRefQNameSet), J2EE_CONVERTER, MessageDestinationRefType.class, MessageDestinationRefType.type);
+        List<MessageDestinationRefType> messageDestinationRefsUntyped = convert(specDD.selectChildren(messageDestinationRefQNameSet), JEE_CONVERTER, MessageDestinationRefType.class, MessageDestinationRefType.type);
 
         for (MessageDestinationRefType messageDestinationRef: messageDestinationRefsUntyped) {
             String name = getStringValue(messageDestinationRef.getMessageDestinationRefName());

Modified: geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-connector-builder/src/main/java/org/apache/geronimo/connector/deployment/ResourceRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -21,10 +21,10 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import javax.naming.Reference;
 import javax.xml.namespace.QName;
@@ -46,7 +46,7 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefDocument;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
-import org.apache.geronimo.xbeans.j2ee.ResourceRefType;
+import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.XmlObject;
 
@@ -80,6 +80,7 @@
 
         for (ResourceRefType resourceRef: resourceRefsUntyped) {
             String name = resourceRef.getResRefName().getStringValue().trim();
+            addInjections(name, resourceRef.getInjectionTargetArray(), componentContext);
             String type = resourceRef.getResType().getStringValue().trim();
             GerResourceRefType gerResourceRef = (GerResourceRefType) refMap.get(name);
             Class iface;
@@ -175,11 +176,11 @@
         builder.setApplicationManagedSecurityResources(applicationManagedSecurityResources);
     }
 
-    private Map mapResourceRefs(XmlObject[] refs) {
-        Map refMap = new HashMap();
+    private Map<String, GerResourceRefType> mapResourceRefs(XmlObject[] refs) {
+        Map<String, GerResourceRefType> refMap = new HashMap<String, GerResourceRefType>();
         if (refs != null) {
-            for (int i = 0; i < refs.length; i++) {
-                GerResourceRefType ref = (GerResourceRefType) refs[i].copy().changeType(GerResourceRefType.type);
+            for (XmlObject ref1 : refs) {
+                GerResourceRefType ref = (GerResourceRefType) ref1.copy().changeType(GerResourceRefType.type);
                 refMap.put(ref.getRefName().trim(), ref);
             }
         }
@@ -207,14 +208,6 @@
 
     public QNameSet getPlanQNameSet() {
         return GER_RESOURCE_REF_QNAME_SET;
-    }
-
-    private static String getStringValue(org.apache.geronimo.xbeans.j2ee.String string) {
-        if (string == null) {
-            return null;
-        }
-        String s = string.getStringValue();
-        return s == null ? null : s.trim();
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-corba-builder/src/main/java/org/apache/geronimo/corba/deployment/OpenEjbCorbaRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -102,6 +102,7 @@
             EjbRefType ejbRef = (EjbRefType) ejbRefsUntyped[i];
 
             String ejbRefName = getStringValue(ejbRef.getEjbRefName());
+            addInjections(ejbRefName, ejbRef.getInjectionTargetArray(), componentContext);
             GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
 
             Reference ejbReference = addEJBRef(localConfiguration, module.getModuleURI(), ejbRef, remoteRef, cl);

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/NamingBuilder.java Mon Feb 26 12:52:05 2007
@@ -35,6 +35,7 @@
     String ENV = "env/";
 
     String JNDI_KEY = "JNDI_COMPONENT_CONTEXT";
+    String INJECTION_KEY = "INJECTIONS";
     String GBEAN_NAME_KEY = "GBEAN_NAME";
 
     void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) throws DeploymentException;

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/EJBAnnotationHelper.java Mon Feb 26 12:52:05 2007
@@ -22,6 +22,8 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
 
 import javax.ejb.EJB;
 import javax.ejb.EJBs;
@@ -50,34 +52,33 @@
 /**
  * Static helper class used to encapsulate all the functions related to the translation of
  *
+ * @version $Rev$ $Date$
  * @EJB and @EBJs annotations to deployment descriptor tags. The EJBAnnotationHelper class can be
  * used as part of the deployment of a module into the Geronimo server. It performs the following
  * major functions:
- *
+ * <p/>
  * <ol>
- *      <li>Translates annotations into corresponding deployment descriptor elements (so that the
- *      actual deployment descriptor in the module can be updated or even created if necessary)
+ * <li>Translates annotations into corresponding deployment descriptor elements (so that the
+ * actual deployment descriptor in the module can be updated or even created if necessary)
  * </ol>
- *
+ * <p/>
  * <p><strong>Note(s):</strong>
  * <ul>
- *      <li>The user is responsible for invoking change to metadata-complete
- *      <li>This helper class will validate any changes it makes to the deployment descriptor. An
- *      exception will be thrown if it fails to parse
+ * <li>The user is responsible for invoking change to metadata-complete
+ * <li>This helper class will validate any changes it makes to the deployment descriptor. An
+ * exception will be thrown if it fails to parse
  * </ul>
- *
+ * <p/>
  * <p><strong>Remaining ToDo(s):</strong>
  * <ul>
- *      <li>How to determine Session/Entity remote/local for @EJB
+ * <li>How to determine Session/Entity remote/local for @EJB
  * </ul>
- *
- * @version $Rev$ $Date$
  * @since 02-2007
  */
 public final class EJBAnnotationHelper {
 
     // Private instance variables
-    private static final Log log = LogFactory.getLog( EJBAnnotationHelper.class );
+    private static final Log log = LogFactory.getLog(EJBAnnotationHelper.class);
 
     // Private constructor to prevent instantiation
     private EJBAnnotationHelper() {
@@ -89,9 +90,9 @@
      *
      * @return true or false
      */
-    public static boolean annotationsPresent( ClassFinder classFinder ) {
-        if ( classFinder.isAnnotationPresent(EJB.class) ) return true;
-        if ( classFinder.isAnnotationPresent(EJBs.class) ) return true;
+    public static boolean annotationsPresent(ClassFinder classFinder) {
+        if (classFinder.isAnnotationPresent(EJB.class)) return true;
+        if (classFinder.isAnnotationPresent(EJBs.class)) return true;
         return false;
     }
 
@@ -100,58 +101,84 @@
      * Process the @EJB, @EJBs annotations
      *
      * @return Updated deployment descriptor
-     * @exception Exception if parsing or validation error
+     * @throws Exception if parsing or validation error
      */
-    public static WebAppType processAnnotations( WebAppType webApp, ClassFinder classFinder ) throws Exception {
-        processEJBs( webApp,classFinder );
-        processEJB( webApp,classFinder );
+    public static WebAppType processAnnotations(WebAppType webApp, ClassFinder classFinder, ClassFinder ejbFinder) throws Exception {
+        Set<Class> remotes = extractRemotes(ejbFinder);
+        Set<Class> locals = extractLocals(ejbFinder);
+        processEJBs(webApp, classFinder, remotes, locals);
+        processEJB(webApp, classFinder, remotes, locals);
         return webApp;
     }
 
+    private static Set<Class> extractRemotes(ClassFinder classFinder) {
+        List<Class> classesWithRemote = classFinder.findAnnotatedClasses(Remote.class);
+        Set<Class> remotes = new HashSet<Class>();
+        for (Class clazz : classesWithRemote) {
+            Remote remoteAnnotation = (Remote) clazz.getAnnotation(Remote.class);
+            for (Class remote : remoteAnnotation.value()) {
+                remotes.add(remote);
+            }
+        }
+        return remotes;
+    }
+
+    private static Set<Class> extractLocals(ClassFinder classFinder) {
+        List<Class> classesWithLocal = classFinder.findAnnotatedClasses(Local.class);
+        Set<Class> locals = new HashSet<Class>();
+        for (Class clazz : classesWithLocal) {
+            Local localAnnotation = (Local) clazz.getAnnotation(Local.class);
+            for (Class local : localAnnotation.value()) {
+                locals.add(local);
+            }
+        }
+        return locals;
+    }
+
 
     /**
      * Process @EJB annotations
      *
      * @param webApp
      * @param classFinder
-     * @exception Exception
+     * @throws Exception
      */
-    private static void processEJB( WebAppType webApp, ClassFinder classFinder ) throws Exception {
-        log.debug( "processEJB(): Entry" );
+    private static void processEJB(WebAppType webApp, ClassFinder classFinder, Set<Class> remotes, Set<Class> locals) throws Exception {
+        log.debug("processEJB(): Entry");
 
         // Save the EJB lists
-        List<Class>  classesWithEJB = classFinder.findAnnotatedClasses( EJB.class );
-        List<Method> methodsWithEJB = classFinder.findAnnotatedMethods( EJB.class );
-        List<Field>  fieldsWithEJB  = classFinder.findAnnotatedFields ( EJB.class );
+        List<Class> classesWithEJB = classFinder.findAnnotatedClasses(EJB.class);
+        List<Method> methodsWithEJB = classFinder.findAnnotatedMethods(EJB.class);
+        List<Field> fieldsWithEJB = classFinder.findAnnotatedFields(EJB.class);
 
         // Class-level EJB
-        for ( Class cls : classesWithEJB ) {
-            EJB ejb = (EJB)cls.getAnnotation( EJB.class );
-            if ( ejb != null ) {
-                addEJB( webApp, ejb, cls, null, null );
+        for (Class cls : classesWithEJB) {
+            EJB ejb = (EJB) cls.getAnnotation(EJB.class);
+            if (ejb != null) {
+                addEJB(webApp, ejb, cls, null, null, remotes, locals);
             }
         }
 
         // Method-level EJB
-        for ( Method method : methodsWithEJB ) {
-            EJB ejb = (EJB)method.getAnnotation( EJB.class );
-            if ( ejb != null ) {
-                addEJB( webApp, ejb, null, method, null );
+        for (Method method : methodsWithEJB) {
+            EJB ejb = (EJB) method.getAnnotation(EJB.class);
+            if (ejb != null) {
+                addEJB(webApp, ejb, null, method, null, remotes, locals);
             }
         }
 
         // Field-level EJB
-        for ( Field field : fieldsWithEJB ) {
-            EJB ejb = (EJB)field.getAnnotation( EJB.class );
-            if ( ejb != null ) {
-                addEJB( webApp, ejb, null, null, field );
+        for (Field field : fieldsWithEJB) {
+            EJB ejb = (EJB) field.getAnnotation(EJB.class);
+            if (ejb != null) {
+                addEJB(webApp, ejb, null, null, field, remotes, locals);
             }
         }
 
         // Validate deployment descriptor to ensure it's still okay
-        validateDD( webApp );
+        validateDD(webApp);
 
-        log.debug( "processEJB(): Exit: webApp: " + webApp.toString() );
+        log.debug("processEJB(): Exit: webApp: " + webApp.toString());
     }
 
 
@@ -160,28 +187,28 @@
      *
      * @param webApp
      * @param classFinder
-     * @exception Exception
+     * @throws Exception
      */
-    private static void processEJBs( WebAppType webApp, ClassFinder classFinder ) throws Exception {
-        log.debug( "processEJBs(): Entry" );
+    private static void processEJBs(WebAppType webApp, ClassFinder classFinder, Set<Class> remotes, Set<Class> locals) throws Exception {
+        log.debug("processEJBs(): Entry");
 
         // Save the EJBs list
-        List<Class> classesWithEJBs = classFinder.findAnnotatedClasses( EJBs.class );
+        List<Class> classesWithEJBs = classFinder.findAnnotatedClasses(EJBs.class);
 
         // Class-level EJBs
         List<EJB> ejbList = new ArrayList<EJB>();
-        for ( Class cls : classesWithEJBs ) {
-            EJBs ejbs = (EJBs) cls.getAnnotation( EJBs.class );
-            if ( ejbs != null ) {
-                ejbList.addAll( Arrays.asList(ejbs.value()) );
+        for (Class cls : classesWithEJBs) {
+            EJBs ejbs = (EJBs) cls.getAnnotation(EJBs.class);
+            if (ejbs != null) {
+                ejbList.addAll(Arrays.asList(ejbs.value()));
             }
-            for ( EJB ejb : ejbList ) {
-                addEJB( webApp, ejb, cls, null, null );
+            for (EJB ejb : ejbList) {
+                addEJB(webApp, ejb, cls, null, null, remotes, locals);
             }
             ejbList.clear();
         }
 
-        log.debug( "processEJBs(): Exit" );
+        log.debug("processEJBs(): Exit");
     }
 
 
@@ -189,16 +216,16 @@
      * Add @EJB and @EJBs annotations to the deployment descriptor. XMLBeans are used to read and
      * manipulate the deployment descriptor as necessary. The EJB annotation(s) will be converted to
      * one of the following deployment descriptors:
-     *
+     * <p/>
      * <ol>
-     *      <li><ejb-ref>
-     *      <li><ejb-local-ref>
+     * <li><ejb-ref>
+     * <li><ejb-local-ref>
      * </ol>
-     *
+     * <p/>
      * <p><strong>Note(s):</strong>
      * <ul>
-     *      <li>The deployment descriptor is the authoritative source so this method ensures that
-     *      existing elements in it are not overwritten by annoations
+     * <li>The deployment descriptor is the authoritative source so this method ensures that
+     * existing elements in it are not overwritten by annoations
      * </ul>
      *
      * @param webApp
@@ -207,42 +234,37 @@
      * @param method     Method name with the @EJB annoation
      * @param field      Field name with the @EJB annoation
      */
-    private static void addEJB( WebAppType webApp, EJB annotation, Class cls, Method method, Field field ) {
-        log.debug( "addEJB( " + webApp.toString() + ","          + '\n' +
-                  annotation.name() + ","                       + '\n' +
-                  (cls!=null?cls.getName():null) + ","          + '\n' +
-                  (method!=null?method.getName():null) + ","    + '\n' +
-                  (field!=null?field.getName():null) + " ): Entry" );
+    private static void addEJB(WebAppType webApp, EJB annotation, Class cls, Method method, Field field, Set<Class> remotes, Set<Class> locals) {
+        log.debug("addEJB( " + webApp.toString() + "," + '\n' +
+                annotation.name() + "," + '\n' +
+                (cls != null ? cls.getName() : null) + "," + '\n' +
+                (method != null ? method.getName() : null) + "," + '\n' +
+                (field != null ? field.getName() : null) + " ): Entry");
 
         // First determine if the interface is "Local" or "Remote"
         boolean localFlag = true;
         Class interfce = annotation.beanInterface();
-        if ( interfce.equals(Object.class) ) {
-            if ( method != null ) {
+        if (interfce.equals(Object.class)) {
+            if (method != null) {
                 interfce = method.getParameterTypes()[0];
-            }
-            else if ( field != null ) {
+            } else if (field != null) {
                 interfce = field.getType();
-            }
-            else {
+            } else {
                 interfce = null;
             }
         }
 
         // Just in case local and/or remote homes are still being implemented (even though
         // they are optional in EJB 3.0)
-        if ( interfce != null && !interfce.equals(Object.class) ) {
-            if ( EJBHome.class.isAssignableFrom(interfce) ) {
+        if (interfce != null && !interfce.equals(Object.class)) {
+            if (EJBHome.class.isAssignableFrom(interfce)) {
                 localFlag = false;
-            }
-            else if ( EJBLocalHome.class.isAssignableFrom(interfce) ) {
+            } else if (EJBLocalHome.class.isAssignableFrom(interfce)) {
                 localFlag = true;
-            }
-            else {
-                if ( interfce.getAnnotation(Local.class) != null ) {
+            } else {
+                if (locals.contains(interfce) || interfce.getAnnotation(Local.class) != null) {
                     localFlag = true;
-                }
-                else if ( interfce.getAnnotation(Remote.class) != null ) {
+                } else if (remotes.contains(interfce) || interfce.getAnnotation(Remote.class) != null) {
                     localFlag = false;
                 }
             }
@@ -251,29 +273,28 @@
         //------------------------------------------------------------------------------------------
         // 1. <ejb-local-ref>
         //------------------------------------------------------------------------------------------
-        if ( localFlag ) {
+        if (localFlag) {
 
-            log.debug( "addEJB(): <ejb-local-ref> found");
+            log.debug("addEJB(): <ejb-local-ref> found");
 
             String localRefName = annotation.name();
-            if ( localRefName.equals("") ) {
-                if ( method != null ) {
+            if (localRefName.equals("")) {
+                if (method != null) {
                     localRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3);  // method should start with "set"
-                }
-                else if ( field != null ) {
+                } else if (field != null) {
                     localRefName = field.getDeclaringClass().getName() + "/" + field.getName();
                 }
             }
 
             boolean exists = false;
             EjbLocalRefType[] ejbLocalRefEntries = webApp.getEjbLocalRefArray();
-            for ( EjbLocalRefType ejbLocalRefEntry : ejbLocalRefEntries ) {
-                if ( ejbLocalRefEntry.getEjbRefName().getStringValue().equals( localRefName ) ) {
+            for (EjbLocalRefType ejbLocalRefEntry : ejbLocalRefEntries) {
+                if (ejbLocalRefEntry.getEjbRefName().getStringValue().equals(localRefName)) {
                     exists = true;
                     break;
                 }
             }
-            if ( !exists ) {
+            if (!exists) {
                 try {
 
                     // Doesn't exist in deployment descriptor -- add new
@@ -285,8 +306,8 @@
 
                     // ejb-ref-name
                     EjbRefNameType ejbRefName = EjbRefNameType.Factory.newInstance();
-                    ejbRefName.setStringValue( localRefName );
-                    ejbLocalRef.setEjbRefName( ejbRefName );
+                    ejbRefName.setStringValue(localRefName);
+                    ejbLocalRef.setEjbRefName(ejbRefName);
 
                     //------------------------------------------------------------------------------
                     // <ejb-local-ref> optional elements:
@@ -294,64 +315,63 @@
 
                     // local
                     String localAnnotation = interfce.getName();
-                    if ( localAnnotation.length() > 0 ) {
+                    if (localAnnotation.length() > 0) {
                         LocalType local = LocalType.Factory.newInstance();
-                        local.setStringValue( localAnnotation );
-                        ejbLocalRef.setLocal( local );
+                        local.setStringValue(localAnnotation);
+                        ejbLocalRef.setLocal(local);
                     }
 
                     // ejb-link
                     String beanName = annotation.beanName();
-                    if ( beanName.length() > 0 ) {
+                    if (beanName.length() > 0) {
                         EjbLinkType ejbLink = EjbLinkType.Factory.newInstance();
-                        ejbLink.setStringValue( beanName );
-                        ejbLocalRef.setEjbLink( ejbLink );
+                        ejbLink.setStringValue(beanName);
+                        ejbLocalRef.setEjbLink(ejbLink);
                     }
 
                     // mappedName
                     String mappdedNameAnnotation = annotation.mappedName();
-                    if ( mappdedNameAnnotation.length() > 0 ) {
+                    if (mappdedNameAnnotation.length() > 0) {
                         XsdStringType mappedName = XsdStringType.Factory.newInstance();
-                        mappedName.setStringValue( mappdedNameAnnotation );
-                        ejbLocalRef.setMappedName( mappedName );
+                        mappedName.setStringValue(mappdedNameAnnotation);
+                        ejbLocalRef.setMappedName(mappedName);
                     }
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( descriptionAnnotation.length() > 0 ) {
+                    if (descriptionAnnotation.length() > 0) {
                         DescriptionType description = DescriptionType.Factory.newInstance();
-                        description.setStringValue( descriptionAnnotation );
+                        description.setStringValue(descriptionAnnotation);
                         int arraySize = ejbLocalRef.sizeOfDescriptionArray();
-                        ejbLocalRef.insertNewDescription( arraySize );
-                        ejbLocalRef.setDescriptionArray( arraySize,description );
+                        ejbLocalRef.insertNewDescription(arraySize);
+                        ejbLocalRef.setDescriptionArray(arraySize, description);
                     }
 
                     // injectionTarget
                     InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
                     FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
                     JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
-                    if ( method != null ) {
-                        qualifiedClass.setStringValue( method.getDeclaringClass().getName() );
-                        javaType.setStringValue( method.getName().substring(3) );   // method should start with "set"
-                        injectionTarget.setInjectionTargetClass( qualifiedClass );
-                        injectionTarget.setInjectionTargetName( javaType );
+                    if (method != null) {
+                        qualifiedClass.setStringValue(method.getDeclaringClass().getName());
+                        javaType.setStringValue(method.getName().substring(3));   // method should start with "set"
+                        injectionTarget.setInjectionTargetClass(qualifiedClass);
+                        injectionTarget.setInjectionTargetName(javaType);
                         int arraySize = ejbLocalRef.sizeOfInjectionTargetArray();
-                        ejbLocalRef.insertNewInjectionTarget( arraySize );
-                        ejbLocalRef.setInjectionTargetArray( arraySize,injectionTarget );
-                    }
-                    else if ( field !=null ) {
-                        qualifiedClass.setStringValue( field.getDeclaringClass().getName() );
-                        javaType.setStringValue( field.getName() );
-                        injectionTarget.setInjectionTargetClass( qualifiedClass );
-                        injectionTarget.setInjectionTargetName( javaType );
+                        ejbLocalRef.insertNewInjectionTarget(arraySize);
+                        ejbLocalRef.setInjectionTargetArray(arraySize, injectionTarget);
+                    } else if (field != null) {
+                        qualifiedClass.setStringValue(field.getDeclaringClass().getName());
+                        javaType.setStringValue(field.getName());
+                        injectionTarget.setInjectionTargetClass(qualifiedClass);
+                        injectionTarget.setInjectionTargetName(javaType);
                         int arraySize = ejbLocalRef.sizeOfInjectionTargetArray();
-                        ejbLocalRef.insertNewInjectionTarget( arraySize );
-                        ejbLocalRef.setInjectionTargetArray( arraySize,injectionTarget );
+                        ejbLocalRef.insertNewInjectionTarget(arraySize);
+                        ejbLocalRef.setInjectionTargetArray(arraySize, injectionTarget);
                     }
 
                 }
-                catch ( Exception anyException ) {
-                    log.debug( "EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>" );
+                catch (Exception anyException) {
+                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>");
                     anyException.printStackTrace();
                 }
             }
@@ -362,27 +382,26 @@
             // 2. <ejb-ref>
             //--------------------------------------------------------------------------------------
 
-            log.debug( "addEJB(): <ejb-ref> found");
+            log.debug("addEJB(): <ejb-ref> found");
 
             String remoteRefName = annotation.name();
-            if ( remoteRefName.equals("") ) {
-                if ( method != null ) {
+            if (remoteRefName.equals("")) {
+                if (method != null) {
                     remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3); // method should start with "set"
-                }
-                else if ( field != null ) {
+                } else if (field != null) {
                     remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
                 }
             }
 
             boolean exists = false;
             EjbRefType[] ejbRefEntries = webApp.getEjbRefArray();
-            for ( EjbRefType ejbRefEntry : ejbRefEntries ) {
-                if ( ejbRefEntry.getEjbRefName().getStringValue().equals( remoteRefName ) ) {
+            for (EjbRefType ejbRefEntry : ejbRefEntries) {
+                if (ejbRefEntry.getEjbRefName().getStringValue().equals(remoteRefName)) {
                     exists = true;
                     break;
                 }
             }
-            if ( !exists ) {
+            if (!exists) {
                 try {
 
                     // Doesn't exist in deployment descriptor -- add new
@@ -394,8 +413,8 @@
 
                     // ejb-ref-name
                     EjbRefNameType ejbRefName = EjbRefNameType.Factory.newInstance();
-                    ejbRefName.setStringValue( remoteRefName );
-                    ejbRef.setEjbRefName( ejbRefName );
+                    ejbRefName.setStringValue(remoteRefName);
+                    ejbRef.setEjbRefName(ejbRefName);
 
                     //------------------------------------------------------------------------------
                     // <ejb-ref> optional elements:
@@ -403,69 +422,68 @@
 
                     // remote
                     String remoteAnnotation = interfce.getName();
-                    if ( remoteAnnotation.length() > 0 ) {
+                    if (remoteAnnotation.length() > 0) {
                         RemoteType remote = RemoteType.Factory.newInstance();
-                        remote.setStringValue( remoteAnnotation );
-                        ejbRef.setRemote( remote );
+                        remote.setStringValue(remoteAnnotation);
+                        ejbRef.setRemote(remote);
                     }
 
                     // ejb-link
                     String beanName = annotation.beanName();
-                    if ( beanName.length() > 0 ) {
+                    if (beanName.length() > 0) {
                         EjbLinkType ejbLink = EjbLinkType.Factory.newInstance();
-                        ejbLink.setStringValue( beanName );
-                        ejbRef.setEjbLink( ejbLink );
+                        ejbLink.setStringValue(beanName);
+                        ejbRef.setEjbLink(ejbLink);
                     }
 
                     // mappedName
                     String mappdedNameAnnotation = annotation.mappedName();
-                    if ( mappdedNameAnnotation.length() > 0 ) {
+                    if (mappdedNameAnnotation.length() > 0) {
                         XsdStringType mappedName = XsdStringType.Factory.newInstance();
-                        mappedName.setStringValue( mappdedNameAnnotation );
-                        ejbRef.setMappedName( mappedName );
+                        mappedName.setStringValue(mappdedNameAnnotation);
+                        ejbRef.setMappedName(mappedName);
                     }
 
                     // description
                     String descriptionAnnotation = annotation.description();
-                    if ( descriptionAnnotation.length() > 0 ) {
+                    if (descriptionAnnotation.length() > 0) {
                         DescriptionType description = DescriptionType.Factory.newInstance();
-                        description.setStringValue( descriptionAnnotation );
+                        description.setStringValue(descriptionAnnotation);
                         int arraySize = ejbRef.sizeOfDescriptionArray();
-                        ejbRef.insertNewDescription( arraySize );
-                        ejbRef.setDescriptionArray( arraySize,description );
+                        ejbRef.insertNewDescription(arraySize);
+                        ejbRef.setDescriptionArray(arraySize, description);
                     }
 
                     // injectionTarget
                     InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
                     FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
                     JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
-                    if ( method != null ) {
-                        qualifiedClass.setStringValue( method.getDeclaringClass().getName() );
-                        javaType.setStringValue( method.getName().substring(3) );   // method should start with "set"
-                        injectionTarget.setInjectionTargetClass( qualifiedClass );
-                        injectionTarget.setInjectionTargetName( javaType );
+                    if (method != null) {
+                        qualifiedClass.setStringValue(method.getDeclaringClass().getName());
+                        javaType.setStringValue(method.getName().substring(3));   // method should start with "set"
+                        injectionTarget.setInjectionTargetClass(qualifiedClass);
+                        injectionTarget.setInjectionTargetName(javaType);
                         int arraySize = ejbRef.sizeOfInjectionTargetArray();
-                        ejbRef.insertNewInjectionTarget( arraySize );
-                        ejbRef.setInjectionTargetArray( arraySize, injectionTarget );
-                    }
-                    else if ( field !=null ) {
-                        qualifiedClass.setStringValue( field.getDeclaringClass().getName() );
-                        javaType.setStringValue( field.getName() );
-                        injectionTarget.setInjectionTargetClass( qualifiedClass );
-                        injectionTarget.setInjectionTargetName( javaType );
+                        ejbRef.insertNewInjectionTarget(arraySize);
+                        ejbRef.setInjectionTargetArray(arraySize, injectionTarget);
+                    } else if (field != null) {
+                        qualifiedClass.setStringValue(field.getDeclaringClass().getName());
+                        javaType.setStringValue(field.getName());
+                        injectionTarget.setInjectionTargetClass(qualifiedClass);
+                        injectionTarget.setInjectionTargetName(javaType);
                         int arraySize = ejbRef.sizeOfInjectionTargetArray();
-                        ejbRef.insertNewInjectionTarget( arraySize );
-                        ejbRef.setInjectionTargetArray( arraySize, injectionTarget );
+                        ejbRef.insertNewInjectionTarget(arraySize);
+                        ejbRef.setInjectionTargetArray(arraySize, injectionTarget);
                     }
 
                 }
-                catch ( Exception anyException ) {
-                    log.debug( "EJBAnnotationHelper: Exception caught while <processing ejb-ref>" );
+                catch (Exception anyException) {
+                    log.debug("EJBAnnotationHelper: Exception caught while <processing ejb-ref>");
                     anyException.printStackTrace();
                 }
             }
         }
-        log.debug( "addEJB(): Exit" );
+        log.debug("addEJB(): Exit");
     }
 
 
@@ -473,13 +491,13 @@
      * Validate deployment descriptor
      *
      * @param webApp
-     * @exception Exception  thrown if deployment descriptor cannot be parsed
+     * @throws Exception thrown if deployment descriptor cannot be parsed
      */
-    private static void validateDD( WebAppType webApp ) throws Exception {
-        log.debug( "validateDD( " + webApp.toString() + " ): Entry" );
+    private static void validateDD(WebAppType webApp) throws Exception {
+        log.debug("validateDD( " + webApp.toString() + " ): Entry");
 
-        XmlBeansUtil.parse( webApp.toString() );
+        XmlBeansUtil.parse(webApp.toString());
 
-        log.debug( "validateDD(): Exit" );
+        log.debug("validateDD(): Exit");
     }
 }

Added: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java?view=auto&rev=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java (added)
+++ geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java Mon Feb 26 12:52:05 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.geronimo.j2ee.annotation;
+
+import java.io.Serializable;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class Injection implements Serializable {
+
+    private final String targetClassName;
+    private final String targetName;
+    private final String jndiName;
+
+
+    public Injection(String targetClassName, String targetName, String jndiName) {
+        this.targetClassName = targetClassName;
+        this.targetName = targetName;
+        this.jndiName = jndiName;
+    }
+
+
+    public String getTargetClassName() {
+        return targetClassName;
+    }
+
+    public String getTargetName() {
+        return targetName;
+    }
+
+    public String getJndiName() {
+        return jndiName;
+    }
+    
+}

Propchange: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Injection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -75,6 +75,7 @@
         
         for (ServiceRefType serviceRef : serviceRefsUntyped) {
             String name = getStringValue(serviceRef.getServiceRefName());            
+            addInjections(name, serviceRef.getInjectionTargetArray(), componentContext);
             GerServiceRefType serviceRefType = (GerServiceRefType) serviceRefMap.get(name);
             
             buildNaming(serviceRef, serviceRefType, module, componentContext);

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java Mon Feb 26 12:52:05 2007
@@ -64,6 +64,7 @@
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.jetty6.Host;
 import org.apache.geronimo.jetty6.JettyDefaultServletHolder;
 import org.apache.geronimo.jetty6.JettyFilterHolder;
@@ -317,11 +318,13 @@
 
         //N.B. we use the ear context which has all the gbeans we could possibly be looking up from this ear.
         Map buildingContext = new HashMap();
-        buildingContext.put(NamingBuilder.JNDI_KEY, new HashMap());
+        buildingContext.put(NamingBuilder.JNDI_KEY, new HashMap<String, Object>());
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
+        buildingContext.put(NamingBuilder.INJECTION_KEY, new HashMap<String, List<Injection>>());
         Configuration earConfiguration = earContext.getConfiguration();
         getNamingBuilders().buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, (Module) webModule, buildingContext);
         Map compContext = (Map) buildingContext.get(NamingBuilder.JNDI_KEY);
+        Map<String, List<Injection>> injections = (Map<String, List<Injection>>) buildingContext.get(NamingBuilder.INJECTION_KEY);
 
 
         GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
@@ -333,6 +336,8 @@
             if (!module.isStandAlone()) {
                 webModuleData.setReferencePattern("J2EEApplication", earContext.getModuleName());
             }
+
+            webModuleData.setAttribute("injections", injections);
 
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
             Set securityRoles = collectRoleNames(webApp);

Modified: geronimo/server/trunk/modules/geronimo-jetty6/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/pom.xml?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/pom.xml Mon Feb 26 12:52:05 2007
@@ -74,6 +74,11 @@
             <artifactId>jetty</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-reflect</artifactId>
+        </dependency>
+
         <!--<dependency>-->
             <!--<groupId>org.mortbay.jetty</groupId>-->
             <!--<artifactId>jetty-plus</artifactId>-->

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InjectionServletHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InjectionServletHandler.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InjectionServletHandler.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InjectionServletHandler.java Mon Feb 26 12:52:05 2007
@@ -18,6 +18,9 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
 import javax.ejb.EJB;
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -27,13 +30,28 @@
 import org.mortbay.jetty.servlet.ServletHandler;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.j2ee.annotation.Injection;
 
 /**
  * @version $Rev$ $Date$
  */
 class InjectionServletHandler extends ServletHandler {
     private static final Log log = LogFactory.getLog(InjectionServletHandler.class);
+
+    private final Map<String, List<Injection>> injections;
+
+
+    public InjectionServletHandler(Map<String, List<Injection>> injections) {
+        this.injections = injections;
+    }
+
     public Servlet customizeServlet(Servlet servlet) throws Exception {
+        List<Injection> classInjections = injections.get(servlet.getClass().getName());
+        if (classInjections != null) {
+            for (Injection injection: classInjections) {
+                
+            }
+        }
         servlet = super.customizeServlet(servlet);
         processAnnotations(servlet);
         return servlet;

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java Mon Feb 26 12:52:05 2007
@@ -19,18 +19,27 @@
 package org.apache.geronimo.jetty6;
 
 import java.io.IOException;
+import java.util.List;
+import java.util.Map;
 
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.ServletException;
 import javax.servlet.UnavailableException;
 import javax.security.auth.Subject;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 
 import org.mortbay.jetty.servlet.ServletHolder;
 import org.apache.geronimo.jetty6.handler.AbstractImmutableHandler;
 import org.apache.geronimo.jetty6.handler.LifecycleCommand;
 import org.apache.geronimo.security.Callers;
 import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.j2ee.annotation.Injection;
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+import org.apache.xbean.recipe.StaticRecipe;
 
 /**
  * @version $Rev$ $Date$
@@ -41,10 +50,12 @@
 
     private final AbstractImmutableHandler lifecycleChain;
     private final Subject runAsSubject;
+    private final JettyServletRegistration servletRegistration;
 
-    public InternalJettyServletHolder(AbstractImmutableHandler lifecycleChain, Subject runAsSubject) {
+    public InternalJettyServletHolder(AbstractImmutableHandler lifecycleChain, Subject runAsSubject, JettyServletRegistration servletRegistration) {
         this.lifecycleChain = lifecycleChain;
         this.runAsSubject = runAsSubject;
+        this.servletRegistration = servletRegistration;
     }
 
     //TODO probably need to override init and destroy (?) to handle runAsSubject since we are not setting it in the superclass any more.
@@ -73,11 +84,16 @@
         }
     }
 
+
+    public synchronized Object newInstance() throws InstantiationException, IllegalAccessException {
+        return servletRegistration.newInstance(_class);
+    }
+
     /**
      * Provide the thread's current JettyServletHolder
      *
      * @return the thread's current JettyServletHolder
-     * @see org.apache.geronimo.jetty6.JAASJettyRealm#isUserInRole(java.security.Principal, java.lang.String)
+     * @see org.apache.geronimo.jetty6.JAASJettyRealm#isUserInRole(java.security.Principal,java.lang.String)
      */
     static String getCurrentServletName() {
         return currentServletName.get();

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java Mon Feb 26 12:52:05 2007
@@ -17,11 +17,19 @@
 package org.apache.geronimo.jetty6;
 
 import java.util.Map;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.annotation.Injection;
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+import org.apache.xbean.recipe.StaticRecipe;
 import org.mortbay.jetty.servlet.FilterHolder;
 
 /**
@@ -37,7 +45,7 @@
     }
 
     public JettyFilterHolder(String filterName, String filterClass, Map initParams, JettyServletRegistration jettyServletRegistration) throws Exception {
-        filterHolder = new FilterHolder();
+        filterHolder = new InternalFilterHolder(jettyServletRegistration);
         if (jettyServletRegistration != null) {
             filterHolder.setName(filterName);
             filterHolder.setClassName(filterClass);
@@ -72,6 +80,19 @@
             filterHolder.stop();
         } catch (Exception e) {
             //ignore?
+        }
+    }
+
+    private static class InternalFilterHolder extends FilterHolder {
+        private final JettyServletRegistration servletRegistration;
+
+        public InternalFilterHolder(JettyServletRegistration servletRegistration) {
+            this.servletRegistration = servletRegistration;
+        }
+
+
+        public synchronized Object newInstance() throws InstantiationException, IllegalAccessException {
+            return servletRegistration.newInstance(_class);
         }
     }
     

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java Mon Feb 26 12:52:05 2007
@@ -18,6 +18,7 @@
 
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 
 import javax.security.auth.Subject;
 
@@ -25,6 +26,7 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.management.Servlet;
 import org.mortbay.jetty.servlet.ServletHolder;
 
@@ -63,7 +65,7 @@
             Subject runAsSubject,
             JettyServletRegistration context) throws Exception {
         servletRegistration = context;
-        servletHolder = new InternalJettyServletHolder(context == null? null: context.getLifecycleChain(), runAsSubject);
+        servletHolder = new InternalJettyServletHolder(context == null? null: context.getLifecycleChain(), runAsSubject, servletRegistration);
         servletHolder.setName(servletName);
         servletHolder.setClassName(servletClassName);
         //context will be null only for use as "default servlet info holder" in deployer.

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletRegistration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletRegistration.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletRegistration.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletRegistration.java Mon Feb 26 12:52:05 2007
@@ -17,6 +17,9 @@
 package org.apache.geronimo.jetty6;
 
 import java.util.Set;
+import java.util.Map;
+
+import javax.naming.Context;
 
 import org.mortbay.jetty.servlet.ServletHandler;
 import org.mortbay.jetty.servlet.ServletHolder;
@@ -28,6 +31,7 @@
 public interface JettyServletRegistration {
 
     void registerServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, String objectName) throws Exception;
+
     void unregisterServletHolder(ServletHolder servletHolder, String servletName, Set servletMappings, String objectName) throws Exception;
 
     ServletHandler getServletHandler();
@@ -36,4 +40,6 @@
 
     AbstractImmutableHandler getLifecycleChain();
 
+    Object newInstance(Class clazz) throws InstantiationException, IllegalAccessException;
+    
 }

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java Mon Feb 26 12:52:05 2007
@@ -28,11 +28,13 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
 
 import javax.faces.FactoryFinder;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.Context;
+import javax.naming.NamingException;
 import javax.transaction.TransactionManager;
 
 import org.apache.commons.logging.Log;
@@ -43,6 +45,7 @@
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
+import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.jetty6.handler.AbstractImmutableHandler;
 import org.apache.geronimo.jetty6.handler.ComponentContextHandler;
 import org.apache.geronimo.jetty6.handler.InstanceContextHandler;
@@ -59,6 +62,9 @@
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+import org.apache.xbean.recipe.StaticRecipe;
 import org.mortbay.jetty.handler.AbstractHandler;
 import org.mortbay.jetty.security.Authenticator;
 import org.mortbay.jetty.servlet.ErrorPageErrorHandler;
@@ -93,6 +99,8 @@
     private final String objectName;
     private final WebAppContext webAppContext;//delegate
     private final AbstractImmutableHandler lifecycleChain;
+    private final Context componentContext;
+    private final Map<String, List<Injection>> injectionMap;
 
     private final Set servletNames = new HashSet();
 
@@ -112,6 +120,8 @@
         configurationBaseURL = null;
         webAppContext = null;
         lifecycleChain = null;
+        componentContext = null;
+        injectionMap = null;
     }
 
     public JettyWebAppContext(String objectName,
@@ -142,6 +152,8 @@
             PermissionCollection checkedPermissions,
             PermissionCollection excludedPermissions,
 
+            Map<String, List<Injection>> injectionMap,
+
             Host host,
             TransactionManager transactionManager,
             TrackedConnectionAssociator trackedConnectionAssociator,
@@ -156,7 +168,9 @@
         assert transactionManager != null;
         assert trackedConnectionAssociator != null;
         assert jettyContainer != null;
-        
+
+        this.injectionMap = injectionMap;
+
         SessionHandler sessionHandler;
         if (null != handlerFactory) {
             if (null == preHandlerFactory) {
@@ -179,15 +193,15 @@
             securityHandler.init(policyContextID, defaultPrincipal, checkedPermissions, excludedPermissions, classLoader);
         }
 
-        ServletHandler servletHandler = new InjectionServletHandler();
+        ServletHandler servletHandler = new ServletHandler();
 
         webAppContext = new WebAppContext(securityHandler, sessionHandler, servletHandler, null);
         AbstractHandler next = sessionHandler;
         next = new ThreadClassloaderHandler(next, classLoader);
 
         GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
-        Context enc = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
-        next = new ComponentContextHandler(next, enc);
+        this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
+        next = new ComponentContextHandler(next, this.componentContext);
         next = new InstanceContextHandler(next, unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator);
         lifecycleChain = (AbstractImmutableHandler) next;
         webAppContext.setHandler(next);
@@ -321,6 +335,46 @@
         return lifecycleChain;
     }
 
+    public Object newInstance(Class clazz) throws InstantiationException, IllegalAccessException {
+        if (clazz == null) {
+            throw new InstantiationException("no class loaded");
+        }
+        ObjectRecipe objectRecipe = new ObjectRecipe(clazz);
+        objectRecipe.allow(Option.FIELD_INJECTION);
+        objectRecipe.allow(Option.PRIVATE_PROPERTIES);
+        objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+        String className = clazz.getName();
+        List<Injection> injections = injectionMap.get(className);
+        if (injections != null) {
+            for (Injection injection : injections) {
+                try {
+                    String jndiName = injection.getJndiName();
+                    //our componentContext is attached to jndi at "java:comp" so we remove that when looking stuff up in it
+                    Object object = componentContext.lookup("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.getTargetName(), string);
+                    } else {
+                        objectRecipe.setProperty(injection.getTargetName(), new StaticRecipe(object));
+                    }
+                } catch (NamingException e) {
+                    //log.warn("could not look up ");
+                }
+            }
+        }
+        Object filter = objectRecipe.create(clazz.getClassLoader());
+        Map unsetProperties = objectRecipe.getUnsetProperties();
+        if (unsetProperties.size() > 0) {
+            for (Object property : unsetProperties.keySet()) {
+//                log.warning("Injection: No such property '"+property+"' in class "+_class.getName());
+            }
+        }
+        return filter;
+
+    }
+
     public void doStart() throws Exception {
         // reset the classsloader... jetty likes to set it to null when stopping
         this.webAppContext.setClassLoader(webClassLoader);
@@ -383,7 +437,7 @@
             for (Iterator iterator = eventListeners.iterator(); iterator.hasNext();) {
                 String listenerClassName = (String) iterator.next();
                 Class clazz = this.webAppContext.loadClass(listenerClassName);
-                EventListener listener = (EventListener) clazz.newInstance();
+                EventListener listener = (EventListener) newInstance(clazz);
                 this.webAppContext.addEventListener(listener);
             }
         }
@@ -568,6 +622,8 @@
         infoBuilder.addAttribute("checkedPermissions", PermissionCollection.class, true);
         infoBuilder.addAttribute("excludedPermissions", PermissionCollection.class, true);
 
+        infoBuilder.addAttribute("injections", Map.class, true);
+
         infoBuilder.addReference("J2EEServer", J2EEServer.class);
         infoBuilder.addReference("J2EEApplication", J2EEApplication.class);
 
@@ -609,6 +665,8 @@
 
                 "checkedPermissions",
                 "excludedPermissions",
+
+                "injections",
 
                 "Host",
                 "TransactionManager",

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml Mon Feb 26 12:52:05 2007
@@ -25,6 +25,10 @@
         <dep:artifactId>jetty-util</dep:artifactId>
     </dep:dependency>
     <dep:dependency>
+        <dep:groupId>org.apache.xbean</dep:groupId>
+        <dep:artifactId>xbean-reflect</dep:artifactId>
+    </dep:dependency>
+    <dep:dependency>
         <dep:groupId>org.apache.tomcat</dep:groupId>
         <dep:artifactId>jasper</dep:artifactId>
     </dep:dependency>

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java Mon Feb 26 12:52:05 2007
@@ -24,6 +24,7 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.List;
 
 import javax.transaction.TransactionManager;
 
@@ -47,6 +48,7 @@
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.apache.geronimo.j2ee.annotation.Injection;
 import org.mortbay.jetty.security.Authenticator;
 import org.mortbay.jetty.security.FormAuthenticator;
 
@@ -114,6 +116,7 @@
                 defaultPrincipal,
                 checkedPermissions,
                 excludedPermissions,
+                new HashMap<String, List<Injection>>(),
                 null,
                 transactionManager,
                 connectionTrackingCoordinator,

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/AbstractNamingBuilder.java Mon Feb 26 12:52:05 2007
@@ -35,6 +35,7 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.annotation.Injection;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
@@ -44,10 +45,12 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerPatternType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerAbstractNamingEntryDocument;
 import org.apache.geronimo.xbeans.javaee.XsdStringType;
+import org.apache.geronimo.xbeans.javaee.InjectionTargetType;
 import org.apache.xmlbeans.QNameSet;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlCursor;
 
 /**
  * @version $Rev$ $Date$
@@ -72,13 +75,13 @@
     public Environment getEnvironment() {
         return this.defaultEnvironment;
     }
-    
+
     public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment) throws DeploymentException {
         // TODO Currently this method is called before the xml is metadata complete, so will not contain all refs
         // Just always call mergeEnvironment until this is fixed
         //
         // if (willMergeEnvironment(specDD, plan)) {
-            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+        EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
         // }
     }
 
@@ -116,8 +119,13 @@
     public void initContext(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module) throws DeploymentException {
     }
 
-    protected Map getJndiContextMap(Map sharedContext) {
-        return (Map) sharedContext.get(JNDI_KEY);
+    protected Map<String, Object> getJndiContextMap(Map sharedContext) {
+        Map jndiContext = (Map) sharedContext.get(JNDI_KEY);
+        if (jndiContext == null) {
+            jndiContext = new HashMap<String, Object>();
+            sharedContext.put(JNDI_KEY, jndiContext);
+        }
+        return jndiContext;
     }
 
     protected AbstractName getGBeanName(Map sharedContext) {
@@ -136,15 +144,15 @@
     }
 
     /**
-     * @deprecated
      * @param xmlObjects
      * @param converter
      * @param type
      * @return
      * @throws DeploymentException
+     * @deprecated
      */
     protected static XmlObject[] convert(XmlObject[] xmlObjects, NamespaceElementConverter converter, SchemaType type) throws DeploymentException {
-               //bizarre ArrayStoreException if xmlObjects is loaded by the wrong classloader
+        //bizarre ArrayStoreException if xmlObjects is loaded by the wrong classloader
         XmlObject[] converted = new XmlObject[xmlObjects.length];
         for (int i = 0; i < xmlObjects.length; i++) {
             XmlObject xmlObject = xmlObjects[i].copy();
@@ -269,4 +277,26 @@
     }
 
 
+    protected void addInjections(String jndiName, InjectionTargetType[] injectionTargetArray, Map sharedContext) {
+        Map<String, List<Injection>> injectionsMap = getInjectionsMap(sharedContext);
+        for (InjectionTargetType injectionTarget : injectionTargetArray) {
+            String targetName = injectionTarget.getInjectionTargetName().getStringValue().trim();
+            String targetClassName = injectionTarget.getInjectionTargetClass().getStringValue().trim();
+            List<Injection> injections = injectionsMap.get(targetClassName);
+            if (injections == null) {
+                injections = new ArrayList<Injection>();
+                injectionsMap.put(targetClassName, injections);
+            }
+            injections.add(new Injection(targetClassName, targetName, jndiName));
+        }
+    }
+
+    private Map<String, List<Injection>> getInjectionsMap(Map sharedContext) {
+        Map<String, List<Injection>> injectionsMap = (Map<String, List<Injection>>) sharedContext.get(INJECTION_KEY);
+        if (injectionsMap == null) {
+            injectionsMap = new HashMap<String, List<Injection>>();
+            sharedContext.put(INJECTION_KEY, injectionsMap);
+        }
+        return injectionsMap;
+    }
 }

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/EnvironmentEntryBuilder.java Mon Feb 26 12:52:05 2007
@@ -56,6 +56,7 @@
         List<EnvEntryType> envEntriesUntyped = convert(specDD.selectChildren(envEntryQNameSet), JEE_CONVERTER, EnvEntryType.class, EnvEntryType.type);
         for (EnvEntryType envEntry: envEntriesUntyped) {
             String name = envEntry.getEnvEntryName().getStringValue().trim();
+            addInjections(name, envEntry.getInjectionTargetArray(), componentContext);
             String type = envEntry.getEnvEntryType().getStringValue().trim();
             String text = envEntry.getEnvEntryValue().getStringValue().trim();
             try {

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -101,7 +101,7 @@
     }
 
     public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
-        JndiConsumer consumer = createJndiConsumer(specDD);
+        JndiConsumer consumer = createJndiConsumer(specDD, componentContext);
 //      processWebEjbAnnotations(module, consumer);
 
         Map<String, Object> map = null;
@@ -148,9 +148,9 @@
         return clientRef;
     }
 
-    protected JndiConsumer createJndiConsumer(XmlObject specDD) throws DeploymentException {
-        List<EjbRefType> ejbRefs = convert(specDD.selectChildren(ejbRefQNameSet), J2EE_CONVERTER, EjbRefType.class, EjbRefType.type);
-        List<EjbLocalRefType> ejbLocalRefs = convert(specDD.selectChildren(ejbLocalRefQNameSet), J2EE_CONVERTER, EjbLocalRefType.class, EjbLocalRefType.type);
+    protected JndiConsumer createJndiConsumer(XmlObject specDD, Map componentContext) throws DeploymentException {
+        List<EjbRefType> ejbRefs = convert(specDD.selectChildren(ejbRefQNameSet), JEE_CONVERTER, EjbRefType.class, EjbRefType.type);
+        List<EjbLocalRefType> ejbLocalRefs = convert(specDD.selectChildren(ejbLocalRefQNameSet), JEE_CONVERTER, EjbLocalRefType.class, EjbLocalRefType.type);
 
         // build jndi consumer
         JndiConsumer jndiConsumer = new SessionBean();
@@ -160,7 +160,8 @@
             jndiConsumer.getEjbRef().add(ref);
 
             // ejb-ref-name
-            ref.setEjbRefName(getStringValue(xmlbeansRef.getEjbRefName()));
+            String refName = getStringValue(xmlbeansRef.getEjbRefName());
+            ref.setEjbRefName(refName);
 
             // ejb-ref-type
             String refType = getStringValue(xmlbeansRef.getEjbRefType());
@@ -182,7 +183,7 @@
             // mapped-name
             ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
 
-            // injection-targets
+            // openejb handling of injection-targets
             if (xmlbeansRef.getInjectionTargetArray() != null) {
                 for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
                     InjectionTarget injectionTarget = new InjectionTarget();
@@ -191,6 +192,9 @@
                     ref.getInjectionTarget().add(injectionTarget);
                 }
             }
+            //geronimo's handling of injection-target
+            addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
+
         }
 
         for (EjbLocalRefType xmlbeansRef : ejbLocalRefs) {
@@ -199,7 +203,8 @@
             jndiConsumer.getEjbLocalRef().add(ref);
 
             // ejb-ref-name
-            ref.setEjbRefName(getStringValue(xmlbeansRef.getEjbRefName()));
+            String refName = getStringValue(xmlbeansRef.getEjbRefName());
+            ref.setEjbRefName(refName);
 
             // ejb-ref-type
             String refType = getStringValue(xmlbeansRef.getEjbRefType());
@@ -221,7 +226,7 @@
             // mapped-name
             ref.setMappedName(getStringValue(xmlbeansRef.getMappedName()));
 
-            // injection-targets
+            // openejb handling of injection-targets
             if (xmlbeansRef.getInjectionTargetArray() != null) {
                 for (InjectionTargetType injectionTargetType : xmlbeansRef.getInjectionTargetArray()) {
                     InjectionTarget injectionTarget = new InjectionTarget();
@@ -230,6 +235,8 @@
                     ref.getInjectionTarget().add(injectionTarget);
                 }
             }
+            //geronimo's handling of injection-target
+            addInjections(refName, xmlbeansRef.getInjectionTargetArray(), componentContext);
         }
         return jndiConsumer;
     }

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceContextRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -75,6 +75,7 @@
         for (PersistenceContextRefType persistenceContextRef : specPersistenceContextRefsUntyped) {
             String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName().getStringValue().trim();
 
+            addInjections(persistenceContextRefName, persistenceContextRef.getInjectionTargetArray(), componentContext);
             PersistenceContextTypeType persistenceContextType = persistenceContextRef.getPersistenceContextType();
             boolean transactionScoped = persistenceContextType == null || !persistenceContextType.getStringValue().equalsIgnoreCase("extended");
 

Modified: geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java?view=diff&rev=512007&r1=512006&r2=512007
==============================================================================
--- geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-persistence-jpa10-builder/src/main/java/org/apache/geronimo/persistence/builder/PersistenceUnitRefBuilder.java Mon Feb 26 12:52:05 2007
@@ -77,6 +77,7 @@
         for (PersistenceUnitRefType PersistenceUnitRef: specPersistenceUnitRefsUntyped) {
             String persistenceUnitRefName = PersistenceUnitRef.getPersistenceUnitRefName().getStringValue().trim();
 
+            addInjections(persistenceUnitRefName, PersistenceUnitRef.getInjectionTargetArray(), componentContext);
             AbstractNameQuery persistenceUnitNameQuery;
             GerPersistenceUnitRefType gerPersistenceUnitRef = gerPersistenceUnitRefsUntyped.remove(persistenceUnitRefName);
             if (gerPersistenceUnitRef != null) {



Mime
View raw message