List of usage examples for org.springframework.context.support AbstractApplicationContext start
@Override public void start()
From source file:com.platform.camel.app.SpringMain.java
public static void main(String[] args) throws Exception { AbstractApplicationContext springContext = new ClassPathXmlApplicationContext( "META-INF/spring/move-file-context.xml"); springContext.start(); Thread.sleep(100000);//w w w . j a v a 2s . c om springContext.stop(); }
From source file:com.opengamma.masterdb.batch.cmd.BatchRunner.java
public static void main(String[] args) throws Exception { // CSIGNORE if (args.length == 0) { usage();//from w w w.j a v a 2s . c o m System.exit(-1); } CommandLine line = null; try { CommandLineParser parser = new PosixParser(); line = parser.parse(getOptions(), args); initialize(line); } catch (ParseException e) { usage(); System.exit(-1); } AbstractApplicationContext appContext = null; try { appContext = getApplicationContext(); appContext.start(); ViewProcessor viewProcessor = appContext.getBean("viewProcessor", ViewProcessor.class); ViewClient viewClient = viewProcessor.createViewClient(UserPrincipal.getLocalUser()); MarketDataSpecification marketDataSpec = new FixedHistoricalMarketDataSpecification( s_observationDateTime.toLocalDate()); ViewCycleExecutionOptions cycleOptions = ViewCycleExecutionOptions.builder() .setValuationTime(s_valuationInstant).setMarketDataSpecification(marketDataSpec) .setResolverVersionCorrection(VersionCorrection.of(s_versionAsOf, s_correctedTo)).create(); ViewCycleExecutionSequence executionSequence = ArbitraryViewCycleExecutionSequence.of(cycleOptions); ExecutionOptions executionOptions = new ExecutionOptions(executionSequence, ExecutionFlags.none().awaitMarketData().get(), null, null); viewClient.attachToViewProcess(UniqueId.parse(s_viewDefinitionUid), executionOptions); } finally { if (appContext != null) { appContext.close(); } } /*if (failed) { s_logger.error("Batch failed."); System.exit(-1); } else { s_logger.info("Batch succeeded."); System.exit(0); }*/ }
From source file:com.newlandframework.avatarmq.spring.AvatarMQContainer.java
public void start() { AbstractApplicationContext context = new ClassPathXmlApplicationContext(AvatarMQConfigFilePath); springContext = new AvatarMQContext(context); context.start(); }
From source file:org.jbr.commons.container.SpringContainerManager.java
@ManagedOperation(description = "Start the SpringContainer if it is not already running.") public void startContainer() { if (log.isInfoEnabled()) { log.info("Starting SpringContainer..."); }// ww w. j av a 2s . c o m final AbstractApplicationContext ctx = (AbstractApplicationContext) context; if (!ctx.isRunning()) { ctx.start(); startTimestamp = Calendar.getInstance(); if (log.isInfoEnabled()) { log.info("SpringContainer started !!!"); } } else { if (log.isInfoEnabled()) { log.info("SpringContainer already running !!!"); } } }
From source file:org.jumpmind.symmetric.ClientSymmetricEngine.java
@Override public synchronized boolean start() { if (this.springContext instanceof AbstractApplicationContext) { AbstractApplicationContext ctx = (AbstractApplicationContext) this.springContext; try {/*ww w. j a va 2s . c o m*/ if (!ctx.isActive()) { ctx.start(); } } catch (Exception ex) { } } return super.start(); }
From source file:org.marketcetera.client.ClientImpl.java
private void connect() throws ConnectionException { if (mParameters.getURL() == null || mParameters.getURL().trim().isEmpty()) { throw new ConnectionException(Messages.CONNECT_ERROR_NO_URL); }/*from w ww.ja v a 2 s.com*/ if (mParameters.getUsername() == null || mParameters.getUsername().trim().isEmpty()) { throw new ConnectionException(Messages.CONNECT_ERROR_NO_USERNAME); } if (mParameters.getHostname() == null || mParameters.getHostname().trim().isEmpty()) { throw new ConnectionException(Messages.CONNECT_ERROR_NO_HOSTNAME); } if (mParameters.getPort() < 1 || mParameters.getPort() > 0xFFFF) { throw new ConnectionException( new I18NBoundMessage1P(Messages.CONNECT_ERROR_INVALID_PORT, mParameters.getPort())); } try { StaticApplicationContext parentCtx = new StaticApplicationContext(); SpringUtils.addStringBean(parentCtx, "brokerURL", //$NON-NLS-1$ mParameters.getURL()); SpringUtils.addStringBean(parentCtx, "runtimeUsername", mParameters.getUsername()); //$NON-NLS-1$ SpringUtils.addStringBean(parentCtx, "runtimePassword", mParameters == null //$NON-NLS-1$ ? null : String.valueOf(mParameters.getPassword())); parentCtx.refresh(); AbstractApplicationContext ctx; try { ctx = new FileSystemXmlApplicationContext( new String[] { "file:" + ApplicationBase.CONF_DIR + "client.xml" }, //$NON-NLS-1$ parentCtx); } catch (BeansException e) { ctx = new ClassPathXmlApplicationContext(new String[] { "client.xml" }, //$NON-NLS-1$ parentCtx); } ctx.registerShutdownHook(); ctx.start(); setContext(ctx); SpringConfig cfg = SpringConfig.getSingleton(); if (cfg == null) { throw new ConnectionException(Messages.CONNECT_ERROR_NO_CONFIGURATION); } mServiceClient = new org.marketcetera.util.ws.stateful.Client(mParameters.getHostname(), mParameters.getPort(), ClientVersion.APP_ID); mServiceClient.login(mParameters.getUsername(), mParameters.getPassword()); mService = mServiceClient.getService(Service.class); mJmsMgr = new JmsManager(cfg.getIncomingConnectionFactory(), cfg.getOutgoingConnectionFactory(), this); startJms(); mServerAlive = true; notifyServerStatus(true); mHeart = new Heart(); mHeart.start(); ClientIDFactory idFactory = new ClientIDFactory(mParameters.getIDPrefix(), this); idFactory.init(); Factory.getInstance().setOrderIDFactory(idFactory); } catch (Throwable t) { internalClose(); ExceptUtils.interrupt(t); if (t.getCause() instanceof RemoteProxyException) { RemoteProxyException ex = (RemoteProxyException) t.getCause(); if (IncompatibleComponentsException.class.getName().equals(ex.getServerName())) { throw new ConnectionException(t, new I18NBoundMessage1P(Messages.ERROR_CONNECT_INCOMPATIBLE_DEDUCED, ex.getMessage())); } } else if (t.getCause() instanceof IncompatibleComponentsException) { IncompatibleComponentsException ex = (IncompatibleComponentsException) t.getCause(); throw new ConnectionException(t, new I18NBoundMessage2P(Messages.ERROR_CONNECT_INCOMPATIBLE_DIRECT, ClientVersion.APP_ID, ex.getServerVersion())); } throw new ConnectionException(t, new I18NBoundMessage4P(Messages.ERROR_CONNECT_TO_SERVER, mParameters.getURL(), mParameters.getUsername(), mParameters.getHostname(), mParameters.getPort())); } mLastConnectTime = new Date(); }