View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-9. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20  */
21  
22  
23  
24  package zeus.actors.event;
25  
26  import zeus.util.*;
27  import zeus.concepts.*;
28  
29  public class MessageHandlerEvent extends Event {
30     public static final long ADD_MASK    = 1;
31     public static final long DELETE_MASK = 2;
32     public static final long FIRE_MASK   = 4;
33     public static final long FAIL_MASK   = 8;
34  
35     protected Object destination = null;
36     protected MessageRule rule = null;
37     protected String ruleName = null;
38     protected Performative msg = null;
39     protected String method = null;
40  
41     public MessageHandlerEvent(Object source, MessageRule rule, long event_mask) {
42        super(source,source,HANDLER_FIRST,HANDLER_LAST,event_mask);
43        this.rule = rule;
44        this.ruleName = rule.getName();
45     }
46  
47     public MessageHandlerEvent(Object source, String rule, long event_mask) {
48        super(source,source,HANDLER_FIRST,HANDLER_LAST,event_mask);
49        this.ruleName = rule;
50     }
51  
52     public MessageHandlerEvent(Object source, String rule,
53                                Object destination, String method,
54  			      Performative msg, long event_mask) {
55        super(source,source,HANDLER_FIRST,HANDLER_LAST,event_mask);
56        this.ruleName = rule;
57        this.destination = destination;
58        this.method = method;
59        this.msg = msg;
60     }
61  
62     public Performative getMessage() {
63        return msg;
64     }
65     public String getSender() {
66        return msg.getSender();
67     }
68     public String getReceiver() {
69        return msg.getReceiver();
70     }
71     public String getMessageType() {
72        return msg.getType();
73     }
74     public String getDestination() {
75        if ( destination == null ) return null;
76        return destination.getClass().getName();
77     }
78     public String getMethod() {
79        return method;
80     }
81     public String getRuleName() {
82        return ruleName;
83     }
84  
85     public MessageRule getRule() {
86        return rule;
87     }
88  }