use of org.apache.openejb.jee.InterceptorBinding 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.InterceptorBinding in project tomee by apache.
the class TransactionAttributesTest 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));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Color.class));
ejbJar.addEnterpriseBean(new StatelessBean(Red.class));
ejbJar.addEnterpriseBean(new StatelessBean(Crimson.class));
ejbJar.addEnterpriseBean(new StatelessBean(Scarlet.class));
final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "*", "*"));
declared.add(new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "*"));
declared.add(new ContainerTransaction(TransAttribute.SUPPORTS, Color.class.getName(), "Scarlet", "*"));
declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
ejbJar.getAssemblyDescriptor().addInterceptorBinding(new InterceptorBinding("*", AttributeInterceptor.class.getName()));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assembler.createApplication(ejbJarInfo);
loadAttributes(ejbJarInfo, "Color");
assertAttribute("Never", Color.class.getMethod("color"));
assertAttribute("RequiresNew", Color.class.getMethod("color", Object.class));
assertAttribute("Mandatory", Color.class.getMethod("color", String.class));
assertAttribute("Mandatory", Color.class.getMethod("color", Boolean.class));
assertAttribute("Mandatory", Color.class.getMethod("color", Integer.class));
loadAttributes(ejbJarInfo, "Red");
assertAttribute("Never", Red.class.getMethod("color"));
assertAttribute("Required", Red.class.getMethod("color", Object.class));
assertAttribute("Mandatory", Red.class.getMethod("color", String.class));
assertAttribute("Mandatory", Red.class.getMethod("color", Boolean.class));
assertAttribute("Mandatory", Red.class.getMethod("color", Integer.class));
assertAttribute("RequiresNew", Red.class.getMethod("red"));
assertAttribute("Required", Red.class.getMethod("red", Object.class));
assertAttribute("Required", Red.class.getMethod("red", String.class));
loadAttributes(ejbJarInfo, "Crimson");
assertAttribute("Supports", Crimson.class.getMethod("color"));
assertAttribute("Supports", Crimson.class.getMethod("color", Object.class));
assertAttribute("Supports", Crimson.class.getMethod("color", String.class));
assertAttribute("Supports", Crimson.class.getMethod("color", Boolean.class));
assertAttribute("Supports", Crimson.class.getMethod("color", Integer.class));
assertAttribute("RequiresNew", Crimson.class.getMethod("red"));
assertAttribute("Supports", Crimson.class.getMethod("red", Object.class));
assertAttribute("Supports", Crimson.class.getMethod("red", String.class));
assertAttribute("RequiresNew", Crimson.class.getMethod("crimson"));
assertAttribute("Supports", Crimson.class.getMethod("crimson", String.class));
loadAttributes(ejbJarInfo, "Scarlet");
assertAttribute("Never", Scarlet.class.getMethod("color"));
assertAttribute("Required", Scarlet.class.getMethod("color", Object.class));
assertAttribute("Supports", Scarlet.class.getMethod("color", String.class));
assertAttribute("Supports", Scarlet.class.getMethod("color", Boolean.class));
assertAttribute("Supports", Scarlet.class.getMethod("color", Integer.class));
assertAttribute("RequiresNew", Scarlet.class.getMethod("red"));
assertAttribute("Never", Scarlet.class.getMethod("red", Object.class));
assertAttribute("Never", Scarlet.class.getMethod("red", String.class));
assertAttribute("Required", Scarlet.class.getMethod("scarlet"));
assertAttribute("NotSupported", Scarlet.class.getMethod("scarlet", String.class));
}
use of org.apache.openejb.jee.InterceptorBinding in project tomee by apache.
the class StatelessInterceptorTest method buildTestApp.
public static EjbModule buildTestApp() throws Exception {
final EjbJar ejbJar = new EjbJar();
ejbJar.setId(StatelessInterceptorTest.class.getName());
final AssemblyDescriptor ad = ejbJar.getAssemblyDescriptor();
ejbJar.addEnterpriseBean(new StatelessBean(Target2Bean.class));
final EnterpriseBean bean = ejbJar.addEnterpriseBean(new StatelessBean(TargetBean.class));
Interceptor interceptor;
interceptor = ejbJar.addInterceptor(new Interceptor(DefaultInterceptor.class));
ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));
{
interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", List.class)));
}
{
interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", int.class)));
}
{
interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptorViaDD.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
binding.setMethod(new NamedMethod(TargetBean.class.getMethod("echo", boolean.class)));
}
final EnterpriseBean bean3 = ejbJar.addEnterpriseBean(new StatelessBean(Target3Bean.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean3));
binding.setExcludeDefaultInterceptors(true);
binding.setExcludeClassInterceptors(true);
return new EjbModule(ejbJar);
}
use of org.apache.openejb.jee.InterceptorBinding in project tomee by apache.
the class SecondStatelessInterceptedTest method module.
@Module
public EjbJar module() {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SecondStatelessInterceptedBean.class));
final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
assembly.addInterceptorBinding(new InterceptorBinding(bean)).setExcludeDefaultInterceptors(true);
return ejbJar;
}
use of org.apache.openejb.jee.InterceptorBinding in project tomee by apache.
the class StatefulInterceptorTest method buildTestApp.
public EjbModule buildTestApp() {
final EjbJar ejbJar = new EjbJar();
final AssemblyDescriptor ad = ejbJar.getAssemblyDescriptor();
final EnterpriseBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class));
Interceptor interceptor;
interceptor = ejbJar.addInterceptor(new Interceptor(ClassInterceptor.class));
ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
interceptor = ejbJar.addInterceptor(new Interceptor(DefaultInterceptor.class));
ad.addInterceptorBinding(new InterceptorBinding("*", interceptor));
interceptor = ejbJar.addInterceptor(new Interceptor(EchoMethodInterceptor.class));
final InterceptorBinding binding = ad.addInterceptorBinding(new InterceptorBinding(bean, interceptor));
binding.setMethod(new NamedMethod("echo"));
return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
}
Aggregations