KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > wsm > model > jsr181 > SOAPMessageHandlerInfo


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.wsm.model.jsr181;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Arrays JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.Map JavaDoc;
26
27 import javax.jws.soap.InitParam;
28 import javax.jws.soap.SOAPMessageHandler;
29
30 import org.apache.beehive.wsm.model.BeehiveWsSOAPMessageHandlerInfo;
31
32 public class SOAPMessageHandlerInfo implements java.io.Serializable JavaDoc, BeehiveWsSOAPMessageHandlerInfo {
33
34     private static final long serialVersionUID = 1L;
35     
36     String JavaDoc name;
37     String JavaDoc className;
38     HashMap JavaDoc<String JavaDoc, String JavaDoc> parameterMap = new HashMap JavaDoc<String JavaDoc, String JavaDoc>();
39     Collection JavaDoc<String JavaDoc> roles = new ArrayList JavaDoc<String JavaDoc>();
40     Collection JavaDoc<String JavaDoc> headers = new ArrayList JavaDoc<String JavaDoc>();
41
42     /**
43      *
44      */

45     public SOAPMessageHandlerInfo(SOAPMessageHandler annotation) {
46
47         // validate className
48
String JavaDoc className = annotation.className();
49         if (0 == className.length()) {
50             throw new IllegalArgumentException JavaDoc("className required to configure a SOAPMessageHandler");
51         }
52         
53         // set fields from annotation
54
setClassName(className);
55         setName((0 < annotation.name().length()) ? annotation.name() : className);
56         for (InitParam p : annotation.initParams()) {
57             addInitParam(p.name(), p.value());
58         }
59         addRoles(Arrays.asList(annotation.roles()));
60         for (String JavaDoc s : annotation.headers()) {
61             addHeader(s);
62         }
63     }
64
65     public SOAPMessageHandlerInfo(
66         String JavaDoc handlerClassName,
67         String JavaDoc handlerName,
68         Map JavaDoc<String JavaDoc, String JavaDoc> initParams,
69         Collection JavaDoc<String JavaDoc> roles,
70         Collection JavaDoc<String JavaDoc> headers
71     ) {
72         setClassName(handlerClassName);
73         setName((handlerName != null && handlerName.length() > 0)
74                 ? handlerName : handlerClassName);
75         addInitParams(initParams);
76         addRoles(roles);
77         addHeaders(headers);
78     }
79
80     /**
81      * @return Returns the className.
82      */

83     public String JavaDoc getClassName() {
84         return className;
85     }
86
87     /**
88      * @param className The className to set.
89      */

90     public void setClassName(String JavaDoc className) {
91         this.className = className;
92     }
93
94     /**
95      * @return Returns the name.
96      */

97     public String JavaDoc getName() {
98         return name;
99     }
100
101     /**
102      * @param name The name to set.
103      */

104     public void setName(String JavaDoc name) {
105         this.name = name;
106     }
107
108     /**
109      * @return Returns the headers.
110      */

111     public Collection JavaDoc<String JavaDoc> getHeaders() {
112         return Collections.unmodifiableCollection(headers);
113     }
114
115     public void addHeader(String JavaDoc header) {
116         this.headers.add(header);
117     }
118
119     /**
120      * @param headers
121      */

122     private void addHeaders(Collection JavaDoc<String JavaDoc> headers) {
123         this.headers.addAll(headers);
124     }
125
126     /**
127      * @return Returns the params.
128      */

129     public Map JavaDoc<String JavaDoc, String JavaDoc> getParameterMap() {
130         return Collections.unmodifiableMap(parameterMap);
131     }
132
133     public void addInitParam(String JavaDoc key, String JavaDoc value) {
134         parameterMap.put(key, value);
135     }
136
137     public void addInitParams(Map JavaDoc<String JavaDoc, String JavaDoc> params) {
138         parameterMap.putAll(params);
139     }
140
141     /**
142      * @return Returns the roles.
143      */

144     public Collection JavaDoc<String JavaDoc> getRoles() {
145         return Collections.unmodifiableCollection(roles);
146     }
147
148     public void addRole(String JavaDoc role) {
149         this.roles.add(role);
150     }
151
152     public void addRoles(Collection JavaDoc<String JavaDoc> roles) {
153         this.roles.addAll(roles);
154     }
155
156 }
157
Popular Tags