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.Queue; 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 JavaMailQueue extends Queue { 00042 private static final long serialVersionUID = 1L; 00043 00044 public static final String MAIL_QUEUE_TYPE = "queue.mail"; 00045 00046 public static String getDestinationType() { 00047 return MAIL_QUEUE_TYPE; 00048 } 00049 00053 public JavaMailQueue() {} 00054 00061 public DestinationImpl createsImpl(AgentId adminId, Properties prop) { 00062 return new JavaMailQueueImpl(adminId, prop); 00063 } 00064 00065 private transient WakeUpTask poptask; 00066 00076 protected void agentInitialize(boolean firstTime) throws Exception { 00077 super.agentInitialize(firstTime); 00078 poptask = new WakeUpTask(getId(), WakeUpPopNot.class); 00079 poptask.schedule(((JavaMailQueueImpl) destImpl).getPopPeriod()); 00080 } 00081 00082 public void react(AgentId from, Notification not) throws Exception { 00083 if (not instanceof WakeUpPopNot) { 00084 if (poptask == null) 00085 poptask = new WakeUpTask(getId(), WakeUpPopNot.class); 00086 poptask.schedule(((JavaMailQueueImpl) destImpl).getPopPeriod()); 00087 ((JavaMailQueueImpl) destImpl).doPop(); 00088 } else { 00089 super.react(from, not); 00090 } 00091 } 00092 }
1.5.0