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

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

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

    java Source

      BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
      14 Posts :: 24 Stories :: 8 Comments :: 0 Trackbacks
    /*
     * LogMessageBean.java
     * Copyright (C) 2009  <JustinLei@gmail.com>
     *
     *        This program is free software; you can redistribute it and/or modify
     *        it under the terms of the GNU General Public License as published by
     *      the Free Software Foundation; either version 2 of the License, or
     *     (at your option) any later version.
     *
     *       This program is distributed in the hope that it will be useful,
     *      but WITHOUT ANY WARRANTY; without even the implied warranty of
     *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *        GNU General Public License for more details.
     *
     
    */
    package org.lambdasoft.mdb;

    import java.util.Map;

    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDriven;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.ObjectMessage;
    import javax.naming.InitialContext;

    import org.lambdasoft.components.log.BaseLogSendInterface;
    import org.lambdasoft.components.log.OperateType;
    import org.lambdasoft.components.log.param.LogParam;
    import org.lambdasoft.utils.FileUtil;

    /**
     * 日志添加消息
     * 
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date 2009-9-17
     * 
    @version 1.0
     
    */
    @MessageDriven(activationConfig 
    = {
            @ActivationConfigProperty(propertyName 
    = "destinationType", propertyValue = MessageConstant.DESTINATIONTYPE_QUEUE),
            @ActivationConfigProperty(propertyName 
    = "acknowledgeMode", propertyValue = MessageConstant.ACKNOWLEDGEMODE_AUTO),
            @ActivationConfigProperty(propertyName 
    = "destination", propertyValue = MessageConstant.DESTINATION_LOG) })
    public class LogMessageBean implements MessageListener{
        
    public static final String LOG_PREFIX = "LOG.TYPE.BEAN.";
        
    private Map<String, String> logConfigure;
        
    public void onMessage(Message message) {
            
    if(!(message instanceof ObjectMessage))
                
    return;
            ObjectMessage objectMessage 
    = (ObjectMessage)message;
            
    try {
                
    if(!(objectMessage.getObject() instanceof LogParam))
                    
    return;
                LogParam logParam 
    = (LogParam)objectMessage.getObject();
                InitialContext context 
    = new InitialContext();
                
    for (Object level : logParam.getOperateTypes()) {
                    OperateType operateType 
    = (OperateType)level;
                    String ejbName 
    = getConfigure().get(LOG_PREFIX + (operateType.toString()));
                    Object sendComponent 
    = context.lookup(ejbName);
                    
    if (sendComponent != null
                            
    && (sendComponent instanceof BaseLogSendInterface)) {
                        ((BaseLogSendInterface) sendComponent).log(logParam);
                    }
                }
            } 
    catch (Exception e) {
                e.printStackTrace();
                
    return;
            }
        }
        
        
    private Map<String, String> getConfigure() {
            String propertiesName 
    = "/org/lambdasoft/components/log/ejb/logConfigure.properties";
            
    try {
                logConfigure 
    = FileUtil.getPropertiesMap(LogMessageBean.class,propertiesName);
                
    return logConfigure;
            } 
    catch (Exception e) {
                
    return null;
            }
        }
    }



    /*
     * MessageConstant.java
     * Copyright (C) 2009  <JustinLei@gmail.com>
     *
     *        This program is free software; you can redistribute it and/or modify
     *        it under the terms of the GNU General Public License as published by
     *      the Free Software Foundation; either version 2 of the License, or
     *     (at your option) any later version.
     *
     *       This program is distributed in the hope that it will be useful,
     *      but WITHOUT ANY WARRANTY; without even the implied warranty of
     *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *        GNU General Public License for more details.
     *
     
    */
    package org.lambdasoft.mdb;

    /**
     * 消息驅動bean定義
     * 
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date 2009-9-18
     * 
    @version 1.0
     
    */
    public class MessageConstant {
        
    public static final String DESTINATIONTYPE_QUEUE = "javax.jms.Queue";
        
    public static final String ACKNOWLEDGEMODE_AUTO = "Auto-acknowledge";//會話確認模式
        
        
    public static final String DESTINATION_CACHE = "queue/AO_CACHE";
        
    public static final String DESTINATION_LOG = "queue/AO_LOG";
        
    public static final String DESTINATION_MAIL = "queue/AO_MAIL";
        
    public static final String DESTINATION_CACHE_REFLASH = "queue/AO_CACHE_REFLASH";
        
        
    private MessageConstant() {}
        
    }



    /*
     * LogMessage.java
     * Copyright (C) 2009  <JustinLei@gmail.com>
     *
     *     This program is free software; you can redistribute it and/or modify
     *     it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     *   This program is distributed in the hope that it will be useful,
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     */
    package org.lambdasoft.mdb;

    import java.io.Serializable;

    /**
     * 
     * @author lei.tang (justinlei@gmail.com)
     * @date 2009-9-17
     * @version 1.0
     */
    public interface LogMessage extends Serializable{
    String getType();
    String getLevel();
    String getLog();
    }

    posted on 2009-12-18 15:17 JustinLei 閱讀(1078) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲精品高清在线| 黄色网址免费观看| 亚洲性久久久影院| 黄色一级视频免费| 免费真实播放国产乱子伦| 亚洲精品国产suv一区88| 手机看片久久国产免费| 国产综合激情在线亚洲第一页| 亚洲视频免费一区| 亚洲日韩一区二区一无码| 成人性生交大片免费看无遮挡 | 91福利免费视频| 国产又粗又长又硬免费视频| 亚洲AV无码欧洲AV无码网站| 国产成人AV片无码免费| 国产成人免费高清在线观看| 亚洲精品成人图区| 9久9久女女免费精品视频在线观看| 在线A亚洲老鸭窝天堂| baoyu122.永久免费视频| 亚洲嫩草影院久久精品| 1000部国产成人免费视频| 亚洲日韩中文字幕一区| 亚洲w码欧洲s码免费| 国产成人亚洲综合网站不卡| 国产精品深夜福利免费观看 | 伊人久久精品亚洲午夜| 精品一区二区三区免费毛片| 怡红院亚洲怡红院首页| 日韩电影免费在线观看网址| 亚洲AV无码一区二区三区系列| 午夜成人无码福利免费视频| 国产V亚洲V天堂无码久久久| 国产在线a免费观看| 日韩在线视频免费| 亚洲黄色免费网站| 免费A级毛片无码A| 老汉精品免费AV在线播放| 亚洲AV无码一区二区三区性色| 免费人成视频在线| 亚洲熟妇少妇任你躁在线观看|