<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

    #

    該組件實現(xiàn)分為以下幾個部分ChannelEItem,ChannelItem,RssBuildFactory,RssComponentBean
    /*
     * ChannelEItem.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.components.rss.ejb;

    /**
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date
     * 
    @version
     
    */
    public class ChannelEItem extends ChannelItem{
        
    private static final long serialVersionUID = 1L;
        
    private String enclosure;// 流媒體文件

        
    public String getEnclosure() {
            
    return enclosure;
        }

        
    public void setEnclosure(String enclosure) {
            
    this.enclosure = enclosure;
        }
    }

    /*
     * ChannelItem.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.components.rss.ejb;

    import java.io.Serializable;
    import java.util.Date;

    /**
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date
     * 
    @version
     
    */
    public class ChannelItem implements Serializable{
        
    private static final long serialVersionUID = 1L;
        
    private String title;// Rss文件中Item的標題
        private String link;// Rss文件中Item對應的連接
        private String description;// Item的描述
        private Date pubDate;// Item發(fā)布的時間
        private String author;// Item作者
        private String category;// Item所屬的頻道范疇

        
    public String getTitle() {
            
    return title;
        }

        
    public void setTitle(String title) {
            
    this.title = title;
        }

        
    public String getLink() {
            
    return link;
        }

        
    public void setLink(String link) {
            
    this.link = link;
        }

        
    public String getDescription() {
            
    return description;
        }

        
    public void setDescription(String description) {
            
    this.description = description;
        }

        
    public Date getPubDate() {
            
    return pubDate;
        }

        
    public void setPubDate(Date pubDate) {
            
    this.pubDate = pubDate;
        }

        
    public String getAuthor() {
            
    return author;
        }

        
    public void setAuthor(String author) {
            
    this.author = author;
        }

        
    public String getCategory() {
            
    return category;
        }

        
    public void setCategory(String category) {
            
    this.category = category;
        }
    }

    /*
     * RssBuildFactory.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.components.rss.ejb;

    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.Writer;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;

    import com.sun.syndication.feed.synd.SyndCategory;
    import com.sun.syndication.feed.synd.SyndCategoryImpl;
    import com.sun.syndication.feed.synd.SyndContent;
    import com.sun.syndication.feed.synd.SyndContentImpl;
    import com.sun.syndication.feed.synd.SyndEnclosure;
    import com.sun.syndication.feed.synd.SyndEnclosureImpl;
    import com.sun.syndication.feed.synd.SyndEntry;
    import com.sun.syndication.feed.synd.SyndEntryImpl;
    import com.sun.syndication.feed.synd.SyndFeed;
    import com.sun.syndication.feed.synd.SyndFeedImpl;
    import com.sun.syndication.io.FeedException;
    import com.sun.syndication.io.SyndFeedOutput;

    /**
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date
     * 
    @version
     
    */
    public class RssBuildFactory {
        
    private SyndFeed feed;
        @SuppressWarnings(
    "unchecked")
        
    private List entries;
        
    private SyndEntry entry;

        @SuppressWarnings(
    "unchecked")
        
    public RssBuildFactory() {
            feed 
    = new SyndFeedImpl();
            feed.setFeedType(
    "rss_2.0");
            entries 
    = new ArrayList();
        }

        
    /**
         * 創(chuàng)建一個頻道
         * 
         * 
    @param title 頻道標題
         * 
    @param link 頻道對應的連接
         * 
    @param description 頻道描述
         * 
    @param language 頻道所用語言
         * 
    @param pubDate 頻道發(fā)布時期
         * 
    @param copyright 版權(quán)所有
         * 
    @throws Exception
         
    */
        
    public void buildChannel(String title, String link, String description,
                String language, Date pubDate, String copyright)
                
    throws RuntimeException {
            feed.setTitle(title);
            feed.setLink(link);
            feed.setDescription(description);
            feed.setLanguage(language);
            feed.setPublishedDate(pubDate);
            feed.setCopyright(copyright);
        }

        
    /**
         * 添加頻道的子內(nèi)容
         * 
         * 
    @param item
         *            [email={
    @link]{@link[/email] ChannelItem}
         * 
    @throws Exception
         
    */
        @SuppressWarnings(
    "unchecked")
        
    public void buildItems(ChannelItem item) throws RuntimeException {
            entry 
    = new SyndEntryImpl();
            
    // 設(shè)置新聞標題
            entry.setTitle(item.getTitle());
            
    // 設(shè)置新聞的連接地址
            entry.setLink(item.getLink());
            
    // 設(shè)置新聞簡介
            SyndContent content = new SyndContentImpl();
            content.setType(
    "text/plain");
            content.setValue(item.getDescription());
            entry.setDescription(content);
            
    // 設(shè)置發(fā)布時間
            entry.setPublishedDate(item.getPubDate());
            
    // 設(shè)置頻道所屬的范圍
            SyndCategory cate = new SyndCategoryImpl();
            cate.setName(item.getCategory());
            List cateList 
    = new ArrayList();
            cateList.add(cate);
            entry.setCategories(cateList);
            
    // 設(shè)置作者
            entry.setAuthor(item.getAuthor());
            
    // 將新聞項添加至數(shù)組中
            entries.add(entry);
        }

        
    /**
         * 添加頻道的內(nèi)容項
         * 
         * 
    @param item
         *            [email={
    @link]{@link[/email] ChannelEItem}此類繼承自ChannelItem類
         * 
    @throws Exception
         
    */
        @SuppressWarnings(
    "unchecked")
        
    public void buildItems(ChannelEItem item) throws RuntimeException {
            entry 
    = new SyndEntryImpl();
            
    // 設(shè)置新聞標題
            entry.setTitle(item.getTitle());
            
    // 設(shè)置新聞的連接地址
            entry.setLink(item.getLink());
            
    // 設(shè)置新聞簡介
            SyndContent content = new SyndContentImpl();
            content.setValue(item.getDescription());
            entry.setDescription(content);
            
    // 設(shè)置發(fā)布時間
            entry.setPublishedDate(item.getPubDate());
            
    // 設(shè)置頻道所屬的范圍
            SyndCategory cate = new SyndCategoryImpl();
            cate.setName(item.getCategory());
            List cateList 
    = new ArrayList();
            cateList.add(cate);
            entry.setCategories(cateList);
            
    // 設(shè)置作者
            entry.setAuthor(item.getAuthor());
            
    // 設(shè)置流媒體播放文件
            SyndEnclosure en = new SyndEnclosureImpl();
            en.setUrl(item.getEnclosure());
            List enList 
    = new ArrayList();
            enList.add(en);
            entry.setEnclosures(enList);
            
    // 將新聞項添加至數(shù)組中
            entries.add(entry);
        }

        
    /**
         * 生成XML文件
         * 
         * 
    @param outputStream
         * 
    @throws Exception
         
    */
        
    public String buildChannel() throws IOException {
            feed.setEntries(entries);
            SyndFeedOutput output 
    = new SyndFeedOutput();
            Writer writer;
            ByteArrayOutputStream outputStream 
    = new ByteArrayOutputStream();
            writer 
    = new OutputStreamWriter(outputStream, "UTF-8");
            
    try {
                output.output(feed, writer);
                
    return new String(outputStream.toByteArray());
            } 
    catch (FeedException e) {
                
    throw new IOException();
            }
        }
    }


    /*
     * RssComponentBean.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.components.rss.ejb;

    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import javax.interceptor.Interceptors;

    import org.lambdasoft.components.application.RssComponent;
    import org.lambdasoft.components.application.param.RssBuildParam;
    import org.lambdasoft.ejb.interceptors.EjbCheckParamInterceptor;

    /**
     * 
    @author lei.tang (justinlei@gmail.com)
     * @date 
     * 
    @version
     
    */
    @Stateless
    @Remote
    @Interceptors({EjbCheckParamInterceptor.
    class})
    public class RssComponentBean implements RssComponent{
        
    public String buildChannel(RssBuildParam rssBuildParam) throws Exception{
            
    if(rssBuildParam.getChannelEItems() == null)
                
    return null;
            RssBuildFactory builder 
    = new RssBuildFactory();
            
    for (ChannelEItem channelEItem : rssBuildParam.getChannelEItems()) {
                builder.buildItems(channelEItem);
            }
            builder.buildChannel(rssBuildParam.getTitle(),rssBuildParam.getLink(), rssBuildParam.getDescription(),
                    rssBuildParam.getLanguage(), rssBuildParam.getPubDate(), rssBuildParam.getCopyright());
            
    return builder.buildChannel();
        }
    }
    posted @ 2009-12-18 15:24 JustinLei 閱讀(1081) | 評論 (0)編輯 收藏

    /*
     * 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 @ 2009-12-18 15:17 JustinLei 閱讀(1078) | 評論 (0)編輯 收藏

         摘要:   1/**//*   2 * StringUtils.java   3 * Copyright (C) 2007-3-19  <JustinLei@gmail.com>   4 *   5...  閱讀全文
    posted @ 2009-12-18 14:28 JustinLei 閱讀(1370) | 評論 (0)編輯 收藏

         摘要: span { font-family: 'Courier New'; font-size: 10pt; color: #000000; } .sc0 { } .sc1 { color: #008000; } .sc2 { color: #008000; } .sc3 { color: #008080; } .sc4 { color: #FF8000; } .s...  閱讀全文
    posted @ 2009-12-18 14:25 JustinLei 閱讀(1990) | 評論 (0)編輯 收藏

    僅列出標題
    共2頁: 上一頁 1 2 
    主站蜘蛛池模板: 亚洲成AV人片在线观看无| 亚洲啪啪AV无码片| a视频在线免费观看| 国产麻豆免费观看91| 国产成人高清精品免费观看| 亚洲色图黄色小说| 亚洲区小说区激情区图片区| 免费永久国产在线视频| 色影音免费色资源| 中文字幕亚洲综合久久综合| 亚洲欧洲免费视频| 亚洲不卡av不卡一区二区| 成人免费无码精品国产电影| 国产成人精品久久免费动漫| 男人进去女人爽免费视频国产| 亚洲成熟丰满熟妇高潮XXXXX| 在线看片v免费观看视频777| 人与动性xxxxx免费| 亚洲一区二区三区日本久久九| 一级毛片免费播放| 99久热只有精品视频免费看| 在线毛片片免费观看| 全黄大全大色全免费大片| 99在线视频免费观看| 男的把j放进女人下面视频免费| 在线播放国产不卡免费视频| 亚洲视频在线免费| 中文在线免费不卡视频| tom影院亚洲国产一区二区| 人禽杂交18禁网站免费| 女人与禽交视频免费看| 爱情岛论坛网亚洲品质自拍| 热久久这里是精品6免费观看| 免费a级毛片无码a∨免费软件| 暖暖免费在线中文日本| 免费毛片a在线观看67194| 大片免费观看92在线视频线视频| 爽爽爽爽爽爽爽成人免费观看| 无码国产精品一区二区免费式芒果| 免费无码成人AV在线播放不卡| 91网站免费观看|