FileDocCategorySizeDatePackage
ProxyDeployer.javaAPI DocJBoss 4.2.16910Fri Jul 13 20:53:58 BST 2007org.jboss.ejb3

ProxyDeployer

public class ProxyDeployer extends Object
Comment
author
Bill Burke
version
$Revision: 57207 $

Fields Summary
private static final Logger
log
private Container
container
private org.jboss.aop.Advisor
advisor
private ArrayList
proxyFactories
private org.jboss.annotation.ejb.RemoteBindings
remoteBindings
private org.jboss.annotation.ejb.LocalBinding
localBinding
Constructors Summary
public ProxyDeployer(Container container)


     
   
      this.container = container;
      this.advisor = (Advisor) container;
   
Methods Summary
private java.lang.ClassgetDefaultRemoteProxyFactory()

      Class factory;
      if (container instanceof StatefulContainer)
      {
         if (advisor.resolveAnnotation(Clustered.class) != null)
         {
            factory = StatefulClusterProxyFactory.class;
         }
         else
         {
            factory = StatefulRemoteProxyFactory.class;
         }
      }
      else if (container instanceof ServiceContainer)
      {
         //TODO Implement clustering
         factory = ServiceRemoteProxyFactory.class;
      }
      else
      {
         if (advisor.resolveAnnotation(Clustered.class) != null)
         {
            factory = StatelessClusterProxyFactory.class;
         }
         else
         {
            factory = StatelessRemoteProxyFactory.class;
         }
      }
      return factory;
   
public java.util.ListgetProxyFactories()

 return proxyFactories; 
public voidinitializeLocalBindingMetadata()

      localBinding = (LocalBinding) advisor.resolveAnnotation(LocalBinding.class);
      if (localBinding == null)
      {
         if (ProxyFactoryHelper.getLocalInterfaces(container) != null)
         {
            localBinding = new LocalBindingImpl(ProxyFactoryHelper.getLocalJndiName(container));
            advisor.getAnnotations().addClassAnnotation(LocalBinding.class, localBinding);
         }
      }
   
public voidinitializeRemoteBindingMetadata()

      remoteBindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
      if (remoteBindings == null)
      {
         RemoteBinding binding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
         if (binding == null)
         {
            log.debug("no declared remote bindings for : " + container.getEjbName());
            if (ProxyFactoryHelper.getRemoteInterfaces(container) != null)
            {
               log.debug("there is remote interfaces for " + container.getEjbName());
               String jndiName = ProxyFactoryHelper.getDefaultRemoteJndiName(container);
               log.debug("default remote binding has jndiName of " + jndiName);
               String uri = ""; // use the default
               Class factory = null;
               factory = getDefaultRemoteProxyFactory();
               RemoteBinding[] list = {new RemoteBindingImpl(jndiName, "", uri, factory)};
               remoteBindings = new RemoteBindingsImpl(list);
               advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
            }
         }
         else
         {
            RemoteBinding[] list = {binding};
            remoteBindings = new RemoteBindingsImpl(list);
            advisor.getAnnotations().addClassAnnotation(RemoteBindings.class, remoteBindings);
         }
      }
   
public voidstart()

      if (remoteBindings != null)
      {
         RemoteBinding[] list = remoteBindings.value();
         for (int i = 0; i < list.length; i++)
         {
            Class factoryClass = list[i].factory();
            if (factoryClass.equals(RemoteProxyFactory.class)) factoryClass = getDefaultRemoteProxyFactory();
            RemoteProxyFactory factory = (RemoteProxyFactory) factoryClass.newInstance();
            factory.setRemoteBinding(list[i]);
            factory.setContainer(container);
            factory.start();
            proxyFactories.add(factory);
         }
      }

      if (localBinding != null)
      {
         ProxyFactory factory = null;
         if (container instanceof StatefulContainer)
         {
            factory = new StatefulLocalProxyFactory();
         }
         else if (container instanceof ServiceContainer)
         {
            factory = new ServiceLocalProxyFactory();
         }
         else
         {
            factory = new StatelessLocalProxyFactory();
         }

         factory.setContainer(container);
         factory.start();
         proxyFactories.add(factory);
      }
   
public voidstop()

      for (int i = 0; i < proxyFactories.size(); i++)
      {
         ProxyFactory factory = (ProxyFactory) proxyFactories.get(i);
         factory.stop();
      }