|
Openwings API Documentation (v1.1) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This interface is the centerpiece of the service-based
component architecture provided by Openwings. The
Component interface abstracts the details of using
synchronous (method based) and asynchronous (messaging or
event based) communication between components.
Synchronous services are provided or used by components. These semantics unite the provide/use semantics of the EJB Component model and the discovery/join/lookup semantics of the Jini architecture.
Asynchronous services are published or subscribed to by components. These semantics abstract the details of event spaces in various 3rd party messaging protocols.
| Method Summary | |
void |
connectDistributedObject(java.lang.Object serviceObject)
This method can be used on the client side of a connection to enable a distributed object to be used. |
void |
discardUsedService(UniqueID serviceID)
This method releases a synchronous (remote method) service provided by another component. |
void |
disconnectDistributedObject(java.lang.Object serviceObject)
This method can be used on the client side of a connection to disable the connection of a distributed object. |
java.lang.Object |
distributeObject(java.lang.Class serviceInterface,
java.lang.Object service)
This method is used to make an object available remotely. |
java.lang.Object |
distributeObject(java.lang.Class serviceInterface,
java.lang.Object service,
java.lang.Class connectorInterface)
This method is used to make an object available remotely. |
ComponentDescriptor |
getComponentDescriptor()
This method is used to retrieve metadata about a component |
UniqueID |
getComponentID()
This method is used to retrieve a unique identifier for the component. |
UniqueID |
provideService(java.lang.Class serviceInterface,
java.lang.Object service)
This method is used to make a synchronous (remote method) service available to other components (join). |
void |
provideService(java.lang.Class serviceInterface,
java.lang.Object service,
UniqueID uniqueID)
This method is used to make a synchronous (remote method) service available to other components (join). |
ServiceResult |
publishService(java.lang.Class serviceInterface)
This method is used to indicate that the component will publish an asynchronous (event or messaging) service. |
void |
publishService(java.lang.Class serviceInterface,
EventServiceListener listener)
This method registers for notification of the ability to publish an asynchronous (event or messaging) service. |
void |
removeEventServiceListener(java.lang.Class serviceInterface,
EventServiceListener listener)
This method stops notification of asynchronous (event or messaging) services created by other components. |
void |
removeProvidedService(UniqueID serviceID)
This method is used to make a synchronous (remote method) service unavailable for use by other components. |
void |
removeUseServiceListener(java.lang.Class serviceInterface,
UseServiceListener listener)
This method stops notification of synchronous services provided by other components. |
void |
shutdown()
This method is used to terminate all service connections and processing provided by a Component. |
UniqueID |
subscribeService(java.lang.Class serviceInterface,
java.lang.Object service)
This method is used to subscribe to a an asynchronous (event or messaging) service. |
void |
subscribeService(java.lang.Class serviceInterface,
java.lang.Object service,
EventServiceListener listener)
This method registers for notification of the ability to subscribe to an asynchronous (event or messaging) service. |
void |
undistributeObject(java.lang.Class serviceInterface,
java.lang.Object service)
This method is used to make an object unavailable remotely. |
void |
unpublishService(UniqueID serviceID)
This method is used to indicate that the component will no longer publish an asynchronous (event or messaging) service. |
void |
unsubscribeService(UniqueID serviceID)
This method is used to stop subscription to a an asynchronous (event or messaging) service. |
ServiceResult |
useService(java.lang.Class serviceInterface)
This method finds a synchronous (remote method) service provided by another component (lookup). |
void |
useService(java.lang.Class serviceInterface,
UseServiceListener listener)
This method registers for notification of synchronous (remote method) services provided other components (lookup). |
| Method Detail |
public UniqueID provideService(java.lang.Class serviceInterface,
java.lang.Object service)
throws InvalidServiceException
Repeated calls to this method with identical parameters have
no effect unless removeProvidedService() has
been called.
A service object that is intended to receive remote calls
should be a distributed object, that is, an object returned
from the distributeObject() method.
If a service is provided with the correct serviceInterface
and service but there is a problem with a particular
discovery plug-in, no Exception is thrown.
Instead the component continues using other discovery plug-ins to
try to provide the service.
serviceInterface - interface describing the service
providedservice - object implementing the specified interface
InvalidServiceException - thrown if service
does not implement Serializable and
serviceInterface
public void provideService(java.lang.Class serviceInterface,
java.lang.Object service,
UniqueID uniqueID)
throws InvalidServiceException
This method allows the uniqueID to be specified
Repeated calls to this method with identical parameters have
no effect unless removeProvidedService() has
been called.
A service object that is intended to receive remote calls
should be a distributed object, that is, an object returned
from the distributeObject() method.
If a service is provided with the correct serviceInterface
and service but there is a problem with a particular
discovery plug-in, no Exception is thrown.
Instead the component continues using other discovery plug-ins to
try to provide the service.
serviceInterface - interface describing the service
providedservice - object implementing the specified interfaceuniqueID - unique identifier for the service
InvalidServiceException - thrown if service
does not implement Serializable and
serviceInterfacepublic void removeProvidedService(UniqueID serviceID)
undistributeObject() method must be called
to disconnect the service. Thus the service can be removed
as a means of limiting the number of users, and then provided
again later.
Repeated calls to this method with identical parameters have no effect.
serviceID - unique service identifier returned from
provideService()
public ServiceResult useService(java.lang.Class serviceInterface)
throws InvalidServiceException
Repeated calls to this method with the same
serviceInterface are not guaranteed to return different
service objects.
serviceInterface - interface describing the desired
service
null if the service could be located
InvalidServiceException - thrown if:
serviceInterface is not a valid interface
public void useService(java.lang.Class serviceInterface,
UseServiceListener listener)
throws InvalidServiceException
Repeated calls to this method with the same
serviceInterface and listener have no
effect.
serviceInterface - interface describing the desired
servicelistener - notification object
InvalidServiceException - thrown if
serviceInterface is not a valid interface
public void removeUseServiceListener(java.lang.Class serviceInterface,
UseServiceListener listener)
Pending callbacks may still be made to listener
due to race conditions.
Service objects previously passed to the serviceProvided()
method of listener are not affected by
this call.
Repeated calls to this method with identical parameters have no effect.
serviceInterface - interface describing the service
providedlistener - a UseServiceListener previously
passed to one of the useService() methods.
public java.lang.Object distributeObject(java.lang.Class serviceInterface,
java.lang.Object service)
throws InvalidServiceException
This can be used for objects provided as services or objects passed to or returned from services. For example, a component using a service uses this method to make an object available remotely so it can be passed to a service method. A component providing a service uses this method to make an object available remotely so it can be returned from a service method.
Repeated calls to this method with the same
serviceInterface and service
are guaranteed to return the same object.
Repeated calls to this method with the same service
but a different serviceInterface will return different
objects. This allows the same object to be provided as several
distinct services.
This method attempts to distribute an object using a
net.openwings.connnector.synchronous.SynchronousConnector.
If asynchronous behavior is needed, the other variant of
distributeObject should be used.
serviceInterface - interface describing the service
providedservice - object implementing the specified interface
net.openwings.connector.synchronous.UserProxy.
InvalidServiceException - thrown if service
does not implement serviceInterface
public java.lang.Object distributeObject(java.lang.Class serviceInterface,
java.lang.Object service,
java.lang.Class connectorInterface)
throws InvalidServiceException
This can be used for objects provided as services or objects passed to or returned from services. For example, a component using a service uses this method to make an object available remotely so it can be passed to a service method. A component providing a service uses this method to make an object available remotely so it can be returned from a service method.
Repeated calls to this method with the same
serviceInterface, service, and
connectorInterface
are guaranteed to return the same object.
Repeated calls to this method with the same service
but a different serviceInterface will return different
objects. This allows the same object to be provided as several
distinct services.
Repeated calls to this method with the same service
and serviceInterface, but a different
connectorInterface will return different
objects. Each new object will cause the previous to be replaced.
This method returns the type of connector specified in the
connectorInterface parameter. For example, if an
asynchronous connector is needed,
net.openwings.connector.asynchronous.AsynchronousConnector.class
could be used as the connectorInterface parameter.
serviceInterface - interface describing the service
providedservice - object implementing the specified interfaceconnectorInterface - class used to make the object available remotely
net.openwings.connector.SenderProxy
and one or more of its subinterfaces.
InvalidServiceException - thrown if service
does not implement serviceInterface
public void undistributeObject(java.lang.Class serviceInterface,
java.lang.Object service)
This can be used for objects provided as services or objects passed to or returned from services. For example, A component using a service uses this method to make an object previously passed to a service method unavailable to the service provider. A component providing a service uses this method to make an object previously returned from a service method unavailable to the service user.
Repeated calls to this method with identical parameters have no effect.
serviceInterface - interface describing the service
providedservice - object previously made available remotely
by calling distributeObject().
public void connectDistributedObject(java.lang.Object serviceObject)
throws java.rmi.RemoteException
connectDistributedObjectsImmediately parameter
in UseServiceParameters can be set to override this.
In that case, this method would be called to connect the
distributed object. This method is also useful when dealing with
a distributed object that is not a used service. For example,
many service interfaces allow callback objects to be passed.
To implement this behavior, the user of a service would call
distributeObject() to make their callback object available
remotely, pass the distributed object to the service, and the
service implementation would call connectDistributedObject()
to begin using the object.
serviceObject - a distributed object.
java.rmi.RemoteException
public void disconnectDistributedObject(java.lang.Object serviceObject)
throws java.rmi.RemoteException
discardUsedService().
This method is also useful when dealing with a distributed object that is not a used service.
serviceObject - a distributed object.
java.rmi.RemoteExceptionpublic void discardUsedService(UniqueID serviceID)
Repeated calls to this method with identical parameters have no effect.
Behavior of method calls on service after calling
this method is undefined, but will likely result in a
RemoteException being thrown.
serviceID - unique service identifier returned from
useService() or passed to
UseServiceListener.serviceProvided().
public ServiceResult publishService(java.lang.Class serviceInterface)
throws InvalidServiceException
Repeated calls to this method with identical parameters have
no effect unless unpublishService() has been called.
serviceInterface - interface describing the service
InvalidServiceException - thrown if
serviceInterface is not a valid interface
public void publishService(java.lang.Class serviceInterface,
EventServiceListener listener)
throws InvalidServiceException
EventServiceListener is notified when the desired
topic becomes available.
Repeated calls to this method with identical parameters have no
effect unless removeEventServiceListener() has been called.
serviceInterface - interface describing the servicelistener - notification object
InvalidServiceException - thrown if
serviceInterface is not a valid interfacepublic void unpublishService(UniqueID serviceID)
publishService(), it will be destroyed.
Repeated calls to this method with identical parameters have no effect.
public void removeEventServiceListener(java.lang.Class serviceInterface,
EventServiceListener listener)
Pending callbacks may still be made to listener
due to race conditions.
Service objects previously passed to the serviceAvailable()
method of listener are not affected by
this call.
Repeated calls to this method with identical parameters have no effect.
serviceInterface - interface describing the service
providedlistener - a EventServiceListener previously
passed to one of the publishService() /
subscribeService() methods.
public UniqueID subscribeService(java.lang.Class serviceInterface,
java.lang.Object service)
throws InvalidServiceException
Repeated calls to this method with identical parameters have
no effect unless unsubscribeService() has been called.
serviceInterface - interface describing the serviceservice - object implementing the specified interface that will
receive messages
InvalidServiceException - thrown if
service does not implement
serviceInterface
serviceInterface is not a valid interface
public void subscribeService(java.lang.Class serviceInterface,
java.lang.Object service,
EventServiceListener listener)
throws InvalidServiceException
EventServiceListener is notified when the desired
topic becomes available.
Repeated calls to this method with identical arguments have no effect
unless removeEventServiceListener() has been called.
serviceInterface - interface describing the serviceservice - object implementing the specified interfacelistener - notification object
InvalidServiceException - thrown if
service does not implement
serviceInterface
serviceInterfaceis not a valid interface
public void unsubscribeService(UniqueID serviceID)
Repeated calls to this method with identical parameters have no effect.
serviceID - unique service identifier for the topic returned from
subscribeService() or passed to
EventServiceListener.serviceSubscribed().public ComponentDescriptor getComponentDescriptor()
ComponentDescriptorpublic UniqueID getComponentID()
public void shutdown()
Component.
All objects that have been distributed by the
Component are undistributed. All services
provided by the Component are removed. All
services being used by the Component are
discarded. All services being published by the
Component are unpublished. All services the
Component subscribes to are unsubscribed.
Any threads created by the Component
implementation must exit. After this method is called,
any operation on the Component is undefined.
|
Openwings API Documentation (v1.1) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||