EJB2.0 HelloWorld 程序.

1.TradeBean.java 代码如下:

import java.rmi.RemoteException; import javax.ejb.EJBException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; /** * XDoclet-based session bean. The class must be declared * public according to the EJB specification. * * To generate the EJB related files to this EJB: * - Add Standard EJB module to XDoclet project properties * - Customize XDoclet configuration for your appserver * - Run XDoclet * * Below are the xdoclet-related tags needed for this EJB. * * @ejb.bean name="Trade" * display-name="Name for Trade" * description="Description for Trade" * jndi-name="ejb/Trade" * type="Stateless" * view-type="both" */ public class TradeBean implements SessionBean { /** The session context */ private SessionContext context; public TradeBean() { super(); } public void ejbCreate() throws EJBException{ System.out.println(" ejb create "); } public void ejbActivate() throws EJBException, RemoteException { System.out.println(" ejb activate "); } public void ejbPassivate() throws EJBException, RemoteException { System.out.println(" ejb passivage "); } public void ejbRemove() throws EJBException, RemoteException { System.out.println(" ejb remove "); } /** * Set the associated session context. The container calls this method * after the instance creation. * * The enterprise bean instance should store the reference to the context * object in an instance variable. * * This method is called with no transaction context. * * @throws EJBException Thrown if method fails due to system-level error. */ public void setSessionContext(SessionContext newContext) throws EJBException { System.out.println(" set session context "); context = newContext; } public String sayHello() throws RemoteException{ return "Welcome to EJB2.0,HXL"; } }

2.TreadeBeanHome.java 程序如下:

import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface TreadeBeanHome extends EJBHome { TreadeBeanRemote create() throws RemoteException,CreateException; }

3.TreadeBeanRemote.java 程序如下:

import java.rmi.RemoteException; import javax.ejb.EJBObject; public interface TreadeBeanRemote extends EJBObject { String sayHello() throws RemoteException; }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值