jboynes 2004/02/05 18:57:24
Modified: modules/deployment/src/java/org/apache/geronimo/deployment/tools
DeployCommand.java
Added: modules/deployment/src/java/org/apache/geronimo/deployment
JARDeployer.java
modules/deployment/src/test/org/apache/geronimo/deployment
JARDeployerTest.java
Log:
Support adding plain JARs into a CAR
Revision Changes Path
1.7 +8 -5
incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DeployCommand.java
Index: DeployCommand.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DeployCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeployCommand.java 24 Jan 2004 19:50:04 -0000 1.6
+++ DeployCommand.java 6 Feb 2004 02:57:23 -0000 1.7
@@ -75,6 +75,7 @@
import org.apache.geronimo.deployment.DeploymentException;
import org.apache.geronimo.deployment.NoDeployerException;
import org.apache.geronimo.deployment.URLDeployer;
+import org.apache.geronimo.deployment.JARDeployer;
import org.apache.geronimo.deployment.service.ServiceDeployer;
import org.apache.geronimo.deployment.util.FileUtil;
import org.apache.geronimo.deployment.util.URLInfo;
@@ -188,14 +189,16 @@
}
private static List getDeployers() {
+ DocumentBuilder parser;
try {
- List deployers = new ArrayList();
- DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
- deployers.add(new ServiceDeployer(parser));
- return deployers;
+ parser =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new AssertionError("Unable to instantiate XML Parser");
}
+ List deployers = new ArrayList();
+ deployers.add(new ServiceDeployer(parser));
+ deployers.add(new JARDeployer());
+ return deployers;
}
private static File createWorkDir() throws IOException {
1.1
incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/JARDeployer.java
Index: JARDeployer.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 [EMAIL PROTECTED]
*
* 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;
import org.apache.geronimo.deployment.util.URLInfo;
import org.apache.geronimo.deployment.util.URLType;
import java.net.URI;
import java.net.URL;
import java.io.IOException;
import java.io.InputStream;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/02/06 02:57:24 $
*/
public class JARDeployer implements ModuleFactory {
public DeploymentModule getModule(URLInfo urlInfo, URI moduleID) throws
DeploymentException {
if (urlInfo.getType() == URLType.PACKED_ARCHIVE) {
return new JARModule(urlInfo.getUrl());
}
return null;
}
private static class JARModule implements DeploymentModule {
private final URL url;
public JARModule(URL url) {
this.url = url;
}
public void init() throws DeploymentException {
}
public void generateClassPath(ConfigurationCallback callback) throws
DeploymentException {
String name = url.toString();
int idx = name.lastIndexOf('/');
if (idx != -1) {
name = name.substring(idx+1);
}
URI path = URI.create(name);
try {
InputStream source = url.openStream();
try {
callback.addFile(path, source);
} finally {
source.close();
}
callback.addToClasspath(path);
} catch (IOException e) {
throw new DeploymentException("Unable to add URL "+url, e);
}
}
public void defineGBeans(ConfigurationCallback callback, ClassLoader
cl) throws DeploymentException {
}
public void complete() {
}
}
}
1.1
incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/JARDeployerTest.java
Index: JARDeployerTest.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 [EMAIL PROTECTED]
*
* 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;
import junit.framework.TestCase;
import java.net.URL;
import java.net.URI;
import java.io.InputStream;
import java.io.IOException;
import org.apache.geronimo.deployment.util.URLInfo;
import org.apache.geronimo.deployment.util.URLType;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
import javax.management.ObjectName;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/02/06 02:57:24 $
*/
public class JARDeployerTest extends TestCase {
private URL url;
private URLInfo urlInfo;
private JARDeployer deployer;
public void testURL() throws Exception {
DeploymentModule module = deployer.getModule(urlInfo, null);
assertNotNull(module);
module.generateClassPath(new ConfigurationCallback() {
public void addFile(URI path, InputStream source) throws
IOException {
assertEquals(URI.create("app-client1.jar"), path);
}
public void addGBean(ObjectName name, GBeanMBean gbean) {
fail();
}
public void addToClasspath(URI uri) {
assertEquals(URI.create("app-client1.jar"), uri);
}
});
}
protected void setUp() throws Exception {
super.setUp();
url =
Thread.currentThread().getContextClassLoader().getResource("deployables/app-client1.jar");
urlInfo = new URLInfo(url, URLType.PACKED_ARCHIVE);
deployer = new JARDeployer();
}
}