EJB3.0的生命周期

package com.easyway.tbs;
/**
 * EJB3.0的生命周期
 * @author longgangbai
 *
 */
public interface LifeCycle {
   public String say();
   public void stopSession();
}

 

 

package com.easyway.tbs;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Init;
import javax.ejb.PostActivate;
import javax.ejb.Remove;
/**
 * EJB3.0的生命周期
 * @author longgangbai
 *
 */
public class LifeCycleBean implements LifeCycle {
     @Init
  public void initialize(){
    System.out.println("@Init事件触发"); 
  }
  public String say() {
   // TODO Auto-generated method stub
   return "测试ejb3的生命周期的方法";
  }

  @PostConstruct
  public void construct(){
   System.out.println("@PostConstruct 开始执行...");
  }
  

  
  
  @PreDestroy
  public void exist(){
   System.out.println("@PreDestroy 开始执行...");
  }
  
  
  @PostActivate
  public void activate(){
   System.out.println("@PostActivate 开始执行...");
  }
  

  
  
  @Remove
  public void stopSession(){
   System.out.println("@Remove 开始执行...");
  }
  
}

你可能感兴趣的:(ejb)