public void start() throws Exception
{
this.init();
InvokerLocator locator = this.getLocator();
SessionContainer container = this.getContainer();
partitionName = container.getPartitionName();
proxyFamilyName = container.getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, container.getInitialContextProperties());
drm = partition.getDistributedReplicantManager();
hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
container.getClusterFamilies().put(proxyFamilyName, hatarget);
if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
{
lbPolicy = new FirstAvailable();
}
else
{
String policyClass = clustered.loadBalancePolicy();
try
{
RemoteProxyFactoryRegistry registry = container.getDeployment().getRemoteProxyFactoryRegistry();
Class<LoadBalancePolicy> policy = registry.getLoadBalancePolicy(policyClass);
policyClass = policy.getName();
}
catch (LoadBalancePolicyNotRegisteredException e){}
lbPolicy = (LoadBalancePolicy)Thread.currentThread().getContextClassLoader().loadClass(policyClass)
.newInstance();
}
wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
drm.registerListener(proxyFamilyName, this);
super.start();
// Set up the proxy to ourself. Needs to be clustered so it can load
// balance requests (EJBTHREE-1375). We use the home load balance policy.
LoadBalancePolicy factoryLBP = null;
if (clustered.homeLoadBalancePolicy() == null || clustered.homeLoadBalancePolicy().equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
{
factoryLBP = new RoundRobin();
}
else
{
String policyClass = clustered.homeLoadBalancePolicy();
try
{
RemoteProxyFactoryRegistry registry = container.getDeployment().getRemoteProxyFactoryRegistry();
Class<LoadBalancePolicy> policy = registry.getLoadBalancePolicy(policyClass);
policyClass = policy.getName();
}
catch (LoadBalancePolicyNotRegisteredException e){}