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.handler;
026:
027: import java.util.List;
028: import com.sun.xml.internal.ws.spi.runtime.MessageContext;
029: import com.sun.xml.internal.ws.encoding.soap.internal.InternalMessage;
030: import com.sun.xml.internal.ws.encoding.soap.SOAPEPTFactory;
031: import com.sun.xml.internal.ws.encoding.JAXWSAttachmentMarshaller;
032: import com.sun.xml.internal.ws.spi.runtime.InternalSoapEncoder;
033: import com.sun.xml.internal.ws.spi.runtime.Invoker;
034: import com.sun.xml.internal.ws.util.MessageInfoUtil;
035:
036: import java.lang.reflect.Method;
037:
038: /**
039: * Implementation of SOAPMessageContext. This class is used at runtime
040: * to pass to the handlers for processing soap messages.
041: *
042: * @see MessageContextImpl
043: *
044: * @author WS Development Team
045: */
046: public class SHDSOAPMessageContext extends SOAPMessageContextImpl
047: implements
048: com.sun.xml.internal.ws.spi.runtime.SOAPMessageContext {
049:
050: SOAPHandlerContext handlerCtxt;
051:
052: public SHDSOAPMessageContext(SOAPHandlerContext handlerCtxt) {
053: super (handlerCtxt);
054: this .handlerCtxt = handlerCtxt;
055: }
056:
057: /**
058: * If there is a SOAPMessage already, use getSOAPMessage(). Ignore all other
059: * methods
060: */
061: public boolean isAlreadySoap() {
062: return handlerCtxt.getSOAPMessage() != null;
063: }
064:
065: /*
066: * Returns InternalMessage's BodyBlock value
067: */
068: public Object getBody() {
069: return handlerCtxt.getBody();
070: }
071:
072: /*
073: * Returns InternalMessage's HeaderBlock values
074: */
075: public List getHeaders() {
076: return handlerCtxt.getHeaders();
077: }
078:
079: /*
080: * Use this MessageInfo to pass to InternalSoapEncoder write methods
081: */
082: public Object getMessageInfo() {
083: return handlerCtxt.getMessageInfo();
084: }
085:
086: /*
087: * Encoder to marshall all JAXWS objects: RpcLitPayload, JAXBBridgeInfo etc
088: */
089: public InternalSoapEncoder getEncoder() {
090: return (InternalSoapEncoder) ((SOAPEPTFactory) handlerCtxt
091: .getMessageInfo().getEPTFactory()).getSOAPEncoder();
092: }
093:
094: public String getBindingId() {
095: return handlerCtxt.getBindingId();
096: }
097:
098: public Method getMethod() {
099: return handlerCtxt.getMethod();
100: }
101:
102: public void setCanonicalization(String algorithm) {
103: handlerCtxt.setCanonicalization(algorithm);
104: }
105:
106: public Invoker getInvoker() {
107: return handlerCtxt.getInvoker();
108: }
109:
110: /**
111: * Returns if MTOM is anbled
112: *
113: * @return true if MTOM is enabled otherwise returns false;
114: */
115: public boolean isMtomEnabled() {
116: JAXWSAttachmentMarshaller am = MessageInfoUtil
117: .getAttachmentMarshaller(handlerCtxt.getMessageInfo());
118: return (am != null) ? am.isXOPPackage() : false;
119: }
120:
121: }
|