Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kevoree.library.camel.http;
  
 
 import java.util.List;

Created with IntelliJ IDEA. User: duke Date: 10/05/12 Time: 15:25
 
 
 @Library(name = "JavaSE")
         @DictionaryAttribute(name = "port", defaultValue = "10000", optional = true, fragmentDependant = true)
 })
 
     protected int port;
 
     @Start
     @Override
     public void startCamelChannel() throws Exception {
          = parsePortNumber(getNodeName());
         super.startCamelChannel();
     }
 
     @Stop
     @Override
     public void stopCamelChannel() throws Exception {
         super.stopCamelChannel();
     }
 
     @Update
     @Override
     public void updateCamelChannel() throws Exception {
         if (!getDictionary().get("port").toString().equals( + "")) {
             super.updateCamelChannel();
         }
     }
 
     @Override
     protected void buildRoutes(RouteBuilder routeBuilder) {
         routeBuilder.from("kchannel:input")
                 .process(new Processor() {
                     @Override
                     public void process(Exchange exchangethrows Exception {
                         if (getBindedPorts().isEmpty() && getOtherFragments().isEmpty()) {
                             Log.debug("No consumer, msg lost=" + exchange.getIn().getBody());
                         } else {
                             for (org.kevoree.framework.KevoreePort p : getBindedPorts()) {
                                 if (exchange.getIn().getBody() instanceof Message) {
                                     forward(p, (Messageexchange.getIn().getBody());
                                 }
                             }
                             for (KevoreeChannelFragment cf : getOtherFragments()) {
                                 List<Stringaddresses = getAddresses(cf.getNodeName());
                                 if (addresses.size() > 0) {
                                     for (String address : addresses) {
                                         try {
                                             getContext().createProducerTemplate().sendBody("jetty:http://" + address + ":" + parsePortNumber(cf.getNodeName()), exchange.getIn().getBody());
                                             break;
                                         } catch (Exception e) {
                                             Log.debug("Unable to send data to components on {} using {} as address",ecf.getNodeName(), "jetty:http://" + address + ":" + parsePortNumber(cf.getNodeName()));
                                         }
                                     }
                                 } else {
                                     try {
                                         getContext().createProducerTemplate().sendBody("jetty:http://127.0.0.1:" + parsePortNumber(cf.getNodeName()), exchange.getIn().getBody());
                                     } catch (Exception e) {
                                         Log.debug("Unable to send data to components on {} using {} as address",ecf.getNodeName(), "jetty:http://127.0.0.1:" + parsePortNumber(cf.getNodeName()));
                                     }
                                 }
                             }
                         }
                     }
                 }
                 );
         List<Stringaddresses = getAddresses(getNodeName());
         if (addresses.size() > 0) {
             for (String address : addresses) {
                 try {
                     routeBuilder.from("jetty:http://" + address + ":" + ).
                             process(new Processor() {
                                 public void process(Exchange exchangethrows Exception {
                                     exchange.getOut().setBody("No result is waiting");
                                     for (org.kevoree.framework.KevoreePort p : getBindedPorts()) {
                                         if (exchange.getIn().getBody() instanceof Message) {
                                             forward(p, (Messageexchange.getIn().getBody());
                                        }
                                    }
                                }
                            });
                } catch (Exception e) {
                    Log.debug("Fail to manage route {}",e"jetty:http://" + address + ":" + );
                }
            }
        } else {
            try {
                routeBuilder.from("jetty:http://127.0.0.1:" + ).
                        process(new Processor() {
                            public void process(Exchange exchangethrows Exception {
                                exchange.getOut().setBody("No result is waiting");
                                for (org.kevoree.framework.KevoreePort p : getBindedPorts()) {
                                    if (exchange.getIn().getBody() instanceof Message) {
                                        forward(p, (Messageexchange.getIn().getBody());
                                    }
                                }
                            }
                        });
            } catch (Exception e) {
                Log.debug("Fail to manage route {}",e"jetty:http://127.0.0.1:" + );
            }
        }
    }
    public List<StringgetAddresses(String remoteNodeName) {
    }
    public int parsePortNumber(String nodeName) {
        String portOption = ..getProperty(getModelElement(), "port"truenodeName);
        int port = 9000;
        if (portOption != null) {
            try {
                port = Integer.parseInt(portOption);
            } catch (NumberFormatException e) {
                Log.warn("Attribute \"port\" of {} is not an Integer, Default value ({}) is returned"getName(), port+"");
            }
        } else {
            Log.info("Attribute \"port\" of {} is not set for {}, Default value ({}) is returned"getName(), nodeNameport + "");
        }
        return port;
    }
New to GrepCode? Check out our FAQ X