01: /*
02: * <copyright>
03: * Copyright 1997-2004 BBNT Solutions, LLC
04: * under sponsorship of the Defense Advanced Research Projects Agency (DARPA).
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the Cougaar Open Source License as published by
08: * DARPA on the Cougaar Open Source Website (www.cougaar.org).
09: *
10: * THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
11: * PROVIDED 'AS IS' WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
12: * IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
13: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
14: * ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
15: * HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
16: * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
17: * TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18: * PERFORMANCE OF THE COUGAAR SOFTWARE.
19: * </copyright>
20: */
21:
22: package org.cougaar.mts.corba;
23:
24: import org.cougaar.mts.corba.idlj.*;
25:
26: import org.cougaar.mts.std.AttributedMessage;
27: import org.cougaar.mts.base.MessageDeliverer;
28: import org.cougaar.mts.base.DontRetryException;
29: import org.cougaar.mts.base.MisdeliveredMessageException;
30: import org.cougaar.core.mts.MessageAddress;
31: import org.cougaar.core.mts.MessageAttributes;
32: import org.cougaar.core.mts.SerializationUtils;
33:
34: /**
35: * This is the CORBA servant class for the MT idl interface.
36: */
37: public class MTImpl extends MTPOA {
38: private MessageAddress address;
39: private MessageDeliverer deliverer;
40:
41: public MTImpl(MessageAddress addr, MessageDeliverer deliverer) {
42: super ();
43: address = addr;
44: this .deliverer = deliverer;
45: }
46:
47: private void dontRetryException(DontRetryException mex)
48: throws CorbaDontRetryException {
49: try {
50: byte[] exception = SerializationUtils.toByteArray(mex);
51: throw new CorbaDontRetryException(exception);
52: } catch (java.io.IOException iox) {
53: }
54:
55: throw new CorbaDontRetryException();
56: }
57:
58: public byte[] rerouteMessage(byte[] message_bytes)
59: throws CorbaMisdeliveredMessage, CorbaDontRetryException {
60: AttributedMessage message = null;
61: try {
62: message = (AttributedMessage) SerializationUtils
63: .fromByteArray(message_bytes);
64: } catch (DontRetryException mex) {
65: dontRetryException(mex);
66: } catch (java.io.IOException iox) {
67: } catch (ClassNotFoundException cnf) {
68: }
69:
70: MessageAttributes metadata = null;
71: try {
72: metadata = deliverer.deliverMessage(message, message
73: .getTarget());
74: } catch (MisdeliveredMessageException ex) {
75: throw new CorbaMisdeliveredMessage();
76: }
77:
78: byte[] reply_bytes = null;
79: try {
80: reply_bytes = SerializationUtils.toByteArray(metadata);
81: } catch (DontRetryException mex) {
82: dontRetryException(mex);
83: } catch (java.io.IOException iox) {
84: }
85:
86: return reply_bytes;
87:
88: }
89:
90: }
|