FileDocCategorySizeDatePackage
BaseStatefulProxyFactory.javaAPI DocJBoss 4.2.13517Fri Jul 13 20:53:50 BST 2007org.jboss.ejb3.stateful

BaseStatefulProxyFactory

public abstract class BaseStatefulProxyFactory extends org.jboss.ejb3.session.BaseSessionProxyFactory implements org.jboss.ejb3.ProxyFactory
Comment
author
Bill Burke
version
$Revision: 57207 $

Fields Summary
private static final Logger
log
protected Class
proxyClass
protected Constructor
proxyConstructor
protected Context
proxyFactoryContext
protected String
jndiName
public static final String
PROXY_FACTORY_NAME
Constructors Summary
Methods Summary
protected abstract java.lang.Class[]getInterfaces()

public voidinit()


       
   
      initializeJndiName();
      Class[] interfaces = getInterfaces();
      Class proxyClass = java.lang.reflect.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
      final Class[] constructorParams =
              {InvocationHandler.class};
      proxyConstructor = proxyClass.getConstructor(constructorParams);
   
protected abstract voidinitializeJndiName()

public voidstart()

      init();

      Context ctx = container.getInitialContext();
      Name name = ctx.getNameParser("").parse(jndiName);
      ctx = Util.createSubcontext(ctx, name.getPrefix(name.size() - 1));
      String atom = name.get(name.size() - 1);
      RefAddr refAddr = new StringRefAddr(JndiProxyFactory.FACTORY, jndiName + PROXY_FACTORY_NAME);
      Reference ref = new Reference("java.lang.Object", refAddr, JndiProxyFactory.class.getName(), null);
      try 
      {
         Util.rebind(ctx, atom, ref);
      } catch (NamingException e)
      {
         NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
         namingException.setRootCause(e);
         throw namingException;
      }
   
public voidstop()

      Util.unbind(container.getInitialContext(), jndiName);