geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r504671 - in /geronimo/server/trunk/modules: geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/ geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/
Date Wed, 07 Feb 2007 20:10:38 GMT
Author: dain
Date: Wed Feb  7 12:10:37 2007
New Revision: 504671

URL: http://svn.apache.org/viewvc?view=rev&rev=504671
Log:
Hard code naming builders to always add dependencies

Modified:
    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/UnavailableRefBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java

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=504671&r1=504670&r2=504671
==============================================================================
--- 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
Wed Feb  7 12:10:37 2007
@@ -74,9 +74,12 @@
     }
     
     public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment)
throws DeploymentException {
-        if (willMergeEnvironment(specDD, plan)) {
+        // 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);
-        }
+        // }
     }
 
     protected boolean willMergeEnvironment(XmlObject specDD, XmlObject plan) throws DeploymentException
{

Modified: geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java?view=diff&rev=504671&r1=504670&r2=504671
==============================================================================
--- geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-naming-builder/src/main/java/org/apache/geronimo/naming/deployment/UnavailableRefBuilder.java
Wed Feb  7 12:10:37 2007
@@ -44,7 +44,9 @@
         unavailableQNameSet = QNameSet.singleton(unavailableQName);
     }
     public void buildEnvironment(XmlObject specDD, XmlObject plan, Environment environment)
throws DeploymentException {
-        checkUnavailable(specDD);
+        if (specDD != null) {
+            checkUnavailable(specDD);
+        }
     }
 
     private void checkUnavailable(XmlObject specDD) throws DeploymentException {

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?view=diff&rev=504671&r1=504670&r2=504671
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
Wed Feb  7 12:10:37 2007
@@ -22,7 +22,6 @@
 import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.service.GBeanBuilder;
-import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
@@ -46,7 +45,6 @@
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.xbeans.geronimo.j2ee.GerSecurityDocument;
-import org.apache.geronimo.xbeans.javaee.AssemblyDescriptorType;
 import org.apache.geronimo.xbeans.javaee.EjbJarType;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.AppInfo;
@@ -204,12 +202,25 @@
         }
 
         // create the geronimo environment object
-        Environment environment = createEnvironment(ejbModule, geronimoEjbJarType, moduleFile,
earEnvironment, idBuilder);
+        Environment environment = XmlUtil.buildEnvironment(geronimoEjbJarType.getEnvironment(),
defaultEnvironment);
+        if (earEnvironment != null) {
+            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
+            environment = earEnvironment;
+            if (!environment.getConfigId().isResolved()) {
+                throw new IllegalStateException("EJB module ID should be fully resolved (not
" + environment.getConfigId() + ")");
+            }
+        } else {
+            idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "jar");
+        }
+
+        if (ejbModule.getEjbJar().getAssemblyDescriptor() != null) {
+            namingBuilder.buildEnvironment(null, null, environment);
+        }
 
         // overridden web service locations
         Map correctedPortLocations = new HashMap();
 
-        // todo
+        // todo Webservices not supported yet
 //        OpenejbSessionBeanType[] openejbSessionBeans = openejbJar.getEnterpriseBeans().getSessionArray();
 //        for (int i = 0; i < openejbSessionBeans.length; i++) {
 //            OpenejbSessionBeanType sessionBean = openejbSessionBeans[i];
@@ -235,32 +246,6 @@
         return new EjbModule(ejbModule, standAlone, moduleName, environment, moduleFile,
targetPath, "", sharedContext);
     }
 
-    private Environment createEnvironment(org.apache.openejb.config.EjbModule ejbModule,
GeronimoEjbJarType jaxbGeronimoOpenejb, JarFile moduleFile, Environment earEnvironment, ModuleIDBuilder
idBuilder) throws DeploymentException {
-        OpenejbGeronimoEjbJarType geronimoOpenejb;
-        geronimoOpenejb = XmlUtil.convertToXmlbeans(jaxbGeronimoOpenejb);
-        EnvironmentType environmentType = geronimoOpenejb.getEnvironment();
-        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
-        if (earEnvironment != null) {
-            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
-            environment = earEnvironment;
-            if (!environment.getConfigId().isResolved()) {
-                throw new IllegalStateException("EJB module ID should be fully resolved (not
" + environment.getConfigId() + ")");
-            }
-        } else {
-            idBuilder.resolve(environment, new File(moduleFile.getName()).getName(), "jar");
-        }
-
-        // todo THIS WILL NOT WORK WITH ANNOTATIONS... move this to initContext when naming
is fixed
-        // since assembly descriptor will only be valid once metadata complete
-        // which is only available once a class loader has been constructed in the init phase
-        if (ejbModule.getEjbJar().getAssemblyDescriptor() != null) {
-            EjbJarType ejbJarType = XmlUtil.convertToXmlbeans(ejbModule.getEjbJar());
-            AssemblyDescriptorType assemblyDescriptor = ejbJarType.getAssemblyDescriptor();
-            namingBuilder.buildEnvironment(assemblyDescriptor, geronimoOpenejb, environment);
-        }
-        return environment;
-    }
-
     protected static void unmapReferences(EjbJar ejbJar) {
         for (EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
             enterpriseBean.getEnvEntry().clear();
@@ -421,8 +406,8 @@
         // if not found create one
         if (persistenceUnit == null) {
             String jtaDataSource = null;
-            Object altDD = ejbModule.getEjbModule().getAltDDs().get("openejb-jar.xml");
             // todo Persistence Unit Data Sources need to be global JNDI names
+            // Object altDD = ejbModule.getEjbModule().getAltDDs().get("openejb-jar.xml");
             // if (altDD instanceof OpenejbJarType) {
             //     String datasourceName = ((OpenejbJarType) altDD).getCmpConnectionFactory().getResourceLink();
             //     jtaDataSource = "?name=" + datasourceName;

Modified: geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java?view=diff&rev=504671&r1=504670&r2=504671
==============================================================================
--- geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
(original)
+++ geronimo/server/trunk/modules/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
Wed Feb  7 12:10:37 2007
@@ -18,8 +18,11 @@
 package org.apache.geronimo.openejb.deployment;
 
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbEjbJarDocument;
 import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
 import org.apache.geronimo.schema.SchemaConversionUtils;
@@ -29,9 +32,11 @@
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.PersistenceContextRef;
 import org.apache.openejb.jee.PersistenceContextType;
-import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
-import org.apache.openejb.jee.oejb2.EnvironmentType;
 import org.apache.openejb.jee.oejb2.ArtifactType;
+import org.apache.openejb.jee.oejb2.DependencyType;
+import org.apache.openejb.jee.oejb2.EnvironmentType;
+import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
+import org.apache.openejb.jee.oejb2.ImportType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.xmlbeans.XmlException;
@@ -54,10 +59,6 @@
 import javax.xml.transform.sax.SAXSource;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.jar.JarFile;
 
 public final class XmlUtil {
     public static final QName OPENEJBJAR_QNAME = OpenejbEjbJarDocument.type.getDocumentElementName();
@@ -186,6 +187,57 @@
         } catch (XmlException e) {
             throw new DeploymentException("Error parsing geronimo-openejb.xml", e);
         }
+    }
+
+    public static Environment buildEnvironment(EnvironmentType environmentType, Environment
defaultEnvironment) {
+        Environment environment = new Environment();
+        if (environmentType != null) {
+            if (environmentType.getModuleId() != null) {
+                environment.setConfigId(toArtifact(environmentType.getModuleId(), null));
+            }
+
+            if (environmentType.getDependencies() != null) {
+                for (DependencyType dependencyType : environmentType.getDependencies().getDependency())
{
+                    Dependency dependency = toDependency(dependencyType);
+                    environment.addDependency(dependency);
+                }
+            }
+            environment.setInverseClassLoading(environmentType.isInverseClassloading());
+            environment.setSuppressDefaultEnvironment(environmentType.isSuppressDefaultEnvironment());
+            if (environmentType.getHiddenClasses() != null) {
+                environment.setHiddenClasses(environmentType.getHiddenClasses().getFilter());
+            }
+            if (environmentType.getNonOverridableClasses() != null) {
+                environment.setNonOverrideableClasses(environmentType.getNonOverridableClasses().getFilter());
+            }
+        }
+        if (!environment.isSuppressDefaultEnvironment()) {
+            EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+        }
+
+        return environment;
+    }
+
+    private static Dependency toDependency(DependencyType dependencyType) {
+        Artifact artifact = toArtifact(dependencyType, null);
+        if (ImportType.CLASSES.equals(dependencyType.getImport())) {
+            return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.CLASSES);
+        } else if (ImportType.SERVICES.equals(dependencyType.getImport())) {
+            return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.SERVICES);
+        } else if (dependencyType.getImport() == null) {
+            return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.ALL);
+        } else {
+            throw new IllegalArgumentException("Unknown import type: " + dependencyType.getImport());
+        }
+    }
+
+    private static Artifact toArtifact(ArtifactType artifactType, String defaultType) {
+        String groupId = artifactType.getGroupId();
+        String type = artifactType.getType();
+        if (type == null) type = defaultType;
+        String artifactId = artifactType.getArtifactId();
+        String version = artifactType.getVersion();
+        return new Artifact(groupId, artifactId, version, type);
     }
 
     public static GeronimoEjbJarType createDefaultPlan(String name, EjbJar ejbJar) {



Mime
View raw message