tw.net.ocs
Class OCSInterfaceProxyFactory

java.lang.Object
  extended by tw.net.ocs.OCSInterfaceProxyFactory

public class OCSInterfaceProxyFactory
extends java.lang.Object

Generates interface proxies through which server-side subjects may be called.

Author:
Tillmann Wegst

Method Summary
static java.lang.Object generateProxyFor(java.lang.Class[] interfaces, java.lang.Class subjectClass, java.lang.String subjectID)
           Creates an object which implements one or more interfaces and functions as a proxy of a server-side subject.
static java.lang.Object generateProxyFor(java.lang.Class[] interfaces, java.lang.Class subjectClass, java.lang.String subjectID, OCSClient ocsClient, boolean checkMethodMatch)
           Creates an object which implements one or more interfaces and functions as a proxy of a server-side subject.
static java.lang.Object generateProxyFor(java.lang.Class interfce, java.lang.Class subjectClass, java.lang.String subjectID)
           Creates an object which implements an interface and functions as a proxy of a server-side subject.
static java.lang.Object generateProxyFor(java.lang.Class interfce, java.lang.Class subjectClass, java.lang.String subjectID, OCSClient ocsClient, boolean checkMethodMatch)
           Creates an object which implements an interface and allows to call a server-side subject.
static void init(OCSClient ocsClient)
           Optionally initializes the factory by setting an OCSClient to use in the absence of an explicit specification.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init(OCSClient ocsClient)
Optionally initializes the factory by
setting an OCSClient to use in the absence
of an explicit specification.

If not set and no OCSClient is specified with
the proxy creation, the OCSClient standard instance
will be used.
                

Parameters:
ocsClient - the OCSClient to use if none is specified in a proxy creation call

generateProxyFor

public static java.lang.Object generateProxyFor(java.lang.Class[] interfaces,
                                                java.lang.Class subjectClass,
                                                java.lang.String subjectID,
                                                OCSClient ocsClient,
                                                boolean checkMethodMatch)
                                         throws OCSException
Creates an object which implements one or more interfaces
and functions as a proxy of a server-side subject.

The object can be cast to each of the interfaces in order
to call the methods declared by an interface. A method call
is executed by delegating it to a server-side subject of
the specified class.

By specifying its ID, the interface proxy can be made to call
a particular subject. If no ID is given, the proxy will attach
to an arbitrary instance of the subject class.

Note that a subject class need not officially implement an
interface in order to qualify as a legal addressee of an
interface proxy! It suffices that it provides the methods
declared in the interface.
The subject needs not even provide every method of the interface:
As long as a missing method never gets called, no havoc will result.

Optionally, the subject class can be checked to make sure it
implements every method declared in the interfaces: if this check
fails, an OCSException is thrown.
Omitting this check is legal; however, calling an interface method
which is missing in the subject will result in an OCSRuntimeException
being thrown.

Note that, other than class proxies, interface proxies cannot
create subjects, but only call subjects already available on
the server. Subjects to be addressed by interface proxies must
therefore be provided by other means.

Communication to the server side is mediated by an OCSClient.
If none is specified, a possible instance installed in the
factory is used, otherwise the standard OCSClient instance.

Note that in addition to the interface/s specified as the
first argument, the created interface proxy also implements
the methods declared in interface OCSInterfaceProxy and its
parent interface OCSProxy.
                

Parameters:
interfaces - the interfaces that the proxy should implement
subjectClass - class of the server-side subject
subjectID - ID of the subject (may be null)
ocsClient - the OCSClient to use for communication with the server
checkMethodMatch - ensure that the subject class implements every method declared in the interfaces?
Returns:
an object which can be cast to each of the interfaces
Throws:
OCSException - if the subject class is required to implement all the interface's methods and does not
OCSRuntimeException - in case of an error on the server side
See Also:
OCSInterfaceProxy, OCSProxy, OCSServer.addSubject(java.lang.Object, java.lang.Class, java.lang.String, boolean, boolean)

generateProxyFor

public static java.lang.Object generateProxyFor(java.lang.Class[] interfaces,
                                                java.lang.Class subjectClass,
                                                java.lang.String subjectID)
                                         throws OCSException
Creates an object which implements one or more interfaces
and functions as a proxy of a server-side subject.

For communication with the server, a possible OCSClient instance
installed in the factory is used, otherwise the standard instance
accessible in class OCSClient.

The subject class gets checked whether it implements every method
declared in the interfaces. If it does not, an OCSException is thrown.

(See another overload of this method for a more detailed description.)
                

Parameters:
interfaces - the interfaces that the proxy shall implement
subjectClass - class of the server-side subject
subjectID - ID of the subject
Returns:
an object which can be cast to and implements all of the interfaces
Throws:
OCSException - if the subject class is required to match the interface methods and does not
OCSRuntimeException - in case of an error on the server side
See Also:
generateProxyFor(java.lang.Class[],java.lang.Class,java.lang.String,tw.net.ocs.OCSClient,boolean), OCSInterfaceProxy, OCSProxy

generateProxyFor

public static java.lang.Object generateProxyFor(java.lang.Class interfce,
                                                java.lang.Class subjectClass,
                                                java.lang.String subjectID,
                                                OCSClient ocsClient,
                                                boolean checkMethodMatch)
                                         throws OCSException
Creates an object which implements an interface
and allows to call a server-side subject.

The object can be cast to the interfaces in order
to call the methods declared by it. A method call
is executed by delegating it to a server-side subject of
the specified class.

By specifying its ID, the interface proxy can be made to call
a particular subject. If no ID is given, the proxy will call
an arbitrary instance of the subject class.

Note that the subject class need not officially implement the
interface in order to qualify as a legal addressee of an
interface proxy! It suffices that it provide the methods
declared in the interface.
The subject need not even provide every method of the interface:
as long as a missing method never gets called, no havoc will result.

Optionally, the subject class can be checked to make sure it
implements every method declared in the interface: if this check
fails, an OCSException is thrown.
Omitting this check is legal; however, calling an interface method
which is missing in the subject will result in an OCSRuntimeException
being thrown.

Note that, other than class proxies, interface proxies cannot
create subjects, but only call subjects already available on
the server. Subjects to be addressed by interface proxies must
therefore be provided by other means.

Communication to the server side is mediated by an OCSClient.
If none is specified, a possible instance installed in the
factory is used, otherwise the standard OCSClient instance.

Note that in addition to the interface specified as the first
argument, the created interface proxy also implements
the methods declared in interface OCSInterfaceProxy and its
parent interface OCSProxy. 
                

Parameters:
interfce - the interface that the proxy shall implement
subjectClass - class of the server side subject
subjectID - ID of the subject
ocsClient - the OCSClient to use for communication with the server
checkMethodMatch - ensure that the subject class implements the methods declared in the interface?
Returns:
an object which can be cast to and implements the methods in the interface
Throws:
OCSException - if the subject class is required to match the interface methods and does not
OCSRuntimeException - in case of an error on the server side
See Also:
generateProxyFor(java.lang.Class[],java.lang.Class,java.lang.String,tw.net.ocs.OCSClient,boolean), OCSInterfaceProxy, OCSProxy, OCSServer.addSubject(java.lang.Object, java.lang.Class, java.lang.String, boolean, boolean)

generateProxyFor

public static java.lang.Object generateProxyFor(java.lang.Class interfce,
                                                java.lang.Class subjectClass,
                                                java.lang.String subjectID)
                                         throws OCSException
Creates an object which implements an interface
and functions as a proxy of a server-side subject.

For communication with the server, a possible OCSClient instance
installed in the factory is used, otherwise the standard instance
accessible in class OCSClient.

The subject class gets checked whether it implements every method
declared in the interface. If it does not, an OCSException is thrown.

(See another overload of this method for a more detailed description.)
                

Parameters:
interfce - the interface that the proxy shall implement
subjectClass - class of the server side subject
subjectID - ID of the subject
Returns:
an object which can be cast to and implements the methods in the interface
Throws:
OCSException - if the subject class is required to match the interface methods and does not
OCSRuntimeException - in case of an error on the server side
See Also:
generateProxyFor(java.lang.Class,java.lang.Class,java.lang.String,tw.net.ocs.OCSClient,boolean), OCSInterfaceProxy, OCSProxy


OCSelot @ www.ocselot.net www.ocselot.net