Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » transport » mock » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.transport.mock;
   18   
   19   import java.io.IOException;
   20   import java.net.URI;
   21   import java.net.URISyntaxException;
   22   
   23   import org.apache.activemq.transport.MutexTransport;
   24   import org.apache.activemq.transport.ResponseCorrelator;
   25   import org.apache.activemq.transport.Transport;
   26   import org.apache.activemq.transport.TransportFactory;
   27   import org.apache.activemq.transport.TransportServer;
   28   import org.apache.activemq.util.IntrospectionSupport;
   29   import org.apache.activemq.util.URISupport;
   30   import org.apache.activemq.util.URISupport.CompositeData;
   31   
   32   public class MockTransportFactory extends TransportFactory {
   33   
   34       public Transport doConnect(URI location) throws URISyntaxException, Exception {
   35           Transport transport = createTransport(URISupport.parseComposite(location));
   36           transport = new MutexTransport(transport);
   37           transport = new ResponseCorrelator(transport);
   38           return transport;
   39       }
   40   
   41       public Transport doCompositeConnect(URI location) throws URISyntaxException, Exception {
   42           return createTransport(URISupport.parseComposite(location));
   43       }
   44   
   45       /**
   46        * @param location
   47        * @return
   48        * @throws Exception
   49        */
   50       public Transport createTransport(CompositeData compositData) throws Exception {
   51           MockTransport transport = new MockTransport(TransportFactory.compositeConnect(compositData.getComponents()[0]));
   52           IntrospectionSupport.setProperties(transport, compositData.getParameters());
   53           return transport;
   54       }
   55   
   56       public TransportServer doBind(URI location) throws IOException {
   57           throw new IOException("This protocol does not support being bound.");
   58       }
   59   
   60   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » transport » mock » [javadoc | source]