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

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

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

    java Source

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      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;

    /**
     * 消息驅(qū)動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 閱讀(1075) 評論(0)  編輯  收藏

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


    網(wǎng)站導航:
     
    主站蜘蛛池模板: sss日本免费完整版在线观看| 亚洲人成欧美中文字幕| 国产特黄一级一片免费 | 免费网站看v片在线香蕉| 亚洲精品美女在线观看| 95老司机免费福利| 亚洲毛片无码专区亚洲乱| 91网站免费观看| 亚洲精品无码久久久久A片苍井空| 免费激情视频网站| 日韩精品视频在线观看免费| 国产啪亚洲国产精品无码| 国产免费久久精品丫丫| 亚洲AV中文无码字幕色三| 久久永久免费人妻精品| 亚洲欧洲日产韩国在线| 妞干网免费视频观看| 爱爱帝国亚洲一区二区三区| 亚洲成A∨人片天堂网无码| 久久高潮一级毛片免费| 亚洲AV永久纯肉无码精品动漫| 2021国内精品久久久久精免费| 亚洲一区二区三区亚瑟| 免费在线观看亚洲| 日韩精品无码免费专区网站| 亚洲区视频在线观看| 日产乱码一卡二卡三免费| 亚洲精品黄色视频在线观看免费资源| 亚洲国产精品VA在线观看麻豆| 亚洲精品在线免费观看| 久久精品国产亚洲av品善| 国产亚洲精品xxx| 在线视频精品免费| 免费无码午夜福利片| 91大神亚洲影视在线| 日本媚薬痉挛在线观看免费| 国产高潮久久免费观看| 亚洲日本在线免费观看| 亚洲AV伊人久久青青草原 | 一二三四在线播放免费观看中文版视频| 最新亚洲人成网站在线观看|