KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > agent > ServiceDesc


1 /*
2  * Copyright (C) 2001 - 2003 ScalAgent Distributed Technologies
3  * Copyright (C) 1996 - 2000 BULL
4  * Copyright (C) 1996 - 2000 INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  */

21 package fr.dyade.aaa.agent;
22
23 import java.io.*;
24
25 /**
26  * Description of a service.
27  */

28 public final class ServiceDesc implements Serializable {
29   /** service class name */
30   transient String JavaDoc scname;
31
32   /** starting arguments, may be null */
33   transient String JavaDoc args;
34
35   /** */
36   transient boolean initialized;
37
38   /** */
39   transient boolean running;
40
41   /**
42    * Constructor.
43    *
44    * @param scname service class name
45    * @param args starting parameters, may be null
46    */

47   public ServiceDesc(String JavaDoc scname,
48              String JavaDoc args) {
49     this.scname = scname;
50     this.args = args;
51     this.initialized = false;
52     this.running = false;
53   }
54
55   private void writeObject(java.io.ObjectOutputStream JavaDoc out)
56     throws IOException {
57     out.writeUTF(scname);
58     if (args != null)
59       out.writeUTF(args);
60     else
61       out.writeUTF("");
62     out.writeBoolean(initialized);
63   }
64
65   private void readObject(java.io.ObjectInputStream JavaDoc in)
66     throws IOException, ClassNotFoundException JavaDoc {
67     scname = in.readUTF();
68     args = in.readUTF();
69     if (args.length() == 0)
70       args = null;
71     initialized = in.readBoolean();
72     running = false;
73   }
74
75   /**
76    * Gets the class name for service.
77    *
78    * @return the classname.
79    */

80   public String JavaDoc getClassName() {
81     return scname;
82   }
83
84   /**
85    * Gets the starting arguments for service.
86    *
87    * @return the arguments.
88    */

89   public String JavaDoc getArguments() {
90     return args;
91   }
92
93   /**
94    * Tests if this <code>Service</code> is initialized.
95    *
96    * @return true if the <code>Service</code> is initialized.
97    */

98   public boolean isInitialized() {
99     return initialized;
100   }
101
102   /**
103    * Tests if this <code>Service</code> is running.
104    *
105    * @return true if the <code>Service</code> is running.
106    */

107   public boolean isRunning() {
108     return running;
109   }
110
111   /**
112    * Provides a string image for this object.
113    *
114    * @return printable image of this object
115    */

116   public String JavaDoc toString() {
117     StringBuffer JavaDoc strBuf = new StringBuffer JavaDoc();
118     strBuf.append("(").append(super.toString());
119     strBuf.append(",scname=").append(scname);
120     strBuf.append(",args=").append(args);
121     strBuf.append(",initialized=").append(initialized);
122     strBuf.append(",running=").append(running);
123     strBuf.append(")");
124     return strBuf.toString();
125   }
126 }
127
Popular Tags