Package org.eclipse.ecf.discovery
Class AbstractDiscoveryContainerAdapter
- java.lang.Object
- 
- org.eclipse.ecf.core.AbstractContainer
- 
- org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter
 
 
- 
- All Implemented Interfaces:
- org.eclipse.core.runtime.IAdaptable,- IContainer,- IIdentifiable,- IDiscoveryAdvertiser,- IDiscoveryLocator
 - Direct Known Subclasses:
- DnsSdDiscoveryContainerAdapter,- JSLPDiscoveryContainer,- ZooDiscoveryContainer
 
 public abstract class AbstractDiscoveryContainerAdapter extends AbstractContainer implements IDiscoveryLocator, IDiscoveryAdvertiser 
- 
- 
Field SummaryFields Modifier and Type Field Description protected SetallServiceListenersCollection of service listeners.protected MapserviceListenersMap of service type to collection of service listeners.protected StringservicesNamespaceNameprotected CollectionserviceTypeListenersCollection of service type listeners.- 
Fields inherited from interface org.eclipse.ecf.discovery.IDiscoveryAdvertiserCONTAINER_NAME
 - 
Fields inherited from interface org.eclipse.ecf.discovery.IDiscoveryLocatorCONTAINER_NAME
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractDiscoveryContainerAdapter(String aNamespaceName, DiscoveryContainerConfig aConfig)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddServiceListener(IServiceTypeID aType, IServiceListener aListener)Add a service listener.voidaddServiceListener(IServiceListener aListener)Add a service listener.voidaddServiceTypeListener(IServiceTypeListener aListener)Add a service type listener.protected voidclearListeners()voiddispose()Dispose this IContainer instance.protected voidfireServiceDiscovered(IServiceEvent aServiceEvent)CallsIServiceListener.serviceDiscovered(IServiceEvent)for all registeredIServiceListenerprotected voidfireServiceTypeDiscovered(IServiceTypeEvent aServiceTypeEvent)CallsIServiceTypeListener.serviceTypeDiscovered(IServiceTypeEvent)for all registeredIServiceTypeListenerprotected voidfireServiceUndiscovered(IServiceEvent aServiceEvent)CallsIServiceListener.serviceUndiscovered(IServiceEvent)for all registeredIServiceListenerorg.eclipse.equinox.concurrent.future.IFuturegetAsyncServiceInfo(IServiceID service)Asynchronously retrieve info about the serviceorg.eclipse.equinox.concurrent.future.IFuturegetAsyncServices()Asynchronously get service info about all known servicesorg.eclipse.equinox.concurrent.future.IFuturegetAsyncServices(IServiceTypeID type)Asynchronously get service info about all known services of given service typeorg.eclipse.equinox.concurrent.future.IFuturegetAsyncServiceTypes()Asynchronously get service info about all known services of given service typeprotected DiscoveryContainerConfiggetConfig()NamespacegetConnectNamespace()Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls toIContainer.connect(ID, IConnectContext).abstract StringgetContainerName()IDgetID()Return the ID for this 'identifiable' object.protected CollectiongetListeners(IServiceTypeID aServiceType)Joins theCollectionofIServiceListeners interested in anyIServiceTypeIDwith theCollectionof theIServiceListenerregistered for the givenIServiceTypeIDprotected IServiceEventgetServiceEvent(IServiceInfo iServiceInfo, ID id)NamespacegetServicesNamespace()Get a Namespace for services associated with this discovery container adapter.IServiceInfo[]purgeCache()Purges the underlying IServiceInfo cache if available in the current providervoidremoveServiceListener(IServiceTypeID aType, IServiceListener aListener)Remove a service listener.voidremoveServiceListener(IServiceListener aListener)Remove a service listener.voidremoveServiceTypeListener(IServiceTypeListener aListener)Remove a service type listener.voidunregisterAllServices()Unregister all previously registered service.- 
Methods inherited from class org.eclipse.ecf.core.AbstractContaineraddListener, fireContainerEvent, getAdapter, getPasswordFromConnectContext, removeListener
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.eclipse.ecf.core.IContainerconnect, disconnect, getConnectedID
 - 
Methods inherited from interface org.eclipse.ecf.discovery.IDiscoveryAdvertiserregisterService, unregisterService
 - 
Methods inherited from interface org.eclipse.ecf.discovery.IDiscoveryLocatorgetServiceInfo, getServices, getServices, getServiceTypes
 
- 
 
- 
- 
- 
Field Detail- 
allServiceListenersprotected final Set allServiceListeners Collection of service listeners. NOTE: Access to this collection is synchronized, so subclasses should take this into account.
 - 
serviceListenersprotected final Map serviceListeners Map of service type to collection of service listeners. NOTE: Access to this map is synchronized, so subclasses should take this into account.
 - 
servicesNamespaceNameprotected final String servicesNamespaceName 
 - 
serviceTypeListenersprotected final Collection serviceTypeListeners Collection of service type listeners. NOTE: Access to this collection is synchronized, so subclasses should take this into account.
 
- 
 - 
Constructor Detail- 
AbstractDiscoveryContainerAdapterpublic AbstractDiscoveryContainerAdapter(String aNamespaceName, DiscoveryContainerConfig aConfig) - Parameters:
- aNamespaceName- namespace name
- aConfig- discovery container config
 
 
- 
 - 
Method Detail- 
addServiceListenerpublic void addServiceListener(IServiceListener aListener) Description copied from interface:IDiscoveryLocatorAdd a service listener. The given listener will have its method called when a service is discovered.- Specified by:
- addServiceListenerin interface- IDiscoveryLocator
- Parameters:
- aListener- IServiceListener to be notified. Must not be- null.
 
 - 
getServiceEventprotected IServiceEvent getServiceEvent(IServiceInfo iServiceInfo, ID id) - Parameters:
- iServiceInfo- service info
- id- id
- Returns:
- IServiceEvent created service event
- Since:
- 5.0
 
 - 
addServiceListenerpublic void addServiceListener(IServiceTypeID aType, IServiceListener aListener) Description copied from interface:IDiscoveryLocatorAdd a service listener. The given listener will have its method called when a service with a type matching that specified by the first parameter is discovered.- Specified by:
- addServiceListenerin interface- IDiscoveryLocator
- Parameters:
- aType- String type to listen for. Must not be- null. Must be formatted according to this specific IDiscoveryContainer
- aListener- IServiceListener to be notified. Must not be- null.
 
 - 
addServiceTypeListenerpublic void addServiceTypeListener(IServiceTypeListener aListener) Description copied from interface:IDiscoveryLocatorAdd a service type listener. The given listener will have its method called when a service type is discovered.- Specified by:
- addServiceTypeListenerin interface- IDiscoveryLocator
- Parameters:
- aListener- the listener to be notified. Must not be- null.
 
 - 
clearListenersprotected void clearListeners() 
 - 
disposepublic void dispose() Description copied from interface:IContainerDispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.- Specified by:
- disposein interface- IContainer
- Overrides:
- disposein class- AbstractContainer
 
 - 
fireServiceDiscoveredprotected void fireServiceDiscovered(IServiceEvent aServiceEvent) CallsIServiceListener.serviceDiscovered(IServiceEvent)for all registeredIServiceListener- Parameters:
- aServiceEvent- The- IServiceEventto send along the call
 
 - 
fireServiceTypeDiscoveredprotected void fireServiceTypeDiscovered(IServiceTypeEvent aServiceTypeEvent) CallsIServiceTypeListener.serviceTypeDiscovered(IServiceTypeEvent)for all registeredIServiceTypeListener- Parameters:
- aServiceTypeEvent- The- IServiceTypeEventto send along the call
 
 - 
fireServiceUndiscoveredprotected void fireServiceUndiscovered(IServiceEvent aServiceEvent) CallsIServiceListener.serviceUndiscovered(IServiceEvent)for all registeredIServiceListener- Parameters:
- aServiceEvent- The- IServiceEventto send along the call
 
 - 
getConfigprotected DiscoveryContainerConfig getConfig() - Returns:
- The DiscoveryContainerConfigof thisIDiscoveryContainerAdapter
 
 - 
getConnectNamespacepublic Namespace getConnectNamespace() Description copied from interface:IContainerGet the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls toIContainer.connect(ID, IConnectContext). If this method returnsnull, then it means thatnullis expected as a valid parameter in subsequent calls toIContainer.connect(ID, IConnectContext). If this method returns a non-nullNamespace, then thetargetIDparameter inIContainer.connect(ID, IConnectContext)must be non-nullinstance created of the returned Namespace.- Specified by:
- getConnectNamespacein interface- IContainer
- Returns:
- Namespace the namespace associated with subsequent calls to
         IContainer.connect(ID, IConnectContext). Ifnull, then thetargetIDinstances passed toIContainer.connect(ID, IConnectContext)may benull. If notnull, thentargetIDinstances passed toIContainer.connect(ID, IConnectContext)must be instances of the returned Namespace.
 
 - 
getIDpublic ID getID() Description copied from interface:IIdentifiableReturn the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May returnnull.- Specified by:
- getIDin interface- IIdentifiable
- Returns:
- the ID for this identifiable object.  May return null.
 
 - 
getContainerNamepublic abstract String getContainerName() - Returns:
- The name of this discovery container
- Since:
- 4.0
 
 - 
getListenersprotected Collection getListeners(IServiceTypeID aServiceType) Joins theCollectionofIServiceListeners interested in anyIServiceTypeIDwith theCollectionof theIServiceListenerregistered for the givenIServiceTypeID- Parameters:
- aServiceType- The- IServiceTypeIDfor which the- IServiceListeners are returned
- Returns:
- All IServiceListeners interested in the givenIServiceTypeID
 
 - 
getServicesNamespacepublic Namespace getServicesNamespace() Description copied from interface:IDiscoveryLocatorGet a Namespace for services associated with this discovery container adapter. The given Namespace may be used via IServiceIDFactory to create IServiceIDs rather than simple IDs. For example:IServiceID serviceID = ServiceIDFactory.getDefault().createServiceID(container.getServicesNamespace(), serviceType, serviceName);- Specified by:
- getServicesNamespacein interface- IDiscoveryAdvertiser
- Specified by:
- getServicesNamespacein interface- IDiscoveryLocator
- Returns:
- Namespace for creating service IDs. Will not be null.
 
 - 
removeServiceListenerpublic void removeServiceListener(IServiceListener aListener) Description copied from interface:IDiscoveryLocatorRemove a service listener. Remove the listener from this container- Specified by:
- removeServiceListenerin interface- IDiscoveryLocator
- Parameters:
- aListener- IServiceListener listener to be removed. Must not be- null.
 
 - 
removeServiceListenerpublic void removeServiceListener(IServiceTypeID aType, IServiceListener aListener) Description copied from interface:IDiscoveryLocatorRemove a service listener. Remove the listener associated with the type specified by the first parameter.- Specified by:
- removeServiceListenerin interface- IDiscoveryLocator
- Parameters:
- aType- String of the desired type to remove the listener. Must not be- null. Must be formatted according to this specific IDiscoveryContainer
- aListener- IServiceListener listener to be removed. Must not be- null.
 
 - 
removeServiceTypeListenerpublic void removeServiceTypeListener(IServiceTypeListener aListener) Description copied from interface:IDiscoveryLocatorRemove a service type listener. Remove the type listener.- Specified by:
- removeServiceTypeListenerin interface- IDiscoveryLocator
- Parameters:
- aListener- IServiceTypeListener to be removed. Must not be- null.
 
 - 
unregisterAllServicespublic void unregisterAllServices() Description copied from interface:IDiscoveryAdvertiserUnregister all previously registered service.- Specified by:
- unregisterAllServicesin interface- IDiscoveryAdvertiser
- Since:
- 3.0
- See Also:
- IDiscoveryAdvertiser.unregisterAllServices()
 
 - 
purgeCachepublic IServiceInfo[] purgeCache() Description copied from interface:IDiscoveryLocatorPurges the underlying IServiceInfo cache if available in the current provider- Specified by:
- purgeCachein interface- IDiscoveryLocator
- Returns:
- The previous cache content
- Since:
- 3.0
- See Also:
- IDiscoveryLocator.purgeCache()
 
 - 
getAsyncServiceInfopublic org.eclipse.equinox.concurrent.future.IFuture getAsyncServiceInfo(IServiceID service) Description copied from interface:IDiscoveryLocatorAsynchronously retrieve info about the service- Specified by:
- getAsyncServiceInfoin interface- IDiscoveryLocator
- Parameters:
- service- IServiceID of the service to get info about. Must not be- null.
- Returns:
- IFuture a future status wrapping an IServiceInfo or
         nullif no information retrievable.
- Since:
- 3.0
- See Also:
- IDiscoveryLocator.getAsyncServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
 
 - 
getAsyncServiceTypespublic org.eclipse.equinox.concurrent.future.IFuture getAsyncServiceTypes() Description copied from interface:IDiscoveryLocatorAsynchronously get service info about all known services of given service type- Specified by:
- getAsyncServiceTypesin interface- IDiscoveryLocator
- Returns:
- IFuture wrapping an IServiceTypeID[]. The resulting array of
         service type IDs will not be null. May be of length 0.
- Since:
- 3.0
- See Also:
- IDiscoveryLocator.getAsyncServiceTypes()
 
 - 
getAsyncServicespublic org.eclipse.equinox.concurrent.future.IFuture getAsyncServices() Description copied from interface:IDiscoveryLocatorAsynchronously get service info about all known services- Specified by:
- getAsyncServicesin interface- IDiscoveryLocator
- Returns:
- IFuture wrapping an IServiceTypeID[]. The resulting array of
         service type IDs will not be null. May be of length 0.
- Since:
- 3.0
- See Also:
- IDiscoveryLocator.getAsyncServices()
 
 - 
getAsyncServicespublic org.eclipse.equinox.concurrent.future.IFuture getAsyncServices(IServiceTypeID type) Description copied from interface:IDiscoveryLocatorAsynchronously get service info about all known services of given service type- Specified by:
- getAsyncServicesin interface- IDiscoveryLocator
- Parameters:
- type- IServiceTypeID defining the type of service we are interested in getting service info about. Must not be- null
- Returns:
- IFuture wrapping an IServiceTypeID[]. The resulting array of
         service type IDs will not be null. May be of length 0.
- Since:
- 3.0
- See Also:
- IDiscoveryLocator.getAsyncServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
 
 
- 
 
-