org.eclipse.datatools.connectivity
Interface IManagedConnection


public interface IManagedConnection

Managed connections represent connection instances whose life cycle is managed by the connection profile it is associated with through the connect() and disconnnect() methods on IConnectionProfile. The managed connection object exists throughout the life cycle of the connection profile it is associated with, however it may not always be in a connected state (e.g. getConnection() may return null if the profile is not in a connected state or it may return a connection with an error if an error occurred trying to establish the connection). This allows a consumer to register a listener at anytime. Clients should register a connection listener so that they may be notified of life cycle events specific to this connection (e.g. open, close).

Author:
rcernich Created on Jan 19, 2006

Nested Class Summary
static interface IManagedConnection.ICloneConnectionJob
          Interface implemented by the Job used in cloneConnection(IJobChangeListener).
 
Method Summary
 void addConnectionListener(IManagedConnectionListener listener)
          Adds a connection listener to this object.
 IConnection cloneConnection()
          Creates a copy of the connection being managed.
 void cloneConnection(org.eclipse.core.runtime.jobs.IJobChangeListener listener)
          Creates a copy of the connection being managed.
 void fireModifiedEvent(java.lang.Object context)
          Used to notify other clients that a change has been made to the server.
 IConnection getConnection()
           
 java.lang.String getFactoryID()
           
 boolean isConnected()
           
 boolean isWorkingOffline()
           
 void removeConnectionListener(IManagedConnectionListener listener)
          Removes a connection listener from this object.
 

Method Detail

isConnected

boolean isConnected()
Returns:
true if this object is managing an active connection.

getConnection

IConnection getConnection()
Returns:
the connection object being managed.

getFactoryID

java.lang.String getFactoryID()
Returns:
the factory ID of the connection factory used to create the connection being managed.

addConnectionListener

void addConnectionListener(IManagedConnectionListener listener)
Adds a connection listener to this object.

Parameters:
listener -

removeConnectionListener

void removeConnectionListener(IManagedConnectionListener listener)
Removes a connection listener from this object.

Parameters:
listener -

fireModifiedEvent

void fireModifiedEvent(java.lang.Object context)
Used to notify other clients that a change has been made to the server. This gives other clients the opportunity to perform any necessary updates.

Parameters:
context - the context of the change; may be null

cloneConnection

IConnection cloneConnection()
Creates a copy of the connection being managed. By gentlemen's agreement, managed connection should be treated as read-only connections. However, this agreement need not apply to connections where changes to the server are immediately available to other clients (e.g. non-transactional connections).

Returns:
a copy of the connection being managed.

cloneConnection

void cloneConnection(org.eclipse.core.runtime.jobs.IJobChangeListener listener)
Creates a copy of the connection being managed. By gentlemen's agreement, managed connection should be treated as read-only connections. However, this agreement need not apply to connections where changes to the server are immediately available to other clients (e.g. non-transactional connections). The connection should be retrieved from the Job by the listener using IManagedConnection.ICloneConnectionJob.getConnection() after the Job has finished.

Parameters:
listener - cannot be null

isWorkingOffline

boolean isWorkingOffline()
Returns:
true if the active connection represents an offline connection.