package org.apacheextras.camel.examples.rcode;

import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;

import java.io.Console;
import java.io.File;
import java.util.concurrent.TimeUnit;

/**
 * @author Sebastian Rühl
 */
public class RCodeRunner {

  public static void main(String... args) throws Exception {
    CamelContext camelContext = new DefaultCamelContext();
    File basePath = args.length > 0 ? new File(args[0]) : new File(System.getProperty("user.home") + "/.rcode-example");

    camelContext.addRoutes(new RCodeRouteBuilder(basePath));

    camelContext.start();
    Console console = System.console();
    if (console != null) {
      console.printf("Please press enter to shutdown route.");
      console.readLine();
    } else {
      TimeUnit.SECONDS.sleep(5);
    }
    camelContext.stop();
  }
}

@@ -1,8 +1,620 @@
+/*%0A * Copyright 2013 Apache Software Foundation.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 package 
@@ -745,97 +745,95 @@
 xt;%0A
-%0A
 import 
-java.io.Console;%0Aimport java.io.File;%0Aimport java.util.concurrent.TimeUnit
+org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.File
 ;%0A%0A/**%0A
+ *%0A
  * @
@@ -843,22 +843,16 @@
 hor 
-Sebastian R%C3%BChl
+cemmersb
 %0A */
@@ -887,183 +887,445 @@
 %0A  p
-ublic static void main(String... args) throws Exception %7B%0A    CamelContext camelContext = new DefaultCamelContext();%0A    File basePath = args.length %3E 0 ? new File(args%5B0%5D) : 
+rivate final static Logger LOGGER = LoggerFactory.getLogger(RCodeRunner.class);%0A  private CamelContext camelContext;%0A  private RCodeRouteBuilder routeBuilder = null;%0A%0A  public RCodeRunner() %7B%0A    try %7B%0A      initializeContext();%0A    %7D catch (Exception ex) %7B%0A      LOGGER.error(%22Unable to initialize context: %7B%7D%22, ex.getMessage());%0A    %7D%0A  %7D%0A%0A  private void initializeContext() throws Exception %7B%0A    routeBuilder = new RCodeRouteBuilder(
 new 
@@ -1358,20 +1358,19 @@
 ser.
-home
+dir
 %22) + %22
-/
 .
+/
 rcod
@@ -1378,20 +1378,71 @@
 -example
-%22);%0A
+/data%22));%0A    camelContext = new DefaultCamelContext();
 %0A    cam
@@ -1461,26 +1461,17 @@
 dRoutes(
-new RCodeR
+r
 outeBuil
@@ -1477,22 +1477,11 @@
 lder
-(basePath)
 );%0A
-%0A
     
@@ -1508,235 +1508,386 @@
 ;%0A  
-  Console console = System.console();%0A    if (console != null) %7B%0A      console.printf(%22Please press e
+%7D%0A%0A  @Override%0A  protected void finalize() throws Throwable %7B%0A    camelContext.stop();%0A    super.finalize();%0A  %7D%0A%0A  public static void main(String... args) throws I
 nter
- to shutdown route.%22);%0A      console.readLine();%0A    %7D else %7B%0A      TimeUnit.SECONDS
+ruptedException, Throwable %7B%0A    LOGGER.info(%22Starting RCodeRunner.%22);%0A    RCodeRunner rCodeRunner = new RCodeRunner();%0A    Thread
 .sleep(
-5
+1000
 );%0A    
-%7D%0A    camelContext.stop
+LOGGER.info(%22Stopping RCodeRunner.%22);%0A    rCodeRunner.finalize
 ();%0A

Revert "migrate example to rcoderunner"