package com.here;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.beans.factory.InitializingBean;

public class StartupBean implements InitializingBean {
	
	@Override
	public void afterPropertiesSet() {	
		/**
		 * Launch Hosebird service in a thread because
		 * 1) It runs continuously
		 * 2) If we didn't do it in a thread it would block the rest of the web server startup
		 */
		ExecutorService executor = Executors.newFixedThreadPool(1);
		HosebirdThread t= new HosebirdThread();
		executor.execute(t);
	}
}

class HosebirdThread implements Runnable {

	@Override
	public void run() {
		try {

			String consumerKey = "R2srtfc5kEIxuQfiyG9pEA";
			String consumerSecret = "0id5kQT8ZSkQuNRBDhIlKOrE3sKvPDGAfmgIVVZPI";
			String accessToken = "312942836-izeK4pfEQGOt48ySWyKYRQJBdgz716cFFcDqh1eg";
			String accessTokenSecret = "d99NY9IjkygnrPtAqafn77aDyqp0PAhztSaXhqyJE40fp";

			System.out.println("Starting Hosebird Service . . . . .");
			HosebirdService.oauth(consumerKey, consumerSecret, accessToken,
					accessTokenSecret);
		} catch (InterruptedException e) {
			System.err.println(e);
		}
		
	}
	
}

@@ -95,16 +95,52 @@
 ecutors;
+%0Aimport javax.annotation.PreDestroy;
 %0A%0Aimport
@@ -248,16 +248,51 @@
 gBean %7B%0A
+%09private ExecutorService executor;%0A
 %09%0A%09@Over
@@ -514,32 +514,21 @@
 %09%09 */%0A%09%09
-ExecutorService 
+this.
 executor
@@ -631,16 +631,93 @@
 (t);%0A%09%7D%0A
+%09%0A%09@PreDestroy%0A%09public void atShutdown() %7B%0A%09%09this.executor.shutdownNow();%0A%09%7D%0A
 %7D%0A%0Aclass

Fix for thread on destroy