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.activemq.transport;
018    
019    import java.net.URI;
020    import java.util.Map;
021    
022    import org.apache.activemq.util.ServiceSupport;
023    
024    /**
025     * A useful base class for implementations of {@link TransportServer}
026     * 
027     * 
028     */
029    public abstract class TransportServerSupport extends ServiceSupport implements TransportServer {
030    
031        private URI connectURI;
032        private URI bindLocation;
033        private TransportAcceptListener acceptListener;
034        protected Map<String, Object> transportOptions;
035    
036        public TransportServerSupport() {
037        }
038    
039        public TransportServerSupport(URI location) {
040            this.connectURI = location;
041            this.bindLocation = location;
042        }
043    
044        /**
045         * @return Returns the acceptListener.
046         */
047        public TransportAcceptListener getAcceptListener() {
048            return acceptListener;
049        }
050    
051        /**
052         * Registers an accept listener
053         * 
054         * @param acceptListener
055         */
056        public void setAcceptListener(TransportAcceptListener acceptListener) {
057            this.acceptListener = acceptListener;
058        }
059    
060        /**
061         * @return Returns the location.
062         */
063        public URI getConnectURI() {
064            return connectURI;
065        }
066    
067        /**
068         * @param location The location to set.
069         */
070        public void setConnectURI(URI location) {
071            this.connectURI = location;
072        }
073    
074        protected void onAcceptError(Exception e) {
075            if (acceptListener != null) {
076                acceptListener.onAcceptError(e);
077            }
078        }
079    
080        public URI getBindLocation() {
081            return bindLocation;
082        }
083    
084        public void setBindLocation(URI bindLocation) {
085            this.bindLocation = bindLocation;
086        }
087    
088        public void setTransportOption(Map<String, Object> transportOptions) {
089            this.transportOptions = transportOptions;
090        }
091    
092    
093    }