KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > mobilitools > smi > api > AgencyPersonality


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.api;
29
30 import org.omg.CfMAF.AgentSystemInfo;
31
32 /**
33  * MobiliTools $Name: $, $Id: AgencyPersonality.java,v 1.1.1.1 2003/03/28 14:48:06 dillense Exp $
34  * <P>
35  * Interface that must be implemented by an agency personality
36  * to give hooks to SMI generic Agency. Most of this interface
37  * consists in intercepting MobileObject life cycle.
38  * @see Agency
39  * @see MobileObject
40 */

41 public interface AgencyPersonality
42 {
43     /**
44         Called on agent creation.
45         @param agent target agent.
46         @param agency reference to the hosting agency.
47         @param entry a structure of information about the newly created agent.
48         @param arguments arguments for agent initialization.
49         @throws BadOperation shall be thrown if the agent refuses to settle.
50         Identifier BadOperation.REJECTED must be set for this exception.
51         Note that the agent creation is canceled,
52         and that <code>beforeDeath()</code> is not called.
53     */

54     public void afterBirth(MobileObject agent, AgentSystem agency, AgentInfo entry, Object JavaDoc arguments)
55         throws BadOperation;
56
57     /**
58         Called before before moving.
59         @param agent target agent
60         @param location location of destination agency
61         @param place name of target place
62         @throws BadOperation thrown to reject the move.
63         Identifier BadOperation.REJECTED must be set for this exception.
64         The agent move is simply canceled and the thrown exception is
65         re-thrown by <code>moveAgent()</code> (note that <code>afterMoveFailed()</code>
66         is not called).
67     */

68     public void beforeMove(MobileObject agent, Location location, String JavaDoc place)
69         throws BadOperation;
70
71     /**
72         Called on reinstalling in the target agency after a move.
73         @param agent target agent
74         @param agency reference to the new hosting agency
75         @param location location of new hosting agency
76         @param place the name of the new residing place
77         @throws BadOperation thrown if the agent can not be
78         correctly reinstalled in the new agency.
79         Identifier BadOperation.REJECTED must be set for this exception.
80         The agent stays in the source agency, <code>afterMoveFailed()</code> is invoked,
81         and <code>moveAgent()</code> throws an exception.
82     */

83     public void afterMove(MobileObject agent, AgentSystem agency, Location location, String JavaDoc place)
84         throws BadOperation;
85
86     /**
87         Called on move failure. (note that throwing an exception in
88         <code>beforeMove()</code> does not result in
89         <code>afterMoveFailed()</code> being called)
90         @param agent target agent
91         @param agency location of the target agency
92         @param place the target place name
93         @param reason problem identifier
94         @param message textual explanation
95     */

96     public void afterMoveFailed(
97         MobileObject agent,
98         Location agency,
99         String JavaDoc place,
100         int reason,
101         String JavaDoc message);
102
103     /**
104         Called before discarding the agent.
105         (note that an exception in <code>afterBirth()</code> does not
106         result in <code>beforeDeath()</code> being called)
107         @param agent target agent
108     */

109     public void beforeDeath(MobileObject agent);
110
111     /**
112         Called to suspend the agent activity (if any).
113         @param agent target agent
114         @throws BadOperation the agent activity was already suspended, or could not be suspended.
115         Identifier BadOperation.REJECTED must be set for this exception. SMI core detects
116         whether the agent is already suspended or not, and throws the corresponding exception if
117         necessary, without invoking this callback.
118     */

119     public void beforeSuspend(MobileObject agent)
120         throws BadOperation;
121
122     /**
123         Called to resume the agent activity (if any).
124         @param agent target agent
125         @throws BadOperation the agent activity was already running, or could not be resumed.
126         Identifier BadOperation.REJECTED must be set for this exception. SMI core detects
127         whether the agent is already running or not, and throws the corresponding exception if
128         necessary, without invoking this callback.
129     */

130     public void beforeResume(MobileObject agent)
131         throws BadOperation;
132
133     /**
134         Called before the agent's hosting agency shutdown.
135         If the agent is still residing in the shutting agency
136         after this callback, it is terminated and callback
137         beforeDeath() is invoked (an agent can't survive the
138         shutdown of its hosting agency).
139         @param agent target agent
140     */

141     public void beforeShutdown(MobileObject agent);
142
143     /**
144      * Called before agency shutdown (once all agents have been warned and terminated).
145      */

146     public void agencyShutdown();
147 }
148
Popular Tags