com.alachisoft.ncache.client.internal.communication.DistributedCallBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.client.internal.communication;
import Alachisoft.NCache.Common.Communication.IChannelFormatter;
import Alachisoft.NCache.Common.Extensibility.Client.RPC.*;
import Alachisoft.NCache.Common.Extensibility.Client.RPC.Impl.MultiPartitionMethodCall;
import java.util.Map;
class DistributedCallBuilder implements IRPCCallBuilder {
private RPCTransport _tranport;
private IChannelFormatter _formtter;
public DistributedCallBuilder(RPCTransport transport, IChannelFormatter formatter) {
this._formtter = formatter;
this._tranport = transport;
}
public final IRPCConstructorCall BuildConstructorCall(java.lang.Class objectType, String objectUID, Object[] arguments) {
DistributedConstructorCall constructorCall = new DistributedConstructorCall(_tranport, _formtter);
constructorCall.SetObjectUid(objectUID);
constructorCall.SetObjectType(objectType);
for (Partition partition : _tranport.GetPartitioningStrategy().GetAllPartitions()) {
constructorCall.AddArguments(partition, arguments);
}
return constructorCall;
}
public final IRPCMethodCall BuildMethodCall(java.lang.Class serverInstanceType, String method, int overload, boolean isStatic, Object[] arguments, String objectUID, IMethodArgumentPartitioner argumentPartitioner, IResponseConsolidator consolidator) {
DistributedMethodCall methodCall = new DistributedMethodCall(_tranport, _formtter);
methodCall.method = method;
methodCall.overload = overload;
methodCall.objectUID = objectUID;
methodCall.consolidator = consolidator;
methodCall.isStatic = isStatic;
methodCall.instanceType = serverInstanceType;
if (argumentPartitioner != null) {
Iterable> partitionWiseArguments = argumentPartitioner.PartitionArguments(arguments, _tranport.GetPartitioningStrategy());
for (Map.Entry partitionArguments : partitionWiseArguments) {
methodCall.AddArguments(partitionArguments.getKey(), partitionArguments.getValue());
}
}
return methodCall;
}
public final MultiPartitionMethodCall BuildMultipartionMethodCall(String method, int overload, Object[] arguments, String objectUID) {
throw new UnsupportedOperationException();
}
public final IRPCPropertyCall BuildPropertyGetterCall(String property, String objectUID) {
return BuildPropertyCallInternal(property, objectUID);
}
public final IRPCPropertyCall BuildPropertySetterCall(String property, Object value, String objectUID) {
IRPCPropertyCall propertyCall = BuildPropertyCallInternal(property, objectUID, value);
propertyCall.setIsSetterCall(true);
return propertyCall;
}
private IRPCPropertyCall BuildPropertyCallInternal(String property, String objectUID) {
return BuildPropertyCallInternal(property, objectUID, null);
}
private IRPCPropertyCall BuildPropertyCallInternal(String property, String objectUID, Object value) {
DistributedPropertyCall propertyCall = new DistributedPropertyCall(_tranport, _formtter);
propertyCall.setObjectUID(objectUID);
propertyCall.setProperty(property);
for (Partition partition : _tranport.GetPartitioningStrategy().GetAllPartitions()) {
propertyCall.AddArguments(partition, value);
}
return propertyCall;
}
}