1 18 package org.apache.activemq.transport.failover; 19 20 import java.io.IOException ; 21 import java.net.URI ; 22 import java.net.URISyntaxException ; 23 import java.util.Map ; 24 25 import org.apache.activemq.transport.MutexTransport; 26 import org.apache.activemq.transport.ResponseCorrelator; 27 import org.apache.activemq.transport.Transport; 28 import org.apache.activemq.transport.TransportFactory; 29 import org.apache.activemq.transport.TransportServer; 30 import org.apache.activemq.util.IntrospectionSupport; 31 import org.apache.activemq.util.URISupport; 32 import org.apache.activemq.util.URISupport.CompositeData; 33 34 public class FailoverTransportFactory extends TransportFactory { 35 36 public Transport doConnect(URI location) throws IOException { 37 try { 38 Transport transport = createTransport(URISupport.parseComposite(location)); 39 transport = new MutexTransport(transport); 40 transport = new ResponseCorrelator(transport); 41 return transport; 42 } catch (URISyntaxException e) { 43 throw new IOException ("Invalid location: "+location); 44 } 45 } 46 47 public Transport doCompositeConnect(URI location) throws IOException { 48 try { 49 return createTransport(URISupport.parseComposite(location)); 50 } catch (URISyntaxException e) { 51 throw new IOException ("Invalid location: "+location); 52 } 53 } 54 55 60 public Transport createTransport(CompositeData compositData) throws IOException { 61 FailoverTransport transport = createTransport(compositData.getParameters()); 62 transport.add(compositData.getComponents()); 63 return transport; 64 } 65 66 public FailoverTransport createTransport(Map parameters) throws IOException { 67 FailoverTransport transport = new FailoverTransport(); 68 IntrospectionSupport.setProperties(transport, parameters); 69 return transport; 70 } 71 72 public TransportServer doBind(String brokerId,URI location) throws IOException { 73 throw new IOException ("Invalid server URI: "+location); 74 } 75 76 } 77 | Popular Tags |