Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 29526 invoked from network); 3 Feb 2004 06:51:24 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Feb 2004 06:51:24 -0000 Received: (qmail 12747 invoked by uid 500); 3 Feb 2004 06:51:02 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 12499 invoked by uid 500); 3 Feb 2004 06:51:00 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 12478 invoked from network); 3 Feb 2004 06:51:00 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 Feb 2004 06:51:00 -0000 Received: (qmail 29517 invoked by uid 1712); 3 Feb 2004 06:51:21 -0000 Date: 3 Feb 2004 06:51:21 -0000 Message-ID: <20040203065121.29516.qmail@minotaur.apache.org> From: djencks@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/util UnclosableInputStream.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N djencks 2004/02/02 22:51:21 Modified: modules/connector/src/java/org/apache/geronimo/connector/deployment Connector_1_0Module.java Connector_1_5Module.java modules/connector/src/test/org/apache/geronimo/connector/deployment Connector_1_0Test.java Connector_1_5Test.java Added: modules/connector/src/java/org/apache/geronimo/connector/deployment AbstractConnectorModule.java AbstractRARConfigurationFactory.java RAR_1_0ConfigurationFactory.java RAR_1_5ConfigurationFactory.java modules/deployment/src/java/org/apache/geronimo/deployment/util UnclosableInputStream.java Removed: modules/connector/src/java/org/apache/geronimo/connector/deployment ConnectorModule.java RARConfigurationFactory.java Log: Read the standard dd from the deployed package. set up the classpath. Work around some stupid behavior of xmlbeans Revision Changes Path 1.2 +13 -32 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_0Module.java Index: Connector_1_0Module.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_0Module.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Connector_1_0Module.java 2 Feb 2004 22:10:35 -0000 1.1 +++ Connector_1_0Module.java 3 Feb 2004 06:51:21 -0000 1.2 @@ -58,10 +58,11 @@ import java.beans.PropertyEditor; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.net.URI; -import java.net.URL; import java.util.Collections; +import java.util.jar.JarInputStream; import javax.management.AttributeNotFoundException; import javax.management.InvalidAttributeValueException; @@ -76,6 +77,7 @@ import org.apache.geronimo.deployment.ConfigurationCallback; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; +import org.apache.geronimo.deployment.util.UnclosableInputStream; import org.apache.geronimo.gbean.DynamicGAttributeInfo; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; @@ -85,11 +87,11 @@ import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType; import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType; import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType; -import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConfigPropertyType; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorDocument; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ResourceadapterType; +import org.apache.xmlbeans.XmlException; import org.w3c.dom.Document; /** @@ -98,42 +100,24 @@ * @version $Revision$ $Date$ * * */ -public class Connector_1_0Module implements DeploymentModule { +public class Connector_1_0Module extends AbstractConnectorModule implements DeploymentModule { - private final static String BASE_CONNECTION_MANAGER_FACTORY_NAME = "geronimo.management:J2eeType=ConnectionManager,name="; - private static final String BASE_MANAGED_CONNECTION_FACTORY_NAME = "geronimo.management:J2eeType=ManagedConnectionFactory,name="; - private static final String BASE_REALM_BRIDGE_NAME = "geronimo.security:service=RealmBridge,name="; - private static final String BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME = "geronimo.security:service=Realm,type=PasswordCredential,name="; - - private final URI configID; private ConnectorDocument connectorDocument; - private GerConnectorDocument geronimoConnectorDocument; - private final ObjectName connectionTrackerNamePattern; - private URL moduleArchive; - - public Connector_1_0Module(URI moduleID, URL moduleArchive, ConnectorDocument connectorDocument, GerConnectorDocument geronimoConnectorDocument, ObjectName connectionTrackerNamePattern) { - this.configID = moduleID; - this.moduleArchive = moduleArchive; - this.connectorDocument = connectorDocument; - this.geronimoConnectorDocument = geronimoConnectorDocument; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + + public Connector_1_0Module(URI configID, InputStream moduleArchive, Object geronimoConnectorDocument, ObjectName connectionTrackerNamePattern) { + super(configID, moduleArchive, geronimoConnectorDocument, connectionTrackerNamePattern); } public Connector_1_0Module(URI configID, InputStream moduleArchive, Document deploymentPlan, ObjectName connectionTrackerNamePattern) { - this.configID = configID; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + super(configID, moduleArchive, null, connectionTrackerNamePattern); } public Connector_1_0Module(URI configID, File moduleArchive, Document deploymentPlan, ObjectName connectionTrackerNamePattern) { - this.configID = configID; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + super(configID, null, null, connectionTrackerNamePattern); } - public void init() throws DeploymentException { - } - - public void generateClassPath(ConfigurationCallback callback) throws DeploymentException { - //I have no idea + protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException { + connectorDocument = ConnectorDocument.Factory.parse(new UnclosableInputStream(jarInputStream)); } public void defineGBeans(ConfigurationCallback callback, ClassLoader cl) throws DeploymentException { @@ -142,7 +126,6 @@ for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) { GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i); assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition"; - String connectionFactoryInterfaceName = geronimoConnectionDefinition.getConnectionfactoryInterface().getStringValue(); //ConnectionManagerFactory GerConnectionmanagerType connectionManagerFactory = geronimoConnectionDefinition.getConnectionmanager(); GBeanInfo connectionManagerFactoryGBeanInfo; @@ -281,6 +264,4 @@ } } - public void complete() { - } } 1.2 +30 -46 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_5Module.java Index: Connector_1_5Module.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/Connector_1_5Module.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Connector_1_5Module.java 2 Feb 2004 22:10:35 -0000 1.1 +++ Connector_1_5Module.java 3 Feb 2004 06:51:21 -0000 1.2 @@ -59,11 +59,14 @@ import java.beans.PropertyEditor; import java.io.File; import java.io.InputStream; +import java.io.IOException; import java.net.URI; import java.net.URL; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.jar.JarInputStream; +import java.util.jar.JarEntry; import javax.management.AttributeNotFoundException; import javax.management.InvalidAttributeValueException; @@ -80,6 +83,7 @@ import org.apache.geronimo.deployment.ConfigurationCallback; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; +import org.apache.geronimo.deployment.util.UnclosableInputStream; import org.apache.geronimo.gbean.DynamicGAttributeInfo; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; @@ -97,6 +101,7 @@ import org.apache.geronimo.xbeans.j2ee.ConnectionDefinitionType; import org.apache.geronimo.xbeans.j2ee.ConnectorDocument; import org.apache.geronimo.xbeans.j2ee.ResourceadapterType; +import org.apache.xmlbeans.XmlException; import org.w3c.dom.Document; /** @@ -105,44 +110,24 @@ * @version $Revision$ $Date$ * * */ -public class Connector_1_5Module implements DeploymentModule { +public class Connector_1_5Module extends AbstractConnectorModule { - public final static String BASE_RESOURCE_ADAPTER_NAME = "geronimo.management:J2eeType=ResourceAdapter,name="; - private final static String BASE_CONNECTION_MANAGER_FACTORY_NAME = "geronimo.management:J2eeType=ConnectionManager,name="; - private static final String BASE_MANAGED_CONNECTION_FACTORY_NAME = "geronimo.management:J2eeType=ManagedConnectionFactory,name="; - private static final String BASE_REALM_BRIDGE_NAME = "geronimo.security:service=RealmBridge,name="; - private static final String BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME = "geronimo.security:service=Realm,type=PasswordCredential,name="; - private static final String BASE_ADMIN_OBJECT_NAME = "geronimo.management:service=AdminObject,name="; - - private final URI configID; private ConnectorDocument connectorDocument; - private GerConnectorDocument geronimoConnectorDocument; - private final ObjectName connectionTrackerNamePattern; - private URL moduleArchive; - - public Connector_1_5Module(URI moduleID, URL moduleArchive, ConnectorDocument connectorDocument, GerConnectorDocument geronimoConnectorDocument, ObjectName connectionTrackerNamePattern) { - this.configID = moduleID; - this.moduleArchive = moduleArchive; - this.connectorDocument = connectorDocument; - this.geronimoConnectorDocument = geronimoConnectorDocument; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + + public Connector_1_5Module(URI configID, InputStream moduleArchive, Object geronimoConnectorDocument, ObjectName connectionTrackerNamePattern) { + super(configID, moduleArchive, geronimoConnectorDocument, connectionTrackerNamePattern); } public Connector_1_5Module(URI configID, InputStream moduleArchive, Document deploymentPlan, ObjectName connectionTrackerNamePattern) { - this.configID = configID; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + super(configID, moduleArchive, null, connectionTrackerNamePattern); } public Connector_1_5Module(URI configID, File moduleArchive, Document deploymentPlan, ObjectName connectionTrackerNamePattern) { - this.configID = configID; - this.connectionTrackerNamePattern = connectionTrackerNamePattern; + super(configID, null, null, connectionTrackerNamePattern); } - public void init() throws DeploymentException { - } - - public void generateClassPath(ConfigurationCallback callback) throws DeploymentException { - //I have no idea + protected void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException { + connectorDocument = ConnectorDocument.Factory.parse(new UnclosableInputStream(jarInputStream)); } public void defineGBeans(ConfigurationCallback callback, ClassLoader cl) throws DeploymentException { @@ -150,23 +135,24 @@ GerResourceadapterType geronimoResourceAdapter = geronimoConnectorDocument.getConnector().getResourceadapter(); //ResourceAdapter setup String resourceAdapterClassName = resourceadapter.getResourceadapterClass().getStringValue(); + if (resourceAdapterClassName == null) { + throw new DeploymentException("No resource adapter class provided for J2ee Connector Architecture 1.5 adapter"); + } ObjectName resourceAdapterObjectName = null; - if (resourceAdapterClassName != null) { - GBeanInfoFactory resourceAdapterInfoFactory = new GBeanInfoFactory(ResourceAdapterWrapper.class.getName(), ResourceAdapterWrapper.getGBeanInfo()); - GBeanMBean resourceAdapterGBean = setUpDynamicGBean(resourceAdapterInfoFactory, resourceadapter.getConfigPropertyArray(), geronimoResourceAdapter.getConfigPropertySettingArray()); - try { - resourceAdapterGBean.setAttribute("ResourceAdapterClass", cl.loadClass(resourceAdapterClassName)); - } catch (Exception e) { - throw new DeploymentException(e); - } - try { - resourceAdapterObjectName = ObjectName.getInstance(BASE_RESOURCE_ADAPTER_NAME + configID); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Could not construct resource adapter object name", e); - } - callback.addGBean(resourceAdapterObjectName, resourceAdapterGBean); - + GBeanInfoFactory resourceAdapterInfoFactory = new GBeanInfoFactory(ResourceAdapterWrapper.class.getName(), ResourceAdapterWrapper.getGBeanInfo()); + GBeanMBean resourceAdapterGBean = setUpDynamicGBean(resourceAdapterInfoFactory, resourceadapter.getConfigPropertyArray(), geronimoResourceAdapter.getConfigPropertySettingArray()); + try { + resourceAdapterGBean.setAttribute("ResourceAdapterClass", cl.loadClass(resourceAdapterClassName)); + } catch (Exception e) { + throw new DeploymentException(e); + } + try { + resourceAdapterObjectName = ObjectName.getInstance(BASE_RESOURCE_ADAPTER_NAME + configID); + } catch (MalformedObjectNameException e) { + throw new DeploymentException("Could not construct resource adapter object name", e); } + callback.addGBean(resourceAdapterObjectName, resourceAdapterGBean); + Map connectionDefinitions = new HashMap(); for (int j = 0; j < resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; j++) { ConnectionDefinitionType connectionDefinition = resourceadapter.getOutboundResourceadapter().getConnectionDefinitionArray(j); @@ -342,6 +328,4 @@ } } - public void complete() { - } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractConnectorModule.java Index: AbstractConnectorModule.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 * . * * ==================================================================== */ package org.apache.geronimo.connector.deployment; import java.net.URI; import java.util.jar.JarInputStream; import java.util.jar.JarEntry; import java.io.IOException; import java.io.InputStream; import javax.management.ObjectName; import org.apache.geronimo.deployment.DeploymentModule; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.ConfigurationCallback; import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.xmlbeans.XmlException; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/03 06:51:21 $ * * */ public abstract class AbstractConnectorModule implements DeploymentModule { public final static String BASE_RESOURCE_ADAPTER_NAME = "geronimo.management:J2eeType=ResourceAdapter,name="; protected final static String BASE_CONNECTION_MANAGER_FACTORY_NAME = "geronimo.management:J2eeType=ConnectionManager,name="; protected static final String BASE_MANAGED_CONNECTION_FACTORY_NAME = "geronimo.management:J2eeType=ManagedConnectionFactory,name="; protected static final String BASE_REALM_BRIDGE_NAME = "geronimo.security:service=RealmBridge,name="; private static final String BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME = "geronimo.security:service=Realm,type=PasswordCredential,name="; protected static final String BASE_ADMIN_OBJECT_NAME = "geronimo.management:service=AdminObject,name="; protected final URI configID; protected final ObjectName connectionTrackerNamePattern; protected InputStream moduleArchive; protected GerConnectorDocument geronimoConnectorDocument; public AbstractConnectorModule(URI configID, InputStream moduleArchive, Object geronimoConnectorDocument, ObjectName connectionTrackerNamePattern) { this.configID = configID; this.moduleArchive = moduleArchive; this.geronimoConnectorDocument = (GerConnectorDocument) geronimoConnectorDocument; this.connectionTrackerNamePattern = connectionTrackerNamePattern; } public void init() throws DeploymentException { } public void generateClassPath(ConfigurationCallback callback) throws DeploymentException { URI moduleBase = URI.create(configID.toString() + "/"); JarInputStream jarInputStream; try { jarInputStream = new JarInputStream(moduleArchive); for (JarEntry entry; (entry = jarInputStream.getNextJarEntry()) != null; jarInputStream.closeEntry()) { String name = entry.getName(); if (name.endsWith("/")) { continue; } if (name.equals("META-INF/ra.xml")) { getConnectorDocument(jarInputStream); continue; } if (name.endsWith(".jar")) { callback.addFile(moduleBase.resolve(name), jarInputStream); } //native libraries? } } catch (IOException e) { throw new DeploymentException(e); } catch (XmlException e) { throw new DeploymentException(e); } } protected abstract void getConnectorDocument(JarInputStream jarInputStream) throws XmlException, IOException; public void complete() { } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractRARConfigurationFactory.java Index: AbstractRARConfigurationFactory.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 * . * * ==================================================================== */ package org.apache.geronimo.connector.deployment; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URI; import javax.enterprise.deploy.model.DeployableObject; import javax.enterprise.deploy.shared.ModuleType; import javax.enterprise.deploy.spi.DeploymentConfiguration; import javax.enterprise.deploy.spi.exceptions.InvalidModuleException; import javax.management.ObjectName; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; import org.apache.geronimo.deployment.plugin.factories.DeploymentConfigurationFactory; import org.apache.geronimo.gbean.GAttributeInfo; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.GConstructorInfo; import org.apache.xmlbeans.XmlException; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/03 06:51:21 $ * * */ public abstract class AbstractRARConfigurationFactory implements DeploymentConfigurationFactory { private final ObjectName connectionTrackerNamePattern; public static final GBeanInfo GBEAN_INFO; public AbstractRARConfigurationFactory(ObjectName connectionTrackerNamePattern) { this.connectionTrackerNamePattern = connectionTrackerNamePattern; } public ObjectName getConnectionTrackerNamePattern() { return connectionTrackerNamePattern; } public DeploymentConfiguration createConfiguration(DeployableObject deployable) throws InvalidModuleException { if (!ModuleType.RAR.equals(deployable.getType())) { throw new InvalidModuleException("DeployableObject must be a RAR"); } return new RARConfiguration(deployable); } public DeploymentModule createModule(InputStream moduleArchive, Document deploymentPlan, URI configID) throws DeploymentException { return null; } public DeploymentModule createModule(File moduleArchive, Document deploymentPlan, URI configID, boolean isLocal) throws DeploymentException { return null; } public abstract DeploymentModule createModule(InputStream moduleArchive, Object geronimoDD, URI configID, boolean isLocal) throws DeploymentException, XmlException, IOException; static { GBeanInfoFactory infoFactory = new GBeanInfoFactory("Geronimo RAR Configuration Factory", AbstractRARConfigurationFactory.class.getName()); infoFactory.addInterface(DeploymentConfigurationFactory.class); infoFactory.addAttribute(new GAttributeInfo("ConnectionTrackerNamePattern", true)); infoFactory.setConstructor(new GConstructorInfo( new String[]{"ConnectionTrackerNamePattern"}, new Class[]{ObjectName.class})); GBEAN_INFO = infoFactory.getBeanInfo(); } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_0ConfigurationFactory.java Index: RAR_1_0ConfigurationFactory.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 * . * * ==================================================================== */ package org.apache.geronimo.connector.deployment; import java.io.IOException; import java.io.InputStream; import java.net.URI; import javax.management.ObjectName; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.xmlbeans.XmlException; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/03 06:51:21 $ * * */ public class RAR_1_0ConfigurationFactory extends AbstractRARConfigurationFactory { public static final GBeanInfo GBEAN_INFO; public RAR_1_0ConfigurationFactory(ObjectName connectionTrackerNamePattern) { super(connectionTrackerNamePattern); } public DeploymentModule createModule(InputStream moduleArchive, Object geronimoDD, URI configID, boolean isLocal) throws DeploymentException, XmlException, IOException { GerConnectorDocument geronimoConnectorDocument = (GerConnectorDocument) geronimoDD; return new Connector_1_0Module(configID, moduleArchive, geronimoConnectorDocument, getConnectionTrackerNamePattern()); } static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(RAR_1_0ConfigurationFactory.class.getName(), AbstractRARConfigurationFactory.GBEAN_INFO); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return RAR_1_0ConfigurationFactory.GBEAN_INFO; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_5ConfigurationFactory.java Index: RAR_1_5ConfigurationFactory.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 * . * * ==================================================================== */ package org.apache.geronimo.connector.deployment; import java.io.IOException; import java.io.InputStream; import java.net.URI; import javax.management.ObjectName; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.DeploymentModule; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.xmlbeans.XmlException; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/03 06:51:21 $ * * */ public class RAR_1_5ConfigurationFactory extends AbstractRARConfigurationFactory { public static final GBeanInfo GBEAN_INFO; public RAR_1_5ConfigurationFactory(ObjectName connectionTrackerNamePattern) { super(connectionTrackerNamePattern); } public DeploymentModule createModule(InputStream moduleArchive, Object geronimoDD, URI configID, boolean isLocal) throws DeploymentException, XmlException, IOException { GerConnectorDocument geronimoConnectorDocument = (GerConnectorDocument) geronimoDD; return new Connector_1_5Module(configID, moduleArchive, geronimoConnectorDocument, getConnectionTrackerNamePattern()); } static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(RAR_1_5ConfigurationFactory.class.getName(), AbstractRARConfigurationFactory.GBEAN_INFO); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return RAR_1_5ConfigurationFactory.GBEAN_INFO; } } 1.2 +22 -4 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/Connector_1_0Test.java Index: Connector_1_0Test.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/Connector_1_0Test.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Connector_1_0Test.java 2 Feb 2004 22:10:35 -0000 1.1 +++ Connector_1_0Test.java 3 Feb 2004 06:51:21 -0000 1.2 @@ -60,9 +60,13 @@ import java.net.URI; import java.util.Map; import java.util.HashMap; +import java.util.zip.ZipEntry; +import java.util.jar.JarOutputStream; import java.io.InputStream; import java.io.File; import java.io.IOException; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; import javax.management.ObjectName; @@ -82,7 +86,6 @@ public class Connector_1_0Test extends TestCase implements ConfigurationCallback { private URL j2eeDD; private URL geronimoDD; - private URL moduleArchive = null; private URI configID = URI.create("geronimo/connector10/test"); private Map gbeans = new HashMap(); @@ -99,10 +102,25 @@ } public void testCreateConnector_1_0Module() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + JarOutputStream jarOutputStream = new JarOutputStream(baos); + ZipEntry entry = new ZipEntry("META-INF/ra.xml"); + jarOutputStream.putNextEntry(entry); + InputStream j2eeInputStream = j2eeDD.openStream(); + byte[] buffer = new byte[1024]; + for (int length; (length = j2eeInputStream.read(buffer)) > 0; ) { + jarOutputStream.write(buffer, 0, length); + } + jarOutputStream.flush(); + jarOutputStream.closeEntry(); + jarOutputStream.close(); + + InputStream moduleArchive = new ByteArrayInputStream(baos.toByteArray()); InputStream geronimoInputStream = geronimoDD.openStream(); - RARConfigurationFactory rarConfigurationFactory = new RARConfigurationFactory(ObjectName.getInstance("geronimo.test:role=ConnectionTracker")); - DeploymentModule connector_1_0Module = rarConfigurationFactory.createModule(moduleArchive, j2eeInputStream, geronimoInputStream, configID, true); + GerConnectorDocument connectorDocument = GerConnectorDocument.Factory.parse(geronimoInputStream); + RAR_1_0ConfigurationFactory rarConfigurationFactory = new RAR_1_0ConfigurationFactory(ObjectName.getInstance("geronimo.test:role=ConnectionTracker")); + DeploymentModule connector_1_0Module = rarConfigurationFactory.createModule(moduleArchive, connectorDocument, configID, true); connector_1_0Module.init(); connector_1_0Module.generateClassPath(this); connector_1_0Module.defineGBeans(this, this.getClass().getClassLoader()); 1.2 +22 -4 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/Connector_1_5Test.java Index: Connector_1_5Test.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/Connector_1_5Test.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Connector_1_5Test.java 2 Feb 2004 22:10:35 -0000 1.1 +++ Connector_1_5Test.java 3 Feb 2004 06:51:21 -0000 1.2 @@ -59,10 +59,14 @@ import java.io.File; import java.io.InputStream; import java.io.IOException; +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; import java.net.URL; import java.net.URI; import java.util.Map; import java.util.HashMap; +import java.util.zip.ZipEntry; +import java.util.jar.JarOutputStream; import javax.management.ObjectName; @@ -82,7 +86,6 @@ public class Connector_1_5Test extends TestCase implements ConfigurationCallback { private URL j2eeDD; private URL geronimoDD; - private URL moduleArchive = null; private URI configID = URI.create("geronimo/connector15/test"); private Map gbeans = new HashMap(); @@ -99,10 +102,25 @@ } public void testCreateConnector_1_5Module() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + JarOutputStream jarOutputStream = new JarOutputStream(baos); + ZipEntry entry = new ZipEntry("META-INF/ra.xml"); + jarOutputStream.putNextEntry(entry); + InputStream j2eeInputStream = j2eeDD.openStream(); + byte[] buffer = new byte[1024]; + for (int length; (length = j2eeInputStream.read(buffer)) > 0; ) { + jarOutputStream.write(buffer, 0, length); + } + jarOutputStream.flush(); + jarOutputStream.closeEntry(); + jarOutputStream.close(); + + InputStream moduleArchive = new ByteArrayInputStream(baos.toByteArray()); InputStream geronimoInputStream = geronimoDD.openStream(); - RARConfigurationFactory rarConfigurationFactory = new RARConfigurationFactory(ObjectName.getInstance("geronimo.test:role=ConnectionTracker")); - DeploymentModule connector_1_5Module = rarConfigurationFactory.createModule(moduleArchive, j2eeInputStream, geronimoInputStream, configID, true); + GerConnectorDocument connectorDocument = GerConnectorDocument.Factory.parse(geronimoInputStream); + RAR_1_5ConfigurationFactory rarConfigurationFactory = new RAR_1_5ConfigurationFactory(ObjectName.getInstance("geronimo.test:role=ConnectionTracker")); + DeploymentModule connector_1_5Module = rarConfigurationFactory.createModule(moduleArchive, connectorDocument, configID, true); connector_1_5Module.init(); connector_1_5Module.generateClassPath(this); connector_1_5Module.defineGBeans(this, this.getClass().getClassLoader()); 1.1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/util/UnclosableInputStream.java Index: UnclosableInputStream.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 * . * * ==================================================================== */ package org.apache.geronimo.deployment.util; import java.io.InputStream; import java.io.IOException; /** * This class is a workaround for XMLBeans unfortunate habit of closing streams it reads from * combined with JarInputStreams insistence that you cant do that. * * @version $Revision: 1.1 $ $Date: 2004/02/03 06:51:21 $ * * */ public class UnclosableInputStream extends InputStream { private final InputStream delegate; public UnclosableInputStream(InputStream delegate) { this.delegate = delegate; } public void close() { } public int available() throws IOException { return delegate.available(); } public void mark(int readLimit) { delegate.mark(readLimit); } public boolean markSupported() { return delegate.markSupported(); } public int read() throws IOException { return delegate.read(); } public int read(byte[] buffer) throws IOException { return delegate.read(buffer); } public int read(byte[] buffer, int offset, int length) throws IOException { return delegate.read(buffer, offset, length); } public void reset() throws IOException { delegate.reset(); } public long skip(long n) throws IOException { return delegate.skip(n); } }