org.jmx4odp.pool
Interface ContextPool

All Known Implementing Classes:
AbstractContextPool, OrderedContextPool, RoundRobbinContextPool

public interface ContextPool

This is for objects that hold pools of Contexts that represent a pool of potential services. Each implementation of the ContextPool can implement its own method for load balancing and clustering. All Context objects will use the common configuration keys and values from this interface. These key value pairs are stored in the Context's environment.

Author:
Lucas McGregor
See Also:
javax.naming.Context;

Field Summary
static java.lang.String DOWN_SERVICE_RETRY_WAIT
           
static java.lang.String INSTANCE_ID
           
static java.lang.String SERVICE_NAME
           
static java.lang.String SERVICE_STATUS
           
static java.lang.String STATUS_DOWN
           
static java.lang.String STATUS_DOWN_DATE
           
static java.lang.String STATUS_UNKOWN
           
static java.lang.String STATUS_UP
           
 
Method Summary
 void addContext(javax.naming.Context ctx)
          Add a loaded context to this pool.
 javax.naming.Context getAvailableContext()
          This is an ORDERED pool.
 javax.naming.Context getContext(javax.naming.Context ctx)
          Given a context, it will look for the INSTANCE_ID property and find the matching context in the pool.
 javax.naming.Context getContext(int i)
          Given an index it will return this context from the pool
 javax.naming.Context getContext(java.lang.String id)
          Given an index it will return this context from the pool
 int getNumberOfServices()
           
 java.lang.String getServiceName()
          Getter for property serviceName.
 java.lang.String getStatus(javax.naming.Context ctx)
          Given a context, it will return the status of this context: STATUS_UNKOWN, STATUS_UP, or STATUS_DOWN
 java.lang.String getStatus(int index)
          return the status of the instance at the given index
 java.lang.String getStatus(java.lang.String id)
          return the status of the instance at the given index
 boolean markDown(javax.naming.Context ctx)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 boolean markDown(int index)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 boolean markDown(java.lang.String id)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 boolean markUp(javax.naming.Context ctx)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 boolean markUp(int index)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 boolean markUp(java.lang.String id)
          Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down.
 void setServiceName(java.lang.String name)
          Setter for property serviceName.
 

Field Detail

STATUS_DOWN

static final java.lang.String STATUS_DOWN
See Also:
Constant Field Values

STATUS_UP

static final java.lang.String STATUS_UP
See Also:
Constant Field Values

STATUS_UNKOWN

static final java.lang.String STATUS_UNKOWN
See Also:
Constant Field Values

SERVICE_NAME

static final java.lang.String SERVICE_NAME
See Also:
Constant Field Values

INSTANCE_ID

static final java.lang.String INSTANCE_ID
See Also:
Constant Field Values

DOWN_SERVICE_RETRY_WAIT

static final java.lang.String DOWN_SERVICE_RETRY_WAIT
See Also:
Constant Field Values

SERVICE_STATUS

static final java.lang.String SERVICE_STATUS
See Also:
Constant Field Values

STATUS_DOWN_DATE

static final java.lang.String STATUS_DOWN_DATE
See Also:
Constant Field Values
Method Detail

getServiceName

java.lang.String getServiceName()
Getter for property serviceName.

Returns:
Value of property serviceName.

setServiceName

void setServiceName(java.lang.String name)
Setter for property serviceName.

Parameters:
serviceName - New value of property serviceName.

getNumberOfServices

int getNumberOfServices()
Returns:
the number of services is the pool

getContext

javax.naming.Context getContext(int i)
                                throws javax.naming.NamingException
Given an index it will return this context from the pool

Parameters:
i - index of the context in the pool
Throws:
javax.naming.NamingException - if there is no matching Context

getContext

javax.naming.Context getContext(java.lang.String id)
                                throws javax.naming.NamingException
Given an index it will return this context from the pool

Parameters:
id - (usually the index) of the context
Throws:
javax.naming.NamingException - if there is no matching Context

getContext

javax.naming.Context getContext(javax.naming.Context ctx)
                                throws javax.naming.NamingException
Given a context, it will look for the INSTANCE_ID property and find the matching context in the pool. If it does not exists, it will throw an Exception

Parameters:
context - containing the id property.
Throws:
javax.naming.NamingException - if there is no matching Context

getStatus

java.lang.String getStatus(int index)
return the status of the instance at the given index


getStatus

java.lang.String getStatus(java.lang.String id)
return the status of the instance at the given index


getStatus

java.lang.String getStatus(javax.naming.Context ctx)
Given a context, it will return the status of this context: STATUS_UNKOWN, STATUS_UP, or STATUS_DOWN


markUp

boolean markUp(int index)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
index - of the service service context to mark as up
Returns:
true if it is able to mark the context as up

markUp

boolean markUp(java.lang.String id)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
if - of the service context to mark as up
Returns:
true if it is able to mark the context as up

markUp

boolean markUp(javax.naming.Context ctx)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
Context, - service context to mark as up
Returns:
true if it is able to mark the context as up

markDown

boolean markDown(int index)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
index - of the service service context to mark as down
Returns:
true if it is able to mark the context as down

markDown

boolean markDown(java.lang.String id)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
id - of the service context to mark as down
Returns:
true if it is able to mark the context as down

markDown

boolean markDown(javax.naming.Context ctx)
Given a context, find the matching on in the system (In case this is a copy and not a ref) and then set it to down. If there is not match, this will do nothing.

Parameters:
Context, - service context to mark as down
Returns:
true if it is able to mark the context as down

getAvailableContext

javax.naming.Context getAvailableContext()
                                         throws NoObjectsInPoolException
This is an ORDERED pool. So it will grab the FIRST UP context. So if there are 10 possible contexts in the pool, and instance 1 never goes down, the other 9 will NEVER be used. This is good for failover only situations.

Throws:
NoObjectsInPoolException

addContext

void addContext(javax.naming.Context ctx)
                throws javax.naming.NamingException
Add a loaded context to this pool. This requires that the context is not null, as the INSTANCE_ID property set, and that the SERVICE_NAME property matches this service pools name.

Throws:
javax.naming.NamingException - if we cannot add this context to this pool.