public static void main( String[] args ) throws Exception {

    // TODO add -t [annotated|programatic] option

    ApplicationContext ac = new ClassPathXmlApplicationContext("/appContext.xml");
    // load the graphite endpoint to fire at 1 min intervals if we are configured for such
    // the reporter hooks are a bit rough for IoC/CDI. A factory approach would be a little nicer
    final GraphiteReporter graphiteReporter;
    try {
      graphiteReporter = ac.getBean("graphiteReporter", GraphiteReporter.class);

      graphiteReporter.start(1, TimeUnit.MINUTES);
    } catch (NoSuchBeanDefinitionException nsbde) {
      logger.info("graphiteReporter config not found... use JMX to see output");
    }

    // The annotated version must come via CDI (a.k.a "IoC container")
    final InstrumentedBean atb = ac.getBean("annotatedTimedBean", InstrumentedBean.class);

    ExecutorService exec = Executors.newFixedThreadPool(1);

    final Random r = new Random();
    exec.submit(new Callable<Object>() {
      @Override
      public Object call() throws Exception {
        while ( true ) {
          try {
            int i = r.nextInt(100);
            atb.calculateSomething(i);
            TimeUnit.MILLISECONDS.sleep(1 + i);
          } catch (Exception ex) {
            // meh
          }
        }
      }
    });

    // may add something fancy like getOpt for param changing

  }