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: * @(#)RobustInOnlyImpl.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.RobustInOnly;
034: import javax.jbi.messaging.NormalizedMessage;
035:
036: /** Implementation of Robust In Only Message Exchange Pattern.
037: * @author Sun Microsystems, Inc.
038: */
039: public class RobustInOnlyImpl extends MessageExchangeProxy implements
040: RobustInOnly {
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: | CREATE_FAULT | DO_SEND | DO_SENDSYNCH
046: | MARK_ACTIVE | SUSPEND_TX, 1, -1, -1, -1 },
047: { DO_ACCEPT | CHECK_STATUS_OR_FAULT | RESUME_TX, -1, 3, 4,
048: 2 },
049: { SET_ERROR | SET_DONE | DO_SEND | SET_PROPERTY, 3, -1, 2,
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_ERROR | SET_DONE | SET_FAULT | CREATE_FAULT
058: | SET_PROPERTY, -1, -1, 2, 3, },
059: {
060: SET_ERROR | SET_DONE | DO_SEND | SUSPEND_TX
061: | SET_PROPERTY, 6, -1, 2, -1 },
062: {
063: SET_FAULT | CREATE_FAULT | DO_SEND | DO_SENDSYNCH
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: RobustInOnlyImpl() {
073: this (SOURCE);
074: }
075:
076: /** Create a new RobustInOnlyImpl in the forward or reverse direction.
077: */
078: RobustInOnlyImpl(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 RobustInOnlyImpl(TARGET));
087: }
088:
089: /** Get the pattern.
090: * @return the message exchange pattern.
091: */
092: public URI getPattern() {
093: return (ExchangePattern.ROBUST_IN_ONLY.getURI());
094: }
095:
096: /** Retrieve the message with reference id "in" from this exchange.
097: * @return the in message, or null if it is not present in the exchange
098: */
099: public NormalizedMessage getInMessage() {
100: return getMessage(IN_MSG);
101: }
102:
103: /** Specifies the "in" message reference for this exchange.
104: * @param msg in message
105: * @throws javax.jbi.messaging.MessagingException invalid message or the
106: * current state of the exchange does not permit this operation.
107: */
108: public void setInMessage(NormalizedMessage msg)
109: throws javax.jbi.messaging.MessagingException {
110: setMessage(msg, IN_MSG);
111: }
112:
113: }
|