KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > distr > WorkerCommand


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.distr;
11
12 import java.util.*;
13 import org.jgap.util.*;
14
15 /**
16  * Command sent by an IMaster instance to an IWorker instance.
17  *
18  * @author Klaus Meffert
19  * @since 2.3
20  */

21 public class WorkerCommand
22     implements ICommand {
23   /** String containing the CVS revision. Read out via reflection!*/
24   private final static String JavaDoc CVS_REVISION = "$Revision: 1.4 $";
25
26   /**
27    * Informative name
28    */

29   private String JavaDoc m_name;
30
31   /**
32    * Time the command was created (i.e. the constructor was called) in
33    * milliseconds. For statistical and purposes and for allowing to set a
34    * timeout
35    */

36   private long m_timeCreated;
37
38   public WorkerCommand(final String JavaDoc a_name) {
39     m_name = a_name;
40     m_timeCreated = getCurrentMilliseconds();
41   }
42
43   /**@inheritedDoc*/
44   public CommandResult execute(final Object JavaDoc a_parameters)
45       throws Exception JavaDoc {
46     /**@todo implement*/
47     return null;
48   }
49
50   private static long getCurrentMilliseconds() {
51     Calendar cal = Calendar.getInstance(TimeZone.getDefault());
52     return cal.getTimeInMillis();
53   }
54
55   public String JavaDoc getName() {
56     return m_name;
57   }
58
59   public long getAgeMillis() {
60     return getCurrentMilliseconds() - m_timeCreated;
61   }
62 }
63
Popular Tags