org.eclipse.ecf.provider.remoteservice.generic
Class RegistrySharedObject

java.lang.Object
  extended by org.eclipse.ecf.core.sharedobject.BaseSharedObject
      extended by org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IIdentifiable, org.eclipse.ecf.core.sharedobject.ISharedObject, IRemoteServiceContainerAdapter

public class RegistrySharedObject
extends org.eclipse.ecf.core.sharedobject.BaseSharedObject
implements IRemoteServiceContainerAdapter


Field Summary
protected  java.util.Map addRegistrationRequests
           
protected  RemoteServiceRegistryImpl localRegistry
           
protected  java.util.Map localServiceRegistrations
           
protected  java.util.Map remoteRegistrys
           
protected  java.util.List requests
           
protected  java.util.List serviceListeners
           
 
Fields inherited from class org.eclipse.ecf.core.sharedobject.BaseSharedObject
DESTROYREMOTE_CODE, DESTROYSELFLOCAL_CODE
 
Constructor Summary
RegistrySharedObject()
           
 
Method Summary
protected  RemoteServiceRegistryImpl addRemoteRegistry(RemoteServiceRegistryImpl registry)
          End message send/handlers
 void addRemoteServiceListener(IRemoteServiceListener listener)
          Add listener for remote service registration/unregistration for this container
protected  java.lang.Object callSynch(RemoteServiceRegistrationImpl registration, IRemoteCall call)
           
protected  void checkRequestServiceAuthorization(ID remoteContainerID, AddRegistrationRequest request, java.io.Serializable credentials)
           
protected  IRemoteServiceRegisteredEvent createRegisteredEvent(RemoteServiceRegistrationImpl registration)
           
protected  IRemoteServiceUnregisteredEvent createUnregisteredEvent(RemoteServiceRegistrationImpl registration)
           
 void dispose(ID containerID)
           
protected  void fireCallCompleteEvent(IRemoteCallListener listener, long requestId, java.lang.Object response, boolean hadException, java.lang.Throwable exception)
           
protected  void fireCallStartEvent(IRemoteCallListener listener, long requestId, IRemoteServiceReference reference, IRemoteCall call)
           
protected  void fireRemoteServiceListeners(IRemoteServiceEvent event)
           
protected  java.io.Serializable getAddRegistrationRequestCredentials(AddRegistrationRequest request)
           
protected  RemoteServiceRegistryImpl getRemoteRegistry(ID containerID)
           
 IRemoteService getRemoteService(IRemoteServiceReference reference)
          Get remote service for given IRemoteServiceReference.
 IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter, java.lang.String clazz, java.lang.String filter)
          Returns an array of IRemoteServiceReference objects.
protected  org.eclipse.ecf.core.sharedobject.ISharedObjectContext getSOContext()
           
protected  ID[] getTargetsFromProperties(java.util.Dictionary properties)
           
protected  void handleAddRegistration(ID remoteContainerID, java.lang.Integer requestId, RemoteServiceRegistrationImpl registration)
           
protected  void handleAddRegistration(ID remoteContainerID, RemoteServiceRegistrationImpl registration)
           
protected  void handleAddRegistrationRequestRefused(ID remoteContainerID, java.lang.Integer requestId, java.security.AccessControlException e)
           
protected  void handleCallRequest(Request request)
           
protected  void handleCallResponse(Response response)
           
protected  void handleContainerConnectedEvent(IContainerConnectedEvent event)
           
protected  void handleContainerDisconnectedEvent(IContainerDisconnectedEvent event)
           
protected  void handleFireRequest(Request request)
           
protected  void handleRegistryUpdateRequest(ID remoteContainerID)
           
protected  void handleRequestService(ID remoteContainerID, AddRegistrationRequest request, java.lang.Integer requestId, java.io.Serializable credentials)
           
protected  boolean handleSharedObjectMsg(org.eclipse.ecf.core.sharedobject.SharedObjectMsg msg)
           
protected  void handleUnregister(ID containerID, java.lang.Long serviceId)
           
 void initialize()
           
 IRemoteServiceRegistration registerRemoteService(java.lang.String[] clazzes, java.lang.Object service, java.util.Dictionary properties)
          Register a new remote service.
protected  RemoteServiceRegistryImpl removeRemoteRegistry(ID containerID)
           
 void removeRemoteServiceListener(IRemoteServiceListener listener)
          Remove remote service registration/unregistration listener for this container.
protected  void sendAddRegistration(ID receiver, java.lang.Integer requestId, RemoteServiceRegistrationImpl reg)
           
protected  void sendAddRegistration(ID receiver, RemoteServiceRegistrationImpl reg)
           
protected  AddRegistrationRequest sendAddRegistrationRequest(ID receiver, AddRegistrationRequest request, java.io.Serializable credentials)
           
protected  void sendAddRegistrationRequestRefused(ID receiver, java.lang.Integer requestId, java.lang.Exception except)
           
protected  Request sendCallRequest(RemoteServiceRegistrationImpl remoteRegistration, IRemoteCall call)
           
protected  void sendCallRequestWithListener(RemoteServiceRegistrationImpl remoteRegistration, IRemoteCall call, IRemoteCallListener listener)
           
protected  void sendCallResponse(ID responseTarget, Response response)
           
protected  Request sendFireRequest(RemoteServiceRegistrationImpl remoteRegistration, IRemoteCall call)
           
protected  void sendRegistryUpdate(ID targetContainerID)
           
protected  void sendRegistryUpdateRequest()
           
protected  void sendUnregister(RemoteServiceRegistrationImpl serviceRegistration)
           
 boolean ungetRemoteService(IRemoteServiceReference ref)
          Unget IRemoteServiceReference.
 
Methods inherited from class org.eclipse.ecf.core.sharedobject.BaseSharedObject
addEventProcessor, clearEventProcessors, creationCompleted, destroyRemote, destroySelf, destroySelfLocal, fireEventProcessors, getAdapter, getConfig, getConnectedID, getContext, getGroupMemberIDs, getHomeContainerID, getID, getLocalContainerID, getProperties, getReplicaDescription, getReplicaDescriptions, getSharedObjectMsgFromEvent, handleEvent, handleEvents, handleSharedObjectCreateResponseEvent, handleSharedObjectMsgEvent, handleUnhandledEvent, init, isConnected, isPrimary, log, log, removeEventProcessor, replicateToRemoteContainers, sendSharedObjectMsgTo, sendSharedObjectMsgToPrimary, sendSharedObjectMsgToSelf, traceCatching, traceEntering, traceEntering, traceEntering, traceExiting, traceExiting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

localRegistry

protected RemoteServiceRegistryImpl localRegistry

remoteRegistrys

protected final java.util.Map remoteRegistrys

serviceListeners

protected final java.util.List serviceListeners

localServiceRegistrations

protected final java.util.Map localServiceRegistrations

addRegistrationRequests

protected java.util.Map addRegistrationRequests

requests

protected java.util.List requests
Constructor Detail

RegistrySharedObject

public RegistrySharedObject()
Method Detail

dispose

public void dispose(ID containerID)
Specified by:
dispose in interface org.eclipse.ecf.core.sharedobject.ISharedObject
Overrides:
dispose in class org.eclipse.ecf.core.sharedobject.BaseSharedObject

addRemoteServiceListener

public void addRemoteServiceListener(IRemoteServiceListener listener)
Description copied from interface: IRemoteServiceContainerAdapter
Add listener for remote service registration/unregistration for this container

Specified by:
addRemoteServiceListener in interface IRemoteServiceContainerAdapter
Parameters:
listener - notified of service registration/unregistration events. Must not be null .

removeRemoteServiceListener

public void removeRemoteServiceListener(IRemoteServiceListener listener)
Description copied from interface: IRemoteServiceContainerAdapter
Remove remote service registration/unregistration listener for this container.

Specified by:
removeRemoteServiceListener in interface IRemoteServiceContainerAdapter
Parameters:
listener - to remove. Must not be null .

getRemoteService

public IRemoteService getRemoteService(IRemoteServiceReference reference)
Description copied from interface: IRemoteServiceContainerAdapter
Get remote service for given IRemoteServiceReference. Note that clients that call this method successfully should later call IRemoteServiceContainerAdapter.ungetRemoteService(IRemoteServiceReference) when the IRemoteService will no longer be used.

Specified by:
getRemoteService in interface IRemoteServiceContainerAdapter
Parameters:
reference - the IRemoteServiceReference for the desired service. Must not be null .
Returns:
IRemoteService representing the remote service. If remote service no longer exists for reference, then null is returned.
See Also:
IRemoteServiceContainerAdapter.ungetRemoteService(IRemoteServiceReference)

getRemoteServiceReferences

public IRemoteServiceReference[] getRemoteServiceReferences(ID[] idFilter,
                                                            java.lang.String clazz,
                                                            java.lang.String filter)
                                                     throws org.osgi.framework.InvalidSyntaxException
Description copied from interface: IRemoteServiceContainerAdapter
Returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned.

If idFilter is null, all containers are considered to match the filter.

filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

Specified by:
getRemoteServiceReferences in interface IRemoteServiceContainerAdapter
Parameters:
idFilter - an array of ID instances that will restrict the search for matching container ids If null, all remote containers will be considered in search for matching IRemoteServiceReference instances. May be null.
clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
filter - The filter criteria. May be null.
Returns:
Array of IRemoteServiceReferences matching given search criteria or null if no services are found that match the search.
Throws:
org.osgi.framework.InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.

getAddRegistrationRequestCredentials

protected java.io.Serializable getAddRegistrationRequestCredentials(AddRegistrationRequest request)

getTargetsFromProperties

protected ID[] getTargetsFromProperties(java.util.Dictionary properties)

registerRemoteService

public IRemoteServiceRegistration registerRemoteService(java.lang.String[] clazzes,
                                                        java.lang.Object service,
                                                        java.util.Dictionary properties)
Description copied from interface: IRemoteServiceContainerAdapter
Register a new remote service. This method is to be called by the service server...i.e. the client that wishes to make available a service to other client within this container.

Specified by:
registerRemoteService in interface IRemoteServiceContainerAdapter
Parameters:
clazzes - the interface classes that the service exposes to remote clients. Must not be null and must not be an empty array.
service - the service object itself. This object must implement all of the classes specified by the first parameter
properties - to be associated with service
Returns:
IRemoteServiceRegistration the service registration. Will not return null .

ungetRemoteService

public boolean ungetRemoteService(IRemoteServiceReference ref)
Description copied from interface: IRemoteServiceContainerAdapter
Unget IRemoteServiceReference. Release all resources associated with the given IRemoteServiceReference. This method should be called by users of the IRemoteServiceReference that have previously called IRemoteServiceContainerAdapter.getRemoteService(IRemoteServiceReference). If this method returns true, then the previously used IRemoteService will no longer be usable.

Specified by:
ungetRemoteService in interface IRemoteServiceContainerAdapter
Parameters:
ref - the IRemoteServiceReference to unget
Returns:
true if unget successful, false if not. If this method returns true, then the IRemoteService instance previously retrieved via the given IRemoteServiceReference instance provided will no longer be usable.
See Also:
IRemoteServiceContainerAdapter.getRemoteService(IRemoteServiceReference)

getSOContext

protected org.eclipse.ecf.core.sharedobject.ISharedObjectContext getSOContext()

initialize

public void initialize()
                throws org.eclipse.ecf.core.sharedobject.SharedObjectInitException
Overrides:
initialize in class org.eclipse.ecf.core.sharedobject.BaseSharedObject
Throws:
org.eclipse.ecf.core.sharedobject.SharedObjectInitException

handleContainerDisconnectedEvent

protected void handleContainerDisconnectedEvent(IContainerDisconnectedEvent event)

sendRegistryUpdate

protected void sendRegistryUpdate(ID targetContainerID)

handleContainerConnectedEvent

protected void handleContainerConnectedEvent(IContainerConnectedEvent event)

fireRemoteServiceListeners

protected void fireRemoteServiceListeners(IRemoteServiceEvent event)

callSynch

protected java.lang.Object callSynch(RemoteServiceRegistrationImpl registration,
                                     IRemoteCall call)
                              throws ECFException
Throws:
ECFException

fireCallStartEvent

protected void fireCallStartEvent(IRemoteCallListener listener,
                                  long requestId,
                                  IRemoteServiceReference reference,
                                  IRemoteCall call)

fireCallCompleteEvent

protected void fireCallCompleteEvent(IRemoteCallListener listener,
                                     long requestId,
                                     java.lang.Object response,
                                     boolean hadException,
                                     java.lang.Throwable exception)

sendRegistryUpdateRequest

protected void sendRegistryUpdateRequest()

handleRegistryUpdateRequest

protected void handleRegistryUpdateRequest(ID remoteContainerID)

sendAddRegistrationRequest

protected AddRegistrationRequest sendAddRegistrationRequest(ID receiver,
                                                            AddRegistrationRequest request,
                                                            java.io.Serializable credentials)

checkRequestServiceAuthorization

protected void checkRequestServiceAuthorization(ID remoteContainerID,
                                                AddRegistrationRequest request,
                                                java.io.Serializable credentials)
                                         throws java.security.AccessControlException
Throws:
java.security.AccessControlException

handleRequestService

protected void handleRequestService(ID remoteContainerID,
                                    AddRegistrationRequest request,
                                    java.lang.Integer requestId,
                                    java.io.Serializable credentials)

sendAddRegistration

protected void sendAddRegistration(ID receiver,
                                   RemoteServiceRegistrationImpl reg)

sendAddRegistration

protected void sendAddRegistration(ID receiver,
                                   java.lang.Integer requestId,
                                   RemoteServiceRegistrationImpl reg)

sendAddRegistrationRequestRefused

protected void sendAddRegistrationRequestRefused(ID receiver,
                                                 java.lang.Integer requestId,
                                                 java.lang.Exception except)

handleAddRegistrationRequestRefused

protected void handleAddRegistrationRequestRefused(ID remoteContainerID,
                                                   java.lang.Integer requestId,
                                                   java.security.AccessControlException e)

handleAddRegistration

protected void handleAddRegistration(ID remoteContainerID,
                                     RemoteServiceRegistrationImpl registration)

handleAddRegistration

protected void handleAddRegistration(ID remoteContainerID,
                                     java.lang.Integer requestId,
                                     RemoteServiceRegistrationImpl registration)

sendCallRequest

protected Request sendCallRequest(RemoteServiceRegistrationImpl remoteRegistration,
                                  IRemoteCall call)
                           throws java.io.IOException
Throws:
java.io.IOException

handleCallRequest

protected void handleCallRequest(Request request)

sendCallRequestWithListener

protected void sendCallRequestWithListener(RemoteServiceRegistrationImpl remoteRegistration,
                                           IRemoteCall call,
                                           IRemoteCallListener listener)

sendCallResponse

protected void sendCallResponse(ID responseTarget,
                                Response response)

handleCallResponse

protected void handleCallResponse(Response response)

sendFireRequest

protected Request sendFireRequest(RemoteServiceRegistrationImpl remoteRegistration,
                                  IRemoteCall call)
                           throws ECFException
Throws:
ECFException

handleFireRequest

protected void handleFireRequest(Request request)

sendUnregister

protected void sendUnregister(RemoteServiceRegistrationImpl serviceRegistration)

handleUnregister

protected void handleUnregister(ID containerID,
                                java.lang.Long serviceId)

createUnregisteredEvent

protected IRemoteServiceUnregisteredEvent createUnregisteredEvent(RemoteServiceRegistrationImpl registration)

createRegisteredEvent

protected IRemoteServiceRegisteredEvent createRegisteredEvent(RemoteServiceRegistrationImpl registration)

addRemoteRegistry

protected RemoteServiceRegistryImpl addRemoteRegistry(RemoteServiceRegistryImpl registry)
End message send/handlers


getRemoteRegistry

protected RemoteServiceRegistryImpl getRemoteRegistry(ID containerID)

removeRemoteRegistry

protected RemoteServiceRegistryImpl removeRemoteRegistry(ID containerID)

handleSharedObjectMsg

protected boolean handleSharedObjectMsg(org.eclipse.ecf.core.sharedobject.SharedObjectMsg msg)
Overrides:
handleSharedObjectMsg in class org.eclipse.ecf.core.sharedobject.BaseSharedObject