public HARMIServerImpl(HAPartition partition,
String replicantName,
Class intf,
Object handler) throws Exception {
this(partition, replicantName, intf, handler, 0, null, null);
}
Create a new HARMIServer implementation that will act as a RMI end-point for a specific server. Parameters:
partition - HAPartition that will determine the cluster member
replicantName - Name of the service using this HARMIServer
intf - Class type under which should appear the RMI server dynamically built
handler - Target object to which calls will be forwarded
Throws:
Exception - Thrown if any exception occurs during call forwarding
|
public HARMIServerImpl(HAPartition partition,
String replicantName,
Class intf,
Object handler,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf) throws Exception {
this(partition,
replicantName,
intf,
handler,
port,
csf,
ssf,
null);
}
|
public HARMIServerImpl(HAPartition partition,
String replicantName,
Class intf,
Object handler,
int port,
RMIClientSocketFactory clientSocketFactory,
RMIServerSocketFactory serverSocketFactory,
InetAddress bindAddress) throws Exception {
this.handler = handler;
this.log = Logger.getLogger(this.getClass());
this.intf = intf;
this.key = partition.getPartitionName() + "/" + replicantName;
// Obtain the hashes for the supported handler interfaces
Class[] ifaces = handler.getClass().getInterfaces();
for (int i = 0; i < ifaces.length; i++)
{
Map tmp = MarshalledInvocation.methodToHashesMap(ifaces[i]);
invokerMap.putAll(tmp);
}
if( bindAddress != null )
{
// If there is no serverSocketFactory use a default
if( serverSocketFactory == null )
serverSocketFactory = new DefaultSocketFactory(bindAddress);
else
{
// See if the server socket supports setBindAddress(String)
try
{
Class[] parameterTypes = {String.class};
Class ssfClass = serverSocketFactory.getClass();
Method m = ssfClass.getMethod("setBindAddress", parameterTypes);
Object[] args = {bindAddress.getHostAddress()};
m.invoke(serverSocketFactory, args);
}
catch (NoSuchMethodException e)
{
log.warn("Socket factory does not support setBindAddress(String)");
// Go with default address
}
catch (Exception e)
{
log.warn("Failed to setBindAddress="+bindAddress+" on socket factory", e);
// Go with default address
}
}
}
this.rmistub = (RemoteStub)UnicastRemoteObject.exportObject(this, port, clientSocketFactory, serverSocketFactory);// casting is necessary because interface has changed in JDK >=1.2
this.target = new RefreshProxiesHATarget(partition, replicantName, rmistub, HATarget.ENABLE_INVOCATIONS);
HARMIServer.rmiServers.put(key, this);
}
|