001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.webservices;
017:
018: import java.util.ArrayList;
019: import java.util.HashMap;
020:
021: /**
022: * A dtd version of the J2EE webservices.xml file would look like this:
023: * <p/>
024: * webservices (webservice-description+)
025: * webservice-description (webservice-description-name, wsdl-file, jaxrpc-mapping-file, port-component+)
026: * port-component (port-component-name, wsdl-port, service-endpoint-interface, service-impl-bean, handler*)
027: * service-impl-bean (ejb-link|servlet-link)
028: * handler (handler-name, handler-class, init-param*, soap-header*, soap-role*)
029: */
030: public class WebServices {
031: /**
032: * List of WebServiceDescription objects
033: *
034: * @see org.apache.geronimo.webservices.WebServiceDescription
035: */
036: private ArrayList webServiceDescriptionList = new ArrayList();
037: /**
038: * Map of WebServiceDescription objects indexed by webServiceDescriptionName
039: *
040: * @see org.apache.geronimo.webservices.WebServiceDescription#getWebServiceDescriptionName
041: */
042: private HashMap webServiceDescriptionMap = new HashMap();
043:
044: public void addWebServiceDescription(
045: WebServiceDescription webServiceDescription)
046: throws IndexOutOfBoundsException {
047: webServiceDescriptionList.add(webServiceDescription);
048: webServiceDescriptionMap.put(webServiceDescription
049: .getWebServiceDescriptionName(), webServiceDescription);
050: }
051:
052: public void addWebServiceDescription(int index,
053: WebServiceDescription webServiceDescription)
054: throws IndexOutOfBoundsException {
055: webServiceDescriptionList.add(index, webServiceDescription);
056: webServiceDescriptionMap.put(webServiceDescription
057: .getWebServiceDescriptionName(), webServiceDescription);
058: }
059:
060: public boolean removeWebServiceDescription(
061: WebServiceDescription webServiceDescription) {
062: webServiceDescriptionMap.remove(webServiceDescription
063: .getWebServiceDescriptionName());
064: return webServiceDescriptionList.remove(webServiceDescription);
065: }
066:
067: public WebServiceDescription getWebServiceDescription(int index)
068: throws IndexOutOfBoundsException {
069: if ((index < 0) || (index > webServiceDescriptionList.size())) {
070: throw new IndexOutOfBoundsException();
071: }
072: return (WebServiceDescription) webServiceDescriptionList
073: .get(index);
074: }
075:
076: public WebServiceDescription[] getWebServiceDescription() {
077: int size = webServiceDescriptionList.size();
078: WebServiceDescription[] mArray = new WebServiceDescription[size];
079: for (int index = 0; index < size; index++) {
080: mArray[index] = (WebServiceDescription) webServiceDescriptionList
081: .get(index);
082: }
083: return mArray;
084: }
085:
086: public WebServiceDescription getWebServiceDescription(
087: String webServiceDescriptionName) {
088: return (WebServiceDescription) webServiceDescriptionMap
089: .get(webServiceDescriptionName);
090: }
091:
092: public void setWebServiceDescription(int index,
093: WebServiceDescription webServiceDescription)
094: throws IndexOutOfBoundsException {
095: if ((index < 0) || (index > webServiceDescriptionList.size())) {
096: throw new IndexOutOfBoundsException();
097: }
098: WebServiceDescription removed = (WebServiceDescription) webServiceDescriptionList
099: .set(index, webServiceDescription);
100: webServiceDescriptionMap.remove(removed
101: .getWebServiceDescriptionName());
102: webServiceDescriptionMap.put(webServiceDescription
103: .getWebServiceDescriptionName(), webServiceDescription);
104: }
105:
106: public void setWebServiceDescription(
107: WebServiceDescription[] webServiceDescriptionArray) {
108: clearWebServiceDescription();
109: for (int i = 0; i < webServiceDescriptionArray.length; i++) {
110: WebServiceDescription webServiceDescription = webServiceDescriptionArray[i];
111: webServiceDescriptionList.add(webServiceDescription);
112: webServiceDescriptionMap.put(webServiceDescription
113: .getWebServiceDescriptionName(),
114: webServiceDescription);
115: }
116: }
117:
118: public void clearWebServiceDescription() {
119: webServiceDescriptionList.clear();
120: webServiceDescriptionMap.clear();
121: }
122: }
|