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