Rio Project 4.2 API Documentation



org.rioproject.associations
Class AssociationMgmt

java.lang.Object
  extended by org.rioproject.associations.AssociationMgmt
All Implemented Interfaces:
AssociationManagement

public class AssociationMgmt
extends Object
implements AssociationManagement

The AssociationMgmt class implements the AssociationManagement interface.

Author:
Dennis Reedy

Nested Class Summary
 class AssociationMgmt.AssociationHandler
          The AssociationHandler handle an Association created from AssociationDescriptor.
 
Constructor Summary
AssociationMgmt()
          Create an AssociationMgmt instance.
AssociationMgmt(ClassLoader cl)
          Create an AssociationMgmt instance.
 
Method Summary
<T> Association<T>
addAssociationDescriptor(AssociationDescriptor aDesc)
          Add an association to the managed set of associations.
 List<Association<?>> addAssociationDescriptors(AssociationDescriptor... aDescs)
          Add associations to the managed set of associations.
protected  AssociationMgmt.AssociationHandler createAssociationHandler(AssociationDescriptor aDesc)
          Create an AssociationHandler
<T> Association<T>
getAssociation(Class<T> serviceType, String serviceName, String opStringName)
          Get the first matching Association.
 AssociationMgmt.AssociationHandler getAssociationHandler(Association association)
           
protected  AssociationListener<?>[] getAssociationListeners()
          Get all AssociationListener instances
 List<Association<?>> getAssociations()
          Get all managed associations.
protected  Configuration getConfiguration()
           
protected  void notifyOnBroken(Association association, Object service)
          Notify listeners that the Association is broken
protected  void notifyOnChange(Association association, Object service)
          Notify listeners on Association change
protected  void notifyOnDiscovery(Association association, Object service)
          Notify listeners on discovery
 void register(AssociationListener... listeners)
          Register AssociationListeners.
 void remove(AssociationListener... listeners)
          Remove AssociationListeners
 void setBackend(Object backend)
          Set the PropertyDescriptor elements.
 void setClientName(String clientName)
          Set the name of the client that has the associations.
 void setConfiguration(Configuration config)
           
 void setServiceBeanContainer(ServiceBeanContainer container)
          Set the ServiceBeanContainer object
 void setServiceBeanContext(ServiceBeanContext context)
          Set the ServiceBeanContext object for the ServiceBean
 void setServiceBeanControl(ServiceBeanControl control)
          Set the ServiceBeanControl object for the ServiceBean
 void setUnadvertiseOnBroken(boolean unadvertiseOnBroken)
          Set unadvertiseOnBroken
 void terminate()
          Terminate AssociationManagement, cleaning up all connections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssociationMgmt

public AssociationMgmt()
Create an AssociationMgmt instance. Uses the current thread's context class loader to provide the caller/client with properly annotated proxies for associated services


AssociationMgmt

public AssociationMgmt(ClassLoader cl)
Create an AssociationMgmt instance. Uses the specified class loader to provide the caller/client with properly annotated proxies for associated services, or the current thread's context class loader if cl is null.

Parameters:
cl - The class loader to provide the caller/client with properly
Method Detail

setUnadvertiseOnBroken

public void setUnadvertiseOnBroken(boolean unadvertiseOnBroken)
Set unadvertiseOnBroken

Specified by:
setUnadvertiseOnBroken in interface AssociationManagement
Parameters:
unadvertiseOnBroken - If true, and the service has an Association with a type of AssociationType.REQUIRES and the Association is broken, the AssociationManagement object will unadvertise the ServiceBean using the ServiceBean instance's ServiceBeanControl object. If false, the AssociationManagement object will not unadvertise the ServiceBean

setServiceBeanControl

public void setServiceBeanControl(ServiceBeanControl control)
Description copied from interface: AssociationManagement
Set the ServiceBeanControl object for the ServiceBean

Specified by:
setServiceBeanControl in interface AssociationManagement
Parameters:
control - The ServiceBeanControl object for the ServiceBean
See Also:
AssociationManagement.setServiceBeanControl(org.rioproject.jsb.ServiceBeanControl)

setServiceBeanContainer

public void setServiceBeanContainer(ServiceBeanContainer container)
Set the ServiceBeanContainer object

Specified by:
setServiceBeanContainer in interface AssociationManagement
Parameters:
container - The ServiceBeanContainer that the ServiceBean is running in

register

public void register(AssociationListener... listeners)
Register AssociationListeners. Each listener object will receive notifications of Association state changes. Once a listener is registered, it will be notified of all Association references discovered to date, and will be notified as Associations are discovered, changed or broken. If the parameter value duplicates (using equals) another element in the set of listeners, no action is taken. If the parameter value is null, an IllegalArgumentException is thrown

Specified by:
register in interface AssociationManagement
Parameters:
listeners - the AssociationListeners

remove

public void remove(AssociationListener... listeners)
Remove AssociationListeners

Specified by:
remove in interface AssociationManagement
Parameters:
listeners - the AssociationListeners

terminate

public void terminate()
Terminate AssociationManagement, cleaning up all connections

Specified by:
terminate in interface AssociationManagement

getAssociation

public <T> Association<T> getAssociation(Class<T> serviceType,
                                         String serviceName,
                                         String opStringName)
Get the first matching Association.

Specified by:
getAssociation in interface AssociationManagement
Parameters:
serviceType - The service type to match, must not be null
serviceName - String name of the associated service. If null will be ignored
opStringName - String name of the OperationalString. If null will be ignored
Returns:
The first Association instance that matches the provided criteria. If there no matching associations, a null will be returned.

getAssociations

public List<Association<?>> getAssociations()
Get all managed associations.

Specified by:
getAssociations in interface AssociationManagement
Returns:
An unmodifiable List of Association objects. A new list is created each time.

setBackend

public void setBackend(Object backend)
Set the PropertyDescriptor elements. This will be used to inject associated services

Parameters:
backend - The backend (implementation) to use for property injection

setClientName

public void setClientName(String clientName)
Set the name of the client that has the associations.

Parameters:
clientName - The name of the client that has the associations. This is used for logging and diagnostics

setServiceBeanContext

public void setServiceBeanContext(ServiceBeanContext context)
Description copied from interface: AssociationManagement
Set the ServiceBeanContext object for the ServiceBean

Specified by:
setServiceBeanContext in interface AssociationManagement
Parameters:
context - The ServiceBeanContest object for the ServiceBean
See Also:
AssociationManagement.setServiceBeanContext(org.rioproject.core.jsb.ServiceBeanContext)

getConfiguration

protected Configuration getConfiguration()

setConfiguration

public void setConfiguration(Configuration config)

getAssociationHandler

public AssociationMgmt.AssociationHandler getAssociationHandler(Association association)

getAssociationListeners

protected AssociationListener<?>[] getAssociationListeners()
Get all AssociationListener instances

Returns:
An Array of AssociationListener instances. A new array is allocated each time. If there are no AssociationListener instances a zero-length array is returned

createAssociationHandler

protected AssociationMgmt.AssociationHandler createAssociationHandler(AssociationDescriptor aDesc)
Create an AssociationHandler

Parameters:
aDesc - The AssociationDescriptor to create an AssociationHandler for
Returns:
An AssociationHandler for the AssociationDescriptor. A new AssociationHandler is created each time this method is called
Throws:
NullPointerException - if the AssociationDescriptor is null

addAssociationDescriptor

public <T> Association<T> addAssociationDescriptor(AssociationDescriptor aDesc)
Add an association to the managed set of associations. If the association already exists, it will not be added.

Specified by:
addAssociationDescriptor in interface AssociationManagement
Parameters:
aDesc - The AssociationDescriptor
Returns:
An Association object.
See Also:
AssociationProxy, ServiceSelectionStrategy

addAssociationDescriptors

public List<Association<?>> addAssociationDescriptors(AssociationDescriptor... aDescs)
Add associations to the managed set of associations. If any of the associations already exists, it will not be added.

Specified by:
addAssociationDescriptors in interface AssociationManagement
Parameters:
aDescs - AssociationDescriptor instances
Returns:
An unmodifiable List of Association objects corresponding to the submitted descriptors. A new list is created each time.
See Also:
AssociationProxy, ServiceSelectionStrategy

notifyOnDiscovery

protected void notifyOnDiscovery(Association association,
                                 Object service)
Notify listeners on discovery

Parameters:
association - The Association
service - The discovered service

notifyOnChange

protected void notifyOnChange(Association association,
                              Object service)
Notify listeners on Association change

Parameters:
association - The Association
service - The discovered service

notifyOnBroken

protected void notifyOnBroken(Association association,
                              Object service)
Notify listeners that the Association is broken

Parameters:
association - The Association
service - The discovered service

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.