本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.registerShutdownHook()
方法的一些代码示例,展示了ClassPathXmlApplicationContext.registerShutdownHook()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.registerShutdownHook()
方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:registerShutdownHook
暂无
代码示例来源:origin: spring-projects/spring-security
@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();
}
}
代码示例来源:origin: gocd/gocd
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();
}
}
代码示例来源:origin: ogcs/Okra
public static void main(String[] args) {
// Spring
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/beans.xml");
context.registerShutdownHook();
}
}
代码示例来源:origin: stackoverflow.com
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:myspring-context.xml");
context.registerShutdownHook();
代码示例来源:origin: ogcs/Okra
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);
}
}
}
代码示例来源:origin: powertac/powertac-server
/** Set up the Spring context */
protected void initialize() {
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext("logtool.xml");
ctx.registerShutdownHook();
setContext(ctx);
}
代码示例来源:origin: dangdangdotcom/config-toolkit
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();
}
}
}
代码示例来源:origin: stackoverflow.com
<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");
}
}
代码示例来源:origin: org.kie/kie-spring
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();
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
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();
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: dangdangdotcom/config-toolkit
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();
}
}
}
}
代码示例来源:origin: com.alibaba/dubbo
@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();
}
代码示例来源:origin: stackoverflow.com
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SpringBeans.xml");
ClassPathXmlApplicationContext helloContext = new ClassPathXmlApplicationContext("HelloBeans.xml");
helloContext.setParent(context);
helloContext.setClassLoader(context.getClassLoader());
helloContext.refresh();
helloContext.registerShutdownHook();
代码示例来源:origin: com.alibaba/dubbo-container-spring
@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();
}
代码示例来源:origin: org.kie/kie-spring
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();
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
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();
}
代码示例来源:origin: v-ladynev/fluent-hibernate
public static void main(String[] args) {
try {
new ClassPathXmlApplicationContext("classpath:hibernate-context.xml")
.registerShutdownHook();
new SpringConsoleExample().doSomeDatabaseStuff();
} finally {
Fluent.factory().close();
}
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-demoapp
/**
* @{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();
}
内容来源于网络,如有侵权,请联系作者删除!