Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » transport » discovery » [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.discovery;
   18   
   19   import java.io.IOException;
   20   import java.net.URI;
   21   import java.util.HashMap;
   22   import java.util.Map;
   23   
   24   import org.apache.activemq.transport.Transport;
   25   import org.apache.activemq.transport.TransportServer;
   26   import org.apache.activemq.transport.failover.FailoverTransportFactory;
   27   import org.apache.activemq.util.IntrospectionSupport;
   28   import org.apache.activemq.util.URISupport.CompositeData;
   29   
   30   /**
   31    * @version $Revision$
   32    */
   33   public class DiscoveryTransportFactory extends FailoverTransportFactory {
   34           
   35       public Transport createTransport(CompositeData compositData) throws IOException {
   36           Map<String, String> parameters = new HashMap<String, String>(compositData.getParameters());
   37           DiscoveryTransport transport = new DiscoveryTransport(createTransport(parameters));
   38   
   39           DiscoveryAgent discoveryAgent = DiscoveryAgentFactory.createDiscoveryAgent(compositData.getComponents()[0]);
   40           transport.setDiscoveryAgent(discoveryAgent);
   41           IntrospectionSupport.setProperties(transport, parameters);
   42           transport.setParameters(parameters);
   43           return transport;
   44       }
   45   
   46       public TransportServer doBind(URI location) throws IOException {
   47           throw new IOException("Invalid server URI: " + location);
   48   // try{
   49   //            CompositeData compositData=URISupport.parseComposite(location);
   50   //            URI[] components=compositData.getComponents();
   51   //            if(components.length!=1){
   52   //                throw new IOException("Invalid location: "+location
   53   //                                +", the location must have 1 and only 1 composite URI in it - components = "
   54   //                                +components.length);
   55   //            }
   56   //            Map parameters=new HashMap(compositData.getParameters());
   57   //            DiscoveryTransportServer server=new DiscoveryTransportServer(TransportFactory.bind(value,components[0]));
   58   //            IntrospectionSupport.setProperties(server,parameters,"discovery");
   59   //            DiscoveryAgent discoveryAgent=DiscoveryAgentFactory.createDiscoveryAgent(server.getDiscovery());
   60   //            // Use the host name to configure the group of the discovery agent.
   61   //            if(!parameters.containsKey("discovery.group")){
   62   //                if(compositData.getHost()!=null){
   63   //                    parameters.put("discovery.group",compositData.getHost());
   64   //                }
   65   //            }
   66   //            if(!parameters.containsKey("discovery.brokerName")){
   67   //                parameters.put("discovery.brokerName",value);
   68   //            }
   69   //            IntrospectionSupport.setProperties(discoveryAgent,parameters,"discovery.");
   70   //            server.setDiscoveryAgent(discoveryAgent);
   71   //            return server;
   72   //        }catch(URISyntaxException e){
   73   //            throw new IOException("Invalid location: "+location);
   74   //        }
   75       }
   76   
   77   }

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