List of usage examples for org.springframework.context.support AbstractXmlApplicationContext wait
public final native void wait(long timeoutMillis) throws InterruptedException;
From source file:com.turbospaces.api.EmbeddedJSpaceRunner.java
/** * launcher method//from w w w. j a v a 2s .c o m * * @param args * [1 argument = application context path] * @throws Exception * re-throw execution errors if any */ public static void main(final String... args) throws Exception { JVMUtil.gcOnExit(); String appContextPath = args[0]; if (System.getProperty(Global.IPv4) == null && System.getProperty(Global.IPv6) == null) System.setProperty(Global.IPv4, Boolean.TRUE.toString()); System.setProperty(Global.CUSTOM_LOG_FACTORY, JGroupsCustomLoggerFactory.class.getName()); LOGGER.info("Welcome to turbospaces:version = {}, build date = {}", SpaceUtility.projectVersion(), SpaceUtility.projecBuildTimestamp()); LOGGER.info("{}: launching configuration {}", EmbeddedJSpaceRunner.class.getSimpleName(), appContextPath); AbstractXmlApplicationContext c = appContextPath.startsWith("file") ? new FileSystemXmlApplicationContext(appContextPath) : new ClassPathXmlApplicationContext(appContextPath); c.getBeansOfType(JSpace.class); c.registerShutdownHook(); Collection<SpaceConfiguration> configurations = c.getBeansOfType(SpaceConfiguration.class).values(); for (SpaceConfiguration spaceConfiguration : configurations) spaceConfiguration.joinNetwork(); LOGGER.info("all jspaces joined network, notifying waiting threads..."); synchronized (joinNetworkMonitor) { joinNetworkMonitor.notifyAll(); } while (!Thread.currentThread().isInterrupted()) synchronized (c) { try { c.wait(TimeUnit.SECONDS.toMillis(1)); } catch (InterruptedException e) { LOGGER.info("got interruption signal, terminating jspaces... stack_trace = {}", Throwables.getStackTraceAsString(e)); Thread.currentThread().interrupt(); Util.printThreads(); } } c.destroy(); }