Skip to main content

Posts

Showing posts from July, 2013

Simplest iterative algorithm Post order traversal

package com.test; import java.util.Stack; public class PostOrderTraversal { static class Node { int data ; Node left , right ; Node( int item ) { data = item ; left = right ; } } private void pfIterate(Node root ) { Node prev = null ; Stack stack = new Stack<>(); stack .push( root ); while (! stack .isEmpty()) { root = stack .pop(); if ( root . left == null && root . right == null ) { System. out .print( root . data + " " ); prev = root ; } else if ( prev == root . left || prev == root . right ) { System. out .print( root . data + " " ); prev = root ; } else { stack .push( root ); if ( root . right != null ) stack .push( root . right ); if ( root . left != null ) stack .push( root . left ); } } } public static void main(String[] args ) { // Let u...

How to inject multiple endpoint in SEI using Camel's @EndpointInject

By default you can inject annotation on single method of an interface like: public interface MyListener {   @EndpointInject(uri="activemq:foo.bar")     String sayHello(String name); } what if you need multiple methods like this with @EndpointInjection happening over them for each endpoint e.g.: public interface MyListener {   @EndpointInject(uri="direct:foo")     String sayHelloFoo(String name); @EndpointInject(uri="direct:bar")     String sayHelloBar(String name); } The simple solution i have working involved spring's FactoryBean implementation. It need following steps: <!-- Define route for which you need injection to happen --> <bean id="r" class="MyListener" /> <!-- Define producer template having that route  -->   <camelContext  xmlns="http://camel.apache.org/schema/spring">         <template id="producerTemp...