1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.xml.internal.ws.handler; |
26 package com.sun.xml.internal.ws.handler; |
27 |
27 |
|
28 import com.sun.xml.internal.ws.api.message.MessageHeaders; |
28 import com.sun.xml.internal.ws.api.message.Packet; |
29 import com.sun.xml.internal.ws.api.message.Packet; |
29 import com.sun.xml.internal.ws.api.message.Message; |
30 import com.sun.xml.internal.ws.api.message.Message; |
30 import com.sun.xml.internal.ws.api.message.HeaderList; |
|
31 import com.sun.xml.internal.ws.api.message.AttachmentSet; |
31 import com.sun.xml.internal.ws.api.message.AttachmentSet; |
32 import com.sun.xml.internal.ws.api.WSBinding; |
32 import com.sun.xml.internal.ws.api.WSBinding; |
33 import com.sun.xml.internal.ws.spi.db.BindingContext; |
33 import com.sun.xml.internal.ws.spi.db.BindingContext; |
34 import com.sun.xml.internal.ws.spi.db.BindingContextFactory; |
34 import com.sun.xml.internal.ws.spi.db.BindingContextFactory; |
35 import com.sun.xml.internal.ws.util.xml.XmlUtil; |
35 import com.sun.xml.internal.ws.util.xml.XmlUtil; |
182 * @param headers |
182 * @param headers |
183 * @param attachments |
183 * @param attachments |
184 * @param binding |
184 * @param binding |
185 * @return |
185 * @return |
186 */ |
186 */ |
187 public Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding) { |
187 public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) { |
188 assert isPayloadModifed(); |
188 assert isPayloadModifed(); |
189 if(isPayloadModifed()) { |
189 if(isPayloadModifed()) { |
190 return lm.getMessage(headers,attachments,binding); |
190 return lm.getMessage(headers,attachments,binding); |
191 } else { |
191 } else { |
192 return packet.getMessage(); |
192 return packet.getMessage(); |
197 |
197 |
198 private abstract class ImmutableLM { |
198 private abstract class ImmutableLM { |
199 public abstract Source getPayload(); |
199 public abstract Source getPayload(); |
200 public abstract Object getPayload(BindingContext context); |
200 public abstract Object getPayload(BindingContext context); |
201 public abstract Object getPayload(JAXBContext context); |
201 public abstract Object getPayload(JAXBContext context); |
202 public abstract Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding); |
202 public abstract Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding); |
203 |
203 |
204 } |
204 } |
205 |
205 |
206 private class DOMLogicalMessageImpl extends SourceLogicalMessageImpl { |
206 private class DOMLogicalMessageImpl extends SourceLogicalMessageImpl { |
207 private DOMSource dom; |
207 private DOMSource dom; |
214 @Override |
214 @Override |
215 public Source getPayload() { |
215 public Source getPayload() { |
216 return dom; |
216 return dom; |
217 } |
217 } |
218 |
218 |
219 public Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding) { |
219 public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) { |
220 Node n = dom.getNode(); |
220 Node n = dom.getNode(); |
221 if(n.getNodeType()== Node.DOCUMENT_NODE) { |
221 if(n.getNodeType()== Node.DOCUMENT_NODE) { |
222 n = ((Document)n).getDocumentElement(); |
222 n = ((Document)n).getDocumentElement(); |
223 } |
223 } |
224 return new DOMMessage(binding.getSOAPVersion(),headers, (Element)n, attachments); |
224 return new DOMMessage(binding.getSOAPVersion(), headers, (Element)n, attachments); |
225 } |
225 } |
226 } |
226 } |
227 |
227 |
228 private class EmptyLogicalMessageImpl extends ImmutableLM { |
228 private class EmptyLogicalMessageImpl extends ImmutableLM { |
229 public EmptyLogicalMessageImpl() { |
229 public EmptyLogicalMessageImpl() { |
243 @Override |
243 @Override |
244 public Object getPayload(BindingContext context) { |
244 public Object getPayload(BindingContext context) { |
245 return null; |
245 return null; |
246 } |
246 } |
247 |
247 |
248 public Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding) { |
248 public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) { |
249 return new EmptyMessageImpl(headers,attachments,binding.getSOAPVersion()); |
249 return new EmptyMessageImpl(headers,attachments,binding.getSOAPVersion()); |
250 } |
250 } |
251 } |
251 } |
252 |
252 |
253 private class JAXBLogicalMessageImpl extends ImmutableLM { |
253 private class JAXBLogicalMessageImpl extends ImmutableLM { |
301 } catch (JAXBException e) { |
301 } catch (JAXBException e) { |
302 throw new WebServiceException(e); |
302 throw new WebServiceException(e); |
303 } |
303 } |
304 } |
304 } |
305 |
305 |
306 public Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding) { |
306 public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) { |
307 return JAXBMessage.create(BindingContextFactory.create(ctxt), o,binding.getSOAPVersion(), headers,attachments); |
307 return JAXBMessage.create(BindingContextFactory.create(ctxt), o,binding.getSOAPVersion(), headers,attachments); |
308 } |
308 } |
309 } |
309 } |
310 |
310 |
311 private class SourceLogicalMessageImpl extends ImmutableLM { |
311 private class SourceLogicalMessageImpl extends ImmutableLM { |
354 throw new WebServiceException(e); |
354 throw new WebServiceException(e); |
355 } |
355 } |
356 |
356 |
357 } |
357 } |
358 |
358 |
359 public Message getMessage(HeaderList headers, AttachmentSet attachments, WSBinding binding) { |
359 public Message getMessage(MessageHeaders headers, AttachmentSet attachments, WSBinding binding) { |
360 assert (payloadSrc!=null); |
360 assert (payloadSrc!=null); |
361 return new PayloadSourceMessage(headers, payloadSrc, attachments,binding.getSOAPVersion()); |
361 return new PayloadSourceMessage(headers, payloadSrc, attachments,binding.getSOAPVersion()); |
362 } |
362 } |
363 } |
363 } |
364 } |
364 } |