com/scalagent/joram/mom/dest/mail/JavaMailTopic.java

00001 /*
00002  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
00003  * Copyright (C) 2003 - 2008 ScalAgent Distributed Technologies
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or any later version.
00009  * 
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00018  * USA.
00019  *
00020  * Initial developer(s): ScalAgent Distributed Technologies
00021  * Contributor(s): 
00022  */
00023 package com.scalagent.joram.mom.dest.mail;
00024 
00025 import java.util.Properties;
00026 
00027 import org.objectweb.joram.mom.dest.DestinationImpl;
00028 import org.objectweb.joram.mom.dest.Topic;
00029 
00030 import fr.dyade.aaa.agent.AgentId;
00031 import fr.dyade.aaa.agent.Notification;
00032 import fr.dyade.aaa.agent.WakeUpTask;
00033 
00040 public class JavaMailTopic extends Topic {
00042   private static final long serialVersionUID = 1L;
00043 
00044   public static final String MAIL_TOPIC_TYPE = "topic.mail";
00045 
00046   public static String getDestinationType() {
00047     return MAIL_TOPIC_TYPE;
00048   }
00049 
00053   public JavaMailTopic() {}
00054 
00055   public DestinationImpl createsImpl(AgentId adminId, Properties prop) {
00056     JavaMailTopicImpl topicImpl = new JavaMailTopicImpl(adminId, prop);
00057     return topicImpl;
00058   }
00059 
00060   private transient WakeUpTask poptask;
00061 
00071   protected void agentInitialize(boolean firstTime) throws Exception {
00072     super.agentInitialize(firstTime);
00073     poptask = new WakeUpTask(getId(), WakeUpPopNot.class);
00074     poptask.schedule(((JavaMailTopicImpl) destImpl).getPopPeriod());
00075   }
00076 
00077   public void react(AgentId from, Notification not) throws Exception {
00078     if (not instanceof WakeUpPopNot) {
00079       if (poptask == null)
00080         poptask = new WakeUpTask(getId(), WakeUpPopNot.class);
00081       poptask.schedule(((JavaMailTopicImpl) destImpl).getPopPeriod());
00082       ((JavaMailTopicImpl) destImpl).doPop();
00083     } else {
00084       super.react(from, not);
00085     }
00086   }
00087 }
00088 

Generated on Tue Sep 16 16:14:22 2008 for joram by  doxygen 1.5.0