Package org.eclipse.ecf.core
Interface IContainer
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable,IIdentifiable
- All Known Subinterfaces:
IReliableContainer,ISharedObjectContainer
- All Known Implementing Classes:
AbstractClientContainer,AbstractContainer,AbstractDiscoveryContainerAdapter,AbstractRestClientContainer,AbstractRSAClientContainer,AbstractRSAContainer,BaseContainer,ClientSOContainer,DnsSdDiscoveryAdvertiser,DnsSdDiscoveryContainerAdapter,DnsSdDiscoveryLocator,JSLPDiscoveryContainer,RemoteServiceContainer,RestClientContainer,ServerSOContainer,ServletServerContainer,SOContainer,SSLClientSOContainer,SSLServerSOContainer,TCPClientSOContainer,TCPServerSOContainer
Contract for ECF communications container
IContainer instances are used by clients to define a context for communications.
The typical life cycle of an ECF communications container is:
IContainer instances are used by clients to define a context for communications.
The typical life cycle of an ECF communications container is:
- Create an IContainer instance via a
ContainerFactory - Optional: Setup client-specific protocol adapters for communicating via specific protocols
- Connect the container to a remote process or group
- Engage in communication via protocol adapters
- Disconnect
// Create container instance via factory
IContainer container = ContainerFactory.getDefault().createContainer(
"ecf.generic.client");
// Get presence protocol adapter
IPresenceContainerAdapter presence = (IPresenceContainerAdapter) container
.getAdapter(IPresenceContainerAdapter.class);
// ... setup presence listeners and local input here using presence
// Connect
container.connect(target, targetConnectContext);
// Engage in appropriate communications here using protocol adapter(s)
// Manage protocol adapters as needed when finished
// Disconnect
container.disconnect();
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(IContainerListener listener) Add listener to IContainer.voidconnect(ID targetID, IConnectContext connectContext) Connect to a target remote process or process group.voidDisconnect.voiddispose()Dispose this IContainer instance.<T> TgetAdapter(Class<T> serviceType) This specialization of IAdaptable.getAdapter() returns additional services supported by this container.Get the target ID that this container instance has connected to.Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls toconnect(ID, IConnectContext).voidremoveListener(IContainerListener listener) Remove listener from IContainer.Methods inherited from interface org.eclipse.ecf.core.identity.IIdentifiable
getID
-
Method Details
-
connect
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.- Parameters:
targetID- the ID of the remote server or group to connect to. SeegetConnectNamespace()for a explanation of the constraints upon this parameter.connectContext- any required context to allow this container to authenticate. May benullif 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.
-
getConnectedID
ID getConnectedID()Get the target ID that this container instance has connected to. Returns null if not connected.- Returns:
- ID of the target we are connected to. Returns
nullif container not connected.
-
getConnectNamespace
Namespace getConnectNamespace()Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls toconnect(ID, IConnectContext). If this method returnsnull, then it means thatnullis expected as a valid parameter in subsequent calls toconnect(ID, IConnectContext). If this method returns a non-nullNamespace, then thetargetIDparameter inconnect(ID, IConnectContext)must be non-nullinstance created of the returned Namespace.- Returns:
- Namespace the namespace associated with subsequent calls to
connect(ID, IConnectContext). Ifnull, then thetargetIDinstances passed toconnect(ID, IConnectContext)may benull. If notnull, thentargetIDinstances passed toconnect(ID, IConnectContext)must be instances of the returned Namespace.
-
disconnect
void disconnect()Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will returnnull. -
getAdapter
This specialization of IAdaptable.getAdapter() returns additional services supported by this container. A container that supports additional services over and above the methods onIContainershould return them using this method. It is recommended that clients use this method rather than instanceof checks and downcasts to find out about the capabilities of a specific container.Typically, after obtaining an IContainer, a client would use this method as a means to obtain a more meaningful interface to the container. This interface may or may not extend IContainer. For example, a client could use the following code to obtain an instance of ISharedObjectContainer:
IContainer newContainer = ContainerFactory.createContainer(type); ISharedObjectContainer soContainer = (ISharedObjectContainer) newContainer .getAdapter(ISharedObjectContainer.class); if (soContainer == null) throw new ContainerCreateException(message);Implementations of this method should delegate to
IAdapterManager.loadAdapter()if the service cannot be provided directly to ensure extensibility by third-party plug-ins.- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable- Parameters:
serviceType- the service type to look up- Returns:
- the service instance castable to the given class, or
nullif this container does not support the given service
-
dispose
void dispose()Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage. -
addListener
Add listener to IContainer. The listener's handleEvent method will be synchronously called when container methods are called. Minimally, the events delivered to the listener are as follows
Container Events container action Event connect start IContainerConnectingEvent connect complete IContainerConnectedEvent disconnect start IContainerDisconnectingEvent disconnect complete IContainerDisconnectedEvent - Parameters:
listener- the IContainerListener to add
-
removeListener
Remove listener from IContainer.- Parameters:
listener- the IContainerListener to remove
-