geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r516141 - in /geronimo/server/trunk: ./ configs/client-deployer/src/plan/ configs/j2ee-deployer/src/plan/ configs/j2ee-server/ modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/ modules/geronimo-client/src/mai...
Date Thu, 08 Mar 2007 18:45:07 GMT
Author: djencks
Date: Thu Mar  8 10:45:05 2007
New Revision: 516141

URL: http://svn.apache.org/viewvc?view=rev&rev=516141
Log:
GERONIMO-2940, GERONIMO-2887  More injection work for app client and jetty: lifecycle methods verified on app client.  Ear lib dir available to app client.  Also upgrade to jetty snapshot for jetty lifecycle method support

Added:
    geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java   (with props)
Modified:
    geronimo/server/trunk/configs/client-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/j2ee-deployer/src/plan/plan.xml
    geronimo/server/trunk/configs/j2ee-server/pom.xml
    geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-client/src/main/java/org/apache/geronimo/client/AppClientContainer.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.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/AnnotatedApp.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApplicationClient.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedEjbJar.java
    geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedWebApp.java
    geronimo/server/trunk/modules/geronimo-j2ee/pom.xml
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/LifecycleMethod.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java
    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/pom.xml

Modified: geronimo/server/trunk/configs/client-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/client-deployer/src/plan/plan.xml?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/configs/client-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/client-deployer/src/plan/plan.xml Thu Mar  8 10:45:05 2007
@@ -61,6 +61,9 @@
             <pattern>
                 <name>ClientCorbaRefBuilder</name>
             </pattern>
+            <pattern>
+                <name>LifecycleMethodBuilder</name>
+            </pattern>
         </references>
         <reference name="ConnectorModuleBuilder">
             <name>ClientConnectorBuilder</name>

Modified: geronimo/server/trunk/configs/j2ee-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/j2ee-deployer/src/plan/plan.xml?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/configs/j2ee-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/j2ee-deployer/src/plan/plan.xml Thu Mar  8 10:45:05 2007
@@ -139,6 +139,9 @@
             <pattern>
                 <name>OpenEjbTSSLinkBuilder</name>
             </pattern>
+            <pattern>
+                <name>LifecycleMethodBuilder</name>
+            </pattern>
         </references>
     </gbean>
 
@@ -163,5 +166,6 @@
             </pattern>
         </references>
     </gbean>
+    <gbean name="LifecycleMethodBuilder" class="org.apache.geronimo.naming.deployment.LifecycleMethodBuilder"/>
 
 </module>

Modified: geronimo/server/trunk/configs/j2ee-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/j2ee-server/pom.xml?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/configs/j2ee-server/pom.xml (original)
+++ geronimo/server/trunk/configs/j2ee-server/pom.xml Thu Mar  8 10:45:05 2007
@@ -74,6 +74,11 @@
             <version>${version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-reflect</artifactId>
+        </dependency>
+
         <!-- purpose unknown -->
         <dependency>
             <groupId>asm</groupId>

Modified: geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Thu Mar  8 10:45:05 2007
@@ -25,7 +25,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -56,11 +55,10 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.SingleElementCollection;
-import org.apache.geronimo.j2ee.annotation.Injection;
-import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.deployment.AppClientModule;
 import org.apache.geronimo.j2ee.deployment.ConnectorModule;
 import org.apache.geronimo.j2ee.deployment.CorbaGBeanNameSource;
+import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
@@ -88,10 +86,10 @@
 import org.apache.geronimo.xbeans.javaee.ApplicationClientDocument;
 import org.apache.geronimo.xbeans.javaee.ApplicationClientType;
 import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
+import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xbean.finder.ClassFinder;
 
 
 /**
@@ -112,7 +110,7 @@
     private final NamespaceDrivenBuilderCollection serviceBuilder;
     private final NamingBuilderCollection namingBuilders;
 
-    private final Collection repositories;
+    private final Collection<Repository> repositories;
 
     private static final String GERAPPCLIENT_NAMESPACE = GerApplicationClientDocument.type.getDocumentElementName().getNamespaceURI();
 
@@ -121,7 +119,7 @@
             AbstractNameQuery transactionManagerObjectName,
             AbstractNameQuery connectionTrackerObjectName,
             AbstractNameQuery corbaGBeanObjectName,
-            Collection repositories,
+            Collection<Repository> repositories,
             ModuleBuilder connectorModuleBuilder,
             NamespaceDrivenBuilder securityBuilder,
             NamespaceDrivenBuilder serviceBuilder,
@@ -140,7 +138,7 @@
     public AppClientModuleBuilder(AbstractNameQuery transactionManagerObjectName,
             AbstractNameQuery connectionTrackerObjectName,
             AbstractNameQuery corbaGBeanObjectName,
-            Collection repositories,
+            Collection<Repository> repositories,
             Collection connectorModuleBuilder,
             Collection securityBuilder,
             Collection serviceBuilder,
@@ -163,7 +161,7 @@
             AbstractNameQuery transactionManagerObjectName,
             AbstractNameQuery connectionTrackerObjectName,
             AbstractNameQuery corbaGBeanObjectName,
-            Collection repositories,
+            Collection<Repository> repositories,
             SingleElementCollection connectorModuleBuilder,
             SingleElementCollection securityBuilder,
             Collection serviceBuilder, Collection namingBuilders) {
@@ -292,18 +290,16 @@
         AbstractName clientBaseName = naming.createRootName(clientEnvironment.getConfigId(), clientEnvironment.getConfigId().toString(), NameFactory.J2EE_APPLICATION);
 
         //start installing the resource adapters in the client.
-        Collection resourceModules = new ArrayList();
+        Collection<ConnectorModule> resourceModules = new ArrayList<ConnectorModule>();
         GerResourceType[] resources = gerAppClient.getResourceArray();
-        for (int i = 0; i < resources.length; i++) {
-            GerResourceType resource = resources[i];
+        for (GerResourceType resource : resources) {
             String path;
             JarFile connectorFile;
             if (resource.isSetExternalRar()) {
                 path = resource.getExternalRar().trim();
                 Artifact artifact = Artifact.create(path);
                 File file = null;
-                for (Iterator iterator = repositories.iterator(); iterator.hasNext();) {
-                    Repository repository = (Repository) iterator.next();
+                for (Repository repository : repositories) {
                     if (repository.contains(artifact)) {
                         file = repository.getLocation(artifact);
                         break;
@@ -326,7 +322,7 @@
                 }
             }
             XmlObject connectorPlan = resource.getConnector();
-            Module connectorModule = getConnectorModuleBuilder().createModule(connectorPlan, connectorFile, path, null, clientEnvironment, null, clientBaseName, naming, idBuilder);
+            ConnectorModule connectorModule = (ConnectorModule) getConnectorModuleBuilder().createModule(connectorPlan, connectorFile, path, null, clientEnvironment, null, clientBaseName, naming, idBuilder);
             resourceModules.add(connectorModule);
         }
 
@@ -450,12 +446,12 @@
 
     public void installModule(JarFile earFile, EARContext earContext, Module module, Collection configurationStores, ConfigurationStore targetConfigurationStore, Collection repositories) throws DeploymentException {
         // extract the app client jar file into a standalone packed jar file and add the contents to the output
-        JarFile moduleFile = module.getModuleFile();
-        try {
-            earContext.addIncludeAsPackedJar(URI.create(module.getTargetPath()), moduleFile);
-        } catch (IOException e) {
-            throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName());
-        }
+//        JarFile moduleFile = module.getModuleFile();
+//        try {
+//            earContext.addIncludeAsPackedJar(URI.create(module.getTargetPath()), moduleFile);
+//        } catch (IOException e) {
+//            throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName());
+//        }
         AppClientModule appClientModule = (AppClientModule) module;
         appClientModule.setEarFile(earFile);
         //create the ear context for the app client.
@@ -493,12 +489,29 @@
             );
             appClientModule.setEarContext(appClientDeploymentContext);
             appClientModule.setRootEarContext(earContext);
+            // extract the app client jar file into a standalone packed jar file and add the contents to the output
+            JarFile moduleFile = module.getModuleFile();
+            try {
+                appClientDeploymentContext.addIncludeAsPackedJar(URI.create(module.getTargetPath()), moduleFile);
+            } catch (IOException e) {
+                throw new DeploymentException("Unable to copy app client module jar into configuration: " + moduleFile.getName());
+            }
+            EARConfigBuilder.LibClasspath libClasspath = (EARConfigBuilder.LibClasspath) earContext.getGeneralData().get(EARConfigBuilder.LibClasspath.class);
+            if (libClasspath != null) {
+                for (String libEntryPath: libClasspath) {
+                    try {
+                        NestedJarFile library = new NestedJarFile(earFile, libEntryPath);
+                        appClientDeploymentContext.addIncludeAsPackedJar(URI.create(libEntryPath), library);
+                    } catch (IOException e) {
+                        throw new DeploymentException("Could not add to app client library classpath: " + libEntryPath, e);
+                    }
+                }
+            }
         } catch (DeploymentException e) {
             cleanupAppClientDir(appClientDir);
             throw e;
         }
-        for (Iterator resources = appClientModule.getResourceModules().iterator(); resources.hasNext();) {
-            ConnectorModule connectorModule = (ConnectorModule) resources.next();
+        for (ConnectorModule connectorModule : appClientModule.getResourceModules()) {
             getConnectorModuleBuilder().installModule(connectorModule.getModuleFile(), appClientDeploymentContext, connectorModule, configurationStores, targetConfigurationStore, repositories);
         }
 
@@ -508,8 +521,7 @@
         namingBuilders.buildEnvironment(clientModule.getSpecDD(), clientModule.getVendorDD(), ((AppClientModule)clientModule).getClientEnvironment());
 
         AppClientModule appClientModule = ((AppClientModule) clientModule);
-        for (Iterator resources = appClientModule.getResourceModules().iterator(); resources.hasNext();) {
-            ConnectorModule connectorModule = (ConnectorModule) resources.next();
+        for (ConnectorModule connectorModule : appClientModule.getResourceModules()) {
             getConnectorModuleBuilder().initContext(appClientModule.getEarContext(), connectorModule, cl);
         }
     }
@@ -573,19 +585,20 @@
                     serviceBuilder.build(geronimoAppClient, appClientDeploymentContext, appClientDeploymentContext);
                     //deploy the resource adapters specified in the geronimo-application.xml
 
-                    for (Iterator resources = appClientModule.getResourceModules().iterator(); resources.hasNext();) {
-                        ConnectorModule connectorModule = (ConnectorModule) resources.next();
+                    for (ConnectorModule connectorModule : appClientModule.getResourceModules()) {
                         getConnectorModuleBuilder().addGBeans(appClientDeploymentContext, connectorModule, appClientClassLoader, repositories);
                     }
                 }
 
-                Map<String, Holder> injectionsMap;
+                //Holder may be loaded in the "client" module classloader here, whereas
+                //NamingBuilder.INJECTION_KEY.get(buildingContext) returns a Holder loaded in the j2ee-server classloader.
+                Object holder;
                 // add the app client static jndi provider
                 //TODO track resource ref shared and app managed security
                 AbstractName jndiContextName = earContext.getNaming().createChildName(appClientDeploymentContext.getModuleName(), "StaticJndiContext", "StaticJndiContext");
                 GBeanData jndiContextGBeanData = new GBeanData(jndiContextName, StaticJndiContextPlugin.GBEAN_INFO);
                 try {
-                    Map buildingContext = new HashMap();
+                    Map<NamingBuilder.Key, Object> buildingContext = new HashMap<NamingBuilder.Key, Object>();
                     buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, jndiContextName);
                     Configuration localConfiguration = appClientDeploymentContext.getConfiguration();
                     Configuration remoteConfiguration = earContext.getConfiguration();
@@ -605,7 +618,7 @@
                     }
 
                     appClientModuleGBeanData.setAttribute("deploymentDescriptor", appClientModule.getOriginalSpecDD());
-                    injectionsMap = NamingBuilder.INJECTION_KEY.get(buildingContext);
+                    holder = NamingBuilder.INJECTION_KEY.get(buildingContext);
                     jndiContextGBeanData.setAttribute("context", NamingBuilder.JNDI_KEY.get(buildingContext));
                 } catch (DeploymentException e) {
                     throw e;
@@ -642,14 +655,7 @@
                         appClientContainerGBeanData.setAttribute("defaultPrincipal", defaultPrincipal);
                     }
                     appClientContainerGBeanData.setReferencePattern("JNDIContext", jndiContextName);
-                    Holder injections = injectionsMap.get(appClientModule.getMainClassName());
-                    if (injections != null) {
-                        appClientContainerGBeanData.setAttribute("injections", injections);
-                    }
-                    Holder callbackHandlerInjections = injectionsMap.get(callbackHandlerClassName);
-                    if (callbackHandlerInjections != null) {
-                        appClientContainerGBeanData.setAttribute("callbackHandlerInjections", callbackHandlerInjections);
-                    }
+                    appClientContainerGBeanData.setAttribute("holder", holder);
 
                 } catch (Exception e) {
                     throw new DeploymentException("Unable to initialize AppClientModule GBean", e);
@@ -703,7 +709,10 @@
         catch (ClassNotFoundException e) {
             throw new DeploymentException("AppClientModuleBuilder: Could not load main class: " + mainClass);
         }
-        classes.add(mainClas);
+        while (mainClas != null && mainClas != Object.class) {
+            classes.add(mainClas);
+            mainClas = mainClas.getSuperclass();
+        }
 
         // Get the callback-handler from the deployment descriptor
         if (appClient.isSetCallbackHandler()) {

Modified: geronimo/server/trunk/modules/geronimo-client/src/main/java/org/apache/geronimo/client/AppClientContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-client/src/main/java/org/apache/geronimo/client/AppClientContainer.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-client/src/main/java/org/apache/geronimo/client/AppClientContainer.java (original)
+++ geronimo/server/trunk/modules/geronimo-client/src/main/java/org/apache/geronimo/client/AppClientContainer.java Thu Mar  8 10:45:05 2007
@@ -16,31 +16,30 @@
  */
 package org.apache.geronimo.client;
 
-import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.PrivilegedAction;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+import javax.naming.Context;
+import javax.naming.NamingException;
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
-import javax.naming.NamingException;
-import javax.naming.Context;
 
 import org.apache.geronimo.gbean.AbstractName;
 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.geronimo.j2ee.annotation.Holder;
-import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
+import org.apache.geronimo.j2ee.annotation.Injection;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.Callers;
+import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.util.ConfigurationUtil;
 import org.apache.xbean.recipe.ObjectRecipe;
@@ -64,8 +63,7 @@
     private final Method mainMethod;
     private final ClassLoader classLoader;
     private final Kernel kernel;
-    private final Holder injections;
-    private final Holder callbackHandlerinjections;
+    private final Holder holder;
     private CallbackHandler callbackHandler;
 
     public AppClientContainer(String mainClassName,
@@ -73,8 +71,7 @@
             String realmName,
             String callbackHandlerClassName,
             DefaultPrincipal defaultPrincipal,
-            Holder injections,
-            Holder callbackHandlerinjections,
+            Holder holder,
             AppClientPlugin jndiContext,
             ClassLoader classLoader,
             Kernel kernel
@@ -100,8 +97,7 @@
         } else {
             defaultSubject = null;
         }
-        this.injections = injections;
-        this.callbackHandlerinjections = callbackHandlerinjections;
+        this.holder = holder == null ? Holder.EMPTY : holder;
         this.classLoader = classLoader;
         this.kernel = kernel;
         this.jndiContext = jndiContext;
@@ -139,41 +135,7 @@
             Context componentContext = jndiContext.getJndiContext();
 
             if (callbackHandlerClass != null) {
-                ObjectRecipe objectRecipe = new ObjectRecipe(callbackHandlerClass);
-                objectRecipe.allow(Option.FIELD_INJECTION);
-                objectRecipe.allow(Option.PRIVATE_PROPERTIES);
-                objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
-                if (callbackHandlerinjections != null && callbackHandlerinjections.getInjections() != null) {
-                    //TODO figure out how to call a String[] arg constructor
-                    for (Injection injection : callbackHandlerinjections.getInjections()) {
-                        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 ", e);
-                        }
-                    }
-                }
-                callbackHandler = (CallbackHandler) objectRecipe.create(classLoader);
-                Map unsetProperties = objectRecipe.getUnsetProperties();
-                if (unsetProperties.size() > 0) {
-                    for (Object property : unsetProperties.keySet()) {
-//                log.warning("Injection: No such property '"+property+"' in class "+_class.getName());
-                    }
-                }
-                if (callbackHandlerinjections != null && callbackHandlerinjections.getPostConstruct() != null) {
-                    LifecycleMethod postConstruct = callbackHandlerinjections.getPostConstruct();
-                    postConstruct.call(callbackHandler, null);
-                }
+                callbackHandler = (CallbackHandler) holder.newInstance(callbackHandlerClass, classLoader, componentContext);
                 //look for a constructor taking the args
                 /*
                 CallbackHandler callbackHandler;
@@ -199,9 +161,18 @@
             objectRecipe.allow(Option.PRIVATE_PROPERTIES);
             objectRecipe.allow(Option.STATIC_PROPERTIES);
             objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
-            if (injections != null && injections.getInjections() != null) {
-                for (Injection injection : injections.getInjections()) {
-                    try {                                                          
+            Class mainClass = classLoader.loadClass(mainClassName);
+            List<Injection> injections = new ArrayList<Injection>();
+            while (mainClass != null && mainClass != Object.class) {
+                List<Injection> perClass = holder.getInjections(mainClass.getName());
+                if (perClass != null) {
+                    injections.addAll(perClass);
+                }
+                mainClass = mainClass.getSuperclass();
+            }
+            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);
@@ -225,9 +196,8 @@
 //                log.warning("Injection: No such property '"+property+"' in class "+_class.getName());
                 }
             }
-            if (injections != null && injections.getPostConstruct() != null) {
-                LifecycleMethod postConstruct = injections.getPostConstruct();
-                postConstruct.call(null, clazz);
+            if (holder.getPostConstruct() != null) {
+                Holder.apply(null, clazz, holder.getPostConstruct());
             }
 
             if (clientSubject == null) {
@@ -265,9 +235,8 @@
     }
 
     public void doStop() throws Exception {
-        if (callbackHandler != null && callbackHandlerinjections != null && callbackHandlerinjections.getPreDestroy() != null) {
-            LifecycleMethod preDestroy = callbackHandlerinjections.getPreDestroy();
-            preDestroy.call(callbackHandler, null);
+        if (callbackHandler != null) {
+            holder.destroyInstance(callbackHandler);
         }
         if (loginContext != null) {
             loginContext.logout();
@@ -296,8 +265,7 @@
         infoFactory.addAttribute("realmName", String.class, true);
         infoFactory.addAttribute("callbackHandlerClassName", String.class, true);
         infoFactory.addAttribute("defaultPrincipal", DefaultPrincipal.class, true);
-        infoFactory.addAttribute("injections", Holder.class, true);
-        infoFactory.addAttribute("callbackHandlerInjections", Holder.class, true);
+        infoFactory.addAttribute("holder", Holder.class, true);
 
         infoFactory.addReference("JNDIContext", AppClientPlugin.class, NameFactory.GERONIMO_SERVICE);
 
@@ -306,15 +274,14 @@
 
 
         infoFactory.setConstructor(new String[]{"mainClassName",
-                                                "appClientModuleName",
-                                                "realmName",
-                                                "callbackHandlerClassName",
-                                                "defaultPrincipal",
-                                                "injections",
-                                                "callbackHandlerInjections",
-                                                "JNDIContext",
-                                                "classLoader",
-                                                "kernel"
+                "appClientModuleName",
+                "realmName",
+                "callbackHandlerClassName",
+                "defaultPrincipal",
+                "holder",
+                "JNDIContext",
+                "classLoader",
+                "kernel"
         });
 
         GBEAN_INFO = infoFactory.getBeanInfo();

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java Thu Mar  8 10:45:05 2007
@@ -20,7 +20,6 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.HashMap;
 import java.util.jar.JarFile;
 
@@ -39,10 +38,10 @@
     private JarFile earFile;
     private final AbstractName appClientName;
     private final String mainClassName;
-    private final Collection resourceModules;
+    private final Collection<ConnectorModule> resourceModules;
 
 
-    public AppClientModule(boolean standAlone, AbstractName moduleName, AbstractName appClientName, Environment serverEnvironment, Environment clientEnvironment, JarFile moduleFile, String targetPath, XmlObject specDD, String mainClassName, XmlObject vendorDD, String originalSpecDD, Collection resourceModules, AnnotatedApplicationClient annotatedAppClient ) {
+    public AppClientModule(boolean standAlone, AbstractName moduleName, AbstractName appClientName, Environment serverEnvironment, Environment clientEnvironment, JarFile moduleFile, String targetPath, XmlObject specDD, String mainClassName, XmlObject vendorDD, String originalSpecDD, Collection<ConnectorModule> resourceModules, AnnotatedApplicationClient annotatedAppClient ) {
         super(standAlone, moduleName, serverEnvironment, moduleFile, targetPath, specDD, vendorDD, originalSpecDD, null, new HashMap(), annotatedAppClient );
         this.clientEnvironment = clientEnvironment;
         this.appClientName = appClientName;
@@ -78,15 +77,14 @@
         context.addClass(location, fqcn, bytes);
     }
 
-    public Collection getResourceModules() {
+    public Collection<ConnectorModule> getResourceModules() {
         return resourceModules;
     }
 
     public void close() {
         if (resourceModules != null) {
-            for (Iterator iterator = resourceModules.iterator(); iterator.hasNext();) {
-                ConnectorModule connectorModule = (ConnectorModule) iterator.next();
-                connectorModule.close();
+            for (ConnectorModule resourceModule : resourceModules) {
+                resourceModule.close();
             }
         }
         super.close();

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Thu Mar  8 10:45:05 2007
@@ -515,6 +515,7 @@
                 //get the value of the library-directory element in spec DD
                 ApplicationType specDD = (ApplicationType) applicationInfo.getSpecDD();
                 String libDir = getLibraryDirectory(specDD);
+                LibClasspath libClasspath = new LibClasspath();
                 for (Enumeration<JarEntry> e = earFile.entries(); e.hasMoreElements();) {
                     ZipEntry entry = e.nextElement();
                     String entryName = entry.getName();
@@ -529,10 +530,14 @@
                     if (libDir != null && entry.getName().startsWith(libDir) && entry.getName().endsWith(".jar")) {
                         NestedJarFile library = new NestedJarFile(earFile, entry.getName());
                         earContext.addIncludeAsPackedJar(URI.create(entry.getName()), library);
+                        libClasspath.add(entry.getName());
                     } else if (addEntry) {
                         earContext.addFile(URI.create(entry.getName()), earFile, entry);
                     }
                 }
+                if (!libClasspath.isEmpty()) {
+                    earContext.getGeneralData().put(LibClasspath.class, libClasspath);
+                }
             }
 
             GerApplicationType geronimoApplication = (GerApplicationType) applicationInfo.getVendorDD();
@@ -1026,6 +1031,8 @@
         }
         throw new IllegalArgumentException("Unknown module type: " + module.getClass().getName());
     }
+
+    public static class LibClasspath extends ArrayList<String> {}
 
     public static final GBeanInfo GBEAN_INFO;
 

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=516141&r1=516140&r2=516141
==============================================================================
--- 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 Thu Mar  8 10:45:05 2007
@@ -50,12 +50,12 @@
             return result;
         }
     };
-    Key<Map<String, Holder>> INJECTION_KEY = new Key<Map<String, Holder>>() {
+    Key<Holder> INJECTION_KEY = new Key<Holder>() {
 
-        public Map<String, Holder> get(Map context) {
-            Map<String, Holder> result = (Map<String, Holder>) context.get(this);
+        public Holder get(Map context) {
+            Holder result = (Holder) context.get(this);
             if (result == null) {
-                result = new HashMap<String, Holder>();
+                result = new Holder();
                 context.put(this, result);
             }
             return result;

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApp.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApp.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApp.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApp.java Thu Mar  8 10:45:05 2007
@@ -26,6 +26,7 @@
 import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
+import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
 
 /**
  * Many of the classes generated from the JEE schemas have methods with identical signatures (see
@@ -115,4 +116,12 @@
      * @return ambiguousRefs list
      */
     List<EjbRefType> getAmbiguousEjbRefs();
+
+    LifecycleCallbackType[] getPostConstructArray();
+    LifecycleCallbackType addPostConstruct();
+
+    LifecycleCallbackType[] getPreDestroyArray();
+    LifecycleCallbackType addPreDestroy();
+
+
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApplicationClient.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApplicationClient.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApplicationClient.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedApplicationClient.java Thu Mar  8 10:45:05 2007
@@ -30,6 +30,7 @@
 import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
+import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
 
 /**
  * Wrapper class to encapsulate the ApplicationClientType class with an interface that the various
@@ -160,5 +161,21 @@
             ambiguousEjbRefs = new ArrayList<EjbRefType>();
         }
         return this.ambiguousEjbRefs;
+    }
+
+    public LifecycleCallbackType[] getPostConstructArray() {
+        return applicationClient.getPostConstructArray();
+    }
+
+    public LifecycleCallbackType addPostConstruct() {
+        return applicationClient.addNewPostConstruct();
+    }
+
+    public LifecycleCallbackType[] getPreDestroyArray() {
+        return applicationClient.getPreDestroyArray();
+    }
+
+    public LifecycleCallbackType addPreDestroy() {
+        return applicationClient.addNewPreDestroy();
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedEjbJar.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedEjbJar.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedEjbJar.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedEjbJar.java Thu Mar  8 10:45:05 2007
@@ -30,6 +30,7 @@
 import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
+import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
 
 /**
  * Wrapper class to encapsulate the EjbJarType class with an interface that the various
@@ -159,5 +160,21 @@
             ambiguousEjbRefs = new ArrayList<EjbRefType>();
         }
         return this.ambiguousEjbRefs;
+    }
+
+    public LifecycleCallbackType[] getPostConstructArray() {
+        return new LifecycleCallbackType[0];
+    }
+
+    public LifecycleCallbackType addPostConstruct() {
+        return null;
+    }
+
+    public LifecycleCallbackType[] getPreDestroyArray() {
+        return new LifecycleCallbackType[0];
+    }
+
+    public LifecycleCallbackType addPreDestroy() {
+        return null;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedWebApp.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedWebApp.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedWebApp.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/annotation/AnnotatedWebApp.java Thu Mar  8 10:45:05 2007
@@ -30,6 +30,7 @@
 import org.apache.geronimo.xbeans.javaee.ResourceRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
 
 /**
  * Wrapper class to encapsulate the WebAppType class with an interface that the various
@@ -161,5 +162,21 @@
             ambiguousEjbRefs = new ArrayList<EjbRefType>();
         }
         return this.ambiguousEjbRefs;
+    }
+
+    public LifecycleCallbackType[] getPostConstructArray() {
+        return webApp.getPostConstructArray();
+    }
+
+    public LifecycleCallbackType addPostConstruct() {
+        return webApp.addNewPostConstruct();
+    }
+
+    public LifecycleCallbackType[] getPreDestroyArray() {
+        return webApp.getPreDestroyArray();
+    }
+
+    public LifecycleCallbackType addPreDestroy() {
+        return webApp.addNewPreDestroy();
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/pom.xml?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee/pom.xml Thu Mar  8 10:45:05 2007
@@ -50,7 +50,12 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-ejb_3.0_spec</artifactId>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-reflect</artifactId>
+        </dependency>
+
     </dependencies>
     
 </project>

Modified: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java Thu Mar  8 10:45:05 2007
@@ -20,8 +20,19 @@
 
 package org.apache.geronimo.j2ee.annotation;
 
-import java.util.List;
 import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.xbean.recipe.ObjectRecipe;
+import org.apache.xbean.recipe.Option;
+import org.apache.xbean.recipe.StaticRecipe;
 
 /**
  * @version $Rev$ $Date$
@@ -29,50 +40,136 @@
 public class Holder implements Serializable {
 
     public static final Holder EMPTY = new Holder() {
-
-        @Override
-        public void setInjections(List<Injection> injections) {
-        }
-
-        @Override
-        public void setPostConstruct(LifecycleMethod postConstruct) {
-        }
-
-        @Override
-        public void setPreDestroy(LifecycleMethod preDestroy) {
-        }
     };
-    
-    private List<Injection> injections;
-    private LifecycleMethod postConstruct;
-    private LifecycleMethod preDestroy;
+
+    private Map<String, List<Injection>> injectionMap;
+    private Map<String, LifecycleMethod> postConstruct;
+    private Map<String, LifecycleMethod> preDestroy;
 
 
     public Holder() {
     }
 
 
-    public void setInjections(List<Injection> injections) {
-        this.injections = injections;
+    public void addInjection(String className, Injection injection) {
+        if (injectionMap == null) {
+            injectionMap = new HashMap<String, List<Injection>>();
+        }
+        List<Injection> injections = injectionMap.get(className);
+        if (injections == null) {
+            injections = new ArrayList<Injection>();
+            injectionMap.put(className, injections);
+        }
+        injections.add(injection);
+    }
+
+    public void addPostConstructs(Map<String, LifecycleMethod> newPostConstructs) {
+        this.postConstruct = merge(postConstruct, newPostConstructs);
     }
 
-    public void setPostConstruct(LifecycleMethod postConstruct) {
-        this.postConstruct = postConstruct;
+    public void addPreDestroys(Map<String, LifecycleMethod> newPreDestroys) {
+        this.preDestroy = merge(preDestroy, newPreDestroys);
     }
 
-    public void setPreDestroy(LifecycleMethod preDestroy) {
-        this.preDestroy = preDestroy;
+    private Map<String, LifecycleMethod> merge(Map<String, LifecycleMethod> old, Map<String, LifecycleMethod> additional) {
+        if (old == null) {
+            return additional;
+        }
+        if (additional == null) {
+            return old;
+        }
+        old.putAll(additional);
+        return old;
     }
 
-    public List<Injection> getInjections() {
-        return injections;
+    public List<Injection> getInjections(String className) {
+        if (injectionMap == null) {
+            return null;
+        }
+        return injectionMap.get(className);
     }
 
-    public LifecycleMethod getPostConstruct() {
+    public Map<String, LifecycleMethod> getPostConstruct() {
         return postConstruct;
     }
 
-    public LifecycleMethod getPreDestroy() {
+    public Map<String, LifecycleMethod> getPreDestroy() {
         return preDestroy;
     }
+
+    public boolean isEmpty() {
+        return (injectionMap == null || injectionMap.isEmpty())
+                && (postConstruct == null || postConstruct.isEmpty())
+                && (preDestroy == null || preDestroy.isEmpty());
+    }
+
+    public Object newInstance(String className, ClassLoader classLoader, Context context) throws IllegalAccessException, InstantiationException {
+        ObjectRecipe objectRecipe = new ObjectRecipe(className);
+        objectRecipe.allow(Option.FIELD_INJECTION);
+        objectRecipe.allow(Option.PRIVATE_PROPERTIES);
+        objectRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
+        List<Injection> callbackHandlerinjections = getInjections(className);
+        if (callbackHandlerinjections != null) {
+            for (Injection injection : callbackHandlerinjections) {
+                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 = context.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 ", e);
+                }
+            }
+        }
+        Object result = objectRecipe.create(classLoader);
+        Map unsetProperties = objectRecipe.getUnsetProperties();
+        if (unsetProperties.size() > 0) {
+            for (Object property : unsetProperties.keySet()) {
+//                log.warning("Injection: No such property '"+property+"' in class "+_class.getName());
+            }
+        }
+        if (getPostConstruct() != null) {
+            try {
+                apply(result, null, postConstruct);
+            } catch (InvocationTargetException e) {
+                Throwable cause = e.getCause();
+                throw (InstantiationException) new InstantiationException("Could not call postConstruct method").initCause(cause);
+            }
+        }
+        return result;
+    }
+
+    public void destroyInstance(Object o) throws Exception {
+        Class clazz = o.getClass();
+        Map<String, LifecycleMethod> preDestroy = getPreDestroy();
+        if (preDestroy != null) {
+            apply(o, clazz, preDestroy);
+        }
+    }
+
+    public static void apply(Object o, Class clazz, Map<String, LifecycleMethod> map) throws IllegalAccessException, InvocationTargetException {
+        if (clazz == null) {
+            clazz = o.getClass();
+        }
+        ArrayList<Class> classes = new ArrayList<Class>();
+        while (clazz != null && clazz != Object.class) {
+            classes.add(clazz);
+            clazz = clazz.getSuperclass();
+        }
+        for (int i = classes.size() - 1; i > -1; i--) {
+            Class clazz1 = classes.get(i);
+            LifecycleMethod m = map.get(clazz1.getName());
+            if (m != null) {
+                m.call(o, clazz1);
+            }
+        }
+    }
+
 }

Modified: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/LifecycleMethod.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/LifecycleMethod.java?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/LifecycleMethod.java (original)
+++ geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/LifecycleMethod.java Thu Mar  8 10:45:05 2007
@@ -50,10 +50,16 @@
         if (clazz == null) {
             clazz = o.getClass();
         }
-        Method m;
-        try {
-            m = clazz.getMethod(methodName);
-        } catch (NoSuchMethodException e) {
+        Method m = null;
+        while (m == null && clazz != null && clazz != Object.class) {
+            try {
+                m = clazz.getDeclaredMethod(methodName);
+            } catch (NoSuchMethodException e) {
+                clazz = clazz.getSuperclass();
+            }
+
+        }
+        if (m == null) {
             throw new AssertionError("We checked that the class had this method at deploy time. expected class: " + targetClassName + ", actual class: " + clazz.getName() + ", method: " + methodName);
         }
         if (!m.isAccessible()) {
@@ -64,7 +70,7 @@
                 m.setAccessible(false);
             }
         } else {
-        m.invoke(o);
+            m.invoke(o);
         }
     }
 }

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=516141&r1=516140&r2=516141
==============================================================================
--- 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 Thu Mar  8 10:45:05 2007
@@ -65,7 +65,6 @@
 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.j2ee.annotation.Holder;
 import org.apache.geronimo.jetty6.Host;
 import org.apache.geronimo.jetty6.JettyDefaultServletHolder;
@@ -112,7 +111,6 @@
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.geronimo.xbeans.javaee.WelcomeFileListType;
-import org.apache.xbean.finder.ClassFinder;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.mortbay.jetty.security.BasicAuthenticator;
@@ -345,7 +343,7 @@
         }
 
         Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
-        Map<String, Holder> injections = NamingBuilder.INJECTION_KEY.get(buildingContext);
+        Holder holder = NamingBuilder.INJECTION_KEY.get(buildingContext);
 
         GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
         try {
@@ -357,7 +355,7 @@
                 webModuleData.setReferencePattern("J2EEApplication", earContext.getModuleName());
             }
 
-            webModuleData.setAttribute("injections", injections);
+            webModuleData.setAttribute("holder", holder);
 
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
             Set securityRoles = collectRoleNames(webApp);

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=516141&r1=516140&r2=516141
==============================================================================
--- 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 Thu Mar  8 10:45:05 2007
@@ -103,7 +103,7 @@
     private final WebAppContext webAppContext;//delegate
     private final AbstractImmutableHandler lifecycleChain;
     private final Context componentContext;
-    private final Map<String, Holder> injectionMap;
+    private final Holder holder;
 
     private final Set servletNames = new HashSet();
 
@@ -124,7 +124,7 @@
         webAppContext = null;
         lifecycleChain = null;
         componentContext = null;
-        injectionMap = null;
+        holder = null;
     }
 
     public JettyWebAppContext(String objectName,
@@ -155,7 +155,7 @@
             PermissionCollection checkedPermissions,
             PermissionCollection excludedPermissions,
 
-            Map<String, Holder> injectionMap,
+            Holder holder,
 
             Host host,
             TransactionManager transactionManager,
@@ -172,7 +172,7 @@
         assert trackedConnectionAssociator != null;
         assert jettyContainer != null;
 
-        this.injectionMap = injectionMap;
+        this.holder = holder == null? Holder.EMPTY: holder;
 
         SessionHandler sessionHandler;
         if (null != handlerFactory) {
@@ -342,62 +342,15 @@
         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();
-        Holder holder = injectionMap.get(className);
-        if (holder == null) {
-            holder = Holder.EMPTY;
-        }
-        List<Injection> injections = holder.getInjections();
-        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(webClassLoader);
-        Map unsetProperties = objectRecipe.getUnsetProperties();
-        if (unsetProperties.size() > 0) {
-            for (Object property : unsetProperties.keySet()) {
-//                log.warning("Injection: No such property '"+property+"' in class "+_class.getName());
-            }
-        }
-        LifecycleMethod postConstruct = holder.getPostConstruct();
-        if (postConstruct != null) {
-            try {
-                postConstruct.call(filter, null);
-            } catch (InvocationTargetException e) {
-                Throwable cause = e.getCause();
-                throw (InstantiationException)new InstantiationException("Could not call postConstruct method").initCause(cause);
-            }
-        }
-        return filter;
-
+        return holder.newInstance(clazz.getName(), webClassLoader, componentContext);
     }
 
     public void destroyInstance(Object o) throws Exception {
         Class clazz = o.getClass();
-        Holder holder = injectionMap.get(clazz.getName());
         if (holder != null) {
-            LifecycleMethod lifecycleMethod = holder.getPreDestroy();
-            if (lifecycleMethod != null) {
-                lifecycleMethod.call(o, o.getClass());
+            Map<String, LifecycleMethod> preDestroy = holder.getPreDestroy();
+            if (preDestroy != null) {
+                Holder.apply(o, clazz, preDestroy);
             }
         }
     }
@@ -649,7 +602,7 @@
         infoBuilder.addAttribute("checkedPermissions", PermissionCollection.class, true);
         infoBuilder.addAttribute("excludedPermissions", PermissionCollection.class, true);
 
-        infoBuilder.addAttribute("injections", Map.class, true);
+        infoBuilder.addAttribute("holder", Holder.class, true);
 
         infoBuilder.addReference("J2EEServer", J2EEServer.class);
         infoBuilder.addReference("J2EEApplication", J2EEApplication.class);
@@ -693,7 +646,7 @@
                 "checkedPermissions",
                 "excludedPermissions",
 
-                "injections",
+                "holder",
 
                 "Host",
                 "TransactionManager",

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=516141&r1=516140&r2=516141
==============================================================================
--- 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 Thu Mar  8 10:45:05 2007
@@ -117,7 +117,7 @@
                 defaultPrincipal,
                 checkedPermissions,
                 excludedPermissions,
-                new HashMap<String, Holder>(),
+                null,
                 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=516141&r1=516140&r2=516141
==============================================================================
--- 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 Thu Mar  8 10:45:05 2007
@@ -293,41 +293,12 @@
 
 
     protected void addInjections(String jndiName, InjectionTargetType[] injectionTargetArray, Map sharedContext) {
-        Map<String, Holder> holders = NamingBuilder.INJECTION_KEY.get(sharedContext);
+        Holder holder = NamingBuilder.INJECTION_KEY.get(sharedContext);
         for (InjectionTargetType injectionTarget : injectionTargetArray) {
             String targetName = injectionTarget.getInjectionTargetName().getStringValue().trim();
             String targetClassName = injectionTarget.getInjectionTargetClass().getStringValue().trim();
-            Holder holder = getHolder(holders, targetClassName);
-            List<Injection> injections = holder.getInjections();
-            if (injections == null) {
-                injections = new ArrayList<Injection>();
-                holder.setInjections(injections);
-            }
-            injections.add(new Injection(targetClassName, targetName, jndiName));
+            holder.addInjection(targetClassName, new Injection(targetClassName, targetName, jndiName));
         }
-    }
-
-    protected void addPostConstruct(LifecycleMethod postConstruct, Map sharedContext) {
-        Map<String, Holder> holders = NamingBuilder.INJECTION_KEY.get(sharedContext);
-        String targetClassName = postConstruct.getTargetClassName();
-        Holder holder = getHolder(holders, targetClassName);
-        holder.setPostConstruct(postConstruct);
-    }
-
-    protected void addPreDestroy(LifecycleMethod preDestroy, Map sharedContext) {
-        Map<String, Holder> holders = NamingBuilder.INJECTION_KEY.get(sharedContext);
-        String targetClassName = preDestroy.getTargetClassName();
-        Holder holder = getHolder(holders, targetClassName);
-        holder.setPreDestroy(preDestroy);
-    }
-
-    private Holder getHolder(Map<String, Holder> holders, String targetClassName) {
-        Holder holder = holders.get(targetClassName);
-        if (holder == null) {
-            holder = new Holder();
-            holders.put(targetClassName, holder);
-        }
-        return holder;
     }
 
 }

Added: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java?view=auto&rev=516141
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java (added)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java Thu Mar  8 10:45:05 2007
@@ -0,0 +1,137 @@
+/*
+ * 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.naming.deployment;
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+import java.lang.reflect.Method;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedApp;
+import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
+import org.apache.geronimo.j2ee.annotation.Holder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
+import org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType;
+import org.apache.geronimo.xbeans.javaee.JavaIdentifierType;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.xbean.finder.ClassFinder;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class LifecycleMethodBuilder extends AbstractNamingBuilder {
+    public void buildNaming(XmlObject specDD, XmlObject plan, Configuration localConfiguration, Configuration remoteConfiguration, Module module, Map componentContext) throws DeploymentException {
+        ClassFinder classFinder = module.getClassFinder();
+        AnnotatedApp annotatedApp = module.getAnnotatedApp();
+        if (annotatedApp == null) {
+            throw new NullPointerException("No AnnotatedApp supplied");
+        }
+        Map<String, LifecycleCallbackType> postConstructMap = mapLifecycleCallbacks(annotatedApp.getPostConstructArray());
+        Map<String, LifecycleCallbackType> preDestroyMap = mapLifecycleCallbacks(annotatedApp.getPreDestroyArray());
+        if (module.getClassFinder() != null) {
+            List<Method> postConstructs = classFinder.findAnnotatedMethods(PostConstruct.class);
+            for (Method m: postConstructs) {
+                String methodName = m.getName();
+                String className = m.getDeclaringClass().getName();
+                if (!postConstructMap.containsKey(className)) {
+                    LifecycleCallbackType  callback = annotatedApp.addPostConstruct();
+                    FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
+                    classType.setStringValue(className);
+                    JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
+                    method.setStringValue(methodName);
+                    postConstructMap.put(className, callback);
+                }
+            }
+            List<Method> preDestroys = classFinder.findAnnotatedMethods(PreDestroy.class);
+            for (Method m: preDestroys) {
+                String methodName = m.getName();
+                String className = m.getDeclaringClass().getName();
+                if (!preDestroyMap.containsKey(className)) {
+                    LifecycleCallbackType  callback = annotatedApp.addPreDestroy();
+                    FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
+                    classType.setStringValue(className);
+                    JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
+                    method.setStringValue(methodName);
+                    preDestroyMap.put(className, callback);
+                }
+            }
+        }
+        Map<String, LifecycleMethod> postConstructs = map(postConstructMap);
+        Map<String, LifecycleMethod> preDestroys = map(preDestroyMap);
+        Holder holder = NamingBuilder.INJECTION_KEY.get(componentContext);
+        holder.addPostConstructs(postConstructs);
+        holder.addPreDestroys(preDestroys);
+    }
+
+    private Map<String, LifecycleMethod> map(Map<String, LifecycleCallbackType> lifecycleCallbackTypes) {
+        if (lifecycleCallbackTypes.isEmpty()) {
+            return null;
+        }
+        Map<String, LifecycleMethod> map = new HashMap<String, LifecycleMethod>();
+        for (Map.Entry<String, LifecycleCallbackType> entry: lifecycleCallbackTypes.entrySet()) {
+            String className = entry.getKey();
+            LifecycleCallbackType callback = entry.getValue();
+            LifecycleMethod method = new LifecycleMethod(className, callback.getLifecycleCallbackMethod().getStringValue().trim());
+            map.put(className, method);
+        }
+        return map;
+    }
+
+    private Map<String, LifecycleCallbackType> mapLifecycleCallbacks(LifecycleCallbackType[] callbackArray) {
+        Map<String, LifecycleCallbackType> map = new HashMap<String, LifecycleCallbackType>();
+        for (LifecycleCallbackType callback: callbackArray) {
+            String className = callback.getLifecycleCallbackClass().getStringValue().trim();
+            map.put(className, callback);
+        }
+        return map;
+    }
+
+    public QNameSet getSpecQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public QNameSet getPlanQNameSet() {
+        return QNameSet.EMPTY;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(LifecycleMethodBuilder.class, NameFactory.MODULE_BUILDER);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/LifecycleMethodBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=516141&r1=516140&r2=516141
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Thu Mar  8 10:45:05 2007
@@ -972,13 +972,13 @@
             <dependency>
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>jetty</artifactId>
-                <version>6.1.0</version>
+                <version>6.1-SNAPSHOT</version>
             </dependency>
 
             <dependency>
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>jetty-util</artifactId>
-                <version>6.1.0</version>
+                <version>6.1-SNAPSHOT</version>
             </dependency>
 
             <dependency>



Mime
View raw message