You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/09/23 11:29:32 UTC
[1/4] cxf git commit: Experimentally simply remove spring and
blueprint related classes to see how much cxf is tied to it
Repository: cxf
Updated Branches:
refs/heads/poc-remove-spring-bp [created] 5e9659557
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java b/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
deleted file mode 100644
index 60d6101..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
+++ /dev/null
@@ -1,48 +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 org.junit.Assert;
-import org.junit.Test;
-
-import org.springframework.beans.BeansException;
-
-public class BusApplicationContextTest extends Assert {
-
- @Test
- public void testGetResources() {
- BusApplicationContext ctx = null;
-
- try {
- ctx = new BusApplicationContext("nowhere.xml", false);
- fail("Bus creation should have thrown exception.");
- } catch (BeansException bex) {
- //Expected
- }
-
- String cfgFile = "/org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
- ctx = new BusApplicationContext(cfgFile, false);
- assertEquals("Unexpected number of resources", 1, ctx.getConfigResources().length);
- ctx.close();
- ctx = new BusApplicationContext(cfgFile, true);
- assertEquals("Unexpected number of resources", 2, ctx.getConfigResources().length);
- ctx.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java b/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
deleted file mode 100644
index 9b0b7a3..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
+++ /dev/null
@@ -1,53 +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 org.apache.cxf.Bus;
-import org.apache.cxf.bus.managers.CXFBusLifeCycleManager;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.support.AbstractRefreshableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-
-public class BusApplicationListenerTest extends Assert {
-
- @Test
- public void testParentApplicationEvent() {
- AbstractRefreshableApplicationContext parent = new ClassPathXmlApplicationContext();
- parent.refresh();
- SpringBusFactory factory = new SpringBusFactory(parent);
- Bus bus = factory.createBus();
- CXFBusLifeCycleManager manager = bus.getExtension(CXFBusLifeCycleManager.class);
- BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
- manager.registerLifeCycleListener(listener);
- EasyMock.reset(listener);
- listener.preShutdown();
- EasyMock.expectLastCall().times(1);
- listener.postShutdown();
- EasyMock.expectLastCall().times(1);
- EasyMock.replay(listener);
- parent.close();
- EasyMock.verify(listener);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java b/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
deleted file mode 100644
index 2c63150..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
+++ /dev/null
@@ -1,168 +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.util.Collection;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.PostConstruct;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.interceptor.LoggingInInterceptor;
-import org.apache.cxf.message.Message;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class BusDefinitionParserTest extends Assert {
-
- @Test
- public void testFeatures() {
- String cfgFile = "org/apache/cxf/bus/spring/bus.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
-
- List<Interceptor<? extends Message>> in = bus.getInInterceptors();
- boolean found = false;
- for (Interceptor<? extends Message> i : in) {
- if (i instanceof LoggingInInterceptor) {
- found = true;
- }
- }
- assertTrue("could not find logging interceptor.", found);
-
- Collection<Feature> features = bus.getFeatures();
- TestFeature tf = null;
- for (Feature f : features) {
- if (f instanceof TestFeature) {
- tf = (TestFeature)f;
- break;
- }
- }
-
- assertNotNull(tf);
- assertTrue("test feature has not been initialised", tf.initialised);
- assertNotNull("test feature has not been injected", tf.testBean);
- assertTrue("bean injected into test feature has not been initialised", tf.testBean.initialised);
- }
-
- @Test
- public void testBusConfigure() {
- ClassPathXmlApplicationContext context = null;
- try {
- context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus.xml");
- Bus cxf1 = (Bus)context.getBean("cxf1");
-
- assertTrue(cxf1.getOutInterceptors().size() == 1);
- assertTrue(cxf1.getInInterceptors().size() == 0);
-
- Bus cxf2 = (Bus)context.getBean("cxf2");
- assertTrue(cxf2.getInInterceptors().size() == 1);
- assertTrue(cxf2.getOutInterceptors().size() == 0);
- } finally {
- if (context != null) {
- context.close();
- }
- }
- }
- @Test
- public void testBusConfigureCreateBus() {
- ClassPathXmlApplicationContext context = null;
- final AtomicBoolean b = new AtomicBoolean();
- try {
- context = new ClassPathXmlApplicationContext("org/apache/cxf/bus/spring/customerBus2.xml");
- Bus cxf1 = (Bus)context.getBean("cxf1");
-
- assertTrue(cxf1.getOutInterceptors().size() == 1);
- assertTrue(cxf1.getInInterceptors().size() == 0);
-
- Bus cxf2 = (Bus)context.getBean("cxf2");
-
- assertTrue(cxf2.getInInterceptors().size() == 1);
- assertTrue(cxf2.getOutInterceptors().size() == 0);
-
- cxf2.getExtension(BusLifeCycleManager.class)
- .registerLifeCycleListener(new BusLifeCycleListener() {
- public void initComplete() {
- }
-
- public void preShutdown() {
- }
-
- public void postShutdown() {
- b.set(true);
- }
-
- });
- } finally {
- if (context != null) {
- context.close();
- }
- }
- assertTrue("postShutdown not called", b.get());
- }
- @Test
- public void testLazyInit() {
- String cfgFile = "org/apache/cxf/bus/spring/lazyInitBus.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
-
- List<Interceptor<? extends Message>> in = bus.getInInterceptors();
- boolean found = false;
- for (Interceptor<? extends Message> i : in) {
- if (i instanceof LoggingInInterceptor) {
- found = true;
- }
- }
- assertTrue("could not find logging interceptor.", found);
- }
-
- static class TestBean {
-
- boolean initialised;
-
- @PostConstruct
- public void initialise() {
- initialised = true;
- }
- }
-
- static class TestFeature extends AbstractFeature {
-
- boolean initialised;
- TestBean testBean;
-
- @PostConstruct
- public void initialise() {
- initialised = true;
- }
-
- public void setTestBean(TestBean tb) {
- testBean = tb;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/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 bf4a96a..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;
-
- 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;
-
- 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;
- 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/5e965955/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 6abcbf4..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",
- Integer.valueOf(2), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- Long.valueOf(3L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- Short.valueOf((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",
- Double.valueOf(7.0D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- Byte.valueOf((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",
- Long.valueOf(9L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- Integer.valueOf(10), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- Short.valueOf((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",
- Integer.valueOf(12), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- Long.valueOf(13L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- Short.valueOf((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",
- Double.valueOf(17D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- Byte.valueOf((byte)18), sb.getByteAttr());
-
- assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
- Long.valueOf(19L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- Integer.valueOf(20), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- Short.valueOf((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 = Integer.valueOf(2);
- private Long longAttr = Long.valueOf(3);
- private Short shortAttr = Short.valueOf((short)4);
- private BigDecimal decimalAttr = new BigDecimal("5");
- private Float floatAttr = new Float(6F);
- private Double doubleAttr = Double.valueOf(7D);
- private Byte byteAttr = Byte.valueOf((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 = Long.valueOf(9);
- private Integer unsignedShortAttr = Integer.valueOf(10);
- private Short unsignedByteAttr = Short.valueOf((short)11);
-
-
- 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 {
-
- ChildBean(String bn) {
- super(bn);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/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/5e965955/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/5e965955/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/5e965955/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java b/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
deleted file mode 100644
index f8f61f8..0000000
--- a/core/src/test/java/org/apache/cxf/internal/CXFAPINamespaceHandlerTest.java
+++ /dev/null
@@ -1,42 +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.internal;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- */
-public class CXFAPINamespaceHandlerTest extends Assert {
- @Test
- public void testGetSchemaLocation() {
- CXFAPINamespaceHandler handler = new CXFAPINamespaceHandler();
-
- assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/beans"));
- assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/parameterized-types"));
- assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/configuration/security"));
- assertNotNull(handler.getSchemaLocation("http://schemas.xmlsoap.org/wsdl/"));
- assertNotNull(handler.getSchemaLocation("http://www.w3.org/2005/08/addressing"));
- assertNotNull(handler.getSchemaLocation("http://schemas.xmlsoap.org/ws/2004/08/addressing"));
- assertNotNull(handler.getSchemaLocation("http://cxf.apache.org/blueprint/core"));
- }
-
-}
[4/4] cxf git commit: Experimentally simply remove spring and
blueprint related classes to see how much cxf is tied to it
Posted by cs...@apache.org.
Experimentally simply remove spring and blueprint related classes to see how much cxf is tied to it
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5e965955
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5e965955
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5e965955
Branch: refs/heads/poc-remove-spring-bp
Commit: 5e96595577df58cafb780002fdc227333600b351
Parents: 7a5e269
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Fri Sep 23 13:29:06 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Fri Sep 23 13:29:06 2016 +0200
----------------------------------------------------------------------
core/pom.xml | 4 +
.../cxf/bus/blueprint/BlueprintBeanLocator.java | 216 --------
.../apache/cxf/bus/blueprint/BlueprintBus.java | 78 ---
.../BlueprintNameSpaceHandlerFactory.java | 30 --
.../blueprint/BundleDelegatingClassLoader.java | 133 -----
.../cxf/bus/blueprint/BusDefinitionParser.java | 68 ---
.../cxf/bus/blueprint/ConfigurerImpl.java | 186 -------
.../cxf/bus/blueprint/Messages.properties | 26 -
.../blueprint/NamespaceHandlerRegisterer.java | 55 --
.../org/apache/cxf/bus/osgi/CXFActivator.java | 131 -----
.../bus/osgi/CXFExtensionBundleListener.java | 178 -------
.../cxf/bus/spring/BusApplicationContext.java | 338 ------------
.../BusApplicationContextResourceResolver.java | 104 ----
.../cxf/bus/spring/BusDefinitionParser.java | 299 -----------
.../cxf/bus/spring/BusEntityResolver.java | 89 ----
.../bus/spring/BusExtensionPostProcessor.java | 71 ---
.../BusWiringBeanFactoryPostProcessor.java | 174 ------
...rolledValidationXmlBeanDefinitionReader.java | 197 -------
.../cxf/bus/spring/Jsr250BeanPostProcessor.java | 157 ------
.../apache/cxf/bus/spring/Messages.properties | 27 -
.../apache/cxf/bus/spring/NamespaceHandler.java | 57 --
.../cxf/bus/spring/SpringBeanLocator.java | 313 -----------
.../org/apache/cxf/bus/spring/SpringBus.java | 141 -----
.../apache/cxf/bus/spring/SpringBusFactory.java | 227 --------
.../cxf/bus/spring/TunedDocumentLoader.java | 146 -----
.../org/apache/cxf/common/util/ClassHelper.java | 12 -
.../cxf/common/util/ClasspathScanner.java | 12 -
.../cxf/common/util/SpringAopClassHelper.java | 92 ----
.../cxf/common/util/SpringClasspathScanner.java | 201 -------
.../apache/cxf/common/util/SpringOsgiUtil.java | 44 --
.../AbstractBPBeanDefinitionParser.java | 441 ---------------
.../blueprint/InterceptorTypeConverter.java | 42 --
.../blueprint/SimpleBPBeanDefinitionParser.java | 87 ---
.../spring/AbstractBeanDefinitionParser.java | 533 -------------------
.../AbstractFactoryBeanDefinitionParser.java | 153 ------
.../cxf/configuration/spring/BusWiringType.java | 37 --
.../configuration/spring/ConfigurerImpl.java | 289 ----------
.../configuration/spring/JAXBBeanFactory.java | 73 ---
.../spring/MappingBeanDefinitionParser.java | 59 --
.../configuration/spring/Messages.properties | 26 -
.../spring/SimpleBeanDefinitionParser.java | 33 --
.../spring/StringBeanDefinitionParser.java | 39 --
.../cxf/internal/CXFAPINamespaceHandler.java | 114 ----
.../invoker/spring/SpringBeanFactory.java | 65 ---
.../bus/spring/BusApplicationContextTest.java | 48 --
.../bus/spring/BusApplicationListenerTest.java | 53 --
.../cxf/bus/spring/BusDefinitionParserTest.java | 168 ------
.../cxf/bus/spring/SpringBusFactoryTest.java | 279 ----------
.../spring/ConfigurerImplTest.java | 412 --------------
.../cxf/configuration/spring/bean.properties | 17 -
.../cxf/configuration/spring/test-beans.xml | 59 --
.../configuration/spring/test-jaxb-beans.xml | 43 --
.../internal/CXFAPINamespaceHandlerTest.java | 42 --
53 files changed, 4 insertions(+), 6914 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index cda420d..1378389 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -141,6 +141,7 @@
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
</dependency>
+ <!--
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
@@ -169,6 +170,7 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
+ -->
<dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
@@ -211,6 +213,7 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>
+ <!--
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-io</artifactId>
@@ -223,6 +226,7 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>
+ -->
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
deleted file mode 100644
index 4db349d..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
+++ /dev/null
@@ -1,216 +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.blueprint;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.aries.blueprint.ExtendedBeanMetadata;
-import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
-import org.apache.cxf.bus.extension.ExtensionManagerImpl;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.configuration.ConfiguredBeanLocator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.container.NoSuchComponentException;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.BeanProperty;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-
-/**
- *
- */
-public class BlueprintBeanLocator implements ConfiguredBeanLocator {
- private static final Logger LOG = LogUtils.getL7dLogger(BlueprintBeanLocator.class);
- ConfiguredBeanLocator orig;
- BlueprintContainer container;
- BundleContext context;
-
- public BlueprintBeanLocator(ConfiguredBeanLocator orig,
- BlueprintContainer cont,
- BundleContext context) {
- this.orig = orig;
- this.container = cont;
- this.context = context;
- if (orig instanceof ExtensionManagerImpl) {
- List<String> names = new ArrayList<String>(container.getComponentIds());
- ((ExtensionManagerImpl)orig).removeBeansOfNames(names);
- }
- }
-
- static Class<?> getClassForMetaData(BlueprintContainer container, ComponentMetadata cmd) {
- Class<?> cls = null;
- if (cmd instanceof BeanMetadata) {
- BeanMetadata bm = (BeanMetadata)cmd;
- if (bm instanceof ExtendedBeanMetadata) {
- cls = ((ExtendedBeanMetadata)bm).getRuntimeClass();
- }
- if (cls == null && container instanceof ExtendedBlueprintContainer && bm.getClassName() != null) {
- try {
- cls = ((ExtendedBlueprintContainer)container).loadClass(bm.getClassName());
- } catch (ClassNotFoundException cnfe) {
- //ignore
- }
- }
- }
- return cls;
- }
- private Class<?> getClassForMetaData(ComponentMetadata cmd) {
- return getClassForMetaData(container, cmd);
- }
- private ComponentMetadata getComponentMetadata(String id) {
- try {
- return container.getComponentMetadata(id);
- } catch (NoSuchComponentException nsce) {
- return null;
- }
- }
-
- public <T> T getBeanOfType(String name, Class<T> type) {
-
- ComponentMetadata cmd = getComponentMetadata(name);
- Class<?> cls = getClassForMetaData(cmd);
- if (cls != null && type.isAssignableFrom(cls)) {
- return type.cast(container.getComponentInstance(name));
- }
- return orig.getBeanOfType(name, type);
- }
- /** {@inheritDoc}*/
- public List<String> getBeanNamesOfType(Class<?> type) {
- Set<String> names = new LinkedHashSet<String>();
- for (String s : container.getComponentIds()) {
- ComponentMetadata cmd = container.getComponentMetadata(s);
- Class<?> cls = getClassForMetaData(cmd);
- if (cls != null && type.isAssignableFrom(cls)) {
- names.add(s);
- }
- }
- names.addAll(orig.getBeanNamesOfType(type));
- return new ArrayList<String>(names);
- }
-
- /** {@inheritDoc}*/
- public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
- List<T> list = new ArrayList<T>();
-
- for (String s : container.getComponentIds()) {
- ComponentMetadata cmd = container.getComponentMetadata(s);
- Class<?> cls = getClassForMetaData(cmd);
- if (cls != null && type.isAssignableFrom(cls)) {
- list.add(type.cast(container.getComponentInstance(s)));
- }
- }
- if (list.isEmpty() && context != null) {
- try {
- ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
- if (refs != null) {
- for (ServiceReference r : refs) {
- list.add(type.cast(context.getService(r)));
- }
- }
- } catch (Exception ex) {
- //ignore, just don't support the OSGi services
- LOG.info("Try to find the Bean with type:" + type
- + " from OSGi services and get error: " + ex);
- }
- }
- list.addAll(orig.getBeansOfType(type));
-
- return list;
- }
-
- /** {@inheritDoc}*/
- public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
- List<String> names = new ArrayList<String>();
- boolean loaded = false;
- for (String s : container.getComponentIds()) {
- ComponentMetadata cmd = container.getComponentMetadata(s);
- Class<?> cls = getClassForMetaData(cmd);
- if (cls != null && type.isAssignableFrom(cls)) {
- names.add(s);
- }
- }
- Collections.reverse(names);
- for (String s : names) {
- ComponentMetadata cmd = container.getComponentMetadata(s);
- Class<?> beanType = getClassForMetaData(cmd);
- Class<? extends T> t = beanType.asSubclass(type);
- if (listener.loadBean(s, t)) {
- Object o = container.getComponentInstance(s);
- if (listener.beanLoaded(s, type.cast(o))) {
- return true;
- }
- loaded = true;
- }
- }
-
- try {
- if (context != null) {
- ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
- if (refs != null) {
- for (ServiceReference r : refs) {
- Object o2 = context.getService(r);
- Class<? extends T> t = o2.getClass().asSubclass(type);
- if (listener.loadBean(t.getName(), t)) {
- if (listener.beanLoaded(t.getName(), type.cast(o2))) {
- return true;
- }
- loaded = true;
- }
- }
- }
- }
- } catch (Exception ex) {
- //ignore, just don't support the OSGi services
- LOG.info("Try to find the Bean with type:" + type
- + " from OSGi services and get error: " + ex);
- }
- return orig.loadBeansOfType(type, listener) || loaded;
- }
-
- public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
- ComponentMetadata cmd = getComponentMetadata(beanName);
- if (cmd instanceof BeanMetadata) {
- BeanMetadata br = (BeanMetadata)cmd;
- for (BeanProperty s : br.getProperties()) {
- if (propertyName.equals(s.getName())) {
- return true;
- }
- }
- return false;
- }
- return orig.hasConfiguredPropertyValue(beanName, propertyName, value);
- }
-
- public boolean hasBeanOfName(String name) {
- ComponentMetadata cmd = getComponentMetadata(name);
- if (cmd instanceof BeanMetadata) {
- return true;
- }
- return orig.hasBeanOfName(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
deleted file mode 100644
index e1aeb7f..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
+++ /dev/null
@@ -1,78 +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.blueprint;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.apache.cxf.configuration.ConfiguredBeanLocator;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.resource.ClassLoaderResolver;
-import org.apache.cxf.resource.ResourceManager;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-/**
- *
- */
-public class BlueprintBus extends ExtensionManagerBus {
- BundleContext context;
- BlueprintContainer container;
-
- public BlueprintBus() {
- // Using the BlueprintBus Classloader to load the extensions
- super(null, null, BlueprintBus.class.getClassLoader());
- }
-
- public void setBundleContext(final BundleContext c) {
- context = c;
- ClassLoader bundleClassLoader =
- AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return new BundleDelegatingClassLoader(c.getBundle(),
- this.getClass().getClassLoader());
- }
- });
- super.setExtension(bundleClassLoader, ClassLoader.class);
- // Setup the resource resolver with the bundle classloader
- ResourceManager rm = super.getExtension(ResourceManager.class);
- rm.addResourceResolver(new ClassLoaderResolver(bundleClassLoader));
- super.setExtension(c, BundleContext.class);
- }
- public void setBlueprintContainer(BlueprintContainer con) {
- container = con;
- setExtension(new ConfigurerImpl(con), Configurer.class);
- setExtension(new BlueprintBeanLocator(getExtension(ConfiguredBeanLocator.class), container, context),
- ConfiguredBeanLocator.class);
- }
- @Override
- public String getId() {
- if (id == null) {
- if (context == null) {
- id = super.getId();
- } else {
- id = context.getBundle().getSymbolicName() + "-"
- + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
- }
- }
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
deleted file mode 100644
index 7f5d27c..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
+++ /dev/null
@@ -1,30 +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.blueprint;
-
-public interface BlueprintNameSpaceHandlerFactory {
- /**
- * Creates aries blueprint NamespaceHandler.
- * The return type is untyped as aries blueprint is an
- * optional import
- *
- * @return handler
- */
- Object createNamespaceHandler();
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
deleted file mode 100644
index 8c00dc3..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
+++ /dev/null
@@ -1,133 +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.blueprint;
-
-import java.io.IOException;
-import java.net.URL;
-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.Enumeration;
-
-import org.osgi.framework.Bundle;
-
-/**
- * A ClassLoader delegating to a given OSGi bundle.
- */
-public class BundleDelegatingClassLoader extends ClassLoader {
-
- private final Bundle bundle;
- private final ClassLoader classLoader;
-
- public BundleDelegatingClassLoader(Bundle bundle) {
- this(bundle, null);
- }
-
- public BundleDelegatingClassLoader(Bundle bundle, ClassLoader classLoader) {
- this.bundle = bundle;
- this.classLoader = classLoader;
- }
-
- protected Class<?> findClass(final String name) throws ClassNotFoundException {
- try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- public Class<?> run() throws ClassNotFoundException {
- return bundle.loadClass(name);
- }
- });
- } catch (PrivilegedActionException e) {
- Exception cause = e.getException();
-
- if (cause instanceof ClassNotFoundException) {
- throw (ClassNotFoundException)cause;
- } else {
- throw (RuntimeException)cause;
- }
- }
- }
-
- protected URL findResource(final String name) {
- URL resource = AccessController.doPrivileged(new PrivilegedAction<URL>() {
- public URL run() {
- return bundle.getResource(name);
- }
- });
- if (classLoader != null && resource == null) {
- resource = classLoader.getResource(name);
- }
- return resource;
- }
-
- protected Enumeration<URL> findResources(final String name) throws IOException {
- Enumeration<URL> urls;
- try {
- urls = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
- @SuppressWarnings("unchecked")
- public Enumeration<URL> run() throws IOException {
- return bundle.getResources(name);
- }
-
- });
- } catch (PrivilegedActionException e) {
- Exception cause = e.getException();
-
- if (cause instanceof IOException) {
- throw (IOException)cause;
- } else {
- throw (RuntimeException)cause;
- }
- }
-
- if (urls == null) {
- urls = Collections.enumeration(new ArrayList<URL>());
- }
-
- return urls;
- }
-
- protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- Class<?> clazz;
- try {
- clazz = findClass(name);
- } catch (ClassNotFoundException cnfe) {
- if (classLoader != null) {
- try {
- clazz = classLoader.loadClass(name);
- } catch (ClassNotFoundException e) {
- throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId()
- + " (" + bundle.getSymbolicName() + ")", cnfe);
- }
- } else {
- throw new ClassNotFoundException(name + " from bundle " + bundle.getBundleId()
- + " (" + bundle.getSymbolicName() + ")", cnfe);
- }
- }
- if (resolve) {
- resolveClass(clazz);
- }
- return clazz;
- }
-
- public Bundle getBundle() {
- return bundle;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
deleted file mode 100644
index 2ea3559..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
+++ /dev/null
@@ -1,68 +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.blueprint;
-
-
-import org.w3c.dom.Element;
-
-import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser;
-import org.osgi.service.blueprint.reflect.Metadata;
-
-public class BusDefinitionParser
- extends AbstractBPBeanDefinitionParser {
-
- public BusDefinitionParser() {
- }
-
- public Metadata parse(Element element, ParserContext context) {
- String bname = element.hasAttribute("bus") ? element.getAttribute("bus") : "cxf";
- String id = element.hasAttribute("id") ? element.getAttribute("id") : null;
- MutableBeanMetadata cxfBean = getBus(context, bname);
- parseAttributes(element, context, cxfBean);
- parseChildElements(element, context, cxfBean);
- context.getComponentDefinitionRegistry().removeComponentDefinition(bname);
- if (!StringUtils.isEmpty(id)) {
- cxfBean.addProperty("id", createValue(context, id));
- }
- return cxfBean;
- }
- protected void processBusAttribute(Element element, ParserContext ctx,
- MutableBeanMetadata bean, String val) {
- //nothing
- }
- protected boolean hasBusProperty() {
- return false;
- }
-
-
- @Override
- protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) {
- if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name)
- || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)
- || "features".equals(name)) {
- bean.addProperty(name, parseListData(ctx, bean, el));
- } else if ("properties".equals(name)) {
- bean.addProperty(name, parseMapData(ctx, bean, el));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
deleted file mode 100644
index bf0ce8c..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
+++ /dev/null
@@ -1,186 +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.blueprint;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.configuration.Configurable;
-import org.apache.cxf.configuration.Configurer;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.container.NoSuchComponentException;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-
-/**
- *
- */
-public class ConfigurerImpl implements Configurer {
- private static final Logger LOG = LogUtils.getL7dLogger(ConfigurerImpl.class);
- BlueprintContainer container;
-
- private final Map<String, List<MatcherHolder>> wildCardBeanDefinitions
- = new TreeMap<String, List<MatcherHolder>>();
-
- static class MatcherHolder implements Comparable<MatcherHolder> {
- Matcher matcher;
- String wildCardId;
- MatcherHolder(String orig, Matcher matcher) {
- wildCardId = orig;
- this.matcher = matcher;
- }
- @Override
- public int compareTo(MatcherHolder mh) {
- Integer literalCharsLen1 = this.wildCardId.replaceAll("\\*", "").length();
- Integer literalCharsLen2 = mh.wildCardId.replaceAll("\\*", "").length();
- // The expression with more literal characters should end up on the top of the list
- return literalCharsLen1.compareTo(literalCharsLen2) * -1;
- }
- }
-
-
- public ConfigurerImpl(BlueprintContainer con) {
- container = con;
- initializeWildcardMap();
- }
- private boolean isWildcardBeanName(String bn) {
- return bn.indexOf('*') != -1 || bn.indexOf('?') != -1
- || (bn.indexOf('(') != -1 && bn.indexOf(')') != -1);
- }
-
- private void initializeWildcardMap() {
- for (String s : container.getComponentIds()) {
- if (isWildcardBeanName(s)) {
- ComponentMetadata cmd = container.getComponentMetadata(s);
- Class<?> cls = BlueprintBeanLocator.getClassForMetaData(container, cmd);
- if (cls != null) {
- String orig = s;
- if (s.charAt(0) == '*') {
- //old wildcard
- s = "." + s.replaceAll("\\.", "\\.");
- }
- Matcher matcher = Pattern.compile(s).matcher("");
- List<MatcherHolder> m = wildCardBeanDefinitions.get(cls.getName());
- if (m == null) {
- m = new ArrayList<MatcherHolder>();
- wildCardBeanDefinitions.put(cls.getName(), m);
- }
- MatcherHolder holder = new MatcherHolder(orig, matcher);
- m.add(holder);
- }
- }
- }
- }
-
- public void configureBean(Object beanInstance) {
- configureBean(null, beanInstance, true);
- }
-
- public void configureBean(String bn, Object beanInstance) {
- configureBean(bn, beanInstance, true);
- }
- public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {
- if (null == bn) {
- bn = getBeanName(beanInstance);
- }
-
- if (null == bn) {
- return;
- }
- if (checkWildcards) {
- configureWithWildCard(bn, beanInstance);
- }
-
- if (container instanceof ExtendedBlueprintContainer) {
- ComponentMetadata cm = null;
- try {
- cm = container.getComponentMetadata(bn);
- } catch (NoSuchComponentException nsce) {
- cm = null;
- }
- if (cm instanceof BeanMetadata) {
- ((ExtendedBlueprintContainer)container).injectBeanInstance((BeanMetadata)cm, beanInstance);
- }
- }
- }
-
- private void configureWithWildCard(String bn, Object beanInstance) {
- if (!wildCardBeanDefinitions.isEmpty()) {
- Class<?> clazz = beanInstance.getClass();
- while (!Object.class.equals(clazz)) {
- String className = clazz.getName();
- List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
- if (matchers != null) {
- for (MatcherHolder m : matchers) {
- synchronized (m.matcher) {
- m.matcher.reset(bn);
- if (m.matcher.matches()) {
- configureBean(m.wildCardId, beanInstance, false);
- return;
- }
- }
- }
- }
- clazz = clazz.getSuperclass();
- }
- }
- }
-
- protected String getBeanName(Object beanInstance) {
- if (beanInstance instanceof Configurable) {
- return ((Configurable)beanInstance).getBeanName();
- }
- String beanName = null;
- Method m = null;
- try {
- m = beanInstance.getClass().getDeclaredMethod("getBeanName", (Class[])null);
- } catch (NoSuchMethodException ex) {
- try {
- m = beanInstance.getClass().getMethod("getBeanName", (Class[])null);
- } catch (NoSuchMethodException e) {
- //ignore
- }
- }
- if (m != null) {
- try {
- beanName = (String)(m.invoke(beanInstance));
- } catch (Exception ex) {
- LogUtils.log(LOG, Level.WARNING, "ERROR_DETERMINING_BEAN_NAME_EXC", ex);
- }
- }
-
- if (null == beanName) {
- LogUtils.log(LOG, Level.FINE, "COULD_NOT_DETERMINE_BEAN_NAME_MSG",
- beanInstance.getClass().getName());
- }
-
- return beanName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties b/core/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
deleted file mode 100644
index ed8f59a..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
+++ /dev/null
@@ -1,26 +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.
-#
-#
-NO_MATCHING_BEAN_MSG = Could not find a definition for bean with id {0} - no injection will be performed.
-COULD_NOT_DETERMINE_BEAN_NAME_MSG = Could not determine bean name for instance of class {0}.
-ERROR_DETERMINING_BEAN_NAME_EXC = Failed to determine bean name.
-JAXB_PROPERTY_EDITOR_EXC = Property editor failed to bind element {0}.
-WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG = Configuration bean with id {0} that uses a ''*'' or wildcard must have a class attribute.
-ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG = A wildcard configuration bean with id {0} already exists for class {1}. The wildcard bean with id {2} will be ignored.
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java b/core/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
deleted file mode 100644
index 14d4ced..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
+++ /dev/null
@@ -1,55 +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.blueprint;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.aries.blueprint.NamespaceHandler;
-import org.apache.cxf.common.logging.LogUtils;
-import org.osgi.framework.BundleContext;
-
-public final class NamespaceHandlerRegisterer {
- private static final Logger LOG = LogUtils.getL7dLogger(NamespaceHandlerRegisterer.class);
-
- private NamespaceHandlerRegisterer() {
- }
-
- public static void register(BundleContext bc, BlueprintNameSpaceHandlerFactory factory,
- String... namespaces) {
- try {
- Object handler = factory.createNamespaceHandler();
- for (String namespace : namespaces) {
- Dictionary<String, String> properties = new Hashtable<String, String>();
- properties.put("osgi.service.blueprint.namespace", namespace);
- bc.registerService(NamespaceHandler.class.getName(), handler, properties);
- LOG.fine("Registered blueprint namespace handler for " + namespace);
- }
- } catch (Throwable e) {
- if (e instanceof NoClassDefFoundError) {
- LOG.log(Level.INFO, "Aries Blueprint packages not available. So namespaces will not be registered");
- } else {
- LOG.log(Level.WARNING, "Unexpected exception when trying to install Aries Blueprint namespaces", e);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java b/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
deleted file mode 100644
index c66d136..0000000
--- a/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
+++ /dev/null
@@ -1,131 +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.osgi;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
-import org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer;
-import org.apache.cxf.bus.extension.Extension;
-import org.apache.cxf.bus.extension.ExtensionRegistry;
-import org.apache.cxf.internal.CXFAPINamespaceHandler;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Is called in OSGi on start and stop of the cxf bundle.
- * Manages
- * - CXFBundleListener
- * - Attaching ManagedWorkqueues to config admin service
- * - OsgiBusListener
- * - Blueprint namespaces
- */
-public class CXFActivator implements BundleActivator {
-
- private List<Extension> extensions;
- private ManagedWorkQueueList workQueues;
- private ServiceTracker configAdminTracker;
- private CXFExtensionBundleListener cxfBundleListener;
- private ServiceRegistration workQueueServiceRegistration;
-
-
-
- /** {@inheritDoc}*/
- public void start(BundleContext context) throws Exception {
- workQueues = new ManagedWorkQueueList();
- cxfBundleListener = new CXFExtensionBundleListener(context.getBundle().getBundleId());
- context.addBundleListener(cxfBundleListener);
- cxfBundleListener.registerExistingBundles(context);
-
- configAdminTracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null);
- configAdminTracker.open();
- workQueues.setConfigAdminTracker(configAdminTracker);
- workQueueServiceRegistration = registerManagedServiceFactory(context, ManagedServiceFactory.class,
- workQueues,
- ManagedWorkQueueList.FACTORY_PID);
-
- extensions = new ArrayList<Extension>();
- extensions.add(createOsgiBusListenerExtension(context));
- extensions.add(createManagedWorkQueueListExtension(workQueues));
- ExtensionRegistry.addExtensions(extensions);
-
- BlueprintNameSpaceHandlerFactory factory = new BlueprintNameSpaceHandlerFactory() {
-
- @Override
- public Object createNamespaceHandler() {
- return new CXFAPINamespaceHandler();
- }
- };
- NamespaceHandlerRegisterer.register(context, factory,
- "http://cxf.apache.org/blueprint/core",
- "http://cxf.apache.org/configuration/beans",
- "http://cxf.apache.org/configuration/parameterized-types",
- "http://cxf.apache.org/configuration/security",
- "http://schemas.xmlsoap.org/wsdl/",
- "http://www.w3.org/2005/08/addressing",
- "http://schemas.xmlsoap.org/ws/2004/08/addressing");
-
- }
-
- private ServiceRegistration registerManagedServiceFactory(BundleContext context,
- Class<?> serviceClass,
- Object service,
- String servicePid) {
- Properties props = new Properties();
- props.put(Constants.SERVICE_PID, servicePid);
- return context.registerService(serviceClass.getName(), service, props);
- }
-
- private Extension createOsgiBusListenerExtension(BundleContext context) {
- Extension busListener = new Extension(OSGIBusListener.class);
- busListener.setArgs(new Object[] {context});
- return busListener;
- }
-
- private static Extension createManagedWorkQueueListExtension(final ManagedWorkQueueList workQueues) {
- return new Extension(ManagedWorkQueueList.class) {
- public Object getLoadedObject() {
- return workQueues;
- }
-
- public Extension cloneNoObject() {
- return this;
- }
- };
- }
-
- /** {@inheritDoc}*/
- public void stop(BundleContext context) throws Exception {
- context.removeBundleListener(cxfBundleListener);
- cxfBundleListener.shutdown();
- workQueues.shutDown();
- workQueueServiceRegistration.unregister();
- configAdminTracker.close();
- ExtensionRegistry.removeExtensions(extensions);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java b/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
deleted file mode 100644
index 7713c33..0000000
--- a/core/src/main/java/org/apache/cxf/bus/osgi/CXFExtensionBundleListener.java
+++ /dev/null
@@ -1,178 +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.osgi;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.bus.extension.Extension;
-import org.apache.cxf.bus.extension.ExtensionException;
-import org.apache.cxf.bus.extension.ExtensionRegistry;
-import org.apache.cxf.bus.extension.TextExtensionFragmentParser;
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
-
-public class CXFExtensionBundleListener implements SynchronousBundleListener {
- private static final Logger LOG = LogUtils.getL7dLogger(CXFActivator.class);
- private long id;
- private ConcurrentMap<Long, List<OSGiExtension>> extensions
- = new ConcurrentHashMap<Long, List<OSGiExtension>>(16, 0.75f, 4);
-
- public CXFExtensionBundleListener(long bundleId) {
- this.id = bundleId;
- }
-
- public void registerExistingBundles(BundleContext context) throws IOException {
- for (Bundle bundle : context.getBundles()) {
- if ((bundle.getState() == Bundle.RESOLVED
- || bundle.getState() == Bundle.STARTING
- || bundle.getState() == Bundle.ACTIVE
- || bundle.getState() == Bundle.STOPPING)
- && bundle.getBundleId() != context.getBundle().getBundleId()) {
- register(bundle);
- }
- }
- }
-
- /** {@inheritDoc}*/
- public void bundleChanged(BundleEvent event) {
- if (event.getType() == BundleEvent.RESOLVED && id != event.getBundle().getBundleId()) {
- register(event.getBundle());
- } else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
- unregister(event.getBundle().getBundleId());
- }
- }
-
- protected void register(final Bundle bundle) {
- Enumeration<?> e = bundle.findEntries("META-INF/cxf/", "bus-extensions.txt", false);
- while (e != null && e.hasMoreElements()) {
- List<Extension> orig = new TextExtensionFragmentParser(null).getExtensions((URL)e.nextElement());
- addExtensions(bundle, orig);
- }
- }
-
- private boolean addExtensions(final Bundle bundle, List<Extension> orig) {
- if (orig.isEmpty()) {
- return false;
- }
-
- List<String> names = new ArrayList<String>(orig.size());
- for (Extension ext : orig) {
- names.add(ext.getName());
- }
- LOG.info("Adding the extensions from bundle " + bundle.getSymbolicName()
- + " (" + bundle.getBundleId() + ") " + names);
- List<OSGiExtension> list = extensions.get(bundle.getBundleId());
- if (list == null) {
- list = new CopyOnWriteArrayList<OSGiExtension>();
- List<OSGiExtension> preList = extensions.putIfAbsent(bundle.getBundleId(), list);
- if (preList != null) {
- list = preList;
- }
- }
- for (Extension ext : orig) {
- list.add(new OSGiExtension(ext, bundle));
- }
- ExtensionRegistry.addExtensions(list);
- return !list.isEmpty();
- }
-
- protected void unregister(final long bundleId) {
- List<OSGiExtension> list = extensions.remove(bundleId);
- if (list != null) {
- LOG.info("Removing the extensions for bundle " + bundleId);
- ExtensionRegistry.removeExtensions(list);
- }
- }
-
- public void shutdown() {
- while (!extensions.isEmpty()) {
- unregister(extensions.keySet().iterator().next());
- }
- }
-
- public class OSGiExtension extends Extension {
- final Bundle bundle;
- Object serviceObject;
- public OSGiExtension(Extension e, Bundle b) {
- super(e);
- bundle = b;
- }
-
- public void setServiceObject(Object o) {
- serviceObject = o;
- obj = o;
- }
- public Object load(ClassLoader cl, Bus b) {
- if (interfaceName == null && bundle.getBundleContext() != null) {
- ServiceReference ref = bundle.getBundleContext().getServiceReference(className);
- if (ref != null && ref.getBundle().getBundleId() == bundle.getBundleId()) {
- Object o = bundle.getBundleContext().getService(ref);
- serviceObject = o;
- obj = o;
- return obj;
- }
- }
- return super.load(cl, b);
- }
- protected Class<?> tryClass(String name, ClassLoader cl) {
- Class<?> c = null;
- Throwable origExc = null;
- try {
- c = bundle.loadClass(className);
- } catch (Throwable e) {
- origExc = e;
- }
- if (c == null) {
- try {
- return super.tryClass(name, cl);
- } catch (ExtensionException ee) {
- if (origExc != null) {
- throw new ExtensionException(new Message("PROBLEM_LOADING_EXTENSION_CLASS",
- Extension.LOG, name),
- origExc);
- } else {
- throw ee;
- }
- }
- }
- return c;
- }
-
- public Extension cloneNoObject() {
- OSGiExtension ext = new OSGiExtension(this, bundle);
- ext.obj = serviceObject;
- return ext;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java b/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
deleted file mode 100644
index 36d951b..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
+++ /dev/null
@@ -1,338 +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.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-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) {
- try (InputStream is = r.getInputStream();
- BufferedReader rd = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
- String line = rd.readLine();
- while (line != null) {
- if (!"".equals(line)) {
- resources.add(resolver.getResource(line));
- }
- line = rd.readLine();
- }
- }
- }
-
- } 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/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java b/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
deleted file mode 100644
index 434a851..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
+++ /dev/null
@@ -1,104 +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.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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java b/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
deleted file mode 100644
index 847ce28..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
+++ /dev/null
@@ -1,299 +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.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
-import org.apache.cxf.configuration.spring.BusWiringType;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.message.Message;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-public class BusDefinitionParser extends AbstractBeanDefinitionParser {
- private static AtomicInteger counter = new AtomicInteger(0);
-
- public BusDefinitionParser() {
- super();
- setBeanClass(BusConfig.class);
- }
-
- protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
- String bus = element.getAttribute("bus");
- if (StringUtils.isEmpty(bus)) {
- bus = element.getAttribute("name");
- if (StringUtils.isEmpty(bus)) {
- element.setAttribute("bus", bus);
- }
- }
- element.removeAttribute("name");
- if (StringUtils.isEmpty(bus)) {
- bus = "cxf";
- }
- String id = element.getAttribute("id");
- if (!StringUtils.isEmpty(id)) {
- bean.addPropertyValue("id", id);
- }
-
- super.doParse(element, ctx, bean);
-
- if (ctx.getRegistry().containsBeanDefinition(bus)) {
- BeanDefinition def = ctx.getRegistry().getBeanDefinition(bus);
- copyProps(bean, def);
- bean.addConstructorArgValue(bus);
- } else if (!"cxf".equals(bus)) {
- bean.getRawBeanDefinition().setBeanClass(SpringBus.class);
- bean.setDestroyMethodName("shutdown");
- try {
- element.setUserData("ID", bus, null);
- bean.getRawBeanDefinition().getPropertyValues().removePropertyValue("bus");
- } catch (Throwable t) {
- //likely not DOM level 3, ignore
- }
- } else {
- addBusWiringAttribute(bean, BusWiringType.PROPERTY, bus, ctx);
- bean.getRawBeanDefinition().setAttribute(WIRE_BUS_CREATE,
- resolveId(element, null, ctx));
- bean.addConstructorArgValue(bus);
- }
- }
- protected boolean processBusAttribute(Element element, ParserContext ctx,
- BeanDefinitionBuilder bean,
- String val) {
- return false;
- }
- private void copyProps(BeanDefinitionBuilder src, BeanDefinition def) {
- for (PropertyValue v : src.getBeanDefinition().getPropertyValues().getPropertyValues()) {
- if (!"bus".equals(v.getName())) {
- def.getPropertyValues().addPropertyValue(v.getName(), v.getValue());
- }
- src.getBeanDefinition().getPropertyValues().removePropertyValue(v);
- }
-
- }
-
- @Override
- protected void mapElement(ParserContext ctx,
- BeanDefinitionBuilder bean,
- Element e,
- String name) {
- if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name)
- || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name)
- || "features".equals(name)) {
- List<?> list = ctx.getDelegate().parseListElement(e, bean.getBeanDefinition());
- bean.addPropertyValue(name, list);
- } else if ("properties".equals(name)) {
- Map<?, ?> map = ctx.getDelegate().parseMapElement(e, bean.getBeanDefinition());
- bean.addPropertyValue("properties", map);
- }
- }
- @Override
- protected String resolveId(Element element, AbstractBeanDefinition definition,
- ParserContext ctx) {
- String bus = null;
- try {
- bus = (String)element.getUserData("ID");
- } catch (Throwable t) {
- //ignore
- }
- if (bus == null) {
- bus = element.getAttribute("bus");
- if (StringUtils.isEmpty(bus)) {
- bus = element.getAttribute("name");
- }
- if (StringUtils.isEmpty(bus)) {
- bus = Bus.DEFAULT_BUS_ID + ".config" + counter.getAndIncrement();
- } else {
- bus = bus + ".config";
- }
- try {
- element.setUserData("ID", bus, null);
- } catch (Throwable t) {
- //maybe no DOM level 3, ignore, but, may have issues with the counter
- }
- }
- return bus;
- }
-
- @NoJSR250Annotations
- public static class BusConfig extends AbstractBasicInterceptorProvider
- implements ApplicationContextAware {
-
- Bus bus;
- String busName;
- String id;
- Collection<Feature> features;
- Map<String, Object> properties;
-
- public BusConfig(String busName) {
- this.busName = busName;
- }
-
- public void setBus(Bus bb) {
- if (bus == bb) {
- return;
- }
- if (properties != null) {
- bb.setProperties(properties);
- properties = null;
- }
- if (!getInInterceptors().isEmpty()) {
- bb.getInInterceptors().addAll(getInInterceptors());
- }
- if (!getOutInterceptors().isEmpty()) {
- bb.getOutInterceptors().addAll(getOutInterceptors());
- }
- if (!getInFaultInterceptors().isEmpty()) {
- bb.getInFaultInterceptors().addAll(getInFaultInterceptors());
- }
- if (!getOutFaultInterceptors().isEmpty()) {
- bb.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
- }
- if (!StringUtils.isEmpty(id)) {
- bb.setId(id);
- }
- if (features != null) {
- bb.setFeatures(features);
- features = null;
- }
- bus = bb;
- }
-
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- if (bus != null) {
- return;
- }
- }
-
- public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
- if (bus != null) {
- return bus.getOutFaultInterceptors();
- }
- return super.getOutFaultInterceptors();
- }
-
- public List<Interceptor<? extends Message>> getInFaultInterceptors() {
- if (bus != null) {
- return bus.getInFaultInterceptors();
- }
- return super.getInFaultInterceptors();
- }
-
- public List<Interceptor<? extends Message>> getInInterceptors() {
- if (bus != null) {
- return bus.getInInterceptors();
- }
- return super.getInInterceptors();
- }
-
- public List<Interceptor<? extends Message>> getOutInterceptors() {
- if (bus != null) {
- return bus.getOutInterceptors();
- }
- return super.getOutInterceptors();
- }
-
- public void setInInterceptors(List<Interceptor<? extends Message>> interceptors) {
- if (bus != null) {
- bus.getInInterceptors().addAll(interceptors);
- } else {
- super.setInInterceptors(interceptors);
- }
- }
-
- public void setInFaultInterceptors(List<Interceptor<? extends Message>> interceptors) {
- if (bus != null) {
- bus.getInFaultInterceptors().addAll(interceptors);
- } else {
- super.setInFaultInterceptors(interceptors);
- }
- }
-
- public void setOutInterceptors(List<Interceptor<? extends Message>> interceptors) {
- if (bus != null) {
- bus.getOutInterceptors().addAll(interceptors);
- } else {
- super.setOutInterceptors(interceptors);
- }
- }
-
- public void setOutFaultInterceptors(List<Interceptor<? extends Message>> interceptors) {
- if (bus != null) {
- bus.getOutFaultInterceptors().addAll(interceptors);
- } else {
- super.setOutFaultInterceptors(interceptors);
- }
- }
-
- public Collection<Feature> getFeatures() {
- if (bus != null) {
- return bus.getFeatures();
- }
- return features;
- }
-
- public void setFeatures(Collection<? extends Feature> features) {
- if (bus != null) {
- bus.setFeatures(features);
- } else {
- this.features = CastUtils.cast(features);
- }
-
- }
-
- public Map<String, Object> getProperties() {
- if (bus != null) {
- return bus.getProperties();
- }
- return properties;
- }
- public void setProperties(Map<String, Object> s) {
- if (bus != null) {
- bus.setProperties(s);
- } else {
- this.properties = s;
- }
- }
-
- public void setId(String s) {
- id = s;
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java b/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
deleted file mode 100644
index 65d3ffc..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
+++ /dev/null
@@ -1,89 +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.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.springframework.beans.factory.xml.DelegatingEntityResolver;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PropertiesLoaderUtils;
-import org.springframework.util.CollectionUtils;
-
-/**
- *
- */
-public class BusEntityResolver extends DelegatingEntityResolver {
-
- private static final Logger LOG = LogUtils.getL7dLogger(BusEntityResolver.class);
-
- private EntityResolver dtdResolver;
- private EntityResolver schemaResolver;
- private Map<String, String> schemaMappings;
- private ClassLoader classLoader;
-
- public BusEntityResolver(ClassLoader loader, EntityResolver dr, EntityResolver sr) {
- super(dr, sr);
- classLoader = loader;
- dtdResolver = dr;
- schemaResolver = sr;
-
- try {
- Properties mappings = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.schemas",
- classLoader);
- schemaMappings = new ConcurrentHashMap<String, String>(mappings.size());
- CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
- } catch (IOException e) {
- //ignore
- }
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- InputSource source = super.resolveEntity(publicId, systemId);
- if (null == source && null != systemId) {
- // try the schema and dtd resolver in turn, ignoring the suffix in publicId
- LOG.log(Level.FINE, "Attempting to resolve systemId {0}", systemId);
- source = schemaResolver.resolveEntity(publicId, systemId);
- if (null == source) {
- source = dtdResolver.resolveEntity(publicId, systemId);
- }
- }
- String resourceLocation = schemaMappings.get(systemId);
- if (resourceLocation != null && publicId == null) {
- Resource resource = new ClassPathResource(resourceLocation, classLoader);
- if (resource != null && resource.exists()) {
- source.setPublicId(systemId);
- source.setSystemId(resource.getURL().toString());
- }
- }
- return source;
- }
-}
[2/4] cxf git commit: Experimentally simply remove spring and
blueprint related classes to see how much cxf is tied to it
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
deleted file mode 100644
index 1e34cf0..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ /dev/null
@@ -1,441 +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.blueprint;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-import org.apache.aries.blueprint.ComponentDefinitionRegistry;
-import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.PassThroughMetadata;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.apache.aries.blueprint.mutable.MutableCollectionMetadata;
-import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
-import org.apache.aries.blueprint.mutable.MutableRefMetadata;
-import org.apache.aries.blueprint.mutable.MutableValueMetadata;
-import org.apache.cxf.bus.blueprint.BlueprintBus;
-import org.apache.cxf.common.jaxb.JAXBContextCache;
-import org.apache.cxf.common.jaxb.JAXBContextCache.CachedContextAndSchemas;
-import org.apache.cxf.common.jaxb.JAXBUtils;
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.CollectionMetadata;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.MapMetadata;
-import org.osgi.service.blueprint.reflect.Metadata;
-import org.osgi.service.blueprint.reflect.RefMetadata;
-import org.osgi.service.blueprint.reflect.ValueMetadata;
-
-public abstract class AbstractBPBeanDefinitionParser {
-
- private static final String XMLNS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
- private static final String COMPONENT_ID = "component-id";
-
- private JAXBContext jaxbContext;
- private Set<Class<?>> jaxbClasses;
-
- protected boolean hasBusProperty() {
- return false;
- }
-
- public Metadata createValue(ParserContext context, QName qName) {
- MutableBeanMetadata v = context.createMetadata(MutableBeanMetadata.class);
- v.setRuntimeClass(QName.class);
- v.addArgument(createValue(context, qName.getNamespaceURI()), null, 0);
- v.addArgument(createValue(context, qName.getLocalPart()), null, 1);
- return v;
- }
-
- protected Metadata parseListData(ParserContext context,
- ComponentMetadata enclosingComponent,
- Element element) {
- MutableCollectionMetadata m
- = (MutableCollectionMetadata) context.parseElement(CollectionMetadata.class,
- enclosingComponent, element);
- m.setCollectionClass(List.class);
- return m;
- }
-
- protected Metadata parseMapData(ParserContext context,
- ComponentMetadata enclosingComponent,
- Element element) {
- return context.parseElement(MapMetadata.class, enclosingComponent, element);
- }
-
- protected void setFirstChildAsProperty(Element element,
- ParserContext ctx,
- MutableBeanMetadata bean,
- String propertyName) {
-
- Element first = DOMUtils.getFirstElement(element);
-
- if (first == null) {
- throw new IllegalStateException(propertyName + " property must have child elements!");
- }
-
- String id;
- if (first.getNamespaceURI().equals(XMLNS_BLUEPRINT)) {
- String name = first.getLocalName();
- if ("ref".equals(name)) {
- id = first.getAttribute(COMPONENT_ID);
- if (id == null) {
- throw new IllegalStateException("<ref> elements must have a \"component-id\" attribute!");
- }
- bean.addProperty(propertyName, createRef(ctx, id));
- } else {
- //Rely on BP to handle these ones.
- bean.addProperty(propertyName, ctx.parseElement(Metadata.class, bean, first));
- }
- } else {
- bean.addProperty(propertyName, ctx.parseElement(Metadata.class, bean, first));
- }
- }
-
- public QName parseQName(Element element, String t) {
- String t1 = t;
- String ns = null;
- String pre = null;
- String local = null;
-
- if (t1.startsWith("{")) {
- int i = t1.indexOf('}');
- if (i == -1) {
- throw new RuntimeException("Namespace bracket '{' must having a closing bracket '}'.");
- }
-
- ns = t1.substring(1, i);
- t1 = t1.substring(i + 1);
- }
-
- int colIdx = t1.indexOf(':');
- if (colIdx == -1) {
- local = t1;
- pre = "";
-
- ns = DOMUtils.getNamespace(element, "");
- } else {
- pre = t1.substring(0, colIdx);
- local = t1.substring(colIdx + 1);
-
- ns = DOMUtils.getNamespace(element, pre);
- }
-
- return new QName(ns, local, pre);
- }
-
- protected boolean parseAttributes(Element element, ParserContext ctx, MutableBeanMetadata bean) {
- NamedNodeMap atts = element.getAttributes();
- boolean setBus = false;
- for (int i = 0; i < atts.getLength(); i++) {
- Attr node = (Attr) atts.item(i);
- String val = node.getValue();
- String pre = node.getPrefix();
- String name = node.getLocalName();
- String prefix = node.getPrefix();
-
- // Don't process namespaces
- if (isNamespace(name, prefix)) {
- continue;
- }
-
- if ("createdFromAPI".equals(name) || "abstract".equals(name)) {
- bean.setScope(BeanMetadata.SCOPE_PROTOTYPE);
- } else {
- if ("depends-on".equals(name)) {
- bean.addDependsOn(val);
- } else if ("name".equals(name)) {
- processNameAttribute(element, ctx, bean, val);
- } else if ("bus".equals(name)) {
- processBusAttribute(element, ctx, bean, val);
- } else if (!"id".equals(name) && isAttribute(pre, name)) {
- mapAttribute(bean, element, name, val, ctx);
- }
- }
- }
- return setBus;
- }
- protected void processBusAttribute(Element element, ParserContext ctx,
- MutableBeanMetadata bean, String val) {
- if (this.hasBusProperty()) {
- bean.addProperty("bus", getBusRef(ctx, val));
- } else {
- bean.addArgument(getBusRef(ctx, val), null, 0);
- }
- }
-
- protected void processNameAttribute(Element element,
- ParserContext ctx,
- MutableBeanMetadata bean,
- String val) {
- //nothing
- }
- protected void mapAttribute(MutableBeanMetadata bean, Element e,
- String name, String val, ParserContext context) {
- mapToProperty(bean, name, val, context);
- }
-
- protected boolean isAttribute(String pre, String name) {
- return !"xmlns".equals(name) && (pre == null || !pre.equals("xmlns"))
- && !"abstract".equals(name) && !"lazy-init".equals(name)
- && !"id".equals(name);
- }
-
- protected boolean isNamespace(String name, String prefix) {
- return "xmlns".equals(prefix) || prefix == null && "xmlns".equals(name);
- }
-
- protected void mapElement(ParserContext ctx, MutableBeanMetadata bean, Element el, String name) {
- }
-
- protected void mapToProperty(MutableBeanMetadata bean,
- String propertyName,
- String val,
- ParserContext context) {
- if ("id".equals(propertyName)) {
- return;
- }
-
- if (!StringUtils.isEmpty(val)) {
- if (val.startsWith("#")) {
- bean.addProperty(propertyName, createRef(context, val.substring(1)));
- } else {
- bean.addProperty(propertyName, createValue(context, val));
- }
- }
- }
-
- public static ValueMetadata createValue(ParserContext context, String value) {
- MutableValueMetadata v = context.createMetadata(MutableValueMetadata.class);
- v.setStringValue(value);
- return v;
- }
-
- public static RefMetadata createRef(ParserContext context, String value) {
- MutableRefMetadata r = context.createMetadata(MutableRefMetadata.class);
- r.setComponentId(value);
- return r;
- }
-
- public static PassThroughMetadata createPassThrough(ParserContext context, Object value) {
- MutablePassThroughMetadata v = context.createMetadata(MutablePassThroughMetadata.class);
- v.setObject(value);
- return v;
- }
-
- public static MutableBeanMetadata createObjectOfClass(ParserContext context, String value) {
- MutableBeanMetadata v = context.createMetadata(MutableBeanMetadata.class);
- v.setClassName(value);
- return v;
- }
-
- protected MutableBeanMetadata getBus(ParserContext context, String name) {
- ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
- ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
-
- if (!cdr.containsComponentDefinition(InterceptorTypeConverter.class.getName())) {
- MutablePassThroughMetadata md = context.createMetadata(MutablePassThroughMetadata.class);
- md.setObject(new InterceptorTypeConverter());
-
- md.setId(InterceptorTypeConverter.class.getName());
- context.getComponentDefinitionRegistry().registerTypeConverter(md);
- }
- if (!cdr.containsComponentDefinition(name)) {
- //Create a bus
-
- MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
- bus.setId(name);
- bus.setRuntimeClass(BlueprintBus.class);
- if (meta != null) {
- //blueprint-no-osgi does not provide a bundleContext
- bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
- }
- bus.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
- bus.setDestroyMethod("shutdown");
- bus.setInitMethod("initialize");
-
- context.getComponentDefinitionRegistry().registerComponentDefinition(bus);
-
- return bus;
- }
- return (MutableBeanMetadata) cdr.getComponentDefinition(name);
- }
-
- protected RefMetadata getBusRef(ParserContext context, String name) {
- if ("cxf".equals(name)) {
- getBus(context, name);
- }
- return createRef(context, name);
- }
-
- protected void parseChildElements(Element element, ParserContext ctx, MutableBeanMetadata bean) {
- Element el = DOMUtils.getFirstElement(element);
- while (el != null) {
- String name = el.getLocalName();
- mapElement(ctx, bean, el, name);
- el = DOMUtils.getNextElement(el);
- }
- }
-
- protected void mapElementToJaxbProperty(ParserContext ctx,
- MutableBeanMetadata bean, Element parent,
- QName name,
- String propertyName,
- Class<?> c) {
- Element data = DOMUtils.getFirstChildWithName(parent, name);
- if (data == null) {
- return;
- }
-
- mapElementToJaxbProperty(ctx, bean, data, propertyName, c);
- }
-
- public static class JAXBBeanFactory {
- final JAXBContext ctx;
- final Class<?> cls;
- public JAXBBeanFactory(JAXBContext c, Class<?> c2) {
- ctx = c;
- cls = c2;
- }
-
-
- public Object createJAXBBean(String v) {
- XMLStreamReader reader = StaxUtils.createXMLStreamReader(new StringReader(v));
- try {
- Object o = JAXBUtils.unmarshall(ctx, reader, cls);
- if (o instanceof JAXBElement<?>) {
- JAXBElement<?> el = (JAXBElement<?>)o;
- o = el.getValue();
- }
- return o;
- } catch (JAXBException e) {
- throw new RuntimeException(e);
- } finally {
- try {
- reader.close();
- } catch (XMLStreamException e) {
- //ignore
- }
- }
- }
- }
-
- protected void mapElementToJaxbProperty(ParserContext ctx,
- MutableBeanMetadata bean,
- Element data,
- String propertyName,
- Class<?> c) {
- try {
- XMLStreamWriter xmlWriter = null;
- Unmarshaller u = null;
- try {
- StringWriter writer = new StringWriter();
- xmlWriter = StaxUtils.createXMLStreamWriter(writer);
- StaxUtils.copy(data, xmlWriter);
- xmlWriter.flush();
-
-
- MutableBeanMetadata factory = ctx.createMetadata(MutableBeanMetadata.class);
- factory.setClassName(c.getName());
- factory.setFactoryComponent(createPassThrough(ctx, new JAXBBeanFactory(getContext(c), c)));
- factory.setFactoryMethod("createJAXBBean");
- factory.addArgument(createValue(ctx, writer.toString()), String.class.getName(), 0);
- bean.addProperty(propertyName, factory);
-
- } catch (Exception ex) {
- u = getContext(c).createUnmarshaller();
- u.setEventHandler(null);
- Object obj;
- if (c != null) {
- obj = u.unmarshal(data, c);
- } else {
- obj = u.unmarshal(data);
- }
- if (obj instanceof JAXBElement<?>) {
- JAXBElement<?> el = (JAXBElement<?>)obj;
- obj = el.getValue();
- }
- if (obj != null) {
- MutablePassThroughMetadata value = ctx.createMetadata(MutablePassThroughMetadata.class);
- value.setObject(obj);
- bean.addProperty(propertyName, value);
- }
- } finally {
- StaxUtils.close(xmlWriter);
- JAXBUtils.closeUnmarshaller(u);
- }
- } catch (JAXBException e) {
- throw new RuntimeException("Could not parse configuration.", e);
- }
- }
-
-
- protected synchronized JAXBContext getContext(Class<?> cls) {
- if (jaxbContext == null || jaxbClasses == null || !jaxbClasses.contains(cls)) {
- try {
- Set<Class<?>> tmp = new HashSet<Class<?>>();
- if (jaxbClasses != null) {
- tmp.addAll(jaxbClasses);
- }
- JAXBContextCache.addPackage(tmp, PackageUtils.getPackageName(cls),
- cls == null
- ? getClass().getClassLoader()
- : cls.getClassLoader());
- if (cls != null) {
- boolean hasOf = false;
- for (Class<?> c : tmp) {
- if (c.getPackage() == cls.getPackage()
- && "ObjectFactory".equals(c.getSimpleName())) {
- hasOf = true;
- }
- }
- if (!hasOf) {
- tmp.add(cls);
- }
- }
- JAXBContextCache.scanPackages(tmp);
- CachedContextAndSchemas ccs
- = JAXBContextCache.getCachedContextAndSchemas(tmp, null, null, null, false);
- jaxbClasses = ccs.getClasses();
- jaxbContext = ccs.getContext();
- } catch (JAXBException e) {
- throw new RuntimeException(e);
- }
- }
- return jaxbContext;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java b/core/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
deleted file mode 100644
index fca633c..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
+++ /dev/null
@@ -1,42 +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.blueprint;
-
-import org.apache.cxf.interceptor.Interceptor;
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.blueprint.container.ReifiedType;
-
-/**
- *
- */
-public class InterceptorTypeConverter implements Converter {
-
- /** {@inheritDoc}*/
- public boolean canConvert(Object sourceObject, ReifiedType targetType) {
- return sourceObject instanceof Interceptor
- && targetType.getRawClass().isInstance(sourceObject);
- }
-
- /** {@inheritDoc}*/
- public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
- return sourceObject;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
deleted file mode 100644
index 77ce8b3..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
+++ /dev/null
@@ -1,87 +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.blueprint;
-
-import org.w3c.dom.Element;
-
-import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.osgi.service.blueprint.reflect.BeanProperty;
-import org.osgi.service.blueprint.reflect.Metadata;
-
-/**
- *
- */
-public class SimpleBPBeanDefinitionParser extends AbstractBPBeanDefinitionParser {
- protected Class<?> cls;
-
- public SimpleBPBeanDefinitionParser(Class<?> cls) {
- this.cls = cls;
- }
-
- public String getFactorySuffix() {
- return null;
- }
- public String getFactoryCreateType(Element element) {
- return null;
- }
-
- public String getId(Element element, ParserContext context) {
- return element.hasAttribute("id") ? element.getAttribute("id") : null;
- }
-
- public Metadata parse(Element element, ParserContext context) {
-
- MutableBeanMetadata cxfBean = context.createMetadata(MutableBeanMetadata.class);
- cxfBean.setRuntimeClass(cls);
- String fact = getFactorySuffix();
- if (fact == null) {
- cxfBean.setId(getId(element, context));
- } else {
- cxfBean.setId(getId(element, context) + fact);
- }
- parseAttributes(element, context, cxfBean);
- parseChildElements(element, context, cxfBean);
- if (hasBusProperty()) {
- boolean foundBus = false;
- for (BeanProperty bp : cxfBean.getProperties()) {
- if ("bus".equals(bp.getName())) {
- foundBus = true;
- }
- }
- if (!foundBus) {
- cxfBean.addProperty("bus", getBusRef(context, "cxf"));
- }
- }
- if (fact != null) {
- context.getComponentDefinitionRegistry().registerComponentDefinition(cxfBean);
-
- MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
- bean.setId(getId(element, context));
- bean.setFactoryComponent(cxfBean);
- bean.setFactoryMethod("create");
- bean.setClassName(getFactoryCreateType(element));
- return bean;
- }
- return cxfBean;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
deleted file mode 100644
index e6e55de..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
+++ /dev/null
@@ -1,533 +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.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.logging.Logger;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-import org.apache.cxf.common.jaxb.JAXBContextCache;
-import org.apache.cxf.common.jaxb.JAXBContextCache.CachedContextAndSchemas;
-import org.apache.cxf.common.jaxb.JAXBUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanDefinitionHolder;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
-import org.springframework.beans.factory.xml.ParserContext;
-
-public abstract class AbstractBeanDefinitionParser
- extends org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser {
- public static final String WIRE_BUS_ATTRIBUTE = AbstractBeanDefinitionParser.class.getName() + ".wireBus";
- public static final String WIRE_BUS_NAME = AbstractBeanDefinitionParser.class.getName() + ".wireBusName";
- public static final String WIRE_BUS_CREATE
- = AbstractBeanDefinitionParser.class.getName() + ".wireBusCreate";
- public static final String WIRE_BUS_HANDLER
- = "org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor";
- private static final Logger LOG = LogUtils.getL7dLogger(AbstractBeanDefinitionParser.class);
-
- private Class<?> beanClass;
- private JAXBContext context;
- private Set<Class<?>> classes;
-
- public AbstractBeanDefinitionParser() {
- }
-
- @Override
- protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
- boolean setBus = parseAttributes(element, ctx, bean);
- if (!setBus && hasBusProperty()) {
- addBusWiringAttribute(bean, BusWiringType.PROPERTY);
- }
- parseChildElements(element, ctx, bean);
- }
-
- protected boolean parseAttributes(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
- NamedNodeMap atts = element.getAttributes();
- boolean setBus = false;
- for (int i = 0; i < atts.getLength(); i++) {
- Attr node = (Attr) atts.item(i);
-
- setBus |= parseAttribute(element, node, ctx, bean);
- }
- return setBus;
- }
- protected boolean parseAttribute(Element element, Attr node,
- ParserContext ctx, BeanDefinitionBuilder bean) {
- String val = node.getValue();
- String pre = node.getPrefix();
- String name = node.getLocalName();
- String prefix = node.getPrefix();
-
- // Don't process namespaces
- if (isNamespace(name, prefix)) {
- return false;
- }
-
- if ("createdFromAPI".equals(name)) {
- bean.setAbstract(true);
- } else if ("abstract".equals(name)) {
- bean.setAbstract(true);
- } else if ("depends-on".equals(name)) {
- bean.addDependsOn(val);
- } else if ("name".equals(name)) {
- processNameAttribute(element, ctx, bean, val);
- } else if ("bus".equals(name)) {
- return processBusAttribute(element, ctx, bean, val);
- } else if (!"id".equals(name) && isAttribute(pre, name)) {
- mapAttribute(bean, element, name, val);
- }
- return false;
- }
-
-
- protected boolean processBusAttribute(Element element, ParserContext ctx,
- BeanDefinitionBuilder bean,
- String val) {
- if (val != null && val.trim().length() > 0) {
- if (ctx.getRegistry().containsBeanDefinition(val)) {
- bean.addPropertyReference("bus", val);
- } else {
- addBusWiringAttribute(bean, BusWiringType.PROPERTY,
- val, ctx);
- }
- return true;
- }
- return false;
- }
-
- protected void processNameAttribute(Element element,
- ParserContext ctx,
- BeanDefinitionBuilder bean,
- String val) {
- //nothing
- }
-
- private boolean isNamespace(String name, String prefix) {
- return "xmlns".equals(prefix) || prefix == null && "xmlns".equals(name);
- }
-
- protected void parseChildElements(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
- Element el = DOMUtils.getFirstElement(element);
- while (el != null) {
- String name = el.getLocalName();
- mapElement(ctx, bean, el, name);
- el = DOMUtils.getNextElement(el);
- }
- }
-
- public Class<?> getBeanClass() {
- return beanClass;
- }
-
- public void setBeanClass(Class<?> beanClass) {
- this.beanClass = beanClass;
- }
-
- @Override
- protected Class<?> getBeanClass(Element e) {
- return beanClass;
- }
-
- protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String val) {
- mapAttribute(bean, name, val);
- }
-
- protected void mapAttribute(BeanDefinitionBuilder bean, String name, String val) {
- mapToProperty(bean, name, val);
- }
-
- protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element e, String name) {
- }
-
- @Override
- protected String resolveId(Element elem, AbstractBeanDefinition definition,
- ParserContext ctx) throws BeanDefinitionStoreException {
-
- // REVISIT: use getAttributeNS instead
-
- String id = getIdOrName(elem);
- String createdFromAPI = elem.getAttribute("createdFromAPI");
-
- if (null == id || "".equals(id)) {
- return super.resolveId(elem, definition, ctx);
- }
-
- if (createdFromAPI != null && "true".equals(createdFromAPI.toLowerCase())) {
- return id + getSuffix();
- }
- return id;
- }
-
- protected boolean hasBusProperty() {
- return false;
- }
-
- protected String getSuffix() {
- return "";
- }
-
- protected void setFirstChildAsProperty(Element element, ParserContext ctx,
- BeanDefinitionBuilder bean, String propertyName) {
-
- Element first = getFirstChild(element);
-
- if (first == null) {
- throw new IllegalStateException(propertyName + " property must have child elements!");
- }
-
- String id;
- BeanDefinition child;
- if (first.getNamespaceURI().equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) {
- String name = first.getLocalName();
- if ("ref".equals(name)) {
- id = first.getAttribute("bean");
- if (id == null) {
- throw new IllegalStateException("<ref> elements must have a \"bean\" attribute!");
- }
- bean.addPropertyReference(propertyName, id);
- return;
- } else if ("bean".equals(name)) {
- BeanDefinitionHolder bdh = ctx.getDelegate().parseBeanDefinitionElement(first);
- child = bdh.getBeanDefinition();
- bean.addPropertyValue(propertyName, child);
- return;
- } else {
- throw new UnsupportedOperationException("Elements with the name " + name
- + " are not currently "
- + "supported as sub elements of "
- + element.getLocalName());
- }
- }
- child = ctx.getDelegate().parseCustomElement(first, bean.getBeanDefinition());
- bean.addPropertyValue(propertyName, child);
- }
-
- protected Element getFirstChild(Element element) {
- return DOMUtils.getFirstElement(element);
- }
-
- protected void addBusWiringAttribute(BeanDefinitionBuilder bean,
- BusWiringType type) {
- addBusWiringAttribute(bean, type, null, null);
- }
-
- protected void addBusWiringAttribute(BeanDefinitionBuilder bean,
- BusWiringType type,
- String busName,
- ParserContext ctx) {
- LOG.fine("Adding " + WIRE_BUS_ATTRIBUTE + " attribute " + type + " to bean " + bean);
- bean.getRawBeanDefinition().setAttribute(WIRE_BUS_ATTRIBUTE, type);
- if (!StringUtils.isEmpty(busName)) {
- if (busName.charAt(0) == '#') {
- busName = busName.substring(1);
- }
- bean.getRawBeanDefinition().setAttribute(WIRE_BUS_NAME, busName);
- }
-
- if (ctx != null
- && !ctx.getRegistry().containsBeanDefinition(WIRE_BUS_HANDLER)) {
- BeanDefinitionBuilder b
- = BeanDefinitionBuilder.rootBeanDefinition(WIRE_BUS_HANDLER);
- ctx.getRegistry().registerBeanDefinition(WIRE_BUS_HANDLER, b.getBeanDefinition());
- }
- }
-
- protected void mapElementToJaxbProperty(Element parent,
- BeanDefinitionBuilder bean,
- QName name,
- String propertyName) {
- mapElementToJaxbProperty(parent, bean, name, propertyName, null);
- }
-
- protected void mapElementToJaxbProperty(Element parent,
- BeanDefinitionBuilder bean,
- QName name,
- String propertyName,
- Class<?> c) {
- Element data = null;
-
- Node node = parent.getFirstChild();
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE && name.getLocalPart().equals(node.getLocalName())
- && name.getNamespaceURI().equals(node.getNamespaceURI())) {
- data = (Element)node;
- break;
- }
- node = node.getNextSibling();
- }
-
- if (data == null) {
- return;
- }
- mapElementToJaxbProperty(data, bean, propertyName, c);
- }
-
- private synchronized JAXBContext getContext(Class<?> cls) {
- if (context == null || classes == null || !classes.contains(cls)) {
- try {
- Set<Class<?>> tmp = new HashSet<Class<?>>();
- if (classes != null) {
- tmp.addAll(classes);
- }
- JAXBContextCache.addPackage(tmp, getJaxbPackage(),
- cls == null
- ? getClass().getClassLoader()
- : cls.getClassLoader());
- if (cls != null) {
- boolean hasOf = false;
- for (Class<?> c : tmp) {
- if (c.getPackage() == cls.getPackage()
- && "ObjectFactory".equals(c.getSimpleName())) {
- hasOf = true;
- }
- }
- if (!hasOf) {
- tmp.add(cls);
- }
- }
- JAXBContextCache.scanPackages(tmp);
- CachedContextAndSchemas ccs
- = JAXBContextCache.getCachedContextAndSchemas(tmp, null, null, null, false);
- classes = ccs.getClasses();
- context = ccs.getContext();
- } catch (JAXBException e) {
- throw new RuntimeException(e);
- }
- }
- return context;
- }
-
- protected void mapElementToJaxbProperty(Element data,
- BeanDefinitionBuilder bean,
- String propertyName,
- Class<?> c) {
- try {
- XMLStreamWriter xmlWriter = null;
- Unmarshaller u = null;
- try {
- StringWriter writer = new StringWriter();
- xmlWriter = StaxUtils.createXMLStreamWriter(writer);
- StaxUtils.copy(data, xmlWriter);
- xmlWriter.flush();
-
- BeanDefinitionBuilder jaxbbean
- = BeanDefinitionBuilder.rootBeanDefinition(JAXBBeanFactory.class);
- jaxbbean.getRawBeanDefinition().setFactoryMethodName("createJAXBBean");
- jaxbbean.addConstructorArgValue(getContext(c));
- jaxbbean.addConstructorArgValue(writer.toString());
- jaxbbean.addConstructorArgValue(c);
- bean.addPropertyValue(propertyName, jaxbbean.getBeanDefinition());
- } catch (Exception ex) {
- u = getContext(c).createUnmarshaller();
- u.setEventHandler(null);
- Object obj;
- if (c != null) {
- obj = u.unmarshal(data, c);
- } else {
- obj = u.unmarshal(data);
- }
- if (obj instanceof JAXBElement<?>) {
- JAXBElement<?> el = (JAXBElement<?>)obj;
- obj = el.getValue();
- }
- if (obj != null) {
- bean.addPropertyValue(propertyName, obj);
- }
- } finally {
- StaxUtils.close(xmlWriter);
- JAXBUtils.closeUnmarshaller(u);
- }
- } catch (JAXBException e) {
- throw new RuntimeException("Could not parse configuration.", e);
- }
- }
-
-
- public void mapElementToJaxbPropertyFactory(Element data,
- BeanDefinitionBuilder bean,
- String propertyName,
- Class<?> type,
- Class<?> factory,
- String method,
- Object ... args) {
- bean.addPropertyValue(propertyName, mapElementToJaxbBean(data,
- factory,
- null, type, method, args));
- }
- public AbstractBeanDefinition mapElementToJaxbBean(Element data,
- Class<?> cls,
- Class<?> factory,
- String method,
- Object ... args) {
- return mapElementToJaxbBean(data, cls, factory, cls, method, args);
- }
-
- public AbstractBeanDefinition mapElementToJaxbBean(Element data,
- Class<?> cls,
- Class<?> factory,
- Class<?> jaxbClass,
- String method,
- Object ... args) {
- StringWriter writer = new StringWriter();
- XMLStreamWriter xmlWriter = StaxUtils.createXMLStreamWriter(writer);
- try {
- StaxUtils.copy(data, xmlWriter);
- xmlWriter.flush();
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- } finally {
- StaxUtils.close(xmlWriter);
- }
-
- BeanDefinitionBuilder jaxbbean
- = BeanDefinitionBuilder.rootBeanDefinition(cls);
- if (factory != null) {
- jaxbbean.getRawBeanDefinition().setFactoryBeanName(factory.getName());
- }
- jaxbbean.getRawBeanDefinition().setFactoryMethodName(method);
- jaxbbean.addConstructorArgValue(writer.toString());
- jaxbbean.addConstructorArgValue(getContext(jaxbClass));
- if (args != null) {
- for (Object o : args) {
- jaxbbean.addConstructorArgValue(o);
- }
- }
- return jaxbbean.getBeanDefinition();
- }
-
- protected static <T> T unmarshalFactoryString(String s, JAXBContext ctx, Class<T> cls) {
- StringReader reader = new StringReader(s);
- XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
- Unmarshaller u = null;
- try {
- u = ctx.createUnmarshaller();
- JAXBElement<?> obj = u.unmarshal(data, cls);
- return cls.cast(obj.getValue());
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- try {
- StaxUtils.close(data);
- } catch (XMLStreamException ex) {
- throw new RuntimeException(ex);
- }
- JAXBUtils.closeUnmarshaller(u);
- }
- }
-
- protected String getJaxbPackage() {
- return "";
- }
-
- protected void mapToProperty(BeanDefinitionBuilder bean, String propertyName, String val) {
- if (ID_ATTRIBUTE.equals(propertyName)) {
- return;
- }
-
- if (!StringUtils.isEmpty(val)) {
- if (val.startsWith("#") && !val.startsWith("#{")) {
- bean.addPropertyReference(propertyName, val.substring(1));
- } else {
- bean.addPropertyValue(propertyName, val);
- }
- }
- }
-
- protected boolean isAttribute(String pre, String name) {
- return !"xmlns".equals(name) && (pre == null || !pre.equals("xmlns"))
- && !"abstract".equals(name) && !"lazy-init".equals(name) && !"id".equals(name);
- }
-
- protected QName parseQName(Element element, String t) {
- String ns = null;
- String pre = null;
- String local = null;
-
- if (t.startsWith("{")) {
- int i = t.indexOf('}');
- if (i == -1) {
- throw new RuntimeException("Namespace bracket '{' must having a closing bracket '}'.");
- }
-
- ns = t.substring(1, i);
- t = t.substring(i + 1);
- }
-
- int colIdx = t.indexOf(':');
- if (colIdx == -1) {
- local = t;
- pre = "";
-
- ns = DOMUtils.getNamespace(element, "");
- } else {
- pre = t.substring(0, colIdx);
- local = t.substring(colIdx + 1);
-
- ns = DOMUtils.getNamespace(element, pre);
- }
-
- return new QName(ns, local, pre);
- }
-
- /* This id-or-name resolution logic follows that in Spring's
- * org.springframework.beans.factory.xml.BeanDefinitionParserDelegate object
- * Intent is to have resolution of CXF custom beans follow that of Spring beans
- */
- protected String getIdOrName(Element elem) {
- String id = elem.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
-
- if (null == id || "".equals(id)) {
- String names = elem.getAttribute("name");
- if (null != names) {
- StringTokenizer st =
- new StringTokenizer(names, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);
- if (st.countTokens() > 0) {
- id = st.nextToken();
- }
- }
- }
- return id;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
deleted file mode 100644
index b8ab25d..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
+++ /dev/null
@@ -1,153 +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 org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-import org.apache.cxf.common.util.StringUtils;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.xml.ParserContext;
-
-/**
- * This class makes it easy to create two simultaneous beans - a factory bean and the bean
- * that the factory produces.
- */
-public abstract class AbstractFactoryBeanDefinitionParser extends AbstractBeanDefinitionParser {
- private static boolean factoriesAreAbstract = true;
- public static void setFactoriesAreAbstract(boolean b) {
- factoriesAreAbstract = b;
- }
-
- protected String getDestroyMethod() {
- return null;
- }
-
- @Override
- protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
- Class<?> factoryClass = getFactoryClass();
- BeanDefinitionBuilder factoryBean = bean;
- if (!FactoryBean.class.isAssignableFrom(factoryClass)) {
- factoryBean = BeanDefinitionBuilder.rootBeanDefinition(getFactoryClass());
- }
-
- NamedNodeMap atts = element.getAttributes();
- boolean createdFromAPI = false;
- boolean setBus = false;
- for (int i = 0; i < atts.getLength(); i++) {
- Attr node = (Attr) atts.item(i);
- String val = node.getValue();
- String pre = node.getPrefix();
- String name = node.getLocalName();
-
- if ("createdFromAPI".equals(name)) {
- factoryBean.setAbstract(true);
- bean.setAbstract(true);
- createdFromAPI = true;
- } else if ("abstract".equals(name)) {
- factoryBean.setAbstract(true);
- bean.setAbstract(true);
- } else if ("depends-on".equals(name)) {
- factoryBean.addDependsOn(val);
- bean.addDependsOn(val);
- } else if (!"id".equals(name) && !"name".equals(name) && isAttribute(pre, name)) {
- if ("bus".equals(name)) {
- setBus = true;
- if (!val.startsWith("#")) {
- //bus attributes always need to be a reference
- val = "#" + val;
- }
- }
- mapAttribute(factoryBean, element, name, val);
- }
- }
-
- if (!setBus) {
- addBusWiringAttribute(factoryBean, BusWiringType.PROPERTY);
- }
-
- Node node = element.getFirstChild();
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String name = node.getLocalName();
- mapElement(ctx, factoryBean, (Element) node, name);
- }
- node = node.getNextSibling();
- }
-
- String id = getIdOrName(element);
- BeanDefinition container = ctx.getContainingBeanDefinition();
- boolean noFactory = false;
- if (StringUtils.isEmpty(id)) {
- if (container == null) {
- id = BeanDefinitionReaderUtils.generateBeanName(bean.getBeanDefinition(),
- ctx.getRegistry(),
- false);
- } else {
- id = BeanDefinitionReaderUtils.generateBeanName(bean.getBeanDefinition(),
- ctx.getRegistry(),
- true);
- noFactory = true;
- //inner bean, no need for the factory to be public at all
- }
- }
- if (createdFromAPI) {
- id = id + getSuffix();
- }
-
- if (FactoryBean.class.isAssignableFrom(getFactoryClass())) {
- if (!noFactory) {
- AbstractBeanDefinition def = factoryBean.getRawBeanDefinition().cloneBeanDefinition();
- def.setBeanClass(getRawFactoryClass());
- def.setAbstract(factoriesAreAbstract);
- def.setLazyInit(true);
- ctx.getRegistry().registerBeanDefinition(id + getFactoryIdSuffix(),
- def);
- }
- bean.getBeanDefinition().setAttribute("id", id);
- } else {
- String factoryId = id + getFactoryIdSuffix();
- ctx.getRegistry().registerBeanDefinition(factoryId, factoryBean.getBeanDefinition());
- bean.getRawBeanDefinition().setAttribute("id", id);
- bean.getRawBeanDefinition().setFactoryBeanName(factoryId);
- bean.getRawBeanDefinition().setFactoryMethodName("create");
- }
- if (getDestroyMethod() != null) {
- bean.setDestroyMethodName(getDestroyMethod());
- }
- }
-
- protected abstract Class<?> getFactoryClass();
-
- protected Class<?> getRawFactoryClass() {
- return getFactoryClass();
- }
-
- /**
- * @return The Spring ID of the factory bean.
- */
- protected abstract String getFactoryIdSuffix();
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java b/core/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
deleted file mode 100644
index 4a7042a..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
+++ /dev/null
@@ -1,37 +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;
-
-/**
- * Enumeration for the ways in which the CXF bus can be wired into a Spring
- * bean.
- */
-public enum BusWiringType {
- /**
- * Wire the bus into the <code>bus</code> property of the target bean.
- */
- PROPERTY,
-
- /**
- * Wire the bus into the first indexed constructor argument of the target
- * bean.
- */
- CONSTRUCTOR
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java b/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
deleted file mode 100644
index 2e0de2a..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
+++ /dev/null
@@ -1,289 +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.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.configuration.Configurable;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.extension.BusExtension;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.support.AbstractBeanFactory;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
-import org.springframework.beans.factory.wiring.BeanWiringInfo;
-import org.springframework.beans.factory.wiring.BeanWiringInfoResolver;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ConfigurableApplicationContext;
-
-@NoJSR250Annotations
-public class ConfigurerImpl extends BeanConfigurerSupport
- implements Configurer, ApplicationContextAware, BusExtension {
-
- private static final Logger LOG = LogUtils.getL7dLogger(ConfigurerImpl.class);
-
- private Set<ApplicationContext> appContexts;
- private final Map<String, List<MatcherHolder>> wildCardBeanDefinitions
- = new TreeMap<String, List<MatcherHolder>>();
- private BeanFactory beanFactory;
-
- static class MatcherHolder implements Comparable<MatcherHolder> {
- Matcher matcher;
- String wildCardId;
- MatcherHolder(String orig, Matcher matcher) {
- wildCardId = orig;
- this.matcher = matcher;
- }
- @Override
- public int compareTo(MatcherHolder mh) {
- Integer literalCharsLen1 = this.wildCardId.replaceAll("\\*", "").length();
- Integer literalCharsLen2 = mh.wildCardId.replaceAll("\\*", "").length();
- // The expression with more literal characters should end up on the top of the list
- return literalCharsLen1.compareTo(literalCharsLen2) * -1;
- }
- }
-
- public ConfigurerImpl() {
- // complete
- }
-
- public ConfigurerImpl(ApplicationContext ac) {
- setApplicationContext(ac);
- }
-
- public void setBeanFactory(BeanFactory beanFactory) {
- this.beanFactory = beanFactory;
- super.setBeanFactory(beanFactory);
- }
-
- private void initWildcardDefinitionMap() {
- if (null != appContexts) {
- for (ApplicationContext appContext : appContexts) {
- for (String n : appContext.getBeanDefinitionNames()) {
- if (isWildcardBeanName(n)) {
- AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
- BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
- BeanDefinition bd = bdr.getBeanDefinition(n);
- String className = bd.getBeanClassName();
- if (null != className) {
- String orig = n;
- if (n.charAt(0) == '*') {
- //old wildcard
- n = "." + n.replaceAll("\\.", "\\.");
- }
- try {
- Matcher matcher = Pattern.compile(n).matcher("");
- List<MatcherHolder> m = wildCardBeanDefinitions.get(className);
- if (m == null) {
- m = new ArrayList<MatcherHolder>();
- wildCardBeanDefinitions.put(className, m);
- }
- MatcherHolder holder = new MatcherHolder(orig, matcher);
- m.add(holder);
- } catch (PatternSyntaxException npe) {
- //not a valid patter, we'll ignore
- }
- } else {
- LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG", n);
- }
- }
- }
- }
- }
- }
-
- public void configureBean(Object beanInstance) {
- configureBean(null, beanInstance, true);
- }
-
- public void configureBean(String bn, Object beanInstance) {
- configureBean(bn, beanInstance, true);
- }
- public synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards) {
-
- if (null == appContexts) {
- return;
- }
-
- if (null == bn) {
- bn = getBeanName(beanInstance);
- }
-
- if (null == bn) {
- return;
- }
- if (checkWildcards) {
- configureWithWildCard(bn, beanInstance);
- }
-
- final String beanName = bn;
- setBeanWiringInfoResolver(new BeanWiringInfoResolver() {
- public BeanWiringInfo resolveWiringInfo(Object instance) {
- if (!"".equals(beanName)) {
- return new BeanWiringInfo(beanName);
- }
- return null;
- }
- });
-
- for (ApplicationContext appContext : appContexts) {
- if (appContext.containsBean(bn)) {
- this.setBeanFactory(appContext.getAutowireCapableBeanFactory());
- }
- }
-
- try {
- //this will prevent a call into the AbstractBeanFactory.markBeanAsCreated(...)
- //which saves ALL the names into a HashSet. For URL based configuration,
- //this can leak memory
- if (beanFactory instanceof AbstractBeanFactory) {
- ((AbstractBeanFactory)beanFactory).getMergedBeanDefinition(bn);
- }
- super.configureBean(beanInstance);
- if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Successfully performed injection.");
- }
- } catch (NoSuchBeanDefinitionException ex) {
- // users often wonder why the settings in their configuration files seem
- // to have no effect - the most common cause is that they have been using
- // incorrect bean ids
- if (LOG.isLoggable(Level.FINE)) {
- LOG.log(Level.FINE, "NO_MATCHING_BEAN_MSG", beanName);
- }
- }
- }
-
- private void configureWithWildCard(String bn, Object beanInstance) {
- if (!wildCardBeanDefinitions.isEmpty()) {
- Class<?> clazz = beanInstance.getClass();
- while (!Object.class.equals(clazz)) {
- String className = clazz.getName();
- List<MatcherHolder> matchers = wildCardBeanDefinitions.get(className);
- if (matchers != null) {
- for (MatcherHolder m : matchers) {
- synchronized (m.matcher) {
- m.matcher.reset(bn);
- if (m.matcher.matches()) {
- configureBean(m.wildCardId, beanInstance, false);
- return;
- }
- }
- }
- }
- clazz = clazz.getSuperclass();
- }
- }
- }
-
- private boolean isWildcardBeanName(String bn) {
- return bn.indexOf('*') != -1 || bn.indexOf('?') != -1
- || (bn.indexOf('(') != -1 && bn.indexOf(')') != -1);
- }
-
- protected String getBeanName(Object beanInstance) {
- if (beanInstance instanceof Configurable) {
- return ((Configurable)beanInstance).getBeanName();
- }
- String beanName = null;
- Method m = null;
- try {
- m = beanInstance.getClass().getDeclaredMethod("getBeanName", (Class[])null);
- } catch (NoSuchMethodException ex) {
- try {
- m = beanInstance.getClass().getMethod("getBeanName", (Class[])null);
- } catch (NoSuchMethodException e) {
- //ignore
- }
- }
- if (m != null) {
- try {
- beanName = (String)(m.invoke(beanInstance));
- } catch (Exception ex) {
- LogUtils.log(LOG, Level.WARNING, "ERROR_DETERMINING_BEAN_NAME_EXC", ex);
- }
- }
-
- if (null == beanName) {
- LogUtils.log(LOG, Level.FINE, "COULD_NOT_DETERMINE_BEAN_NAME_MSG",
- beanInstance.getClass().getName());
- }
-
- return beanName;
- }
-
- public final void setApplicationContext(ApplicationContext ac) {
- appContexts = new CopyOnWriteArraySet<ApplicationContext>();
- addApplicationContext(ac);
- this.beanFactory = ac.getAutowireCapableBeanFactory();
- super.setBeanFactory(this.beanFactory);
- }
-
- public final void addApplicationContext(ApplicationContext ac) {
- if (!appContexts.contains(ac)) {
- appContexts.add(ac);
- List<ApplicationContext> inactiveApplicationContexts = new ArrayList<ApplicationContext>();
- Iterator<ApplicationContext> it = appContexts.iterator();
- while (it.hasNext()) {
- ApplicationContext c = it.next();
- if (c instanceof ConfigurableApplicationContext
- && !((ConfigurableApplicationContext)c).isActive()) {
- inactiveApplicationContexts.add(c);
- }
- }
- // Remove the inactive application context here can avoid the UnsupportedOperationException
- for (ApplicationContext context : inactiveApplicationContexts) {
- appContexts.remove(context);
- }
- initWildcardDefinitionMap();
- }
- }
-
- public void destroy() {
- super.destroy();
- appContexts.clear();
- }
-
- public Class<?> getRegistrationType() {
- return Configurer.class;
- }
-
- protected Set<ApplicationContext> getAppContexts() {
- return appContexts;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java b/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
deleted file mode 100644
index 9c606df..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
+++ /dev/null
@@ -1,73 +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.io.StringReader;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.cxf.common.jaxb.JAXBUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-
-/**
- *
- */
-public final class JAXBBeanFactory {
- private JAXBBeanFactory() {
- //nothing
- }
-
- public static <T> T createJAXBBean(JAXBContext context,
- String s,
- Class<T> c) {
-
- StringReader reader = new StringReader(s);
- XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
- try {
-
- T obj = null;
- if (c != null) {
- obj = JAXBUtils.unmarshall(context, data, c).getValue();
- } else {
- Object o = JAXBUtils.unmarshall(context, data);
- if (o instanceof JAXBElement<?>) {
- JAXBElement<?> el = (JAXBElement<?>)o;
- @SuppressWarnings("unchecked")
- T ot = (T)el.getValue();
- obj = ot;
- }
- }
- return obj;
- } catch (JAXBException e) {
- throw new RuntimeException(e);
- } finally {
- try {
- StaxUtils.close(data);
- } catch (XMLStreamException ex) {
- throw new RuntimeException(ex);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
deleted file mode 100644
index 776edc5..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/MappingBeanDefinitionParser.java
+++ /dev/null
@@ -1,59 +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.util.Collections;
-import java.util.Map;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.cxf.staxutils.W3CDOMStreamWriter;
-import org.apache.cxf.staxutils.transform.OutTransformWriter;
-import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.beans.factory.xml.ParserContext;
-
-public class MappingBeanDefinitionParser
- extends org.springframework.beans.factory.xml.AbstractBeanDefinitionParser {
-
- private final Map<String, String> transformMap;
- public MappingBeanDefinitionParser(String oldns, String newns) {
- transformMap = Collections.singletonMap("{" + oldns + "}*", "{" + newns + "}*");
- }
-
- @Override
- protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
- element = transformElement(element);
- return (AbstractBeanDefinition)parserContext.getDelegate().parseCustomElement(element);
- }
- private Element transformElement(Element element) {
-
- W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter();
- OutTransformWriter transformWriter = new OutTransformWriter(domWriter, transformMap);
- try {
- StaxUtils.copy(element, transformWriter);
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- }
- return domWriter.getDocument().getDocumentElement();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/Messages.properties b/core/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
deleted file mode 100644
index ed8f59a..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
+++ /dev/null
@@ -1,26 +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.
-#
-#
-NO_MATCHING_BEAN_MSG = Could not find a definition for bean with id {0} - no injection will be performed.
-COULD_NOT_DETERMINE_BEAN_NAME_MSG = Could not determine bean name for instance of class {0}.
-ERROR_DETERMINING_BEAN_NAME_EXC = Failed to determine bean name.
-JAXB_PROPERTY_EDITOR_EXC = Property editor failed to bind element {0}.
-WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG = Configuration bean with id {0} that uses a ''*'' or wildcard must have a class attribute.
-ONE_WILDCARD_BEAN_ID_PER_CLASS_MSG = A wildcard configuration bean with id {0} already exists for class {1}. The wildcard bean with id {2} will be ignored.
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
deleted file mode 100644
index 442970c..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
+++ /dev/null
@@ -1,33 +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;
-
-/**
- * This bean parser will map all the attributes to properties on the bean.
- *
- */
-public class SimpleBeanDefinitionParser extends AbstractBeanDefinitionParser {
-
- public SimpleBeanDefinitionParser(Class<?> beanClass) {
- super();
- setBeanClass(beanClass);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
deleted file mode 100644
index 064c43d..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
+++ /dev/null
@@ -1,39 +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 org.w3c.dom.Element;
-
-import org.apache.cxf.helpers.DOMUtils;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
-
-public class StringBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
-
- @Override
- protected void doParse(Element element, BeanDefinitionBuilder builder) {
- builder.addConstructorArgValue(DOMUtils.getRawContent(element));
- }
-
- @Override
- protected Class<?> getBeanClass(Element arg0) {
- return String.class;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/internal/CXFAPINamespaceHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/internal/CXFAPINamespaceHandler.java b/core/src/main/java/org/apache/cxf/internal/CXFAPINamespaceHandler.java
deleted file mode 100644
index 507e1ca..0000000
--- a/core/src/main/java/org/apache/cxf/internal/CXFAPINamespaceHandler.java
+++ /dev/null
@@ -1,114 +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.internal;
-
-import java.net.URL;
-import java.util.Set;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import org.apache.aries.blueprint.NamespaceHandler;
-import org.apache.aries.blueprint.Namespaces;
-import org.apache.aries.blueprint.ParserContext;
-import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
-import org.apache.cxf.bus.blueprint.BusDefinitionParser;
-import org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
-import org.apache.cxf.feature.FastInfosetFeature;
-import org.apache.cxf.feature.LoggingFeature;
-import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.Metadata;
-
-@Namespaces({"http://cxf.apache.org/blueprint/core",
- "http://cxf.apache.org/configuration/beans",
- "http://cxf.apache.org/configuration/parameterized-types",
- "http://cxf.apache.org/configuration/security",
- "http://schemas.xmlsoap.org/wsdl/",
- "http://www.w3.org/2005/08/addressing",
- "http://schemas.xmlsoap.org/ws/2004/08/addressing"})
-public class CXFAPINamespaceHandler implements NamespaceHandler {
-
- public URL getSchemaLocation(String namespace) {
- String location = null;
-
- if ("http://cxf.apache.org/configuration/beans".equals(namespace)) {
- location = "schemas/configuration/cxf-beans.xsd";
- } else if ("http://cxf.apache.org/configuration/parameterized-types".equals(namespace)) {
- location = "schemas/configuration/parameterized-types.xsd";
- } else if ("http://cxf.apache.org/configuration/security".equals(namespace)) {
- location = "schemas/configuration/security.xsd";
- } else if ("http://schemas.xmlsoap.org/wsdl/".equals(namespace)) {
- location = "schemas/wsdl/wsdl.xsd";
- } else if ("http://www.w3.org/2005/08/addressing".equals(namespace)) {
- location = "schemas/wsdl/ws-addr.xsd";
- } else if ("http://schemas.xmlsoap.org/ws/2004/08/addressing".equals(namespace)) {
- location = "schemas/wsdl/addressing.xsd";
- } else if ("http://cxf.apache.org/blueprint/core".equals(namespace)) {
- location = "schemas/blueprint/core.xsd";
- }
- if (location != null) {
- return getClass().getClassLoader().getResource(location);
- }
- return null;
- }
-
-
- public Metadata parse(Element element, ParserContext context) {
- String s = element.getLocalName();
- if ("bus".equals(s)) {
- //parse bus
- return new BusDefinitionParser().parse(element, context);
- } else if ("logging".equals(s)) {
- //logging feature
- return new SimpleBPBeanDefinitionParser(LoggingFeature.class).parse(element, context);
- } else if ("fastinfoset".equals(s)) {
- //fastinfosetfeature
- return new SimpleBPBeanDefinitionParser(FastInfosetFeature.class).parse(element, context);
- } else if ("workqueue".equals(s)) {
- return new SimpleBPBeanDefinitionParser(AutomaticWorkQueueImpl.class) {
- public String getId(Element element, ParserContext context) {
- String id = element.hasAttribute("id") ? element.getAttribute("id") : null;
- if (id == null) {
- id = "cxf.workqueue.";
- id += element.hasAttribute("name") ? element.getAttribute("name") : "def";
- }
- return id;
- }
-
- protected void processNameAttribute(Element element, ParserContext ctx,
- MutableBeanMetadata bean, String val) {
- bean.addProperty("name", createValue(ctx, val));
- }
- } .parse(element, context);
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- public Set<Class> getManagedClasses() {
- //probably should have the various stuff in cxf-api in here?
- return null;
- }
- public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java b/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
deleted file mode 100644
index d5911b3..0000000
--- a/core/src/main/java/org/apache/cxf/service/invoker/spring/SpringBeanFactory.java
+++ /dev/null
@@ -1,65 +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.service.invoker.spring;
-
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.service.invoker.Factory;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-/**
- * Factory that will query the Spring ApplicationContext for the
- * appropriate bean for each request.
- *
- * This can be expensive. If the bean is "prototype" or similar such that a
- * new instance is created each time, this could slow things down. In that
- * case, it's recommended to use this in conjunction with the PooledFactory
- * to pool the beans or the SessionFactory or similar.
- */
-public class SpringBeanFactory implements Factory, ApplicationContextAware {
- volatile ApplicationContext ctx;
- final String beanName;
-
- public SpringBeanFactory(String name) {
- beanName = name;
- }
- public SpringBeanFactory(Class<?> c, String[] args) { //NOPMD
- beanName = args[0];
- }
-
- /** {@inheritDoc}*/
- public Object create(Exchange e) throws Throwable {
- if (ctx == null) {
- ctx = e.getBus().getExtension(ApplicationContext.class);
- }
- return ctx.getBean(beanName);
- }
-
- /** {@inheritDoc}*/
- public void release(Exchange e, Object o) {
- //nothing
- }
-
- public void setApplicationContext(ApplicationContext arg0) throws BeansException {
- ctx = arg0;
- }
-
-}
[3/4] cxf git commit: Experimentally simply remove spring and
blueprint related classes to see how much cxf is tied to it
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java b/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
deleted file mode 100644
index 3c6369d..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
+++ /dev/null
@@ -1,71 +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 org.apache.cxf.Bus;
-import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.extension.BusExtension;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.core.Ordered;
-
-@NoJSR250Annotations
-public class BusExtensionPostProcessor implements BeanPostProcessor, ApplicationContextAware, Ordered {
-
- private Bus bus;
- private ApplicationContext context;
-
- public void setApplicationContext(ApplicationContext ctx) {
- context = ctx;
- }
-
- public int getOrder() {
- return 1001;
- }
-
-
- public Object postProcessAfterInitialization(Object bean, String beanId) throws BeansException {
- return bean;
- }
-
- public Object postProcessBeforeInitialization(Object bean, String beanId) throws BeansException {
- if (bean instanceof BusExtension && null != getBus()) {
- Class<? extends Object> cls = ((BusExtension)bean).getRegistrationType();
- registerExt(bean, cls);
- } else if (bean instanceof Bus && Bus.DEFAULT_BUS_ID.equals(beanId)) {
- bus = (Bus)bean;
- }
- return bean;
- }
- private <T> void registerExt(Object bean, Class<T> cls) {
- getBus().setExtension(cls.cast(bean), cls);
- }
-
- private Bus getBus() {
- if (bus == null) {
- bus = (Bus)context.getBean(Bus.DEFAULT_BUS_ID);
- }
- return bus;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java b/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
deleted file mode 100644
index e24da64..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
+++ /dev/null
@@ -1,174 +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.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
-import org.apache.cxf.configuration.spring.BusWiringType;
-import org.apache.cxf.helpers.CastUtils;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.config.ConstructorArgumentValues;
-import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/**
- * BeanFactoryPostProcessor that looks for any bean definitions that have the
- * {@link AbstractBeanDefinitionParser#WIRE_BUS_ATTRIBUTE} attribute set. If the attribute has the value
- * {@link BusWiringType#PROPERTY} then it attaches their "bus" property to the bean called "cxf". If the
- * attribute has the value {@link BusWiringType#CONSTRUCTOR} then it shifts any existing indexed constructor
- * arguments one place to the right and adds a reference to "cxf" as the first constructor argument. This
- * processor is intended to operate on beans defined via Spring namespace support which require a reference to
- * the CXF bus.
- */
-public class BusWiringBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
-
- Bus bus;
- String busName;
-
- public BusWiringBeanFactoryPostProcessor() {
- }
-
- public BusWiringBeanFactoryPostProcessor(Bus b) {
- bus = b;
- }
- public BusWiringBeanFactoryPostProcessor(String n) {
- busName = n;
- }
- private static Bus getBusForName(String name,
- ApplicationContext context,
- boolean create) {
- if (!context.containsBean(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) {
- SpringBus b = new SpringBus();
- ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)context;
- cctx.getBeanFactory().registerSingleton(name, b);
- b.setApplicationContext(context);
- }
- return (Bus)context.getBean(name, Bus.class);
- }
- private Object getBusForName(String name,
- ConfigurableListableBeanFactory factory,
- boolean create,
- String cn) {
- if (!factory.containsBeanDefinition(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) {
- DefaultListableBeanFactory df = (DefaultListableBeanFactory)factory;
- RootBeanDefinition rbd = new RootBeanDefinition(SpringBus.class);
- if (cn != null) {
- rbd.setAttribute("busConfig", new RuntimeBeanReference(cn));
- }
- df.registerBeanDefinition(name, rbd);
- } else if (cn != null) {
- BeanDefinition bd = factory.getBeanDefinition(name);
- bd.getPropertyValues().addPropertyValue("busConfig", new RuntimeBeanReference(cn));
- }
- return new RuntimeBeanReference(name);
- }
-
- public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException {
- Object inject = bus;
- if (inject == null) {
- inject = getBusForName(Bus.DEFAULT_BUS_ID, factory, true, null);
- } else {
- if (!factory.containsBeanDefinition(Bus.DEFAULT_BUS_ID)
- && !factory.containsSingleton(Bus.DEFAULT_BUS_ID)) {
- factory.registerSingleton(Bus.DEFAULT_BUS_ID, bus);
- }
- }
- for (String beanName : factory.getBeanDefinitionNames()) {
- BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
- BusWiringType type
- = (BusWiringType)beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
- if (type == null) {
- continue;
- }
- String busname = (String)beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
- String create = (String)beanDefinition
- .getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
- Object inj = inject;
- if (busname != null) {
- if (bus != null) {
- continue;
- }
- inj = getBusForName(busname, factory, create != null, create);
- }
- beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
- beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
- beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
- if (create == null) {
- if (BusWiringType.PROPERTY == type) {
- beanDefinition.getPropertyValues()
- .addPropertyValue("bus", inj);
- } else if (BusWiringType.CONSTRUCTOR == type) {
- ConstructorArgumentValues constructorArgs = beanDefinition.getConstructorArgumentValues();
- insertConstructorArg(constructorArgs, inj);
- }
- }
- }
- }
-
- /**
- * Insert the given value as the first constructor argument in the given set. To do this, we clear the
- * argument set, then re-insert all its generic arguments, then re-insert all its indexed arguments with
- * their indices incremented by 1, and finally set the first indexed argument (at index 0) to the given
- * value.
- *
- * @param constructorArgs the argument definition to modify.
- * @param valueToInsert the value to insert as the first argument.
- */
- private void insertConstructorArg(ConstructorArgumentValues constructorArgs, Object valueToInsert) {
- List<ValueHolder> genericArgs = new ArrayList<ValueHolder>(CastUtils
- .<ValueHolder> cast(constructorArgs.getGenericArgumentValues()));
- Map<Integer, ValueHolder> indexedArgs = new HashMap<Integer, ValueHolder>(CastUtils
- .<Integer, ValueHolder> cast(constructorArgs.getIndexedArgumentValues()));
-
- constructorArgs.clear();
- for (ValueHolder genericValue : genericArgs) {
- constructorArgs.addGenericArgumentValue(genericValue);
- }
- for (Map.Entry<Integer, ValueHolder> entry : indexedArgs.entrySet()) {
- constructorArgs.addIndexedArgumentValue(entry.getKey() + 1, entry.getValue());
- }
- constructorArgs.addIndexedArgumentValue(0, valueToInsert);
- }
-
- public static Bus addDefaultBus(ApplicationContext ctx) {
- if (!ctx.containsBean(Bus.DEFAULT_BUS_ID)) {
- Bus b = getBusForName(Bus.DEFAULT_BUS_ID, ctx, true);
- if (ctx instanceof ConfigurableApplicationContext) {
- ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)ctx;
- new BusWiringBeanFactoryPostProcessor(b).postProcessBeanFactory(cctx.getBeanFactory());
- }
- }
- return Bus.class.cast(ctx.getBean(Bus.DEFAULT_BUS_ID, Bus.class));
- }
- public static Bus addBus(ApplicationContext ctx, String name) {
- return getBusForName(name, ctx, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java b/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
deleted file mode 100644
index 007ce70..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
+++ /dev/null
@@ -1,197 +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.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamException;
-
-import org.w3c.dom.Document;
-
-import org.xml.sax.InputSource;
-
-import org.apache.cxf.common.util.SystemPropertyAction;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-import org.springframework.core.io.support.EncodedResource;
-
-/**
- * CXF reads a series of Spring XML files as part of initialization.
- * The time it takes to parse them, especially if validating, builds up.
- * The XML files shipped in a release in the JARs are valid and invariant.
- * To speed things up, this class implements two levels of optimization.
- * When a CXF distribution is fully-packaged, each of the Spring XML
- * bus extension .xml files is accompanied by a FastInfoset '.fixml' file.
- * These read much more rapidly. When one of those is present, this classs
- * reads it instead of reading the XML text file.
- *
- * Absent a .fixml file, this class uses WoodStox instead of Xerces (or
- * whatever the JDK is providing).
- *
- * The Woodstox optimization also applies to user cxf.xml or cxf-servlet.xml files
- * if the user has disabled XML validation of Spring files with
- * the org.apache.cxf.spring.validation.mode system property.
- *
- * Note that the fastInfoset optimization is only applied for the
- * methods here that start from a Resource. If this is called with an InputSource,
- * that optimization is not applied, since we can't reliably know the
- * location of the XML.
- */
-public class ControlledValidationXmlBeanDefinitionReader extends XmlBeanDefinitionReader {
-
- /**
- * Exception class used to avoid reading old FastInfoset files.
- */
- private static class StaleFastinfosetException extends Exception {
-
- private static final long serialVersionUID = -3594973504794187383L;
-
- }
-
- // the following flag allows performance comparisons with and
- // without fast infoset processing.
- private boolean noFastinfoset;
- // Spring has no 'getter' for this, so we need our own copy.
- private int visibleValidationMode = VALIDATION_AUTO;
- // We need a reference to the subclass.
- private TunedDocumentLoader tunedDocumentLoader;
- /**
- * @param beanFactory
- */
- public ControlledValidationXmlBeanDefinitionReader(BeanDefinitionRegistry beanFactory) {
- super(beanFactory);
- tunedDocumentLoader = new TunedDocumentLoader();
- this.setDocumentLoader(tunedDocumentLoader);
- noFastinfoset = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.nofastinfoset") != null
- || !TunedDocumentLoader.hasFastInfoSet();
- }
-
- @Override
- protected int doLoadBeanDefinitions(InputSource inputSource,
- Resource resource) throws BeanDefinitionStoreException {
- // sadly, the Spring class we are extending has the critical function
- // getValidationModeForResource
- // marked private instead of protected, so trickery is called for here.
- boolean suppressValidation = false;
- try {
- URL url = resource.getURL();
- if (url.getFile().contains("META-INF/cxf/")) {
- suppressValidation = true;
- }
- } catch (IOException e) {
- // this space intentionally left blank.
- }
-
- int savedValidation = visibleValidationMode;
- if (suppressValidation) {
- setValidationMode(VALIDATION_NONE);
- }
- int r = super.doLoadBeanDefinitions(inputSource, resource);
- setValidationMode(savedValidation);
- return r;
- }
-
- @Override
- public void setValidationMode(int validationMode) {
- visibleValidationMode = validationMode;
- super.setValidationMode(validationMode);
- }
-
- @Override
- public int loadBeanDefinitions(final EncodedResource encodedResource)
- throws BeanDefinitionStoreException {
- if (!noFastinfoset) {
- try {
- return fastInfosetLoadBeanDefinitions(encodedResource);
- } catch (BeanDefinitionStoreException bdse) {
- throw bdse;
- } catch (Throwable e) {
- //ignore - just call the super to load them
- }
- }
- try {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Integer>() {
- public Integer run() throws Exception {
- return internalLoadBeanDefinitions(encodedResource);
- }
-
- });
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof RuntimeException) {
- throw (RuntimeException)e.getException();
- }
- throw (BeanDefinitionStoreException)e.getException();
- }
- }
-
- private int internalLoadBeanDefinitions(EncodedResource encodedResource) {
- return super.loadBeanDefinitions(encodedResource);
- }
-
- private int fastInfosetLoadBeanDefinitions(EncodedResource encodedResource)
- throws IOException, StaleFastinfosetException,
- ParserConfigurationException, XMLStreamException {
-
- URL resUrl = encodedResource.getResource().getURL();
- // There are XML files scampering around that don't end in .xml.
- // We don't apply the optimization to them.
- if (!resUrl.getPath().endsWith(".xml")) {
- throw new StaleFastinfosetException();
- }
- String fixmlPath = resUrl.getPath().replaceFirst("\\.xml$", ".fixml");
- String protocol = resUrl.getProtocol();
- // beware of the relative URL rules for jar:, which are surprising.
- if ("jar".equals(protocol)) {
- fixmlPath = fixmlPath.replaceFirst("^.*!", "");
- }
-
- URL fixmlUrl = new URL(resUrl, fixmlPath);
-
- // if we are in unpacked files, we take some extra time
- // to ensure that we aren't using a stale Fastinfoset file.
- if ("file".equals(protocol)) {
- URLConnection resCon = null;
- URLConnection fixCon = null;
- resCon = resUrl.openConnection();
- fixCon = fixmlUrl.openConnection();
- if (resCon.getLastModified() > fixCon.getLastModified()) {
- throw new StaleFastinfosetException();
- }
- }
-
- Resource newResource = new UrlResource(fixmlUrl);
- Document doc = TunedDocumentLoader.loadFastinfosetDocument(fixmlUrl);
- if (doc == null) {
- //something caused FastinfoSet to not be able to read the doc
- throw new StaleFastinfosetException();
- }
- return registerBeanDefinitions(doc, newResource);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java b/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
deleted file mode 100644
index 25748bf..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
+++ /dev/null
@@ -1,157 +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 org.apache.cxf.Bus;
-import org.apache.cxf.common.injection.ResourceInjector;
-import org.apache.cxf.resource.ResourceManager;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.core.Ordered;
-
-public class Jsr250BeanPostProcessor
- implements DestructionAwareBeanPostProcessor, Ordered, ApplicationContextAware {
-
- private ResourceManager resourceManager;
- private ApplicationContext context;
-
- private boolean isProcessing = true;
- //private int count;
- //private int count2;
-
- Jsr250BeanPostProcessor() {
- }
-
- public void setApplicationContext(ApplicationContext arg0) throws BeansException {
- context = arg0;
- try {
- Class<?> cls = Class
- .forName("org.springframework.context.annotation.CommonAnnotationBeanPostProcessor");
- isProcessing = context.getBeanNamesForType(cls, true, false).length == 0;
- } catch (ClassNotFoundException e) {
- isProcessing = true;
- }
- }
-
- public int getOrder() {
- return 1010;
- }
-
- private boolean injectable(Object bean, String beanId) {
- return !"cxf".equals(beanId) && ResourceInjector.processable(bean.getClass(), bean);
- }
- private ResourceManager getResourceManager(Object bean) {
- if (resourceManager == null) {
- boolean temp = isProcessing;
- isProcessing = false;
- if (bean instanceof ResourceManager) {
- resourceManager = (ResourceManager)bean;
- resourceManager.addResourceResolver(new BusApplicationContextResourceResolver(context));
- } else if (bean instanceof Bus) {
- Bus b = (Bus)bean;
- ResourceManager m = b.getExtension(ResourceManager.class);
- if (m != null) {
- resourceManager = m;
- if (!(b instanceof SpringBus)) {
- resourceManager
- .addResourceResolver(new BusApplicationContextResourceResolver(context));
- }
- }
- } else {
- ResourceManager m = null;
- Bus b = null;
- try {
- m = (ResourceManager)context.getBean(ResourceManager.class.getName());
- } catch (NoSuchBeanDefinitionException t) {
- //ignore - no resource manager
- }
- if (m == null) {
- b = (Bus)context.getBean("cxf");
- m = b.getExtension(ResourceManager.class);
- }
- if (m != null) {
- resourceManager = m;
- if (!(b instanceof SpringBus)) {
- resourceManager
- .addResourceResolver(new BusApplicationContextResourceResolver(context));
- }
- }
- }
- isProcessing = temp;
- }
- return resourceManager;
- }
- public Object postProcessAfterInitialization(Object bean, String beanId) throws BeansException {
- if (!isProcessing) {
- if (resourceManager == null && bean instanceof ResourceManager) {
- resourceManager = (ResourceManager)bean;
- resourceManager.addResourceResolver(new BusApplicationContextResourceResolver(context));
- }
- return bean;
- }
- if (bean != null
- && injectable(bean, beanId)) {
- new ResourceInjector(getResourceManager(bean)).construct(bean);
- }
- return bean;
- }
-
- public Object postProcessBeforeInitialization(Object bean, String beanId) throws BeansException {
- if (!isProcessing) {
- return bean;
- }
- if (bean instanceof Bus) {
- getResourceManager(bean);
- }
- /*
- if (bean.getClass().getName().contains("Corb")) {
- Thread.dumpStack();
- }
- */
-
- if (bean != null
- && injectable(bean, beanId)) {
- new ResourceInjector(getResourceManager(bean)).inject(bean);
- /*
- System.out.println("p :" + (++count) + ": " + bean.getClass().getName() + " " + beanId);
- } else if (bean != null) {
- System.out.println("np: " + (++count2)
- + ": " + bean.getClass().getName() + " " + beanId);
- */
- }
- return bean;
- }
-
- public void postProcessBeforeDestruction(Object bean, String beanId) {
- if (!isProcessing) {
- return;
- }
- if (bean != null
- && injectable(bean, beanId)) {
- new ResourceInjector(getResourceManager(bean)).destroy(bean);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties b/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
deleted file mode 100644
index 3783c8e..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/Messages.properties
+++ /dev/null
@@ -1,27 +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.
-#
-#
-USER_CFG_FILE_NOT_FOUND_MSG = Could not find the configuration file {0} on the classpath.
-USER_CFG_FILE_IN_USE= Loaded configuration file {0}.
-USER_CFG_FILE_URL_ERROR_MSG = The configuration file URL {0} is a a malformed URL.
-USER_CFG_FILE_URL_NOT_FOUND_MSG = Could not find the configuration file in the url of {0}.
-APP_CONTEXT_CREATION_FAILED_MSG = Failed to create application context.
-INITIAL_APP_CONTEXT_CREATION_FAILED_MSG = Initial attempt to create application context was unsuccessful.
-USER_CFG_FILE_NOT_LOADED=Failed to load configuration {0}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java b/core/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
deleted file mode 100644
index 9a67b84..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
+++ /dev/null
@@ -1,57 +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 org.w3c.dom.Element;
-
-import org.apache.cxf.configuration.spring.SimpleBeanDefinitionParser;
-import org.apache.cxf.feature.FastInfosetFeature;
-import org.apache.cxf.feature.LoggingFeature;
-import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-import org.springframework.beans.factory.xml.ParserContext;
-
-public class NamespaceHandler extends NamespaceHandlerSupport {
- public void init() {
- registerBeanDefinitionParser("bus",
- new BusDefinitionParser());
- registerBeanDefinitionParser("logging",
- new SimpleBeanDefinitionParser(LoggingFeature.class));
- registerBeanDefinitionParser("fastinfoset",
- new SimpleBeanDefinitionParser(FastInfosetFeature.class));
-
- registerBeanDefinitionParser("workqueue",
- new SimpleBeanDefinitionParser(AutomaticWorkQueueImpl.class) {
-
- protected void processNameAttribute(Element element,
- ParserContext ctx,
- BeanDefinitionBuilder bean,
- String val) {
- bean.addPropertyValue("name", val);
- element.removeAttribute("name");
- if (!element.hasAttribute("id")) {
- val = "cxf.workqueue." + val;
- element.setAttribute("id", val);
- }
-
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java b/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
deleted file mode 100644
index 6686cd1..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
+++ /dev/null
@@ -1,313 +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.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.bus.extension.ExtensionManagerImpl;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ReflectionUtil;
-import org.apache.cxf.configuration.ConfiguredBeanLocator;
-import org.springframework.beans.Mergeable;
-import org.springframework.beans.PropertyValue;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.TypedStringValue;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/**
- *
- */
-public class SpringBeanLocator implements ConfiguredBeanLocator {
- private static final Logger LOG = LogUtils.getL7dLogger(SpringBeanLocator.class);
-
- ApplicationContext context;
- ConfiguredBeanLocator orig;
- Set<String> passThroughs = new HashSet<String>();
- Object bundleContext;
- boolean osgi = true;
-
- public SpringBeanLocator(ApplicationContext ctx) {
- this(ctx, null);
- }
- public SpringBeanLocator(ApplicationContext ctx, Bus bus) {
- context = ctx;
- if (bus != null) {
- orig = bus.getExtension(ConfiguredBeanLocator.class);
- if (orig instanceof ExtensionManagerImpl) {
- List<String> names = new ArrayList<String>();
- for (String s : ctx.getBeanDefinitionNames()) {
- names.add(s);
- for (String s2 : ctx.getAliases(s)) {
- names.add(s2);
- }
- }
-
- ((ExtensionManagerImpl)orig).removeBeansOfNames(names);
- }
- }
- loadOSGIContext(bus);
- }
-
- private void loadOSGIContext(Bus b) {
- bundleContext = findBundleContext(context, b);
- if (bundleContext == null) {
- osgi = false;
- }
- }
-
- private Object findBundleContext(ApplicationContext applicationContext, Bus b) {
- Object answer = null;
- ApplicationContext aContext = applicationContext;
- // try to find out the bundleContext by going through the parent context
- while (aContext != null && answer == null) {
- answer = getBundleContext(aContext, b);
- aContext = aContext.getParent();
- }
- return answer;
- }
-
- private Object getBundleContext(ApplicationContext applicationContext, Bus b) {
- try {
- //use a little reflection to allow this to work without the spring-dm jars
- //for the non-osgi cases
- Method m = applicationContext.getClass().getMethod("getBundleContext");
- Object o = m.invoke(applicationContext);
- if (o != null && b != null) {
- @SuppressWarnings("unchecked")
- Class<Object> cls = (Class<Object>)m.getReturnType();
- b.setExtension(o, cls);
- }
- return o;
- } catch (Throwable t) {
- // do nothing here
- }
- return null;
- }
-
- public <T> T getBeanOfType(String name, Class<T> type) {
- T t = null;
- try {
- t = type.cast(context.getBean(name, type));
- } catch (NoSuchBeanDefinitionException nsbde) {
- //ignore
- }
- if (t == null) {
- t = orig.getBeanOfType(name, type);
- }
- return t;
- }
-
- /** {@inheritDoc}*/
- public List<String> getBeanNamesOfType(Class<?> type) {
- Set<String> s = new LinkedHashSet<String>(Arrays.asList(context.getBeanNamesForType(type,
- false,
- false)));
- s.removeAll(passThroughs);
- s.addAll(orig.getBeanNamesOfType(type));
- return new ArrayList<String>(s);
- }
-
- /** {@inheritDoc}*/
- public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
- Set<String> s = new LinkedHashSet<String>(Arrays.asList(context.getBeanNamesForType(type,
- false,
- false)));
- s.removeAll(passThroughs);
- List<T> lst = new LinkedList<T>();
- for (String n : s) {
- lst.add(type.cast(context.getBean(n, type)));
- }
- lst.addAll(orig.getBeansOfType(type));
- if (lst.isEmpty()) {
- tryOSGI(lst, type);
- }
- return lst;
- }
- private <T> void tryOSGI(Collection<T> lst, Class<T> type) {
- if (!osgi) {
- return;
- }
- try {
- //use a little reflection to allow this to work without the spring-dm jars
- //for the non-osgi cases
- Class<?> contextClass = findContextClass(bundleContext.getClass());
-
- Method m = contextClass.getMethod("getServiceReference", String.class);
- ReflectionUtil.setAccessible(m);
- Object o = m.invoke(bundleContext, type.getName());
- if (o != null) {
- m = contextClass.getMethod("getService", m.getReturnType());
- ReflectionUtil.setAccessible(m);
- o = m.invoke(bundleContext, o);
- lst.add(type.cast(o));
- }
- } catch (NoSuchMethodException e) {
- osgi = false;
- //not using OSGi
- } catch (Throwable e) {
- //ignore
- LOG.log(Level.WARNING, "Could not get service for " + type.getName(), e);
- }
- }
- private Class<?> findContextClass(Class<?> cls) {
- for (Class<?> c : cls.getInterfaces()) {
- if (c.getName().equals("org.osgi.framework.BundleContext")) {
- return c;
- }
- }
- for (Class<?> c : cls.getInterfaces()) {
- Class<?> c2 = findContextClass(c);
- if (c2 != null) {
- return c2;
- }
- }
- Class<?> c2 = findContextClass(cls.getSuperclass());
- if (c2 != null) {
- return c2;
- }
-
- return cls;
- }
-
-
- public <T> boolean loadBeansOfType(Class<T> type,
- BeanLoaderListener<T> listener) {
- List<String> list = new ArrayList<String>(Arrays.asList(context.getBeanNamesForType(type,
- false,
- false)));
- list.removeAll(passThroughs);
- Collections.reverse(list);
- boolean loaded = false;
- for (String s : list) {
- Class<?> beanType = context.getType(s);
- Class<? extends T> t = beanType.asSubclass(type);
- if (listener.loadBean(s, t)) {
- Object o = context.getBean(s);
- if (listener.beanLoaded(s, type.cast(o))) {
- return true;
- }
- loaded = true;
- }
- }
- return loaded || orig.loadBeansOfType(type, listener);
- }
-
- public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String searchValue) {
- if (context.containsBean(beanName) && !passThroughs.contains(beanName)) {
- ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext)context;
- BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanName);
- if (!ctxt.getBeanFactory().isSingleton(beanName) || def.isAbstract()) {
- return false;
- }
- Collection<?> ids = null;
- PropertyValue pv = def.getPropertyValues().getPropertyValue(propertyName);
-
- if (pv != null) {
- Object value = pv.getValue();
- if (!(value instanceof Collection)) {
- throw new RuntimeException("The property " + propertyName + " must be a collection!");
- }
-
- if (value instanceof Mergeable) {
- if (!((Mergeable)value).isMergeEnabled()) {
- ids = (Collection<?>)value;
- }
- } else {
- ids = (Collection<?>)value;
- }
- }
-
- if (ids != null) {
- for (Iterator<?> itr = ids.iterator(); itr.hasNext();) {
- Object o = itr.next();
- if (o instanceof TypedStringValue) {
- if (searchValue.equals(((TypedStringValue) o).getValue())) {
- return true;
- }
- } else {
- if (searchValue.equals(o)) {
- return true;
- }
- }
- }
- }
- }
- return orig.hasConfiguredPropertyValue(beanName, propertyName, searchValue);
- }
-
- public <T> List<T> getOSGiServices(Class<T> type) {
- List<T> lst = new ArrayList<T>();
- if (!osgi) {
- return lst;
- }
-
- Class<?> contextClass = findContextClass(bundleContext.getClass());
- try {
- Method m = contextClass.getMethod("getServiceReference", String.class);
- Class<?> servRefClass = m.getReturnType();
- m = contextClass.getMethod("getServiceReferences", String.class, String.class);
-
- Object o = ReflectionUtil.setAccessible(m).invoke(bundleContext, type.getName(), null);
- if (o != null) {
- m = contextClass.getMethod("getService", servRefClass);
- ReflectionUtil.setAccessible(m);
- for (int x = 0; x < Array.getLength(o); x++) {
- Object ref = Array.get(o, x);
- Object o2 = m.invoke(bundleContext, ref);
- if (o2 != null) {
- lst.add(type.cast(o2));
- }
- }
- }
- } catch (NoSuchMethodException e) {
- //not using OSGi apparently
- e.printStackTrace();
- } catch (Throwable e) {
- //ignore
- e.printStackTrace();
- LOG.log(Level.FINE, "Could not get services for " + type.getName(), e);
- }
- return lst;
- }
-
- public boolean hasBeanOfName(String name) {
- if (context.containsBean(name)) {
- return true;
- }
- return orig.hasBeanOfName(name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java b/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
deleted file mode 100644
index 6272f3b..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
+++ /dev/null
@@ -1,141 +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 org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.apache.cxf.configuration.ConfiguredBeanLocator;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.configuration.spring.ConfigurerImpl;
-import org.apache.cxf.resource.ResourceManager;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextClosedEvent;
-import org.springframework.context.event.ContextRefreshedEvent;
-import org.springframework.context.support.AbstractApplicationContext;
-
-/**
- *
- */
-public class SpringBus extends ExtensionManagerBus
- implements ApplicationContextAware {
-
- AbstractApplicationContext ctx;
- boolean closeContext;
-
- public SpringBus() {
- }
-
- public void setBusConfig(BusDefinitionParser.BusConfig bc) {
- bc.setBus(this);
- }
-
- /** {@inheritDoc}*/
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- ctx = (AbstractApplicationContext)applicationContext;
- @SuppressWarnings("rawtypes")
- ApplicationListener listener = new ApplicationListener() {
- public void onApplicationEvent(ApplicationEvent event) {
- SpringBus.this.onApplicationEvent(event);
- }
- };
- ctx.addApplicationListener(listener);
- ApplicationContext ac = applicationContext.getParent();
- while (ac != null) {
- if (ac instanceof AbstractApplicationContext) {
- ((AbstractApplicationContext)ac).addApplicationListener(listener);
- }
- ac = ac.getParent();
- }
-
- // set the classLoader extension with the application context classLoader
- setExtension(applicationContext.getClassLoader(), ClassLoader.class);
-
- setExtension(new ConfigurerImpl(applicationContext), Configurer.class);
-
- ResourceManager m = getExtension(ResourceManager.class);
- m.addResourceResolver(new BusApplicationContextResourceResolver(applicationContext));
-
- setExtension(applicationContext, ApplicationContext.class);
- ConfiguredBeanLocator loc = getExtension(ConfiguredBeanLocator.class);
- if (!(loc instanceof SpringBeanLocator)) {
- setExtension(new SpringBeanLocator(applicationContext, this), ConfiguredBeanLocator.class);
- }
- if (getState() != BusState.RUNNING) {
- initialize();
- }
- }
-
- public void onApplicationEvent(ApplicationEvent event) {
- if (ctx == null) {
- return;
- }
- boolean doIt = false;
- ApplicationContext ac = ctx;
- while (ac != null && !doIt) {
- if (event.getSource() == ac) {
- doIt = true;
- break;
- }
- ac = ac.getParent();
- }
- if (doIt) {
- if (event instanceof ContextRefreshedEvent) {
- if (getState() != BusState.RUNNING) {
- initialize();
- }
- } else if (event instanceof ContextClosedEvent && getState() == BusState.RUNNING) {
- // The bus could be create by using SpringBusFactory.createBus("/cxf.xml");
- // Just to make sure the shutdown is called rightly
- shutdown();
- }
- }
- }
-
- public void destroyBeans() {
- if (closeContext) {
- ctx.close();
- }
- super.destroyBeans();
- }
-
- public String getId() {
- if (id == null) {
- try {
- Class<?> clsbc = Class.forName("org.osgi.framework.BundleContext");
- Class<?> clsb = Class.forName("org.osgi.framework.Bundle");
- Object o = getExtension(clsbc);
- Object o2 = clsbc.getMethod("getBundle").invoke(o);
- String s = (String)clsb.getMethod("getSymbolicName").invoke(o2);
- id = s + "-" + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
- } catch (Throwable t) {
- id = super.getId();
- }
- }
- return id;
- }
-
- public void setCloseContext(boolean b) {
- closeContext = b;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java b/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
deleted file mode 100644
index 04ea866..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
+++ /dev/null
@@ -1,227 +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.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.SystemPropertyAction;
-import org.apache.cxf.configuration.Configurer;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.io.Resource;
-
-public class SpringBusFactory extends BusFactory {
-
- private static final Logger LOG = LogUtils.getL7dLogger(SpringBusFactory.class);
-
- private final ApplicationContext context;
- private NamespaceHandlerResolver resolver;
-
- public SpringBusFactory() {
- this.context = null;
- }
-
- public SpringBusFactory(ApplicationContext context) {
- this.context = context;
- this.resolver = tryFindNamespaceHandler(context);
- }
- public SpringBusFactory(NamespaceHandlerResolver r) {
- context = null;
- this.resolver = r;
- }
-
- private static NamespaceHandlerResolver tryFindNamespaceHandler(ApplicationContext ctx) {
- try {
- SpringBeanLocator sbl = new SpringBeanLocator(ctx);
- List<NamespaceHandlerResolver> r = sbl.getOSGiServices(NamespaceHandlerResolver.class);
- if (r != null && !r.isEmpty()) {
- return r.get(0);
- }
- } catch (Throwable t) {
- //ignore
- }
- return null;
- }
-
- public ApplicationContext getApplicationContext() {
- return context;
- }
- public void setNamespaceHandlerResolver(NamespaceHandlerResolver r) {
- resolver = r;
- }
-
- public Bus createBus() {
- return createBus((String)null);
- }
-
- private boolean defaultBusNotExists() {
- if (null != context) {
- return !context.containsBean(Bus.DEFAULT_BUS_ID);
- }
- return true;
- }
-
- public Bus createBus(String cfgFile) {
- return createBus(cfgFile, defaultBusNotExists());
- }
-
- public Bus createBus(String cfgFiles[]) {
- return createBus(cfgFiles, defaultBusNotExists());
- }
-
- protected Bus finishCreatingBus(ConfigurableApplicationContext bac) {
- final Bus bus = (Bus)bac.getBean(Bus.DEFAULT_BUS_ID);
-
- bus.setExtension(bac, ApplicationContext.class);
- if (bac instanceof BusApplicationContext) {
- bus.setExtension((BusApplicationContext)bac, BusApplicationContext.class);
- }
- possiblySetDefaultBus(bus);
-
- initializeBus(bus);
-
- registerApplicationContextLifeCycleListener(bus, bac);
-
- if (bus instanceof SpringBus && defaultBusNotExists()) {
- ((SpringBus)bus).setCloseContext(true);
- }
- return bus;
- }
-
- public Bus createBus(String cfgFile, boolean includeDefaults) {
- if (cfgFile == null) {
- return createBus((String[])null, includeDefaults);
- }
- return createBus(new String[] {cfgFile}, includeDefaults);
- }
-
- public Bus createBus(String cfgFiles[], boolean includeDefaults) {
- try {
- String userCfgFile
- = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_NAME);
- String sysCfgFileUrl
- = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_URL);
- final Resource r = BusApplicationContext.findResource(Configurer.DEFAULT_USER_CFG_FILE);
-
- boolean exists = true;
- if (r != null) {
- exists = AccessController
- .doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- return r.exists();
- }
- });
- }
- if (context == null && userCfgFile == null && cfgFiles == null && sysCfgFileUrl == null
- && (r == null || !exists) && includeDefaults) {
- return new org.apache.cxf.bus.CXFBusFactory().createBus();
- }
- return finishCreatingBus(createApplicationContext(cfgFiles, includeDefaults));
- } catch (BeansException ex) {
- LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
- throw new RuntimeException(ex);
- }
- }
-
- protected ConfigurableApplicationContext createApplicationContext(String cfgFiles[], boolean includeDefaults) {
- try {
- return new BusApplicationContext(cfgFiles, includeDefaults, context, resolver);
- } catch (BeansException ex) {
- LogUtils.log(LOG, Level.WARNING, "INITIAL_APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
- ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
- if (contextLoader != BusApplicationContext.class.getClassLoader()) {
- Thread.currentThread().setContextClassLoader(
- BusApplicationContext.class.getClassLoader());
- try {
- return new BusApplicationContext(cfgFiles, includeDefaults, context);
- } finally {
- Thread.currentThread().setContextClassLoader(contextLoader);
- }
- } else {
- throw ex;
- }
- }
- }
-
- public Bus createBus(URL url) {
- return createBus(url, defaultBusNotExists());
- }
- public Bus createBus(URL[] urls) {
- return createBus(urls, defaultBusNotExists());
- }
-
- public Bus createBus(URL url, boolean includeDefaults) {
- if (url == null) {
- return createBus((URL[])null, includeDefaults);
- }
- return createBus(new URL[] {url}, includeDefaults);
- }
-
- public Bus createBus(URL[] urls, boolean includeDefaults) {
- try {
- return finishCreatingBus(createAppContext(urls, includeDefaults));
- } catch (BeansException ex) {
- LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[])null);
- throw new RuntimeException(ex);
- }
- }
-
- protected ConfigurableApplicationContext createAppContext(URL[] urls, boolean includeDefaults) {
- return new BusApplicationContext(urls, includeDefaults, context, resolver);
- }
-
- void registerApplicationContextLifeCycleListener(Bus bus, ConfigurableApplicationContext bac) {
- BusLifeCycleManager lm = bus.getExtension(BusLifeCycleManager.class);
- if (null != lm) {
- lm.registerLifeCycleListener(new BusApplicationContextLifeCycleListener(bac));
- }
- }
-
- static class BusApplicationContextLifeCycleListener implements BusLifeCycleListener {
- private ConfigurableApplicationContext bac;
-
- BusApplicationContextLifeCycleListener(ConfigurableApplicationContext b) {
- bac = b;
- }
-
- public void initComplete() {
- }
-
- public void preShutdown() {
- }
-
- public void postShutdown() {
- bac.close();
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java b/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
deleted file mode 100644
index b67fd94..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
+++ /dev/null
@@ -1,146 +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.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.sax.SAXSource;
-
-import org.w3c.dom.Document;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-
-import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.cxf.staxutils.W3CDOMStreamWriter;
-import org.springframework.beans.factory.xml.DefaultDocumentLoader;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-
-/**
- * A Spring DocumentLoader that uses WoodStox when we are not validating to speed up the process.
- */
-class TunedDocumentLoader extends DefaultDocumentLoader {
- private static final Logger LOG = LogUtils.getL7dLogger(TunedDocumentLoader.class);
-
- private static boolean hasFastInfoSet;
-
- static {
- try {
- ClassLoaderUtils
- .loadClass("com.sun.xml.fastinfoset.stax.StAXDocumentParser",
- TunedDocumentLoader.class);
- hasFastInfoSet = true;
- } catch (Throwable e) {
- LOG.fine("FastInfoset not found on classpath. Disabling context load optimizations.");
- hasFastInfoSet = false;
- }
- }
- private SAXParserFactory saxParserFactory;
- private SAXParserFactory nsasaxParserFactory;
-
- TunedDocumentLoader() {
- try {
- Class<?> cls = ClassLoaderUtils.loadClass("com.ctc.wstx.sax.WstxSAXParserFactory",
- TunedDocumentLoader.class);
- saxParserFactory = (SAXParserFactory)cls.newInstance();
- nsasaxParserFactory = (SAXParserFactory)cls.newInstance();
- } catch (Throwable e) {
- //woodstox not found, use any other Stax parser
- saxParserFactory = SAXParserFactory.newInstance();
- nsasaxParserFactory = SAXParserFactory.newInstance();
- }
-
- try {
- nsasaxParserFactory.setFeature("http://xml.org/sax/features/namespaces", true);
- nsasaxParserFactory.setFeature("http://xml.org/sax/features/namespace-prefixes",
- true);
- } catch (Throwable e) {
- //ignore
- }
-
- }
-
- public static boolean hasFastInfoSet() {
- return hasFastInfoSet;
- }
-
- @Override
- public Document loadDocument(InputSource inputSource, EntityResolver entityResolver,
- ErrorHandler errorHandler, int validationMode, boolean namespaceAware)
- throws Exception {
- if (validationMode == XmlBeanDefinitionReader.VALIDATION_NONE) {
- SAXParserFactory parserFactory =
- namespaceAware ? nsasaxParserFactory : saxParserFactory;
- SAXParser parser = parserFactory.newSAXParser();
- XMLReader reader = parser.getXMLReader();
- reader.setEntityResolver(entityResolver);
- reader.setErrorHandler(errorHandler);
- SAXSource saxSource = new SAXSource(reader, inputSource);
- W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
- StaxUtils.copy(saxSource, writer);
- return writer.getDocument();
- } else {
- return super.loadDocument(inputSource, entityResolver, errorHandler, validationMode,
- namespaceAware);
- }
- }
-
- @Override
- protected DocumentBuilderFactory createDocumentBuilderFactory(int validationMode, boolean namespaceAware)
- throws ParserConfigurationException {
- DocumentBuilderFactory factory = super.createDocumentBuilderFactory(validationMode, namespaceAware);
- try {
- factory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
- } catch (Throwable e) {
- // we can get all kinds of exceptions from this
- // due to old copies of Xerces and whatnot.
- }
-
- return factory;
- }
-
- static Document loadFastinfosetDocument(URL url)
- throws IOException, ParserConfigurationException, XMLStreamException {
- InputStream is = url.openStream();
- InputStream in = new BufferedInputStream(is);
- XMLStreamReader staxReader = new StAXDocumentParser(in);
- W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
- StaxUtils.copy(staxReader, writer);
- in.close();
- return writer.getDocument();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index 461c84a..6f19990 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -38,18 +38,6 @@ public class ClassHelper {
}
private static ClassHelper getClassHelper() {
- boolean useSpring = true;
- String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
- if (!StringUtils.isEmpty(s)) {
- useSpring = "1".equals(s) || Boolean.parseBoolean(s);
- }
- if (useSpring) {
- try {
- return new SpringAopClassHelper();
- } catch (Throwable ex) {
- // ignore
- }
- }
return new ClassHelper();
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
index 7b4c34a..bf1405f 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
@@ -48,18 +48,6 @@ public class ClasspathScanner {
}
private static ClasspathScanner getClasspathScanner() {
- boolean useSpring = true;
- String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
- if (!StringUtils.isEmpty(s)) {
- useSpring = "1".equals(s) || Boolean.parseBoolean(s);
- }
- if (useSpring) {
- try {
- return new SpringClasspathScanner();
- } catch (Throwable ex) {
- // ignore
- }
- }
return new ClasspathScanner();
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
deleted file mode 100644
index 7282f01..0000000
--- a/core/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
+++ /dev/null
@@ -1,92 +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.common.util;
-
-import org.springframework.aop.TargetSource;
-import org.springframework.aop.framework.Advised;
-import org.springframework.aop.support.AopUtils;
-import org.springframework.beans.factory.BeanCreationException;
-import org.springframework.util.ClassUtils;
-
-/**
- *
- */
-class SpringAopClassHelper extends ClassHelper {
- SpringAopClassHelper() throws Exception {
- Class.forName("org.springframework.aop.support.AopUtils");
- Class.forName("org.springframework.aop.framework.Advised");
- }
-
- protected Class<?> getRealClassFromClassInternal(Class<?> cls) {
- if (ClassUtils.isCglibProxyClass(cls)) {
- return getRealClassFromClassInternal(cls.getSuperclass());
- }
- return cls;
- }
- protected Object getRealObjectInternal(Object o) {
- if (o instanceof Advised) {
- try {
-
- Advised advised = (Advised)o;
- Object target = advised.getTargetSource().getTarget();
- //could be a proxy of a proxy.....
- return getRealObjectInternal(target);
- } catch (Exception ex) {
- // ignore
- }
- }
- return o;
- }
-
- protected Class<?> getRealClassInternal(Object o) {
- if (AopUtils.isAopProxy(o) && (o instanceof Advised)) {
- Advised advised = (Advised)o;
- try {
- TargetSource targetSource = advised.getTargetSource();
-
- Object target = null;
-
- try {
- target = targetSource.getTarget();
- } catch (BeanCreationException ex) {
- // some scopes such as 'request' may not
- // be active on the current thread yet
- return getRealClassFromClassInternal(targetSource.getTargetClass());
- }
-
- if (target == null) {
- Class<?> targetClass = AopUtils.getTargetClass(o);
- if (targetClass != null) {
- return getRealClassFromClassInternal(targetClass);
- }
- } else {
- return getRealClassInternal(target);
- }
- } catch (Exception ex) {
- // ignore
- }
-
- } else if (ClassUtils.isCglibProxyClass(o.getClass())) {
- return getRealClassFromClassInternal(AopUtils.getTargetClass(o));
- }
- return o.getClass();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
deleted file mode 100644
index 650e793..0000000
--- a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
+++ /dev/null
@@ -1,201 +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.common.util;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.util.ClassUtils;
-
-class SpringClasspathScanner extends ClasspathScanner {
-
- private static final Boolean IN_OSGI;
- static {
- IN_OSGI = isSpringInOsgi();
- }
- SpringClasspathScanner() throws Exception {
- Class.forName("org.springframework.core.io.support.PathMatchingResourcePatternResolver");
- Class.forName("org.springframework.core.type.classreading.CachingMetadataReaderFactory");
- }
- private static boolean isSpringInOsgi() {
- try {
- Class.forName("org.springframework.osgi.io.OsgiBundleResourcePatternResolver");
- Class.forName("org.springframework.osgi.util.BundleDelegatingClassLoader");
- return true;
- } catch (Throwable ex) {
- return false;
- }
- }
-
- protected Map< Class< ? extends Annotation >, Collection< Class< ? > > > findClassesInternal(
- Collection< String > basePackages,
- List<Class< ? extends Annotation > > annotations,
- ClassLoader loader)
- throws IOException, ClassNotFoundException {
-
- ResourcePatternResolver resolver = getResolver(loader);
- MetadataReaderFactory factory = new CachingMetadataReaderFactory(resolver);
-
- final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
- new HashMap< Class< ? extends Annotation >, Collection< Class< ? > > >();
- final Map< Class< ? extends Annotation >, Collection< String > > matchingInterfaces =
- new HashMap< Class< ? extends Annotation >, Collection< String > >();
- final Map<String, String[]> nonMatchingClasses = new HashMap<String, String[]>();
-
- for (Class< ? extends Annotation > annotation: annotations) {
- classes.put(annotation, new HashSet< Class < ? > >());
- matchingInterfaces.put(annotation, new HashSet< String >());
- }
-
- if (basePackages == null || basePackages.isEmpty()) {
- return classes;
- }
-
- for (final String basePackage: basePackages) {
- final boolean scanAllPackages = basePackage.equals(WILDCARD);
- final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
- + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(basePackage))
- + ALL_CLASS_FILES;
-
- final Resource[] resources = resolver.getResources(packageSearchPath);
-
-
- for (final Resource resource: resources) {
- final MetadataReader reader = factory.getMetadataReader(resource);
- final AnnotationMetadata metadata = reader.getAnnotationMetadata();
-
- if (scanAllPackages && shouldSkip(metadata.getClassName())) {
- continue;
- }
-
- for (Class< ? extends Annotation > annotation: annotations) {
- boolean concreteClass = !metadata.isInterface() && !metadata.isAbstract();
- if (metadata.isAnnotated(annotation.getName())) {
- if (concreteClass) {
- classes.get(annotation).add(loadClass(metadata.getClassName(), loader));
- } else {
- matchingInterfaces.get(annotation).add(metadata.getClassName());
- }
- } else if (concreteClass && metadata.getInterfaceNames().length > 0) {
- nonMatchingClasses.put(metadata.getClassName(), metadata.getInterfaceNames());
- }
- }
- }
- }
- if (!nonMatchingClasses.isEmpty()) {
- for (Map.Entry<Class<? extends Annotation>, Collection<String>> e1 : matchingInterfaces.entrySet()) {
- for (Map.Entry<String, String[]> e2 : nonMatchingClasses.entrySet()) {
- for (String intName : e2.getValue()) {
- if (e1.getValue().contains(intName)) {
- classes.get(e1.getKey()).add(loadClass(e2.getKey(), loader));
- break;
- }
- }
- }
- }
- }
-
- for (Map.Entry<Class<? extends Annotation>, Collection<String>> e : matchingInterfaces.entrySet()) {
- if (classes.get(e.getKey()).isEmpty()) {
- for (String intName : e.getValue()) {
- classes.get(e.getKey()).add(loadClass(intName, loader));
- }
- }
- }
-
- return classes;
- }
-
- protected List<URL> findResourcesInternal(Collection<String> basePackages,
- String extension,
- ClassLoader loader)
- throws IOException {
- final List<URL> resourceURLs = new ArrayList<URL>();
- if (basePackages == null || basePackages.isEmpty()) {
- return resourceURLs;
- }
- ResourcePatternResolver resolver = getResolver(loader);
-
- for (final String basePackage: basePackages) {
- final boolean scanAllPackages = basePackage.equals(WILDCARD);
-
- String theBasePackage = basePackage;
- if (theBasePackage.startsWith(CLASSPATH_URL_SCHEME)) {
- theBasePackage = theBasePackage.substring(CLASSPATH_URL_SCHEME.length());
- }
-
- final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
- + (scanAllPackages ? "" : basePackage.contains(WILDCARD) ? basePackage
- : ClassUtils.convertClassNameToResourcePath(theBasePackage)) + ALL_FILES + "." + extension;
-
- final Resource[] resources = resolver.getResources(packageSearchPath);
- for (final Resource resource: resources) {
- resourceURLs.add(resource.getURL());
- }
- }
-
- return resourceURLs;
- }
-
- private ResourcePatternResolver getResolver(ClassLoader loader) {
- ResourcePatternResolver resolver = null;
- if (IN_OSGI) {
- resolver = SpringOsgiUtil.getResolver(loader);
- }
- if (resolver == null) {
- resolver = loader != null
- ? new PathMatchingResourcePatternResolver(loader) : new PathMatchingResourcePatternResolver();
- }
- return resolver;
- }
-
- private boolean shouldSkip(final String classname) {
- for (String packageToSkip: PACKAGES_TO_SKIP) {
- if (classname.startsWith(packageToSkip)) {
- return true;
- }
- }
-
- return false;
- }
-
- private Class<?> loadClass(String className, ClassLoader loader)
- throws ClassNotFoundException {
- if (loader == null) {
- return ClassLoaderUtils.loadClass(className, getClass());
- } else {
- return loader.loadClass(className);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/5e965955/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java b/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
deleted file mode 100644
index 26b54b1..0000000
--- a/core/src/main/java/org/apache/cxf/common/util/SpringOsgiUtil.java
+++ /dev/null
@@ -1,44 +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.common.util;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkUtil;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.osgi.io.OsgiBundleResourcePatternResolver;
-import org.springframework.osgi.util.BundleDelegatingClassLoader;
-
-final class SpringOsgiUtil {
-
- private SpringOsgiUtil() {
- }
-
- public static ResourcePatternResolver getResolver(ClassLoader loader) {
- Bundle bundle = null;
- if (loader == null) {
- loader = Thread.currentThread().getContextClassLoader();
- }
- if (loader instanceof BundleDelegatingClassLoader) {
- bundle = ((BundleDelegatingClassLoader)loader).getBundle();
- } else {
- bundle = FrameworkUtil.getBundle(SpringClasspathScanner.class);
- }
- return bundle != null ? new OsgiBundleResourcePatternResolver(bundle) : null;
- }
-}