<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    于吉吉的技術博客

    建造高性能門戶網

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      65 隨筆 :: 6 文章 :: 149 評論 :: 0 Trackbacks
    由于歷史原因,幾個項目都選用hessian作為web service的實現方式,hessian的確是非常輕量級,基于http協議進行傳輸,通過自定義的串行化機制將請求信息進行序列化,以二進制傳輸節省了不少的開銷,速度跟socket差不多.客戶端和服務器發起和接收請求都是通過spring提供的hessian api進行請求和接收,但是在服務端中并沒有記錄和控制遠端ip地址和主機的信息,所以需要對源碼進行一些重寫

    對org.springframework.remoting.caucho.HessianServiceExporter進行重寫

    /**
     * 重寫HessianServiceExporter.handleRequest(),攔截獲取遠端調用信息
     * 
    @author chenyz
     *
     
    */
    public class HouseHessianServiceExporter extends HessianServiceExporter {
        
        
    private static String[] entryIP = {"192.168.0.1","192.168.0.3","192.168.0.3"};
        
        
    private static Log log = LogFactory.getLog("Myremote"); 
        
        @Override
        
    public void handleRequest(HttpServletRequest request,
                HttpServletResponse response) 
    throws ServletException, IOException {        
            log.info(
    "try ==>remote 's IP:"+IpUtil.getIpAddr(request)+"remote 's host: "+request.getRemoteHost());
            
    int call = 0;
            
    for(String ip:entryIP){
                
    if(ip.equals(IpUtil.getIpAddr(request)))
                    call
    ++;
            }
            
    if(call>0){
                log.info(
    "call ==>remote 's IP:"+IpUtil.getIpAddr(request)+"remote 's host: "+request.getRemoteHost());
                
    super.handleRequest(request, response);
            }
        }
    }

       <bean id="shineLibWSImpl" class="com.***.shine.remote.ShineLibWSImpl"/>
        
    <bean name="/remote/shineinfo" class="com.***.shine.hessian.service.HouseHessianServiceExporter">
            
    <property name="service">
                
    <ref bean="shineLibWSImpl"/>
            
    </property>
            
    <property name="serviceInterface">
                
    <value>com.***.shine.remote.ShineLibWebService</value>
            
    </property>
        
    </bean>

    重寫HessianServiceExporter.handleRequest(),攔截獲取遠端調用信息,提取出調用端的ip信息與服務端制定的ip列表進行對比,并將所有調用信息記錄日志

    如果直接使用hessian的api的HessianServlet,直接對HessianServlet的service()重寫,攔截并提取遠端調用信息

    /**
     * 重寫HouseHessianServlet.service(),攔截獲取遠端調用信息
     * 
    @author chenyz
     *
     
    */
    public class HouseHessianServlet extends HessianServlet{
        
        
    private static String[] entryIP = {"192.168.0.1","192.168.0.3","192.168.0.3"};
        
        
    private static Log log = LogFactory.getLog("Myremote"); 
        
        @Override
        
    public void service(ServletRequest request, ServletResponse response)
                
    throws IOException, ServletException {
            HttpServletRequest req 
    = (HttpServletRequest) request;
            log.info(
    "try ==>remote 's IP:"+IpUtil.getIpAddr(req)+"remote 's host: "+request.getRemoteHost());
            
    int call = 0;
            
    for(String ip:entryIP){
                
    if(ip.equals(IpUtil.getIpAddr(request)))
                    call
    ++;
            }
            
    if(call>0){
                log.info(
    "call ==>remote 's IP:"+IpUtil.getIpAddr(req)+"remote 's host: "+request.getRemoteHost());
                
    super.service(request, response);
            }
        }
    }

    web.xml

       <servlet>   
        
    <servlet-name>HessianServlet</servlet-name>   
        
    <servlet-class>   
            com.***.product.remote.Htest
        
    </servlet-class>   
      
    </servlet>  

      
    <servlet-mapping>   
        
    <servlet-name>HessianServlet</servlet-name>   
        
    <url-pattern>/service/hession</url-pattern>   
      
    </servlet-mapping>  

    com.***.product.remote.Htest

    public class Htest extends HouseHessianServlet implements IHtest{
        
        
    public hello(){
            System.out.println(
    "hello");
        }
    }


    posted on 2010-12-21 16:05 陳于喆 閱讀(3039) 評論(0)  編輯  收藏 所屬分類: javaweb service
    主站蜘蛛池模板: 国产精品爱啪在线线免费观看| www一区二区www免费| 67194国产精品免费观看| 亚洲AV午夜福利精品一区二区| 亚洲人午夜射精精品日韩| 国产成人精品日本亚洲语音| 国产精品冒白浆免费视频| 亚洲AV无码欧洲AV无码网站| 青柠影视在线观看免费高清| 国产精品亚洲片在线观看不卡| 亚洲人成日本在线观看| 精品人妻系列无码人妻免费视频| 亚州免费一级毛片| 国产成人精品久久亚洲| 亚州**色毛片免费观看| 毛片免费在线播放| 久久精品国产亚洲av麻| 免费国产污网站在线观看15| 亚洲综合区小说区激情区| a一级爱做片免费| 亚洲AV日韩AV天堂久久| 一个人看的免费视频www在线高清动漫| 亚洲福利视频一区二区| 久久er国产精品免费观看2| 亚洲日本精品一区二区| 最近最新中文字幕完整版免费高清 | 亚洲国产成人久久综合碰碰动漫3d| 人妻无码一区二区三区免费| 亚洲午夜久久久久久尤物| 日韩一区二区三区免费体验| 一个人看的www在线免费视频| 亚洲色无码一区二区三区| 免费观看激色视频网站(性色)| 亚洲中文字幕一二三四区| 亚洲一区二区三区在线播放| av片在线观看永久免费| 亚洲精品国产肉丝袜久久| 久久精品免费一区二区喷潮| 成人久久久观看免费毛片| 亚洲男人天堂2017| 免费人成视频x8x8入口|