2006-10-20
iproxy模块代码备份(sessionbean,mdb,jms)
现备份一下IProxy模块代码:包含:
1:一个无状态SessionBean:负责JMS和http服务
2:一个MDB:负责监听一个message queue,并调用其它模块ejb.
其它辅助类我就不备份了,纯属个人备份,如果有人对sessionbean,mdb感兴趣,可以参考.
一:负责JMS服务的实现类为JmsService,负责http服务的实现类为:HttpService,为了调用方便,它们都实现ServiceInterface接口:
package co.iproxy.service;

/** *//**
* @author lichunlei
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public interface ServiceInterface 
...{
/** *//**
* Send message and receive the response content
* @param request xml request
* @return the response
* @throws Exception
*/
public String syncRequest(String request) throws Exception;

/** *//**
* Send message and receive the response status
* @param request xml request
* @return the response status
* @throws Exception
*/
public String request(String request) throws Exception;

/** *//**
* Release the used resourses
*
*/
public void clear();
}SessionBean的实现类(home,local和remote接口没有备份)
package co.iproxy.sb;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import co.iproxy.exception.IProxyException;
import co.iproxy.exception.ParamInvalidIProxyException;
import co.iproxy.jms.JmsService;
import co.iproxy.service.IProxyConfig;
import co.iproxy.service.IProxyConstants;
import co.iproxy.service.MessageInfo;
import co.iproxy.service.ServiceInterface;

/** *//**
* Bean implementation class for Enterprise Bean: IProxyServiceSession
*/
public class IProxyServiceSessionBean implements javax.ejb.SessionBean
...{
private javax.ejb.SessionContext mySessionCtx;
private InitialContext context = null;

/** *//**The map which contains the services for sending and receiving message*/
private Map services = new HashMap();
// private ServiceInterface service = null;

/** *//**
* getSessionContext
*/
public javax.ejb.SessionContext getSessionContext()
...{
return mySessionCtx;
}
/** *//**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx)
...{
mySessionCtx = ctx;
}

/** *//**
* ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException
...{
this.getContext();
//cache the environment variable name: sb/JmsServiceSessionBean_Cfg_File
String cfgVarName = new StringBuffer().append(IProxyConstants.LOOKUP_PATH).append("/")
.append(IProxyConstants.ENV_JMS_CFG_NAEM)
.toString();
//Cache the configration file name from the environment variable.
String file;
try
...{
file = (String) context.lookup(cfgVarName);
this.setupInit(file);
}
catch (NamingException e)
...{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

/** *//**
* Get the context of the container
*
*/
private void getContext()
...{
try
...{
this.context = new InitialContext();
}
catch (NamingException e)
...{
try
...{
this.context = new InitialContext();
}
catch (NamingException e1)
...{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}

/** *//**
* Initialize the param for IProxy
* @param filepath the path of configuration file
*/
private void setupInit(String filepath)
...{
//Initalize JMS params for request
IProxyConfig config = new IProxyConfig(filepath);
IProxyConstants.DEF_REP_QCF = config.getResponseQcfactory();
IProxyConstants.DEF_REP_Q = config.getResponseDestination();
IProxyConstants.DEF_REP_TIMEOUT = config.getResponseTimeout();
//Initalize JMS params for response
IProxyConstants.DEF_REQ_QCF = config.getRequestQcfactory();
IProxyConstants.DEF_REQ_Q = config.getRequestDestination();
IProxyConstants.msgProperties = config.getMessageProperties();
//Initalize http params for http service
IProxyConstants.DEF_SERVLET_URL = config.getServletUrl();
IProxyConstants.DEF_SERVLET_PORT = config.getServletPort();
IProxyConstants.DEF_SERVLET_HOST = config.getServletHost();
IProxyConstants.DEF_PROXY_URL = config.getProxyUrl();
IProxyConstants.DEF_PROXY_PORT = config.getProxyPort();
System.out.println("in init: " + IProxyConstants.msgProperties);
services = config.getServices();

}

/** *//**
* ejbActivate
*/img
发表评论
- 浏览: 39441 次
- 性别:

- 来自: 武汉

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
EJB2.1 & EJB3.0: Timer S ...
好像都没有提到EJB3下的timer service如何建立
-- by Joo -
纯java 的javascript引擎 ...
lcllcl987 写道此言差矣! 比如:如果你的应用有脚本功能,你可以在你的应 ...
-- by manyinjin -
Velocity心得
FileUtil的代码没有啊? 想知道 String loadpath = F ...
-- by douglas_lhs -
java:MD5加密字符串
说得不详细..注释也少.只能自用吧..不太好!
-- by dingdangxiaoma -
nio socket 及其开源框架 ...
文章写的很好,不知道是否可以将你的backport-util-concurren ...
-- by lk_03626






评论排行榜