@Test public void testOutputDescriptor() throws Exception { final OutputGeneratedDescriptors dynamicDeployer = new OutputGeneratedDescriptors(); final EjbJar ejbJar = new EjbJar(); final StatelessBean redBean = new StatelessBean(); redBean.setEjbClass("com.foo.Red"); redBean.setEjbName("Red"); redBean.setRemote("com.foo.Color"); final ManagedBean orangeBean = new ManagedBean("Orange", "com.foo.Orange"); final StatefulBean yellowBean = new StatefulBean(); yellowBean.setEjbClass("com.foo.Yellow"); yellowBean.setEjbName("Yellow"); yellowBean.setRemote("com.foo.Color"); final SingletonBean greenBean = new SingletonBean(); greenBean.setEjbClass("com.foo.Green"); greenBean.setEjbName("Green"); greenBean.setRemote("com.foo.Color"); ejbJar.addEnterpriseBean(redBean); ejbJar.addEnterpriseBean(orangeBean); ejbJar.addEnterpriseBean(yellowBean); ejbJar.addEnterpriseBean(greenBean); final OpenejbJar openejbJar = new OpenejbJar(); final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar); final AppModule appModule = new AppModule(ejbModule); File tempFolder = File.createTempFile("tmp", "ogd"); tempFolder.delete(); Assert.assertTrue("unable to create temp folder", tempFolder.mkdirs()); try { Properties properties = ejbModule.getOpenejbJar().getProperties(); properties.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "true"); properties.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS_FOLDER, tempFolder.getAbsolutePath()); SystemInstance.get().setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS_FOLDER, tempFolder.getAbsolutePath()); dynamicDeployer.deploy(appModule); boolean seenEjbJarXml = false; boolean seenOpenejbJarXml = false; File[] listFiles = tempFolder.listFiles(); for (File file : listFiles) { if (file.getName().startsWith("ejb-jar-")) { seenEjbJarXml = true; assertEjbFileCorrect(file); } if (file.getName().startsWith("openejb-jar-")) { seenOpenejbJarXml = true; } } Assert.assertTrue("No ejb-jar.xml file produced", seenEjbJarXml); Assert.assertTrue("No openejb-jar.xml file produced", seenOpenejbJarXml); } finally { Files.delete(tempFolder); } }
public AppModule deploy(final AppModule appModule) throws OpenEJBException { boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false); if (output && appModule.getCmpMappings() != null) { writeGenratedCmpMappings(appModule); } for (final EjbModule ejbModule : appModule.getEjbModules()) { final Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions()); final ValidationContext context = ejbModule.getValidation(); final boolean invalid = context.hasErrors() || context.hasFailures(); output = options.get(OUTPUT_DESCRIPTORS, invalid); if (output) { if (ejbModule.getEjbJar() != null) { writeEjbJar(ejbModule); } if (ejbModule.getOpenejbJar() != null) { writeOpenejbJar(ejbModule); } writeGeronimoOpenejb(ejbModule); } } for (final ConnectorModule connectorModule : appModule.getConnectorModules()) { writeRaXml(connectorModule); } return appModule; }
OutputGeneratedDescriptors implements DynamicDeployer { public AppModule deploy(final AppModule appModule) throws OpenEJBException { boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false); if (output && appModule.getCmpMappings() != null) { writeGenratedCmpMappings(appModule); } for (final EjbModule ejbModule : appModule.getEjbModules()) { final Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions()); final ValidationContext context = ejbModule.getValidation(); final boolean invalid = context.hasErrors() || context.hasFailures(); output = options.get(OUTPUT_DESCRIPTORS, invalid); if (output) { if (ejbModule.getEjbJar() != null) { writeEjbJar(ejbModule); } if (ejbModule.getOpenejbJar() != null) { writeOpenejbJar(ejbModule); } writeGeronimoOpenejb(ejbModule); } } for (final ConnectorModule connectorModule : appModule.getConnectorModules()) { writeRaXml(connectorModule); } return appModule; } }
OutputGeneratedDescriptors implements DynamicDeployer { public AppModule deploy(final AppModule appModule) throws OpenEJBException { boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false); if (output && appModule.getCmpMappings() != null) { writeGenratedCmpMappings(appModule); } for (final EjbModule ejbModule : appModule.getEjbModules()) { final Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions()); final ValidationContext context = ejbModule.getValidation(); final boolean invalid = context.hasErrors() || context.hasFailures(); output = options.get(OUTPUT_DESCRIPTORS, invalid); if (output) { if (ejbModule.getEjbJar() != null) { writeEjbJar(ejbModule); } if (ejbModule.getOpenejbJar() != null) { writeOpenejbJar(ejbModule); } writeGeronimoOpenejb(ejbModule); } } for (final ConnectorModule connectorModule : appModule.getConnectorModules()) { writeRaXml(connectorModule); } return appModule; }  }
OutputGeneratedDescriptors implements DynamicDeployer { public AppModule deploy(final AppModule appModule) throws OpenEJBException { boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false); if (output && appModule.getCmpMappings() != null) { writeGenratedCmpMappings(appModule); } for (final EjbModule ejbModule : appModule.getEjbModules()) { final Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions()); final ValidationContext context = ejbModule.getValidation(); final boolean invalid = context.hasErrors() || context.hasFailures(); output = options.get(OUTPUT_DESCRIPTORS, invalid); if (output) { if (ejbModule.getEjbJar() != null) { writeEjbJar(ejbModule); } if (ejbModule.getOpenejbJar() != null) { writeOpenejbJar(ejbModule); } writeGeronimoOpenejb(ejbModule); } } for (final ConnectorModule connectorModule : appModule.getConnectorModules()) { writeRaXml(connectorModule); } return appModule; }  AppModule deploy(final AppModule appModule); }
OutputGeneratedDescriptors implements DynamicDeployer { public AppModule deploy(final AppModule appModule) throws OpenEJBException { boolean output = SystemInstance.get().getOptions().get(OUTPUT_DESCRIPTORS, false); if (output && appModule.getCmpMappings() != null) { writeGenratedCmpMappings(appModule); } for (final EjbModule ejbModule : appModule.getEjbModules()) { final Options options = new Options(ejbModule.getOpenejbJar().getProperties(), SystemInstance.get().getOptions()); final ValidationContext context = ejbModule.getValidation(); final boolean invalid = context.hasErrors() || context.hasFailures(); output = options.get(OUTPUT_DESCRIPTORS, invalid); if (output) { if (ejbModule.getEjbJar() != null) { writeEjbJar(ejbModule); } if (ejbModule.getOpenejbJar() != null) { writeOpenejbJar(ejbModule); } writeGeronimoOpenejb(ejbModule); } } for (final ConnectorModule connectorModule : appModule.getConnectorModules()) { writeRaXml(connectorModule); } return appModule; }  AppModule deploy(final AppModule appModule); static final String OUTPUT_DESCRIPTORS; static final String OUTPUT_DESCRIPTORS_FOLDER; }