Skip to content

Commit

Permalink
Proxy classloading ordering, make enterprise bean destruction actuall…
Browse files Browse the repository at this point in the history
…y work

git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1206 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jan 23, 2009
1 parent d76a003 commit 3f6a049
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
Expand Up @@ -249,6 +249,7 @@ protected void initPrimitive()

protected boolean injectionPointsAreSerializable()
{
// TODO CACHE THIS!!!
// TODO: a bit crude, don't check *all* injectionpoints, only those listed
// in the spec for passivation checks
for (AnnotatedItem<?, ?> injectionPoint : getAnnotatedInjectionPoints())
Expand Down
Expand Up @@ -18,7 +18,8 @@
package org.jboss.webbeans.bean;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
Expand All @@ -31,6 +32,7 @@
import javax.webbeans.Interceptor;

import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.proxy.EnterpiseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
Expand Down Expand Up @@ -133,17 +135,19 @@ protected void initInjectionPoints()

protected void initTypes()
{
types = new HashSet<Type>();
types = new LinkedHashSet<Type>();
types.add(Object.class);
for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
{
types.add(businessInterfaceDescriptor.getInterface());
}
types.add(Object.class);
}

protected void initProxyClass()
{
ProxyFactory proxyFactory = Proxies.getProxyFactory(getTypes());
Set<Type> types = new LinkedHashSet<Type>(getTypes());
types.add(EnterpiseBeanInstance.class);
ProxyFactory proxyFactory = Proxies.getProxyFactory(types);

@SuppressWarnings("unchecked")
Class<T> proxyClass = proxyFactory.createClass();
Expand Down Expand Up @@ -241,6 +245,7 @@ public T create()
@Override
public void destroy(T instance)
{
EnterpiseBeanInstance enterpiseBeanInstance = (EnterpiseBeanInstance) instance;
Boolean isDestroyed = (Boolean) Reflections.invokeAndWrap("isDestroyed", null, instance, null);
if (isDestroyed.booleanValue())
{
Expand Down
@@ -0,0 +1,8 @@
package org.jboss.webbeans.bean.proxy;

public interface EnterpiseBeanInstance
{

public boolean isDestroyed();

}
Expand Up @@ -19,7 +19,7 @@

import java.io.Serializable;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -77,7 +77,7 @@ private static <T> T createClientProxy(Bean<T> bean, int beanIndex) throws Runti
try
{
ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, beanIndex);
Set<Type> classes = new HashSet<Type>(bean.getTypes());
Set<Type> classes = new LinkedHashSet<Type>(bean.getTypes());
classes.add(Serializable.class);
ProxyFactory proxyFactory = Proxies.getProxyFactory(classes);
proxyFactory.setHandler(proxyMethodHandler);
Expand Down
Expand Up @@ -17,8 +17,8 @@
package org.jboss.webbeans.util;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import javassist.util.proxy.ProxyFactory;
Expand Down Expand Up @@ -46,8 +46,8 @@ public static class TypeInfo
private TypeInfo()
{
super();
this.interfaces = new HashSet<Class<?>>();
this.classes = new HashSet<Class<?>>();
this.interfaces = new LinkedHashSet<Class<?>>();
this.classes = new LinkedHashSet<Class<?>>();
}

public Class<?> getSuperClass()
Expand Down

0 comments on commit 3f6a049

Please sign in to comment.