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/deployment/src/java/org/apache/geronimo/deployment/tools/loader AbstractDeployable.java ApplicationDeployable.java ClientDeployable.java DeployableFactory.java WebDeployable.java
Date Wed, 21 Jan 2004 22:19:41 GMT
jboynes     2004/01/21 14:19:41

  Added:       modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader
                        AbstractDeployable.java ApplicationDeployable.java
                        ClientDeployable.java DeployableFactory.java
                        WebDeployable.java
  Log:
  Oops - missed these
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader/AbstractDeployable.java
  
  Index: AbstractDeployable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.tools.loader;
  
  import java.io.BufferedInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Enumeration;
  import java.util.List;
  import java.util.zip.ZipEntry;
  import java.util.zip.ZipInputStream;
  import javax.enterprise.deploy.model.DDBean;
  import javax.enterprise.deploy.model.DDBeanRoot;
  import javax.enterprise.deploy.model.DeployableObject;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  import javax.enterprise.deploy.shared.ModuleType;
  
  import org.apache.geronimo.deployment.tools.DDBeanRootImpl;
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/21 22:19:41 $
   */
  public abstract class AbstractDeployable implements DeployableObject {
      private final URL moduleURL;
      private final ModuleType type;
      private final DDBeanRoot root;
      private final ClassLoader rootCL;
      private final List entries;
  
      protected AbstractDeployable(ModuleType type, URL moduleURL, String rootDD) throws DDBeanCreateException
{
          this.type = type;
          this.moduleURL = moduleURL;
          rootCL = new URLClassLoader(new URL[] {moduleURL}, Thread.currentThread().getContextClassLoader());
          root = new DDBeanRootImpl(this, rootCL.getResource(rootDD));
  
          // @todo make this work with unpacked
          entries = new ArrayList();
          InputStream is = null;
          try {
              is = moduleURL.openStream();
              ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
              ZipEntry entry;
              while ((entry = zis.getNextEntry()) != null) {
                  entries.add(entry.getName());
              }
          } catch (IOException e) {
              throw (DDBeanCreateException) new DDBeanCreateException("Unable to create list
of entries").initCause(e);
          } finally {
              if (is != null) {
                  try {
                      is.close();
                  } catch (IOException e1) {
                      // ignore
                  }
              }
          }
      }
  
      public ModuleType getType() {
          return type;
      }
  
      public DDBeanRoot getDDBeanRoot() {
          return root;
      }
  
      public DDBeanRoot getDDBeanRoot(String filename) throws FileNotFoundException, DDBeanCreateException
{
          try {
              return new DDBeanRootImpl(null, new URL(moduleURL, filename));
          } catch (MalformedURLException e) {
              throw (DDBeanCreateException) new DDBeanCreateException("Unable to construct
URL for "+filename).initCause(e);
          }
      }
  
      public DDBean[] getChildBean(String xpath) {
          return root.getChildBean(xpath);
      }
  
      public String[] getText(String xpath) {
          return root.getText(xpath);
      }
  
      public Enumeration entries() {
          return Collections.enumeration(entries);
      }
  
      public InputStream getEntry(String name) {
          return rootCL.getResourceAsStream(name);
      }
  
      protected ClassLoader getModuleLoader() {
          return rootCL;
      }
  
      public Class getClassFromScope(String className) {
          try {
              return getModuleLoader().loadClass(className);
          } catch (ClassNotFoundException e) {
              // spec does not allow an Exception
              return null;
          }
      }
  
      public String getModuleDTDVersion() {
          throw new UnsupportedOperationException();
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader/ApplicationDeployable.java
  
  Index: ApplicationDeployable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.tools.loader;
  
  import java.net.URL;
  import java.util.HashMap;
  import java.util.Map;
  import javax.enterprise.deploy.model.DDBean;
  import javax.enterprise.deploy.model.J2eeApplicationObject;
  import javax.enterprise.deploy.model.XpathListener;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  import javax.enterprise.deploy.shared.ModuleType;
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/21 22:19:41 $
   */
  public abstract class ApplicationDeployable extends AbstractDeployable implements J2eeApplicationObject
{
      private final Map uriMap;
      public ApplicationDeployable(URL moduleURL) throws DDBeanCreateException {
          super(ModuleType.EAR, moduleURL, "META-INF/application.xml");
          DDBean[] moduleBeans = getChildBean("/application/module");
          uriMap = new HashMap(moduleBeans.length);
          for (int i = 0; i < moduleBeans.length; i++) {
              DDBean moduleBean = moduleBeans[i];
              String uri;
  
          }
      }
  
      public void addXpathListener(ModuleType type, String xpath, XpathListener xpl) {
      }
  
      public void removeXpathListener(ModuleType type, String xpath, XpathListener xpl) {
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader/ClientDeployable.java
  
  Index: ClientDeployable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.tools.loader;
  
  import java.net.URL;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  import javax.enterprise.deploy.shared.ModuleType;
  
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/21 22:19:41 $
   */
  public class ClientDeployable extends AbstractDeployable  {
      public ClientDeployable(URL moduleURL) throws DDBeanCreateException {
          super(ModuleType.CAR, moduleURL, "META-INF/application-client.xml");
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader/DeployableFactory.java
  
  Index: DeployableFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.tools.loader;
  
  import java.net.URL;
  import java.net.URLClassLoader;
  import javax.enterprise.deploy.model.DeployableObject;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/21 22:19:41 $
   */
  public class DeployableFactory {
      public static DeployableObject createDeployable(URL moduleURL) throws DDBeanCreateException
{
          ClassLoader cl = new URLClassLoader(new URL[] {moduleURL}, ClassLoader.getSystemClassLoader());
          if (cl.getResource("META-INF/application.xml") != null) {
              // EAR file
  //            return new ApplicationDeployable(moduleFile.toURL());
              throw new UnsupportedOperationException();
          } else if (cl.getResource("META-INF/application-client.xml") != null) {
              // Application Client
              return new ClientDeployable(moduleURL);
          } else if (cl.getResource("WEB-INF/web.xml") != null) {
              // WAR
              throw new UnsupportedOperationException();
          } else if (cl.getResource("META-INF/ejb-jar.xml") != null) {
              // EJB Jar
              throw new UnsupportedOperationException();
          } else if (cl.getResource("META-INF/ra.xml") != null) {
              // Connector
              throw new UnsupportedOperationException();
          } else {
              throw new DDBeanCreateException("Unrecognized archive: " + moduleURL);
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
  
  Index: WebDeployable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.tools.loader;
  
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.List;
  import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
  import javax.enterprise.deploy.shared.ModuleType;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/21 22:19:41 $
   */
  public class WebDeployable extends AbstractDeployable {
      private final ClassLoader webLoader;
  
      public WebDeployable(URL moduleURL) throws DDBeanCreateException {
          super(ModuleType.WAR, moduleURL, "WEB-INF/web.xml");
          ClassLoader parent = super.getModuleLoader();
          List path = new ArrayList();
          path.add(parent.getResource("WEB-INF/classes/"));
          Enumeration e = entries();
          while (e.hasMoreElements()) {
              String entry = (String) e.nextElement();
              if (entry.startsWith("WEB-INF/lib/")) {
                  String jarName = entry.substring(12);
                  if (jarName.indexOf('/') == -1 && (jarName.endsWith(".jar") || jarName.endsWith(".zip")))
{
                      path.add(parent.getResource(entry));
                  }
              }
          }
          webLoader = new URLClassLoader((URL[]) path.toArray(new URL[path.size()]), parent);
      }
  
      protected ClassLoader getModuleLoader() {
          return webLoader;
      }
  }
  
  
  

Mime
View raw message