Methods Summary |
---|
protected void | bindProxy(java.lang.Object proxy)
try
{
log.debug("Binding proxy for " + container.getEjbName() + " in JNDI at " + jndiName);
Util.rebind(container.getInitialContext(), jndiName, proxy);
} catch (NamingException e)
{
NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName);
namingException.setRootCause(e);
throw namingException;
}
|
protected java.lang.Object | constructProxy(java.lang.reflect.InvocationHandler handler)Hide the fact that I'm now using javassist.
try
{
/* plain jdk */
Object args[] = { handler };
Object proxy = proxyConstructor.newInstance(args);
/* javassist */
/*
MethodHandler realHandler = new MethodHandlerAdapter(handler);
// ProxyObject proxy = (ProxyObject) proxyConstructor.newInstance((Object[]) null);
// proxy.setHandler(realHandler);
JavassistProxy proxy = (JavassistProxy) proxyConstructor.newInstance((Object[]) null);
proxy.setMethodHandler(realHandler);
JavassistProxy.pokeInterfaces(proxy, getInterfaces());
*/
/* cglib */
/*
Object args[] = { new CGLibInvocationHandlerAdapter(handler) };
Object proxy = proxyConstructor.newInstance(args);
*/
return proxy;
}
catch (IllegalArgumentException e)
{
throw new RuntimeException(e);
}
catch (InstantiationException e)
{
throw new RuntimeException(e);
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e);
}
catch (InvocationTargetException e)
{
throw new RuntimeException(e.getTargetException());
}
|
public final java.lang.Object | createProxy(java.lang.Object id)
assert id == null : "stateless bean must not have an id";
return createProxy();
|
protected abstract java.lang.Class[] | getInterfaces()
|
public void | init()
initializeJndiName();
Class[] interfaces = getInterfaces();
/* plain jdk */
Class proxyClass = java.lang.reflect.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
final Class[] constructorParams =
{InvocationHandler.class};
proxyConstructor = proxyClass.getConstructor(constructorParams);
/* javassist */
/*
proxyFactory = new javassist.util.proxy.ProxyFactory()
{
@Override
protected ClassLoader getClassLoader()
{
return container.getBeanClass().getClassLoader();
}
};
proxyFactory.setInterfaces(interfaces);
proxyFactory.setSuperclass(JavassistProxy.class);
proxyClass = proxyFactory.createClass();
proxyConstructor = proxyClass.getConstructor((Class[]) null);
*/
/* cglib */
/*
proxyClass = net.sf.cglib.proxy.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
final Class[] constructorParams = {net.sf.cglib.proxy.InvocationHandler.class};
proxyConstructor = proxyClass.getConstructor(constructorParams);
*/
|
protected abstract void | initializeJndiName()
|
public void | setContainer(org.jboss.ejb3.Container container)
this.container = container;
this.advisor = (Advisor) container;
|
public void | start()
init();
Object proxy = createProxy();
//describeClass(proxy.getClass());
bindProxy(proxy);
|
public void | stop()
Util.unbind(container.getInitialContext(), jndiName);
|