@Test public void javadocExample() { String resName = "/" + getClass().getName().replace('.', '/') + ".xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( resName); context.registerShutdownHook(); try { provider = context.getBean(DefaultJaasAuthenticationProvider.class); Authentication auth = provider.authenticate(token); assertThat(auth.isAuthenticated()).isEqualTo(true); assertThat(auth.getPrincipal()).isEqualTo(token.getPrincipal()); } finally { context.close(); } }
public static void main(String... argv) { assertVMVersion(); AgentBootstrapperArgs args = new AgentCLI().parse(argv); LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOGBACK_CONFIGURATION_FILE); logConfigurator.initialize(); new SystemEnvironment().setProperty("go.process.type", "agent"); new SystemEnvironment().setProperty(SystemEnvironment.SERVICE_URL, args.getServerUrl().toString()); new SystemEnvironment().setProperty(SystemEnvironment.AGENT_SSL_VERIFICATION_MODE, args.getSslMode().toString()); if (args.getRootCertFile() != null) { new SystemEnvironment().setProperty(SystemEnvironment.AGENT_ROOT_CERT_FILE, args.getRootCertFile().toString()); } ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); ctx.registerShutdownHook(); } }
public static void main(String[] args) { // Spring ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/beans.xml"); context.registerShutdownHook(); } }
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:myspring-context.xml"); context.registerShutdownHook();
public static void main(String[] args) { LOG.info("PreBootstrap server."); ClassPathXmlApplicationContext context = null; try { context = new ClassPathXmlApplicationContext("classpath:spring/beans.xml"); context.registerShutdownHook(); LOG.info("Server bootstrap successful."); } catch (Exception e) { if (context != null) context.close(); LOG.error("Server bootstrap failure.", e); } } }
/** Set up the Spring context */ protected void initialize() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("logtool.xml"); ctx.registerShutdownHook(); setContext(ctx); }
public static void main(String[] args) { ClassPathXmlApplicationContext context = null; try { context = new ClassPathXmlApplicationContext("classpath:config-toolkit-placeholder-support.xml"); context.registerShutdownHook(); context.start(); ExampleBean bean = context.getBean(ExampleBean.class); System.out.println(bean); } finally { if (context != null) { context.close(); } } }
<int:channel id="quakeinfotrigger.channel" /> <int:gateway id="sender" service-interface="com.foo.bar.Sender" default-request-channel="quakeinfotrigger.channel" /> <int-ip:udp-outbound-channel-adapter id="metoo" channel="quakeinfotrigger.channel" port="11111" host="localhost"/> public interface Sender { public void sendMessage(String message); } public class Main { public static void main(String[] args) { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/new_tutorial.xml"); applicationContext.registerShutdownHook(); Sender sender = (Sender) context.getBean("sender"); sender.sendMessage("123"); } }
public static KieModuleModel fromXML(File kModuleFile, ReleaseId releaseId){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(kModuleFile.getAbsolutePath()); context.setConfigLocation(kModuleFile.getAbsolutePath()); context.refresh(); context.registerShutdownHook(); return null;//kieSpringApplicationListener.getKieModuleModel(); }
public static KieModuleModel fromXML(File kModuleFile, ReleaseId releaseId){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(kModuleFile.getAbsolutePath()); context.setConfigLocation(kModuleFile.getAbsolutePath()); context.refresh(); context.registerShutdownHook(); return null;//kieSpringApplicationListener.getKieModuleModel(); }
public static void main(String[] args) throws JMSException, InterruptedException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("my- context.xml"); context.registerShutdownHook(); App app = context.getBean("app", App.class); app.start(); context.stop(); }
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("my-context.xml"); context.registerShutdownHook(); App app = context.getBean("app", App.class); app.start(); context.close(); }
public static void main(String[] args) { ClassPathXmlApplicationContext context = null; try { context = new ClassPathXmlApplicationContext("classpath:config-toolkit-simple.xml"); context.registerShutdownHook(); context.start(); ExampleBeanWithConfigNode bean = context.getBean(ExampleBeanWithConfigNode.class); while (true) { bean.someMethod(); try { Thread.sleep(1000); } catch (InterruptedException e) { // } } } finally { if (context != null) { context.close(); } } } }
@Override public void start() { String configPath = ConfigUtils.getProperty(SPRING_CONFIG); if (configPath == null || configPath.length() == 0) { configPath = DEFAULT_SPRING_CONFIG; } context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"), false); context.addApplicationListener(new DubboApplicationListener()); context.registerShutdownHook(); context.refresh(); context.start(); }
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SpringBeans.xml"); ClassPathXmlApplicationContext helloContext = new ClassPathXmlApplicationContext("HelloBeans.xml"); helloContext.setParent(context); helloContext.setClassLoader(context.getClassLoader()); helloContext.refresh(); helloContext.registerShutdownHook();
@Override public void start() { String configPath = ConfigUtils.getProperty(SPRING_CONFIG); if (configPath == null || configPath.length() == 0) { configPath = DEFAULT_SPRING_CONFIG; } context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"), false); context.addApplicationListener(new DubboApplicationListener()); context.registerShutdownHook(); context.refresh(); context.start(); }
public static KieModuleModel fromXML(java.net.URL kModuleUrl, ReleaseId releaseId){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); KModuleBeanFactoryPostProcessor beanFactoryPostProcessor = new KModuleBeanFactoryPostProcessor(kModuleUrl, context); beanFactoryPostProcessor.setReleaseId(releaseId); context.addBeanFactoryPostProcessor(beanFactoryPostProcessor); context.setConfigLocation(kModuleUrl.toExternalForm()); context.refresh(); context.registerShutdownHook(); return null;//kieSpringApplicationListener.getKieModuleModel(); }
public static KieModuleModel fromXML(java.net.URL kModuleUrl, ReleaseId releaseId){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); KModuleBeanFactoryPostProcessor beanFactoryPostProcessor = new KModuleBeanFactoryPostProcessor(kModuleUrl, context); beanFactoryPostProcessor.setReleaseId(releaseId); context.addBeanFactoryPostProcessor(beanFactoryPostProcessor); context.setConfigLocation(kModuleUrl.toExternalForm()); context.refresh(); context.registerShutdownHook(); return null;//kieSpringApplicationListener.getKieModuleModel(); }
public static void main(String[] args) { try { new ClassPathXmlApplicationContext("classpath:hibernate-context.xml") .registerShutdownHook(); new SpringConsoleExample().doSomeDatabaseStuff(); } finally { Fluent.factory().close(); } }
/** * @{inheritedDoc} */ @Override public void initApplication() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); //context.getEnvironment().setActiveProfiles("dev","mobile","h2"); context.setConfigLocation(getRootContextPath()); context.refresh(); context.registerShutdownHook(); this.viewStructure = (ViewStructure) Services.getBean("platformViewStructure"); this.viewStructure.buildStructure(); }