本文整理匯總了Java中org.springframework.context.support.ClassPathXmlApplicationContext.start方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassPathXmlApplicationContext.start方法的具體用法?Java ClassPathXmlApplicationContext.start怎麽用?Java ClassPathXmlApplicationContext.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.ClassPathXmlApplicationContext
的用法示例。
在下文中一共展示了ClassPathXmlApplicationContext.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testProviderNestedService
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void testProviderNestedService() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-nested-service.xml");
ctx.start();
try {
ServiceConfig<DemoService> serviceConfig = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig");
assertNotNull(serviceConfig.getProvider());
assertEquals(2000, serviceConfig.getProvider().getTimeout().intValue());
ServiceConfig<DemoService> serviceConfig2 = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig2");
assertNotNull(serviceConfig2.getProvider());
assertEquals(1000, serviceConfig2.getProvider().getTimeout().intValue());
} finally {
ctx.stop();
ctx.close();
}
}
示例2: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
String config = VersionConsumer.class.getPackage().getName().replace('.', '/') + "/version-consumer.xml";
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
context.start();
VersionService versionService = (VersionService) context.getBean("versionService");
for (int i = 0; i < 10000; i ++) {
String hello = versionService.sayHello("world");
System.out.println(hello);
Thread.sleep(2000);
}
System.in.read();
}
示例3: testSystemPropertyOverrideXmlDefault
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testSystemPropertyOverrideXmlDefault() throws Exception {
System.setProperty("dubbo.application.name", "sysover");
System.setProperty("dubbo.application.owner", "sysowner");
System.setProperty("dubbo.registry.address", "N/A");
System.setProperty("dubbo.protocol.name", "dubbo");
System.setProperty("dubbo.protocol.port", "20819");
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/system-properties-override-default.xml");
providerContext.start();
try {
ServiceConfig<DemoService> service = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
assertEquals("sysover", service.getApplication().getName());
assertEquals("sysowner", service.getApplication().getOwner());
assertEquals("N/A", service.getRegistry().getAddress());
assertEquals("dubbo", service.getProtocol().getName());
assertEquals(20819, service.getProtocol().getPort().intValue());
} finally {
System.setProperty("dubbo.application.name", "");
System.setProperty("dubbo.application.owner", "");
System.setProperty("dubbo.registry.address", "");
System.setProperty("dubbo.protocol.name", "");
System.setProperty("dubbo.protocol.port", "");
providerContext.stop();
providerContext.close();
}
}
示例4: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
String config = MergeConsumer.class.getPackage().getName().replace('.', '/') + "/merge-consumer.xml";
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
context.start();
MergeService mergeService = (MergeService)context.getBean("mergeService");
for (int i = 0; i < Integer.MAX_VALUE; i ++) {
try {
List<String> result = mergeService.mergeResult();
System.out.println("(" + i + ") " + result);
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例5: testMultiProtocol
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testMultiProtocol() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");
ctx.start();
try {
DemoService demoService = refer("dubbo://127.0.0.1:20881");
String hello = demoService.sayName("hello");
assertEquals("say:hello", hello);
} finally {
ctx.stop();
ctx.close();
}
}
示例6: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("dubbo-demo-consumer.xml");
context.start();
Demo.Iface demo = (Demo.Iface) context.getBean("demoService");
System.out.println(demo.echoI32(32));
for (int i = 0; i < 10; i++) {
System.out.println(demo.echoI32(i + 1));
}
context.close();
}
示例7: testMultiProtocolError
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testMultiProtocolError() {
try {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-error.xml");
ctx.start();
ctx.stop();
ctx.close();
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("Found multi-protocols"));
}
}
示例8: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("ProviderSample.xml");
ctx.start();
synchronized (RpcBenchmarkServer.class) {
try {
RpcBenchmarkServer.class.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例9: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String... args) throws IOException {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext(
new String[] {"applicationContext.xml"});
context.start();
System.in.read(); // 按任意鍵退出
}
示例10: main
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String arg[]){
//加載spring配置
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"classpath:spring-scheduler-context.xml"});
context.start();
System.out.println("=================================");
System.out.println("[SCHEDULER服務]啟動完成!!!");
System.out.println("=================================");
}
示例11: upload
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
public static void upload(){
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-storage-fdfs.xml");
applicationContext.start();
FDFSAttachmentService fdfsAttachmentService = applicationContext.getBean(FDFSAttachmentService.class);
//String url=fdfsAttachmentService.upload(new File("C:\\unintall.log"));
//String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\header.jpg"));
//String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\ERWin 7.3.zip"));
//String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\8月4日應用答疑(上)_知識講解.avi"));
String url = fdfsAttachmentService.uploadWithUrl(new File("D:\\logs\\error.log"));
System.out.println(url);
applicationContext.stop();
}
示例12: test_noMethodInterface_methodsKeyHasValue
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void test_noMethodInterface_methodsKeyHasValue() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-no-methods-interface.xml");
ctx.start();
try {
ServiceBean bean = (ServiceBean) ctx.getBean("service");
List<URL> urls = bean.getExportedUrls();
assertEquals(1, urls.size());
URL url = urls.get(0);
assertEquals("sayName,getBox", url.getParameter("methods"));
} finally {
ctx.stop();
ctx.close();
}
}
示例13: test_RpcContext_getUrls
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void test_RpcContext_getUrls() throws Exception {
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(
ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-long-waiting.xml");
providerContext.start();
try {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
ConfigTest.class.getPackage().getName().replace('.', '/')
+ "/init-reference-getUrls.xml");
ctx.start();
try {
DemoService demoService = (DemoService) ctx.getBean("demoService");
try {
demoService.sayName("Haha");
fail();
} catch (RpcException expected) {
assertThat(expected.getMessage(), containsString("Tried 3 times"));
}
assertEquals(3, RpcContext.getContext().getUrls().size());
} finally {
ctx.stop();
ctx.close();
}
} finally {
providerContext.stop();
providerContext.close();
}
}
示例14: testCustomizeParameter
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void testCustomizeParameter() throws Exception {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/customize-parameter.xml");
context.start();
ServiceBean<DemoService> serviceBean = (ServiceBean<DemoService>) context.getBean("demoServiceExport");
URL url = (URL) serviceBean.toUrls().get(0);
assertEquals("protocol-paramA", url.getParameter("protocol.paramA"));
assertEquals("service-paramA", url.getParameter("service.paramA"));
}
示例15: test_retrySettingFail
import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void test_retrySettingFail() throws Exception {
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(
ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-long-waiting.xml");
providerContext.start();
try {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
ConfigTest.class.getPackage().getName().replace('.', '/')
+ "/init-reference-retry-false.xml");
ctx.start();
try {
DemoService demoService = (DemoService) ctx.getBean("demoService");
try {
demoService.sayName("Haha");
fail();
} catch (RpcException expected) {
assertThat(expected.getMessage(), containsString("Tried 1 times"));
}
assertEquals(1, RpcContext.getContext().getUrls().size());
} finally {
ctx.stop();
ctx.close();
}
} finally {
providerContext.stop();
providerContext.close();
}
}