KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsif > providers > soap > apacheaxis > WSIFJmsTransport


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "WSIF" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.apache.wsif.providers.soap.apacheaxis;
59
60 import org.apache.axis.AxisEngine;
61 import org.apache.axis.AxisFault;
62 import org.apache.axis.MessageContext;
63 import org.apache.axis.client.Call;
64 import org.apache.axis.client.Transport;
65 import org.apache.wsif.WSIFException;
66 import org.apache.wsif.WSIFOperation;
67 import org.apache.wsif.logging.Trc;
68 import org.apache.wsif.util.jms.WSIFJMSDestination;
69
70 /**
71  * @author Mark Whitlock <whitlock@apache.org>
72  * @author Ant Elder <ant.elder@uk.ibm.com>
73  */

74 public class WSIFJmsTransport extends Transport {
75     private WSIFJMSDestination destination = null;
76     private String JavaDoc asyncOperation = "false";
77     private WSIFOperation wsifOperation = null;
78     private Long JavaDoc syncTimeout = null;
79     private Long JavaDoc asyncTimeout = null;
80
81     public static final String JavaDoc DESTINATION = "destination";
82     public static final String JavaDoc ASYNCOPERATION = "asyncOperation";
83     public static final String JavaDoc WSIFOPERATION = "wsifOperation";
84     public static final String JavaDoc SYNC_TIMEOUT = "syncTimeout";
85     public static final String JavaDoc ASYNC_TIMEOUT = "asyncTimeout";
86
87     public WSIFJmsTransport(WSIFJMSDestination destination) throws WSIFException {
88         if (destination == null) {
89             throw new WSIFException("destination is null");
90         }
91         this.destination = destination;
92     }
93
94     public void setDestination(WSIFJMSDestination destination) {
95         Trc.entry(this, destination);
96         this.destination = destination;
97         Trc.exit();
98     }
99
100     public void setAsyncOperation(String JavaDoc asyncOperation) {
101         Trc.entry(this, asyncOperation);
102         this.asyncOperation = asyncOperation;
103         Trc.exit();
104     }
105
106     public void setWsifOperation(WSIFOperation wsifOperation) {
107         Trc.entry(this, wsifOperation);
108         this.wsifOperation = wsifOperation;
109         Trc.exit();
110     }
111
112     public void setSyncTimeout(Long JavaDoc syncTimeout) {
113         Trc.entry(this, syncTimeout);
114         this.syncTimeout = syncTimeout;
115         Trc.exit();
116     }
117
118     public void setAsyncTimeout(Long JavaDoc asyncTimeout) {
119         Trc.entry(this, asyncTimeout);
120         this.asyncTimeout = asyncTimeout;
121         Trc.exit();
122     }
123
124     public WSIFJMSDestination getDestination() {
125         Trc.entry(this);
126         Trc.exit(this.destination);
127         return this.destination;
128     }
129
130     public String JavaDoc getAsyncOperation() {
131         Trc.entry(this);
132         Trc.exit(this.asyncOperation);
133         return this.asyncOperation;
134     }
135
136     public WSIFOperation getWsifOperation() {
137         Trc.entry(this);
138         Trc.exit(this.wsifOperation);
139         return this.wsifOperation;
140     }
141
142     public Long JavaDoc getSyncTimeout() {
143         Trc.entry(this);
144         Trc.exit(this.syncTimeout);
145         return this.syncTimeout;
146     }
147
148     public Long JavaDoc getAsyncTimeout() {
149         Trc.entry(this);
150         Trc.exit(this.asyncTimeout);
151         return this.asyncTimeout;
152     }
153
154     public void setupMessageContextImpl(
155         MessageContext context,
156         Call call,
157         AxisEngine engine)
158         throws AxisFault {
159         Trc.entry(this, context, call, engine);
160         context.setTransportName("jms");
161         if (destination != null)
162             context.setProperty(DESTINATION, destination);
163         context.setProperty(ASYNCOPERATION, new Boolean JavaDoc(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 JavaDoc deep() {
196         String JavaDoc buff = "";
197         try {
198             buff = new String JavaDoc(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 JavaDoc e) {
206             Trc.exceptionInTrace(e);
207         }
208         return buff;
209     }
210 }
Popular Tags