KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > mom > dest > AdminTopic


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2007 ScalAgent Distributed Technologies
4  * Copyright (C) 2003 - 2004 Bull SA
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  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s): ScalAgent Distributed Technologies
23  */

24 package org.objectweb.joram.mom.dest;
25
26 import java.util.Properties JavaDoc;
27
28 import org.objectweb.joram.mom.dest.AdminTopicImpl.AdminRequestNot;
29 import org.objectweb.joram.mom.notifications.AdminReply;
30 import org.objectweb.joram.mom.notifications.GetProxyIdListNot;
31 import org.objectweb.joram.mom.notifications.GetProxyIdNot;
32 import org.objectweb.joram.mom.notifications.RegisterDestNot;
33 import org.objectweb.joram.mom.notifications.RegisterTmpDestNot;
34 import org.objectweb.joram.mom.notifications.RegisteredDestNot;
35 import org.objectweb.joram.mom.proxies.AdminNotification;
36 import org.objectweb.util.monolog.api.BasicLevel;
37
38 import fr.dyade.aaa.agent.AgentId;
39 import fr.dyade.aaa.agent.AgentServer;
40 import fr.dyade.aaa.agent.Notification;
41
42 /**
43  * An <code>AdminTopic</code> agent is a MOM administration service, which
44  * behaviour is provided by an <code>AdminTopicImpl</code> instance.
45  *
46  * @see AdminTopicImpl
47  */

48 public class AdminTopic extends Topic {
49   /**
50    * Constructs an <code>AdminTopic</code> agent.
51    */

52   public AdminTopic() {
53     super("JoramAdminTopic", true, AgentId.JoramAdminStamp);
54     init(null, null);
55   }
56
57   /**
58    * Creates the <tt>TopicImpl</tt>.
59    *
60    * @param adminId Identifier of the topic administrator.
61    * @param prop The initial set of properties.
62    */

63   public DestinationImpl createsImpl(AgentId adminId, Properties JavaDoc prop) {
64     return new AdminTopicImpl(getId());
65   }
66
67   /**
68    * Gets the identifier of the default administration topic on a given server.
69    */

70   public static AgentId getDefault(short serverId) {
71     return new AgentId(serverId, serverId, AgentId.JoramAdminStamp);
72   }
73
74   static AgentId adminId = null;
75
76   /**
77    * Gets the identifier of the default administration topic on the
78    * current server.
79    */

80   public static AgentId getDefault() {
81     if (adminId == null)
82       adminId = new AgentId(AgentServer.getServerId(),
83                             AgentServer.getServerId(),
84                             AgentId.JoramAdminStamp);
85     return adminId;
86   }
87   
88   /**
89    * Distributes the received notifications to the appropriate reactions.
90    * @throws Exception
91    */

92   public void react(AgentId from, Notification not) throws Exception JavaDoc {
93     if (logger.isLoggable(BasicLevel.DEBUG))
94       logger.log(BasicLevel.DEBUG, "--- " + this
95                                    + ": got " + not
96                                    + " from: " + from.toString());
97
98     // state change, so save.
99
setSave();
100
101     if (not instanceof AdminNotification)
102       ((AdminTopicImpl)destImpl).AdminNotification(from, (AdminNotification) not);
103     else if (not instanceof AdminRequestNot)
104       ((AdminTopicImpl)destImpl).AdminRequestNot(from, (AdminRequestNot) not);
105     else if (not instanceof org.objectweb.joram.mom.notifications.AdminReply)
106       ((AdminTopicImpl)destImpl).AdminReply(from, (AdminReply) not);
107     else if (not instanceof GetProxyIdNot)
108       ((AdminTopicImpl)destImpl).GetProxyIdNot((GetProxyIdNot)not);
109     else if (not instanceof GetProxyIdListNot)
110       ((AdminTopicImpl)destImpl).GetProxyIdListNot((GetProxyIdListNot)not);
111     else if (not instanceof RegisterTmpDestNot)
112       ((AdminTopicImpl)destImpl).RegisterTmpDestNot((RegisterTmpDestNot)not);
113     else if (not instanceof RegisterDestNot)
114       ((AdminTopicImpl)destImpl).RegisterDestNot((RegisterDestNot)not);
115     else if (not instanceof RegisteredDestNot)
116       ((AdminTopicImpl)destImpl).RegisteredDestNot(from, (RegisteredDestNot)not);
117     else
118       super.react(from, not);
119   }
120 }
121
Popular Tags