geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/service ClassSpaceMetadataXMLLoader.java ServiceDeploymentPlanner.java
Date Fri, 15 Aug 2003 15:27:42 GMT
jboynes     2003/08/15 08:27:42

  Modified:    modules/core/src/java/org/apache/geronimo/deployment/service
                        ClassSpaceMetadataXMLLoader.java
                        ServiceDeploymentPlanner.java
  Log:
  Support deployment of unpacked service archives
  
  Revision  Changes    Path
  1.3       +8 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/service/ClassSpaceMetadataXMLLoader.java
  
  Index: ClassSpaceMetadataXMLLoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/service/ClassSpaceMetadataXMLLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassSpaceMetadataXMLLoader.java	12 Aug 2003 07:10:16 -0000	1.2
  +++ ClassSpaceMetadataXMLLoader.java	15 Aug 2003 15:27:42 -0000	1.3
  @@ -79,6 +79,12 @@
    * @version $Revision$ $Date$
    */
   public class ClassSpaceMetadataXMLLoader {
  +    private final URL baseURL;
  +
  +    public ClassSpaceMetadataXMLLoader(URL baseURL) {
  +        this.baseURL = baseURL;
  +    }
  +
       public ClassSpaceMetadata loadXML(Element element) throws DeploymentException {
           ClassSpaceMetadata md = new ClassSpaceMetadata();
           try {
  @@ -92,7 +98,7 @@
               for (int i = 0; i < nl.getLength(); i++) {
                   Element codebaseElement = (Element) nl.item(i);
                   URL codebase;
  -                codebase = new URL(codebaseElement.getAttribute("url"));
  +                codebase = new URL(baseURL, codebaseElement.getAttribute("url"));
                   NodeList archiveNodes = codebaseElement.getElementsByTagName("archive");
                   if (archiveNodes.getLength() == 0) {
                       // no archives present, use codebase itself
  
  
  
  1.3       +28 -7     incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/service/ServiceDeploymentPlanner.java
  
  Index: ServiceDeploymentPlanner.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/service/ServiceDeploymentPlanner.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceDeploymentPlanner.java	14 Aug 2003 00:02:43 -0000	1.2
  +++ ServiceDeploymentPlanner.java	15 Aug 2003 15:27:42 -0000	1.3
  @@ -56,6 +56,7 @@
   package org.apache.geronimo.deployment.service;
   
   import java.io.IOException;
  +import java.io.InputStream;
   import java.net.URL;
   import java.util.Collection;
   import java.util.HashSet;
  @@ -77,6 +78,7 @@
   import javax.xml.parsers.ParserConfigurationException;
   
   import org.apache.geronimo.deployment.DeploymentException;
  +import org.apache.geronimo.deployment.scanner.URLType;
   import org.apache.geronimo.deployment.goal.DeployURL;
   import org.apache.geronimo.deployment.goal.DeploymentGoal;
   import org.apache.geronimo.deployment.goal.RedeployURL;
  @@ -105,7 +107,6 @@
       private RelationServiceMBean relationService;
       private final DocumentBuilder parser;
       private final MBeanMetadataXMLLoader mbeanLoader;
  -    private final ClassSpaceMetadataXMLLoader classSpaceLoader;
   
       public ServiceDeploymentPlanner() {
           DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  @@ -115,7 +116,6 @@
               throw new AssertionError("No XML parser available");
           }
           mbeanLoader = new MBeanMetadataXMLLoader();
  -        classSpaceLoader = new ClassSpaceMetadataXMLLoader();
       }
   
       public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws
Exception {
  @@ -161,14 +161,34 @@
       }
   
       private boolean addURL(DeployURL goal, Set goals, Set plans) throws DeploymentException
{
  +        InputStream is;
           URL url = goal.getUrl();
  -        if (!url.getPath().endsWith("-service.xml")) {
  +        URLType type = goal.getType();
  +        if (type == URLType.RESOURCE) {
  +            if (!url.getPath().endsWith("-service.xml")) {
  +                return false;
  +            }
  +            try {
  +                is = url.openConnection().getInputStream();
  +            } catch (IOException e) {
  +                throw new DeploymentException(e);
  +            }
  +        } else if (type == URLType.UNPACKED_ARCHIVE) {
  +            try {
  +                URL serviceURL = new URL(url, "META-INF/geronimo-service.xml");
  +                is = serviceURL.openConnection().getInputStream();
  +            } catch (IOException e) {
  +                // assume resource does not exist
  +                return false;
  +            }
  +        } else {
               return false;
           }
   
  +
           Document doc;
           try {
  -            doc = parser.parse(url.toString());
  +            doc = parser.parse(is);
           } catch (SAXException e) {
               throw new DeploymentException(e);
           } catch (IOException e) {
  @@ -185,7 +205,7 @@
           ServiceDeployment serviceInfo = new ServiceDeployment(deploymentName, null, url);
           createPlan.addTask(new RegisterMBeanInstance(server, deploymentName, serviceInfo));
   
  -        ObjectName loaderName = addClassSpaces(doc.getElementsByTagName("class-space"),
createPlan);
  +        ObjectName loaderName = addClassSpaces(doc.getElementsByTagName("class-space"),
createPlan, url);
   
           NodeList nl = doc.getElementsByTagName("mbean");
           for (int i = 0; i < nl.getLength(); i++) {
  @@ -204,12 +224,13 @@
           return true;
       }
   
  -    private ObjectName addClassSpaces(NodeList nl, DeploymentPlan plan) throws DeploymentException
{
  +    private ObjectName addClassSpaces(NodeList nl, DeploymentPlan plan, URL baseURL) throws
DeploymentException {
           Element classSpaceElement = (Element) nl.item(0);
           if (classSpaceElement == null) {
               return null;
           }
   
  +        ClassSpaceMetadataXMLLoader classSpaceLoader = new ClassSpaceMetadataXMLLoader(baseURL);
           ClassSpaceMetadata md = classSpaceLoader.loadXML(classSpaceElement);
           CreateClassSpace createTask = new CreateClassSpace(server, md);
           plan.addTask(createTask);
  
  
  

Mime
View raw message