1 17 package org.apache.servicemix.jbi.messaging; 18 19 import javax.jbi.messaging.InOptionalOut; 20 21 import java.io.IOException ; 22 import java.io.ObjectInput ; 23 24 29 public class InOptionalOutImpl extends MessageExchangeImpl implements InOptionalOut { 30 31 private static final long serialVersionUID = -3145649037372074912L; 32 33 private static int[][] STATES_CONSUMER = { 34 { CAN_CONSUMER + CAN_OWNER + CAN_SET_IN_MSG + CAN_SEND + CAN_STATUS_ACTIVE, 1, -1, -1, -1}, 35 { CAN_CONSUMER, 2, 3, 4, 4 }, 36 { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_SET_FAULT_MSG + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, 5, 6, 6}, 37 { CAN_CONSUMER + CAN_OWNER + CAN_SEND + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, -1, 6, 6}, 38 { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 }, 39 { CAN_CONSUMER, -1, -1, 7, 7 }, 40 { CAN_CONSUMER, -1, -1, -1, -1 }, 41 { CAN_CONSUMER + CAN_OWNER, -1, -1, -1, -1 }, 42 }; 43 44 private static int[][] STATES_PROVIDER = { 45 { CAN_PROVIDER, 1, -1, -1 }, 46 { CAN_PROVIDER + CAN_OWNER + CAN_SET_OUT_MSG + CAN_SET_FAULT_MSG + CAN_SEND + CAN_STATUS_ACTIVE + CAN_STATUS_ERROR + CAN_STATUS_DONE, 2, 3, 4, 4 }, 47 { CAN_PROVIDER, -1, 5, 6, 6 }, 48 { CAN_PROVIDER, -1, -1, 6, 6 }, 49 { CAN_PROVIDER, -1, -1, -1, -1 }, 50 { CAN_PROVIDER + CAN_OWNER + CAN_SEND + CAN_STATUS_ERROR + CAN_STATUS_DONE, -1, -1, 7, 7 }, 51 { CAN_PROVIDER + CAN_OWNER, -1, -1, -1, -1 }, 52 { CAN_PROVIDER, -1, -1, -1, -1 }, 53 }; 54 55 public InOptionalOutImpl() { 56 } 57 58 public InOptionalOutImpl(String exchangeId) { 59 super(exchangeId, MessageExchangeSupport.IN_OPTIONAL_OUT, STATES_CONSUMER); 60 this.mirror = new InOptionalOutImpl(this); 61 } 62 63 public InOptionalOutImpl(ExchangePacket packet) { 64 super(packet, STATES_CONSUMER); 65 this.mirror = new InOptionalOutImpl(this); 66 } 67 68 protected InOptionalOutImpl(InOptionalOutImpl mep) { 69 super(mep.packet, STATES_PROVIDER); 70 this.mirror = mep; 71 } 72 73 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 74 this.packet = new ExchangePacket(); 75 this.packet.readExternal(in); 76 if (this.packet.in != null) { 77 this.packet.in.exchange = this; 78 } 79 if (this.packet.out != null) { 80 this.packet.out.exchange = this; 81 } 82 if (this.packet.fault != null) { 83 this.packet.fault.exchange = this; 84 } 85 this.state = in.read(); 86 this.mirror = new InOptionalOutImpl(); 87 this.mirror.mirror = this; 88 this.mirror.packet = this.packet; 89 this.mirror.state = in.read(); 90 boolean provider = in.readBoolean(); 91 if (provider) { 92 this.states = STATES_PROVIDER; 93 this.mirror.states = STATES_CONSUMER; 94 } else { 95 this.states = STATES_CONSUMER; 96 this.mirror.states = STATES_PROVIDER; 97 } 98 } 99 100 } | Popular Tags |