gdamour 2004/08/04 05:05:34
Modified: modules/connector/src/java/org/apache/geronimo/connector/deployment ConnectorModuleBuilder.java modules/jetty/src/java/org/apache/geronimo/jetty/deployment JettyModuleBuilder.java Log: Supports deployment of unpacked or packed WAR and RAR modules within an unpacked EAR: in the application.xml of an unpacked EAR, it is possible to specify connector, war and ejb as either (standard) packed or unpacked modules. Moreover, a default vendor specific DD is created for a WAR module defined within an EAR. This is a partial commit (waiting for an OpenEJB commit to checkin the support of unpacked EAR). Revision Changes Path 1.11 +168 -131 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java Index: ConnectorModuleBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ConnectorModuleBuilder.java 23 Jul 2004 06:06:19 -0000 1.10 +++ ConnectorModuleBuilder.java 4 Aug 2004 12:05:34 -0000 1.11 @@ -17,7 +17,6 @@ package org.apache.geronimo.connector.deployment; import java.beans.PropertyEditor; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -173,150 +172,93 @@ } public void installModule(File earFolder, EARContext earContext, Module module) throws DeploymentException { - try { - File connectorFolder = new File(earFolder, module.getURI().toString()); - URI connectorFolderURI = connectorFolder.toURI(); - URI moduleBase; - if ( !module.getURI().equals(URI.create("/")) ) { - moduleBase = URI.create(module.getURI().toString() + "/"); - } else { - moduleBase = URI.create("connector/"); - } - - XmlObject specConnnector = null; - GerConnectorType vendorConnector = (GerConnectorType) module.getVendorDD(); - - Collection files = new ArrayList(); - FileUtil.listRecursiveFiles(connectorFolder, files); - for (Iterator iter = files.iterator(); iter.hasNext();) { - File file = (File) iter.next(); - URI fileURI = connectorFolderURI.relativize(file.toURI()); - URI target = moduleBase.resolve(fileURI); - if ( fileURI.toString().equals("META-INF/ra.xml") ) { - earContext.addFile(target, file); - try { - // try 1.0 - ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(new FileInputStream(file)); - SchemaConversionUtils.validateDD(connectorDoc); - specConnnector = connectorDoc.getConnector(); - } catch (XmlException ignore) { - // that didn't work try 1.5 - try { - ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(new FileInputStream(file)); - SchemaConversionUtils.validateDD(connectorDoc); - specConnnector = connectorDoc.getConnector(); - } catch (XmlException alsoIgnore) { - throw new DeploymentException("Could not parse META-INF/ra.xml"); - } - } - } else if (module.getVendorDD() == null && fileURI.toString().equals("META-INF/geronimo-ra.xml") ) { - earContext.addFile(target, file); - GerConnectorDocument vendorConnectorDoc; - try { - vendorConnectorDoc = GerConnectorDocument.Factory.parse(new FileInputStream(file)); - SchemaConversionUtils.validateDD(vendorConnectorDoc); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse geronimo-ra.xml"); - } - vendorConnector = vendorConnectorDoc.getConnector(); - } else if (file.getName().endsWith(".jar")) { - earContext.addInclude(target, file.toURL()); - } else { - earContext.addFile(target, file); - } - } - - if (specConnnector == null) { - throw new DeploymentException("Did not find META-INF/ra.xml in module"); - } - module.setSpecDD(specConnnector); - if (vendorConnector == null) { - throw new DeploymentException("Did not find META-INF/geronimo-ra.xml in module"); - } - module.setVendorDD(vendorConnector); - - if (vendorConnector != null) { - GerDependencyType[] dependencies = vendorConnector.getDependencyArray(); - for (int i = 0; i < dependencies.length; i++) { - earContext.addDependency(getDependencyURI(dependencies[i])); - } + File rarFolder = new File(earFolder, module.getURI().toString()); + + // Unpacked EAR modules can define via application.xml either + // (standard) packed or unpacked modules + InstallCallback callback; + if ( rarFolder.isDirectory() ) { + callback = new UnPackedInstallCallback(module, rarFolder); + } else { + JarFile rarFile; + try { + rarFile = new JarFile(rarFolder); + } catch (IOException e) { + throw new DeploymentException("Can not create RAR file " + rarFolder, e); } - } catch (IOException e) { - throw new DeploymentException("Problem deploying connector", e); + callback = new PackedInstallCallback(module, rarFile); } + installModule(callback, earContext, module); } - + public void installModule(JarFile earFile, EARContext earContext, Module module) throws DeploymentException { + JarFile rarFile; try { - URI moduleBase = null; - JarInputStream jarIS = null; if (!module.getURI().equals(URI.create("/"))) { - ZipEntry connectorEntry = earFile.getEntry(module.getURI().toString()); - jarIS = new JarInputStream(earFile.getInputStream(connectorEntry)); - moduleBase = URI.create(module.getURI() + "/"); + ZipEntry rarEntry = earFile.getEntry(module.getURI().toString()); + // Unpack the nested RAR. + File tempFile = FileUtil.toTempFile(earFile.getInputStream(rarEntry)); + rarFile = new JarFile(tempFile); } else { - jarIS = new JarInputStream(new FileInputStream(earFile.getName())); - moduleBase = URI.create("connector/"); + rarFile = earFile; + } + } catch (IOException e) { + throw new DeploymentException("Problem deploying rar", e); + } + InstallCallback callback = new PackedInstallCallback(module, rarFile); + installModule(callback, earContext, module); + } + + public void installModule(InstallCallback callback, EARContext earContext, Module module) throws DeploymentException { + URI moduleBase = null; + if (!module.getURI().equals(URI.create("/"))) { + moduleBase = URI.create(module.getURI() + "/"); + } else { + moduleBase = URI.create("connector/"); + } + + try { + XmlObject specConnnector; + try { + // try 1.0 + ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(callback.getRaDD()); + SchemaConversionUtils.validateDD(connectorDoc); + specConnnector = connectorDoc.getConnector(); + } catch (XmlException ignore) { + // that didn't work try 1.5 + try { + ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(callback.getRaDD()); + SchemaConversionUtils.validateDD(connectorDoc); + specConnnector = connectorDoc.getConnector(); + } catch (XmlException alsoIgnore) { + throw new DeploymentException( + "Could not parse META-INF/ra.xml"); + } } + module.setSpecDD(specConnnector); - XmlObject specConnnector = null; GerConnectorType vendorConnector = (GerConnectorType) module.getVendorDD(); - for (JarEntry entry; (entry = jarIS.getNextJarEntry()) != null; jarIS.closeEntry()) { - String name = entry.getName(); - URI target = moduleBase.resolve(name); - if (name.endsWith("/")) { - continue; - } else if (name.equals("META-INF/ra.xml")) { - byte[] buffer = getBytes(jarIS); - earContext.addFile(target, new ByteArrayInputStream(buffer)); - - try { - // try 1.0 - ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(new ByteArrayInputStream(buffer)); - SchemaConversionUtils.validateDD(connectorDoc); - specConnnector = connectorDoc.getConnector(); - } catch (XmlException ignore) { - // that didn't work try 1.5 - try { - ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(new ByteArrayInputStream(buffer)); - SchemaConversionUtils.validateDD(connectorDoc); - specConnnector = connectorDoc.getConnector(); - } catch (XmlException alsoIgnore) { - throw new DeploymentException("Could not parse META-INF/ra.xml"); - } - } - } else if (module.getVendorDD() == null && name.equals("META-INF/geronimo-ra.xml")) { - byte[] buffer = getBytes(jarIS); - earContext.addFile(target, new ByteArrayInputStream(buffer)); - GerConnectorDocument vendorConnectorDoc; - try { - vendorConnectorDoc = GerConnectorDocument.Factory.parse(new ByteArrayInputStream(buffer)); - SchemaConversionUtils.validateDD(vendorConnectorDoc); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse geronimo-ra.xml"); + if ( null == vendorConnector ) { + try { + InputStream gerDDInputStream = callback.getGeronimoRaDD(); + GerConnectorDocument doc; + if (gerDDInputStream != null) { + doc = (GerConnectorDocument) XmlBeansUtil.parse(gerDDInputStream, GerConnectorDocument.type); + } else { + throw new DeploymentException("No geronimo-ra.xml."); } - vendorConnector = vendorConnectorDoc.getConnector(); - } else if (name.endsWith(".jar")) { - earContext.addStreamInclude(target, jarIS); - } else { - earContext.addFile(target, jarIS); + vendorConnector = doc.getConnector(); + module.setVendorDD(vendorConnector); + } catch (XmlException e) { + throw new DeploymentException("Unable to parse geronimo-ra.xml"); } } - if (specConnnector == null) { - throw new DeploymentException("Did not find META-INF/ra.xml in module"); - } - module.setSpecDD(specConnnector); - if (vendorConnector == null) { - throw new DeploymentException("Did not find META-INF/geronimo-ra.xml in module"); - } - module.setVendorDD(vendorConnector); + callback.installInEARContext(earContext, moduleBase); - if (vendorConnector != null) { - GerDependencyType[] dependencies = vendorConnector.getDependencyArray(); - for (int i = 0; i < dependencies.length; i++) { - earContext.addDependency(getDependencyURI(dependencies[i])); - } + GerDependencyType[] dependencies = vendorConnector.getDependencyArray(); + for (int i = 0; i < dependencies.length; i++) { + earContext.addDependency(getDependencyURI(dependencies[i])); } } catch (IOException e) { throw new DeploymentException("Problem deploying connector", e); @@ -880,6 +822,101 @@ } } + private interface InstallCallback { + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException; + + public InputStream getRaDD() throws DeploymentException, IOException; + + public InputStream getGeronimoRaDD() throws DeploymentException, IOException; + + } + + private static final class UnPackedInstallCallback implements InstallCallback { + + private final File rarFolder; + + private final Module rarModule; + + private UnPackedInstallCallback(Module rarModule, File rarFolder) { + this.rarFolder = rarFolder; + this.rarModule = rarModule; + } + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException { + URI raRoot = rarFolder.toURI(); + Collection files = new ArrayList(); + FileUtil.listRecursiveFiles(rarFolder, files); + for (Iterator iter = files.iterator(); iter.hasNext();) { + File file = (File) iter.next(); + URI fileURI = raRoot.relativize(file.toURI()); + URI target = moduleBase.resolve(fileURI); + if (file.getName().endsWith(".jar")) { + earContext.addInclude(target, file.toURL()); + } else { + earContext.addFile(target, file); + } + } + } + + public InputStream getRaDD() throws DeploymentException, IOException { + File raFile = new File(rarFolder, "META-INF/ra.xml"); + if ( !raFile.exists() ) { + throw new DeploymentException("No in module [" + rarModule.getName() + "]"); + } + return new FileInputStream(raFile); + } + + public InputStream getGeronimoRaDD() throws DeploymentException, IOException { + File geronimoRaFile = new File(rarFolder, "META-INF/geronimo-ra.xml"); + if ( geronimoRaFile.exists() ) { + return new FileInputStream(geronimoRaFile); + } + return null; + } + + } + + private static final class PackedInstallCallback implements InstallCallback { + + private final Module rarModule; + + private final JarFile rarFile; + + private PackedInstallCallback(Module rarModule, JarFile rarFile) { + this.rarModule = rarModule; + this.rarFile = rarFile; + } + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException { + JarInputStream jarIS = new JarInputStream(new FileInputStream(rarFile.getName())); + for (JarEntry entry; (entry = jarIS.getNextJarEntry()) != null; jarIS.closeEntry()) { + URI target = moduleBase.resolve(entry.getName()); + if (entry.getName().endsWith(".jar")) { + earContext.addStreamInclude(target, jarIS); + } else { + earContext.addFile(target, jarIS); + } + } + } + + public InputStream getRaDD() throws DeploymentException, IOException { + JarEntry entry = rarFile.getJarEntry("META-INF/ra.xml"); + if (entry == null) { + throw new DeploymentException("No META-INF/ra.xml in module [" + rarModule.getName() + "]"); + } + return rarFile.getInputStream(entry); + } + + public InputStream getGeronimoRaDD() throws DeploymentException, IOException { + JarEntry entry = rarFile.getJarEntry("META-INF/geronimo-ra.xml"); + if (entry != null) { + return rarFile.getInputStream(entry); + } + return null; + } + } + public static final GBeanInfo GBEAN_INFO; static { 1.19 +167 -107 incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Index: JettyModuleBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- JettyModuleBuilder.java 1 Aug 2004 20:14:20 -0000 1.18 +++ JettyModuleBuilder.java 4 Aug 2004 12:05:34 -0000 1.19 @@ -17,7 +17,6 @@ package org.apache.geronimo.jetty.deployment; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -35,6 +34,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarInputStream; import java.util.zip.ZipEntry; @@ -143,13 +143,8 @@ return null; } - // construct the empty geronimo-jetty.xml - JettyWebAppDocument jettyWebAppDocument = JettyWebAppDocument.Factory.newInstance(); - JettyWebAppType jettyWebApp = jettyWebAppDocument.addNewWebApp(); - - // set the parentId, configId and context root - jettyWebApp.setParentId(PARENT_ID); - String id = webAppDoc.getWebApp().getId(); + WebAppType webApp = webAppDoc.getWebApp(); + String id = webApp.getId(); if (id == null) { id = moduleBase.getFile(); if (id.endsWith("!/")) { @@ -158,9 +153,24 @@ if (id.endsWith(".war")) { id = id.substring(0, id.length() - 4); } + if ( id.endsWith("/") ) { + id = id.substring(0, id.length() - 1); + } id = id.substring(id.lastIndexOf('/') + 1); } + return newJettyWebAppDocument(webApp, id); + } + + private JettyWebAppDocument newJettyWebAppDocument(WebAppType webApp, String id) { + // construct the empty geronimo-jetty.xml + JettyWebAppDocument jettyWebAppDocument = JettyWebAppDocument.Factory.newInstance(); + JettyWebAppType jettyWebApp = jettyWebAppDocument.addNewWebApp(); + // set the parentId, configId and context root + jettyWebApp.setParentId(PARENT_ID); + if ( null != webApp.getId() ) { + id = webApp.getId(); + } jettyWebApp.setConfigId(id); jettyWebApp.setContextRoot(id); return jettyWebAppDocument; @@ -195,120 +205,82 @@ return module; } - public void installModule(File earFolder, EARContext earContext, - Module webModule) throws DeploymentException { + public void installModule(File earFolder, EARContext earContext, Module webModule) throws DeploymentException { + File webFolder = new File(earFolder, webModule.getURI().toString()); + + // Unpacked EAR modules can define via application.xml either + // (standard) packed or unpacked modules + InstallCallback callback; + if ( webFolder.isDirectory() ) { + callback = new UnPackedInstallCallback(webModule, webFolder); + } else { + JarFile warFile; + try { + warFile = new JarFile(webFolder); + } catch (IOException e) { + throw new DeploymentException("Can not create WAR file " + webFolder, e); + } + callback = new PackedInstallCallback(webModule, warFile); + } + installModule(callback, earContext, webModule); + } + + public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws DeploymentException { + JarFile webAppFile; try { - File webFolder = new File(earFolder, webModule.getURI().toString()); - URI warRoot = webFolder.toURI(); - URI moduleBase; if (!webModule.getURI().equals(URI.create("/"))) { - moduleBase = URI.create(webModule.getURI().toString() + "/"); + ZipEntry warEntry = earFile.getEntry(webModule.getURI().toString()); + // Unpack the nested JAR. + File tempFile = FileUtil.toTempFile(earFile.getInputStream(warEntry)); + webAppFile = new JarFile(tempFile); } else { - moduleBase = URI.create("war/"); - } - - WebAppType webApp = null; - JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD(); - - // add the warfile's content to the configuration - Collection files = new ArrayList(); - FileUtil.listRecursiveFiles(webFolder, files); - for (Iterator iter = files.iterator(); iter.hasNext();) { - File file = (File) iter.next(); - URI fileURI = warRoot.relativize(file.toURI()); - URI target = moduleBase.resolve(fileURI); - if (fileURI.toString().equals("WEB-INF/web.xml")) { - earContext.addFile(target, file); - try { - InputStream ddInputStream = new FileInputStream(file); - webApp = getWebAppDocument(ddInputStream).getWebApp(); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse web.xml", e); - } - } else if (jettyWebApp == null && fileURI.toString().equals("WEB-INF/geronimo-jetty.xml")) { - earContext.addFile(target, file); - try { - JettyWebAppDocument doc = (JettyWebAppDocument) XmlBeansUtil.parse(new FileInputStream(file), JettyWebAppDocument.type); - jettyWebApp = doc.getWebApp(); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse geronimo-jetty.xml", e); - } - } else { - earContext.addFile(target, file); - } - } - - if (webApp == null) { - throw new DeploymentException("Did not find WEB-INF/web.xml in module"); - } - webModule.setSpecDD(webApp); - - if (jettyWebApp == null) { - throw new DeploymentException("No plan or WEB-INF/jetty-web.xml found"); - } - webModule.setVendorDD(jettyWebApp); - - // add the dependencies declared in the geronimo-jetty.xml file - JettyDependencyType[] dependencies = jettyWebApp.getDependencyArray(); - for (int i = 0; i < dependencies.length; i++) { - earContext.addDependency(getDependencyURI(dependencies[i])); + webAppFile = earFile; } } catch (IOException e) { throw new DeploymentException("Problem deploying war", e); } + InstallCallback callback = new PackedInstallCallback(webModule, webAppFile); + installModule(callback, earContext, webModule); } - public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws DeploymentException { + private void installModule(InstallCallback callback, EARContext earContext, Module webModule) throws DeploymentException { + URI moduleBase; + if (!webModule.getURI().equals(URI.create("/"))) { + moduleBase = URI.create(webModule.getURI() + "/"); + } else { + moduleBase = URI.create("war/"); + } try { - URI warRoot = null; - JarInputStream jarIS = null; - if (!webModule.getURI().equals(URI.create("/"))) { - ZipEntry warEntry = earFile.getEntry(webModule.getURI().toString()); - jarIS = new JarInputStream(earFile.getInputStream(warEntry)); - warRoot = URI.create(webModule.getURI() + "/"); - } else { - jarIS = new JarInputStream(new FileInputStream(earFile.getName())); - warRoot = URI.create("war/"); + // load the web.xml file + WebAppType webApp; + try { + InputStream ddInputStream = callback.getWebDD(); + webApp = getWebAppDocument(ddInputStream).getWebApp(); + webModule.setSpecDD(webApp); + } catch (XmlException e) { + throw new DeploymentException("Unable to parse web.xml", e); } - // add the warfile's content to the configuration - ZipEntry src; - WebAppType webApp = null; + // load the geronimo-jetty.xml file JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD(); - while ((src = jarIS.getNextEntry()) != null) { - URI target = warRoot.resolve(src.getName()); - if ("WEB-INF/web.xml".equals(src.getName())) { - byte[] buffer = getBytes(jarIS); - earContext.addFile(target, new ByteArrayInputStream(buffer)); - try { - InputStream ddInputStream = new ByteArrayInputStream(buffer); - webApp = getWebAppDocument(ddInputStream).getWebApp(); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse web.xml", e); - } - } else if (jettyWebApp == null && "WEB-INF/geronimo-jetty.xml".equals(src.getName())) { - byte[] buffer = getBytes(jarIS); - earContext.addFile(target, new ByteArrayInputStream(buffer)); - try { - JettyWebAppDocument doc = (JettyWebAppDocument) XmlBeansUtil.parse(new ByteArrayInputStream(buffer), JettyWebAppDocument.type); - jettyWebApp = doc.getWebApp(); - } catch (XmlException e) { - throw new DeploymentException("Unable to parse geronimo-jetty.xml", e); + if (jettyWebApp == null) { + try { + InputStream jettyDDInputStream = callback.getGeronimoJettyDD(); + JettyWebAppDocument doc; + if (jettyDDInputStream != null) { + doc = (JettyWebAppDocument) XmlBeansUtil.parse(jettyDDInputStream, JettyWebAppDocument.type); + } else { + doc = newJettyWebAppDocument(webApp, moduleBase.toString()); } - } else { - earContext.addFile(target, jarIS); + jettyWebApp = doc.getWebApp(); + webModule.setVendorDD(jettyWebApp); + } catch (XmlException e) { + throw new DeploymentException("Unable to parse openejb-jar.xml"); } } - - if (webApp == null) { - throw new DeploymentException("Did not find WEB-INF/web.xml in module"); - } - webModule.setSpecDD(webApp); - - if (jettyWebApp == null) { - throw new DeploymentException("No plan or WEB-INF/jetty-web.xml found"); - } - webModule.setVendorDD(jettyWebApp); + + // add the warfile's content to the configuration + callback.installInEARContext(earContext, moduleBase); // add the dependencies declared in the geronimo-jetty.xml file JettyDependencyType[] dependencies = jettyWebApp.getDependencyArray(); @@ -663,6 +635,94 @@ baos.write(buffer, 0, count); } return baos.toByteArray(); + } + + private interface InstallCallback { + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException; + + public InputStream getWebDD() throws DeploymentException, IOException; + + public InputStream getGeronimoJettyDD() throws DeploymentException, IOException; + + } + + private static final class UnPackedInstallCallback implements InstallCallback { + + private final File webFolder; + + private final Module webModule; + + private UnPackedInstallCallback(Module webModule, File webFolder) { + this.webFolder = webFolder; + this.webModule = webModule; + } + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException { + URI warRoot = webFolder.toURI(); + // add the warfile's content to the configuration + Collection files = new ArrayList(); + FileUtil.listRecursiveFiles(webFolder, files); + for (Iterator iter = files.iterator(); iter.hasNext();) { + File file = (File) iter.next(); + URI fileURI = warRoot.relativize(file.toURI()); + URI target = moduleBase.resolve(fileURI); + earContext.addFile(target, file); + } + } + + public InputStream getWebDD() throws DeploymentException, IOException { + File webAppFile = new File(webFolder, "WEB-INF/web.xml"); + if ( !webAppFile.exists() ) { + throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]"); + } + return new FileInputStream(webAppFile); + } + + public InputStream getGeronimoJettyDD() throws DeploymentException, IOException { + File jettyWebAppFile = new File(webFolder, "WEB-INF/geronimo-jetty.xml"); + if ( jettyWebAppFile.exists() ) { + return new FileInputStream(jettyWebAppFile); + } + return null; + } + + } + + private static final class PackedInstallCallback implements InstallCallback { + + private final Module webModule; + + private final JarFile webAppFile; + + private PackedInstallCallback(Module webModule, JarFile webAppFile) { + this.webModule = webModule; + this.webAppFile = webAppFile; + } + + public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException { + JarInputStream jarIS = new JarInputStream(new FileInputStream(webAppFile.getName())); + for (JarEntry entry; (entry = jarIS.getNextJarEntry()) != null; jarIS.closeEntry()) { + URI target = moduleBase.resolve(entry.getName()); + earContext.addFile(target, jarIS); + } + } + + public InputStream getWebDD() throws DeploymentException, IOException { + JarEntry entry = webAppFile.getJarEntry("WEB-INF/web.xml"); + if (entry == null) { + throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]"); + } + return webAppFile.getInputStream(entry); + } + + public InputStream getGeronimoJettyDD() throws DeploymentException, IOException { + JarEntry entry = webAppFile.getJarEntry("WEB-INF/geronimo-jetty.xml"); + if (entry != null) { + return webAppFile.getInputStream(entry); + } + return null; + } } public static final GBeanInfo GBEAN_INFO;