KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (C) 2001 - 2004 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  * This notification is used to ask aa agent creation to a remote
27  * agent factory.
28  */

29 public final class AgentCreateRequest extends Notification {
30   static final long serialVersionUID = -873215263839213534L;
31
32   /** Id. of agent to reply to */
33   public AgentId reply;
34   /**
35    * Id. of agent to deploy, used since id is not more serialized in
36    * agent state.
37    */

38   AgentId deploy;
39   /** Serialized state of the agent */
40   byte agentState[];
41
42   public AgentCreateRequest(Agent agent) throws IOException {
43     this(agent, null);
44   }
45
46   public AgentCreateRequest(Agent agent, AgentId reply) throws IOException {
47     super();
48     
49     this.reply = reply;
50     this.deploy = agent.getId();
51
52     ByteArrayOutputStream bos = new ByteArrayOutputStream();
53     ObjectOutputStream oos = new ObjectOutputStream(bos);
54     oos.writeObject(agent);
55     oos.flush();
56     agentState = bos.toByteArray();
57   }
58
59   public final AgentId getDeploy() {
60     return deploy;
61   }
62 }
63
Popular Tags