use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class LoggingJAXRSCommons method getEjbModule.
protected EjbModule getEjbModule(String pojoDeploymentClassName, String ejbModuleId) throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
if (ejbModuleId != null) {
module.setModuleId(ejbModuleId);
}
final EnterpriseBean bean = new SingletonBean(LogginTestBean.class).localBean();
module.getEjbJar().addEnterpriseBean(bean);
final Resources resources = new Resources();
final Service feature = new Service("xml", null);
feature.setClassName(JAXBElementProvider.class.getName());
feature.getProperties().put("eventHandler", "$handler");
resources.getService().add(feature);
module.initResources(resources);
if (pojoDeploymentClassName != null) {
final PojoDeployment e = new PojoDeployment();
e.setClassName(pojoDeploymentClassName);
e.getProperties().setProperty("cxf.jaxrs.providers", "xml");
module.getOpenejbJar().getPojoDeployment().add(e);
}
return module;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class AdvancedProviderConfigTest method service.
@Module
public static EjbModule service() throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
final EnterpriseBean bean = new SingletonBean(AdvancedBean.class).localBean();
module.getEjbJar().addEnterpriseBean(bean);
final Resources resources = new Resources();
final Service feature = new Service("xml", null);
feature.setClassName(JAXBElementProvider.class.getName());
feature.getProperties().put("eventHandler", "$handler");
resources.getService().add(feature);
final Service handler = new Service("handler", null);
handler.setClassName(MyValidator.class.getName());
resources.getService().add(handler);
module.initResources(resources);
final PojoDeployment e = new PojoDeployment();
e.setClassName("jaxrs-application");
e.getProperties().setProperty("cxf.jaxrs.providers", "xml");
module.getOpenejbJar().getPojoDeployment().add(e);
return module;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class SystemApps method getSystemModule.
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;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class OpenEJBXmlByModuleTest method setUp.
@Before
public void setUp() throws OpenEJBException, NamingException, IOException {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final AppModule app = new AppModule(OpenEJBXmlByModuleTest.class.getClassLoader(), OpenEJBXmlByModuleTest.class.getSimpleName());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(UselessBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
app.getEjbModules().iterator().next().getAltDDs().put("resources.xml", getClass().getClassLoader().getResource("META-INF/resource/appresource.openejb.xml"));
assembler.createApplication(config.configureApplication(app));
final Properties properties = new Properties();
properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
properties.setProperty("openejb.embedded.initialcontext.close", "destroy");
// some hack to be sure to call destroy()
context = new InitialContext(properties);
bean = (UselessBean) context.lookup("UselessBeanLocalBean");
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class AccessTimeoutTest method test.
public void test() throws Exception {
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
//TODO alternative to hack in CidBuilder to initialize if missing
// SystemInstance.get().setComponent(ThreadSingletonService.class, new ThreadSingletonServiceImpl(getClass().getClassLoader()));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(Color.class));
ejbJar.addEnterpriseBean(new SingletonBean(Red.class));
ejbJar.addEnterpriseBean(new SingletonBean(Crimson.class));
ejbJar.addEnterpriseBean(new SingletonBean(Scarlet.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
loadAttributes(ejbJarInfo, "Color");
assertAttribute(2, TimeUnit.SECONDS, Color.class.getMethod("color"));
assertAttribute(3, TimeUnit.SECONDS, Color.class.getMethod("color", Object.class));
assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", String.class));
assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", Boolean.class));
assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", Integer.class));
loadAttributes(ejbJarInfo, "Red");
assertAttribute(2, TimeUnit.SECONDS, Red.class.getMethod("color"));
assertNullAttribute(Red.class.getMethod("color", Object.class));
assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", String.class));
assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", Boolean.class));
assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", Integer.class));
assertAttribute(1, TimeUnit.MINUTES, Red.class.getMethod("red"));
assertNullAttribute(Red.class.getMethod("red", Object.class));
assertNullAttribute(Red.class.getMethod("red", String.class));
loadAttributes(ejbJarInfo, "Crimson");
assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("color"));
assertNullAttribute(Crimson.class.getMethod("color", Object.class));
assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("color", String.class));
assertAttribute(1, TimeUnit.SECONDS, Crimson.class.getMethod("color", Boolean.class));
assertAttribute(1, TimeUnit.SECONDS, Crimson.class.getMethod("color", Integer.class));
assertAttribute(1, TimeUnit.MINUTES, Crimson.class.getMethod("red"));
assertNullAttribute(Crimson.class.getMethod("red", Object.class));
assertNullAttribute(Crimson.class.getMethod("red", String.class));
assertAttribute(2, TimeUnit.HOURS, Crimson.class.getMethod("crimson"));
assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("crimson", String.class));
loadAttributes(ejbJarInfo, "Scarlet");
assertAttribute(2, TimeUnit.SECONDS, Scarlet.class.getMethod("color"));
assertNullAttribute(Scarlet.class.getMethod("color", Object.class));
assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", String.class));
assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", Boolean.class));
assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", Integer.class));
assertAttribute(1, TimeUnit.MINUTES, Scarlet.class.getMethod("red"));
assertNullAttribute(Scarlet.class.getMethod("red", Object.class));
assertNullAttribute(Scarlet.class.getMethod("red", String.class));
assertAttribute(2, TimeUnit.DAYS, Scarlet.class.getMethod("scarlet"));
assertAttribute(1, TimeUnit.DAYS, Scarlet.class.getMethod("scarlet", String.class));
}
Aggregations