001 /** 002 * 003 * Copyright 2004 Hiram Chirino 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.activeio; 019 020 import java.io.IOException; 021 import java.net.URI; 022 import java.net.URISyntaxException; 023 024 import javax.jms.JMSException; 025 026 import org.activeio.AsyncChannelServer; 027 import org.activeio.ChannelFactory; 028 import org.activemq.io.WireFormat; 029 import org.activemq.transport.TransportServerChannel; 030 import org.activemq.transport.TransportServerChannelFactory; 031 import org.activemq.util.JMSExceptionHelper; 032 033 /** 034 * A tcp implementation of a TransportServerChannelFactory 035 * 036 * @version $Revision: 1.1.1.1 $ 037 */ 038 public class ActiveIOTransportServerChannelFactory implements TransportServerChannelFactory { 039 040 /** 041 * Bind a ServerChannel to an address 042 *O 043 * @param wireFormat 044 * @param bindAddress 045 * @return the TransportChannel bound to the remote node 046 * @throws JMSException 047 */ 048 public TransportServerChannel create(WireFormat wireFormat, URI bindAddress) throws JMSException { 049 AsyncChannelServer server = createAsyncChannelServer(bindAddress); 050 return new ActiveIOTransportServerChannel(wireFormat, server); 051 } 052 053 /** 054 * @param bindAddress 055 * @return 056 */ 057 private AsyncChannelServer createAsyncChannelServer(URI bindAddress) throws JMSException { 058 try { 059 bindAddress = URIConverter.convert(bindAddress); 060 AsyncChannelServer server = new ChannelFactory().bindAsyncChannel(bindAddress); 061 return server; 062 } catch (IOException e) { 063 throw JMSExceptionHelper.newJMSException(e.getMessage(), e); 064 } catch (URISyntaxException e) { 065 throw JMSExceptionHelper.newJMSException(e.getMessage(), e); 066 } 067 } 068 069 }