protected void tearDown() throws Exception { if (context != null) { log.info("Closing down the spring context"); context.destroy(); } }
@Override public void destroy() throws Exception { if (rpcService != null) { rpcService.destroy(); } if (applicationContext != null) { applicationContext.destroy(); } }
public void destroyContext(ApplicationContext applicationContext) throws Exception { if (applicationContext instanceof AbstractApplicationContext) { ((AbstractApplicationContext) applicationContext).destroy(); } }
public void disposeContext(Object handler) { //cleanup Spring fixture which was associated with this handler instance ContextWithURL springContext = springContextByCreatingHandler.remove(handler); if (springContext != null) { log.debug("Destroying spring context " + springContext + " for handler " + handler); springContext.springContext.destroy(); } }
public static void main(String[] args) throws InterruptedException { AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:content.xml"); //RabbitMQ模板 RabbitTemplate template = ctx.getBean(RabbitTemplate.class); //发送消息 template.convertAndSend("hello world"); Thread.sleep(1000);//休眠1s ctx.destroy(); } }
public void run() { AbstractApplicationContext context = new ClassPathXmlApplicationContext("five-minute-tutorial.xml"); context.start(); try { OrderClient client = (OrderClient) context.getBean("orderClient"); client.execute(); } finally { context.destroy(); synchronized (lock) { lock.notifyAll(); } } } };
@AfterClass public static void tearDown() { context.destroy(); }
@AfterClass public static void tearDown() { context.destroy(); }
} finally { if (context != null) { context.destroy();