geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r109611 - geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader
Date Fri, 03 Dec 2004 00:55:05 GMT
Author: ammulder
Date: Thu Dec  2 16:55:04 2004
New Revision: 109611

URL: http://svn.apache.org/viewcvs?view=rev&rev=109611
Log:
Some files seem to have vaporized during the commit -- I must have
  messed up something in the various copying and deleting

Added:
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/AbstractDeployable.java
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ApplicationDeployable.java
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ClientDeployable.java
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/DeployableFactory.java
   geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java

Added: geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/AbstractDeployable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/AbstractDeployable.java?view=auto&rev=109611
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/AbstractDeployable.java
Thu Dec  2 16:55:04 2004
@@ -0,0 +1,130 @@
+/**
+ *
+ * Copyright 2003-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.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 $Rev$ $Date$
+ */
+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();
+    }
+}

Added: geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ApplicationDeployable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ApplicationDeployable.java?view=auto&rev=109611
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ApplicationDeployable.java
Thu Dec  2 16:55:04 2004
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2003-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.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 $Rev$ $Date$
+ */
+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) {
+    }
+}

Added: geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ClientDeployable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ClientDeployable.java?view=auto&rev=109611
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/ClientDeployable.java
Thu Dec  2 16:55:04 2004
@@ -0,0 +1,34 @@
+/**
+ *
+ * Copyright 2003-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.tools.loader;
+
+import java.net.URL;
+import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
+import javax.enterprise.deploy.shared.ModuleType;
+
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ClientDeployable extends AbstractDeployable  {
+    public ClientDeployable(URL moduleURL) throws DDBeanCreateException {
+        super(ModuleType.CAR, moduleURL, "META-INF/application-client.xml");
+    }
+}

Added: geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/DeployableFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/DeployableFactory.java?view=auto&rev=109611
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/DeployableFactory.java
Thu Dec  2 16:55:04 2004
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2003-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.tools.loader;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import javax.enterprise.deploy.model.DeployableObject;
+import javax.enterprise.deploy.model.exceptions.DDBeanCreateException;
+
+/**
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+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);
+        }
+    }
+}

Added: geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java?view=auto&rev=109611
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/test-ddbean/src/java/org/apache/geronimo/deployment/tools/loader/WebDeployable.java
Thu Dec  2 16:55:04 2004
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2003-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.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 $Rev$ $Date$
+ */
+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