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