use of org.apache.openejb.jee.InterceptorBinding$JAXB.readInterceptorBinding 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$JAXB.readInterceptorBinding 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$JAXB.readInterceptorBinding in project tomee by apache.
the class CheckAssemblyBindings method checkUnusedInterceptors.
private void checkUnusedInterceptors(final EjbModule ejbModule) {
final AssemblyDescriptor assembly = ejbModule.getEjbJar().getAssemblyDescriptor();
final Interceptor[] interceptorsArray = ejbModule.getEjbJar().getInterceptors();
final List<Interceptor> interceptors = Arrays.asList(interceptorsArray);
final Set<String> interceptorClassNames = new HashSet<String>(interceptors.size());
for (final Interceptor interceptor : interceptors) {
interceptorClassNames.add(interceptor.getInterceptorClass());
}
final Set<String> interceptorClassNamesUsedInBindings = new HashSet<String>();
for (final InterceptorBinding binding : assembly.getInterceptorBinding()) {
final List<String> interceptorClass = binding.getInterceptorClass();
interceptorClassNamesUsedInBindings.addAll(interceptorClass);
}
final Set<String> unusedInterceptors = new HashSet<String>();
for (final String clazz : interceptorClassNames) {
if (!interceptorClassNamesUsedInBindings.contains(clazz)) {
unusedInterceptors.add(clazz);
}
}
for (final String clazz : unusedInterceptors) {
warn("Interceptors", "interceptor.unused", clazz);
}
}
use of org.apache.openejb.jee.InterceptorBinding$JAXB.readInterceptorBinding 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));
}
Aggregations