org.eclipse.ecf.provider.jmdns.container
Class JMDNSDiscoveryContainer

java.lang.Object
  extended by org.eclipse.ecf.core.AbstractContainer
      extended by org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter
          extended by org.eclipse.ecf.provider.jmdns.container.JMDNSDiscoveryContainer
All Implemented Interfaces:
java.util.EventListener, javax.jmdns.ServiceListener, javax.jmdns.ServiceTypeListener, org.eclipse.core.runtime.IAdaptable, IContainer, IIdentifiable, IDiscoveryAdvertiser, IDiscoveryContainerAdapter, IDiscoveryLocator, IDiscoveryService

public class JMDNSDiscoveryContainer
extends AbstractDiscoveryContainerAdapter
implements IDiscoveryService, javax.jmdns.ServiceListener, javax.jmdns.ServiceTypeListener


Field Summary
static int DEFAULT_REQUEST_TIMEOUT
           
 
Fields inherited from class org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter
allServiceListeners, serviceListeners, servicesNamespaceName, serviceTypeListeners
 
Fields inherited from interface org.eclipse.ecf.discovery.service.IDiscoveryService
CONTAINER_ID, CONTAINER_NAME
 
Constructor Summary
JMDNSDiscoveryContainer()
           
 
Method Summary
 void connect(ID targetID1, IConnectContext joinContext)
          Connect to a target remote process or process group.
 void disconnect()
          Disconnect.
 void dispose()
          Dispose this IContainer instance.
 ID getConnectedID()
          IContainer methods
 java.lang.String getContainerName()
           
 IServiceInfo getServiceInfo(IServiceID service)
          IDiscoveryContainerAdapter methods
 IServiceInfo[] getServices()
          Synchronously get service info about all known services
 IServiceInfo[] getServices(IServiceTypeID type)
          Synchronously get service info about all known services of given service type
 IServiceTypeID[] getServiceTypes()
          Synchronously get service info about all known services of given service type
 IServiceInfo[] purgeCache()
          Purges the underlying IServiceInfo cache if available in the current provider
 void registerService(IServiceInfo serviceInfo)
          Register the given service.
 void serviceAdded(javax.jmdns.ServiceEvent arg0)
          A service has been added.
 void serviceRemoved(javax.jmdns.ServiceEvent arg0)
          A service has been removed.
 void serviceResolved(javax.jmdns.ServiceEvent arg0)
          A service has been resolved.
 void serviceTypeAdded(javax.jmdns.ServiceEvent arg0)
          A new service type was discovered.
 void unregisterAllServices()
          Unregister all previously registered service.
 void unregisterService(IServiceInfo serviceInfo)
          Unregister a previously registered service defined by serviceInfo.
 
Methods inherited from class org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter
addServiceListener, addServiceListener, addServiceTypeListener, clearListeners, fireServiceDiscovered, fireServiceTypeDiscovered, fireServiceUndiscovered, getAsyncServiceInfo, getAsyncServices, getAsyncServices, getAsyncServiceTypes, getConfig, getConnectNamespace, getID, getListeners, getServicesNamespace, removeServiceListener, removeServiceListener, removeServiceTypeListener
 
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.discovery.IDiscoveryLocator
addServiceListener, addServiceListener, addServiceTypeListener, getAsyncServiceInfo, getAsyncServices, getAsyncServices, getAsyncServiceTypes, getServicesNamespace, removeServiceListener, removeServiceListener, removeServiceTypeListener
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 
Methods inherited from interface org.eclipse.ecf.discovery.IDiscoveryAdvertiser
getServicesNamespace
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

DEFAULT_REQUEST_TIMEOUT

public static final int DEFAULT_REQUEST_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

JMDNSDiscoveryContainer

public JMDNSDiscoveryContainer()
Since:
4.0
Method Detail

getConnectedID

public ID getConnectedID()
IContainer methods

Specified by:
getConnectedID in interface IContainer
Returns:
ID of the target we are connected to. Returns null if container not connected.

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 interface IContainer
Overrides:
dispose in class AbstractDiscoveryContainerAdapter

connect

public void connect(ID targetID1,
                    IConnectContext joinContext)
             throws ContainerConnectException
Description copied from interface: IContainer
Connect to a target remote process or process group. The target identified by the first parameter (targetID) is connected the implementation class. If authentication information is required, the required information is given via via the second parameter (connectContext). Callers note that depending upon the provider implementation this method may block. It is suggested that callers use a separate thread to call this method. This method provides an implementation independent way for container implementations to connect, authenticate, and communicate with a remote service or group of services. Providers are responsible for implementing this operation in a way appropriate to the given remote service (or group) via expected protocol.

Specified by:
connect in interface IContainer
Parameters:
targetID1 - the ID of the remote server or group to connect to. See IContainer.getConnectNamespace() for a explanation of the constraints upon this parameter.
joinContext - any required context to allow this container to authenticate. May be null if underlying provider does not have any authentication requirements for connection.
Throws:
ContainerConnectException - thrown if communication cannot be established with remote service. Causes can include network connection failure, authentication failure, server error, or if container is already connected.

disconnect

public void disconnect()
Description copied from interface: IContainer
Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return null.

Specified by:
disconnect in interface IContainer

getServiceInfo

public IServiceInfo getServiceInfo(IServiceID service)
IDiscoveryContainerAdapter methods

Specified by:
getServiceInfo in interface IDiscoveryLocator
Returns:
IServiceInfo the service info retrieved. null if no information retrievable.

getServices

public IServiceInfo[] getServices()
Description copied from interface: IDiscoveryLocator
Synchronously get service info about all known services

Specified by:
getServices in interface IDiscoveryLocator
Returns:
IServiceInfo[] the resulting array of service info instances. Will not be null. May be of length 0.

getServices

public IServiceInfo[] getServices(IServiceTypeID type)
Description copied from interface: IDiscoveryLocator
Synchronously get service info about all known services of given service type

Specified by:
getServices in interface IDiscoveryLocator
Returns:
IServiceInfo[] the resulting array of service info instances. Will not be null. May be of length 0.

getServiceTypes

public IServiceTypeID[] getServiceTypes()
Description copied from interface: IDiscoveryLocator
Synchronously get service info about all known services of given service type

Specified by:
getServiceTypes in interface IDiscoveryLocator
Returns:
IServiceTypeID[] the resulting array of service type IDs. Will not be null. May be of length 0.

registerService

public void registerService(IServiceInfo serviceInfo)
Description copied from interface: IDiscoveryAdvertiser
Register the given service. This publishes the service defined by the serviceInfo to the underlying publishing mechanism

Specified by:
registerService in interface IDiscoveryAdvertiser
Parameters:
serviceInfo - IServiceInfo of the service to be published. Must not be null.

unregisterService

public void unregisterService(IServiceInfo serviceInfo)
Description copied from interface: IDiscoveryAdvertiser
Unregister a previously registered service defined by serviceInfo.

Specified by:
unregisterService in interface IDiscoveryAdvertiser
Parameters:
serviceInfo - IServiceInfo defining the service to unregister. Must not be null.

unregisterAllServices

public void unregisterAllServices()
Description copied from interface: IDiscoveryAdvertiser
Unregister all previously registered service.

Specified by:
unregisterAllServices in interface IDiscoveryAdvertiser
Overrides:
unregisterAllServices in class AbstractDiscoveryContainerAdapter
See Also:
IDiscoveryAdvertiser.unregisterAllServices()

purgeCache

public IServiceInfo[] purgeCache()
Description copied from interface: IDiscoveryLocator
Purges the underlying IServiceInfo cache if available in the current provider

Specified by:
purgeCache in interface IDiscoveryLocator
Overrides:
purgeCache in class AbstractDiscoveryContainerAdapter
Returns:
The previous cache content
See Also:
IDiscoveryLocator.purgeCache()

serviceTypeAdded

public void serviceTypeAdded(javax.jmdns.ServiceEvent arg0)
Description copied from interface: javax.jmdns.ServiceTypeListener
A new service type was discovered.

Specified by:
serviceTypeAdded in interface javax.jmdns.ServiceTypeListener
Parameters:
arg0 - The service event providing the fully qualified type of the service.

serviceAdded

public void serviceAdded(javax.jmdns.ServiceEvent arg0)
Description copied from interface: javax.jmdns.ServiceListener
A service has been added.

Specified by:
serviceAdded in interface javax.jmdns.ServiceListener
Parameters:
arg0 - The ServiceEvent providing the name and fully qualified type of the service.

serviceRemoved

public void serviceRemoved(javax.jmdns.ServiceEvent arg0)
Description copied from interface: javax.jmdns.ServiceListener
A service has been removed.

Specified by:
serviceRemoved in interface javax.jmdns.ServiceListener
Parameters:
arg0 - The ServiceEvent providing the name and fully qualified type of the service.

serviceResolved

public void serviceResolved(javax.jmdns.ServiceEvent arg0)
Description copied from interface: javax.jmdns.ServiceListener
A service has been resolved. Its details are now available in the ServiceInfo record.

Specified by:
serviceResolved in interface javax.jmdns.ServiceListener
Parameters:
arg0 - The ServiceEvent providing the name, the fully qualified type of the service, and the service info record, or null if the service could not be resolved.

getContainerName

public java.lang.String getContainerName()
Specified by:
getContainerName in class AbstractDiscoveryContainerAdapter
Returns:
The name of this discovery container