001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 2002 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "WSIF" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 2001, 2002, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057:
058: package org.apache.wsif.providers.soap.apacheaxis;
059:
060: import org.apache.axis.AxisEngine;
061: import org.apache.axis.AxisFault;
062: import org.apache.axis.MessageContext;
063: import org.apache.axis.client.Call;
064: import org.apache.axis.client.Transport;
065: import org.apache.wsif.WSIFException;
066: import org.apache.wsif.WSIFOperation;
067: import org.apache.wsif.logging.Trc;
068: import org.apache.wsif.util.jms.WSIFJMSDestination;
069:
070: /**
071: * @author Mark Whitlock <whitlock@apache.org>
072: * @author Ant Elder <ant.elder@uk.ibm.com>
073: */
074: public class WSIFJmsTransport extends Transport {
075: private WSIFJMSDestination destination = null;
076: private String asyncOperation = "false";
077: private WSIFOperation wsifOperation = null;
078: private Long syncTimeout = null;
079: private Long asyncTimeout = null;
080:
081: public static final String DESTINATION = "destination";
082: public static final String ASYNCOPERATION = "asyncOperation";
083: public static final String WSIFOPERATION = "wsifOperation";
084: public static final String SYNC_TIMEOUT = "syncTimeout";
085: public static final String ASYNC_TIMEOUT = "asyncTimeout";
086:
087: public WSIFJmsTransport(WSIFJMSDestination destination)
088: throws WSIFException {
089: if (destination == null) {
090: throw new WSIFException("destination is null");
091: }
092: this .destination = destination;
093: }
094:
095: public void setDestination(WSIFJMSDestination destination) {
096: Trc.entry(this , destination);
097: this .destination = destination;
098: Trc.exit();
099: }
100:
101: public void setAsyncOperation(String asyncOperation) {
102: Trc.entry(this , asyncOperation);
103: this .asyncOperation = asyncOperation;
104: Trc.exit();
105: }
106:
107: public void setWsifOperation(WSIFOperation wsifOperation) {
108: Trc.entry(this , wsifOperation);
109: this .wsifOperation = wsifOperation;
110: Trc.exit();
111: }
112:
113: public void setSyncTimeout(Long syncTimeout) {
114: Trc.entry(this , syncTimeout);
115: this .syncTimeout = syncTimeout;
116: Trc.exit();
117: }
118:
119: public void setAsyncTimeout(Long asyncTimeout) {
120: Trc.entry(this , asyncTimeout);
121: this .asyncTimeout = asyncTimeout;
122: Trc.exit();
123: }
124:
125: public WSIFJMSDestination getDestination() {
126: Trc.entry(this );
127: Trc.exit(this .destination);
128: return this .destination;
129: }
130:
131: public String getAsyncOperation() {
132: Trc.entry(this );
133: Trc.exit(this .asyncOperation);
134: return this .asyncOperation;
135: }
136:
137: public WSIFOperation getWsifOperation() {
138: Trc.entry(this );
139: Trc.exit(this .wsifOperation);
140: return this .wsifOperation;
141: }
142:
143: public Long getSyncTimeout() {
144: Trc.entry(this );
145: Trc.exit(this .syncTimeout);
146: return this .syncTimeout;
147: }
148:
149: public Long getAsyncTimeout() {
150: Trc.entry(this );
151: Trc.exit(this .asyncTimeout);
152: return this .asyncTimeout;
153: }
154:
155: public void setupMessageContextImpl(MessageContext context,
156: Call call, AxisEngine engine) throws AxisFault {
157: Trc.entry(this , context, call, engine);
158: context.setTransportName("jms");
159: if (destination != null)
160: context.setProperty(DESTINATION, destination);
161: context
162: .setProperty(ASYNCOPERATION,
163: new Boolean(asyncOperation));
164: if (wsifOperation != null)
165: context.setProperty(WSIFOPERATION, wsifOperation);
166: if (syncTimeout != null)
167: context.setProperty(SYNC_TIMEOUT, syncTimeout);
168: if (asyncTimeout != null)
169: context.setProperty(ASYNC_TIMEOUT, asyncTimeout);
170: Trc.exit();
171: }
172:
173: public WSIFJmsTransport copy() throws WSIFException {
174: Trc.entry(this );
175: WSIFJmsTransport t = new WSIFJmsTransport(destination);
176: t.setAsyncOperation(asyncOperation);
177: t.setWsifOperation(wsifOperation);
178: t.setSyncTimeout(syncTimeout);
179: t.setAsyncTimeout(asyncTimeout);
180: if (Trc.ON)
181: Trc.exit(t.deep());
182: return t;
183: }
184:
185: public void close() throws WSIFException {
186: Trc.entry(this );
187: if (destination == null) {
188: throw new WSIFException("already closed");
189: }
190: destination.close();
191: destination = null;
192: Trc.exit();
193: }
194:
195: public String deep() {
196: String buff = "";
197: try {
198: buff = new String(super .toString() + ":\n");
199:
200: buff += "destination:" + destination;
201: buff += "asyncOperation:" + asyncOperation;
202: buff += "wsifOperation:" + wsifOperation;
203: buff += "syncTimeout:" + syncTimeout;
204: buff += "asyncTimeout:" + asyncTimeout;
205: } catch (Exception e) {
206: Trc.exceptionInTrace(e);
207: }
208: return buff;
209: }
210: }
|