Package jfun.yan.xml.nuts.spring

Source Code of jfun.yan.xml.nuts.spring.SpringBeanNut

package jfun.yan.xml.nuts.spring;


import java.util.Properties;


import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.ApplicationContext;
import org.springframework.transaction.PlatformTransactionManager;



import jfun.yan.Component;
import jfun.yan.PropertyBinder;
import jfun.yan.spring.SpringAdapter;
import jfun.yan.spring.SpringContext;
import jfun.yan.spring.SpringUtils;
import jfun.yan.xml.SingletonMode;
import jfun.yan.xml.nuts.BeanNut;

/**
* The spring-aware bean tag.
* <p>
* @author Ben Yu
* Nov 17, 2005 12:05:51 AM
*/
public class SpringBeanNut extends BeanNut
implements SpringContext{
  private final SpringService spring;
  private Component tx;
  private Component transaction_attrs;
  private String[] interfaces;
  public void setInit_method(String name){
    setInitializer(name);
  }
  public void setDestroy_method(String name){
    setDisposer(name);
  }
  public void setStart_method(String name){
    setStarter(name);
  }
  public void setStop_method(String name){
    setStopper(name);
  }


  public String[] getInterfaces() {
    return interfaces;
  }

  public void setInterfaces(String[] interfaces) {
    this.interfaces = interfaces;
  }

  public Component getTransactionAttributes() {
    return transaction_attrs;
  }

  public void setTransactionAttributes(Component transaction_attrs) {
    this.transaction_attrs =
      cast(Properties.class, transaction_attrs);
  }

  public Component getTransactionManager() {
    return tx;
  }

  public void setTransactionManager(Component tx) {
    this.tx = cast(PlatformTransactionManager.class, tx);
  }

  public SpringBeanNut(SpringService service) {
    this.spring = service;
  }

  public void manageDisposableBean(DisposableBean instance){
    spring.manageDisposableBean(instance);
  }

  public ApplicationContext getApplicationContext() {
    return spring.getApplicationContext();
  }

  public Component eval(){
    final Component r = super.eval();
    return SpringAdapter.adapt(r, this, tx, transaction_attrs, interfaces);
  }

  public void addBeanPostProcessor(String key, Component bpp) {
    spring.addBeanPostProcessor(key, bpp.getType(), bpp);
  }
 
 
 
  private boolean singleton_attribute_set = false;
  private SingletonMode singleton;
  public SingletonMode getSingleton() {
    return singleton;
  }
  public void setSingleton(SingletonMode singleton) {
    singleton_attribute_set = true;
    this.singleton = singleton;
  }
  public boolean isSingletonAttributeSet() {
    return singleton_attribute_set;
  }
  /**
   * Decorate the autowire mode by filtering out setters defined
   * in the Spring XXXAware marker interfaces.
   */
  public PropertyBinder getPropertyAutowireMode() {
    final PropertyBinder mode = super.getPropertyAutowireMode();
    if(mode==null) return null;
    return SpringUtils.getAutowireWithoutAwareMarkerInterfaces(mode);
  }
}
TOP

Related Classes of jfun.yan.xml.nuts.spring.SpringBeanNut

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.