KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > presumo > jms > router > RoutingTarget


1 /**
2  * This file is part of Presumo.
3  *
4  * Presumo is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Presumo is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Presumo; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  *
19  * Copyright 2001 Dan Greff
20  */

21 package com.presumo.jms.router;
22
23 import com.presumo.jms.message.JmsMessage;
24 import com.presumo.jms.selector.JmsOperand;
25
26 /**
27  * Only interface the Router knows about in terms of sending messages.
28  * Classes wishing to receive messages (i.e. RemoteSession and JmsSession)
29  * Implement this interface and register themselves with the Router.
30  *
31  * @author Dan Greff
32  */

33 public interface RoutingTarget
34 {
35   /**
36    * Used by the Router to assign a unique ID (per JVM) to the
37    * RoutingTarget
38    */

39   public void setTargetID(int id);
40   
41   /**
42    * Used by the Router to get the RoutingTarget's routing filter
43    * which could be used to determine if the RoutingTarget needs a
44    * message. This is not actually what it is used for though, the
45    * RoutingTarget is responsible for determining if it needs the message
46    * when the Router calls <code>takeMessage</code> on the target.
47    *
48    * Instead, the router uses this method to fetch the routing filter
49    * for necessary filter propogation to other Routers.
50    */

51   public JmsOperand getRoutingFilter();
52   
53   /**
54    * Called by the Router to tell the target what the combined routing
55    * filter is for the given Router. The RoutingTarget should try not
56    * to pass any Messages to the Router that do not pass this filter.
57    */

58   public void setRemoteRoutingFilter(JmsOperand filter, boolean add);
59   
60   /**
61    * Some RoutingTargets, like JmsSession, do not care about filter
62    * propogation since they will always give their produced messages
63    * to the Router.
64    */

65   public boolean needsFilterUpdates();
66   
67   /**
68    * Basically an incoming message for the RoutingTarget. It is up
69    * to the Routing target to determine if it needs the message or
70    * not.
71    */

72   public JmsMessage takeMessage(JmsMessage msg);
73 }
Popular Tags