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
public abstract class AbstractDiscoveryContainerAdapter
extends AbstractContainer
implements IDiscoveryLocator, IDiscoveryAdvertiser
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Set
Collection of service listeners.protected final Map
Map of service type to collection of service listeners.protected final String
protected final Collection
Collection of service type listeners.Fields inherited from interface org.eclipse.ecf.discovery.IDiscoveryAdvertiser
CONTAINER_NAME
Fields inherited from interface org.eclipse.ecf.discovery.IDiscoveryLocator
CONTAINER_NAME
-
Constructor Summary
ConstructorDescriptionAbstractDiscoveryContainerAdapter
(String aNamespaceName, DiscoveryContainerConfig aConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addServiceListener
(IServiceTypeID aType, IServiceListener aListener) Add a service listener.void
addServiceListener
(IServiceListener aListener) Add a service listener.void
addServiceTypeListener
(IServiceTypeListener aListener) Add a service type listener.protected void
void
dispose()
Dispose this IContainer instance.protected void
fireServiceDiscovered
(IServiceEvent aServiceEvent) CallsIServiceListener.serviceDiscovered(IServiceEvent)
for all registeredIServiceListener
protected void
fireServiceTypeDiscovered
(IServiceTypeEvent aServiceTypeEvent) CallsIServiceTypeListener.serviceTypeDiscovered(IServiceTypeEvent)
for all registeredIServiceTypeListener
protected void
fireServiceUndiscovered
(IServiceEvent aServiceEvent) CallsIServiceListener.serviceUndiscovered(IServiceEvent)
for all registeredIServiceListener
org.eclipse.equinox.concurrent.future.IFuture
getAsyncServiceInfo
(IServiceID service) Asynchronously retrieve info about the serviceorg.eclipse.equinox.concurrent.future.IFuture
Asynchronously get service info about all known servicesorg.eclipse.equinox.concurrent.future.IFuture
Asynchronously get service info about all known services of given service typeorg.eclipse.equinox.concurrent.future.IFuture
Asynchronously get service info about all known services of given service typeprotected DiscoveryContainerConfig
Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls toIContainer.connect(ID, IConnectContext)
.abstract String
getID()
Return the ID for this 'identifiable' object.protected Collection
getListeners
(IServiceTypeID aServiceType) Joins theCollection
ofIServiceListener
s interested in anyIServiceTypeID
with theCollection
of theIServiceListener
registered for the givenIServiceTypeID
protected IServiceEvent
getServiceEvent
(IServiceInfo iServiceInfo, ID id) Get a Namespace for services associated with this discovery container adapter.Purges the underlying IServiceInfo cache if available in the current providervoid
removeServiceListener
(IServiceTypeID aType, IServiceListener aListener) Remove a service listener.void
removeServiceListener
(IServiceListener aListener) Remove a service listener.void
removeServiceTypeListener
(IServiceTypeListener aListener) Remove a service type listener.void
Unregister all previously registered service.Methods inherited from class org.eclipse.ecf.core.AbstractContainer
addListener, fireContainerEvent, getAdapter, getPasswordFromConnectContext, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.ecf.core.IContainer
connect, disconnect, getConnectedID
Methods inherited from interface org.eclipse.ecf.discovery.IDiscoveryAdvertiser
registerService, unregisterService
Methods inherited from interface org.eclipse.ecf.discovery.IDiscoveryLocator
getServiceInfo, getServices, getServices, getServiceTypes
-
Field Details
-
allServiceListeners
Collection of service listeners. NOTE: Access to this collection is synchronized, so subclasses should take this into account. -
serviceListeners
Map of service type to collection of service listeners. NOTE: Access to this map is synchronized, so subclasses should take this into account. -
servicesNamespaceName
-
serviceTypeListeners
Collection of service type listeners. NOTE: Access to this collection is synchronized, so subclasses should take this into account.
-
-
Constructor Details
-
AbstractDiscoveryContainerAdapter
- Parameters:
aNamespaceName
- namespace nameaConfig
- discovery container config
-
-
Method Details
-
addServiceListener
Description copied from interface:IDiscoveryLocator
Add a service listener. The given listener will have its method called when a service is discovered.- Specified by:
addServiceListener
in interfaceIDiscoveryLocator
- Parameters:
aListener
- IServiceListener to be notified. Must not benull
.
-
getServiceEvent
- Parameters:
iServiceInfo
- service infoid
- id- Returns:
- IServiceEvent created service event
- Since:
- 5.0
-
addServiceListener
Description copied from interface:IDiscoveryLocator
Add 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:
addServiceListener
in interfaceIDiscoveryLocator
- Parameters:
aType
- String type to listen for. Must not benull
. Must be formatted according to this specific IDiscoveryContaineraListener
- IServiceListener to be notified. Must not benull
.
-
addServiceTypeListener
Description copied from interface:IDiscoveryLocator
Add a service type listener. The given listener will have its method called when a service type is discovered.- Specified by:
addServiceTypeListener
in interfaceIDiscoveryLocator
- Parameters:
aListener
- the listener to be notified. Must not benull
.
-
clearListeners
protected void clearListeners() -
dispose
public void dispose()Description copied from interface:IContainer
Dispose 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:
dispose
in interfaceIContainer
- Overrides:
dispose
in classAbstractContainer
-
fireServiceDiscovered
CallsIServiceListener.serviceDiscovered(IServiceEvent)
for all registeredIServiceListener
- Parameters:
aServiceEvent
- TheIServiceEvent
to send along the call
-
fireServiceTypeDiscovered
CallsIServiceTypeListener.serviceTypeDiscovered(IServiceTypeEvent)
for all registeredIServiceTypeListener
- Parameters:
aServiceTypeEvent
- TheIServiceTypeEvent
to send along the call
-
fireServiceUndiscovered
CallsIServiceListener.serviceUndiscovered(IServiceEvent)
for all registeredIServiceListener
- Parameters:
aServiceEvent
- TheIServiceEvent
to send along the call
-
getConfig
- Returns:
- The
DiscoveryContainerConfig
of thisIDiscoveryContainerAdapter
-
getConnectNamespace
Description copied from interface:IContainer
Get 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 thatnull
is expected as a valid parameter in subsequent calls toIContainer.connect(ID, IConnectContext)
. If this method returns a non-null
Namespace, then thetargetID
parameter inIContainer.connect(ID, IConnectContext)
must be non-null
instance created of the returned Namespace.- Specified by:
getConnectNamespace
in interfaceIContainer
- Returns:
- Namespace the namespace associated with subsequent calls to
IContainer.connect(ID, IConnectContext)
. Ifnull
, then thetargetID
instances passed toIContainer.connect(ID, IConnectContext)
may benull
. If notnull
, thentargetID
instances passed toIContainer.connect(ID, IConnectContext)
must be instances of the returned Namespace.
-
getID
Description copied from interface:IIdentifiable
Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May returnnull
.- Specified by:
getID
in interfaceIIdentifiable
- Returns:
- the ID for this identifiable object. May return
null
.
-
getContainerName
- Returns:
- The name of this discovery container
- Since:
- 4.0
-
getListeners
Joins theCollection
ofIServiceListener
s interested in anyIServiceTypeID
with theCollection
of theIServiceListener
registered for the givenIServiceTypeID
- Parameters:
aServiceType
- TheIServiceTypeID
for which theIServiceListener
s are returned- Returns:
- All
IServiceListener
s interested in the givenIServiceTypeID
-
getServicesNamespace
Description copied from interface:IDiscoveryLocator
Get 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:
getServicesNamespace
in interfaceIDiscoveryAdvertiser
- Specified by:
getServicesNamespace
in interfaceIDiscoveryLocator
- Returns:
- Namespace for creating service IDs. Will not be
null
.
-
removeServiceListener
Description copied from interface:IDiscoveryLocator
Remove a service listener. Remove the listener from this container- Specified by:
removeServiceListener
in interfaceIDiscoveryLocator
- Parameters:
aListener
- IServiceListener listener to be removed. Must not benull
.
-
removeServiceListener
Description copied from interface:IDiscoveryLocator
Remove a service listener. Remove the listener associated with the type specified by the first parameter.- Specified by:
removeServiceListener
in interfaceIDiscoveryLocator
- Parameters:
aType
- String of the desired type to remove the listener. Must not benull
. Must be formatted according to this specific IDiscoveryContaineraListener
- IServiceListener listener to be removed. Must not benull
.
-
removeServiceTypeListener
Description copied from interface:IDiscoveryLocator
Remove a service type listener. Remove the type listener.- Specified by:
removeServiceTypeListener
in interfaceIDiscoveryLocator
- Parameters:
aListener
- IServiceTypeListener to be removed. Must not benull
.
-
unregisterAllServices
public void unregisterAllServices()Description copied from interface:IDiscoveryAdvertiser
Unregister all previously registered service.- Specified by:
unregisterAllServices
in interfaceIDiscoveryAdvertiser
- Since:
- 3.0
- See Also:
-
purgeCache
Description copied from interface:IDiscoveryLocator
Purges the underlying IServiceInfo cache if available in the current provider- Specified by:
purgeCache
in interfaceIDiscoveryLocator
- Returns:
- The previous cache content
- Since:
- 3.0
- See Also:
-
getAsyncServiceInfo
Description copied from interface:IDiscoveryLocator
Asynchronously retrieve info about the service- Specified by:
getAsyncServiceInfo
in interfaceIDiscoveryLocator
- Parameters:
service
- IServiceID of the service to get info about. Must not benull
.- Returns:
- IFuture a future status wrapping an IServiceInfo or
null
if no information retrievable. - Since:
- 3.0
- See Also:
-
getAsyncServiceTypes
public org.eclipse.equinox.concurrent.future.IFuture getAsyncServiceTypes()Description copied from interface:IDiscoveryLocator
Asynchronously get service info about all known services of given service type- Specified by:
getAsyncServiceTypes
in interfaceIDiscoveryLocator
- 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:
-
getAsyncServices
public org.eclipse.equinox.concurrent.future.IFuture getAsyncServices()Description copied from interface:IDiscoveryLocator
Asynchronously get service info about all known services- Specified by:
getAsyncServices
in interfaceIDiscoveryLocator
- 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:
-
getAsyncServices
Description copied from interface:IDiscoveryLocator
Asynchronously get service info about all known services of given service type- Specified by:
getAsyncServices
in interfaceIDiscoveryLocator
- Parameters:
type
- IServiceTypeID defining the type of service we are interested in getting service info about. Must not benull
- 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:
-