You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/05/01 17:49:42 UTC
[4/9] Experiment with pulling spring out of core
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java b/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
deleted file mode 100644
index abb89a5..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cxf.bus.spring;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.List;
-import java.util.SortedSet;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.bus.managers.PhaseManagerImpl;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.phase.PhaseManager;
-import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.workqueue.WorkQueueManager;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SpringBusFactoryTest extends Assert {
-
- @After
- public void tearDown() {
- BusFactory.setDefaultBus(null);
- }
-
- @Test
- public void testDefault() {
- Bus bus = new SpringBusFactory().createBus();
- assertNotNull(bus);
- BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
- assertNotNull("No binding factory manager", bfm);
- assertNotNull("No configurer", bus.getExtension(Configurer.class));
- assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
- assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
- assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
- assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
- assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
- assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
- assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
-
- try {
- bfm.getBindingFactory("http://cxf.apache.org/unknown");
- } catch (BusException ex) {
- // expected
- }
-
- assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
-
- }
-
- @Test
- public void testCustomFileName() {
- String cfgFile = "org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
- checkCustomerConfiguration(bus);
- }
-
- @Test
- public void testCustomerBusShutdown() {
- String cfgFile = "org/apache/cxf/bus/spring/customerBus.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
- // We have three bus here, which should be closed rightly
- bus.shutdown(true);
- }
-
- @Test
- public void testCustomFileURLFromSystemProperty() {
- URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
- System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());
- Bus bus = new SpringBusFactory().createBus((String)null, true);
- checkCustomerConfiguration(bus);
- System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
- }
-
- @Test
- public void testCustomFileURL() {
- URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
- Bus bus = new SpringBusFactory().createBus(cfgFileURL, true);
- checkCustomerConfiguration(bus);
- }
-
- private void checkCustomerConfiguration(Bus bus) {
- assertNotNull(bus);
- List<Interceptor<? extends Message>> interceptors = bus.getInInterceptors();
- assertEquals("Unexpected number of interceptors", 2, interceptors.size());
- assertEquals("Unexpected interceptor", "in-a", interceptors.get(0).toString());
- assertEquals("Unexpected interceptor", "in-b", interceptors.get(1).toString());
- interceptors = bus.getInFaultInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "in-fault", interceptors.get(0).toString());
- interceptors = bus.getOutFaultInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "out-fault", interceptors.get(0).toString());
- interceptors = bus.getOutInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
- }
-
- @Test
- public void testForLifeCycle() {
- BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.class);
- Bus bus = new SpringBusFactory().createBus();
- BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
- lifeCycleManager.registerLifeCycleListener(bl);
- EasyMock.reset(bl);
- bl.preShutdown();
- EasyMock.expectLastCall();
- bl.postShutdown();
- EasyMock.expectLastCall();
- EasyMock.replay(bl);
- bus.shutdown(true);
- EasyMock.verify(bl);
-
- }
-
- @Test
- public void testPhases() {
- Bus bus = new SpringBusFactory().createBus();
- PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
- PhaseManager defaultPM = new PhaseManagerImpl();
- SortedSet<Phase> cxfPhases = cxfPM.getInPhases();
- SortedSet<Phase> defaultPhases = defaultPM.getInPhases();
- assertEquals(defaultPhases.size(), cxfPhases.size());
- assertTrue(cxfPhases.equals(defaultPhases));
- cxfPhases = cxfPM.getOutPhases();
- defaultPhases = defaultPM.getOutPhases();
- assertEquals(defaultPhases.size(), cxfPhases.size());
- assertTrue(cxfPhases.equals(defaultPhases));
- }
-
- @Test
- public void testJsr250() {
- Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/testjsr250.xml");
- TestExtension te = bus.getExtension(TestExtension.class);
- assertTrue("@PostConstruct annotated method has not been called.", te.postConstructMethodCalled);
- assertTrue("@PreDestroy annoated method has been called already.", !te.preDestroyMethodCalled);
- bus.shutdown(true);
- assertTrue("@PreDestroy annotated method has not been called.", te.preDestroyMethodCalled);
-
- }
-
- @Test
- public void testInitialisation() {
- Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/init.xml");
- assertNotNull(bus.getExtension(TestListener.class));
- assertSame(bus, bus.getExtension(BusApplicationContext.class).getBean("cxf"));
- }
-
-
- static class TestInterceptor implements Interceptor<Message> {
-
- private String name;
-
- public TestInterceptor() {
- }
-
- public void setName(String n) {
- name = n;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public void handleFault(Message message) {
- }
-
- public void handleMessage(Message message) throws Fault {
- }
-
- public void postHandleMessage(Message message) throws Fault {
- }
-
- }
-
- static class TestExtension {
-
- boolean postConstructMethodCalled;
- boolean preDestroyMethodCalled;
-
- public TestExtension(Bus bus) {
- bus.setExtension(this, TestExtension.class);
- }
-
- @PostConstruct
- void postConstructMethod() {
- postConstructMethodCalled = true;
- }
-
- @PreDestroy
- void preDestroyMethod() {
- preDestroyMethodCalled = true;
- }
- }
-
- static class TestFeature extends AbstractFeature {
- boolean initialised;
- public TestFeature() {
- //nothing
- }
-
- @Override
- public void initialize(Bus bus) {
- initialised = true;
- }
- }
-
- static class TestListener implements BusLifeCycleListener {
-
- Bus bus;
-
- @Resource
- public void setBus(Bus b) {
- bus = b;
- }
-
- @PostConstruct
- public void register() {
- bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
- }
-
- public void initComplete() {
- assertNull(bus.getExtension(TestFeature.class));
- Collection<Feature> features = bus.getFeatures();
- assertEquals(1, features.size());
- TestFeature tf = (TestFeature)features.iterator().next();
- assertTrue(tf.initialised);
- bus.setExtension(this, TestListener.class);
- }
-
- public void postShutdown() {
- }
-
- public void preShutdown() {
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/bus.xml b/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
deleted file mode 100644
index 9b2085b..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <c:bus>
- <c:features>
- <c:logging/>
- <bean class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestFeature">
- <property name="testBean" ref="tb"/>
- </bean>
- </c:features>
- </c:bus>
- <bean id="tb" class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestBean"/>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml b/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
deleted file mode 100644
index 0b0f8c9..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <cxf:bus bus="cxf1">
- <cxf:outInterceptors>
- <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
- </cxf:outInterceptors>
- </cxf:bus>
- <cxf:bus bus="cxf2">
- <cxf:inInterceptors>
- <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
- </cxf:inInterceptors>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml b/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
deleted file mode 100644
index 0b0f8c9..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <cxf:bus bus="cxf1">
- <cxf:outInterceptors>
- <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
- </cxf:outInterceptors>
- </cxf:bus>
- <cxf:bus bus="cxf2">
- <cxf:inInterceptors>
- <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
- </cxf:inInterceptors>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/init.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/init.xml b/core/src/test/java/org/apache/cxf/bus/spring/init.xml
deleted file mode 100644
index 55b13ff..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/init.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestListener">
- <property name="bus" ref="cxf"/>
- </bean>
- <cxf:bus>
- <cxf:features>
- <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestFeature"/>
- </cxf:features>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml b/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
deleted file mode 100644
index 6cc4f07..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd" default-lazy-init="true">
- <c:bus>
- <c:features>
- <c:logging/>
- </c:features>
- </c:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml b/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
deleted file mode 100644
index 64d5485..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="cxf" class="org.apache.cxf.bus.extension.ExtensionManagerBus">
- <property name="inInterceptors">
- <list>
- <ref bean="in-a"/>
- <ref bean="in-b"/>
- </list>
- </property>
- <property name="inFaultInterceptors">
- <list>
- <ref bean="in-fault"/>
- </list>
- </property>
- <property name="outInterceptors">
- <list>
- <ref bean="out"/>
- </list>
- </property>
- <property name="outFaultInterceptors">
- <list>
- <ref bean="out-fault"/>
- </list>
- </property>
- </bean>
- <bean id="in-a" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-a"/>
- </bean>
- <bean id="in-b" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-b"/>
- </bean>
- <bean id="out" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="out"/>
- </bean>
- <bean id="in-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-fault"/>
- </bean>
- <bean id="out-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="out-fault"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/test.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/test.xml b/core/src/test/java/org/apache/cxf/bus/spring/test.xml
deleted file mode 100644
index 65506f3..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/test.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
- <property name="propertyEditorRegistrars">
- <list merge="true">
- </list>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml b/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
deleted file mode 100644
index 8bcecc3..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="testExtension" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestExtension">
- <constructor-arg ref="cxf"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java b/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
deleted file mode 100644
index 41094cf..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cxf.configuration.spring;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Set;
-
-import javax.xml.bind.DatatypeConverter;
-import javax.xml.bind.DatatypeConverterInterface;
-import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.bus.spring.BusApplicationContext;
-import org.apache.cxf.configuration.Configurable;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-
-
-
-public class ConfigurerImplTest extends Assert {
-
- static {
- Class<?> cls;
- try {
- try {
- cls = Class.forName("com.sun.xml.bind.DatatypeConverterImpl");
- } catch (ClassNotFoundException e) {
- cls = Class.forName("com.sun.xml.internal.bind.DatatypeConverterImpl");
- }
- DatatypeConverterInterface convert = (DatatypeConverterInterface)cls.getField("theInstance")
- .get(null);
- DatatypeConverter.setDatatypeConverter(convert);
- } catch (Exception ex) {
- //ignore;
- }
- }
-
- @Test
- public void testConfigureSimpleNoMatchingBean() {
- SimpleBean sb = new SimpleBean("unknown");
-
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl(ac);
- configurer.configureBean(sb);
- assertEquals("Unexpected value for attribute stringAttr",
- "hello", sb.getStringAttr());
- assertTrue("Unexpected value for attribute booleanAttr",
- sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.ONE, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute intAttr",
- new Integer(2), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- new Long(3L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- new Short((short)4), sb.getShortAttr());
- assertEquals("Unexpected value for attribute decimalAttr",
- new BigDecimal("5"), sb.getDecimalAttr());
- assertEquals("Unexpected value for attribute floatAttr",
- new Float(6F), sb.getFloatAttr());
- assertEquals("Unexpected value for attribute doubleAttr",
- new Double(7D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- new Byte((byte)8), sb.getByteAttr());
-
- QName qn = sb.getQnameAttr();
- assertEquals("Unexpected value for attribute qnameAttrNoDefault",
- "schema", qn.getLocalPart());
- assertEquals("Unexpected value for attribute qnameAttrNoDefault",
- "http://www.w3.org/2001/XMLSchema", qn.getNamespaceURI());
- byte[] expected = DatatypeConverter.parseBase64Binary("abcd");
- byte[] val = sb.getBase64BinaryAttr();
- assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected.length, val.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected[i], val[i]);
- }
- expected = new HexBinaryAdapter().unmarshal("aaaa");
- val = sb.getHexBinaryAttr();
- assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected.length, val.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected[i], val[i]);
- }
-
- assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
- new Long(9L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- new Integer(10), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- new Short((short)11), sb.getUnsignedByteAttr());
- }
-
- @Test
- public void testConfigureSimple() {
- // Try to configure the bean with id
- verifyConfigureSimple("simple");
- // Try to configure the bean with an alias name
- verifyConfigureSimple("simpleValueBean");
- }
-
-
- public void verifyConfigureSimple(String beanName) {
-
- SimpleBean sb = new SimpleBean(beanName);
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
-
- configurer.configureBean(sb);
- assertEquals("Unexpected value for attribute stringAttr",
- "hallo", sb.getStringAttr());
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute intAttr",
- new Integer(12), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- new Long(13L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- new Short((short)14), sb.getShortAttr());
- assertEquals("Unexpected value for attribute decimalAttr",
- new BigDecimal("15"), sb.getDecimalAttr());
- assertEquals("Unexpected value for attribute floatAttr",
- new Float(16F), sb.getFloatAttr());
- assertEquals("Unexpected value for attribute doubleAttr",
- new Double(17D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- new Byte((byte)18), sb.getByteAttr());
-
- assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
- new Long(19L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- new Integer(20), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- new Short((short)21), sb.getUnsignedByteAttr());
- }
-
- @Test
- public void testConfigureSimpleMatchingStarBeanId() {
- SimpleBean sb = new SimpleBean("simple2");
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
- configurer.configureBean(sb);
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute stringAttr",
- "StarHallo", sb.getStringAttr());
- }
-
- @Test
- public void testConfigureSimpleMatchingStarBeanIdWithChildInstance() {
- SimpleBean sb = new ChildBean("simple2");
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
- configurer.configureBean(sb);
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute stringAttr",
- "StarHallo", sb.getStringAttr());
- }
-
- @Test
- public void testGetBeanName() {
- ConfigurerImpl configurer = new ConfigurerImpl();
- Object beanInstance = new Configurable() {
-
- public String getBeanName() {
- return "a";
- }
- };
- assertEquals("a", configurer.getBeanName(beanInstance));
- final class NamedBean {
- @SuppressWarnings("unused")
- public String getBeanName() {
- return "b";
- }
- }
- beanInstance = new NamedBean();
- assertEquals("b", configurer.getBeanName(beanInstance));
- beanInstance = this;
- assertNull(configurer.getBeanName(beanInstance));
- }
-
- @Test
- public void testAddApplicationContext() {
- ConfigurableApplicationContext context1 =
- new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(context1);
- // Just to simulate the OSGi's uninstall command
- context1.close();
-
- ConfigurableApplicationContext context2 =
- new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
- configurer.addApplicationContext(context2);
- Set<ApplicationContext> contexts = configurer.getAppContexts();
- assertEquals("The Context's size is wrong", 1, contexts.size());
- assertTrue("The conetxts' contains a wrong application context", contexts.contains(context2));
- }
-
- class SimpleBean implements Configurable {
-
- private String beanName;
-
- private String stringAttr = "hello";
- private Boolean booleanAttr = Boolean.TRUE;
- private BigInteger integerAttr = BigInteger.ONE;
- private Integer intAttr = new Integer(2);
- private Long longAttr = new Long(3);
- private Short shortAttr = new Short((short)4);
- private BigDecimal decimalAttr = new BigDecimal("5");
- private Float floatAttr = new Float(6F);
- private Double doubleAttr = new Double(7D);
- private Byte byteAttr = new Byte((byte)8);
- private QName qnameAttr = new QName("http://www.w3.org/2001/XMLSchema", "schema", "xs");
- private byte[] base64BinaryAttr = DatatypeConverter.parseBase64Binary("abcd");
- private byte[] hexBinaryAttr = new HexBinaryAdapter().unmarshal("aaaa");
- private Long unsignedIntAttr = new Long(9);
- private Integer unsignedShortAttr = new Integer(10);
- private Short unsignedByteAttr = new Short((short)11);
-
-
- public SimpleBean(String bn) {
- beanName = bn;
- }
-
- public String getBeanName() {
- return beanName;
- }
-
- public byte[] getBase64BinaryAttr() {
- return base64BinaryAttr;
- }
-
- public void setBase64BinaryAttr(byte[] base64BinaryAttr) {
- this.base64BinaryAttr = base64BinaryAttr;
- }
-
- public Boolean getBooleanAttr() {
- return booleanAttr;
- }
-
- public void setBooleanAttr(Boolean booleanAttr) {
- this.booleanAttr = booleanAttr;
- }
-
- public Byte getByteAttr() {
- return byteAttr;
- }
-
- public void setByteAttr(Byte byteAttr) {
- this.byteAttr = byteAttr;
- }
-
- public BigDecimal getDecimalAttr() {
- return decimalAttr;
- }
-
- public void setDecimalAttr(BigDecimal decimalAttr) {
- this.decimalAttr = decimalAttr;
- }
-
- public Double getDoubleAttr() {
- return doubleAttr;
- }
-
- public void setDoubleAttr(Double doubleAttr) {
- this.doubleAttr = doubleAttr;
- }
-
- public Float getFloatAttr() {
- return floatAttr;
- }
-
- public void setFloatAttr(Float floatAttr) {
- this.floatAttr = floatAttr;
- }
-
- public byte[] getHexBinaryAttr() {
- return hexBinaryAttr;
- }
-
- public void setHexBinaryAttr(byte[] hexBinaryAttr) {
- this.hexBinaryAttr = hexBinaryAttr;
- }
-
- public Integer getIntAttr() {
- return intAttr;
- }
-
- public void setIntAttr(Integer intAttr) {
- this.intAttr = intAttr;
- }
-
- public BigInteger getIntegerAttr() {
- return integerAttr;
- }
-
- public void setIntegerAttr(BigInteger integerAttr) {
- this.integerAttr = integerAttr;
- }
-
- public Long getLongAttr() {
- return longAttr;
- }
-
- public void setLongAttr(Long longAttr) {
- this.longAttr = longAttr;
- }
-
- public QName getQnameAttr() {
- return qnameAttr;
- }
-
- public void setQnameAttr(QName qnameAttr) {
- this.qnameAttr = qnameAttr;
- }
-
- public Short getShortAttr() {
- return shortAttr;
- }
-
- public void setShortAttr(Short shortAttr) {
- this.shortAttr = shortAttr;
- }
-
- public String getStringAttr() {
- return stringAttr;
- }
-
- public void setStringAttr(String stringAttr) {
- this.stringAttr = stringAttr;
- }
-
- public Short getUnsignedByteAttr() {
- return unsignedByteAttr;
- }
-
- public void setUnsignedByteAttr(Short unsignedByteAttr) {
- this.unsignedByteAttr = unsignedByteAttr;
- }
-
- public Long getUnsignedIntAttr() {
- return unsignedIntAttr;
- }
-
- public void setUnsignedIntAttr(Long unsignedIntAttr) {
- this.unsignedIntAttr = unsignedIntAttr;
- }
-
- public Integer getUnsignedShortAttr() {
- return unsignedShortAttr;
- }
-
- public void setUnsignedShortAttr(Integer unsignedShortAttr) {
- this.unsignedShortAttr = unsignedShortAttr;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
- }
-
- class ChildBean extends SimpleBean {
-
- public ChildBean(String bn) {
- super(bn);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties b/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
deleted file mode 100644
index 9199905..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-simple.name=simpleValueBean
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml b/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
deleted file mode 100644
index 359bb47..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="org/apache/cxf/configuration/spring/bean.properties"/>
- </bean>
- <bean name="*2" abstract="true" class="org.apache.cxf.configuration.spring.ConfigurerImplTest$SimpleBean">
- <property name="stringAttr" value="StarHallo"/>
- </bean>
- <!-- additional wildcards for class SimpleBean will be ignored with a warning -->
- <bean name="*duplicateWildcardForClassWillBeIgnored" abstract="true" class="SimpleBean">
- <property name="stringAttr" value="duplicateWildcardForClassWillBeIgnored"/>
- </bean>
- <!-- wildcards bean with no class will be ignored with a warning -->
- <bean name="*willBeIgnoredBecausOfNoClass" abstract="true">
- <property name="stringAttr" value="willBeIgnoredBecausOfNoClass"/>
- </bean>
- <bean id="simple2" lazy-init="true">
- <property name="booleanAttr" value="false"/>
- <property name="integerAttr" value="10"/>
- </bean>
- <bean id="simple" name="${simple.name}" lazy-init="true">
- <property name="stringAttr" value="hallo"/>
- <property name="booleanAttr" value="false"/>
- <property name="integerAttr" value="10"/>
- <property name="intAttr" value="12"/>
- <property name="longAttr" value="13"/>
- <property name="shortAttr" value="14"/>
- <property name="decimalAttr" value="15"/>
- <property name="floatAttr" value="16"/>
- <property name="doubleAttr" value="17"/>
- <property name="byteAttr" value="18"/>
- <!--
- <property name="qnameAttr" value="xs:string"/>
- -->
- <property name="base64BinaryAttr" value="abcd"/>
- <property name="hexBinaryAttr" value="bbbb"/>
- <property name="unsignedIntAttr" value="19"/>
- <property name="unsignedShortAttr" value="20"/>
- <property name="unsignedByteAttr" value="21"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml b/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
deleted file mode 100644
index 801968a..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="complex" class="org.apache.cxf.configuration.spring.JaxbPropertyEditorTest$FooBean" lazy-init="true">
- <property name="name">
- <value>foam</value>
- </property>
- <property name="position">
- <value>
- <foo:point>
- <foo:x>12</foo:x>
- <foo:y>33</foo:y>
- </foo:point>
- </value>
- </property>
- <property name="address">
- <value>
- <foo:address>
- <foo:city>Dublin</foo:city>
- <foo:zip>4</foo:zip>
- <foo:street>Shelbourne Rd</foo:street>
- </foo:address>
- </value>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/integration/jca/pom.xml
----------------------------------------------------------------------
diff --git a/integration/jca/pom.xml b/integration/jca/pom.xml
index 3e076e5..0e2f938 100644
--- a/integration/jca/pom.xml
+++ b/integration/jca/pom.xml
@@ -53,6 +53,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/bindings/object/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/object/pom.xml b/rt/bindings/object/pom.xml
index 2d26b02..ed7a2be 100644
--- a/rt/bindings/object/pom.xml
+++ b/rt/bindings/object/pom.xml
@@ -48,6 +48,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/bindings/soap/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/pom.xml b/rt/bindings/soap/pom.xml
index 777443b..fba8cd6 100644
--- a/rt/bindings/soap/pom.xml
+++ b/rt/bindings/soap/pom.xml
@@ -57,6 +57,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/databinding/xmlbeans/pom.xml
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/pom.xml b/rt/databinding/xmlbeans/pom.xml
index b7c786c..6738e1b 100644
--- a/rt/databinding/xmlbeans/pom.xml
+++ b/rt/databinding/xmlbeans/pom.xml
@@ -67,6 +67,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<exclusions>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/features/clustering/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/clustering/pom.xml b/rt/features/clustering/pom.xml
index b1a255b..dac027a 100644
--- a/rt/features/clustering/pom.xml
+++ b/rt/features/clustering/pom.xml
@@ -58,6 +58,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml
index 95e75ed..6b2948b 100644
--- a/rt/frontend/jaxrs/pom.xml
+++ b/rt/frontend/jaxrs/pom.xml
@@ -99,6 +99,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>${cxf.servlet-api.group}</groupId>
<artifactId>${cxf.servlet-api.artifact}</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/pom.xml b/rt/frontend/jaxws/pom.xml
index c9e3c27..20ea597 100644
--- a/rt/frontend/jaxws/pom.xml
+++ b/rt/frontend/jaxws/pom.xml
@@ -101,6 +101,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/simple/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/pom.xml b/rt/frontend/simple/pom.xml
index 0279632..d80ec4c 100644
--- a/rt/frontend/simple/pom.xml
+++ b/rt/frontend/simple/pom.xml
@@ -74,6 +74,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/management/pom.xml
----------------------------------------------------------------------
diff --git a/rt/management/pom.xml b/rt/management/pom.xml
index ba033e5..3811e09 100644
--- a/rt/management/pom.xml
+++ b/rt/management/pom.xml
@@ -42,6 +42,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/pom.xml
----------------------------------------------------------------------
diff --git a/rt/pom.xml b/rt/pom.xml
index 8472491..aa04230 100644
--- a/rt/pom.xml
+++ b/rt/pom.xml
@@ -30,6 +30,7 @@
<version>3.0.0-SNAPSHOT</version>
</parent>
<modules>
+ <module>spring</module>
<module>wsdl</module>
<module>transports/local</module>
<module>databinding/jaxb</module>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/rs/client/pom.xml
----------------------------------------------------------------------
diff --git a/rt/rs/client/pom.xml b/rt/rs/client/pom.xml
index 9ef22ab..1c97db0 100644
--- a/rt/rs/client/pom.xml
+++ b/rt/rs/client/pom.xml
@@ -58,6 +58,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-local</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/pom.xml
----------------------------------------------------------------------
diff --git a/rt/spring/pom.xml b/rt/spring/pom.xml
new file mode 100644
index 0000000..6a22428
--- /dev/null
+++ b/rt/spring/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-spring</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Spring Support</name>
+ <description>Apache CXF Spring Support</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.fastinfoset</groupId>
+ <artifactId>FastInfoset</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
new file mode 100644
index 0000000..5f086b7
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
@@ -0,0 +1,337 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.bus.spring;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Fault;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.BeansDtdResolver;
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.PluggableSchemaResolver;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextException;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+public class BusApplicationContext extends ClassPathXmlApplicationContext {
+
+ private static final String DEFAULT_CXF_CFG_FILE = "META-INF/cxf/cxf.xml";
+ private static final String DEFAULT_CXF_EXT_CFG_FILE = "classpath*:META-INF/cxf/cxf.extension";
+
+ private static final Logger LOG = LogUtils.getL7dLogger(BusApplicationContext.class);
+
+ private NamespaceHandlerResolver nsHandlerResolver;
+ private boolean includeDefaults;
+ private String[] cfgFiles;
+ private URL[] cfgFileURLs;
+
+ public BusApplicationContext(String cf, boolean include) {
+ this(cf, include, null);
+ }
+ public BusApplicationContext(String[] cfs, boolean include) {
+ this(cfs, include, null);
+ }
+
+ public BusApplicationContext(URL url, boolean include) {
+ this(url, include, null);
+ }
+ public BusApplicationContext(URL[] urls, boolean include) {
+ this(urls, include, null);
+ }
+
+ public BusApplicationContext(String cf, boolean include, ApplicationContext parent) {
+ this(new String[] {cf}, include, parent);
+ }
+
+ public BusApplicationContext(URL url, boolean include, ApplicationContext parent) {
+ this(new URL[] {url}, include, parent, null);
+ }
+ public BusApplicationContext(String[] cf, boolean include, ApplicationContext parent) {
+ this(cf, include, parent, null);
+ }
+ public BusApplicationContext(String[] cf, boolean include,
+ ApplicationContext parent, NamespaceHandlerResolver res) {
+ super(new String[0], false, parent);
+ cfgFiles = cf;
+ includeDefaults = include;
+ nsHandlerResolver = res;
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() throws Exception {
+ refresh();
+ return Boolean.TRUE;
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ if (e.getException() instanceof RuntimeException) {
+ throw (RuntimeException)e.getException();
+ }
+ throw new Fault(e);
+ }
+ }
+ public BusApplicationContext(URL[] url, boolean include,
+ ApplicationContext parent) {
+ this(url, include, parent, null);
+ }
+ public BusApplicationContext(URL[] url, boolean include,
+ ApplicationContext parent,
+ NamespaceHandlerResolver res) {
+ super(new String[0], false, parent);
+ cfgFileURLs = url;
+ includeDefaults = include;
+ nsHandlerResolver = res;
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() throws Exception {
+ refresh();
+ return Boolean.TRUE;
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ if (e.getException() instanceof RuntimeException) {
+ throw (RuntimeException)e.getException();
+ }
+ throw new Fault(e);
+ }
+ }
+
+ @Override
+ protected Resource[] getConfigResources() {
+ List<Resource> resources = new ArrayList<Resource>();
+
+ if (includeDefaults) {
+ try {
+ PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread
+ .currentThread().getContextClassLoader());
+
+ Collections.addAll(resources, resolver.getResources(DEFAULT_CXF_CFG_FILE));
+
+ Resource[] exts = resolver.getResources(DEFAULT_CXF_EXT_CFG_FILE);
+ for (Resource r : exts) {
+ InputStream is = r.getInputStream();
+ BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ String line = rd.readLine();
+ while (line != null) {
+ if (!"".equals(line)) {
+ resources.add(resolver.getResource(line));
+ }
+ line = rd.readLine();
+ }
+ is.close();
+ }
+
+ } catch (IOException ex) {
+ // ignore
+ }
+ }
+
+ boolean usingDefault = false;
+ if (null == cfgFiles) {
+ String cfgFile = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+ if (cfgFile != null) {
+ cfgFiles = new String[] {cfgFile};
+ }
+ }
+ if (null == cfgFiles) {
+ cfgFiles = new String[] {Configurer.DEFAULT_USER_CFG_FILE};
+ usingDefault = true;
+ }
+ for (String cfgFile : cfgFiles) {
+ final Resource cpr = findResource(cfgFile);
+ boolean exists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ return cpr != null && cpr.exists();
+ }
+
+ });
+ if (exists) {
+ resources.add(cpr);
+ LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
+ } else {
+ if (!usingDefault) {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
+ String message = (new Message("USER_CFG_FILE_NOT_LOADED", LOG, cfgFile)).toString();
+ throw new ApplicationContextException(message);
+ }
+ }
+ }
+
+ if (null != cfgFileURLs) {
+ for (URL cfgFileURL : cfgFileURLs) {
+ UrlResource ur = new UrlResource(cfgFileURL);
+ if (ur.exists()) {
+ resources.add(ur);
+ } else {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", cfgFileURL);
+ }
+ }
+ }
+
+ String sysCfgFileUrl = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_URL);
+ if (null != sysCfgFileUrl) {
+ try {
+ UrlResource ur = new UrlResource(sysCfgFileUrl);
+ if (ur.exists()) {
+ resources.add(ur);
+ } else {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", sysCfgFileUrl);
+ }
+ } catch (MalformedURLException e) {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_ERROR_MSG", sysCfgFileUrl);
+ }
+ }
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Creating application context with resources: " + resources);
+ }
+
+ if (0 == resources.size()) {
+ return null;
+ }
+ Resource[] res = new Resource[resources.size()];
+ res = resources.toArray(res);
+ return res;
+ }
+
+ public static Resource findResource(final String cfgFile) {
+ try {
+ return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
+ public Resource run() {
+ Resource cpr = new ClassPathResource(cfgFile);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ try {
+ //see if it's a URL
+ URL url = new URL(cfgFile);
+ cpr = new UrlResource(url);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ } catch (MalformedURLException e) {
+ //ignore
+ }
+ //try loading it our way
+ URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
+ if (url != null) {
+ cpr = new UrlResource(url);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ }
+ cpr = new FileSystemResource(cfgFile);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ return null;
+ }
+ });
+ } catch (AccessControlException ex) {
+ //cannot read the user config file
+ return null;
+ }
+ }
+
+ @Override
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
+ // Spring always creates a new one of these, which takes a fair amount
+ // of time on startup (nearly 1/2 second) as it gets created for every
+ // spring context on the classpath
+ if (nsHandlerResolver == null) {
+ nsHandlerResolver = new DefaultNamespaceHandlerResolver();
+ }
+ reader.setNamespaceHandlerResolver(nsHandlerResolver);
+
+ String mode = getSpringValidationMode();
+ if (null != mode) {
+ reader.setValidationModeName(mode);
+ }
+ reader.setNamespaceAware(true);
+
+ setEntityResolvers(reader);
+ }
+
+ static String getSpringValidationMode() {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ String mode = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.spring.validation.mode");
+ if (mode == null) {
+ mode = SystemPropertyAction.getPropertyOrNull("spring.validation.mode");
+ }
+ return mode;
+ }
+ });
+ }
+
+
+ void setEntityResolvers(XmlBeanDefinitionReader reader) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ reader.setEntityResolver(new BusEntityResolver(cl, new BeansDtdResolver(),
+ new PluggableSchemaResolver(cl)));
+ }
+ @Override
+ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException {
+ // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+ XmlBeanDefinitionReader beanDefinitionReader =
+ new ControlledValidationXmlBeanDefinitionReader(beanFactory);
+ beanDefinitionReader.setNamespaceHandlerResolver(nsHandlerResolver);
+
+ // Configure the bean definition reader with this context's
+ // resource loading environment.
+ beanDefinitionReader.setResourceLoader(this);
+ beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
+
+ // Allow a subclass to provide custom initialization of the reader,
+ // then proceed with actually loading the bean definitions.
+ initBeanDefinitionReader(beanDefinitionReader);
+ loadBeanDefinitions(beanDefinitionReader);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
new file mode 100644
index 0000000..434a851
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.bus.spring;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.resource.ResourceResolver;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.core.io.Resource;
+
+@NoJSR250Annotations
+public class BusApplicationContextResourceResolver
+ implements ResourceResolver, ApplicationContextAware {
+
+ ApplicationContext context;
+
+ public BusApplicationContextResourceResolver() {
+ }
+ public BusApplicationContextResourceResolver(ApplicationContext c) {
+ context = c;
+ }
+
+
+ public InputStream getAsStream(String name) {
+ Resource r = context.getResource(name);
+ if (r != null && r.exists()) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ //ignore and return null
+ }
+ }
+ r = context.getResource("/" + name);
+ if (r != null && r.exists()) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ //ignore and return null
+ }
+ }
+ return null;
+ }
+
+ public <T> T resolve(String resourceName, Class<T> resourceType) {
+
+ try {
+ T resource = null;
+ if (resourceName == null) {
+ String names[] = context.getBeanNamesForType(resourceType);
+ if (names != null && names.length > 0) {
+ resource = resourceType.cast(context.getBean(names[0], resourceType));
+ }
+ } else {
+ resource = resourceType.cast(context.getBean(resourceName, resourceType));
+ }
+ return resource;
+ } catch (NoSuchBeanDefinitionException def) {
+ //ignore
+ }
+ try {
+ if (ClassLoader.class.isAssignableFrom(resourceType)) {
+ return resourceType.cast(context.getClassLoader());
+ } else if (URL.class.isAssignableFrom(resourceType)) {
+ Resource r = context.getResource(resourceName);
+ if (r != null && r.exists()) {
+ r.getInputStream().close(); //checks to see if the URL really can resolve
+ return resourceType.cast(r.getURL());
+ }
+ }
+ } catch (IOException e) {
+ //ignore
+ }
+ return null;
+ }
+
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ context = applicationContext;
+ }
+
+}