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     */
017    package org.apache.geronimo.webservices;
018    
019    import java.util.ArrayList;
020    import java.util.HashMap;
021    
022    public class PortComponent {
023        private String portComponentName;
024        private String wsdlPort;
025        private String serviceEndpointInterface;
026        private ServiceImplBean serviceImplBean;
027    
028        /**
029         * List of Handler objects
030         *
031         * @see org.apache.geronimo.webservices.Handler
032         */
033        private ArrayList handlerList = new ArrayList();
034        /**
035         * Map of Handler objects indexed by handlerName
036         *
037         * @see org.apache.geronimo.webservices.Handler#getHandlerName
038         */
039        private HashMap handlerMap = new HashMap();
040    
041        public void addHandler(Handler handler) throws IndexOutOfBoundsException {
042            handlerList.add(handler);
043            handlerMap.put(handler.getHandlerName(), handler);
044        }
045    
046        public void addHandler(int index, Handler handler) throws IndexOutOfBoundsException {
047            handlerList.add(index, handler);
048            handlerMap.put(handler.getHandlerName(), handler);
049        }
050    
051        public boolean removeHandler(Handler handler) {
052            handlerMap.remove(handler.getHandlerName());
053            return handlerList.remove(handler);
054        }
055    
056        public Handler getHandler(int index) throws IndexOutOfBoundsException {
057            if ((index < 0) || (index > handlerList.size())) {
058                throw new IndexOutOfBoundsException();
059            }
060            return (Handler) handlerList.get(index);
061        }
062    
063        public Handler[] getHandler() {
064            int size = handlerList.size();
065            Handler[] mArray = new Handler[size];
066            for (int index = 0; index < size; index++) {
067                mArray[index] = (Handler) handlerList.get(index);
068            }
069            return mArray;
070        }
071    
072        public Handler getHandler(String handlerName) {
073            return (Handler) handlerMap.get(handlerName);
074        }
075    
076        public void setHandler(int index, Handler handler) throws IndexOutOfBoundsException {
077            if ((index < 0) || (index > handlerList.size())) {
078                throw new IndexOutOfBoundsException();
079            }
080            Handler removed = (Handler) handlerList.set(index, handler);
081            handlerMap.remove(removed.getHandlerName());
082            handlerMap.put(handler.getHandlerName(), handler);
083        }
084    
085        public void setHandler(Handler[] handlerArray) {
086            handlerList.clear();
087            for (int i = 0; i < handlerArray.length; i++) {
088                Handler handler = handlerArray[i];
089                handlerList.add(handler);
090                handlerMap.put(handler.getHandlerName(), handler);
091            }
092        }
093    
094        public void clearHandler() {
095            handlerList.clear();
096            handlerMap.clear();
097        }
098    
099        public String getPortComponentName() {
100            return portComponentName;
101        }
102    
103        public void setPortComponentName(String portComponentName) {
104            this.portComponentName = portComponentName;
105        }
106    
107        public String getWsdlPort() {
108            return wsdlPort;
109        }
110    
111        public void setWsdlPort(String wsdlPort) {
112            this.wsdlPort = wsdlPort;
113        }
114    
115        public String getServiceEndpointInterface() {
116            return serviceEndpointInterface;
117        }
118    
119        public void setServiceEndpointInterface(String serviceEndpointInterface) {
120            this.serviceEndpointInterface = serviceEndpointInterface;
121        }
122    
123        public ServiceImplBean getServiceImplBean() {
124            return serviceImplBean;
125        }
126    
127        public void setServiceImplBean(ServiceImplBean serviceImplBean) {
128            this.serviceImplBean = serviceImplBean;
129        }
130    }