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