KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > SOAPMessageContext_2_0


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.admin.wsmgmt;
24
25 import javax.xml.ws.handler.MessageContext;
26 import javax.xml.soap.SOAPMessage JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.Set JavaDoc;
29 import java.util.Map JavaDoc;
30
31 /**
32  * SOAP Message Context. This encapsulates the required data for web services
33  * management either from JAXWS 1.0 or 2.0 MessageContext.
34  */

35 public class SOAPMessageContext_2_0 implements SOAPMessageContext {
36
37     /**
38      * Constructed from JAXWS 2.0 MessageContext
39      *
40      * @param msg the detail message for this exception
41      */

42     public SOAPMessageContext_2_0(
43         com.sun.xml.ws.spi.runtime.SOAPMessageContext smc) {
44         if (smc == null) {
45             throw new IllegalArgumentException JavaDoc();
46         }
47         _smc = smc;
48     }
49
50     /**
51      * Gets the SOAPMessage for this web service invocation.
52      *
53      * @return SOAPMessage for this web service invocation
54      */

55     public SOAPMessage JavaDoc getMessage() {
56         return _smc.getMessage();
57     }
58
59     /**
60      * Gets the PropertyNames for this web service invocation.
61      *
62      * @return PropertyNames for this web service invocation
63      */

64     public Iterator JavaDoc getPropertyNames() {
65         Set JavaDoc keySet = _smc.keySet();
66         if ( keySet != null) {
67             return keySet.iterator();
68         } else {
69             return null;
70         }
71     }
72
73     /**
74      * Gets the PropertyNames for this web service invocation.
75      *
76      * @return PropertyNames for this web service invocation
77      */

78     public Object JavaDoc getProperty(String JavaDoc name) {
79         // convert jax-rpc property to jax ws property
80
if (( name != null) && (
81         "com.sun.xml.rpc.server.http.HttpServletRequest".equals(name))) {
82             name = MessageContext.SERVLET_REQUEST;
83         }
84         return _smc.get(name);
85     }
86
87     /**
88      * Sets the SOAPMessage in the message context.
89      *
90      * @param msg the SOAPMessage to be set in the message context
91      */

92     public void setMessage(SOAPMessage JavaDoc msg) {
93             _smc.setMessage(msg);
94     }
95     /**
96      * Gets the HTTP Request headers in the message.
97      *
98      * @return the HTTP Request headers in the message.
99      */

100     public String JavaDoc getHTTPRequestHeaders() {
101         Map JavaDoc headerMap = (Map JavaDoc)_smc.get(MessageContext.HTTP_REQUEST_HEADERS);
102         return Utils.getString(headerMap);
103     }
104
105     /**
106      * Gets the HTTP Response headers in the message.
107      *
108      * @return the HTTP Response headers in the message.
109      */

110     public String JavaDoc getHTTPResponseHeaders() {
111         Map JavaDoc headerMap = (Map JavaDoc)_smc.get(MessageContext.HTTP_RESPONSE_HEADERS);
112         return Utils.getString(headerMap);
113     }
114
115
116     // Private variables
117
private com.sun.xml.ws.spi.runtime.SOAPMessageContext _smc = null;
118 }
119
Popular Tags