geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r950397 [4/4] - in /geronimo/server/trunk/plugins: activemq/ bval/geronimo-bval-builder/src/main/java/org/apache/geronimo/bval/deployment/ client/client/src/main/history/ client/geronimo-client-builder/src/main/java/org/apache/geronimo/clie...
Date Wed, 02 Jun 2010 07:35:26 GMT
Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=950397&r1=950396&r2=950397&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Wed Jun  2 07:35:24 2010
@@ -17,9 +17,6 @@
 
 package org.apache.geronimo.tomcat.deployment;
 
-import static java.lang.Boolean.FALSE;
-import static java.lang.Boolean.TRUE;
-
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
@@ -32,7 +29,6 @@ import java.util.Map;
 import java.util.jar.JarFile;
 
 import javax.servlet.Servlet;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.Deployable;
 import org.apache.geronimo.deployment.DeployableBundle;
@@ -46,13 +42,16 @@ import org.apache.geronimo.deployment.xm
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
@@ -97,12 +96,17 @@ import org.apache.xbean.osgi.bundle.util
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static java.lang.Boolean.FALSE;
+import static java.lang.Boolean.TRUE;
+
 /**
  * @version $Rev:385659 $ $Date$
  */
+@GBean(j2eeType = NameFactory.MODULE_BUILDER)
 public class TomcatModuleBuilder extends AbstractWebModuleBuilder implements GBeanLifecycle
{
 
     private static final Logger log = LoggerFactory.getLogger(TomcatModuleBuilder.class);
@@ -125,16 +129,19 @@ public class TomcatModuleBuilder extends
     private final AbstractNameQuery tomcatContainerName;
     protected final NamespaceDrivenBuilderCollection clusteringBuilders;
 
-    public TomcatModuleBuilder(Environment defaultEnvironment,
-            AbstractNameQuery tomcatContainerName,
-            Collection<WebServiceBuilder> webServiceBuilder,
-            Collection<NamespaceDrivenBuilder> serviceBuilders,
-            NamingBuilder namingBuilders,
-            Collection<NamespaceDrivenBuilder> clusteringBuilders,
-            Collection<ModuleBuilderExtension> moduleBuilderExtensions,
-            ResourceEnvironmentSetter resourceEnvironmentSetter,
-            Kernel kernel) {
-        super(kernel, serviceBuilders, namingBuilders, resourceEnvironmentSetter, webServiceBuilder,
moduleBuilderExtensions);
+    public static final String GBEAN_REF_CLUSTERING_BUILDERS = "ClusteringBuilders";
+
+    public TomcatModuleBuilder(@ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
+            @ParamAttribute(name = "tomcatContainerName") AbstractNameQuery tomcatContainerName,
+            @ParamReference(name="WebServiceBuilder", namingType = NameFactory.MODULE_BUILDER)
Collection<WebServiceBuilder> webServiceBuilder,
+            @ParamReference(name="ServiceBuilders", namingType = NameFactory.MODULE_BUILDER)Collection<NamespaceDrivenBuilder>
serviceBuilders,
+            @ParamReference(name="NamingBuilders", namingType = NameFactory.MODULE_BUILDER)NamingBuilder
namingBuilders,
+            @ParamReference(name= GBEAN_REF_CLUSTERING_BUILDERS, namingType = NameFactory.MODULE_BUILDER)Collection<NamespaceDrivenBuilder>
clusteringBuilders,
+            @ParamReference(name="ModuleBuilderExtensions", namingType = NameFactory.MODULE_BUILDER)Collection<ModuleBuilderExtension>
moduleBuilderExtensions,
+            @ParamReference(name="ResourceEnvironmentSetter", namingType = NameFactory.MODULE_BUILDER)ResourceEnvironmentSetter
resourceEnvironmentSetter,
+            @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+            @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext)
{
+        super(kernel, serviceBuilders, namingBuilders, resourceEnvironmentSetter, webServiceBuilder,
moduleBuilderExtensions, bundleContext);
         this.defaultEnvironment = defaultEnvironment;
         this.clusteringBuilders = new NamespaceDrivenBuilderCollection(clusteringBuilders);
         this.tomcatContainerName = tomcatContainerName;
@@ -215,14 +222,14 @@ public class TomcatModuleBuilder extends
             name = bundle.getSymbolicName();
         }
 
-        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable,
targetPath, webApp, tomcatWebApp, specDD, contextPath, TOMCAT_NAMESPACE, annotatedWebApp);
+        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable,
targetPath, webApp, tomcatWebApp, specDD, contextPath, TOMCAT_NAMESPACE, annotatedWebApp,
shareJndi(null), null);
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, bundle, naming, idBuilder);
         }
         return module;
     }
 
-    protected Module createModule(Object plan, JarFile moduleFile, String targetPath, URL
specDDUrl, Environment earEnvironment, String contextRoot, AbstractName earName, Naming naming,
ModuleIDBuilder idBuilder) throws DeploymentException {
+    protected Module createModule(Object plan, JarFile moduleFile, String targetPath, URL
specDDUrl, Environment earEnvironment, String contextRoot, Module parentModule, Naming naming,
ModuleIDBuilder idBuilder) throws DeploymentException {
         assert moduleFile != null : "moduleFile is null";
         assert targetPath != null : "targetPath is null";
         assert !targetPath.endsWith("/") : "targetPath must not end with a '/'";
@@ -288,10 +295,12 @@ public class TomcatModuleBuilder extends
         idBuilder.resolve(environment, warName, "war");
 
         AbstractName moduleName;
-        if (earName == null) {
+        AbstractName earName;
+        if (parentModule == null) {
             earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL,
NameFactory.J2EE_APPLICATION);
             moduleName = naming.createChildName(earName, environment.getConfigId().toString(),
NameFactory.WEB_MODULE);
         } else {
+            earName = parentModule.getModuleName();
             moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
         }
 
@@ -307,7 +316,7 @@ public class TomcatModuleBuilder extends
             }
         }
 
-        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable,
targetPath, webApp, tomcatWebApp, specDD, contextRoot, TOMCAT_NAMESPACE, annotatedWebApp);
+        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable,
targetPath, webApp, tomcatWebApp, specDD, contextRoot, TOMCAT_NAMESPACE, annotatedWebApp,
shareJndi(parentModule), parentModule);
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, plan, moduleFile, targetPath, specDDUrl, environment,
contextRoot, earName, naming, idBuilder);
         }
@@ -648,37 +657,4 @@ public class TomcatModuleBuilder extends
 
 
 
-    public static final GBeanInfo GBEAN_INFO;
-    public static final String GBEAN_REF_CLUSTERING_BUILDERS = "ClusteringBuilders";
-
-    static {
-        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(TomcatModuleBuilder.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
-        infoBuilder.addAttribute("tomcatContainerName", AbstractNameQuery.class, true, true);
-        infoBuilder.addReference("WebServiceBuilder", WebServiceBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("NamingBuilders", NamingBuilder.class, NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference(GBEAN_REF_CLUSTERING_BUILDERS, NamespaceDrivenBuilder.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ModuleBuilderExtensions", ModuleBuilderExtension.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addReference("ResourceEnvironmentSetter", ResourceEnvironmentSetter.class,
NameFactory.MODULE_BUILDER);
-        infoBuilder.addAttribute("kernel", Kernel.class, false);
-        infoBuilder.addInterface(ModuleBuilder.class);
-
-        infoBuilder.setConstructor(new String[]{
-                "defaultEnvironment",
-                "tomcatContainerName",
-                "WebServiceBuilder",
-                "ServiceBuilders",
-                "NamingBuilders",
-                GBEAN_REF_CLUSTERING_BUILDERS,
-                "ModuleBuilderExtensions",
-                "ResourceEnvironmentSetter",
-                "kernel"});
-        GBEAN_INFO = infoBuilder.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
 }

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=950397&r1=950396&r2=950397&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
Wed Jun  2 07:35:24 2010
@@ -35,6 +35,7 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.osgi.MockBundleContext;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
@@ -44,6 +45,10 @@ import org.apache.geronimo.xbeans.geroni
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.xmlbeans.XmlObject;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
 
 /**
  */
@@ -59,6 +64,64 @@ public class PlanParsingTest extends Tes
     private TomcatModuleBuilder builder;
 
     protected void setUp() throws Exception {
+        MockBundleContext bundleContext = new MockBundleContext(getClass().getClassLoader(),
"", null, null);
+        PackageAdmin packageAdmin = new PackageAdmin() {
+
+                @Override
+                public ExportedPackage[] getExportedPackages(Bundle bundle) {
+                    return new ExportedPackage[0];
+                }
+
+                @Override
+                public ExportedPackage[] getExportedPackages(String s) {
+                    return new ExportedPackage[0];
+                }
+
+                @Override
+                public ExportedPackage getExportedPackage(String s) {
+                    return null;
+                }
+
+                @Override
+                public void refreshPackages(Bundle[] bundles) {
+                }
+
+                @Override
+                public boolean resolveBundles(Bundle[] bundles) {
+                    return false;
+                }
+
+                @Override
+                public RequiredBundle[] getRequiredBundles(String s) {
+                    return new RequiredBundle[0];
+                }
+
+                @Override
+                public Bundle[] getBundles(String s, String s1) {
+                    return new Bundle[0];
+                }
+
+                @Override
+                public Bundle[] getFragments(Bundle bundle) {
+                    return new Bundle[0];
+                }
+
+                @Override
+                public Bundle[] getHosts(Bundle bundle) {
+                    return new Bundle[0];
+                }
+
+                @Override
+                public Bundle getBundle(Class aClass) {
+                    return null;
+                }
+
+                @Override
+                public int getBundleType(Bundle bundle) {
+                    return 0;
+                }
+            };
+        bundleContext.registerService(PackageAdmin.class.getName(), packageAdmin, null);
         builder = new TomcatModuleBuilder(defaultEnvironment,
                 tomcatContainerObjectName,
                 Collections.singleton(webServiceBuilder),
@@ -67,7 +130,8 @@ public class PlanParsingTest extends Tes
                 Collections.EMPTY_LIST,
                 null,
                 new MockResourceEnvironmentSetter(),
-                null);
+                null,
+                bundleContext);
         builder.doStart();
         GeronimoSecurityBuilderImpl securityBuilder = new GeronimoSecurityBuilderImpl(null,
null, null);
         securityBuilder.doStart();

Modified: geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java?rev=950397&r1=950396&r2=950397&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
(original)
+++ geronimo/server/trunk/plugins/wab/geronimo-web-extender/src/main/java/org/apache/geronimo/osgi/web/extender/WebApplication.java
Wed Jun  2 07:35:24 2010
@@ -23,7 +23,6 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.geronimo.common.DeploymentException;
@@ -33,10 +32,8 @@ import org.apache.geronimo.gbean.GBeanDa
 import org.apache.geronimo.j2ee.deployment.BundleDeploymentContext;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
-import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.jndi.ApplicationJndi;
-import org.apache.geronimo.j2ee.jndi.JndiKey;
 import org.apache.geronimo.j2ee.jndi.JndiScope;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
@@ -204,10 +201,7 @@ public class WebApplication implements R
                 deploymentContext.flush();
                 deploymentContext.initializeConfiguration();
 
-                Map<JndiKey, Map<String, Object>> contexts = NamingBuilder.JNDI_KEY.get(deploymentContext.getGeneralData());
-                Map<String, Object> app = new HashMap<String, Object>();
-                app.put("app/AppName", webModule.getName());
-                contexts.put(JndiScope.app, app);
+                webModule.getJndiScope(JndiScope.app).put("app/AppName", webModule.getName());
                 
                 webModuleBuilder.initContext(deploymentContext, webModule, bundle);
 
@@ -217,8 +211,8 @@ public class WebApplication implements R
                 webModuleBuilder.addGBeans(deploymentContext, webModule, bundle, extender.getRepositories());
 
                 GBeanData appContexts = new GBeanData(appJndiName, ApplicationJndi.class);
-                appContexts.setAttribute("globalContextSegment", contexts.get(JndiScope.global));
-                appContexts.setAttribute("applicationContextMap", contexts.get(JndiScope.app));
+                appContexts.setAttribute("globalContextSegment", webModule.getJndiScope(JndiScope.global));
+                appContexts.setAttribute("applicationContextMap", webModule.getJndiScope(JndiScope.app));
                 appContexts.setReferencePattern("GlobalContext", extender.getGlobalContextAbstractName());
                 deploymentContext.addGBean(appContexts);
 



Mime
View raw message