01: /*
02: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25: package com.sun.xml.internal.ws.handler;
26:
27: import javax.xml.bind.JAXBContext;
28: import javax.xml.ws.LogicalMessage;
29: import javax.xml.transform.Source;
30: import com.sun.xml.internal.ws.encoding.xml.XMLMessage;
31:
32: /**
33: * Implementation of LogicalMessage that is used in the
34: * XML/HTTP binding. It is similar to LogicalMessageImpl
35: * except that the context object passed in is an
36: * {@link XMLHandlerContext} rather than a {@link HandlerContext}.
37: *
38: * @see LogicalMessageImpl
39: * @see XMLHandlerContext
40: * @see XMLLogicalMessageContextImpl
41: *
42: * @author WS Development Team
43: */
44: public class XMLLogicalMessageImpl implements LogicalMessage {
45:
46: private XMLHandlerContext ctxt;
47:
48: public XMLLogicalMessageImpl(XMLHandlerContext ctxt) {
49: this .ctxt = ctxt;
50: }
51:
52: /*
53: * Gets the source from XMLMessage. XMLMessage gives a copy of existing
54: * data
55: */
56: public Source getPayload() {
57: XMLMessage xmlMessage = ctxt.getXMLMessage();
58: return xmlMessage.getPayload();
59: }
60:
61: /*
62: * Sets the Source as payload in XMLMessage
63: */
64: public void setPayload(Source source) {
65: XMLMessage xmlMessage = ctxt.getXMLMessage();
66: xmlMessage = new XMLMessage(source,
67: xmlMessage.getAttachments(), xmlMessage
68: .useFastInfoset());
69: ctxt.setXMLMessage(xmlMessage);
70: }
71:
72: /*
73: * Gets XMLMessage data as JAXB bean
74: */
75: public Object getPayload(JAXBContext jaxbContext) {
76: XMLMessage xmlMessage = ctxt.getXMLMessage();
77: return xmlMessage.getPayload(jaxbContext);
78: }
79:
80: /*
81: * Sets JAXB bean into XMLMessage
82: */
83: public void setPayload(Object bean, JAXBContext jaxbContext) {
84: XMLMessage xmlMessage = ctxt.getXMLMessage();
85: xmlMessage = new XMLMessage(bean, jaxbContext, xmlMessage
86: .getAttachments(), xmlMessage.useFastInfoset());
87: ctxt.setXMLMessage(xmlMessage);
88: }
89:
90: public XMLHandlerContext getHandlerContext() {
91: return ctxt;
92: }
93:
94: }
|