Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*     */ package org.jboss.ejb3.stateful;
  /*     */ 
  /*     */ import java.util.ArrayList;
  /*     */ import java.util.List;
  /*     */ import java.util.Map;
  /*     */ import javax.naming.InitialContext;
  /*     */ import javax.naming.NamingException;
  /*     */ import org.jboss.aop.Advisor;
  /*     */ import org.jboss.aop.AspectManager;
 /*     */ import org.jboss.aop.Dispatcher;
 /*     */ import org.jboss.aop.advice.AdviceStack;
 /*     */ import org.jboss.aspects.remoting.Remoting;
 /*     */ import org.jboss.ejb3.Container;
 /*     */ import org.jboss.ejb3.JBossProxy;
 /*     */ import org.jboss.ejb3.ProxyFactory;
 /*     */ import org.jboss.ejb3.ProxyFactoryHelper;
 /*     */ import org.jboss.ejb3.annotation.Clustered;
 /*     */ import  org.jboss.ha.framework.interfaces.DistributedReplicantManager;
 /*     */ import  org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener;
 /*     */ import  org.jboss.ha.framework.interfaces.HAPartition;
 /*     */ import  org.jboss.ha.framework.server.HATarget;
 /*     */ import org.jboss.logging.Logger;
 /*     */ import org.jboss.naming.Util;
 /*     */ import org.jboss.remoting.InvokerLocator;
 /*     */ 
 /*     */ public class StatefulClusterProxyFactory extends BaseStatefulProxyFactory
 /*     */   implements RemoteProxyFactory, DistributedReplicantManager.ReplicantListener
 /*     */ {
 /*     */   private static final Logger log;
 /*     */   private RemoteBinding binding;
 /*     */   private Clustered clustered;
 /*     */   private InvokerLocator locator;
 /*     */   private DistributedReplicantManager drm;
 /*     */   private HATarget hatarget;
 /*     */   private String proxyFamilyName;
 /*     */   private LoadBalancePolicy lbPolicy;
 /*     */   private FamilyWrapper wrapper;
 /*     */ 
 /*     */   public StatefulClusterProxyFactory(SessionContainer containerRemoteBinding bindingClustered clustered)
 /*     */   {
 /*  79 */     super(containerbinding.jndiBinding());
 /*     */ 
 /*  81 */     assert (clustered != null) : "clustered is null";
 /*     */ 
 /*  83 */     this. = binding;
 /*  84 */     this. = clustered;
 /*     */   }
 /*     */ 
 /*     */   protected Class[] getInterfaces()
 /*     */   {
 /*  89 */     Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer());
 /*  90 */     Class[] interfaces = new Class[remoteInterfaces.length + 1];
 /*  91 */     System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
 /*  92 */     interfaces[remoteInterfaces.length] = JBossProxy.class;
 /*  93 */     return interfaces;
 /*     */   }
 /*     */ 
 /*     */   public void start() throws Exception
 /*     */   {
 /*  98 */     String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(this.);
 /*  99 */     this. = new InvokerLocator(clientBindUrl);
 /* 100 */     String partitionName = ((SessionContainer)getContainer()).getPartitionName();
 /* 101 */     this. = (((SessionContainer)getContainer()).getDeploymentQualifiedName() + this..getProtocol() + partitionName);
 /* 102 */     HAPartition partition = (HAPartition)getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
 /* 103 */     this. = new HATarget(partitionthis.this., 2);
 /* 104 */     ClusteringTargetsRepository.initTarget(this.this..getReplicants());
 /* 106 */     if ((this..loadBalancePolicy() == null) || (this..loadBalancePolicy().equals(LoadBalancePolicy.class)))
 /*     */     {
 /* 108 */       this. = new FirstAvailable();
 /*     */     }
 /*     */     else
 /*     */     {
 /* 112 */       this. = ((LoadBalancePolicy)this..loadBalancePolicy().newInstance());
 /*     */     }
 /* 114 */     this. = new FamilyWrapper(this.this..getReplicants());
 /*     */ 
 /* 116 */     this. = partition.getDistributedReplicantManager();
 /* 117 */     this..registerListener(this.this);
 /*     */ 
 /* 119 */     super.start();
 /*     */ 
 /* 121 */     Class[] interfaces = { ProxyFactory.class };
 /* 122 */     String targetId = getTargetId();
 /* 123 */     Object factoryProxy = Remoting.createPojiProxy(targetIdinterfaces, ProxyFactoryHelper.getClientBindUrl(this.));
 /*     */     try
 /*     */     {
 /* 126 */       Util.rebind(getContainer().getInitialContext(), this. + "StatefulProxyFactory"factoryProxy);
 /*     */     }
 /*     */     catch (NamingException e) {
 /* 129 */       NamingException namingException = new NamingException("Could not bind stateful cluster proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + this. + "StatefulProxyFactory");
/* 130 */       namingException.setRootCause(e);
/* 131 */       throw namingException;
/*     */     }
/* 133 */     assert (!..isRegistered(targetId)) : (targetId + " is already registered");
/* 134 */     ..registerTarget(targetIdthis);
/*     */   }
/*     */ 
/*     */   public Object createProxy()
/*     */   {
/* 140 */     String stackName = "ClusteredStatefulSessionClientInterceptors";
/* 141 */     if ((this..interceptorStack() != null) && (!this..interceptorStack().equals("")))
/*     */     {
/* 143 */       stackName = this..interceptorStack();
/*     */     }
/* 145 */     AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
/* 146 */     String partitionName = ((SessionContainer)getContainer()).getPartitionName();
/* 147 */     return constructProxy(new StatefulClusteredProxy(getContainer(), stack.createInterceptors((Advisor)getContainer(), null), this.this.partitionName));
/*     */   }
/*     */ 
/*     */   public Object createProxy(Object id)
/*     */   {
/* 153 */     throw new RuntimeException("NYI");
/*     */   }
/*     */ 
/*     */   public void stop() throws Exception
/*     */   {
/* 159 */     this..destroy();
/* 160 */     this..unregisterListener(this.this);
/* 162 */     Util.unbind(getContainer().getInitialContext(), this. + "StatefulProxyFactory");
/* 163 */     super.stop();
/*     */   }
/*     */ 
/*     */   protected StatefulHandleImpl getHandle()
/*     */   {
/* 168 */     StatefulHandleImpl handle = new StatefulHandleImpl();
/* 169 */     RemoteBinding remoteBinding = (RemoteBinding)((Advisor)getContainer()).resolveAnnotation(RemoteBinding.class);
/* 170 */     if (remoteBinding != null) {
/* 171 */       handle.jndiName = remoteBinding.jndiBinding();
/*     */     }
/* 173 */     return handle;
/*     */   }
/*     */ 
/*     */   protected String getTargetId()
/*     */   {
/* 181 */     assert (this. != null) : "jndiName is null";
/* 182 */     String partition = ((SessionContainer)getContainer()).getPartitionName();
/* 183 */     return this. + "StatefulProxyFactory" + "@" + partition;
/*     */   }
/*     */ 
/*     */   public synchronized void replicantsChanged(String keyList newReplicantsint newReplicantsViewId)
/*     */   {
/*     */     try
/*     */     {
/* 193 */       ArrayList targets = new ArrayList(newReplicants);
/* 194 */       this..get().updateClusterInfo(targetsnewReplicantsViewId);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 198 */       .error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   static
/*     */   {
/*  64 */      = Logger.getLogger(StatefulClusterProxyFactory.class);
/*     */   }
/*     */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/jboss-embedded-all.jar
 * Qualified Name:     org.jboss.ejb3.stateful.StatefulClusterProxyFactory
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X