geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment WARConfigBuilder.java
Date Fri, 27 Feb 2004 07:35:03 GMT
djencks     2004/02/26 23:35:03

  Modified:    modules/assembly/src/plan j2ee-deployer-plan.xml
               modules/connector/src/java/org/apache/geronimo/connector/deployment
                        AbstractRARConfigBuilder.java
               modules/jetty/src/java/org/apache/geronimo/jetty/deployment
                        WARConfigBuilder.java
  Added:       modules/deployment/src/java/org/apache/geronimo/deployment/util
                        XmlBeansUtil.java
  Log:
  make rars deploy with embedded geronimo-ra.xml: put common code in utility class
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/util/XmlBeansUtil.java
  
  Index: XmlBeansUtil.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.deployment.util;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.net.URL;
  
  import org.apache.xmlbeans.XmlObject;
  import org.apache.xmlbeans.SchemaType;
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.SchemaTypeLoader;
  import org.apache.xmlbeans.XmlBeans;
  import org.apache.xmlbeans.XmlOptions;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/02/27 07:35:03 $
   *
   * */
  public class XmlBeansUtil {
  
      private XmlBeansUtil() {}
  
      public static XmlObject getPlan(URL planURL, SchemaType type) {
          InputStream is;
          try {
              is = planURL.openStream();
              try {
                  return parse(is, type);
              } finally {
                  is.close();
              }
          } catch (IOException e) {
              return null;
          } catch (XmlException e) {
              return null;
          }
      }
  
      public static XmlObject parse(InputStream is, SchemaType type) throws IOException, XmlException
{
          ArrayList errors = new ArrayList();
          SchemaTypeLoader loader = XmlBeans.getContextTypeLoader();
          XmlOptions options = new XmlOptions();
          options.setLoadLineNumbers();
          options.setErrorListener(errors);
          return loader.parse(is, type, options);
      }
  
  }
  
  
  
  1.2       +10 -0     incubator-geronimo/modules/assembly/src/plan/j2ee-deployer-plan.xml
  
  Index: j2ee-deployer-plan.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/assembly/src/plan/j2ee-deployer-plan.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- j2ee-deployer-plan.xml	25 Feb 2004 08:01:08 -0000	1.1
  +++ j2ee-deployer-plan.xml	27 Feb 2004 07:35:03 -0000	1.2
  @@ -34,6 +34,16 @@
           <reference name="Store">geronimo.deployment:role=ConfigurationStore,type=Local</reference>
       </gbean>
   
  +    <gbean name="geronimo.deployer:role=Builder,type=RAR_1_0,config=org/apache/geronimo/J2EEDeployer"
class="org.apache.geronimo.connector.deployment.RAR_1_0ConfigBuilder">
  +        <reference name="Kernel">geronimo.boot:role=Kernel</reference>
  +        <reference name="Repository">*:role=Repository,*</reference>
  +    </gbean>
  +
  +    <gbean name="geronimo.deployer:role=Builder,type=RAR_1_5,config=org/apache/geronimo/J2EEDeployer"
class="org.apache.geronimo.connector.deployment.RAR_1_5ConfigBuilder">
  +        <reference name="Kernel">geronimo.boot:role=Kernel</reference>
  +        <reference name="Repository">*:role=Repository,*</reference>
  +    </gbean>
  +
       <gbean name="geronimo.deployer:role=Builder,type=Service,config=org/apache/geronimo/J2EEDeployer"
class="org.apache.geronimo.deployment.service.ServiceConfigBuilder">
           <reference name="Kernel">geronimo.boot:role=Kernel</reference>
           <reference name="Repository">*:role=Repository,*</reference>
  
  
  
  1.4       +14 -3     incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractRARConfigBuilder.java
  
  Index: AbstractRARConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractRARConfigBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractRARConfigBuilder.java	25 Feb 2004 09:57:09 -0000	1.3
  +++ AbstractRARConfigBuilder.java	27 Feb 2004 07:35:03 -0000	1.4
  @@ -26,6 +26,7 @@
   import java.net.URI;
   import java.net.URISyntaxException;
   import java.net.URL;
  +import java.net.MalformedURLException;
   import java.util.jar.JarEntry;
   import java.util.jar.JarInputStream;
   import java.util.jar.JarOutputStream;
  @@ -36,6 +37,7 @@
   import org.apache.geronimo.deployment.ConfigurationBuilder;
   import org.apache.geronimo.deployment.DeploymentContext;
   import org.apache.geronimo.deployment.DeploymentException;
  +import org.apache.geronimo.deployment.util.XmlBeansUtil;
   import org.apache.geronimo.gbean.GAttributeInfo;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
  @@ -117,8 +119,17 @@
       protected abstract XmlObject getConnectorDocument(JarInputStream jarInputStream) throws
XmlException, IOException, DeploymentException;
   
       public XmlObject getDeploymentPlan(URL module) {
  -        //for starters we require an external geronimo dd.
  -        return null;
  +         try {
  +            URL moduleBase = new URL("jar:" + module.toString() + "!/");
  +            XmlObject plan = XmlBeansUtil.getPlan(new URL(moduleBase, "META-INF/geronimo-ra.xml"),
GerConnectorDocument.type);
  +             if (plan != null && canConfigure(plan)) {
  +                 return plan;
  +             } else {
  +                 return null;
  +             }
  +         } catch (MalformedURLException e) {
  +            return null;
  +        }
       }
   
       public void buildConfiguration(File outfile, File module, XmlObject plan) throws IOException,
DeploymentException {
  
  
  
  1.11      +5 -27     incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigBuilder.java
  
  Index: WARConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigBuilder.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- WARConfigBuilder.java	25 Feb 2004 09:57:44 -0000	1.10
  +++ WARConfigBuilder.java	27 Feb 2004 07:35:03 -0000	1.11
  @@ -43,6 +43,7 @@
   import org.apache.geronimo.deployment.ConfigurationBuilder;
   import org.apache.geronimo.deployment.DeploymentContext;
   import org.apache.geronimo.deployment.DeploymentException;
  +import org.apache.geronimo.deployment.util.XmlBeansUtil;
   import org.apache.geronimo.deployment.service.GBeanBuilder;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
  @@ -101,7 +102,7 @@
               } else {
                   moduleBase = new URL("jar:" + module.toString() + "!/");
               }
  -            XmlObject plan = getPlan(new URL(moduleBase, "WEB-INF/geronimo-jetty.xml"),
JettyWebAppDocument.type);
  +            XmlObject plan = XmlBeansUtil.getPlan(new URL(moduleBase, "WEB-INF/geronimo-jetty.xml"),
JettyWebAppDocument.type);
   // todo needs generic web XMLBeans
   //            if (plan == null) {
   //                plan = getPlan(new URL(moduleBase, "WEB-INF/geronimo-web.xml"));
  @@ -116,21 +117,6 @@
           }
       }
   
  -    private XmlObject getPlan(URL planURL, SchemaType type) {
  -        InputStream is;
  -        try {
  -            is = planURL.openStream();
  -            try {
  -                return parse(is, type);
  -            } finally {
  -                is.close();
  -            }
  -        } catch (IOException e) {
  -            return null;
  -        } catch (XmlException e) {
  -            return null;
  -        }
  -    }
   
       public void buildConfiguration(File outfile, File module, XmlObject plan) throws IOException,
DeploymentException {
           if (!module.isDirectory()) {
  @@ -189,7 +175,7 @@
           FileInputStream is = new FileInputStream(dd);
           try {
               try {
  -                WebAppDocument doc = (WebAppDocument) parse(new BufferedInputStream(is),
WebAppDocument.type);
  +                WebAppDocument doc = (WebAppDocument) XmlBeansUtil.parse(new BufferedInputStream(is),
WebAppDocument.type);
                   return doc.getWebApp();
               } catch (XmlException e) {
                   throw new DeploymentException("Unable to parse web.xml", e);
  @@ -228,7 +214,7 @@
                       byte[] buffer = getBytes(module);
                       context.addFile(target, new ByteArrayInputStream(buffer));
                       try {
  -                        WebAppDocument doc = (WebAppDocument) parse(new ByteArrayInputStream(buffer),
WebAppDocument.type);
  +                        WebAppDocument doc = (WebAppDocument) XmlBeansUtil.parse(new ByteArrayInputStream(buffer),
WebAppDocument.type);
                           webApp = doc.getWebApp();
                       } catch (XmlException e) {
                           throw new DeploymentException("Unable to parse web.xml");
  @@ -363,14 +349,6 @@
           }
       }
   
  -    private XmlObject parse(InputStream is, SchemaType type) throws IOException, XmlException
{
  -        ArrayList errors = new ArrayList();
  -        SchemaTypeLoader loader = XmlBeans.getContextTypeLoader();
  -        XmlOptions options = new XmlOptions();
  -        options.setLoadLineNumbers();
  -        options.setErrorListener(errors);
  -        return loader.parse(is, type, options);
  -    }
   
       private URI getParentID(JettyWebAppType jettyWebApp) throws DeploymentException {
           URI parentID;
  
  
  

Mime
View raw message