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: * @(#)InOptionalOutImpl.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.InOptionalOut;
034: import javax.jbi.messaging.NormalizedMessage;
035:
036: /** Implementation of In Optional Out Message Exchange Pattern.
037: * @author Sun Microsystems, Inc.
038: */
039: public class InOptionalOutImpl extends MessageExchangeProxy implements
040: InOptionalOut {
041: /** Simple state machine for the SOURCE side of the pattern. */
042: private static final int[][] SOURCE = {
043: {
044: SET_IN | ADDRESS | SET_TRANSACTION | SET_PROPERTY
045: | DO_SEND | DO_SENDSYNCH | SUSPEND_TX
046: | MARK_ACTIVE, 1, -1, -1, -1 },
047: { DO_ACCEPT | CHECK_STATUS_OR_FAULT | RESUME_TX, -1, 2, 9,
048: 6 },
049: {
050: SET_DONE | SET_ERROR | SET_FAULT | CREATE_FAULT
051: | SET_PROPERTY, -1, -1, 3, 4 },
052: { SET_DONE | SET_ERROR | DO_SEND | SET_PROPERTY, 8, -1, 3,
053: -1 },
054: {
055: SET_FAULT | CREATE_FAULT | DO_SEND | DO_SENDSYNCH
056: | SET_PROPERTY | SUSPEND_TX, 5, -1, -1, 4 },
057: { DO_ACCEPT | STATUS | RESUME_TX, -1, 9, -1, -1 },
058: { SET_DONE | SET_ERROR | SET_PROPERTY, -1, -1, 7, -1 },
059: { SET_DONE | SET_ERROR | DO_SEND | SET_PROPERTY, 8, -1, 7,
060: -1 }, { MARK_DONE, -1, -1, -1, -1 },
061: { MARK_DONE | COMPLETE, -1, -1, -1, -1 }, };
062:
063: /** Simple state machine for the TARGET side of the pattern */
064: private static final int[][] TARGET = {
065: { DO_ACCEPT | REQUEST | RESUME_TX, -1, 1, -1, -1 },
066: {
067: SET_OUT | SET_ERROR | SET_DONE | SET_FAULT
068: | CREATE_FAULT | DO_SEND | DO_SENDSYNCH
069: | SUSPEND_TX | SET_PROPERTY, 2, -1, 6, 5 },
070: { DO_ACCEPT | CHECK_STATUS_OR_FAULT, -1, -1, 8, 3 },
071: { SET_ERROR | SET_DONE | SET_PROPERTY, -1, -1, 4, -1 },
072: {
073: SET_ERROR | SET_DONE | DO_SEND | SUSPEND_TX
074: | SET_PROPERTY, 9, -1, 4, -1 },
075: {
076: SET_FAULT | CREATE_FAULT | DO_SEND | DO_SENDSYNCH
077: | SUSPEND_TX | SET_PROPERTY, 7, -1, -1, 5 },
078: { SET_ERROR | SET_DONE | DO_SEND | SET_PROPERTY, 9, -1, 6,
079: -1 }, { DO_ACCEPT | STATUS, -1, 8, -1, -1 },
080: { MARK_DONE | COMPLETE, -1, -1, -1, -1 },
081: { MARK_DONE, -1, -1, -1, -1 } };
082:
083: /**
084: * Default constructor.
085: */
086: InOptionalOutImpl() {
087: this (SOURCE);
088: }
089:
090: /** Create a new InOptionalOutImpl in the forward or reverse direction.
091: */
092: InOptionalOutImpl(int[][] state) {
093: super (state);
094: }
095:
096: /**
097: * Return a new instance of ourselves in the target role.
098: */
099: MessageExchangeProxy newTwin() {
100: return (new InOptionalOutImpl(TARGET));
101: }
102:
103: /** Get the pattern.
104: * @return the message exchange pattern.
105: */
106: public URI getPattern() {
107: return (ExchangePattern.IN_OPTIONAL_OUT.getURI());
108: }
109:
110: /** Retrieve the message with reference id "in" from this exchange.
111: * @return the out message, or null if it is not present in the exchange
112: */
113: public NormalizedMessage getInMessage() {
114: return getMessage(IN_MSG);
115: }
116:
117: /** Retrieve the message with reference id "out" from this exchange.
118: * @return the out message, or null if it is not present in the exchange
119: */
120: public NormalizedMessage getOutMessage() {
121: return getMessage(OUT_MSG);
122: }
123:
124: /** Specifies the "in" message reference for this exchange.
125: * @param msg in message
126: * @throws javax.jbi.messaging.MessagingException invalid message or the
127: * current state of the exchange does not permit this operation.
128: */
129: public void setInMessage(NormalizedMessage msg)
130: throws javax.jbi.messaging.MessagingException {
131: setMessage(msg, IN_MSG);
132: }
133:
134: /** Specifies the "out" message reference for this exchange.
135: * @param msg out message
136: * @throws javax.jbi.messaging.MessagingException invalid message or the
137: * current state of the exchange does not permit this operation.
138: */
139: public void setOutMessage(NormalizedMessage msg)
140: throws javax.jbi.messaging.MessagingException {
141: setMessage(msg, OUT_MSG);
142: }
143:
144: }
|