Changed XML app context to @Configuration
This commit is contained in:
@@ -19,7 +19,7 @@ package org.springframework.ws.samples.weather;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
|
||||
import org.springframework.ws.soap.client.core.SoapActionCallback;
|
||||
|
||||
@@ -69,9 +69,8 @@ public class WeatherClient extends WebServiceGatewaySupport {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml",
|
||||
WeatherClient.class);
|
||||
WeatherClient client = context.getBean("weatherClient", WeatherClient.class);
|
||||
new AnnotationConfigApplicationContext(WeatherConfiguration.class);
|
||||
WeatherClient client = context.getBean(WeatherClient.class);
|
||||
|
||||
String zipCode = "94304";
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.weather;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||
|
||||
@Configuration
|
||||
public class WeatherConfiguration {
|
||||
|
||||
@Bean
|
||||
public Jaxb2Marshaller marshaller() {
|
||||
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
|
||||
marshaller.setContextPath("org.springframework.ws.samples.weather");
|
||||
return marshaller;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WeatherClient weatherClient() {
|
||||
WeatherClient client = new WeatherClient();
|
||||
client.setDefaultUri("http://wsf.cdyne.com/WeatherWS/Weather.asmx");
|
||||
Jaxb2Marshaller marshaller = marshaller();
|
||||
client.setMarshaller(marshaller);
|
||||
client.setUnmarshaller(marshaller);
|
||||
return client;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
log4j.rootLogger=WARN, stdout
|
||||
log4j.logger.org.springframework.ws=DEBUG
|
||||
log4j.logger.org.springframework.xml=DEBUG
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:oxm="http://www.springframework.org/schema/oxm"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd">
|
||||
|
||||
<oxm:jaxb2-marshaller id="marshaller" contextPath="org.springframework.ws.samples.weather"/>
|
||||
|
||||
<bean id="weatherClient" class="org.springframework.ws.samples.weather.WeatherClient">
|
||||
<property name="defaultUri" value="http://wsf.cdyne.com/WeatherWS/Weather.asmx"/>
|
||||
<property name="marshaller" ref="marshaller"/>
|
||||
<property name="unmarshaller" ref="marshaller"/>
|
||||
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user