KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > mobilitools > smi > AgentEntry


1 /*
2 * MobiliTools: an implementation of the Object Management Group's
3 * Mobile Agent Facility specification.
4 * Copyright (C) 2003 France Telecom R&D
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 of the License, or (at your option) 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 USA
19 *
20 * MobiliTools $Name: $
21 *
22 * Contact: mobilitools-smi@lists.debian-sf.objectweb.org
23 *
24 * Authors: Bruno Dillenseger
25 */

26
27
28 package org.objectweb.mobilitools.smi;
29
30
31 import org.objectweb.mobilitools.smi.api.*;
32 import java.util.Properties JavaDoc;
33
34
35 /**
36  * MobiliTools $Name: $, $Id: AgentEntry.java,v 1.1.1.1 2003/03/28 14:48:05 dillense Exp $
37  * <P>
38  * Data record holding information about an agent.
39  */

40 public class AgentEntry implements AgentInfo
41 {
42     MobileObject agent;
43     Name name;
44     String JavaDoc place;
45     boolean running;
46     String JavaDoc codebase;
47     Properties JavaDoc properties;
48     Object JavaDoc data;
49
50
51     /**
52         Creates a new data record describing an agent
53         (with null as agency personality specific data)
54         @param agent the Java object reference to the agent.
55         @param name the MAF unique name of the agent.
56         @param place the name of the place where the agent is residing.
57         @param codebase the codebase for the agent's classes.
58         @param properties a set of properties attached to the agent.
59     */

60     public AgentEntry(
61         MobileObject agent,
62         Name name,
63         String JavaDoc place,
64         boolean running,
65         String JavaDoc codebase,
66         Properties JavaDoc properties)
67     {
68         this(agent, name, place, running, codebase, properties, null);
69     }
70
71
72     /**
73         Creates a new data record describing an agent.
74         @param agent the Java object reference to the agent.
75         @param name the wrapper object of the agent's MAF unique name.
76         @param place the name of the place where the agent is residing.
77         @param codebase the codebase for the agent's classes.
78         @param properties a set of properties attached to the agent.
79         @param data opaque data that may be set by an agency personality.
80     */

81     public AgentEntry(
82         MobileObject agent,
83         Name name,
84         String JavaDoc place,
85         boolean running,
86         String JavaDoc codebase,
87         Properties JavaDoc properties,
88         Object JavaDoc data)
89     {
90         this.agent = agent;
91         this.name = name;
92         this.place = place;
93         this.running = running;
94         this.codebase = codebase;
95         this.properties = properties;
96         this.data = data;
97     }
98
99
100     /**
101         @return the Java object reference to the agent.
102     */

103     public MobileObject getAgent()
104     {
105         return agent;
106     }
107
108
109     /**
110         @return the wrapper object of the agent's MAF name.
111     */

112     public Name getName()
113     {
114         return name;
115     }
116
117
118     /**
119         @return the name of the place where the agent is.
120     */

121     public String JavaDoc getPlace()
122     {
123         return place;
124     }
125
126
127     /**
128         @return true if the agent is currently active,
129         false if it is suspended.
130     */

131     public boolean isRunning()
132     {
133         return running;
134     }
135
136
137     /**
138         Toggle the activity status between running and suspended.
139         @return true if the new status is running, false if it is suspended.
140     */

141     public boolean toggleRunning()
142     {
143         return running = ! running;
144     }
145
146
147     /**
148         @return the codebase of the agent.
149     */

150     public String JavaDoc getCodebase()
151     {
152         return codebase;
153     }
154
155
156     /**
157         @return the set of properties attached to the agent.
158     */

159     public Properties JavaDoc getProperties()
160     {
161         return properties;
162     }
163
164
165     /**
166         @return the opaque data set by an agency personality.
167     */

168     public Object JavaDoc getData()
169     {
170         return data;
171     }
172 }
173
Popular Tags