Rio Project 4.2 API Documentation



org.rioproject.associations
Class AssociationInjector<T>

java.lang.Object
  extended by org.rioproject.associations.AssociationInjector<T>
All Implemented Interfaces:
AssociationListener<T>

public class AssociationInjector<T>
extends Object
implements AssociationListener<T>

The AssociationInjector is an AssociationListener implementation that provides support for setter-based dependency injection by calling setters on a target object method when it receives association events. For example, we have a bean called Foo and it requires JavaSpace. In order to have the JavaSpace proxy set, a setter method is required :

 public class Foo  {
     JavaSpace myJavaSpace;
 
     ...
     public void setMyJavaSpace(JavaSpace space) {
         myJavaSpace = space; 
     }
     ...
 }
 
Finally, in the OperationalString, you'll need to create an Association with a Property attribute which matches the setter.
 associations {
     association type:"uses", name="JavaSpace", property="myJavaSpace"
 }
 

Author:
Dennis Reedy

Constructor Summary
AssociationInjector(Object target)
          Create an AssociationInjector
 
Method Summary
 void broken(Association<T> association, T service)
          Notify the AssociationListener that an Association is broken.
 void changed(Association<T> association, T service)
          Notify the AssociationListener that a service endpoint has changed
 void discovered(Association<T> association, T service)
          Notify the AssociationListener that an Association has been discovered
 Map<AssociationDescriptor,Long> getInvocationMap()
          For each generated association proxy, get the corresponding AssociationDescriptor and how many successful invocations were made to all services in the association.
 void injectEmpty(Association<T> association)
           
 void setBackend(Object target)
          Set the object that will have dependencies injected
 void setCallerClassLoader(ClassLoader callerCL)
          Set The ClassLoader which will be used to load proxies
 void terminate()
          If any AssociationProxy instances were created, make sure they are terminated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssociationInjector

public AssociationInjector(Object target)
Create an AssociationInjector

Parameters:
target - The object that will have dependencies injected
Method Detail

setBackend

public void setBackend(Object target)
Set the object that will have dependencies injected

Parameters:
target - The object that will have dependencies injected

setCallerClassLoader

public void setCallerClassLoader(ClassLoader callerCL)
Set The ClassLoader which will be used to load proxies

Parameters:
callerCL - The classloader for the target

terminate

public void terminate()
If any AssociationProxy instances were created, make sure they are terminated


getInvocationMap

public Map<AssociationDescriptor,Long> getInvocationMap()
For each generated association proxy, get the corresponding AssociationDescriptor and how many successful invocations were made to all services in the association.

Returns:
A Map whose keys are AssociationDescriptor, and values are the number of successful invocations made to all services in the association. If there are no generated association proxy instances, a Map with no entries is returned. A new Map is created each time this method is called.

injectEmpty

public void injectEmpty(Association<T> association)

discovered

public void discovered(Association<T> association,
                       T service)
Description copied from interface: AssociationListener
Notify the AssociationListener that an Association has been discovered

Specified by:
discovered in interface AssociationListener<T>
Parameters:
association - The Association
service - The associated service that has been discovered
See Also:
AssociationListener.discovered(Association, Object)

changed

public void changed(Association<T> association,
                    T service)
Description copied from interface: AssociationListener
Notify the AssociationListener that a service endpoint has changed

Specified by:
changed in interface AssociationListener<T>
Parameters:
association - The Association
service - The service that was removed, changing the endpoint

broken

public void broken(Association<T> association,
                   T service)
Description copied from interface: AssociationListener
Notify the AssociationListener that an Association is broken. If the Association type is requires, the AssociationManagement object will unadvertise the ServiceBean using the ServiceBean instances ServiceBeanControl interface unless the unadvertiseOnBroken is set to false

Specified by:
broken in interface AssociationListener<T>
Parameters:
association - The Association.
service - The service that was removed, causing the Association to be broken

Copyright © Rio Project.

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