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-2001. All Rights Reserved.
18 *
19 * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20 */
21 package zeus.actors.outtrays;
22
23 import javax.agent.service.*;
24 import javax.agent.*;
25 import FIPA.*;
26 import zeus.concepts.*;
27 import zeus.actors.*;
28
29 /***
30 implementation of the OutTray interface that can be used to message on a
31 Zeus (TCP/IP) communications channel
32 */
33 public class Zeus_Native_Transport implements OutTray {
34
35
36 private ZeusAgentContext context = null;
37
38 public Zeus_Native_Transport (ZeusAgentContext context) {
39 this.context = context;
40 }
41
42
43
44 public void send (Object obj) throws UnsuitableMessageException {
45 try {
46 Performative perf = (Performative) obj;
47 send (perf);
48 } catch (ClassCastException cce) {
49 throw new UnsuitableMessageException ("Must be Performative to work with this transport");
50 }catch (Exception e) {
51 e.printStackTrace();
52 throw new UnsuitableMessageException ("Bad message in send() - unknown problem, Excepiton printed to sout");
53
54 }
55 }
56
57
58
59 public void send (Performative perf) {
60 context.getMailBox().sendMsg(perf);
61 }
62
63
64 public void send (javax.agent.Envelope env) {
65
66 try {
67 // very risky - is the object a performative, probably not.....
68 Performative perf = (Performative) env.getObject();
69 context.getMailBox().sendMsg(perf);
70 }
71 catch (ClassCastException cce) {
72 cce.printStackTrace();
73 return; }
74
75 }
76
77
78 }