KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > webservices > WebServices


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

17 package org.apache.geronimo.webservices;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.HashMap JavaDoc;
21
22
23 /**
24  * A dtd version of the J2EE webservices.xml file would look like this:
25  * <p/>
26  * webservices (webservice-description+)
27  * webservice-description (webservice-description-name, wsdl-file, jaxrpc-mapping-file, port-component+)
28  * port-component (port-component-name, wsdl-port, service-endpoint-interface, service-impl-bean, handler*)
29  * service-impl-bean (ejb-link|servlet-link)
30  * handler (handler-name, handler-class, init-param*, soap-header*, soap-role*)
31  */

32 public class WebServices {
33     /**
34      * List of WebServiceDescription objects
35      *
36      * @see org.apache.geronimo.webservices.WebServiceDescription
37      */

38     private ArrayList JavaDoc webServiceDescriptionList = new ArrayList JavaDoc();
39     /**
40      * Map of WebServiceDescription objects indexed by webServiceDescriptionName
41      *
42      * @see org.apache.geronimo.webservices.WebServiceDescription#getWebServiceDescriptionName
43      */

44     private HashMap JavaDoc webServiceDescriptionMap = new HashMap JavaDoc();
45
46     public void addWebServiceDescription(WebServiceDescription webServiceDescription) throws IndexOutOfBoundsException JavaDoc {
47         webServiceDescriptionList.add(webServiceDescription);
48         webServiceDescriptionMap.put(webServiceDescription.getWebServiceDescriptionName(), webServiceDescription);
49     }
50
51     public void addWebServiceDescription(int index, WebServiceDescription webServiceDescription) throws IndexOutOfBoundsException JavaDoc {
52         webServiceDescriptionList.add(index, webServiceDescription);
53         webServiceDescriptionMap.put(webServiceDescription.getWebServiceDescriptionName(), webServiceDescription);
54     }
55
56     public boolean removeWebServiceDescription(WebServiceDescription webServiceDescription) {
57         webServiceDescriptionMap.remove(webServiceDescription.getWebServiceDescriptionName());
58         return webServiceDescriptionList.remove(webServiceDescription);
59     }
60
61     public WebServiceDescription getWebServiceDescription(int index) throws IndexOutOfBoundsException JavaDoc {
62         if ((index < 0) || (index > webServiceDescriptionList.size())) {
63             throw new IndexOutOfBoundsException JavaDoc();
64         }
65         return (WebServiceDescription) webServiceDescriptionList.get(index);
66     }
67
68     public WebServiceDescription[] getWebServiceDescription() {
69         int size = webServiceDescriptionList.size();
70         WebServiceDescription[] mArray = new WebServiceDescription[size];
71         for (int index = 0; index < size; index++) {
72             mArray[index] = (WebServiceDescription) webServiceDescriptionList.get(index);
73         }
74         return mArray;
75     }
76
77     public WebServiceDescription getWebServiceDescription(String JavaDoc webServiceDescriptionName) {
78         return (WebServiceDescription) webServiceDescriptionMap.get(webServiceDescriptionName);
79     }
80
81     public void setWebServiceDescription(int index, WebServiceDescription webServiceDescription) throws IndexOutOfBoundsException JavaDoc {
82         if ((index < 0) || (index > webServiceDescriptionList.size())) {
83             throw new IndexOutOfBoundsException JavaDoc();
84         }
85         WebServiceDescription removed = (WebServiceDescription) webServiceDescriptionList.set(index, webServiceDescription);
86         webServiceDescriptionMap.remove(removed.getWebServiceDescriptionName());
87         webServiceDescriptionMap.put(webServiceDescription.getWebServiceDescriptionName(), webServiceDescription);
88     }
89
90     public void setWebServiceDescription(WebServiceDescription[] webServiceDescriptionArray) {
91         clearWebServiceDescription();
92         for (int i = 0; i < webServiceDescriptionArray.length; i++) {
93             WebServiceDescription webServiceDescription = webServiceDescriptionArray[i];
94             webServiceDescriptionList.add(webServiceDescription);
95             webServiceDescriptionMap.put(webServiceDescription.getWebServiceDescriptionName(), webServiceDescription);
96         }
97     }
98
99     public void clearWebServiceDescription() {
100         webServiceDescriptionList.clear();
101         webServiceDescriptionMap.clear();
102     }
103 }
104
Popular Tags