KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > multiplexer > PeriodicAttachment


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact : dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.multiplexer;
26
27 import java.util.Map JavaDoc;
28
29 import org.objectweb.dream.Pull;
30 import org.objectweb.dream.Push;
31
32 /**
33  * This class defines a periodic attachment.
34  */

35 public class PeriodicAttachment extends Attachment
36 {
37   protected long startingDate;
38   protected long pullingFrequencyInMillis;
39   protected long endDate; // 0 means
40
// no end
41
protected long nextDeadline = 0;
42
43   /**
44    * The name of the key that must be used to specify the starting date of this
45    * attachment in the <code>parameters</code> passed to the
46    * {@link org.objectweb.dream.multiplexer.PullPushMultiplexer#attach(String[], Map[], String[], Map[], Map) }
47    */

48   public static final String JavaDoc STARTING_DATE = "startingDate";
49
50   /**
51    * The name of the key that must be used to specify the end date of this
52    * attachment in the <code>parameters</code> passed to the
53    * {@link org.objectweb.dream.multiplexer.PullPushMultiplexer#attach(String[], Map[], String[], Map[], Map) }
54    */

55   public static final String JavaDoc END_DATE = "endDate";
56
57   /**
58    * The name of the key that must be used to specify the pulling frequency of
59    * this attachment in the <code>parameters</code> passed to the
60    * {@link org.objectweb.dream.multiplexer.PullPushMultiplexer#attach(String[], Map[], String[], Map[], Map) }
61    */

62   public static final String JavaDoc PULLING_FREQUENCY = "pullingFrequency";
63
64   /**
65    * The name of the key that must be used in the context of the
66    * <code>pull</code> method to specify the time at which the pulling has
67    * been scheduled by the multiplexer.
68    */

69   public static final String JavaDoc TIMESTAMP = "timestamp";
70
71   /**
72    * Creates a new <code>Attachment</code> object
73    *
74    * @param id the id of the attachment
75    * @param inputNames the names of the attached inputs.
76    * @param inputs the attached inputs.
77    * @param inputContexts the contexts to be passed when pulling the inputs.
78    * @param outputNames the names of the outputs to wich intputs are attached.
79    * @param outputs the outputs to wich intputs are attached.
80    * @param outputContexts the contexts to be passed when pushing the outputs.
81    * @param startingDate attachment start date.
82    * @param pullingFrequencyInMillis time between two pulling
83    * @param endDate attachment end date
84    */

85   public PeriodicAttachment(int id, String JavaDoc[] inputNames, Pull[] inputs,
86       Map JavaDoc[] inputContexts, String JavaDoc[] outputNames, Push[] outputs,
87       Map JavaDoc[] outputContexts, long startingDate, long pullingFrequencyInMillis,
88       long endDate)
89   {
90     super(id, inputNames, inputs, inputContexts, outputNames, outputs,
91         outputContexts);
92     this.startingDate = startingDate;
93     this.pullingFrequencyInMillis = pullingFrequencyInMillis;
94     this.endDate = endDate;
95     this.nextDeadline = startingDate;
96   }
97
98   /**
99    * Creates a new <code>Attachment</code> object without an end date. It
100    * means that pulling never ends.
101    *
102    * @param id the id of the attachment
103    * @param inputNames the names of the attached inputs.
104    * @param inputs the attached inputs.
105    * @param inputContexts the contexts to be passed when pulling the inputs.
106    * @param outputNames the names of the outputs to wich intputs are attached.
107    * @param outputs the outputs to wich intputs are attached.
108    * @param outputContexts the contexts to be passed when pushing the outputs.
109    * @param startingDate attachment start date.
110    * @param pullingFrequencyInMillis time between two pulling
111    */

112   public PeriodicAttachment(int id, String JavaDoc[] inputNames, Pull[] inputs,
113       Map JavaDoc[] inputContexts, String JavaDoc[] outputNames, Push[] outputs,
114       Map JavaDoc[] outputContexts, long startingDate, long pullingFrequencyInMillis)
115   {
116     this(id, inputNames, inputs, inputContexts, outputNames, outputs,
117         outputContexts, startingDate, pullingFrequencyInMillis, 0);
118   }
119
120   /**
121    * Returns the nextDeadline value.
122    *
123    * @return the nextDeadline.
124    */

125   public long getNextDeadline()
126   {
127     return nextDeadline;
128   }
129
130   /**
131    * Sets the nextDeadline value.
132    *
133    * @param nextDeadline the nextDeadline to set.
134    */

135   public void setNextDeadline(long nextDeadline)
136   {
137     this.nextDeadline = nextDeadline;
138   }
139
140   /**
141    * Returns the startingDate value.
142    *
143    * @return the starting date.
144    */

145   public long getStartingDate()
146   {
147     return startingDate;
148   }
149
150   /**
151    * Returns the endDate value.
152    *
153    * @return the end date.
154    */

155   public long getEndDate()
156   {
157     return endDate;
158   }
159
160   /**
161    * Sets the endDate value.
162    *
163    * @param endDate the endDate to set.
164    */

165   public void setEndDate(long endDate)
166   {
167     this.endDate = endDate;
168   }
169
170   /**
171    * Returns the samplingFrequencyInMillis value.
172    *
173    * @return the samplingFrequencyInMillis.
174    */

175   public long pullingFrequencyInMillis()
176   {
177     return pullingFrequencyInMillis;
178   }
179
180   /**
181    * Returns a clone of this attachment.
182    *
183    * @return a clone of this attachment.
184    */

185   public Object JavaDoc clone()
186   {
187     return super.clone();
188   }
189
190 }
Popular Tags