001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.xml.internal.ws.util;
026:
027: import com.sun.xml.internal.bind.api.BridgeContext;
028: import com.sun.xml.internal.ws.client.BindingProviderProperties;
029: import com.sun.xml.internal.ws.encoding.JAXWSAttachmentMarshaller;
030: import com.sun.xml.internal.ws.encoding.soap.SOAPDecoder;
031: import com.sun.xml.internal.ws.encoding.soap.internal.HeaderBlock;
032: import com.sun.xml.internal.ws.handler.HandlerChainCaller;
033: import com.sun.xml.internal.ws.handler.HandlerContext;
034: import com.sun.xml.internal.ws.pept.ept.MessageInfo;
035: import com.sun.xml.internal.ws.server.RuntimeContext;
036:
037: import javax.xml.ws.handler.MessageContext;
038: import javax.xml.bind.Marshaller;
039: import java.util.Set;
040:
041: /**
042: * @author WS RI Development Team
043: */
044: public class MessageInfoUtil {
045:
046: public static void setRuntimeContext(MessageInfo messageInfo,
047: RuntimeContext runtimeContext) {
048: messageInfo.setMetaData(
049: BindingProviderProperties.JAXWS_RUNTIME_CONTEXT,
050: runtimeContext);
051: }
052:
053: public static RuntimeContext getRuntimeContext(
054: MessageInfo messageInfo) {
055: return (RuntimeContext) messageInfo
056: .getMetaData(BindingProviderProperties.JAXWS_RUNTIME_CONTEXT);
057: }
058:
059: public static MessageContext getMessageContext(
060: MessageInfo messageInfo) {
061: RuntimeContext rtCtxt = getRuntimeContext(messageInfo);
062: HandlerContext hdCtxt = null;
063: if (rtCtxt != null)
064: hdCtxt = rtCtxt.getHandlerContext();
065: else
066: hdCtxt = (HandlerContext) messageInfo
067: .getMetaData(BindingProviderProperties.JAXWS_HANDLER_CONTEXT_PROPERTY);
068: return (hdCtxt == null) ? null : hdCtxt.getMessageContext();
069: }
070:
071: public static HandlerChainCaller getHandlerChainCaller(
072: MessageInfo messageInfo) {
073: return (HandlerChainCaller) messageInfo
074: .getMetaData(HandlerChainCaller.HANDLER_CHAIN_CALLER);
075: }
076:
077: public static void setHandlerChainCaller(MessageInfo messageInfo,
078: HandlerChainCaller caller) {
079: messageInfo.setMetaData(
080: HandlerChainCaller.HANDLER_CHAIN_CALLER, caller);
081: }
082:
083: public static JAXWSAttachmentMarshaller getAttachmentMarshaller(
084: MessageInfo messageInfo) {
085: Object rtc = messageInfo
086: .getMetaData(BindingProviderProperties.JAXWS_RUNTIME_CONTEXT);
087: if (rtc != null) {
088: BridgeContext bc = ((RuntimeContext) rtc)
089: .getBridgeContext();
090: if (bc != null) {
091: return (JAXWSAttachmentMarshaller) bc
092: .getAttachmentMarshaller();
093: }
094: } else {
095: Marshaller m = (Marshaller) messageInfo
096: .getMetaData(BindingProviderProperties.DISPATCH_MARSHALLER);
097: if (m != null) {
098: return (JAXWSAttachmentMarshaller) m
099: .getAttachmentMarshaller();
100: }
101: }
102: return null;
103: }
104:
105: public static void setNotUnderstoodHeaders(MessageInfo messageInfo,
106: Set<HeaderBlock> headers) {
107:
108: messageInfo.setMetaData(SOAPDecoder.NOT_UNDERSTOOD_HEADERS,
109: headers);
110: }
111:
112: public static Set<HeaderBlock> getNotUnderstoodHeaders(
113: MessageInfo messageInfo) {
114:
115: return (Set<HeaderBlock>) messageInfo
116: .getMetaData(SOAPDecoder.NOT_UNDERSTOOD_HEADERS);
117: }
118: }
|