jfun.yan.spring
Class SpringAdapter

java.lang.Object
  extended by jfun.yan.spring.SpringAdapter

public class SpringAdapter
extends java.lang.Object

The main adapter class to between Yan and Spring.

Author:
Ben Yu Nov 17, 2005 12:01:20 AM

Constructor Summary
SpringAdapter()
           
 
Method Summary
static Component adapt(Component c, SpringContext ctxt, Component transaction_manager, Component transaction_attributes, java.lang.String[] interfaces)
          Decorate a Component with spring context so that dependencies can be injected automatically, and FactoryBean can be automatically instantiated.
static org.springframework.beans.factory.FactoryBean getFactoryBean(Container yan, java.lang.Object key)
          Get FactoryBean instance from a Spring integrated Container object.
static java.lang.Object injectBean(java.lang.Object obj, SpringContext ctxt, org.springframework.transaction.PlatformTransactionManager transaction_manager, java.util.Properties transaction_attributes, java.lang.String[] interfaces)
          Inject spring dependencies into an object when it is of any Spring marker interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringAdapter

public SpringAdapter()
Method Detail

injectBean

public static java.lang.Object injectBean(java.lang.Object obj,
                                          SpringContext ctxt,
                                          org.springframework.transaction.PlatformTransactionManager transaction_manager,
                                          java.util.Properties transaction_attributes,
                                          java.lang.String[] interfaces)
                                   throws java.lang.Exception
Inject spring dependencies into an object when it is of any Spring marker interface. Run FactoryBean if any. Add transaction proxy if any.

Parameters:
obj - the object to inject dependencies.
ctxt - the SpringContext object hosting all pertinent runtime information.
transaction_manager - the Component that instantiates the transaction manager. Can be null if transaction_attributes is null.
transaction_attributes - the Component that instantiates a Properties object that contains transaction attributes. This is the indicator parameter. When it is null, no transaction proxying is done. And when it is not null, the transaction_manager cannot be null.
interfaces - the interface names to proxy on. Can be null.
Returns:
the final result object.
Throws:
java.lang.Exception

adapt

public static Component adapt(Component c,
                              SpringContext ctxt,
                              Component transaction_manager,
                              Component transaction_attributes,
                              java.lang.String[] interfaces)
Decorate a Component with spring context so that dependencies can be injected automatically, and FactoryBean can be automatically instantiated.

Parameters:
c - the Component object.
ctxt - the SpringContext object.
transaction_manager - the Component that instantiates the transaction manager. Can be null if transaction_attributes is null.
transaction_attributes - the Component that instantiates a Properties object that contains transaction attributes. This is the indicator parameter. When it is null, no transaction proxying is done. And when it is not null, the transaction_manager cannot be null.
interfaces - the interface names to proxy on. Can be null.
Returns:
the new Component that does all the spring-related work.

getFactoryBean

public static org.springframework.beans.factory.FactoryBean getFactoryBean(Container yan,
                                                                           java.lang.Object key)
Get FactoryBean instance from a Spring integrated Container object.

Parameters:
yan - the Container object.
key - the key of the FactoryBean component. The key doesn't need to be prefixed with a '&' as one has to do in Spring.
Returns:
the FactoryBean instance.