001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 **/ 018 package org.activemq.transport.udp; 019 020 import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean; 021 import org.apache.commons.logging.Log; 022 import org.apache.commons.logging.LogFactory; 023 import org.activemq.transport.TransportServerChannelSupport; 024 025 import javax.jms.JMSException; 026 import java.net.URI; 027 028 /** 029 * A UDP implementation of TransportServerChannel 030 * 031 * @version $Revision: 1.1.1.1 $ 032 */ 033 public class UdpTransportServerChannel extends TransportServerChannelSupport { 034 035 private static final Log log = LogFactory.getLog(UdpTransportServerChannel.class); 036 037 private SynchronizedBoolean started; 038 039 public UdpTransportServerChannel(URI bindAddr) { 040 super(bindAddr); 041 started = new SynchronizedBoolean(false); 042 } 043 044 /** 045 * start listeneing for events 046 * 047 * @throws JMSException if an error occurs 048 */ 049 public void start() throws JMSException { 050 if (started.commit(false, true)) { 051 log.info("ServerChannel at: " + getUrl()); 052 } 053 } 054 055 /** 056 * @return pretty print of this 057 */ 058 public String toString() { 059 return "UdpTransportServerChannel@" + getUrl(); 060 } 061 062 }