/** * This method sets a new application.xml for the provided enterprise * archive. * * @param enterpriseArchive * is the {@link EnterpriseArchive} to be edited. * @param applicationXML * is the content of the application.xml as {@link String}. * @throws IOException * is thrown if the new application.xml was not set. */ public static void setApplicationXml(EnterpriseArchive enterpriseArchive, String applicationXML) throws IOException { File tempApplicationXmlFile = File.createTempFile( APPLICATION_XML_FILE_NAME, ".temp"); tempApplicationXmlFile.deleteOnExit(); IOUtils.write(applicationXML, new FileOutputStream( tempApplicationXmlFile)); // delete old application.xml enterpriseArchive.delete(APPLICATION_XML_PATH); // set the new application.xml enterpriseArchive.setApplicationXML(tempApplicationXmlFile); }
/** * This method sets a new JBoss deployment structure for an enterprise * archive. * * @param enterpriseArchive * is the {@link EnterpriseArchive} to be edited. * @param jbossDeploymentStructure * is the content of the new deployment structure. * @throws IOException * No application.xml found */ public static void setJBossDeploymentStructureXml( EnterpriseArchive enterpriseArchive, String jbossDeploymentStructure) throws IOException { File tempFile = File.createTempFile( JBOSS_DEPLOYMENT_STRUCTURE_XML_FILE_NAME, ".temp"); tempFile.deleteOnExit(); IOUtils.write(jbossDeploymentStructure, new FileOutputStream(tempFile)); // delete the old descriptor enterpriseArchive.delete(JBOSS_DEPLOYMENT_STRUCTURE_XML_PATH); // set the new descriptor enterpriseArchive.addAsManifestResource(tempFile, JBOSS_DEPLOYMENT_STRUCTURE_XML_FILE_NAME); }
/** * This modules removes a module from an enterprise archive. * * @param enterpriseArchive * is the {@link EnterpriseArchive} to be searched for a module * to be removed. * @param moduleName * is the name of the module to be removed. * @throws Exception * is thrown if the modules could not be removed. */ public static void removeModule(EnterpriseArchive enterpriseArchive, String moduleName) throws Exception { enterpriseArchive.delete("/" + moduleName); removeModuleFromApplicationXml(enterpriseArchive, moduleName); removeModuleFromJBossDeploymentStructureXml(enterpriseArchive, moduleName); }
Node deplStructNode = ear.get(DEPLOYMENT_STRUCTURE_FILE); if (deplStructNode != null) { ear.delete(deplStructNode.getPath()); ear.addAsApplicationResource(testDeploymentDesc);
applicationArchive.delete(APPLICATION_XML_PATH); applicationArchive.setApplicationXML( new StringAsset(applicationXml.exportAsString()));
applicationArchive.delete(APPLICATION_XML_PATH); applicationArchive.setApplicationXML( new StringAsset(applicationXml.exportAsString()));