备份(sessionbean,mdb,jms)

现备份一下代码:包含:
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();
        

    }

&nbs
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值