Skip to content

Commit

Permalink
[JBAS-8323] - Only return proxy if there are interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
baileyje committed Aug 25, 2010
1 parent 0c49b37 commit 5a959ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import org.jboss.msc.service.StopContext;

/**
* Service responsible for managing the creation and life-cycle of a managed bean. This service will return a new instance
* of the manged bean each time getValue is called. In essence this can be used as a factory to create instances of a specific managed
* bean.
* Service responsible for managing the life-cycle of a managed bean container. Once this service is started it will
* register the managed bean container with the registry and in essence mark the managed bean in service. It will
* un-register the container from the registry when stopped.
*
* @author John E. Bailey
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ManagedBeanContainer(final Class<T> beanClass, final List<Method> postCon
*/
public T createInstance() {
// Create instance
final T managedBean;
T managedBean;
try {
managedBean = beanClass.newInstance();
} catch (Throwable t) {
Expand All @@ -83,22 +83,26 @@ public T createInstance() {
}
}
}
// Create a proxy
final List<ManagedBeanInterceptor.AroundInvokeInterceptor<?>> aroundInvokeInterceptors = new ArrayList<ManagedBeanInterceptor.AroundInvokeInterceptor<?>>(interceptors.size());
for(ManagedBeanInterceptor<?> managedBeanInterceptor : interceptors) {

if(!interceptors.isEmpty()) {
// Create a proxy
final List<ManagedBeanInterceptor.AroundInvokeInterceptor<?>> aroundInvokeInterceptors = new ArrayList<ManagedBeanInterceptor.AroundInvokeInterceptor<?>>(interceptors.size());
for(ManagedBeanInterceptor<?> managedBeanInterceptor : interceptors) {
try {
aroundInvokeInterceptors.add(managedBeanInterceptor.createInstance());
} catch (Throwable t) {
throw new RuntimeException("Failed to create instance of interceptor " + managedBeanInterceptor.toString(), t);
}
}

final T proxy;
try {
aroundInvokeInterceptors.add(managedBeanInterceptor.createInstance());
managedBean = ManagedBeanProxyHandler.createProxy(beanClass, managedBean, aroundInvokeInterceptors);
} catch (Throwable t) {
throw new RuntimeException("Failed to create instance of interceptor " + managedBeanInterceptor.toString(), t);
throw new RuntimeException("Unable to create managed bean proxy for " + beanClass, t);
}
}
final T proxy;
try {
proxy = ManagedBeanProxyHandler.createProxy(beanClass, managedBean, aroundInvokeInterceptors);
} catch (Throwable t) {
throw new RuntimeException("Unable to create managed bean proxy for " + beanClass, t);
}
return proxy;
return managedBean;
}


Expand Down

0 comments on commit 5a959ff

Please sign in to comment.