⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digitalstorebean.java

📁 关于中间件学习的一些例子 关于中间件学习的一些例子
💻 JAVA
字号:
package com.j2ee.ejb;


import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import javax.ejb.CreateException;

/**
 * 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="DigitalStore"
 *           display-name="Name for DigitalStore"
 *           description="Description for DigitalStore"
 *           jndi-name="ejb/DigitalStore"
 *           type="Stateful"
 *           view-type="remote"
 */
public class DigitalStoreBean implements SessionBean {

	/** The session context */
	private SessionContext context;

	String userID;
	double egold;

	public DigitalStoreBean() {
		super();
		// TODO 自动生成构造函数存根
	}

	/**
	 * 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 {
		context = newContext;
	}

	public void ejbRemove() throws EJBException, RemoteException {
		// TODO 自动生成方法存根

	}

	public void ejbActivate() throws EJBException, RemoteException {
		// TODO 自动生成方法存根

	}

	public void ejbPassivate() throws EJBException, RemoteException {
		// TODO 自动生成方法存根

	}

	/**
	 * Default create method
	 * 
	 * @throws CreateException
	 * @ejb.create-method
	 */
public void ejbCreate(String uid, double eg) throws CreateException {
		// TODO Auto-generated method stub
		if(eg<=0){
			throw new CreateException("初始参数eg无效");
			
		}
		userID = uid;
		egold = eg;
	}	/**
	 * An example business method
	 *
	 * @ejb.interface-method view-type = "remote"
	 * 
	 * @throws EJBException Thrown if method fails due to system-level error.
	 */
	public void replaceWithRealBusinessMethod() throws EJBException {
		// rename and start putting your business logic here
	}

	/**
	 * Business method
	 * @ejb.interface-method  view-type = "remote"
	 */
	public void addegold(double eg) {
		// TODO Auto-generated method stub
		if (eg <= 0)
			return;
		else
			egold += eg;
	}
	/**
	 * Business method
	 * @ejb.interface-method  view-type = "remote"
	 */
	public void withdrawegold(double eg) {
		// TODO Auto-generated method stub
		if (egold <= 0)
			return;
		else
			egold -= eg;
	}
	/**
	 * Business method
	 * @ejb.interface-method  view-type = "remote"
	 */
	public double getRemain() {
		// TODO Auto-generated method stub
		return egold;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -