public static EjbJar readEjbJar(URL url) throws OpenEJBException { try { if (isEmptyEjbJar(url)) return new EjbJar(); return (EjbJar) JaxbJavaee.unmarshal(EjbJar.class, url.openStream()); } catch (SAXException e) { throw new OpenEJBException("Cannot parse the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (JAXBException e) { throw new OpenEJBException("Cannot unmarshall the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (IOException e) { throw new OpenEJBException("Cannot read the ejb-jar.xml file: " + url.toExternalForm(), e); } catch (Exception e) { throw new OpenEJBException("Encountered unknown error parsing the ejb-jar.xml file: " + url.toExternalForm(), e); } }
public static EjbJar readEjbJar(final InputStream is) throws OpenEJBException { try { final String content = IO.slurp(is); if (isEmptyEjbJar(new ByteArrayInputStream(content.getBytes()))) { final String id = getId(new ByteArrayInputStream(content.getBytes())); return new EjbJar(id); } return EjbJarXml.unmarshal(new ByteArrayInputStream(content.getBytes())); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered error parsing the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } }
public static EjbJar readEjbJar(final InputStream is) throws OpenEJBException { try { final String content = IO.slurp(is); if (isEmptyEjbJar(new ByteArrayInputStream(content.getBytes()))) { final String id = getId(new ByteArrayInputStream(content.getBytes())); return new EjbJar(id); } return EjbJarXml.unmarshal(new ByteArrayInputStream(content.getBytes())); } catch (final SAXException e) { throw new OpenEJBException("Cannot parse the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } catch (final IOException e) { throw new OpenEJBException("Cannot read the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } catch (final Exception e) { throw new OpenEJBException("Encountered error parsing the ejb-jar.xml", e); // file: " + url.toExternalForm(), e); } }
private static EjbJar createEjbJar(final String prefix, final Archive<?> webArchive) { final EjbJar webEjbJar; final Node webEjbJarXml = webArchive.get(prefix.concat(EJB_JAR_XML)); if (webEjbJarXml != null) { try { webEjbJar = ReadDescriptors.readEjbJar(webEjbJarXml.getAsset().openStream()); } catch (final OpenEJBException e) { throw new OpenEJBRuntimeException(e); } } else { webEjbJar = new EjbJar(); } return webEjbJar; }
EjbJar ejbJar = new EjbJar(); ejbJar.addEnterpriseBean(new StatelessBean(ProcessorBean.class)); ejbJar.addEnterpriseBean(new StatelessBean(MockDao.class));
/** * If the web.xml is metadata-complete and there is no ejb-jar.xml * then per specification we use the web.xml metadata-complete setting * to imply the same for EJBs. * * @param webModule WebModule * @param ejbModule EjbModule */ private static void fillEjbJar(final WebModule webModule, final EjbModule ejbModule) { final Object o = webModule.getAltDDs().get("ejb-jar.xml"); if (o != null) { return; } if (ejbModule.getEjbJar() != null) { return; } final EjbJar ejbJar = new EjbJar(); final WebApp webApp = webModule.getWebApp(); ejbJar.setMetadataComplete(webApp.isMetadataComplete()); ejbModule.setEjbJar(ejbJar); }
/** * If the web.xml is metadata-complete and there is no ejb-jar.xml * then per specification we use the web.xml metadata-complete setting * to imply the same for EJBs. * * @param webModule WebModule * @param ejbModule EjbModule */ private static void fillEjbJar(final WebModule webModule, final EjbModule ejbModule) { final Object o = webModule.getAltDDs().get("ejb-jar.xml"); if (o != null) { return; } if (ejbModule.getEjbJar() != null) { return; } final EjbJar ejbJar = new EjbJar(); final WebApp webApp = webModule.getWebApp(); ejbJar.setMetadataComplete(webApp.isMetadataComplete()); ejbModule.setEjbJar(ejbJar); }
private static EjbModule addTestClassAsManagedBean(Class<?> javaClass, URLClassLoader tempClassLoader, AppModule appModule) { final EjbJar ejbJar = new EjbJar(); final OpenejbJar openejbJar = new OpenejbJar(); final String ejbName = appModule.getModuleId() + "_" + javaClass.getName(); final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(ejbName, javaClass.getName(), true)); bean.localBean(); bean.setTransactionType(TransactionType.BEAN); final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean); ejbDeployment.setDeploymentId(ejbName); final EjbModule e = new EjbModule(ejbJar, openejbJar); e.getProperties().setProperty("openejb.cdi.activated", "false"); e.getProperties().setProperty("openejb.test.module", "true"); e.setBeans(new Beans()); e.setClassLoader(tempClassLoader); appModule.getEjbModules().add(e); return e; }
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()); } }
public EjbModule beans() { EjbJar ejbJar = new EjbJar("processing"); OpenejbJar openejbJar = new OpenejbJar();
public static EjbModule getSystemModule() { final EjbModule module = new EjbModule(new EjbJar("openejb"), new OpenejbJar()); final OpenejbJar openejbJar = module.getOpenejbJar(); final EjbJar ejbJar = module.getEjbJar(); ejbJar.addEnterpriseBean(new StatelessBean(null, DeployerEjb.class)); ejbJar.addEnterpriseBean(new StatelessBean(null, ConfigurationInfoEjb.class)); ejbJar.addEnterpriseBean(new StatelessBean(null, MEJBBean.class)); ejbJar.addInterceptor(new Interceptor(InternalSecurityInterceptor.class)); ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", InternalSecurityInterceptor.class.getName())); module.getMbeans().add(JMXDeployer.class.getName()); final String className = "org.apache.tomee.catalina.deployer.WebappDeployer"; if (exists(className)) { final SingletonBean bean = ejbJar.addEnterpriseBean(new SingletonBean("openejb/WebappDeployer", className)); final EjbDeployment deployment = openejbJar.addEjbDeployment(bean); deployment.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}"); final SingletonBean exceptionManager = ejbJar.addEnterpriseBean(new SingletonBean("openejb/ExceptionManagerFacade", "org.apache.tomee.catalina.facade.ExceptionManagerFacadeBean")); final EjbDeployment exceptionMgr = openejbJar.addEjbDeployment(exceptionManager); exceptionMgr.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}"); } openejbJar.getProperties().put("openejb.deploymentId.format", "{ejbName}"); openejbJar.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.openejbLegacyName}"); return module; }
public static EjbModule getSystemModule() { final EjbModule module = new EjbModule(new EjbJar("openejb"), new OpenejbJar()); final OpenejbJar openejbJar = module.getOpenejbJar(); final EjbJar ejbJar = module.getEjbJar(); // // // DONT MODIFY IT WITHOUT VALIDATING org.apache.openejb.config.SystemAppInfo.preComputedInfo() // // ejbJar.addEnterpriseBean(singleton(DeployerEjb.class)); ejbJar.addEnterpriseBean(singleton(ConfigurationInfoEjb.class)); ejbJar.addEnterpriseBean(singleton(MEJBBean.class)); ejbJar.addInterceptor(new Interceptor(InternalSecurityInterceptor.class)); ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", InternalSecurityInterceptor.class.getName())); module.getMbeans().add(JMXDeployer.class.getName()); final SingletonBean bean = ejbJar.addEnterpriseBean(new SingletonBean("openejb/WebappDeployer", "org.apache.tomee.catalina.deployer.WebappDeployer")); final EjbDeployment deployment = openejbJar.addEjbDeployment(bean); deployment.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}"); final SingletonBean exceptionManager = ejbJar.addEnterpriseBean(new SingletonBean("openejb/ExceptionManagerFacade", "org.apache.tomee.catalina.facade.ExceptionManagerFacadeBean")); final EjbDeployment exceptionMgr = openejbJar.addEjbDeployment(exceptionManager); exceptionMgr.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.annotationName}"); openejbJar.getProperties().put("openejb.deploymentId.format", "{ejbName}"); openejbJar.getProperties().put("openejb.jndiname.format", "{deploymentId}{interfaceType.openejbLegacyName}"); return module; }
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()); } }
final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); ejbModule.setBeans(complete); ejbModule.setFinder(finder);
final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); ejbModule.setBeans(complete); ejbModule.setFinder(finder);
EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
private AppModule createTribestreamNotificationCoreModule() { final ClassLoader loader = ParentClassLoaderFinder.Helper.get(); final EjbModule module = new EjbModule(new EjbJar(moduleName), new OpenejbJar()); // activate CDI final Beans beans = new Beans(); beans.addManagedClass(AlterPersisterObserver.class); module.setBeans(beans); // find all from current jar final File jar = JarLocation.jarLocation(Installer.class); try { module.setFinder(new AnnotationFinder( new FilteredArchive( jar.isDirectory() ? new FileArchive(loader, jar) : new JarArchive(loader, jar.toURI().toURL()), Filters.packages("com.tomitribe.tribestream.notifications.core"))) .link()); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } // add unit for persistence final PersistenceUnit unit = new PersistenceUnit(unitName); unit.setJtaDataSource(dataSourceName); unit.setNonJtaDataSource(dataSourceName + "NonJta"); unit.addClass(Alert.class); unit.setExcludeUnlistedClasses(true); unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); // here we are, assemble eveything final AppModule appModule = new AppModule(module); appModule.addPersistenceModule(new PersistenceModule("", new Persistence(unit))); return appModule; }
private AppModule createTribestreamCoreModule() { final ClassLoader loader = ParentClassLoaderFinder.Helper.get(); final EjbModule module = new EjbModule(new EjbJar(moduleName), new OpenejbJar()); // activate CDI final Beans beans = new Beans(); module.setBeans(beans); // find all from current jar final File jar = JarLocation.jarLocation(SignaturesService.class); try { module.setFinder(new AnnotationFinder( new FilteredArchive( jar.isDirectory() ? new FileArchive(loader, jar) : new JarArchive(loader, jar.toURI().toURL()), Filters.packages("com.tomitribe.tribestream.security.signatures"))) .link()); } catch (final MalformedURLException e) { throw new IllegalStateException(e); } // add unit for persistence final PersistenceUnit unit = new PersistenceUnit(unitName); unit.setJtaDataSource(dataSourceName); unit.setNonJtaDataSource(dataSourceName + "NonJta"); unit.addClass(KeyId.class); unit.addClass(Key.class); unit.setExcludeUnlistedClasses(true); unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)"); // here we are, assemble everything final AppModule appModule = new AppModule(module); appModule.addPersistenceModule(new PersistenceModule("", new Persistence(unit))); return appModule; }