001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)InOutImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.messaging;
030:
031: import java.net.URI;
032:
033: import javax.jbi.messaging.InOut;
034: import javax.jbi.messaging.NormalizedMessage;
035:
036: /** Implementation of In Out Message Exchange Pattern.
037: * @author Sun Microsystems, Inc.
038: */
039: public class InOutImpl extends MessageExchangeProxy implements InOut {
040: /** Simple state machine for the SOURCE side of the pattern. */
041: private static final int[][] SOURCE = {
042: {
043: SET_IN | ADDRESS | SET_TRANSACTION | SET_PROPERTY
044: | DO_SEND | DO_SENDSYNCH | MARK_ACTIVE
045: | SUSPEND_TX, 1, -1, -1, -1 },
046: { DO_ACCEPT | CHECK_STATUS_OR_FAULT | RESUME_TX, -1, 2, 5,
047: 2 },
048: { SET_ERROR | SET_DONE | SET_PROPERTY, -1, -1, 3, -1 },
049: { SET_ERROR | SET_DONE | DO_SEND | SET_PROPERTY, 4, -1, -1,
050: -1 }, { MARK_DONE, -1, -1, -1, -1 },
051: { MARK_DONE | COMPLETE, -1, -1, -1, -1 }, };
052:
053: /** Simple state machine for the TARGET side of the pattern */
054: private static final int[][] TARGET = {
055: { DO_ACCEPT | REQUEST | RESUME_TX, -1, 1, -1, -1 },
056: {
057: SET_OUT | SET_ERROR | SET_FAULT | CREATE_FAULT
058: | DO_SEND | DO_SENDSYNCH | SUSPEND_TX
059: | SET_PROPERTY, 4, -1, 2, 3 },
060: { SET_ERROR | DO_SEND | SUSPEND_TX | SET_PROPERTY, 6, -1,
061: 2, -1 },
062: {
063: DO_SEND | DO_SENDSYNCH | SET_FAULT | CREATE_FAULT
064: | SUSPEND_TX | SET_PROPERTY, 4, -1, -1, 3 },
065: { DO_ACCEPT | STATUS, -1, 5, -1, -1 },
066: { MARK_DONE | COMPLETE, -1, -1, -1, -1 },
067: { MARK_DONE, -1, -1, -1, -1 }, };
068:
069: /**
070: * Default constructor.
071: */
072: InOutImpl() {
073: this (SOURCE);
074: }
075:
076: /** Create a new InOutImpl in the forward or reverse direction.
077: */
078: InOutImpl(int[][] state) {
079: super (state);
080: }
081:
082: /**
083: * Return a new instance of ourselves in the target role.
084: */
085: MessageExchangeProxy newTwin() {
086: return (new InOutImpl(TARGET));
087: }
088:
089: /** Get the pattern.
090: * @return the message exchange pattern.
091: */
092: public URI getPattern() {
093: return (ExchangePattern.IN_OUT.getURI());
094: }
095:
096: /** Retrieve the message with reference id "in" from this exchange.
097: * @return the out message, or null if it is not present in the exchange
098: */
099: public NormalizedMessage getInMessage() {
100: return getMessage(IN_MSG);
101: }
102:
103: /** Retrieve the message with reference id "out" from this exchange.
104: * @return the out message, or null if it is not present in the exchange
105: */
106: public NormalizedMessage getOutMessage() {
107: return getMessage(OUT_MSG);
108: }
109:
110: /** Specifies the "in" message reference for this exchange.
111: * @param msg in message
112: * @throws javax.jbi.messaging.MessagingException invalid message or the
113: * current state of the exchange does not permit this operation.
114: */
115: public void setInMessage(NormalizedMessage msg)
116: throws javax.jbi.messaging.MessagingException {
117: setMessage(msg, IN_MSG);
118: }
119:
120: /** Specifies the "out" message reference for this exchange.
121: * @param msg out message
122: * @throws javax.jbi.messaging.MessagingException invalid message or the
123: * current state of the exchange does not permit this operation.
124: */
125: public void setOutMessage(NormalizedMessage msg)
126: throws javax.jbi.messaging.MessagingException {
127: setMessage(msg, OUT_MSG);
128: }
129:
130: }
|