[jboss-cvs] JBossAS SVN: r94913 - in projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb: interceptor and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 14 22:52:24 EDT 2009
Author: marius.bogoevici
Date: 2009-10-14 22:52:24 -0400 (Wed, 14 Oct 2009)
New Revision: 94913
Modified:
projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java
projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/interceptor/Jsr299BindingsInterceptor.java
Log:
Fix support for invoking bound interceptors from EJBs
Modified: projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java
===================================================================
--- projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java 2009-10-15 01:26:05 UTC (rev 94912)
+++ projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java 2009-10-15 02:52:24 UTC (rev 94913)
@@ -41,7 +41,7 @@
protected EjbReferenceResolver resolver;
private final List<EjbDescriptor<?>> ejbs = new ArrayList<EjbDescriptor<?>>();
private final List<String> ejbContainerNames = new ArrayList<String>();
- private Map<String, InterceptorBindings> interceptorBindings = new ConcurrentHashMap<String, InterceptorBindings>();
+ private Map<EjbDescriptor, InterceptorBindings> interceptorBindings = new ConcurrentHashMap<EjbDescriptor, InterceptorBindings>();
public JBossEjbServices() throws NamingException
{
@@ -118,11 +118,7 @@
public void registerInterceptors(EjbDescriptor<?> ejbDescriptor, InterceptorBindings interceptorBindings)
{
- //this.interceptorBindings.put(ejbDescriptor.getEjbName(), interceptorBindings);
- if (ejbDescriptor instanceof JBossEJBDescriptorAdaptor)
- {
- ((JBossEJBDescriptorAdaptor)ejbDescriptor).setInterceptorBindings(interceptorBindings);
- }
+ this.interceptorBindings.put(ejbDescriptor, interceptorBindings);
}
public Object resolveRemoteEjb(String jndiName, String mappedName, String ejbLink)
@@ -217,7 +213,7 @@
public InterceptorBindings getInterceptorBindings(EjbDescriptor<?> ejbDescriptor)
{
- return interceptorBindings.get(ejbDescriptor.getEjbName());
+ return interceptorBindings.get(ejbDescriptor);
}
public void cleanup()
Modified: projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/interceptor/Jsr299BindingsInterceptor.java
===================================================================
--- projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/interceptor/Jsr299BindingsInterceptor.java 2009-10-15 01:26:05 UTC (rev 94912)
+++ projects/weld-int/trunk/ejb/src/main/java/org/jboss/weld/integration/ejb/interceptor/Jsr299BindingsInterceptor.java 2009-10-15 02:52:24 UTC (rev 94913)
@@ -71,7 +71,7 @@
doLifecycleInterception(invocationContext, InterceptionType.POST_CONSTRUCT);
}
- private <T> void init(InvocationContext invocationContext)
+ private void init(InvocationContext invocationContext)
{
// create contextual instances for inteDITrceptors
interceptorInstances = new ConcurrentHashMap<String, Object>();
@@ -100,7 +100,7 @@
private <T> void addInterceptorInstance(Interceptor<T> interceptor, InvocationContext invocationContext)
{
CreationalContext<T> creationalContext = (CreationalContext<T>) invocationContext.getContextData().get(SessionBeanInterceptor.CREATIONAL_CONTEXT);
- interceptorInstances.put(interceptor.getName(), beanManager.getContext(interceptor.getScope()).get(interceptor, creationalContext));
+ interceptorInstances.put(interceptor.getBeanClass().getName(), beanManager.getContext(interceptor.getScope()).get(interceptor, creationalContext));
}
@PreDestroy
@@ -110,9 +110,9 @@
}
@AroundInvoke
- public void doAroundInvoke(InvocationContext invocationContext) throws Exception
+ public Object doAroundInvoke(InvocationContext invocationContext) throws Exception
{
- doMethodInterception(invocationContext, InterceptionType.AROUND_INVOKE);
+ return doMethodInterception(invocationContext, InterceptionType.AROUND_INVOKE);
}
private void doLifecycleInterception(InvocationContext invocationContext, InterceptionType interceptionType)
@@ -129,28 +129,36 @@
}
}
- private void doMethodInterception(InvocationContext invocationContext, InterceptionType interceptionType)
+ private Object doMethodInterception(InvocationContext invocationContext, InterceptionType interceptionType)
throws Exception
{
if (interceptorBindings != null)
{
List<Interceptor<?>> currentInterceptors = interceptorBindings.getMethodInterceptors(interceptionType, invocationContext.getMethod());
- delegateInterception(invocationContext, interceptionType, currentInterceptors);
+ return delegateInterception(invocationContext, interceptionType, currentInterceptors);
}
else
{
- invocationContext.proceed();
+ return invocationContext.proceed();
}
}
- private void delegateInterception(InvocationContext invocationContext, InterceptionType interceptionType, List<Interceptor<?>> currentInterceptors)
+ private Object delegateInterception(InvocationContext invocationContext, InterceptionType interceptionType, List<Interceptor<?>> currentInterceptors)
throws Exception
{
List<Object> currentInterceptorInstances = new ArrayList<Object>();
for (Interceptor<?> interceptor: currentInterceptors)
{
- currentInterceptorInstances.add(interceptorInstances.get(interceptor.getName()));
+ currentInterceptorInstances.add(interceptorInstances.get(interceptor.getBeanClass().getName()));
}
- new DelegatingInterceptorInvocationContext(invocationContext, currentInterceptors, currentInterceptorInstances, interceptionType).proceed();
+ if (currentInterceptorInstances.size() > 0)
+ {
+ return new DelegatingInterceptorInvocationContext(invocationContext, currentInterceptors, currentInterceptorInstances, interceptionType).proceed();
+ }
+ else
+ {
+ return invocationContext.proceed();
+ }
+
}
}
More information about the jboss-cvs-commits
mailing list