1 24 package org.objectweb.joram.mom.dest; 25 26 import java.util.Properties ; 27 28 import org.objectweb.joram.mom.notifications.AbstractRequest; 29 import org.objectweb.joram.mom.notifications.ClusterRequest; 30 import org.objectweb.joram.mom.notifications.DestinationAdminRequestNot; 31 import org.objectweb.joram.mom.notifications.ExceptionReply; 32 import org.objectweb.joram.mom.notifications.Monit_GetCluster; 33 import org.objectweb.joram.mom.notifications.Monit_GetFather; 34 import org.objectweb.joram.mom.notifications.Monit_GetSubscriptions; 35 import org.objectweb.joram.mom.notifications.SetFatherRequest; 36 import org.objectweb.joram.mom.notifications.SubscribeRequest; 37 import org.objectweb.joram.mom.notifications.UnclusterRequest; 38 import org.objectweb.joram.mom.notifications.UnsetFatherRequest; 39 import org.objectweb.joram.mom.notifications.UnsubscribeRequest; 40 import org.objectweb.joram.shared.JoramTracing; 41 import org.objectweb.joram.shared.excepts.MomException; 42 import org.objectweb.util.monolog.api.BasicLevel; 43 44 import fr.dyade.aaa.agent.AgentId; 45 import fr.dyade.aaa.agent.Channel; 46 import fr.dyade.aaa.agent.Notification; 47 48 54 public class Topic extends Destination { 55 56 public static final String TOPIC_TYPE = "topic"; 57 58 public static String getDestinationType() { 59 return TOPIC_TYPE; 60 } 61 62 65 public Topic() {} 66 67 72 protected Topic(String name, boolean fixed, int stamp) { 73 super(name, fixed, stamp); 74 } 75 76 82 public DestinationImpl createsImpl(AgentId adminId, Properties prop) { 83 return new TopicImpl(getId(), adminId, prop); 84 } 85 86 90 public void react(AgentId from, Notification not) throws Exception { 91 ((TopicImpl)destImpl).setAlreadySentLocally(false); 92 int reqId = -1; 93 if (not instanceof AbstractRequest) 94 reqId = ((AbstractRequest) not).getRequestId(); 95 96 if (JoramTracing.dbgDestination.isLoggable(BasicLevel.DEBUG)) 97 JoramTracing.dbgDestination.log(BasicLevel.DEBUG, "--- " + this 98 + ": got " + not.getClass().getName() 99 + " with id: " + reqId 100 + " from: " + from.toString()); 101 try { 102 if (not instanceof ClusterRequest) 103 ((TopicImpl)destImpl).clusterRequest(from, (ClusterRequest) not); 104 else if (not instanceof ClusterTest) 105 ((TopicImpl)destImpl).clusterTest(from, (ClusterTest) not); 106 else if (not instanceof ClusterAck) 107 ((TopicImpl)destImpl).clusterAck(from, (ClusterAck) not); 108 else if (not instanceof ClusterNot) 109 ((TopicImpl)destImpl).clusterNot(from, (ClusterNot) not); 110 else if (not instanceof UnclusterRequest) 111 ((TopicImpl)destImpl).unclusterRequest(from, (UnclusterRequest) not); 112 else if (not instanceof UnclusterNot) 113 ((TopicImpl)destImpl).unclusterNot(from, (UnclusterNot) not); 114 else if (not instanceof SetFatherRequest) 115 ((TopicImpl)destImpl).setFatherRequest(from, (SetFatherRequest) not); 116 else if (not instanceof FatherTest) 117 ((TopicImpl)destImpl).fatherTest(from, (FatherTest) not); 118 else if (not instanceof FatherAck) 119 ((TopicImpl)destImpl).fatherAck(from, (FatherAck) not); 120 else if (not instanceof UnsetFatherRequest) 121 ((TopicImpl)destImpl).unsetFatherRequest(from, (UnsetFatherRequest) not); 122 else if (not instanceof Monit_GetSubscriptions) 123 ((TopicImpl)destImpl).monitGetSubscriptions(from, (Monit_GetSubscriptions) not); 124 else if (not instanceof Monit_GetFather) 125 ((TopicImpl)destImpl).monitGetFather(from, (Monit_GetFather) not); 126 else if (not instanceof Monit_GetCluster) 127 ((TopicImpl)destImpl).monitGetCluster(from, (Monit_GetCluster) not); 128 else if (not instanceof SubscribeRequest) 129 ((TopicImpl)destImpl).subscribeRequest(from, (SubscribeRequest) not); 130 else if (not instanceof UnsubscribeRequest) 131 ((TopicImpl)destImpl).unsubscribeRequest(from, (UnsubscribeRequest) not); 132 else if (not instanceof TopicForwardNot) 133 ((TopicImpl)destImpl).topicForwardNot(from, (TopicForwardNot) not); 134 else if (not instanceof DestinationAdminRequestNot) 135 ((TopicImpl)destImpl).destinationAdminRequestNot(from, (DestinationAdminRequestNot) not); 136 else 137 super.react(from, not); 138 } catch (MomException exc) { 139 if (logger.isLoggable(BasicLevel.WARN)) 141 logger.log(BasicLevel.WARN, exc); 142 143 AbstractRequest req = (AbstractRequest) not; 144 Channel.sendTo(from, new ExceptionReply(req, exc)); 145 } 146 } 147 148 } 149 | Popular Tags |