throws Exception
{
String proxyFamilyName = objectId.toString() + locator.getProtocol() + partitionName;
HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);
HATarget target = null;
Map families = null;
InstanceAdvisor advisor = null;
Class clazz;
if (obj instanceof Advised)
{
advisor = ((Advised) obj)._getInstanceAdvisor();
clazz = obj.getClass();
Dispatcher.singleton.registerTarget(objectId, obj);
}
else
{
clazz = obj.getClass();
ClassProxy proxy = ClassProxyFactory.newInstance(obj.getClass());
advisor = proxy._getInstanceAdvisor();
advisor.insertInterceptor(new ForwardingInterceptor(obj));
Dispatcher.singleton.registerTarget(objectId, proxy);
}
families = (Map) advisor.getMetaData().getMetaData(CLUSTERED_REMOTING, CLUSTER_FAMILIES);
if (families != null)
{
target = (HATarget) families.get(proxyFamilyName);
if (target == null)
{
target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList());
families.put(proxyFamilyName, target);
}
}
else
{
families = new HashMap();
target = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
ClusteringTargetsRepository.initTarget(proxyFamilyName, target.getReplicantList());
families.put(proxyFamilyName, target);
advisor.insertInterceptor(0, new ReplicantsManagerInterceptor(families));
}
ClassProxy proxy = ClassProxyFactory.newInstance(clazz);
InstanceAdvisor proxyAdvisor = proxy._getInstanceAdvisor();
proxyAdvisor.insertInterceptor(IsLocalInterceptor.singleton);
advisor.insertInterceptor(SecurityClientInterceptor.singleton);
advisor.insertInterceptor(ClientTxPropagationInterceptor.singleton);
proxyAdvisor.insertInterceptor(MergeMetaDataInterceptor.singleton);
proxyAdvisor.insertInterceptor(ClusterChooserInterceptor.singleton);
proxyAdvisor.insertInterceptor(InvokeRemoteInterceptor.singleton);
proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
CLUSTER_FAMILY_WRAPPER,
new FamilyWrapper(proxyFamilyName, target.getReplicantList()),
PayloadKey.AS_IS);
// LB policy should be AS_IS so that remoting framework downloads the classes
proxyAdvisor.getMetaData().addMetaData(CLUSTERED_REMOTING,
LOADBALANCE_POLICY,