private EntityMappings getUserEntityMappings(final EjbModule ejbModule) { final Object o = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (o instanceof EntityMappings) { return (EntityMappings) o; } return new EntityMappings(); }
private EntityMappings getUserEntityMappings(final EjbModule ejbModule) { final Object o = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (o instanceof EntityMappings) { return (EntityMappings) o; } return new EntityMappings(); }
private EntityMappings getUserEntityMappings(EjbModule ejbModule) { Object o = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (o instanceof EntityMappings) { return (EntityMappings) o; } return new EntityMappings(); }
private static void addOpenEJbJarXml(final Archive<?> archive, final String prefix, final EjbModule ejbModule) { final Node openejbJarXml = archive.get(prefix.concat(OPENEJB_JAR_XML)); if (openejbJarXml != null) { ejbModule.getAltDDs().put(OPENEJB_JAR_XML, new AssetSource(openejbJarXml.getAsset(), null)); } }
private void writeGeronimoOpenejb(EjbModule ejbModule) { try { GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml"); if (geronimoEjbJarType == null) return; File tempFile = File.createTempFile("geronimo-openejb-", ejbModule.getModuleId() + ".xml"); FileOutputStream fout = new FileOutputStream(tempFile); BufferedOutputStream out = new BufferedOutputStream(fout); try { JaxbOpenejbJar2.marshal(GeronimoEjbJarType.class, geronimoEjbJarType, out); logger.info("Dumping Generated geronimo-openejb.xml to: " + tempFile.getAbsolutePath()); } catch (JAXBException e) { } finally { out.close(); } } catch (Exception e) { } }
private static void addResourcesXml(final Archive<?> archive, final String prefix, final EjbModule ejbModule) { final Node resourcesXml = archive.get(prefix.concat(RESOURCES_XML)); if (resourcesXml != null) { ejbModule.getAltDDs().put(RESOURCES_XML, new AssetSource(resourcesXml.getAsset(), null)); } }
private static void addEnvEntries(final Archive<?> archive, final String prefix, final AppModule appModule, final EjbModule ejbModule) { final Node envEntriesProperties = archive.get(prefix.concat(ENV_ENTRIES_PROPERTIES)); if (envEntriesProperties != null) { InputStream is = null; final Properties properties = new Properties(); try { is = envEntriesProperties.getAsset().openStream(); properties.load(is); ejbModule.getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); // do it for test class too appModule.getEjbModules().iterator().next().getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); } catch (final Exception e) { LOGGER.log(Level.SEVERE, "can't read env-entries.properties", e); } finally { IO.close(is); } } }
private void readCmpOrm(EjbModule ejbModule) throws OpenEJBException { Object data = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (data == null || data instanceof EntityMappings) { return; } else if (data instanceof URL) { URL url = (URL) data; try { EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshal(EntityMappings.class, url.openStream()); ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entitymappings); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } } }
private SunCmpMappings getSunCmpMappings(final EjbModule ejbModule) { Object altDD = ejbModule.getAltDDs().get("sun-cmp-mappings.xml"); if (altDD instanceof String) { try { altDD = JaxbSun.unmarshal(SunCmpMappings.class, new ByteArrayInputStream(((String) altDD).getBytes())); } catch (final Exception e) { // todo warn about not being able to parse sun descriptor } } if (altDD instanceof URL) { try { altDD = JaxbSun.unmarshal(SunCmpMappings.class, IO.read((URL) altDD)); } catch (final Exception e) { e.printStackTrace(); // todo warn about not being able to parse sun descriptor } } if (altDD instanceof SunCmpMappings) { return (SunCmpMappings) altDD; } return null; }
private static void addValidationXml(final Archive<?> archive, final String prefix, final Map<String, Object> testDD, final EjbModule ejbModule) { Node validationXml = archive.get(prefix.concat(VALIDATION_XML)); // bval tcks if (validationXml == null && WEB_INF == prefix) { // we can use == here validationXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(VALIDATION_XML)); } if (validationXml != null) { testDD.put(VALIDATION_XML, new AssetSource(validationXml.getAsset(), null)); // use same config otherwise behavior is weird ejbModule.getAltDDs().put(VALIDATION_XML, new AssetSource(validationXml.getAsset(), null)); } }
private void readCmpOrm(final EjbModule ejbModule) throws OpenEJBException { final Object data = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (data != null && !(data instanceof EntityMappings)) { if (data instanceof URL) { final URL url = (URL) data; try { final EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshalJavaee(EntityMappings.class, IO.read(url)); ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entitymappings); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final JAXBException e) { throw new OpenEJBException("Cannot unmarshall the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered unknown error parsing the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } } } }
private void readCmpOrm(final EjbModule ejbModule) throws OpenEJBException { final Object data = ejbModule.getAltDDs().get("openejb-cmp-orm.xml"); if (data == null || data instanceof EntityMappings) { return; } else if (data instanceof URL) { final URL url = (URL) data; try { final EntityMappings entitymappings = (EntityMappings) JaxbJavaee.unmarshalJavaee(EntityMappings.class, IO.read(url)); ejbModule.getAltDDs().put("openejb-cmp-orm.xml", entitymappings); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final JAXBException e) { throw new OpenEJBException("Cannot unmarshall the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered unknown error parsing the openejb-cmp-orm.xml file: " + url.toExternalForm(), e); } } }
protected static EjbModule createEjbModule(URL baseUrl, String jarPath, ClassLoader classLoader, String moduleId) throws OpenEJBException { // read the ejb-jar.xml file Map<String, URL> descriptors = getDescriptors(baseUrl); EjbJar ejbJar = null; URL ejbJarXmlUrl = descriptors.get("ejb-jar.xml"); if (ejbJarXmlUrl != null){ ejbJar = ReadDescriptors.readEjbJar(ejbJarXmlUrl); } // create the EJB Module EjbModule ejbModule = new EjbModule(classLoader, moduleId, jarPath, ejbJar, null); ejbModule.getAltDDs().putAll(descriptors); ejbModule.getWatchedResources().add(jarPath); if (ejbJarXmlUrl != null && "file".equals(ejbJarXmlUrl.getProtocol())) { ejbModule.getWatchedResources().add(URLs.toFilePath(ejbJarXmlUrl)); } ejbModule.setClientModule(createClientModule(baseUrl, jarPath, classLoader, null, false)); // load webservices descriptor addWebservices(ejbModule); return ejbModule; }
private void writeGeronimoOpenejb(final EjbModule ejbModule) { try { final GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml"); if (geronimoEjbJarType == null) { return; } final File tempFile = tempFile("geronimo-openejb-", ejbModule.getModuleId() + ".xml"); final OutputStream out = IO.write(tempFile); try { JaxbOpenejbJar2.marshal(GeronimoEjbJarType.class, geronimoEjbJarType, out); logger.info("Dumping Generated geronimo-openejb.xml to: " + tempFile.getAbsolutePath()); } catch (final JAXBException e) { // no-op } finally { IO.close(out); } } catch (final Exception e) { // no-op } }
private void writeGeronimoOpenejb(final EjbModule ejbModule) { try { final GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml"); if (geronimoEjbJarType == null) { return; } final File tempFile = tempFile("geronimo-openejb-", ejbModule.getModuleId() + ".xml"); final OutputStream out = IO.write(tempFile); try { JaxbOpenejbJar2.marshal(GeronimoEjbJarType.class, geronimoEjbJarType, out); logger.info("Dumping Generated geronimo-openejb.xml to: " + tempFile.getAbsolutePath()); } catch (final JAXBException e) { // no-op } finally { IO.close(out); } } catch (final Exception e) { // no-op } }
public void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException { EjbModule ejbModule = (EjbModule) module; GeronimoEjbJarType tmpGeronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getEjbModule().getAltDDs().get("geronimo-openejb.xml"); OpenejbGeronimoEjbJarType geronimoEjbJarType = XmlUtil.convertToXmlbeans(tmpGeronimoEjbJarType); GerOpenejbClusteringWadiType clusteringWadiType = getWadiClusterConfig(geronimoEjbJarType); if (null == clusteringWadiType) { return; } EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment); ejbModule.getPreAutoConfigDeployer().add(new MapSFSBToContainerIDDeployer(defaultClusteredStatefulContainerId)); }
private void readEjbJar(EjbModule ejbModule, AppModule appModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null) return; Object data = ejbModule.getAltDDs().get("ejb-jar.xml"); if (data instanceof EjbJar) { ejbModule.setEjbJar((EjbJar) data); } else if (data instanceof URL) { URL url = (URL) data; EjbJar ejbJar = readEjbJar(url); ejbModule.setEjbJar(ejbJar); } else { DeploymentLoader.logger.debug("No ejb-jar.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId()); ejbModule.setEjbJar(new EjbJar()); } }
private void readBeans(final EjbModule ejbModule) throws OpenEJBException { if (ejbModule.getBeans() != null) { return; } final Object raw = ejbModule.getAltDDs().get("beans.xml"); final Source data = getSource(raw); if (data != null) { try { final Beans beans = readBeans(data.get()); checkDuplicatedByBeansXml(beans, beans); ejbModule.setBeans(beans); } catch (final IOException e) { throw new OpenEJBException(e); } } else if (raw instanceof Beans) { ejbModule.setBeans((Beans) raw); } }
public void readEjbJar(final EjbModule ejbModule, final AppModule appModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null) { return; } final Source data = getSource(ejbModule.getAltDDs().get("ejb-jar.xml")); if (data != null) { try { final EjbJar ejbJar = readEjbJar(data.get()); ejbModule.setEjbJar(ejbJar); } catch (final IOException e) { throw new OpenEJBException(e); } } else { DeploymentLoader.logger.debug("No ejb-jar.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId()); ejbModule.setEjbJar(new EjbJar()); } }
public void readEjbJar(final EjbModule ejbModule, final AppModule appModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null) { return; } final Source data = getSource(ejbModule.getAltDDs().get("ejb-jar.xml")); if (data != null) { try { final EjbJar ejbJar = readEjbJar(data.get()); ejbModule.setEjbJar(ejbJar); } catch (final IOException e) { throw new OpenEJBException(e); } } else { DeploymentLoader.logger.debug("No ejb-jar.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId()); ejbModule.setEjbJar(new EjbJar()); } }