org.softamis.cluster4spring.rmi.support
Class RmiEndpointFactory<SI extends ServiceMoniker>

java.lang.Object
  extended by org.softamis.cluster4spring.rmi.support.RmiEndpointFactory<SI>
Type Parameters:
SI - - information about service.
All Implemented Interfaces:
EndpointFactory<RmiEndpoint<SI>,SI>

public class RmiEndpointFactory<SI extends ServiceMoniker>
extends java.lang.Object
implements EndpointFactory<RmiEndpoint<SI>,SI>

Endpoint factory used to create RMI related endpoints.

Author:
Andrew Sazonov

Field Summary
static java.lang.String RMI_PROTOCOL_PREFIX
          Prefix used for constructing full RMI specific URL.
 
Constructor Summary
RmiEndpointFactory()
           
 
Method Summary
protected  RmiEndpoint<SI> createRmiEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, java.lang.String aEndpointKey, SI aServiceInfo, java.rmi.Remote aRemote)
          Creates RMIEndpoint using given parameters
 RmiEndpoint<SI> createServiceEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aFactory, java.lang.String aBeanName, SI aServiceInfo)
          Creates endpoint for cluster4spring protocol supported by particular factory.
 java.lang.String getServiceUrl(SI aServiceInfo)
          Returns URL used to lookup remote object.
protected  java.rmi.Remote obtainRemoteStub(java.lang.String aBeanName, SI aServiceInfo)
          Obtains remote stub based on given information about service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RMI_PROTOCOL_PREFIX

public static final java.lang.String RMI_PROTOCOL_PREFIX
Prefix used for constructing full RMI specific URL. This implementation assumes that if URL for service does not start with standard RMI related protocol (rmi://) it will append it first.

See Also:
Constant Field Values
Constructor Detail

RmiEndpointFactory

public RmiEndpointFactory()
Method Detail

createServiceEndpoint

public RmiEndpoint<SI> createServiceEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aFactory,
                                             java.lang.String aBeanName,
                                             SI aServiceInfo)
                                                             throws org.springframework.remoting.RemoteAccessException
Creates endpoint for cluster4spring protocol supported by particular factory. Method tries to obtain remote object based on information provided and if remote object is located, creates RMIEndpoint.

Specified by:
createServiceEndpoint in interface EndpointFactory<RmiEndpoint<SI extends ServiceMoniker>,SI extends ServiceMoniker>
Parameters:
aFactory - factory used to create remote invocations
aBeanName - name of bean/service
aServiceInfo - information about remote service
Returns:
created endpoint
Throws:
org.springframework.remoting.RemoteAccessException - thrown if endpoint could not be created.
See Also:
obtainRemoteStub(String, ServiceMoniker), createRmiEndpoint(org.springframework.remoting.support.RemoteInvocationFactory, String, ServiceMoniker, java.rmi.Remote)

createRmiEndpoint

protected RmiEndpoint<SI> createRmiEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
                                            java.lang.String aEndpointKey,
                                            SI aServiceInfo,
                                            java.rmi.Remote aRemote)
Creates RMIEndpoint using given parameters

Parameters:
aRemoteInvocationFactory - factory used to create remote invocation
aEndpointKey - endpoint key
aServiceInfo - information about service
aRemote - remote object used by RMIEndpoint
Returns:
Create RMIEndpoint

obtainRemoteStub

protected java.rmi.Remote obtainRemoteStub(java.lang.String aBeanName,
                                           SI aServiceInfo)
                                    throws java.rmi.NotBoundException,
                                           java.net.MalformedURLException,
                                           java.rmi.RemoteException
Obtains remote stub based on given information about service. First method tries to determine url of remote object and based on them tries to perform usual lookup of RMI remote object.

Parameters:
aBeanName - name of proxy bean
aServiceInfo - information about service (remote object)
Returns:
remote object
Throws:
java.rmi.NotBoundException
java.net.MalformedURLException
java.rmi.RemoteException
See Also:
getServiceUrl(ServiceMoniker)

getServiceUrl

public java.lang.String getServiceUrl(SI aServiceInfo)
Returns URL used to lookup remote object. Current implementation assumes that given service info represents either string with traditional RMI url in form "rmi://server_name:port/remote_object_name" or short form of url (one which starts without rmi:// protocol prefix

Parameters:
aServiceInfo - service info
Returns:
url of remote object