use of org.apache.openejb.jee.Interceptor$JAXB.readInterceptor in project tomee by apache.
the class EjbJarInfoBuilder method initInterceptors.
private void initInterceptors(final EjbModule jar, final EjbJarInfo ejbJar) throws OpenEJBException {
if (jar.getEjbJar().getInterceptors().length == 0) {
return;
}
if (jar.getEjbJar().getAssemblyDescriptor() == null) {
return;
}
if (jar.getEjbJar().getAssemblyDescriptor().getInterceptorBinding() == null) {
return;
}
for (final Interceptor s : jar.getEjbJar().getInterceptors()) {
final InterceptorInfo info = new InterceptorInfo();
info.clazz = s.getInterceptorClass();
copyCallbacks(s.getAroundInvoke(), info.aroundInvoke);
copyCallbacks(s.getPostConstruct(), info.postConstruct);
copyCallbacks(s.getPreDestroy(), info.preDestroy);
copyCallbacks(s.getPostActivate(), info.postActivate);
copyCallbacks(s.getPrePassivate(), info.prePassivate);
copyCallbacks(s.getAfterBegin(), info.afterBegin);
copyCallbacks(s.getBeforeCompletion(), info.beforeCompletion);
copyCallbacks(s.getAfterCompletion(), info.afterCompletion);
copyCallbacks(s.getAroundTimeout(), info.aroundTimeout);
ejbJar.interceptors.add(info);
}
for (final InterceptorBinding binding : jar.getEjbJar().getAssemblyDescriptor().getInterceptorBinding()) {
final InterceptorBindingInfo info = new InterceptorBindingInfo();
info.ejbName = binding.getEjbName();
info.excludeClassInterceptors = binding.getExcludeClassInterceptors();
info.excludeDefaultInterceptors = binding.getExcludeDefaultInterceptors();
info.interceptors.addAll(binding.getInterceptorClass());
if (binding.getInterceptorOrder() != null) {
info.interceptorOrder.addAll(binding.getInterceptorOrder().getInterceptorClass());
}
info.method = toInfo(binding.getMethod());
info.className = binding.getClassName();
ejbJar.interceptorBindings.add(info);
}
}
use of org.apache.openejb.jee.Interceptor$JAXB.readInterceptor in project tomee by apache.
the class DebuggableVmHackery method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
ejbJar.setRelationships(null);
final List<String> removed = new ArrayList<String>();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
pruneRefs(bean, ejbDeployment);
// }
if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
continue;
}
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
removed.add(ejbName);
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Drop any ejb ref to with an ejb-link to a removed ejb
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
bean.getEjbLocalRefMap().keySet().removeAll(removed);
bean.getEjbRefMap().keySet().removeAll(removed);
}
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
pruneRefs(interceptor, new EjbDeployment());
}
}
return appModule;
}
use of org.apache.openejb.jee.Interceptor$JAXB.readInterceptor in project tomee by apache.
the class FullyInterceptedTest method module.
@Module
public EjbJar module() {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FullyInterceptedBean.class));
final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
final InterceptorBinding b = assembly.addInterceptorBinding(new InterceptorBinding(bean));
b.setExcludeDefaultInterceptors(true);
b.setMethod(new NamedMethod("methodWithDefaultInterceptorsExcluded"));
return ejbJar;
}
use of org.apache.openejb.jee.Interceptor$JAXB.readInterceptor in project tomee by apache.
the class MethodLevelInterceptorOnlyTest method module.
@Module
public EjbJar module() {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(MethodLevelInterceptorOnlySLSBean.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.Interceptor$JAXB.readInterceptor in project tomee by apache.
the class ThirdSLSBeanTest method module.
@Module
public EjbJar module() {
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(ThirdSLSBean.class));
final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
return ejbJar;
}
Aggregations