geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl J2EEDomainImpl.java
Date Wed, 23 Jun 2004 20:24:45 GMT
dain        2004/06/23 13:24:45

  Modified:    modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment
                        EARConfigBuilder.java
               modules/j2ee/src/test-ear/META-INF geronimo-application.xml
               modules/j2ee/src/schema geronimo-application.xsd
               modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl
                        J2EEDomainImpl.java
  Added:       modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment
                        GerGBeanAdapter.java
  Log:
  Added support for GBeans and dependencies in the geronimo-application.xml file
  
  Revision  Changes    Path
  1.10      +42 -1     incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
  
  Index: EARConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EARConfigBuilder.java	22 Jun 2004 04:47:47 -0000	1.9
  +++ EARConfigBuilder.java	23 Jun 2004 20:24:45 -0000	1.10
  @@ -42,6 +42,7 @@
   import org.apache.geronimo.common.xml.XmlBeansUtil;
   import org.apache.geronimo.deployment.ConfigurationBuilder;
   import org.apache.geronimo.deployment.DeploymentException;
  +import org.apache.geronimo.deployment.service.GBeanHelper;
   import org.apache.geronimo.deployment.util.FileUtil;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
  @@ -51,6 +52,8 @@
   import org.apache.geronimo.kernel.repository.Repository;
   import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationDocument;
   import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationType;
  +import org.apache.geronimo.xbeans.geronimo.j2ee.GerDependencyType;
  +import org.apache.geronimo.xbeans.geronimo.j2ee.GerGbeanType;
   import org.apache.geronimo.xbeans.j2ee.ApplicationDocument;
   import org.apache.geronimo.xbeans.j2ee.ApplicationType;
   import org.apache.geronimo.xbeans.j2ee.ModuleType;
  @@ -195,6 +198,15 @@
                   }
               }
   
  +            // add dependencies declared in the geronimo-application.xml
  +            if (plan instanceof GerApplicationDocument) {
  +                GerApplicationDocument geronimoDoc = (GerApplicationDocument) plan;
  +                GerDependencyType[] dependencies = geronimoDoc.getApplication().getDependencyArray();
  +                for (int i = 0; i < dependencies.length; i++) {
  +                    earContext.addDependency(getDependencyURI(dependencies[i]));
  +                }
  +            }
  +
               // each module installs it's files into the output context.. this is differenct
for each module type
               for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
                   Module module = (Module) iterator.next();
  @@ -208,6 +220,15 @@
                   getBuilder(module).initContext(earContext, module, cl);
               }
   
  +            // add gbeans declared in the geronimo-application.xml
  +            if (plan instanceof GerApplicationDocument) {
  +                GerApplicationDocument geronimoDoc = (GerApplicationDocument) plan;
  +                GerGbeanType[] gbeans = geronimoDoc.getApplication().getGbeanArray();
  +                for (int i = 0; i < gbeans.length; i++) {
  +                    GBeanHelper.addGbean(new GerGBeanAdapter(gbeans[i]), cl, earContext);
  +                }
  +            }
  +
               // Create the J2EEApplication managed object
               if (application != null) {
                   GBeanMBean gbean = new GBeanMBean(J2EEApplicationImpl.GBEAN_INFO, cl);
  @@ -377,6 +398,26 @@
           }
   
           throw new DeploymentException("Could not determine config id");
  +    }
  +
  +    private URI getDependencyURI(GerDependencyType dep) throws DeploymentException {
  +        URI uri;
  +        if (dep.isSetUri()) {
  +            try {
  +                uri = new URI(dep.getUri());
  +            } catch (URISyntaxException e) {
  +                throw new DeploymentException("Invalid dependency URI " + dep.getUri(),
e);
  +            }
  +        } else {
  +            // @todo support more than just jars
  +            String id = dep.getGroupId() + "/jars/" + dep.getArtifactId() + '-' + dep.getVersion()
+ ".jar";
  +            try {
  +                uri = new URI(id);
  +            } catch (URISyntaxException e) {
  +                throw new DeploymentException("Unable to construct URI for groupId=" +
dep.getGroupId() + ", artifactId=" + dep.getArtifactId() + ", version=" + dep.getVersion(),
e);
  +            }
  +        }
  +        return uri;
       }
   
       public static final GBeanInfo GBEAN_INFO;
  
  
  
  1.1                  incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/GerGBeanAdapter.java
  
  Index: GerGBeanAdapter.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  package org.apache.geronimo.j2ee.deployment;
  
  import org.apache.geronimo.deployment.service.GBeanAdapter;
  import org.apache.geronimo.xbeans.geronimo.j2ee.GerGbeanType;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2004/06/23 20:24:45 $
   */
  public class GerGBeanAdapter implements GBeanAdapter {
  
      private final GerGbeanType gbean;
  
      public GerGBeanAdapter(GerGbeanType gbean) {
          this.gbean = gbean;
      }
  
      public String getName() {
          return gbean.getName();
      }
  
      public String getClass1() {
          return gbean.getClass1();
      }
  
      public int getAttributeCount() {
          return gbean.getAttributeArray().length;
      }
  
      public String getAttributeName(int i) {
          return gbean.getAttributeArray(i).getName();
      }
  
      public String getAttributeType(int i) {
          return gbean.getAttributeArray(i).getType();
      }
  
      public String getAttributeStringValue(int i) {
          return gbean.getAttributeArray(i).getStringValue();
      }
  
      public int getReferenceCount() {
          return gbean.getReferenceArray().length;
      }
  
      public String getReferenceName(int i) {
          return gbean.getReferenceArray(i).getName();
      }
  
      public String getReferenceStringValue(int i) {
          return gbean.getReferenceArray(i).getStringValue();
      }
  
      public int getReferencesCount() {
          return gbean.getReferencesArray().length;
      }
  
      public String getReferencesName(int i) {
          return gbean.getReferencesArray(i).getName();
      }
  
      public String[] getReferencesPatternArray(int i) {
          return gbean.getReferencesArray(i).getPatternArray();
      }
  }
  
  
  
  1.2       +4 -0      incubator-geronimo/modules/j2ee/src/test-ear/META-INF/geronimo-application.xml
  
  Index: geronimo-application.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test-ear/META-INF/geronimo-application.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- geronimo-application.xml	19 May 2004 20:53:59 -0000	1.1
  +++ geronimo-application.xml	23 Jun 2004 20:24:45 -0000	1.2
  @@ -19,4 +19,8 @@
   <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
       configId="org/apache/geronimo/j2ee/deployment/test"
       parentId="org/apache/geronimo/Server">
  +
  +    <!-- a random gbean just to verify that the deployer doesn't die because of it -->
  +    <gbean name="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
  +
   </application>
  
  
  
  1.2       +5 -0      incubator-geronimo/modules/j2ee/src/schema/geronimo-application.xsd
  
  Index: geronimo-application.xsd
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/schema/geronimo-application.xsd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- geronimo-application.xsd	19 May 2004 20:53:59 -0000	1.1
  +++ geronimo-application.xsd	23 Jun 2004 20:24:45 -0000	1.2
  @@ -29,6 +29,11 @@
       <xs:element name="application" type="geronimo:applicationType"/>
   
       <xs:complexType name="applicationType">
  +        <xs:sequence>
  +            <xs:element name="dependency" type="geronimo:dependencyType" minOccurs="0"
maxOccurs="unbounded"/>
  +            <xs:element name="gbean" type="geronimo:gbeanType" minOccurs="0" maxOccurs="unbounded"/>
  +        </xs:sequence>
  +
           <xs:attribute name="configId" type="xs:string" use="required"/>
           <xs:attribute name="parentId" type="xs:string" use="optional"/>
       </xs:complexType>
  
  
  
  1.4       +2 -2      incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEDomainImpl.java
  
  Index: J2EEDomainImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/management/impl/J2EEDomainImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- J2EEDomainImpl.java	4 Jun 2004 22:31:56 -0000	1.3
  +++ J2EEDomainImpl.java	23 Jun 2004 20:24:45 -0000	1.4
  @@ -44,7 +44,7 @@
       /**
        * ObjectName must match this pattern:
        * <p/>
  -     * domain:j2eeType=J2EEServer,name=MyName
  +     * domain:j2eeType=J2EEDomain,name=domain
        */
       private void verifyObjectName(ObjectName objectName) {
           if (objectName.isPattern()) {
  
  
  

Mime
View raw message