FileDocCategorySizeDatePackage
StatelessRemoteProxyFactory.javaAPI DocJBoss 4.2.18090Fri Jul 13 20:53:52 BST 2007org.jboss.ejb3.stateless

StatelessRemoteProxyFactory

public class StatelessRemoteProxyFactory extends BaseStatelessProxyFactory implements org.jboss.ejb3.remoting.RemoteProxyFactory
Comment
author
Bill Burke
version
$Revision: 61329 $

Fields Summary
private static final Logger
log
protected org.jboss.annotation.ejb.RemoteBinding
binding
protected org.jboss.remoting.InvokerLocator
locator
Constructors Summary
Methods Summary
protected booleanbindHomeAndBusinessTogether(org.jboss.ejb3.EJBContainer container)

      return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteJndiName(container));
   
public java.lang.ObjectcreateHomeProxy(java.lang.Class homeInterface)

      try {
         Object containerId = container.getObjectName().getCanonicalName();
         ;
         String stackName = "StatelessSessionClientInterceptors";
         if (binding.interceptorStack() != null
               && !binding.interceptorStack().equals(""))
         {
            stackName = binding.interceptorStack();
         }
         AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
         StatelessRemoteProxy proxy = new StatelessRemoteProxy(containerId,
               stack.createInterceptors((Advisor) container, null), locator);
         setEjb21Objects(proxy);
         Class[] interfaces = { homeInterface };
         return java.lang.reflect.Proxy.newProxyInstance(container
               .getBeanClass().getClassLoader(), interfaces, proxy);
      } catch (IllegalArgumentException e)
      {
         throw new RuntimeException(e); // To change body of catch statement
                                          // use Options | File Templates.
      }
   
public java.lang.ObjectcreateProxy()

      // try
      {
         Object containerId = container.getObjectName().getCanonicalName();
         ;
         String stackName = "StatelessSessionClientInterceptors";
         if (binding.interceptorStack() != null
               && !binding.interceptorStack().equals(""))
         {
            stackName = binding.interceptorStack();
         }
         AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
         StatelessRemoteProxy proxy = new StatelessRemoteProxy(containerId,
               stack.createInterceptors((Advisor) container, null), locator);
         setEjb21Objects(proxy);
         /*
          * Object[] args = {proxy}; return proxyConstructor.newInstance(args);
          */
         return constructProxy(proxy);
      }
      /*
       * catch (InstantiationException e) { throw new RuntimeException(e); //To
       * change body of catch statement use Options | File Templates. } catch
       * (IllegalAccessException e) { throw new RuntimeException(e); //To change
       * body of catch statement use Options | File Templates. } catch
       * (IllegalArgumentException e) { throw new RuntimeException(e); //To
       * change body of catch statement use Options | File Templates. } catch
       * (InvocationTargetException e) { throw new
       * RuntimeException(e.getTargetException()); //To change body of catch
       * statement use Options | File Templates. }
       */
   
protected StatelessHandleImplgetHandle()

      StatelessHandleImpl handle = new StatelessHandleImpl();
      RemoteBinding remoteBinding = (RemoteBinding) advisor
            .resolveAnnotation(RemoteBinding.class);
      if (remoteBinding != null)
         handle.jndiName = remoteBinding.jndiBinding();

      return handle;
   
protected java.lang.Class[]getInterfaces()

      Class[] interfaces;
      
      StatelessContainer statelessContainer = (StatelessContainer) container;
      RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
      
      boolean bindTogether = false;
      
      if (remoteHome != null && bindHomeAndBusinessTogether(statelessContainer))
         bindTogether = true;
      
      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
      
      if (bindTogether)
         interfaces = new Class[remoteInterfaces.length + 3];
      else
         interfaces = new Class[remoteInterfaces.length + 2];
      
      System.arraycopy(remoteInterfaces, 0, interfaces, 0,
            remoteInterfaces.length);
      interfaces[remoteInterfaces.length] = JBossProxy.class;
      interfaces[remoteInterfaces.length + 1] = javax.ejb.EJBObject.class;
      
      if (bindTogether)
         interfaces[remoteInterfaces.length + 2] = remoteHome.value();

      return interfaces;
   
public voidinit()

      super.init();
      String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
      locator = new InvokerLocator(clientBindUrl);
   
protected voidinitializeJndiName()

      jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
   
public voidsetRemoteBinding(org.jboss.annotation.ejb.RemoteBinding binding)


      
   
      this.binding = binding;
   
public voidstart()

      super.start();
      EJBContainer statelessContainer = (EJBContainer) container;
      RemoteHome remoteHome = (RemoteHome) statelessContainer
            .resolveAnnotation(RemoteHome.class);
      if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
      {
         Object homeProxy = createHomeProxy(remoteHome.value());
         try {
            Util.rebind(container.getInitialContext(), ProxyFactoryHelper
                  .getHomeJndiName(container), homeProxy);
         }
         catch (NamingException e)
         {
            NamingException namingException = new NamingException(
                  "Could not bind stateless home proxy with ejb name "
                        + container.getEjbName()
                        + " into JNDI under jndiName: "
                        + container.getInitialContext().getNameInNamespace()
                        + "/" + ProxyFactoryHelper.getHomeJndiName(container));
            namingException.setRootCause(e);
            throw namingException;
         }

      }
   
public voidstop()

      super.stop();
      EJBContainer statelessContainer = (EJBContainer) container;
      RemoteHome remoteHome = (RemoteHome) statelessContainer
            .resolveAnnotation(RemoteHome.class);
      if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
      {
         Util.unbind(container.getInitialContext(), ProxyFactoryHelper
               .getHomeJndiName(container));
      }