EJB 2.0嗤彜蓑SessionBean
扮寂:2011-09-14 51cto鴬人 leizhimin
桟廠?
JBoss 4.0.2
JDK1.5
IDEA8.1.4
匯、EJB蝕窟
package lavasoft.testejb20yzt;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
/**
* Bean窃
* 侭嗤醤悶議匍暦貸辞脅壓緩窃戦中?緩窃音砺竃垓殻呟窃
*
* @author leizhimin 2010-3-31 15:26:53
*/
public class HelloStatefulBean implements SessionBean /
private SessionContext context;
private String someOne;
/**
* 匍暦圭隈
*
* @return Hello議?連
*/
public String sayHello() /
System.out.println("HelloStatefulBean: sayHello() is called!");
return "Hello, " + someOne + "!";
}
/**
* 駅倬嗤宸倖圭隈?宸頁EJB議匯訳圻夸?宸倖圭隈音頁栖徭SessionBean俊笥議
* 宸峪嬬頁匯倖嗤彜蓑議bean,咀葎涙彜蓑議bean茅阻涙歌方議create圭隈翌? 音嬬嗤凪麿議幹秀圭隈
*/
public void ejbCreate(String someOne) /
System.out.println("HelloStatefulBean: ejbCreate(String someOne) is called!");
this.someOne = someOne;
}
//-------和中膨倖圭隈頁栖徭SessionBean議?駅倬亟竃栖?徽短俵喘-------
public void ejbActivate() /
System.out.println("HelloStatefulBean: ejbActivate() is called!");
}
public void ejbPassivate() /
System.out.println("HelloStatefulBean: ejbPassivate() is called!");
}
public void ejbRemove() /
System.out.println("HelloStatefulBean: ejbRemove() is called!");
}
public void setSessionContext(SessionContext sessionContext) /
System.out.println("HelloStatefulBean: setSessionContext() is called!");
context = sessionContext;
}
}
package lavasoft.testejb20yzt;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
/**
* 怏周俊笥
* 侭嗤議匍暦圭隈脅勣壓緩俊笥嶄蕗苧
*
* @author leizhimin 2010-3-31 15:31:10
*/
public interface HelloStateful extends EJBObject /
/**
* 匍暦圭隈?怏周俊笥嶄議匍暦圭隈駅倬砺竃RemoteException
*
* @return
* @throws java.rmi.RemoteException
*/
public String sayHello() throws RemoteException;
}
EJB 2.0有状态SessionBean(2)
时间:2011-09-14 51cto博客 leizhimin
package lavasoft.testejb20yzt;
import javax.ejb.Crea
|