本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.start()
方法的一些代码示例,展示了ClassPathXmlApplicationContext.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.start()
方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:start
暂无
代码示例来源:origin: apache/incubator-dubbo
/**
* In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before
* launch the application
*/
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");
context.start();
System.in.read();
}
}
代码示例来源:origin: apache/incubator-dubbo
/**
* In order to make sure multicast registry works, need to specify '-Djava.net.preferIPv4Stack=true' before
* launch the application
*/
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
DemoService demoService = context.getBean("demoService", DemoService.class);
String hello = demoService.sayHello("world");
System.out.println("result: " + hello);
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (StringUtils.isEmpty(configPath)) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
context.start();
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void start() {
String configPath = ConfigUtils.getProperty(SPRING_CONFIG);
if (StringUtils.isEmpty(configPath)) {
configPath = DEFAULT_SPRING_CONFIG;
}
context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));
context.start();
}
代码示例来源:origin: mrdear/JavaWEB
public static void main(String[] args) throws IOException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
context.start();
System.in.read(); // 为保证服务一直开着,利用输入流的阻塞来模拟
}
}
代码示例来源:origin: dearbinge/dubbo-spring-boot-mybatis-redis
private ClassPathXmlApplicationContext getContext() {
if (context == null) {
synchronized (UserSecurityInterceptor.class) {
if (context == null) {
context = new ClassPathXmlApplicationContext(new String[] { "dubbo-services.xml" });
context.refresh();
context.start();
}
}
}
return context;
}
代码示例来源:origin: javahongxi/whatsmars
public static void main(String[] args) throws Exception {
//Prevent to get IPV6 address,this way only work in debug mode
//But you can pass use -Djava.net.preferIPv4Stack=true,then it work well whether in debug mode or not
System.setProperty("java.net.preferIPv4Stack", "true");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-async-consumer.xml"});
context.start();
// 异步调用
async(context);
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testGatewayWithMessageConverter() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithMessageConverter.xml", this.getClass());
PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
context.start();
Message<?> message = channel.receive(10000);
assertNotNull("message should not be null", message);
assertEquals("converted-test-message", message.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test(expected = ReplyRequiredException.class)
public void splitterParserTestWithRequiresReply() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"splitterParserTests.xml", this.getClass());
context.start();
DirectChannel inputChannel = context.getBean("requiresReplyInput", DirectChannel.class);
inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
@Ignore
public void testOutbound() throws Exception {
ClassPathXmlApplicationContext ac =
new ClassPathXmlApplicationContext("SftpOutboundTransferSample-ignored.xml", SftpOutboundTransferSample.class);
ac.start();
File file = new File("/Users/ozhurakousky/workspace-sts-2.3.3.M2/si/spring-integration/spring-integration-sftp/local-test-dir/foo.txt");
if (file.exists()) {
Message<File> message = MessageBuilder.withPayload(file).build();
MessageChannel inputChannel = ac.getBean("inputChannel", MessageChannel.class);
inputChannel.send(message);
Thread.sleep(2000);
}
ac.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testGatewayWithConnectionFactoryAndDestinationName() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithConnectionFactoryAndDestinationName.xml", this.getClass());
PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
context.start();
Message<?> message = channel.receive(10000);
assertNotNull("message should not be null", message);
assertEquals("message-driven-test", message.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testGatewayWithDefaultConnectionFactory() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithDefaultConnectionFactory.xml", this.getClass());
PollableChannel channel = (PollableChannel) context.getBean("requestChannel");
JmsMessageDrivenEndpoint gateway = (JmsMessageDrivenEndpoint) context.getBean("jmsGateway");
assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
context.start();
Message<?> message = channel.receive(10000);
assertNotNull("message should not be null", message);
assertEquals("message-driven-test", message.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void autoDetectionWithApplicationContext() {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("messageBusTests.xml", this.getClass());
context.start();
PollableChannel sourceChannel = (PollableChannel) context.getBean("sourceChannel");
sourceChannel.send(new GenericMessage<>("test"));
PollableChannel targetChannel = (PollableChannel) context.getBean("targetChannel");
Message<?> result = targetChannel.receive(10000);
assertEquals("test", result.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void outputChannelWithNoReturnAddress() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"returnAddressTests.xml", this.getClass());
MessageChannel channel4 = (MessageChannel) context.getBean("channel4");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
GenericMessage<String> message = new GenericMessage<String>("*");
channel4.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void returnAddressFallbackButNotAvailable() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"returnAddressTests.xml", this.getClass());
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
context.start();
GenericMessage<String> message = new GenericMessage<String>("*");
try {
channel3.send(message);
}
catch (MessagingException e) {
assertTrue(e.getCause() instanceof DestinationResolutionException);
}
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testSimpleEndpoint() throws InterruptedException {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"simpleEndpointTests.xml", this.getClass());
context.start();
MessageChannel channel = (MessageChannel) context.getBean("endpointParserTestInput");
TestHandler handler = (TestHandler) context.getBean("testHandler");
assertNull(handler.getMessageString());
channel.send(new GenericMessage<>("test"));
assertTrue(handler.getLatch().await(10000, TimeUnit.MILLISECONDS));
assertEquals("test", handler.getMessageString());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void returnAddressFallbackWithChannelName() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"returnAddressTests.xml", this.getClass());
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
PollableChannel channel5 = (PollableChannel) context.getBean("channel5");
context.start();
Message<String> message = MessageBuilder.withPayload("*")
.setReplyChannelName("channel5").build();
channel3.send(message);
Message<?> response = channel5.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void returnAddressFallbackWithChannelReference() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"returnAddressTests.xml", this.getClass());
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
PollableChannel channel5 = (PollableChannel) context.getBean("channel5");
context.start();
Message<String> message = MessageBuilder.withPayload("*")
.setReplyChannel(channel5).build();
channel3.send(message);
Message<?> response = channel5.receive(3000);
assertNotNull(response);
assertEquals("**", response.getPayload());
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void splitterParserTestApplySequenceFalse() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"splitterParserTests.xml", this.getClass());
context.start();
DirectChannel inputChannel = context.getBean("noSequenceInput", DirectChannel.class);
PollableChannel output = (PollableChannel) context.getBean("output");
inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build());
Message<?> message = output.receive(1000);
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceNumber(), is(0));
assertThat(new IntegrationMessageHeaderAccessor(message).getSequenceSize(), is(0));
context.close();
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void returnAddressWithChannelReferenceAfterMultipleEndpoints() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"returnAddressTests.xml", this.getClass());
MessageChannel channel1 = (MessageChannel) context.getBean("channel1");
PollableChannel replyChannel = (PollableChannel) context.getBean("replyChannel");
context.start();
Message<String> message = MessageBuilder.withPayload("*")
.setReplyChannel(replyChannel).build();
channel1.send(message);
Message<?> response = replyChannel.receive(3000);
assertNotNull(response);
assertEquals("********", response.getPayload());
PollableChannel channel2 = (PollableChannel) context.getBean("channel2");
assertNull(channel2.receive(0));
context.close();
}
内容来源于网络,如有侵权,请联系作者删除!