Package jfun.yan.xml.nuts.spring

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

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.spring.SpringAdapter;
import jfun.yan.spring.SpringContext;
import jfun.yan.xml.SingletonMode;
import jfun.yan.xml.nuts.MethodNut;

/**
* A spring-aware method tag.
* <p>
* @author Ben Yu
* Nov 17, 2005 12:07:25 AM
*/
public class SpringMethodNut extends MethodNut 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 SpringMethodNut(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;
  }
}
TOP

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

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.