Java 类org.apache.camel.main.Main 实例源码

项目:microservice-mock    文件:RouteTestSupport.java   
@BeforeClass
public void findAvailablePortNumber() throws Exception {
    LOGGER.info("BeforeClass called (from: {})", getClass());
    this.availablePort = String.valueOf(AvailablePortFinder.getNextAvailable(10000));
    LOGGER.info("Found port: {}", this.availablePort);
    this.main = new Main();
    MockRegistry.registerPropertiesInRegistry(this.main);
    MockRegistry.registerBeansInRegistryBeforeStart();
    Properties properties = MockRegistry.findProperties();
    properties.put("port", this.availablePort);
    this.main.addMainListener(new MockMainListener());
    this.main.addRouteBuilder(new MockRoute());
    this.main.start();
    LOGGER.info("Main started: {}", this.main.isStarted());
    MockRegistry.registerBeansInRegistryAfterStart();
    this.producerTemplate = this.main.getCamelTemplate();
}
项目:Camel    文件:IntegrationTest.java   
@Before
public void setUp() throws Exception {
    this.host = System.getProperty("pgjdbc.test.server", "localhost");
    this.port = System.getProperty("pgjdbc.test.port", "5432");
    this.database = System.getProperty("pgjdbc.test.db", "event_tests");
    this.user = System.getProperty("pgjdbc.test.user", "dphillips");
    this.password = System.getProperty("pgjdbc.test.password");

    ds = new PGDataSource();
    ds.setHost(this.host);
    ds.setPort(Integer.parseInt(this.port));
    ds.setDatabase(this.database);
    ds.setUser(this.user);
    if (this.password != null) {
        ds.setPassword(this.password);
    }

    main = new Main();
    main.bind("test", ds);
    main.addRouteBuilder(buildConsumer());
    main.addRouteBuilder(buildProducer());
}
项目:Camel    文件:CamelSpringBootApplicationController.java   
public CamelSpringBootApplicationController(final ApplicationContext applicationContext, final CamelContext camelContext) {
    this.main = new Main() {
        @Override
        protected ProducerTemplate findOrCreateCamelTemplate() {
            return applicationContext.getBean(ProducerTemplate.class);
        }

        @Override
        protected Map<String, CamelContext> getCamelContextMap() {
            return Collections.singletonMap("camelContext", camelContext);
        }

        @Override
        protected void doStop() throws Exception {
            LOG.debug("Controller is shutting down CamelContext");
            try {
                super.doStop();
            } finally {
                latch.countDown();
            }
        }
    };
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot(String[] args) throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    main = new Main();
    main.bind("hz", hz);

    if (args.length == 0) {
        // route which uses get/put operations
        main.addRouteBuilder(new CounterRoute("Foo", 8080));
    } else {
        // route which uses atomic counter
        main.addRouteBuilder(new AtomicCounterRoute("Foo", 8080));
    }
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot(String[] args) throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    main = new Main();
    main.bind("hz", hz);

    if (args.length == 0) {
        // route which uses get/put operations
        main.addRouteBuilder(new CounterRoute("Bar", 9090));
    } else {
        // route which uses atomic counter
        main.addRouteBuilder(new AtomicCounterRoute("Bar", 9090));
    }
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    main = new Main();

    // create jcache component and configure it
    JCacheComponent jcache = new JCacheComponent();
    // use infinispan
    jcache.setCachingProvider(JCachingProvider.class.getName());
    // load infinispan client (hotrod) configuration from the classpath
    jcache.setConfigurationUri("hotrod-client.properties");

    // register the component to Camel with the name jcache
    main.bind("jcache", jcache);

    main.addRouteBuilder(new CounterRoute("Foo", 8888));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    main = new Main();

    // create jcache component and configure it
    JCacheComponent jcache = new JCacheComponent();
    // use infinispan
    jcache.setCachingProvider(JCachingProvider.class.getName());
    // load infinispan client (hotrod) configuration from the classpath
    jcache.setConfigurationUri("hotrod-client.properties");

    // register the component to Camel with the name jcache
    main.bind("jcache", jcache);

    // route which uses get/put operations
    main.addRouteBuilder(new CounterRoute("Bar", 8889));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    // setup the hazelcast route policy
    HazelcastRoutePolicy routePolicy = new HazelcastRoutePolicy(hz);
    // the lock names must be same in the foo and bar server
    routePolicy.setLockMapName("myLock");
    routePolicy.setLockKey("myLockKey");
    routePolicy.setLockValue("myLockValue");
    // attempt to grab lock every 5th second
    routePolicy.setTryLockTimeout(5, TimeUnit.SECONDS);

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Foo", 100));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    // setup the hazelcast route policy
    HazelcastRoutePolicy routePolicy = new HazelcastRoutePolicy(hz);
    // the lock names must be same in the foo and bar server
    routePolicy.setLockMapName("myLock");
    routePolicy.setLockKey("myLockKey");
    routePolicy.setLockValue("myLockValue");
    // attempt to grab lock every 5th second
    routePolicy.setTryLockTimeout(5, TimeUnit.SECONDS);

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Bar", 100));
    main.run();
}
项目:myeslib    文件:JdbiExample.java   
@Inject
JdbiExample(ReceiveCommandsAsJsonRoute receiveCommandsRoute,
            JdbiConsumeCommandsRoute consumeCommandsRoute, 
            JdbiConsumeEventsRoute consumeEventsRoute) throws Exception  {

    main = new Main() ;
    main.enableHangupSupport();
    registry = new SimpleRegistry();
    context = new DefaultCamelContext(registry);

    context.addRoutes(receiveCommandsRoute);
    context.addRoutes(consumeCommandsRoute);
    context.addRoutes(consumeEventsRoute);

    main.getCamelContexts().clear();
    main.getCamelContexts().add(context);
    main.setDuration(-1);
    main.start();


}
项目:myeslib    文件:CmdProducer.java   
@Inject
CmdProducer(CommandsDataSetsRoute datasetRoute) throws Exception  {

    main = new Main() ;
    main.enableHangupSupport();
    registry = new SimpleRegistry();
    context = new DefaultCamelContext(registry);

    populate();

    registry.put("createCommandDataset", new CreateCommandDataSet(ids, dataSetSize));
    registry.put("increaseCommandDataset", new IncreaseCommandDataSet(ids, dataSetSize));
    registry.put("decreaseCommandDataset", new DecreaseCommandDataSet(ids, dataSetSize));

    context.addRoutes(datasetRoute);

    main.getCamelContexts().clear();
    main.getCamelContexts().add(context);
    main.setDuration(-1);
    main.start();

}
项目:OracleToElasticSearch    文件:Standalone.java   
private void boot() throws Exception{
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-context.xml");
    CamelContext  camelContext = SpringCamelContext.springCamelContext(applicationContext, false);
    main = new Main();
    main.enableHangupSupport();

    camelContext.start();
    main.getOrCreateCamelContext();
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    // setup the hazelcast route policy
    ConsulRoutePolicy routePolicy = new ConsulRoutePolicy();
    // the service names must be same in the foo and bar server
    routePolicy.setServiceName("myLock");
    routePolicy.setTtl(5);

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Foo", 100));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    // setup the hazelcast route policy
    ConsulRoutePolicy routePolicy = new ConsulRoutePolicy();
    // the service names must be same in the foo and bar server
    routePolicy.setServiceName("myLock");
    routePolicy.setTtl(5);

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Bar", 100));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    Properties props = new Properties();
    // list of urls for the infinispan server
    // as we run in domain node we have two servers out of the box, and can therefore include both
    // that the client can load balance/failover to be highly available
    props.setProperty("infinispan.client.hotrod.server_list", "localhost:11222;localhost:11372");
    // by default, previously existing values for java.util.Map operations
    // are not returned for remote caches but they are required for the route
    // policy to work.
    props.setProperty("infinispan.client.hotrod.force_return_values", "true");

    // create remote infinispan cache manager and start it
    RemoteCacheManager remote = new RemoteCacheManager(
        new ConfigurationBuilder().withProperties(props).build(),
        true
    );

    // setup Camel infinispan configuration to use the remote cache manager
    InfinispanConfiguration ic = new InfinispanConfiguration();
    ic.setCacheContainer(remote);

    // setup the hazelcast route policy
    InfinispanRoutePolicy routePolicy = new InfinispanRoutePolicy(ic);
    // the lock names must be same in the foo and bar server
    routePolicy.setLockMapName("myLock");
    routePolicy.setLockKey("myLockKey");
    // the lock value identifies the node
    routePolicy.setLockValue("foo");

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Foo", 100));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    Properties props = new Properties();
    // list of urls for the infinispan server
    // as we run in domain node we have two servers out of the box, and can therefore include both
    // that the client can load balance/failover to be highly available
    props.setProperty("infinispan.client.hotrod.server_list", "localhost:11222;localhost:11372");
    // by default, previously existing values for java.util.Map operations
    // are not returned for remote caches but they are required for the route
    // policy to work.
    props.setProperty("infinispan.client.hotrod.force_return_values", "true");

    // create remote infinispan cache manager and start it
    RemoteCacheManager remote = new RemoteCacheManager(
        new ConfigurationBuilder().withProperties(props).build(),
        true
    );

    // setup Camel infinispan configuration to use the remote cache manager
    InfinispanConfiguration ic = new InfinispanConfiguration();
    ic.setCacheContainer(remote);

    // setup the hazelcast route policy
    InfinispanRoutePolicy routePolicy = new InfinispanRoutePolicy(ic);
    // the lock names must be same in the foo and bar server
    routePolicy.setLockMapName("myLock");
    routePolicy.setLockKey("myLockKey");
    // the lock value identifies the node
    routePolicy.setLockValue("bar");

    main = new Main();
    // bind the hazelcast route policy to the name myPolicy which we refer to from the route
    main.bind("myPolicy", routePolicy);
    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Bar", 100));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    main = new Main();

    // setup quartz component
    QuartzComponent quartz = new QuartzComponent();
    quartz.setPropertiesFile("quartz.properties");

    // add the component to Camel
    main.bind("quartz2", quartz);

    main.addRouteBuilder(new QuartzRoute("Foo"));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    main = new Main();

    // setup quartz component
    QuartzComponent quartz = new QuartzComponent();
    quartz.setPropertiesFile("quartz.properties");

    // add the component to Camel
    main.bind("quartz2", quartz);

    // route which uses get/put operations
    main.addRouteBuilder(new QuartzRoute("Bar"));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    main = new Main();

    // the default zookeeper url is localhost:2181
    MasterRoutePolicy master = new MasterRoutePolicy();
    master.setZooKeeperUrl("localhost:2181");
    master.setGroupName("myGroup");
    main.bind("zookeeper-master-policy", master);

    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Foo", 200));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    main = new Main();

    // the default zookeeper url is localhost:2181
    MasterRoutePolicy master = new MasterRoutePolicy();
    master.setZooKeeperUrl("localhost:2181");
    master.setGroupName("myGroup");
    main.bind("zookeeper-master-policy", master);

    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Bar", 200));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    main = new Main();

    // the default zookeeper url is localhost:2181
    MasterComponent master = new MasterComponent();
    master.setZooKeeperUrl("localhost:2181");
    main.bind("zookeeper-master", master);

    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Foo", 200));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    main = new Main();

    // the default zookeeper url is localhost:2181
    MasterComponent master = new MasterComponent();
    master.setZooKeeperUrl("localhost:2181");
    main.bind("zookeeper-master", master);

    // add the route and and let the route be named Bar and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("Bar", 200));
    main.run();
}
项目:camelinaction2    文件:ServerFoo.java   
public void boot() throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    // setup the hazelcast idempotent repository which we will use in the route
    HazelcastIdempotentRepository repo = new HazelcastIdempotentRepository(hz, "camel");

    main = new Main();
    // bind the hazelcast repository to the name myRepo which we refer to from the route
    main.bind("myRepo", repo);
    // add the route and and let the route be named BAR and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("FOO", 100));
    main.run();
}
项目:camelinaction2    文件:ServerBar.java   
public void boot() throws Exception {
    // create and embed the hazelcast server
    // (you can use the hazelcast client if you want to connect to external hazelcast server)
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();

    // setup the hazelcast idempotent repository which we will use in the route
    HazelcastIdempotentRepository repo = new HazelcastIdempotentRepository(hz, "camel");

    main = new Main();
    // bind the hazelcast repository to the name myRepo which we refer to from the route
    main.bind("myRepo", repo);
    // add the route and and let the route be named BAR and use a little delay when processing the files
    main.addRouteBuilder(new FileConsumerRoute("BAR", 100));
    main.run();
}
项目:first-camel-microservice    文件:RunTimeService.java   
public void boot(String port) throws Exception {
  System.setProperty("port", port);

  // create a Main instance
  main = new Main();
  // enable hangup support so you can press ctrl + c to terminate the JVM
  main.enableHangupSupport();
  // add routes
  main.addRouteBuilder(new TimeServiceRouteBuilder());

  // run until you terminate the JVM
  System.out.println(String.format("Starting Camel, using port %s. Use ctrl + c to terminate the JVM.", port));
  main.run();
}
项目:first-camel-microservice    文件:RunDateService.java   
public void boot(String port) throws Exception {
  System.setProperty("port", port);

  // create a Main instance
  main = new Main();
  // enable hangup support so you can press ctrl + c to terminate the JVM
  main.enableHangupSupport();
  // add routes
  main.addRouteBuilder(new DateServiceRouteBuilder());

  // run until you terminate the JVM
  System.out.println(String.format("Starting Camel, using port %s. Use ctrl + c to terminate the JVM.", port));
  main.run();
}
项目:myeslib    文件:HzExample.java   
@Inject
HzExample(final HazelcastInstance hazelcastInstance,
             ReceiveCommandsAsJsonRoute receiveCommandsRoute,
          HzConsumeCommandsRoute consumeCommandsRoute,
          HzConsumeEventsRoute consumeEventsRoute
        ) throws Exception  {

    this.main = new Main() ;
    this.main.enableHangupSupport();
    this.registry = new SimpleRegistry();
    this.context = new DefaultCamelContext(registry);

    context.addRoutes(receiveCommandsRoute);
    context.addRoutes(consumeCommandsRoute);
    context.addRoutes(consumeEventsRoute);

    main.getCamelContexts().clear();
    main.getCamelContexts().add(context);
    main.setDuration(-1);

/*       Runtime.getRuntime().addShutdownHook(new Thread() {
           public void run() {
               log.warn("stopping Camel...");
               try {
                   context.stop();
               } catch (Exception e) {
                   log.error(e.getMessage());
               } finally {
                   log.warn("stopping Hazelcast...");
                   hazelcastInstance.shutdown();
               }
           }
       });*/

       main.start();

       log.info("started...");

}
项目:microservice-mock    文件:RouteTestSupport.java   
public Main getMain() {
    return this.main;
}
项目:camel-test-framework-demo    文件:MainApp.java   
private static void startWithCamelMainWrapper(String[] args) throws Exception {
    Main main = new Main();
    main.enableHangupSupport();
    main.addRouteBuilder(new MyRouteBuilder());
    main.run(args);
}
项目:camel-cookbook-examples    文件:Application.java   
public void boot() throws Exception {
    this.main = new Main();
    this.main.addRouteBuilder(new CamelRoutes());
    main.run();
}
项目:IDEAConfigSync    文件:LocalMoveTest.java   
@Test
public  void moveFileTest() throws Exception {

    Main main = new Main();
    main.addRouteBuilder(new MoreRouterBuilders.SyncIDEAConfig());
    main.enableHangupSupport();
    main.run();







}
项目:microservice-mock    文件:MockRegistry.java   
/**
 * Custom constructor with a reference of the main which is used to store the properties.
 *
 * @param mainReference
 *  A reference of the Main object.
 */
public static void registerPropertiesInRegistry(Main mainReference) {
    main = mainReference;
    main.bind(BEAN_META_DATA_PROPERTIES, PropertiesManager.extractMetaData());
    main.bind(BEAN_PROPERTIES, PropertiesManager.extractProperties());
}