Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2014 Red Hat, Inc. Red Hat licenses this file to you under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package io.fabric8.camel;
 
 
 import java.net.URI;
 import java.util.Map;

Creates an endpoint which uses FABRIC to map a logical name to physical endpoint names
 
 public class FabricPublisherEndpoint extends DefaultEndpoint {
     private static final transient Log LOG = LogFactory.getLog(FabricPublisherEndpoint.class);
 
     private final FabricComponent component;
     private final String singletonId;
     private final String child;
     private final String consumer;
     private final Group<CamelNodeStategroup;
     private String joined;
 
     public FabricPublisherEndpoint(String uriFabricComponent componentString singletonIdString childthrows Exception {
         super(uricomponent);
         this. = component;
         this. = singletonId;
 
         String path = child;
         int idx = path.indexOf('?');
         if (idx > -1) {
             path = path.substring(0, idx);
         }
         Map<StringObjectparams = URISupport.parseParameters(new URI(child));
         String consumer = params != null ? (Stringparams.remove("consumer") : null;
         if (consumer != null) {
             Map<StringObjectproperties = IntrospectionSupport.extractProperties(params"consumer.");
             if (properties != null && properties.size() > 0) {
                 consumer = consumer + "?" + URISupport.createQueryString(properties);
                 for (String k : properties.keySet()) {
                     params.remove(k);
                 }
             }
             child = path;
             if (params.size() > 0) {
                 child = child + "?" + URISupport.createQueryString(params);
             }
         } else {
             consumer = child;
         }
         .info("Child: " + child);
         .info("Consumer: " + consumer);
         this. = child;
         this. = consumer;
 
         path = getComponent().getFabricPath(singletonId);
          = getComponent().createGroup(path);
         CamelNodeState state = new CamelNodeState(singletonId);
         state.consumer = consumer;
         .update(state);
     }
 
     public Producer createProducer() throws Exception {
         return getCamelContext().getEndpoint().createProducer();
     }
 
     @Override
     public boolean isLenientProperties() {
         // to allow properties to be propagated to the child endpoint
         return true;
     }
     
     public Consumer createConsumer(Processor processorthrows Exception {
         return getCamelContext().getEndpoint().createConsumer(processor);
     }
 
     public boolean isSingleton() {
         return true;
     }
    @Override
    public void doStart() throws Exception {
        super.doStart();
        .start();
    }
    @Override
    public void doStop() throws Exception {
        .close();
        super.doStop();
    }
    // Properties
    //-------------------------------------------------------------------------
    public FabricComponent getComponent() {
        return ;
    }
    public String getChild() {
        return ;
    }
New to GrepCode? Check out our FAQ X