From geronimo-cvs-return-2862-apmail-incubator-geronimo-cvs-archive=incubator.apache.org@incubator.apache.org Fri Feb 20 07:19:16 2004 Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 86808 invoked from network); 20 Feb 2004 07:19:16 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 20 Feb 2004 07:19:16 -0000 Received: (qmail 92943 invoked by uid 500); 20 Feb 2004 07:18:53 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 92763 invoked by uid 500); 20 Feb 2004 07:18:51 -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 92749 invoked from network); 20 Feb 2004 07:18:51 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 20 Feb 2004 07:18:51 -0000 Received: (qmail 86776 invoked by uid 1716); 20 Feb 2004 07:19:13 -0000 Date: 20 Feb 2004 07:19:13 -0000 Message-ID: <20040220071913.86775.qmail@minotaur.apache.org> From: jboynes@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment DeploymentTest.java WARConfigurationFactoryTest.java WebAppDConfigTest.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 jboynes 2004/02/19 23:19:13 Modified: modules/deployment/src/java/org/apache/geronimo/deployment Bootstrap.java ConfigurationBuilder.java Deployer.java modules/deployment/src/java/org/apache/geronimo/deployment/service ServiceConfigBuilder.java modules/jetty/src/java/org/apache/geronimo/jetty/deployment AbstractModule.java WebAppDConfigBean.java modules/jetty/src/schema geronimo-jetty.xsd modules/jetty/src/test-resources/deployables/war1/WEB-INF geronimo-web.xml modules/jetty/src/test/org/apache/geronimo/jetty/deployment DeploymentTest.java WARConfigurationFactoryTest.java WebAppDConfigTest.java Added: modules/deployment/src/java/org/apache/geronimo/deployment/service GBeanBuilder.java modules/jetty/src/java/org/apache/geronimo/jetty/deployment WARConfigBuilder.java Log: Temporarily remove naming and security from jetty deployment Factor out GBean construction from ServiceConfigBuilder Add GBean element to jetty deployment Move install option from builder to Deployer Revision Changes Path 1.7 +2 -1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java Index: Bootstrap.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Bootstrap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Bootstrap.java 12 Feb 2004 18:27:39 -0000 1.6 +++ Bootstrap.java 20 Feb 2004 07:19:13 -0000 1.7 @@ -125,6 +125,7 @@ // Install Deployer ObjectName deployerName = Deployer.getDeployerName(CONFIG_ID); GBeanMBean deployer = new GBeanMBean(Deployer.GBEAN_INFO); + deployer.setReferencePatterns("Kernel", Collections.singleton(Kernel.KERNEL)); deployer.setReferencePatterns("Builders", Collections.singleton(new ObjectName("geronimo.deployer:role=Builder,id=" + CONFIG_ID.toString() + ",*"))); gbeans.put(deployerName, deployer); 1.3 +6 -2 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java Index: ConfigurationBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ConfigurationBuilder.java 19 Feb 2004 01:51:44 -0000 1.2 +++ ConfigurationBuilder.java 20 Feb 2004 07:19:13 -0000 1.3 @@ -59,8 +59,10 @@ import java.io.File; import java.net.URL; import java.util.jar.JarInputStream; +import java.util.List; import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.SchemaTypeLoader; /** * @@ -68,6 +70,8 @@ * @version $Revision$ $Date$ */ public interface ConfigurationBuilder { + SchemaTypeLoader[] getTypeLoaders(); + /** * Determine if this builder can handle the supplied plan. * @param plan the plan to examine @@ -83,5 +87,5 @@ */ XmlObject getDeploymentPlan(URL module); - void buildConfiguration(File outfile, JarInputStream module, XmlObject plan, boolean install) throws IOException, DeploymentException; + void buildConfiguration(File outfile, JarInputStream module, XmlObject plan) throws IOException, DeploymentException; } 1.5 +28 -6 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Index: Deployer.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Deployer.java 19 Feb 2004 01:51:44 -0000 1.4 +++ Deployer.java 20 Feb 2004 07:19:13 -0000 1.5 @@ -63,6 +63,9 @@ import java.util.Collection; import java.util.Iterator; import java.util.Properties; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -78,6 +81,7 @@ import org.apache.geronimo.gbean.GReferenceInfo; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.config.LocalConfigStore; +import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.log.GeronimoLogging; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; @@ -98,8 +102,10 @@ public static final URI DEFAULT_CONFIG = URI.create("org/apache/geronimo/J2EEDeployer"); private final Collection builders; + private final Kernel kernel; - public Deployer(Collection builders) { + public Deployer(Kernel kernel, Collection builders) { + this.kernel = kernel; this.builders = builders; } @@ -126,7 +132,16 @@ saveOutput = true; } try { - builder.buildConfiguration(cmd.carfile, null, plan, cmd.install); + builder.buildConfiguration(cmd.carfile, null, plan); + + try { + if (cmd.install) { + kernel.install(cmd.carfile.toURL()); + } + } catch (InvalidConfigException e) { + // unlikely as we just built this + throw new DeploymentException(e); + } } finally { if (!saveOutput) { cmd.carfile.delete(); @@ -135,8 +150,14 @@ } private SchemaTypeLoader getLoader() { + List types = new ArrayList(builders.size()); + for (Iterator i = builders.iterator(); i.hasNext();) { + ConfigurationBuilder builder = (ConfigurationBuilder) i.next(); + types.addAll(Arrays.asList(builder.getTypeLoaders())); + } // @todo this should also set up the entity resolver and error handlers - return XmlBeans.getContextTypeLoader(); + SchemaTypeLoader[] loaders = (SchemaTypeLoader[]) types.toArray(new SchemaTypeLoader[types.size()]); + return XmlBeans.typeLoaderUnion(loaders); } /** @@ -258,10 +279,11 @@ GBeanInfoFactory infoFactory = new GBeanInfoFactory(Deployer.class); infoFactory.addOperation(new GOperationInfo("deploy", new Class[]{String[].class})); infoFactory.addOperation(new GOperationInfo("deploy", new Class[]{Command.class})); + infoFactory.addReference(new GReferenceInfo("Kernel", Kernel.class)); infoFactory.addReference(new GReferenceInfo("Builders", ConfigurationBuilder.class)); infoFactory.setConstructor(new GConstructorInfo( - new String[]{"Builders"}, - new Class[]{Collection.class} + new String[]{"Kernel", "Builders"}, + new Class[]{Kernel.class, Collection.class} )); GBEAN_INFO = infoFactory.getBeanInfo(); } 1.4 +15 -70 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Index: ServiceConfigBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ServiceConfigBuilder.java 19 Feb 2004 01:51:44 -0000 1.3 +++ ServiceConfigBuilder.java 20 Feb 2004 07:19:13 -0000 1.4 @@ -55,28 +55,22 @@ */ package org.apache.geronimo.deployment.service; -import java.beans.PropertyEditor; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.net.MalformedURLException; import java.net.URLClassLoader; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; import java.util.jar.Attributes; +import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; -import java.util.jar.JarInputStream; import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import org.apache.geronimo.common.propertyeditor.PropertyEditors; import org.apache.geronimo.deployment.ConfigurationBuilder; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.deployment.DeploymentException; @@ -92,10 +86,10 @@ import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.GConstructorInfo; import org.apache.geronimo.gbean.GReferenceInfo; -import org.apache.geronimo.gbean.jmx.GBeanMBean; import org.apache.geronimo.kernel.Kernel; -import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.repository.Repository; +import org.apache.xmlbeans.SchemaTypeLoader; +import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlObject; /** @@ -112,6 +106,10 @@ this.kernel = kernel; } + public SchemaTypeLoader[] getTypeLoaders() { + return new SchemaTypeLoader[]{XmlBeans.getContextTypeLoader()}; + } + public boolean canConfigure(XmlObject plan) { return plan instanceof ConfigurationDocument; } @@ -120,7 +118,7 @@ return null; } - public void buildConfiguration(File outfile, JarInputStream module, XmlObject plan, boolean install) throws IOException, DeploymentException { + public void buildConfiguration(File outfile, JarInputStream module, XmlObject plan) throws IOException, DeploymentException { ConfigurationType configType = ((ConfigurationDocument) plan).getConfiguration(); URI configID; try { @@ -162,14 +160,6 @@ fos.close(); } - try { - if (install) { - kernel.install(outfile.toURL()); - } - } catch (InvalidConfigException e) { - // unlikely as we just built this - throw new DeploymentException(e); - } } private void addIncludes(DeploymentContext context, ConfigurationType configType) throws DeploymentException { @@ -252,75 +242,30 @@ GbeanType[] gbeans = configType.getGbeanArray(); for (int i = 0; i < gbeans.length; i++) { GbeanType gbean = gbeans[i]; - ObjectName name; - try { - name = new ObjectName(gbean.getName()); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Invalid ObjectName " + gbean.getName(), e); - } - String className = gbean.getClass1(); - GBeanMBean mbean; - try { - mbean = new GBeanMBean(className, cl); - } catch (Exception e) { - throw new DeploymentException("Unable to create GBean from class " + className, e); - } + GBeanBuilder builder = new GBeanBuilder(gbean.getName(), cl, gbean.getClass1()); // set up attributes AttributeType[] attrs = gbean.getAttributeArray(); for (int j = 0; j < attrs.length; j++) { AttributeType attr = attrs[j]; - String attrName = attr.getName(); - String type = attr.getType(); - Object value = attr.getStringValue(); - try { - // @todo we should not need all of common just for this - PropertyEditor editor = PropertyEditors.findEditor(type); - if (editor != null) { - editor.setAsText((String) value); - value = editor.getValue(); - } - } catch (ClassNotFoundException e) { - throw new DeploymentException("Unable to find PropertyEditor for " + type, e); - } - try { - mbean.setAttribute(attrName, value); - } catch (Exception e) { - throw new DeploymentException("Unable to set attribute " + attrName, e); - } + builder.setAttribute(attr.getName(), attr.getType(), attr.getStringValue()); } // set up all single pattern references ReferenceType[] refs = gbean.getReferenceArray(); for (int j = 0; j < refs.length; j++) { ReferenceType ref = refs[j]; - String refName = ref.getName(); - String pattern = ref.getStringValue(); - try { - mbean.setReferencePatterns(refName, Collections.singleton(new ObjectName(pattern))); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Invalid pattern for reference " + refName, e); - } + builder.setReference(ref.getName(), ref.getStringValue()); } // set up app multi-patterned references ReferencesType[] refs2 = gbean.getReferencesArray(); for (int j = 0; j < refs2.length; j++) { ReferencesType type = refs2[j]; - String refName = type.getName(); - String[] patterns = type.getPatternArray(); - Set patternNames = new HashSet(patterns.length); - for (int k = 0; k < patterns.length; k++) { - try { - patternNames.add(new ObjectName(patterns[k])); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Invalid pattern for reference " + refName + " : " + patterns[k], e); - } - } - mbean.setReferencePatterns(refName, patternNames); + builder.setReference(type.getName(), type.getPatternArray()); } - context.addGBean(name, mbean); + context.addGBean(builder.getName(), builder.getGBean()); } } 1.1 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/GBeanBuilder.java Index: GBeanBuilder.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.service; import java.beans.PropertyEditor; import java.util.Collections; import java.util.HashSet; import java.util.Set; import javax.management.AttributeNotFoundException; import javax.management.InvalidAttributeValueException; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.apache.geronimo.common.propertyeditor.PropertyEditors; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.gbean.jmx.GBeanMBean; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/20 07:19:13 $ */ public class GBeanBuilder { private final ObjectName name; private final GBeanMBean gbean; public GBeanBuilder(String name, ClassLoader classLoader, String className) throws DeploymentException { try { this.name = new ObjectName(name); } catch (MalformedObjectNameException e) { throw new DeploymentException("Invalid ObjectName: " + name, e); } try { this.gbean = new GBeanMBean(className, classLoader); } catch (Exception e) { throw new DeploymentException("Unable to create GBean from class " + className, e); } } public void setAttribute(String name, String type, String text) throws DeploymentException { try { // @todo we should not need all of common just for this PropertyEditor editor = PropertyEditors.findEditor(type); if (editor == null) { throw new DeploymentException("Unable to find PropertyEditor for " + type); } editor.setAsText(text); Object value = editor.getValue(); gbean.setAttribute(name, value); } catch (ClassNotFoundException e) { throw new DeploymentException("Unable to find PropertyEditor for " + type, e); } catch (AttributeNotFoundException e) { throw new DeploymentException("Unknown attribute " + name); } catch (InvalidAttributeValueException e) { throw new DeploymentException("Invalid value for attribute " + name + ": " + text, e); } catch (Exception e) { throw new DeploymentException("Unable to set attribute " + name + " to " + text, e); } } public void setReference(String name, String pattern) throws DeploymentException { try { gbean.setReferencePatterns(name, Collections.singleton(new ObjectName(pattern))); } catch (MalformedObjectNameException e) { throw new DeploymentException("Invalid pattern for reference " + name + ": " + pattern, e); } } public void setReference(String name, String[] patterns) throws DeploymentException { Set patternNames = new HashSet(patterns.length); for (int i = 0; i < patterns.length; i++) { try { patternNames.add(new ObjectName(patterns[i])); } catch (MalformedObjectNameException e) { throw new DeploymentException("Invalid pattern for reference " + name + ": " + patterns[i], e); } } gbean.setReferencePatterns(name, patternNames); } public GBeanMBean getGBean() { return gbean; } public ObjectName getName() { return name; } } 1.8 +4 -2 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/AbstractModule.java Index: AbstractModule.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/AbstractModule.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractModule.java 15 Feb 2004 16:33:44 -0000 1.7 +++ AbstractModule.java 20 Feb 2004 07:19:13 -0000 1.8 @@ -101,7 +101,7 @@ this.configID = configID; this.jettyWebApp = jettyWebApp; this.proxyFactory = proxyFactory; - contextPath = jettyWebApp.getContextRoot().getStringValue(); + contextPath = jettyWebApp.getContextRoot(); if (contextPath == null) { throw new DeploymentException("No context root specified"); } @@ -130,6 +130,7 @@ app.setAttribute("ContextPriorityClassLoader", new Boolean(contextPriorityClassLoader)); app.setAttribute("PolicyContextID", null); //jndi +/* if (proxyFactory != null) { UserTransaction userTransaction = null; Context componentContext = new ComponentContextBuilder(proxyFactory, cl).buildContext( @@ -142,6 +143,7 @@ userTransaction); app.setAttribute("ComponentContext", componentContext); } +*/ app.setReferencePatterns("Configuration", Collections.singleton(Kernel.getConfigObjectName(configID))); app.setReferencePatterns("JettyContainer", Collections.singleton(new ObjectName("geronimo.web:type=WebContainer,container=Jetty"))); // @todo configurable 1.10 +11 -15 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java Index: WebAppDConfigBean.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WebAppDConfigBean.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WebAppDConfigBean.java 18 Feb 2004 20:58:43 -0000 1.9 +++ WebAppDConfigBean.java 20 Feb 2004 07:19:13 -0000 1.10 @@ -61,13 +61,8 @@ import javax.enterprise.deploy.spi.exceptions.ConfigurationException; import org.apache.geronimo.deployment.plugin.DConfigBeanSupport; -import org.apache.geronimo.naming.deployment.ENCHelper; +//import org.apache.geronimo.naming.deployment.ENCHelper; import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType; -import org.apache.geronimo.xbeans.geronimo.GerEjbRefType; -import org.apache.geronimo.xbeans.geronimo.GerEjbLocalRefType; -import org.apache.geronimo.xbeans.geronimo.GerMessageDestinationRefType; -import org.apache.geronimo.xbeans.geronimo.GerResourceEnvRefType; -import org.apache.geronimo.xbeans.geronimo.GerResourceRefType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; @@ -79,13 +74,11 @@ public class WebAppDConfigBean extends DConfigBeanSupport { private final static SchemaTypeLoader SCHEMA_TYPE_LOADER = XmlBeans.getContextTypeLoader(); - private ENCHelper encHelper; +// private ENCHelper encHelper; WebAppDConfigBean(DDBean ddBean, JettyWebAppType webApp) { super(ddBean, webApp, SCHEMA_TYPE_LOADER); - if (webApp.getContextRoot() == null) { - webApp.addNewContextRoot(); - } +/* encHelper = new ENCHelper(ddBean, new ENCHelper.XmlEnvRefs() { public GerEjbRefType[] getEjbRefs() { return getWebApp().getEjbRefArray(); @@ -148,6 +141,7 @@ } }); +*/ } JettyWebAppType getWebApp() { @@ -155,12 +149,12 @@ } public String getContextRoot() { - return getWebApp().getContextRoot().getStringValue(); + return getWebApp().getContextRoot(); } public void setContextRoot(String contextRoot) { pcs.firePropertyChange("contextRoot", getContextRoot(), contextRoot); - getWebApp().getContextRoot().setStringValue(contextRoot); + getWebApp().setContextRoot(contextRoot); } /** getContextPriorityClassLoader. @@ -181,7 +175,8 @@ } public DConfigBean getDConfigBean(DDBean ddBean) throws ConfigurationException { - return encHelper.getDConfigBean(ddBean); + return null; +// return encHelper.getDConfigBean(ddBean); } public void removeDConfigBean(DConfigBean dcBean) throws BeanNotFoundException { @@ -189,7 +184,8 @@ } public String[] getXpaths() { - return ENCHelper.ENC_XPATHS; + return null; +// return ENCHelper.ENC_XPATHS; } } 1.1 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/WARConfigBuilder.java Index: WARConfigBuilder.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.jetty.deployment; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; import javax.management.MalformedObjectNameException; import org.apache.geronimo.deployment.ConfigurationBuilder; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.deployment.service.GBeanBuilder; import org.apache.geronimo.deployment.service.ServiceConfigBuilder; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.GConstructorInfo; import org.apache.geronimo.gbean.GReferenceInfo; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.repository.Repository; import org.apache.geronimo.xbeans.geronimo.jetty.JettyAttributeType; import org.apache.geronimo.xbeans.geronimo.jetty.JettyGbeanType; import org.apache.geronimo.xbeans.geronimo.jetty.JettyReferenceType; import org.apache.geronimo.xbeans.geronimo.jetty.JettyReferencesType; import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument; import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType; import org.apache.geronimo.xbeans.j2ee.WebAppDocument; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; /** * * * @version $Revision: 1.1 $ $Date: 2004/02/20 07:19:13 $ */ public class WARConfigBuilder implements ConfigurationBuilder { private final Repository repository; private final Kernel kernel; public WARConfigBuilder(Kernel kernel, Repository repository) { this.kernel = kernel; this.repository = repository; } public boolean canConfigure(XmlObject plan) { return plan instanceof JettyWebAppDocument || plan instanceof WebAppDocument; } public SchemaTypeLoader[] getTypeLoaders() { return new SchemaTypeLoader[]{XmlBeans.getContextTypeLoader()}; } public XmlObject getDeploymentPlan(URL module) { try { XmlObject plan = getPlan(new URL(module, "WEB-INF/geronimo-jetty.xml"), JettyWebAppDocument.type); // todo needs generic web XMLBeans // if (plan == null) { // plan = getPlan(new URL(module, "WEB-INF/geronimo-web.xml")); // } // todo should be able to deploy a naked WAR // if (plan == null) { // plan = getPlan(new URL(module, "WEB-INF/web.xml"), WebAppDocument.type); // } return plan; } catch (MalformedURLException e) { return null; } } private XmlObject getPlan(URL planURL, SchemaType type) { InputStream is; try { is = planURL.openStream(); try { return XmlBeans.getContextTypeLoader().parse(is, type, null); } finally { is.close(); } } catch (IOException e) { return null; } catch (XmlException e) { return null; } } public void buildConfiguration(File outfile, JarInputStream module, XmlObject plan) throws IOException, DeploymentException { JettyWebAppType jettyWebApp = ((JettyWebAppDocument) plan).getWebApp(); URI configID; try { configID = new URI(jettyWebApp.getConfigId()); } catch (URISyntaxException e) { throw new DeploymentException("Invalid configId " + jettyWebApp.getConfigId(), e); } URI parentID; if (jettyWebApp.isSetParentId()) { try { parentID = new URI(jettyWebApp.getParentId()); } catch (URISyntaxException e) { throw new DeploymentException("Invalid parentId " + jettyWebApp.getParentId(), e); } } else { parentID = null; } FileOutputStream fos = new FileOutputStream(outfile); try { JarOutputStream os = new JarOutputStream(new BufferedOutputStream(fos)); DeploymentContext context = null; try { context = new DeploymentContext(os, configID, parentID, kernel); } catch (MalformedObjectNameException e) { throw new DeploymentException(e); } // addIncludes(context, configType); // addDependencies(context, configType.getDependencyArray()); ClassLoader cl = context.getClassLoader(repository); addGBeans(context, jettyWebApp, cl); context.close(); os.flush(); } finally { fos.close(); } } private void addGBeans(DeploymentContext context, JettyWebAppType webApp, ClassLoader cl) throws DeploymentException { JettyGbeanType[] gbeans = webApp.getGbeanArray(); for (int i = 0; i < gbeans.length; i++) { JettyGbeanType gbean = gbeans[i]; GBeanBuilder builder = new GBeanBuilder(gbean.getName(), cl, gbean.getClass1()); // set up attributes JettyAttributeType[] attrs = gbean.getAttributeArray(); for (int j = 0; j < attrs.length; j++) { JettyAttributeType attr = attrs[j]; builder.setAttribute(attr.getName(), attr.getType(), attr.getStringValue()); } // set up all single pattern references JettyReferenceType[] refs = gbean.getReferenceArray(); for (int j = 0; j < refs.length; j++) { JettyReferenceType ref = refs[j]; builder.setReference(ref.getName(), ref.getStringValue()); } // set up app multi-patterned references JettyReferencesType[] refs2 = gbean.getReferencesArray(); for (int j = 0; j < refs2.length; j++) { JettyReferencesType type = refs2[j]; builder.setReference(type.getName(), type.getPatternArray()); } context.addGBean(builder.getName(), builder.getGBean()); } } public static final GBeanInfo GBEAN_INFO; static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(ServiceConfigBuilder.class); infoFactory.addInterface(ConfigurationBuilder.class); infoFactory.addReference(new GReferenceInfo("Repository", Repository.class)); infoFactory.addReference(new GReferenceInfo("Kernel", Kernel.class)); infoFactory.setConstructor(new GConstructorInfo( new String[]{"Repository", "Kernel"}, new Class[]{Repository.class, Kernel.class} )); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GBEAN_INFO; } } 1.5 +22 -23 incubator-geronimo/modules/jetty/src/schema/geronimo-jetty.xsd Index: geronimo-jetty.xsd =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/schema/geronimo-jetty.xsd,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- geronimo-jetty.xsd 14 Feb 2004 18:49:43 -0000 1.4 +++ geronimo-jetty.xsd 20 Feb 2004 07:19:13 -0000 1.5 @@ -1,32 +1,31 @@ - - - + + - + - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + 1.6 +12 -9 incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml Index: geronimo-web.xml =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- geronimo-web.xml 14 Feb 2004 18:49:43 -0000 1.5 +++ geronimo-web.xml 20 Feb 2004 07:19:13 -0000 1.6 @@ -1,13 +1,16 @@ - + /test false - - - - - + 1.9 +2 -2 incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/DeploymentTest.java Index: DeploymentTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/DeploymentTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- DeploymentTest.java 14 Feb 2004 18:49:43 -0000 1.8 +++ DeploymentTest.java 20 Feb 2004 07:19:13 -0000 1.9 @@ -109,7 +109,7 @@ System.out.println("Errors: " + errors); throw new DeploymentException("Invalid deployment descriptor: errors: " + errors); } - assertEquals("/test", doc.getWebApp().getContextRoot().getStringValue()); + assertEquals("/test", doc.getWebApp().getContextRoot()); } //unpacked needs a little more work. 1.11 +7 -11 incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WARConfigurationFactoryTest.java Index: WARConfigurationFactoryTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WARConfigurationFactoryTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WARConfigurationFactoryTest.java 14 Feb 2004 01:50:15 -0000 1.10 +++ WARConfigurationFactoryTest.java 20 Feb 2004 07:19:13 -0000 1.11 @@ -57,13 +57,12 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; - import javax.enterprise.deploy.spi.DConfigBeanRoot; import org.apache.geronimo.deployment.tools.loader.WebDeployable; -import org.apache.geronimo.xbeans.geronimo.jetty.JettyContextRootType; import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument; import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType; + import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -105,7 +104,7 @@ JettyWebAppDocument webAppDoc = JettyWebAppDocument.Factory.parse(new ByteArrayInputStream(baos.toByteArray())); JettyWebAppType webApp = webAppDoc.getWebApp(); - assertEquals("/test", webApp.getContextRoot().getStringValue()); + assertEquals("/test", webApp.getContextRoot()); assertEquals(false, webApp.getContextPriorityClassloader()); } @@ -128,7 +127,7 @@ configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot()); contextBean = (WebAppDConfigBean) configRoot.getDConfigBean(deployable.getChildBean(configRoot.getXpaths()[0])[0]); - assertEquals("", contextBean.getContextRoot()); + assertNull(contextBean.getContextRoot()); config.restore(new ByteArrayInputStream(baos.toByteArray())); configRoot = config.getDConfigBeanRoot(deployable.getDDBeanRoot()); @@ -142,7 +141,7 @@ private void checkContents(JettyWebAppDocument webAppDoc) { JettyWebAppType webApp = webAppDoc.getWebApp(); - assertEquals("/test", webApp.getContextRoot().getStringValue()); + assertEquals("/test", webApp.getContextRoot()); assertEquals(true, webApp.getContextPriorityClassloader()); } @@ -150,13 +149,10 @@ JettyWebAppDocument webAppDoc = JettyWebAppDocument.Factory.newInstance(); JettyWebAppType webApp = webAppDoc.addNewWebApp(); webAppDoc.setWebApp(webApp); - JettyContextRootType contextRoot = webApp.addNewContextRoot(); - webApp.setContextRoot(contextRoot); - contextRoot.setStringValue("/test"); + webApp.setContextRoot("/test"); webApp.setContextPriorityClassloader(true); checkContents(webAppDoc); - assertEquals("/test", webApp.getContextRoot().getStringValue()); - assertEquals("/test", contextRoot.getStringValue()); + assertEquals("/test", webApp.getContextRoot()); assertEquals(true, webApp.getContextPriorityClassloader()); } 1.8 +7 -1 incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WebAppDConfigTest.java Index: WebAppDConfigTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/test/org/apache/geronimo/jetty/deployment/WebAppDConfigTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebAppDConfigTest.java 18 Feb 2004 20:58:43 -0000 1.7 +++ WebAppDConfigTest.java 20 Feb 2004 07:19:13 -0000 1.8 @@ -87,6 +87,7 @@ DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0]; WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean); assertNotNull(webApp); +/* String[] xpaths = webApp.getXpaths(); assertTrue(Arrays.equals( new String[]{ @@ -98,8 +99,10 @@ }, xpaths) ); +*/ } +/* public void testEJBRef() throws Exception { DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0]; WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean); @@ -116,7 +119,9 @@ assertEquals(ddBeans[1], ejbRef1.getDDBean()); assertTrue(ejbRef0 != ejbRef1); } +*/ +/* public void testEJBLocalRef() throws Exception { DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0]; WebAppDConfigBean webApp = (WebAppDConfigBean) configRoot.getDConfigBean(ddBean); @@ -133,6 +138,7 @@ assertEquals(ddBeans[1], ejbRef1.getDDBean()); assertTrue(ejbRef0 != ejbRef1); } +*/ protected void setUp() throws Exception { super.setUp();