org.jini.rio.associations
Class AssociationInjector

java.lang.Object
  extended by org.jini.rio.associations.AssociationInjector
All Implemented Interfaces:
AssociationListener

public class AssociationInjector
extends Object
implements AssociationListener

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.
  
      
  
 


Constructor Summary
AssociationInjector(Object target)
          Create an AssociationInjector
 
Method Summary
 void broken(Association association, Object service)
          Always inject a null if the association is broken
 void changed(Association association, Object service)
          Get the next service in the collection for injection
 void discovered(Association association, Object service)
          Notify the AssociationListener that an Association has been discovered
 
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)
                    throws IntrospectionException
Create an AssociationInjector

Parameters:
target - The object which will have dependencies injected
Throws:
IntrospectionException
Method Detail

discovered

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

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

changed

public void changed(Association association,
                    Object service)
Get the next service in the collection for injection

Specified by:
changed in interface AssociationListener
Parameters:
association - The Association
service - The service that was removed, changing the endpoint
See Also:
AssociationListener.changed(Association, Object)

broken

public void broken(Association association,
                   Object service)
Always inject a null if the association is broken

Specified by:
broken in interface AssociationListener
Parameters:
association - The Association.
service - The service that was removed, causing the Association to be broken
See Also:
AssociationListener.broken(Association, Object)


Copyright (c) 2005 Sun Microsystems, Inc.
Copyright (c) 2006 GigaSpaces Technologies, Inc.
All Rights Reserved.