|
1 /* |
|
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.client.dispatch; |
|
27 |
|
28 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; |
|
29 import com.sun.xml.internal.ws.api.message.Message; |
|
30 import com.sun.xml.internal.ws.api.message.Packet; |
|
31 import com.sun.xml.internal.ws.api.pipe.Tube; |
|
32 import com.sun.xml.internal.ws.api.client.WSPortInfo; |
|
33 import com.sun.xml.internal.ws.binding.BindingImpl; |
|
34 import com.sun.xml.internal.ws.client.WSServiceDelegate; |
|
35 import com.sun.xml.internal.ws.client.PortInfo; |
|
36 import com.sun.xml.internal.ws.encoding.xml.XMLMessage; |
|
37 import com.sun.xml.internal.ws.encoding.xml.XMLMessage.MessageDataSource; |
|
38 import com.sun.xml.internal.ws.message.source.PayloadSourceMessage; |
|
39 |
|
40 import javax.activation.DataSource; |
|
41 import javax.xml.namespace.QName; |
|
42 import javax.xml.ws.Service; |
|
43 import javax.xml.ws.WebServiceException; |
|
44 |
|
45 /** |
|
46 * |
|
47 * @author WS Development Team |
|
48 * @version 1.0 |
|
49 */ |
|
50 public class DataSourceDispatch extends DispatchImpl<DataSource> { |
|
51 @Deprecated |
|
52 public DataSourceDispatch(QName port, Service.Mode mode, WSServiceDelegate service, Tube pipe, BindingImpl binding, WSEndpointReference epr) { |
|
53 super(port, mode, service, pipe, binding, epr ); |
|
54 } |
|
55 |
|
56 public DataSourceDispatch(WSPortInfo portInfo, Service.Mode mode,BindingImpl binding, WSEndpointReference epr) { |
|
57 super(portInfo, mode, binding, epr ); |
|
58 } |
|
59 |
|
60 Packet createPacket(DataSource arg) { |
|
61 |
|
62 switch (mode) { |
|
63 case PAYLOAD: |
|
64 throw new IllegalArgumentException("DataSource use is not allowed in Service.Mode.PAYLOAD\n"); |
|
65 case MESSAGE: |
|
66 return new Packet(XMLMessage.create(arg, binding.getFeatures())); |
|
67 default: |
|
68 throw new WebServiceException("Unrecognized message mode"); |
|
69 } |
|
70 } |
|
71 |
|
72 DataSource toReturnValue(Packet response) { |
|
73 Message message = response.getInternalMessage(); |
|
74 return (message instanceof MessageDataSource) |
|
75 ? ((MessageDataSource)message).getDataSource() |
|
76 : XMLMessage.getDataSource(message, binding.getFeatures()); |
|
77 } |
|
78 } |