EJB2之照猫画虎

本文介绍了一个用于查询企业信息的代理类实现,包括单例模式的应用、远程服务定位及异常处理等关键技术点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代理

public class EnterpriseInfoProxy {
private static Logger logger = Logger.getLogger(EnterpriseInfoProxy.class);

private static EnterpriseInfoProxy instance = null;

private EnterpriseInfoProxy() {
}

/**
* 返回单个本类对象
*
* @return CaTabProxy
*/
public synchronized static EnterpriseInfoProxy getInstance() {
if (instance == null) {
instance = new EnterpriseInfoProxy();
}
return instance;
}
/**
* 查询企业信息列表
* @param cond
* @return
* @throws DaoException
* @throws SystemException
*/
public List queryEnterpriseList(EnterpriseInfoCond cond) throws DaoException, SystemException {
List list = null;
try {
RemoteServiceLocator locator = null;
locator = RemoteServiceLocator.getInstance();

EnterpriseInfoFacade var = ((EnterpriseInfoFacadeHome) locator
.getHome("EnterpriseInfoFacade")).create();
list = var.queryEnterpriseList(cond);
} catch (DaoException daoex) {
logger.error(daoex, daoex);
throw daoex;
} catch (Exception ex) {
logger.error(ex, ex);
throw new SystemException(ex.getMessage());
}
return list;
}
}



public interface EnterpriseInfoFacade extends EJBObject {
/**
* 查询企业信息列表
* @param cond
* @return
* @throws DaoException
* @throws SystemException
*/
public List queryEnterpriseList(EnterpriseInfoCond cond) throws DaoException, SystemException,RemoteException;
}


public class EnterpriseInfoFacadeBean implements SessionBean {
SessionContext sessionContext;
private static Logger logger = Logger
.getLogger(EnterpriseInfoFacadeBean.class);

public void ejbCreate() throws CreateException {
}
public void ejbActivate() throws EJBException, RemoteException {
}

public void ejbPassivate() throws EJBException, RemoteException {
}

public void ejbRemove() throws EJBException, RemoteException {
}

public void setSessionContext(SessionContext arg0) throws EJBException,
RemoteException {
this.sessionContext = arg0;
}

/**
* 查询企业信息列表
*
* @param cond
* @return
* @throws DaoException
* @throws SystemException
*/
public List queryEnterpriseList(EnterpriseInfoCond cond)
throws DaoException, SystemException {
DaoManager dao = null;
List list = null;
try {
// 获取DAO
dao = DaoManagerFactory.getDaoManager();
EnterpriseInfoDao var = (EnterpriseInfoDao) dao
.getDao(EnterpriseInfoDao.class);

dao.startTransaction();
list = var.getInfoList(cond);
dao.commitTransaction();
logger.info(list);
return list;
} catch (DaoException ex) {
logger.error(ex, ex);
throw ex;
} catch (Exception ex) {
logger.error(ex, ex);
throw new SystemException(ex.getMessage());
} finally {
if (dao != null) {
dao.endTransaction(); // 关闭事务,关闭数据库连接
}
}
}
}


public interface EnterpriseInfoFacadeHome extends EJBHome {

public EnterpriseInfoFacade create() throws CreateException, RemoteException;;

}


在ejb-jar.xml和jboss.xml里配置所添加的实体,打包,发布
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值