EjbJar ejbJar = new EjbJar(); ejbJar.addEnterpriseBean(new StatelessBean(ProcessorBean.class)); ejbJar.addEnterpriseBean(new StatelessBean(MockDao.class)); return ejbJar;
@Override public EnterpriseBean[] getEnterpriseBeans() { return super.getEnterpriseBeans(); }
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; }
/** * 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); }
Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); ejbJar.setRelationships(null); for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { ejbJar.removeEnterpriseBean(ejbName); openejbJar.removeEjbDeployment(ejbDeployment); removed.add(ejbName); AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor(); if (assemblyDescriptor != null){ for (MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) { for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { bean.getEjbLocalRefMap().keySet().removeAll(removed); bean.getEjbRefMap().keySet().removeAll(removed); for (Interceptor interceptor : ejbJar.getInterceptors()) { pruneRefs(interceptor, new EjbDeployment());
public EjbModule deploy(final EjbModule ejbModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null && ejbModule.getEjbJar().isMetadataComplete()) { return ejbModule; final org.apache.openejb.jee.ManagedBean managedBean = new CompManagedBean(name, BeanContext.Comp.class); managedBean.setTransactionType(TransactionType.BEAN); ejbModule.getEjbJar().addEnterpriseBean(managedBean); for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { if (!(bean instanceof SessionBean)) { continue; for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { if (bean.getEjbClass() == null) { continue; ejbModule.getEjbJar().removeEnterpriseBean(bean.getEjbName()); try { final Class<?> clazz = ejbModule.getClassLoader().loadClass(bean.getEjbClass()); ejbModule.getEjbJar().addEnterpriseBean(bean); EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new SingletonBean(ejbName, beanClass.get()); ejbJar.addEnterpriseBean(enterpriseBean); EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new StatelessBean(ejbName, beanClass.get());
public EjbModule deploy(EjbModule ejbModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null && ejbModule.getEjbJar().isMetadataComplete()) return ejbModule; EnterpriseBean[] enterpriseBeans = ejbModule.getEjbJar().getEnterpriseBeans(); for (EnterpriseBean bean : enterpriseBeans) { final String ejbName = bean.getEjbName(); AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor(); if (ejbJar.getInterceptor(interceptor) == null) { logger.debug("Adding '<ejb-jar><interceptors><interceptor>' entry for undeclared interceptor " + interceptor); ejbJar.addInterceptor(new Interceptor(interceptor)); EjbJar ejbJar = ejbModule.getEjbJar(); for (Class interceptor : interceptors.value()) { if (ejbJar.getInterceptor(interceptor.getName()) == null) { ejbJar.addInterceptor(new Interceptor(interceptor.getName())); EjbJar ejbJar = ejbModule.getEjbJar(); for (Class interceptor : interceptors.value()) { if (ejbJar.getInterceptor(interceptor.getName()) == null) { ejbJar.addInterceptor(new Interceptor(interceptor.getName())); for (Interceptor interceptor : ejbModule.getEjbJar().getInterceptors()) { Class<?> clazz; try { processApplicationExceptions(clazz, ejbModule.getEjbJar().getAssemblyDescriptor());
final EjbJar ejbJar = new EjbJar(); final OpenejbJar openejbJar = new OpenejbJar(); testBean = ejbJar.addEnterpriseBean(new ManagedBean(testClass.getSimpleName(), testClass.getName(), true)); testBean.localBean(); testBean.setTransactionType(TransactionType.BEAN); final EjbJar ejbJar = new EjbJar(method.getName()); ejbJar.addEnterpriseBean(bean); final EjbModule ejbModule = new EjbModule(ejbJar); final Beans beans = new Beans(); final EjbModule ejbModule = new EjbModule(new EjbJar(method.getName())); ejbModule.setBeans(beans); appModule.getEjbModules().add(ejbModule); final EjbModule ejbModule = new EjbModule(new EjbJar(method.getName())); ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(beans)).link()); ejbModule.setBeans(new Beans()); final EjbModule ejbModule = new EjbModule(new EjbJar(method.getName())); ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(bean)).link()); ejbModule.setBeans(new Beans()); final EjbModule ejbModule = new EjbModule(new EjbJar(method.getName())); ejbModule.setFinder((IAnnotationFinder) obj); ejbModule.setBeans(new Beans()); final EjbModule ejbModule = new EjbModule(new EjbJar(method.getName())); ejbModule.setFinder(new AnnotationFinder((Archive) obj).link());
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); ejbJar = new EjbJar(); if (ejbJar.getModuleName() == null) { final String name = archive.getName(); if (name.endsWith("ar") && name.length() > 4) { ejbJar.setModuleName(name.substring(0, name.length() - ".jar".length())); } else { ejbJar.setModuleName(name);
final int beansInEjbJar = jar.getEjbJar().getEnterpriseBeans().length; for (final EnterpriseBean bean : jar.getEjbJar().getEnterpriseBeans()) { if (!ejbds.containsKey(bean.getEjbName())) { ConfigUtils.logger.warning("conf.0018", bean.getEjbName(), jar.getJarLocation()); ejbJar.moduleUri = jar.getModuleUri(); ejbJar.moduleId = jar.getModuleId(); if (jar.getEjbJar() != null && jar.getEjbJar().getModuleName() != null) { ejbJar.moduleName = jar.getEjbJar().getModuleName(); } else { ejbJar.moduleName = jar.getModuleId(); ejbJar.properties.putAll(jar.getOpenejbJar().getProperties()); for (final EnterpriseBean bean : jar.getEjbJar().getEnterpriseBeans()) { final EnterpriseBeanInfo beanInfo; if (bean instanceof SessionBean) { if (jar.getEjbJar().getAssemblyDescriptor() != null) { initInterceptors(jar, ejbJar); initSecurityRoles(jar, ejbJar); if (jar.getEjbJar().getRelationships() != null) { initRelationships(jar, infos);
public EjbModule deploy(EjbModule ejbModule) throws OpenEJBException { if (ejbModule.getEjbJar() != null && ejbModule.getEjbJar().isMetadataComplete()) return ejbModule; EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new SingletonBean(ejbName, beanClass.getName()); ejbJar.addEnterpriseBean(enterpriseBean); EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new StatelessBean(ejbName, beanClass.getName()); ejbJar.addEnterpriseBean(enterpriseBean); EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new StatefulBean(ejbName, beanClass.getName()); ejbJar.addEnterpriseBean(enterpriseBean); EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName); if (enterpriseBean == null) { enterpriseBean = new org.apache.openejb.jee.ManagedBean(ejbName, beanClass.getName()); ejbJar.addEnterpriseBean(enterpriseBean); MessageDrivenBean messageBean = (MessageDrivenBean) ejbJar.getEnterpriseBean(ejbName); if (messageBean == null) { messageBean = new MessageDrivenBean(ejbName); ejbJar.addEnterpriseBean(messageBean); AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor(); if (assemblyDescriptor == null) {
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 void addTimeoutInterceptor(@Observes final BeforeAppInfoBuilderEvent event) { LOGGER.fine(GovernanceCodes.EXTENSION_ADDING_INTERCEPTOR, "Adding governance interceptor to application > " + event.getAppModule().getModuleId()); final List<EjbModule> ejbModules = event.getAppModule().getEjbModules(); for (final EjbModule ejbModule : ejbModules) { if (ejbModule.getEjbJar().getEnterpriseBeans().length > 0) { final InterceptorBinding binding = new InterceptorBinding(); binding.setEjbName("*"); binding.getInterceptorClass().add(TimeoutGovernanceInterceptor.class.getName()); ejbModule.getEjbJar().getAssemblyDescriptor().addInterceptorBinding(binding); final Interceptor interceptor = new Interceptor(); interceptor.setInterceptorClass(TimeoutGovernanceInterceptor.class.getName()); interceptor.addAroundTimeout("timeout"); ejbModule.getEjbJar().addInterceptor(interceptor); } } } }
private void initExcludesList(final EjbModule jar, final Map ejbds, final EjbJarInfo ejbJarInfo) { final ExcludeList methodPermissions = jar.getEjbJar().getAssemblyDescriptor().getExcludeList(); for (final Method excludedMethod : methodPermissions.getMethod()) { ejbJarInfo.excludeList.add(getMethodInfo(excludedMethod, ejbds)); } }
appModule.setEarLibFinder(earLibFinder); final EjbModule earCdiModule = new EjbModule(appModule.getClassLoader(), DeploymentLoader.EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); earCdiModule.setBeans(earBeans); earCdiModule.setFinder(earLibFinder); ejbJar = new EjbJar(); if (ejbJar.getModuleName() == null) { final String name = archive.getName(); if (name.endsWith("ar") && name.length() > 4) { ejbJar.setModuleName(name.substring(0, name.length() - ".jar".length())); } else { ejbJar.setModuleName(name);
EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL()); for(EnterpriseBean eb : ejbJar.getEnterpriseBeans()) {
if (!ejbJar.isMetadataComplete()) { for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { String ejbName = bean.getEjbName(); String deploymentId = getDeploymentId(ejbName, ejbJarInfo); for (EnterpriseBean bean: ejbJar.getEnterpriseBeans()) { String ejbName = bean.getEjbName().trim(); GBeanData gbean = getEjbGBean(ejbName); if (!ejbJar.isMetadataComplete()) { ejbJar.setMetadataComplete(true); ejbModule.setOriginalSpecDD(ejbModule.getSpecDD().toString());
String ejbName = name.substring(0,name.indexOf('.')); name = name.substring(name.indexOf('.')+1); EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName); if (bean != null){ for (EnterpriseBean bean : module.getEjbJar().getEnterpriseBeans()) { apply(bean, envEntry, bean.getEjbName());
private void configureClasses(final WebModule web, final EjbModule ejbModule, final ApplicationComposer applicationComposer, final Classes classes) { ejbModule.getEjbJar().setMetadataComplete(applicationComposer.metadataComplete()); final org.apache.openejb.jee.ManagedBean managedBean = new CompManagedBean(name, BeanContext.Comp.class); managedBean.setTransactionType(TransactionType.BEAN); ejbModule.getEjbJar().addEnterpriseBean(managedBean); web.getWebApp().setMetadataComplete(ejbModule.getEjbJar().isMetadataComplete());
public void buildComponentPermissions(ComponentPermissions componentPermissions) throws DeploymentException { List<MethodPermission> methodPermissions = ejbModule.getEjbJar().getAssemblyDescriptor().getMethodPermission(); if (earContext.getSecurityConfiguration() != null) { earContext.setHasSecurity(true); } if (earContext.getSecurityConfiguration() == null && methodPermissions.size() > 0) { throw new DeploymentException("Ejb app has method permissions but no security configuration supplied in geronimo plan"); } for (EnterpriseBean enterpriseBean : ejbModule.getEjbJar().getEnterpriseBeans()) { addSecurityData(enterpriseBean, componentPermissions); } }