package io.trygvis; import io.trygvis.queue.*; import org.hibernate.dialect.*; import org.slf4j.*; import org.slf4j.bridge.*; import org.springframework.beans.factory.annotation.*; import org.springframework.context.support.*; import org.springframework.stereotype.*; import org.springframework.transaction.annotation.*; import static java.lang.System.*; @Component @Transactional public class Main { private static final Logger log = LoggerFactory.getLogger(Main.class); public static void main(String[] args) throws Exception { SLF4JBridgeHandler.install(); String username = getProperty("user.name"); setProperty("database.url", getProperty("jdbc.url", "jdbc:postgresql://localhost/" + username)); setProperty("database.username", username); setProperty("database.password", username); setProperty("hibernate.showSql", "true"); setProperty("hibernate.hbm2ddl.auto", "create"); // create setProperty("hibernate.dialect", PostgreSQL82Dialect.class.getName()); log.info("Starting context"); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); context.start(); log.info("Started context"); try { context.getBean(Main.class).run(); log.info("Sleeping"); Thread.sleep(1000 * 1000); } catch (Exception e) { e.printStackTrace(System.out); } log.info("Stopping context"); context.stop(); log.info("Stopped context"); exit(0); } @Autowired private AsyncService asyncService; public void run() throws Exception { log.info("Main.run"); asyncService.registerQueue("test-queue", 1, MyJob.class); AsyncService.QueueRef queue = asyncService.getQueue("test-queue"); AsyncService.ExecutionRef executionRef = asyncService.schedule(queue); } }