You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/05/01 17:49:39 UTC
[1/9] Experiment with pulling spring out of core
Repository: cxf
Updated Branches:
refs/heads/split-spring [created] fc2cbb290
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/test.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/test.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/test.xml
new file mode 100644
index 0000000..65506f3
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/test.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
+ <property name="propertyEditorRegistrars">
+ <list merge="true">
+ </list>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
new file mode 100644
index 0000000..8bcecc3
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="testExtension" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestExtension">
+ <constructor-arg ref="cxf"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
new file mode 100644
index 0000000..41094cf
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
@@ -0,0 +1,412 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.configuration.spring;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Set;
+
+import javax.xml.bind.DatatypeConverter;
+import javax.xml.bind.DatatypeConverterInterface;
+import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.bus.spring.BusApplicationContext;
+import org.apache.cxf.configuration.Configurable;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+
+
+
+
+public class ConfigurerImplTest extends Assert {
+
+ static {
+ Class<?> cls;
+ try {
+ try {
+ cls = Class.forName("com.sun.xml.bind.DatatypeConverterImpl");
+ } catch (ClassNotFoundException e) {
+ cls = Class.forName("com.sun.xml.internal.bind.DatatypeConverterImpl");
+ }
+ DatatypeConverterInterface convert = (DatatypeConverterInterface)cls.getField("theInstance")
+ .get(null);
+ DatatypeConverter.setDatatypeConverter(convert);
+ } catch (Exception ex) {
+ //ignore;
+ }
+ }
+
+ @Test
+ public void testConfigureSimpleNoMatchingBean() {
+ SimpleBean sb = new SimpleBean("unknown");
+
+ BusApplicationContext ac =
+ new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
+ false);
+
+ ConfigurerImpl configurer = new ConfigurerImpl(ac);
+ configurer.configureBean(sb);
+ assertEquals("Unexpected value for attribute stringAttr",
+ "hello", sb.getStringAttr());
+ assertTrue("Unexpected value for attribute booleanAttr",
+ sb.getBooleanAttr());
+ assertEquals("Unexpected value for attribute integerAttr",
+ BigInteger.ONE, sb.getIntegerAttr());
+ assertEquals("Unexpected value for attribute intAttr",
+ new Integer(2), sb.getIntAttr());
+ assertEquals("Unexpected value for attribute longAttr",
+ new Long(3L), sb.getLongAttr());
+ assertEquals("Unexpected value for attribute shortAttr",
+ new Short((short)4), sb.getShortAttr());
+ assertEquals("Unexpected value for attribute decimalAttr",
+ new BigDecimal("5"), sb.getDecimalAttr());
+ assertEquals("Unexpected value for attribute floatAttr",
+ new Float(6F), sb.getFloatAttr());
+ assertEquals("Unexpected value for attribute doubleAttr",
+ new Double(7D), sb.getDoubleAttr());
+ assertEquals("Unexpected value for attribute byteAttr",
+ new Byte((byte)8), sb.getByteAttr());
+
+ QName qn = sb.getQnameAttr();
+ assertEquals("Unexpected value for attribute qnameAttrNoDefault",
+ "schema", qn.getLocalPart());
+ assertEquals("Unexpected value for attribute qnameAttrNoDefault",
+ "http://www.w3.org/2001/XMLSchema", qn.getNamespaceURI());
+ byte[] expected = DatatypeConverter.parseBase64Binary("abcd");
+ byte[] val = sb.getBase64BinaryAttr();
+ assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected.length, val.length);
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected[i], val[i]);
+ }
+ expected = new HexBinaryAdapter().unmarshal("aaaa");
+ val = sb.getHexBinaryAttr();
+ assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected.length, val.length);
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected[i], val[i]);
+ }
+
+ assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
+ new Long(9L), sb.getUnsignedIntAttr());
+ assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
+ new Integer(10), sb.getUnsignedShortAttr());
+ assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
+ new Short((short)11), sb.getUnsignedByteAttr());
+ }
+
+ @Test
+ public void testConfigureSimple() {
+ // Try to configure the bean with id
+ verifyConfigureSimple("simple");
+ // Try to configure the bean with an alias name
+ verifyConfigureSimple("simpleValueBean");
+ }
+
+
+ public void verifyConfigureSimple(String beanName) {
+
+ SimpleBean sb = new SimpleBean(beanName);
+ BusApplicationContext ac =
+ new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
+ false);
+
+ ConfigurerImpl configurer = new ConfigurerImpl();
+ configurer.setApplicationContext(ac);
+
+ configurer.configureBean(sb);
+ assertEquals("Unexpected value for attribute stringAttr",
+ "hallo", sb.getStringAttr());
+ assertTrue("Unexpected value for attribute booleanAttr",
+ !sb.getBooleanAttr());
+ assertEquals("Unexpected value for attribute integerAttr",
+ BigInteger.TEN, sb.getIntegerAttr());
+ assertEquals("Unexpected value for attribute intAttr",
+ new Integer(12), sb.getIntAttr());
+ assertEquals("Unexpected value for attribute longAttr",
+ new Long(13L), sb.getLongAttr());
+ assertEquals("Unexpected value for attribute shortAttr",
+ new Short((short)14), sb.getShortAttr());
+ assertEquals("Unexpected value for attribute decimalAttr",
+ new BigDecimal("15"), sb.getDecimalAttr());
+ assertEquals("Unexpected value for attribute floatAttr",
+ new Float(16F), sb.getFloatAttr());
+ assertEquals("Unexpected value for attribute doubleAttr",
+ new Double(17D), sb.getDoubleAttr());
+ assertEquals("Unexpected value for attribute byteAttr",
+ new Byte((byte)18), sb.getByteAttr());
+
+ assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
+ new Long(19L), sb.getUnsignedIntAttr());
+ assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
+ new Integer(20), sb.getUnsignedShortAttr());
+ assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
+ new Short((short)21), sb.getUnsignedByteAttr());
+ }
+
+ @Test
+ public void testConfigureSimpleMatchingStarBeanId() {
+ SimpleBean sb = new SimpleBean("simple2");
+ BusApplicationContext ac =
+ new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
+ false);
+
+ ConfigurerImpl configurer = new ConfigurerImpl();
+ configurer.setApplicationContext(ac);
+ configurer.configureBean(sb);
+ assertTrue("Unexpected value for attribute booleanAttr",
+ !sb.getBooleanAttr());
+ assertEquals("Unexpected value for attribute integerAttr",
+ BigInteger.TEN, sb.getIntegerAttr());
+ assertEquals("Unexpected value for attribute stringAttr",
+ "StarHallo", sb.getStringAttr());
+ }
+
+ @Test
+ public void testConfigureSimpleMatchingStarBeanIdWithChildInstance() {
+ SimpleBean sb = new ChildBean("simple2");
+ BusApplicationContext ac =
+ new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
+ false);
+
+ ConfigurerImpl configurer = new ConfigurerImpl();
+ configurer.setApplicationContext(ac);
+ configurer.configureBean(sb);
+ assertTrue("Unexpected value for attribute booleanAttr",
+ !sb.getBooleanAttr());
+ assertEquals("Unexpected value for attribute integerAttr",
+ BigInteger.TEN, sb.getIntegerAttr());
+ assertEquals("Unexpected value for attribute stringAttr",
+ "StarHallo", sb.getStringAttr());
+ }
+
+ @Test
+ public void testGetBeanName() {
+ ConfigurerImpl configurer = new ConfigurerImpl();
+ Object beanInstance = new Configurable() {
+
+ public String getBeanName() {
+ return "a";
+ }
+ };
+ assertEquals("a", configurer.getBeanName(beanInstance));
+ final class NamedBean {
+ @SuppressWarnings("unused")
+ public String getBeanName() {
+ return "b";
+ }
+ }
+ beanInstance = new NamedBean();
+ assertEquals("b", configurer.getBeanName(beanInstance));
+ beanInstance = this;
+ assertNull(configurer.getBeanName(beanInstance));
+ }
+
+ @Test
+ public void testAddApplicationContext() {
+ ConfigurableApplicationContext context1 =
+ new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
+ ConfigurerImpl configurer = new ConfigurerImpl();
+ configurer.setApplicationContext(context1);
+ // Just to simulate the OSGi's uninstall command
+ context1.close();
+
+ ConfigurableApplicationContext context2 =
+ new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
+ configurer.addApplicationContext(context2);
+ Set<ApplicationContext> contexts = configurer.getAppContexts();
+ assertEquals("The Context's size is wrong", 1, contexts.size());
+ assertTrue("The conetxts' contains a wrong application context", contexts.contains(context2));
+ }
+
+ class SimpleBean implements Configurable {
+
+ private String beanName;
+
+ private String stringAttr = "hello";
+ private Boolean booleanAttr = Boolean.TRUE;
+ private BigInteger integerAttr = BigInteger.ONE;
+ private Integer intAttr = new Integer(2);
+ private Long longAttr = new Long(3);
+ private Short shortAttr = new Short((short)4);
+ private BigDecimal decimalAttr = new BigDecimal("5");
+ private Float floatAttr = new Float(6F);
+ private Double doubleAttr = new Double(7D);
+ private Byte byteAttr = new Byte((byte)8);
+ private QName qnameAttr = new QName("http://www.w3.org/2001/XMLSchema", "schema", "xs");
+ private byte[] base64BinaryAttr = DatatypeConverter.parseBase64Binary("abcd");
+ private byte[] hexBinaryAttr = new HexBinaryAdapter().unmarshal("aaaa");
+ private Long unsignedIntAttr = new Long(9);
+ private Integer unsignedShortAttr = new Integer(10);
+ private Short unsignedByteAttr = new Short((short)11);
+
+
+ public SimpleBean(String bn) {
+ beanName = bn;
+ }
+
+ public String getBeanName() {
+ return beanName;
+ }
+
+ public byte[] getBase64BinaryAttr() {
+ return base64BinaryAttr;
+ }
+
+ public void setBase64BinaryAttr(byte[] base64BinaryAttr) {
+ this.base64BinaryAttr = base64BinaryAttr;
+ }
+
+ public Boolean getBooleanAttr() {
+ return booleanAttr;
+ }
+
+ public void setBooleanAttr(Boolean booleanAttr) {
+ this.booleanAttr = booleanAttr;
+ }
+
+ public Byte getByteAttr() {
+ return byteAttr;
+ }
+
+ public void setByteAttr(Byte byteAttr) {
+ this.byteAttr = byteAttr;
+ }
+
+ public BigDecimal getDecimalAttr() {
+ return decimalAttr;
+ }
+
+ public void setDecimalAttr(BigDecimal decimalAttr) {
+ this.decimalAttr = decimalAttr;
+ }
+
+ public Double getDoubleAttr() {
+ return doubleAttr;
+ }
+
+ public void setDoubleAttr(Double doubleAttr) {
+ this.doubleAttr = doubleAttr;
+ }
+
+ public Float getFloatAttr() {
+ return floatAttr;
+ }
+
+ public void setFloatAttr(Float floatAttr) {
+ this.floatAttr = floatAttr;
+ }
+
+ public byte[] getHexBinaryAttr() {
+ return hexBinaryAttr;
+ }
+
+ public void setHexBinaryAttr(byte[] hexBinaryAttr) {
+ this.hexBinaryAttr = hexBinaryAttr;
+ }
+
+ public Integer getIntAttr() {
+ return intAttr;
+ }
+
+ public void setIntAttr(Integer intAttr) {
+ this.intAttr = intAttr;
+ }
+
+ public BigInteger getIntegerAttr() {
+ return integerAttr;
+ }
+
+ public void setIntegerAttr(BigInteger integerAttr) {
+ this.integerAttr = integerAttr;
+ }
+
+ public Long getLongAttr() {
+ return longAttr;
+ }
+
+ public void setLongAttr(Long longAttr) {
+ this.longAttr = longAttr;
+ }
+
+ public QName getQnameAttr() {
+ return qnameAttr;
+ }
+
+ public void setQnameAttr(QName qnameAttr) {
+ this.qnameAttr = qnameAttr;
+ }
+
+ public Short getShortAttr() {
+ return shortAttr;
+ }
+
+ public void setShortAttr(Short shortAttr) {
+ this.shortAttr = shortAttr;
+ }
+
+ public String getStringAttr() {
+ return stringAttr;
+ }
+
+ public void setStringAttr(String stringAttr) {
+ this.stringAttr = stringAttr;
+ }
+
+ public Short getUnsignedByteAttr() {
+ return unsignedByteAttr;
+ }
+
+ public void setUnsignedByteAttr(Short unsignedByteAttr) {
+ this.unsignedByteAttr = unsignedByteAttr;
+ }
+
+ public Long getUnsignedIntAttr() {
+ return unsignedIntAttr;
+ }
+
+ public void setUnsignedIntAttr(Long unsignedIntAttr) {
+ this.unsignedIntAttr = unsignedIntAttr;
+ }
+
+ public Integer getUnsignedShortAttr() {
+ return unsignedShortAttr;
+ }
+
+ public void setUnsignedShortAttr(Integer unsignedShortAttr) {
+ this.unsignedShortAttr = unsignedShortAttr;
+ }
+
+ public void setBeanName(String beanName) {
+ this.beanName = beanName;
+ }
+ }
+
+ class ChildBean extends SimpleBean {
+
+ public ChildBean(String bn) {
+ super(bn);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/configuration/spring/bean.properties
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/configuration/spring/bean.properties b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/bean.properties
new file mode 100644
index 0000000..9199905
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/bean.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+simple.name=simpleValueBean
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
new file mode 100644
index 0000000..359bb47
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="location" value="org/apache/cxf/configuration/spring/bean.properties"/>
+ </bean>
+ <bean name="*2" abstract="true" class="org.apache.cxf.configuration.spring.ConfigurerImplTest$SimpleBean">
+ <property name="stringAttr" value="StarHallo"/>
+ </bean>
+ <!-- additional wildcards for class SimpleBean will be ignored with a warning -->
+ <bean name="*duplicateWildcardForClassWillBeIgnored" abstract="true" class="SimpleBean">
+ <property name="stringAttr" value="duplicateWildcardForClassWillBeIgnored"/>
+ </bean>
+ <!-- wildcards bean with no class will be ignored with a warning -->
+ <bean name="*willBeIgnoredBecausOfNoClass" abstract="true">
+ <property name="stringAttr" value="willBeIgnoredBecausOfNoClass"/>
+ </bean>
+ <bean id="simple2" lazy-init="true">
+ <property name="booleanAttr" value="false"/>
+ <property name="integerAttr" value="10"/>
+ </bean>
+ <bean id="simple" name="${simple.name}" lazy-init="true">
+ <property name="stringAttr" value="hallo"/>
+ <property name="booleanAttr" value="false"/>
+ <property name="integerAttr" value="10"/>
+ <property name="intAttr" value="12"/>
+ <property name="longAttr" value="13"/>
+ <property name="shortAttr" value="14"/>
+ <property name="decimalAttr" value="15"/>
+ <property name="floatAttr" value="16"/>
+ <property name="doubleAttr" value="17"/>
+ <property name="byteAttr" value="18"/>
+ <!--
+ <property name="qnameAttr" value="xs:string"/>
+ -->
+ <property name="base64BinaryAttr" value="abcd"/>
+ <property name="hexBinaryAttr" value="bbbb"/>
+ <property name="unsignedIntAttr" value="19"/>
+ <property name="unsignedShortAttr" value="20"/>
+ <property name="unsignedByteAttr" value="21"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
new file mode 100644
index 0000000..801968a
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="complex" class="org.apache.cxf.configuration.spring.JaxbPropertyEditorTest$FooBean" lazy-init="true">
+ <property name="name">
+ <value>foam</value>
+ </property>
+ <property name="position">
+ <value>
+ <foo:point>
+ <foo:x>12</foo:x>
+ <foo:y>33</foo:y>
+ </foo:point>
+ </value>
+ </property>
+ <property name="address">
+ <value>
+ <foo:address>
+ <foo:city>Dublin</foo:city>
+ <foo:zip>4</foo:zip>
+ <foo:street>Shelbourne Rd</foo:street>
+ </foo:address>
+ </value>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index d2af63c..1925908 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -74,6 +74,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/transports/http-netty/netty-server/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/pom.xml b/rt/transports/http-netty/netty-server/pom.xml
index aeb6a5b..b015f23 100644
--- a/rt/transports/http-netty/netty-server/pom.xml
+++ b/rt/transports/http-netty/netty-server/pom.xml
@@ -53,6 +53,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${cxf.netty.version}</version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/transports/http/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http/pom.xml b/rt/transports/http/pom.xml
index f5a7c57..56b01b7 100644
--- a/rt/transports/http/pom.xml
+++ b/rt/transports/http/pom.xml
@@ -83,6 +83,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/ws/addr/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/addr/pom.xml b/rt/ws/addr/pom.xml
index 803d37d..63e062f 100644
--- a/rt/ws/addr/pom.xml
+++ b/rt/ws/addr/pom.xml
@@ -78,6 +78,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/ws/policy/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/policy/pom.xml b/rt/ws/policy/pom.xml
index 3b03dd7..6b16df9 100644
--- a/rt/ws/policy/pom.xml
+++ b/rt/ws/policy/pom.xml
@@ -92,6 +92,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/ws/rm/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/rm/pom.xml b/rt/ws/rm/pom.xml
index 086dca3..2354f72 100644
--- a/rt/ws/rm/pom.xml
+++ b/rt/ws/rm/pom.xml
@@ -71,6 +71,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/testutils/pom.xml
----------------------------------------------------------------------
diff --git a/testutils/pom.xml b/testutils/pom.xml
index 8853fd7..a2fd487 100644
--- a/testutils/pom.xml
+++ b/testutils/pom.xml
@@ -47,6 +47,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/tools/javato/ws/pom.xml
----------------------------------------------------------------------
diff --git a/tools/javato/ws/pom.xml b/tools/javato/ws/pom.xml
index f7192d5..4c2abb4 100644
--- a/tools/javato/ws/pom.xml
+++ b/tools/javato/ws/pom.xml
@@ -43,6 +43,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
<version>${project.version}</version>
</dependency>
[3/9] Experiment with pulling spring out of core
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
new file mode 100644
index 0000000..d3f200d
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
@@ -0,0 +1,299 @@
+/**
+ * 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;
+ }
+ bus = bb;
+ if (properties != null) {
+ bus.setProperties(properties);
+ properties = null;
+ }
+ if (!getInInterceptors().isEmpty()) {
+ bus.getInInterceptors().addAll(getInInterceptors());
+ }
+ if (!getOutInterceptors().isEmpty()) {
+ bus.getOutInterceptors().addAll(getOutInterceptors());
+ }
+ if (!getInFaultInterceptors().isEmpty()) {
+ bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
+ }
+ if (!getOutFaultInterceptors().isEmpty()) {
+ bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
+ }
+ if (!StringUtils.isEmpty(id)) {
+ bus.setId(id);
+ }
+ if (features != null) {
+ bus.setFeatures(features);
+ features = null;
+ }
+ }
+
+ 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
new file mode 100644
index 0000000..65d3ffc
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
@@ -0,0 +1,89 @@
+/**
+ * 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
new file mode 100644
index 0000000..3c6369d
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusExtensionPostProcessor.java
@@ -0,0 +1,71 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
new file mode 100644
index 0000000..e24da64
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
@@ -0,0 +1,174 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
new file mode 100644
index 0000000..007ce70
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
@@ -0,0 +1,197 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
new file mode 100644
index 0000000..25748bf
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/Jsr250BeanPostProcessor.java
@@ -0,0 +1,157 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/Messages.properties b/rt/spring/src/main/java/org/apache/cxf/bus/spring/Messages.properties
new file mode 100644
index 0000000..3783c8e
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/Messages.properties
@@ -0,0 +1,27 @@
+#
+#
+# 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
new file mode 100644
index 0000000..9a67b84
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/NamespaceHandler.java
@@ -0,0 +1,57 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
new file mode 100644
index 0000000..6686cd1
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
@@ -0,0 +1,313 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBus.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
new file mode 100644
index 0000000..648431d
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
@@ -0,0 +1,145 @@
+/**
+ * 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);
+ }
+
+ public void loadAdditionalFeatures() {
+ super.loadAdditionalFeatures();
+ }
+
+ /** {@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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
new file mode 100644
index 0000000..04ea866
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
@@ -0,0 +1,227 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
new file mode 100644
index 0000000..b67fd94
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
@@ -0,0 +1,146 @@
+/**
+ * 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();
+ }
+
+}
[6/9] git commit: Experiment with pulling spring out of core
Posted by dk...@apache.org.
Experiment with pulling spring out of core
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e46d0180
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e46d0180
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e46d0180
Branch: refs/heads/split-spring
Commit: e46d018083182277bf302961e61461ca672efa9d
Parents: d7cb537
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Apr 30 21:56:22 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Apr 30 21:56:22 2014 -0400
----------------------------------------------------------------------
.../cxf/bus/spring/BusApplicationContext.java | 337 ------------
.../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 | 145 ------
.../apache/cxf/bus/spring/SpringBusFactory.java | 227 --------
.../cxf/bus/spring/TunedDocumentLoader.java | 146 ------
.../spring/AbstractBeanDefinitionParser.java | 520 -------------------
.../AbstractFactoryBeanDefinitionParser.java | 153 ------
.../cxf/configuration/spring/BusWiringType.java | 37 --
.../configuration/spring/ConfigurerImpl.java | 281 ----------
.../configuration/spring/JAXBBeanFactory.java | 73 ---
.../configuration/spring/Messages.properties | 26 -
.../spring/SimpleBeanDefinitionParser.java | 33 --
.../spring/StringBeanDefinitionParser.java | 39 --
.../src/main/resources/META-INF/spring.handlers | 21 -
.../bus/spring/BusApplicationContextTest.java | 48 --
.../bus/spring/BusApplicationListenerTest.java | 53 --
.../cxf/bus/spring/BusDefinitionParserTest.java | 168 ------
.../cxf/bus/spring/SpringBusFactoryTest.java | 279 ----------
.../test/java/org/apache/cxf/bus/spring/bus.xml | 30 --
.../org/apache/cxf/bus/spring/customerBus.xml | 31 --
.../org/apache/cxf/bus/spring/customerBus2.xml | 31 --
.../java/org/apache/cxf/bus/spring/init.xml | 29 --
.../org/apache/cxf/bus/spring/lazyInitBus.xml | 26 -
.../cxf/bus/spring/resources/bus-overwrite.xml | 59 ---
.../java/org/apache/cxf/bus/spring/test.xml | 27 -
.../org/apache/cxf/bus/spring/testjsr250.xml | 24 -
.../spring/ConfigurerImplTest.java | 412 ---------------
.../cxf/configuration/spring/bean.properties | 17 -
.../cxf/configuration/spring/test-beans.xml | 59 ---
.../configuration/spring/test-jaxb-beans.xml | 43 --
integration/jca/pom.xml | 5 +
rt/bindings/object/pom.xml | 6 +
rt/bindings/soap/pom.xml | 6 +
rt/databinding/xmlbeans/pom.xml | 6 +
rt/features/clustering/pom.xml | 6 +
rt/frontend/jaxrs/pom.xml | 6 +
rt/frontend/jaxws/pom.xml | 6 +
rt/frontend/simple/pom.xml | 6 +
rt/management/pom.xml | 6 +
rt/pom.xml | 1 +
rt/rs/client/pom.xml | 6 +
rt/spring/pom.xml | 84 +++
.../cxf/bus/spring/BusApplicationContext.java | 337 ++++++++++++
.../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 | 145 ++++++
.../apache/cxf/bus/spring/SpringBusFactory.java | 227 ++++++++
.../cxf/bus/spring/TunedDocumentLoader.java | 146 ++++++
.../spring/AbstractBeanDefinitionParser.java | 520 +++++++++++++++++++
.../AbstractFactoryBeanDefinitionParser.java | 153 ++++++
.../cxf/configuration/spring/BusWiringType.java | 37 ++
.../configuration/spring/ConfigurerImpl.java | 281 ++++++++++
.../configuration/spring/JAXBBeanFactory.java | 73 +++
.../configuration/spring/Messages.properties | 26 +
.../spring/SimpleBeanDefinitionParser.java | 33 ++
.../spring/StringBeanDefinitionParser.java | 39 ++
.../src/main/resources/META-INF/spring.handlers | 21 +
.../bus/spring/BusApplicationContextTest.java | 48 ++
.../bus/spring/BusApplicationListenerTest.java | 53 ++
.../cxf/bus/spring/BusDefinitionParserTest.java | 168 ++++++
.../cxf/bus/spring/SpringBusFactoryTest.java | 279 ++++++++++
.../test/java/org/apache/cxf/bus/spring/bus.xml | 30 ++
.../org/apache/cxf/bus/spring/customerBus.xml | 31 ++
.../org/apache/cxf/bus/spring/customerBus2.xml | 31 ++
.../java/org/apache/cxf/bus/spring/init.xml | 29 ++
.../org/apache/cxf/bus/spring/lazyInitBus.xml | 26 +
.../cxf/bus/spring/resources/bus-overwrite.xml | 59 +++
.../java/org/apache/cxf/bus/spring/test.xml | 27 +
.../org/apache/cxf/bus/spring/testjsr250.xml | 24 +
.../spring/ConfigurerImplTest.java | 412 +++++++++++++++
.../cxf/configuration/spring/bean.properties | 17 +
.../cxf/configuration/spring/test-beans.xml | 59 +++
.../configuration/spring/test-jaxb-beans.xml | 43 ++
rt/transports/http-jetty/pom.xml | 6 +
rt/transports/http-netty/netty-server/pom.xml | 6 +
rt/transports/http/pom.xml | 6 +
rt/ws/addr/pom.xml | 6 +
rt/ws/policy/pom.xml | 6 +
rt/ws/rm/pom.xml | 6 +
testutils/pom.xml | 5 +
tools/javato/ws/pom.xml | 5 +
98 files changed, 5052 insertions(+), 4862 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/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 5f086b7..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
+++ /dev/null
@@ -1,337 +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.security.AccessControlException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.SystemPropertyAction;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.interceptor.Fault;
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.beans.factory.xml.BeansDtdResolver;
-import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
-import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
-import org.springframework.beans.factory.xml.PluggableSchemaResolver;
-import org.springframework.beans.factory.xml.ResourceEntityResolver;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextException;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.UrlResource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-
-public class BusApplicationContext extends ClassPathXmlApplicationContext {
-
- private static final String DEFAULT_CXF_CFG_FILE = "META-INF/cxf/cxf.xml";
- private static final String DEFAULT_CXF_EXT_CFG_FILE = "classpath*:META-INF/cxf/cxf.extension";
-
- private static final Logger LOG = LogUtils.getL7dLogger(BusApplicationContext.class);
-
- private NamespaceHandlerResolver nsHandlerResolver;
- private boolean includeDefaults;
- private String[] cfgFiles;
- private URL[] cfgFileURLs;
-
- public BusApplicationContext(String cf, boolean include) {
- this(cf, include, null);
- }
- public BusApplicationContext(String[] cfs, boolean include) {
- this(cfs, include, null);
- }
-
- public BusApplicationContext(URL url, boolean include) {
- this(url, include, null);
- }
- public BusApplicationContext(URL[] urls, boolean include) {
- this(urls, include, null);
- }
-
- public BusApplicationContext(String cf, boolean include, ApplicationContext parent) {
- this(new String[] {cf}, include, parent);
- }
-
- public BusApplicationContext(URL url, boolean include, ApplicationContext parent) {
- this(new URL[] {url}, include, parent, null);
- }
- public BusApplicationContext(String[] cf, boolean include, ApplicationContext parent) {
- this(cf, include, parent, null);
- }
- public BusApplicationContext(String[] cf, boolean include,
- ApplicationContext parent, NamespaceHandlerResolver res) {
- super(new String[0], false, parent);
- cfgFiles = cf;
- includeDefaults = include;
- nsHandlerResolver = res;
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
- public Boolean run() throws Exception {
- refresh();
- return Boolean.TRUE;
- }
-
- });
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof RuntimeException) {
- throw (RuntimeException)e.getException();
- }
- throw new Fault(e);
- }
- }
- public BusApplicationContext(URL[] url, boolean include,
- ApplicationContext parent) {
- this(url, include, parent, null);
- }
- public BusApplicationContext(URL[] url, boolean include,
- ApplicationContext parent,
- NamespaceHandlerResolver res) {
- super(new String[0], false, parent);
- cfgFileURLs = url;
- includeDefaults = include;
- nsHandlerResolver = res;
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
- public Boolean run() throws Exception {
- refresh();
- return Boolean.TRUE;
- }
-
- });
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof RuntimeException) {
- throw (RuntimeException)e.getException();
- }
- throw new Fault(e);
- }
- }
-
- @Override
- protected Resource[] getConfigResources() {
- List<Resource> resources = new ArrayList<Resource>();
-
- if (includeDefaults) {
- try {
- PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread
- .currentThread().getContextClassLoader());
-
- Collections.addAll(resources, resolver.getResources(DEFAULT_CXF_CFG_FILE));
-
- Resource[] exts = resolver.getResources(DEFAULT_CXF_EXT_CFG_FILE);
- for (Resource r : exts) {
- InputStream is = r.getInputStream();
- BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- String line = rd.readLine();
- while (line != null) {
- if (!"".equals(line)) {
- resources.add(resolver.getResource(line));
- }
- line = rd.readLine();
- }
- is.close();
- }
-
- } catch (IOException ex) {
- // ignore
- }
- }
-
- boolean usingDefault = false;
- if (null == cfgFiles) {
- String cfgFile = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_NAME);
- if (cfgFile != null) {
- cfgFiles = new String[] {cfgFile};
- }
- }
- if (null == cfgFiles) {
- cfgFiles = new String[] {Configurer.DEFAULT_USER_CFG_FILE};
- usingDefault = true;
- }
- for (String cfgFile : cfgFiles) {
- final Resource cpr = findResource(cfgFile);
- boolean exists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
- public Boolean run() {
- return cpr != null && cpr.exists();
- }
-
- });
- if (exists) {
- resources.add(cpr);
- LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
- } else {
- if (!usingDefault) {
- LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
- String message = (new Message("USER_CFG_FILE_NOT_LOADED", LOG, cfgFile)).toString();
- throw new ApplicationContextException(message);
- }
- }
- }
-
- if (null != cfgFileURLs) {
- for (URL cfgFileURL : cfgFileURLs) {
- UrlResource ur = new UrlResource(cfgFileURL);
- if (ur.exists()) {
- resources.add(ur);
- } else {
- LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", cfgFileURL);
- }
- }
- }
-
- String sysCfgFileUrl = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_URL);
- if (null != sysCfgFileUrl) {
- try {
- UrlResource ur = new UrlResource(sysCfgFileUrl);
- if (ur.exists()) {
- resources.add(ur);
- } else {
- LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", sysCfgFileUrl);
- }
- } catch (MalformedURLException e) {
- LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_ERROR_MSG", sysCfgFileUrl);
- }
- }
-
- if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Creating application context with resources: " + resources);
- }
-
- if (0 == resources.size()) {
- return null;
- }
- Resource[] res = new Resource[resources.size()];
- res = resources.toArray(res);
- return res;
- }
-
- public static Resource findResource(final String cfgFile) {
- try {
- return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
- public Resource run() {
- Resource cpr = new ClassPathResource(cfgFile);
- if (cpr.exists()) {
- return cpr;
- }
- try {
- //see if it's a URL
- URL url = new URL(cfgFile);
- cpr = new UrlResource(url);
- if (cpr.exists()) {
- return cpr;
- }
- } catch (MalformedURLException e) {
- //ignore
- }
- //try loading it our way
- URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
- if (url != null) {
- cpr = new UrlResource(url);
- if (cpr.exists()) {
- return cpr;
- }
- }
- cpr = new FileSystemResource(cfgFile);
- if (cpr.exists()) {
- return cpr;
- }
- return null;
- }
- });
- } catch (AccessControlException ex) {
- //cannot read the user config file
- return null;
- }
- }
-
- @Override
- protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
- // Spring always creates a new one of these, which takes a fair amount
- // of time on startup (nearly 1/2 second) as it gets created for every
- // spring context on the classpath
- if (nsHandlerResolver == null) {
- nsHandlerResolver = new DefaultNamespaceHandlerResolver();
- }
- reader.setNamespaceHandlerResolver(nsHandlerResolver);
-
- String mode = getSpringValidationMode();
- if (null != mode) {
- reader.setValidationModeName(mode);
- }
- reader.setNamespaceAware(true);
-
- setEntityResolvers(reader);
- }
-
- static String getSpringValidationMode() {
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- String mode = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.spring.validation.mode");
- if (mode == null) {
- mode = SystemPropertyAction.getPropertyOrNull("spring.validation.mode");
- }
- return mode;
- }
- });
- }
-
-
- void setEntityResolvers(XmlBeanDefinitionReader reader) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- reader.setEntityResolver(new BusEntityResolver(cl, new BeansDtdResolver(),
- new PluggableSchemaResolver(cl)));
- }
- @Override
- protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException {
- // Create a new XmlBeanDefinitionReader for the given BeanFactory.
- XmlBeanDefinitionReader beanDefinitionReader =
- new ControlledValidationXmlBeanDefinitionReader(beanFactory);
- beanDefinitionReader.setNamespaceHandlerResolver(nsHandlerResolver);
-
- // Configure the bean definition reader with this context's
- // resource loading environment.
- beanDefinitionReader.setResourceLoader(this);
- beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
-
- // Allow a subclass to provide custom initialization of the reader,
- // then proceed with actually loading the bean definitions.
- initBeanDefinitionReader(beanDefinitionReader);
- loadBeanDefinitions(beanDefinitionReader);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/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/e46d0180/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 d3f200d..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;
- }
- bus = bb;
- if (properties != null) {
- bus.setProperties(properties);
- properties = null;
- }
- if (!getInInterceptors().isEmpty()) {
- bus.getInInterceptors().addAll(getInInterceptors());
- }
- if (!getOutInterceptors().isEmpty()) {
- bus.getOutInterceptors().addAll(getOutInterceptors());
- }
- if (!getInFaultInterceptors().isEmpty()) {
- bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
- }
- if (!getOutFaultInterceptors().isEmpty()) {
- bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
- }
- if (!StringUtils.isEmpty(id)) {
- bus.setId(id);
- }
- if (features != null) {
- bus.setFeatures(features);
- features = null;
- }
- }
-
- 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/e46d0180/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;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/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/e46d0180/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/e46d0180/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/e46d0180/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/e46d0180/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/e46d0180/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/e46d0180/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);
- }
-
-}
[4/9] Experiment with pulling spring out of core
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java b/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
deleted file mode 100644
index abb89a5..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.bus.spring;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.List;
-import java.util.SortedSet;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.bus.managers.PhaseManagerImpl;
-import org.apache.cxf.buslifecycle.BusLifeCycleListener;
-import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.phase.PhaseManager;
-import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.transport.ConduitInitiatorManager;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.workqueue.WorkQueueManager;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class SpringBusFactoryTest extends Assert {
-
- @After
- public void tearDown() {
- BusFactory.setDefaultBus(null);
- }
-
- @Test
- public void testDefault() {
- Bus bus = new SpringBusFactory().createBus();
- assertNotNull(bus);
- BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
- assertNotNull("No binding factory manager", bfm);
- assertNotNull("No configurer", bus.getExtension(Configurer.class));
- assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
- assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
- assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
- assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
- assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
- assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
- assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
-
- try {
- bfm.getBindingFactory("http://cxf.apache.org/unknown");
- } catch (BusException ex) {
- // expected
- }
-
- assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
- assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
-
- }
-
- @Test
- public void testCustomFileName() {
- String cfgFile = "org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
- checkCustomerConfiguration(bus);
- }
-
- @Test
- public void testCustomerBusShutdown() {
- String cfgFile = "org/apache/cxf/bus/spring/customerBus.xml";
- Bus bus = new SpringBusFactory().createBus(cfgFile, true);
- // We have three bus here, which should be closed rightly
- bus.shutdown(true);
- }
-
- @Test
- public void testCustomFileURLFromSystemProperty() {
- URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
- System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());
- Bus bus = new SpringBusFactory().createBus((String)null, true);
- checkCustomerConfiguration(bus);
- System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
- }
-
- @Test
- public void testCustomFileURL() {
- URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
- Bus bus = new SpringBusFactory().createBus(cfgFileURL, true);
- checkCustomerConfiguration(bus);
- }
-
- private void checkCustomerConfiguration(Bus bus) {
- assertNotNull(bus);
- List<Interceptor<? extends Message>> interceptors = bus.getInInterceptors();
- assertEquals("Unexpected number of interceptors", 2, interceptors.size());
- assertEquals("Unexpected interceptor", "in-a", interceptors.get(0).toString());
- assertEquals("Unexpected interceptor", "in-b", interceptors.get(1).toString());
- interceptors = bus.getInFaultInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "in-fault", interceptors.get(0).toString());
- interceptors = bus.getOutFaultInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "out-fault", interceptors.get(0).toString());
- interceptors = bus.getOutInterceptors();
- assertEquals("Unexpected number of interceptors", 1, interceptors.size());
- assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
- }
-
- @Test
- public void testForLifeCycle() {
- BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.class);
- Bus bus = new SpringBusFactory().createBus();
- BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
- lifeCycleManager.registerLifeCycleListener(bl);
- EasyMock.reset(bl);
- bl.preShutdown();
- EasyMock.expectLastCall();
- bl.postShutdown();
- EasyMock.expectLastCall();
- EasyMock.replay(bl);
- bus.shutdown(true);
- EasyMock.verify(bl);
-
- }
-
- @Test
- public void testPhases() {
- Bus bus = new SpringBusFactory().createBus();
- PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
- PhaseManager defaultPM = new PhaseManagerImpl();
- SortedSet<Phase> cxfPhases = cxfPM.getInPhases();
- SortedSet<Phase> defaultPhases = defaultPM.getInPhases();
- assertEquals(defaultPhases.size(), cxfPhases.size());
- assertTrue(cxfPhases.equals(defaultPhases));
- cxfPhases = cxfPM.getOutPhases();
- defaultPhases = defaultPM.getOutPhases();
- assertEquals(defaultPhases.size(), cxfPhases.size());
- assertTrue(cxfPhases.equals(defaultPhases));
- }
-
- @Test
- public void testJsr250() {
- Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/testjsr250.xml");
- TestExtension te = bus.getExtension(TestExtension.class);
- assertTrue("@PostConstruct annotated method has not been called.", te.postConstructMethodCalled);
- assertTrue("@PreDestroy annoated method has been called already.", !te.preDestroyMethodCalled);
- bus.shutdown(true);
- assertTrue("@PreDestroy annotated method has not been called.", te.preDestroyMethodCalled);
-
- }
-
- @Test
- public void testInitialisation() {
- Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/init.xml");
- assertNotNull(bus.getExtension(TestListener.class));
- assertSame(bus, bus.getExtension(BusApplicationContext.class).getBean("cxf"));
- }
-
-
- static class TestInterceptor implements Interceptor<Message> {
-
- private String name;
-
- public TestInterceptor() {
- }
-
- public void setName(String n) {
- name = n;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public void handleFault(Message message) {
- }
-
- public void handleMessage(Message message) throws Fault {
- }
-
- public void postHandleMessage(Message message) throws Fault {
- }
-
- }
-
- static class TestExtension {
-
- boolean postConstructMethodCalled;
- boolean preDestroyMethodCalled;
-
- public TestExtension(Bus bus) {
- bus.setExtension(this, TestExtension.class);
- }
-
- @PostConstruct
- void postConstructMethod() {
- postConstructMethodCalled = true;
- }
-
- @PreDestroy
- void preDestroyMethod() {
- preDestroyMethodCalled = true;
- }
- }
-
- static class TestFeature extends AbstractFeature {
- boolean initialised;
- public TestFeature() {
- //nothing
- }
-
- @Override
- public void initialize(Bus bus) {
- initialised = true;
- }
- }
-
- static class TestListener implements BusLifeCycleListener {
-
- Bus bus;
-
- @Resource
- public void setBus(Bus b) {
- bus = b;
- }
-
- @PostConstruct
- public void register() {
- bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
- }
-
- public void initComplete() {
- assertNull(bus.getExtension(TestFeature.class));
- Collection<Feature> features = bus.getFeatures();
- assertEquals(1, features.size());
- TestFeature tf = (TestFeature)features.iterator().next();
- assertTrue(tf.initialised);
- bus.setExtension(this, TestListener.class);
- }
-
- public void postShutdown() {
- }
-
- public void preShutdown() {
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/bus.xml b/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
deleted file mode 100644
index 9b2085b..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/bus.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <c:bus>
- <c:features>
- <c:logging/>
- <bean class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestFeature">
- <property name="testBean" ref="tb"/>
- </bean>
- </c:features>
- </c:bus>
- <bean id="tb" class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestBean"/>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml b/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
deleted file mode 100644
index 0b0f8c9..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <cxf:bus bus="cxf1">
- <cxf:outInterceptors>
- <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
- </cxf:outInterceptors>
- </cxf:bus>
- <cxf:bus bus="cxf2">
- <cxf:inInterceptors>
- <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
- </cxf:inInterceptors>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml b/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
deleted file mode 100644
index 0b0f8c9..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
- <cxf:bus bus="cxf1">
- <cxf:outInterceptors>
- <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
- </cxf:outInterceptors>
- </cxf:bus>
- <cxf:bus bus="cxf2">
- <cxf:inInterceptors>
- <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
- </cxf:inInterceptors>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/init.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/init.xml b/core/src/test/java/org/apache/cxf/bus/spring/init.xml
deleted file mode 100644
index 55b13ff..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/init.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestListener">
- <property name="bus" ref="cxf"/>
- </bean>
- <cxf:bus>
- <cxf:features>
- <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestFeature"/>
- </cxf:features>
- </cxf:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml b/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
deleted file mode 100644
index 6cc4f07..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd" default-lazy-init="true">
- <c:bus>
- <c:features>
- <c:logging/>
- </c:features>
- </c:bus>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml b/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
deleted file mode 100644
index 64d5485..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="cxf" class="org.apache.cxf.bus.extension.ExtensionManagerBus">
- <property name="inInterceptors">
- <list>
- <ref bean="in-a"/>
- <ref bean="in-b"/>
- </list>
- </property>
- <property name="inFaultInterceptors">
- <list>
- <ref bean="in-fault"/>
- </list>
- </property>
- <property name="outInterceptors">
- <list>
- <ref bean="out"/>
- </list>
- </property>
- <property name="outFaultInterceptors">
- <list>
- <ref bean="out-fault"/>
- </list>
- </property>
- </bean>
- <bean id="in-a" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-a"/>
- </bean>
- <bean id="in-b" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-b"/>
- </bean>
- <bean id="out" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="out"/>
- </bean>
- <bean id="in-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="in-fault"/>
- </bean>
- <bean id="out-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
- <property name="name" value="out-fault"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/test.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/test.xml b/core/src/test/java/org/apache/cxf/bus/spring/test.xml
deleted file mode 100644
index 65506f3..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/test.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
- <property name="propertyEditorRegistrars">
- <list merge="true">
- </list>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml b/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
deleted file mode 100644
index 8bcecc3..0000000
--- a/core/src/test/java/org/apache/cxf/bus/spring/testjsr250.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="testExtension" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestExtension">
- <constructor-arg ref="cxf"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java b/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
deleted file mode 100644
index 41094cf..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.configuration.spring;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Set;
-
-import javax.xml.bind.DatatypeConverter;
-import javax.xml.bind.DatatypeConverterInterface;
-import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.bus.spring.BusApplicationContext;
-import org.apache.cxf.configuration.Configurable;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-
-
-
-
-public class ConfigurerImplTest extends Assert {
-
- static {
- Class<?> cls;
- try {
- try {
- cls = Class.forName("com.sun.xml.bind.DatatypeConverterImpl");
- } catch (ClassNotFoundException e) {
- cls = Class.forName("com.sun.xml.internal.bind.DatatypeConverterImpl");
- }
- DatatypeConverterInterface convert = (DatatypeConverterInterface)cls.getField("theInstance")
- .get(null);
- DatatypeConverter.setDatatypeConverter(convert);
- } catch (Exception ex) {
- //ignore;
- }
- }
-
- @Test
- public void testConfigureSimpleNoMatchingBean() {
- SimpleBean sb = new SimpleBean("unknown");
-
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl(ac);
- configurer.configureBean(sb);
- assertEquals("Unexpected value for attribute stringAttr",
- "hello", sb.getStringAttr());
- assertTrue("Unexpected value for attribute booleanAttr",
- sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.ONE, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute intAttr",
- new Integer(2), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- new Long(3L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- new Short((short)4), sb.getShortAttr());
- assertEquals("Unexpected value for attribute decimalAttr",
- new BigDecimal("5"), sb.getDecimalAttr());
- assertEquals("Unexpected value for attribute floatAttr",
- new Float(6F), sb.getFloatAttr());
- assertEquals("Unexpected value for attribute doubleAttr",
- new Double(7D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- new Byte((byte)8), sb.getByteAttr());
-
- QName qn = sb.getQnameAttr();
- assertEquals("Unexpected value for attribute qnameAttrNoDefault",
- "schema", qn.getLocalPart());
- assertEquals("Unexpected value for attribute qnameAttrNoDefault",
- "http://www.w3.org/2001/XMLSchema", qn.getNamespaceURI());
- byte[] expected = DatatypeConverter.parseBase64Binary("abcd");
- byte[] val = sb.getBase64BinaryAttr();
- assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected.length, val.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Unexpected value for attribute base64BinaryAttrNoDefault", expected[i], val[i]);
- }
- expected = new HexBinaryAdapter().unmarshal("aaaa");
- val = sb.getHexBinaryAttr();
- assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected.length, val.length);
- for (int i = 0; i < expected.length; i++) {
- assertEquals("Unexpected value for attribute hexBinaryAttrNoDefault", expected[i], val[i]);
- }
-
- assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
- new Long(9L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- new Integer(10), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- new Short((short)11), sb.getUnsignedByteAttr());
- }
-
- @Test
- public void testConfigureSimple() {
- // Try to configure the bean with id
- verifyConfigureSimple("simple");
- // Try to configure the bean with an alias name
- verifyConfigureSimple("simpleValueBean");
- }
-
-
- public void verifyConfigureSimple(String beanName) {
-
- SimpleBean sb = new SimpleBean(beanName);
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
-
- configurer.configureBean(sb);
- assertEquals("Unexpected value for attribute stringAttr",
- "hallo", sb.getStringAttr());
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute intAttr",
- new Integer(12), sb.getIntAttr());
- assertEquals("Unexpected value for attribute longAttr",
- new Long(13L), sb.getLongAttr());
- assertEquals("Unexpected value for attribute shortAttr",
- new Short((short)14), sb.getShortAttr());
- assertEquals("Unexpected value for attribute decimalAttr",
- new BigDecimal("15"), sb.getDecimalAttr());
- assertEquals("Unexpected value for attribute floatAttr",
- new Float(16F), sb.getFloatAttr());
- assertEquals("Unexpected value for attribute doubleAttr",
- new Double(17D), sb.getDoubleAttr());
- assertEquals("Unexpected value for attribute byteAttr",
- new Byte((byte)18), sb.getByteAttr());
-
- assertEquals("Unexpected value for attribute unsignedIntAttrNoDefault",
- new Long(19L), sb.getUnsignedIntAttr());
- assertEquals("Unexpected value for attribute unsignedShortAttrNoDefault",
- new Integer(20), sb.getUnsignedShortAttr());
- assertEquals("Unexpected value for attribute unsignedByteAttrNoDefault",
- new Short((short)21), sb.getUnsignedByteAttr());
- }
-
- @Test
- public void testConfigureSimpleMatchingStarBeanId() {
- SimpleBean sb = new SimpleBean("simple2");
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
- configurer.configureBean(sb);
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute stringAttr",
- "StarHallo", sb.getStringAttr());
- }
-
- @Test
- public void testConfigureSimpleMatchingStarBeanIdWithChildInstance() {
- SimpleBean sb = new ChildBean("simple2");
- BusApplicationContext ac =
- new BusApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml",
- false);
-
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(ac);
- configurer.configureBean(sb);
- assertTrue("Unexpected value for attribute booleanAttr",
- !sb.getBooleanAttr());
- assertEquals("Unexpected value for attribute integerAttr",
- BigInteger.TEN, sb.getIntegerAttr());
- assertEquals("Unexpected value for attribute stringAttr",
- "StarHallo", sb.getStringAttr());
- }
-
- @Test
- public void testGetBeanName() {
- ConfigurerImpl configurer = new ConfigurerImpl();
- Object beanInstance = new Configurable() {
-
- public String getBeanName() {
- return "a";
- }
- };
- assertEquals("a", configurer.getBeanName(beanInstance));
- final class NamedBean {
- @SuppressWarnings("unused")
- public String getBeanName() {
- return "b";
- }
- }
- beanInstance = new NamedBean();
- assertEquals("b", configurer.getBeanName(beanInstance));
- beanInstance = this;
- assertNull(configurer.getBeanName(beanInstance));
- }
-
- @Test
- public void testAddApplicationContext() {
- ConfigurableApplicationContext context1 =
- new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
- ConfigurerImpl configurer = new ConfigurerImpl();
- configurer.setApplicationContext(context1);
- // Just to simulate the OSGi's uninstall command
- context1.close();
-
- ConfigurableApplicationContext context2 =
- new ClassPathXmlApplicationContext("/org/apache/cxf/configuration/spring/test-beans.xml");
- configurer.addApplicationContext(context2);
- Set<ApplicationContext> contexts = configurer.getAppContexts();
- assertEquals("The Context's size is wrong", 1, contexts.size());
- assertTrue("The conetxts' contains a wrong application context", contexts.contains(context2));
- }
-
- class SimpleBean implements Configurable {
-
- private String beanName;
-
- private String stringAttr = "hello";
- private Boolean booleanAttr = Boolean.TRUE;
- private BigInteger integerAttr = BigInteger.ONE;
- private Integer intAttr = new Integer(2);
- private Long longAttr = new Long(3);
- private Short shortAttr = new Short((short)4);
- private BigDecimal decimalAttr = new BigDecimal("5");
- private Float floatAttr = new Float(6F);
- private Double doubleAttr = new Double(7D);
- private Byte byteAttr = new Byte((byte)8);
- private QName qnameAttr = new QName("http://www.w3.org/2001/XMLSchema", "schema", "xs");
- private byte[] base64BinaryAttr = DatatypeConverter.parseBase64Binary("abcd");
- private byte[] hexBinaryAttr = new HexBinaryAdapter().unmarshal("aaaa");
- private Long unsignedIntAttr = new Long(9);
- private Integer unsignedShortAttr = new Integer(10);
- private Short unsignedByteAttr = new Short((short)11);
-
-
- public SimpleBean(String bn) {
- beanName = bn;
- }
-
- public String getBeanName() {
- return beanName;
- }
-
- public byte[] getBase64BinaryAttr() {
- return base64BinaryAttr;
- }
-
- public void setBase64BinaryAttr(byte[] base64BinaryAttr) {
- this.base64BinaryAttr = base64BinaryAttr;
- }
-
- public Boolean getBooleanAttr() {
- return booleanAttr;
- }
-
- public void setBooleanAttr(Boolean booleanAttr) {
- this.booleanAttr = booleanAttr;
- }
-
- public Byte getByteAttr() {
- return byteAttr;
- }
-
- public void setByteAttr(Byte byteAttr) {
- this.byteAttr = byteAttr;
- }
-
- public BigDecimal getDecimalAttr() {
- return decimalAttr;
- }
-
- public void setDecimalAttr(BigDecimal decimalAttr) {
- this.decimalAttr = decimalAttr;
- }
-
- public Double getDoubleAttr() {
- return doubleAttr;
- }
-
- public void setDoubleAttr(Double doubleAttr) {
- this.doubleAttr = doubleAttr;
- }
-
- public Float getFloatAttr() {
- return floatAttr;
- }
-
- public void setFloatAttr(Float floatAttr) {
- this.floatAttr = floatAttr;
- }
-
- public byte[] getHexBinaryAttr() {
- return hexBinaryAttr;
- }
-
- public void setHexBinaryAttr(byte[] hexBinaryAttr) {
- this.hexBinaryAttr = hexBinaryAttr;
- }
-
- public Integer getIntAttr() {
- return intAttr;
- }
-
- public void setIntAttr(Integer intAttr) {
- this.intAttr = intAttr;
- }
-
- public BigInteger getIntegerAttr() {
- return integerAttr;
- }
-
- public void setIntegerAttr(BigInteger integerAttr) {
- this.integerAttr = integerAttr;
- }
-
- public Long getLongAttr() {
- return longAttr;
- }
-
- public void setLongAttr(Long longAttr) {
- this.longAttr = longAttr;
- }
-
- public QName getQnameAttr() {
- return qnameAttr;
- }
-
- public void setQnameAttr(QName qnameAttr) {
- this.qnameAttr = qnameAttr;
- }
-
- public Short getShortAttr() {
- return shortAttr;
- }
-
- public void setShortAttr(Short shortAttr) {
- this.shortAttr = shortAttr;
- }
-
- public String getStringAttr() {
- return stringAttr;
- }
-
- public void setStringAttr(String stringAttr) {
- this.stringAttr = stringAttr;
- }
-
- public Short getUnsignedByteAttr() {
- return unsignedByteAttr;
- }
-
- public void setUnsignedByteAttr(Short unsignedByteAttr) {
- this.unsignedByteAttr = unsignedByteAttr;
- }
-
- public Long getUnsignedIntAttr() {
- return unsignedIntAttr;
- }
-
- public void setUnsignedIntAttr(Long unsignedIntAttr) {
- this.unsignedIntAttr = unsignedIntAttr;
- }
-
- public Integer getUnsignedShortAttr() {
- return unsignedShortAttr;
- }
-
- public void setUnsignedShortAttr(Integer unsignedShortAttr) {
- this.unsignedShortAttr = unsignedShortAttr;
- }
-
- public void setBeanName(String beanName) {
- this.beanName = beanName;
- }
- }
-
- class ChildBean extends SimpleBean {
-
- public ChildBean(String bn) {
- super(bn);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties b/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
deleted file mode 100644
index 9199905..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/bean.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-simple.name=simpleValueBean
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml b/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
deleted file mode 100644
index 359bb47..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/test-beans.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="org/apache/cxf/configuration/spring/bean.properties"/>
- </bean>
- <bean name="*2" abstract="true" class="org.apache.cxf.configuration.spring.ConfigurerImplTest$SimpleBean">
- <property name="stringAttr" value="StarHallo"/>
- </bean>
- <!-- additional wildcards for class SimpleBean will be ignored with a warning -->
- <bean name="*duplicateWildcardForClassWillBeIgnored" abstract="true" class="SimpleBean">
- <property name="stringAttr" value="duplicateWildcardForClassWillBeIgnored"/>
- </bean>
- <!-- wildcards bean with no class will be ignored with a warning -->
- <bean name="*willBeIgnoredBecausOfNoClass" abstract="true">
- <property name="stringAttr" value="willBeIgnoredBecausOfNoClass"/>
- </bean>
- <bean id="simple2" lazy-init="true">
- <property name="booleanAttr" value="false"/>
- <property name="integerAttr" value="10"/>
- </bean>
- <bean id="simple" name="${simple.name}" lazy-init="true">
- <property name="stringAttr" value="hallo"/>
- <property name="booleanAttr" value="false"/>
- <property name="integerAttr" value="10"/>
- <property name="intAttr" value="12"/>
- <property name="longAttr" value="13"/>
- <property name="shortAttr" value="14"/>
- <property name="decimalAttr" value="15"/>
- <property name="floatAttr" value="16"/>
- <property name="doubleAttr" value="17"/>
- <property name="byteAttr" value="18"/>
- <!--
- <property name="qnameAttr" value="xs:string"/>
- -->
- <property name="base64BinaryAttr" value="abcd"/>
- <property name="hexBinaryAttr" value="bbbb"/>
- <property name="unsignedIntAttr" value="19"/>
- <property name="unsignedShortAttr" value="20"/>
- <property name="unsignedByteAttr" value="21"/>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml b/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
deleted file mode 100644
index 801968a..0000000
--- a/core/src/test/java/org/apache/cxf/configuration/spring/test-jaxb-beans.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="complex" class="org.apache.cxf.configuration.spring.JaxbPropertyEditorTest$FooBean" lazy-init="true">
- <property name="name">
- <value>foam</value>
- </property>
- <property name="position">
- <value>
- <foo:point>
- <foo:x>12</foo:x>
- <foo:y>33</foo:y>
- </foo:point>
- </value>
- </property>
- <property name="address">
- <value>
- <foo:address>
- <foo:city>Dublin</foo:city>
- <foo:zip>4</foo:zip>
- <foo:street>Shelbourne Rd</foo:street>
- </foo:address>
- </value>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/integration/jca/pom.xml
----------------------------------------------------------------------
diff --git a/integration/jca/pom.xml b/integration/jca/pom.xml
index 3e076e5..0e2f938 100644
--- a/integration/jca/pom.xml
+++ b/integration/jca/pom.xml
@@ -53,6 +53,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/bindings/object/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/object/pom.xml b/rt/bindings/object/pom.xml
index 2d26b02..ed7a2be 100644
--- a/rt/bindings/object/pom.xml
+++ b/rt/bindings/object/pom.xml
@@ -48,6 +48,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/bindings/soap/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/pom.xml b/rt/bindings/soap/pom.xml
index 777443b..fba8cd6 100644
--- a/rt/bindings/soap/pom.xml
+++ b/rt/bindings/soap/pom.xml
@@ -57,6 +57,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/databinding/xmlbeans/pom.xml
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/pom.xml b/rt/databinding/xmlbeans/pom.xml
index b7c786c..6738e1b 100644
--- a/rt/databinding/xmlbeans/pom.xml
+++ b/rt/databinding/xmlbeans/pom.xml
@@ -67,6 +67,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<exclusions>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/features/clustering/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/clustering/pom.xml b/rt/features/clustering/pom.xml
index b1a255b..dac027a 100644
--- a/rt/features/clustering/pom.xml
+++ b/rt/features/clustering/pom.xml
@@ -58,6 +58,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml
index 95e75ed..6b2948b 100644
--- a/rt/frontend/jaxrs/pom.xml
+++ b/rt/frontend/jaxrs/pom.xml
@@ -99,6 +99,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>${cxf.servlet-api.group}</groupId>
<artifactId>${cxf.servlet-api.artifact}</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/pom.xml b/rt/frontend/jaxws/pom.xml
index c9e3c27..20ea597 100644
--- a/rt/frontend/jaxws/pom.xml
+++ b/rt/frontend/jaxws/pom.xml
@@ -101,6 +101,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/frontend/simple/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/pom.xml b/rt/frontend/simple/pom.xml
index 0279632..d80ec4c 100644
--- a/rt/frontend/simple/pom.xml
+++ b/rt/frontend/simple/pom.xml
@@ -74,6 +74,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/management/pom.xml
----------------------------------------------------------------------
diff --git a/rt/management/pom.xml b/rt/management/pom.xml
index ba033e5..3811e09 100644
--- a/rt/management/pom.xml
+++ b/rt/management/pom.xml
@@ -42,6 +42,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/pom.xml
----------------------------------------------------------------------
diff --git a/rt/pom.xml b/rt/pom.xml
index 8472491..aa04230 100644
--- a/rt/pom.xml
+++ b/rt/pom.xml
@@ -30,6 +30,7 @@
<version>3.0.0-SNAPSHOT</version>
</parent>
<modules>
+ <module>spring</module>
<module>wsdl</module>
<module>transports/local</module>
<module>databinding/jaxb</module>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/rs/client/pom.xml
----------------------------------------------------------------------
diff --git a/rt/rs/client/pom.xml b/rt/rs/client/pom.xml
index 9ef22ab..1c97db0 100644
--- a/rt/rs/client/pom.xml
+++ b/rt/rs/client/pom.xml
@@ -58,6 +58,12 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-spring</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-local</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/pom.xml
----------------------------------------------------------------------
diff --git a/rt/spring/pom.xml b/rt/spring/pom.xml
new file mode 100644
index 0000000..6a22428
--- /dev/null
+++ b/rt/spring/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-spring</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Spring Support</name>
+ <description>Apache CXF Spring Support</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.fastinfoset</groupId>
+ <artifactId>FastInfoset</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
new file mode 100644
index 0000000..5f086b7
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
@@ -0,0 +1,337 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.bus.spring;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Fault;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.BeansDtdResolver;
+import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.PluggableSchemaResolver;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextException;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+
+public class BusApplicationContext extends ClassPathXmlApplicationContext {
+
+ private static final String DEFAULT_CXF_CFG_FILE = "META-INF/cxf/cxf.xml";
+ private static final String DEFAULT_CXF_EXT_CFG_FILE = "classpath*:META-INF/cxf/cxf.extension";
+
+ private static final Logger LOG = LogUtils.getL7dLogger(BusApplicationContext.class);
+
+ private NamespaceHandlerResolver nsHandlerResolver;
+ private boolean includeDefaults;
+ private String[] cfgFiles;
+ private URL[] cfgFileURLs;
+
+ public BusApplicationContext(String cf, boolean include) {
+ this(cf, include, null);
+ }
+ public BusApplicationContext(String[] cfs, boolean include) {
+ this(cfs, include, null);
+ }
+
+ public BusApplicationContext(URL url, boolean include) {
+ this(url, include, null);
+ }
+ public BusApplicationContext(URL[] urls, boolean include) {
+ this(urls, include, null);
+ }
+
+ public BusApplicationContext(String cf, boolean include, ApplicationContext parent) {
+ this(new String[] {cf}, include, parent);
+ }
+
+ public BusApplicationContext(URL url, boolean include, ApplicationContext parent) {
+ this(new URL[] {url}, include, parent, null);
+ }
+ public BusApplicationContext(String[] cf, boolean include, ApplicationContext parent) {
+ this(cf, include, parent, null);
+ }
+ public BusApplicationContext(String[] cf, boolean include,
+ ApplicationContext parent, NamespaceHandlerResolver res) {
+ super(new String[0], false, parent);
+ cfgFiles = cf;
+ includeDefaults = include;
+ nsHandlerResolver = res;
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() throws Exception {
+ refresh();
+ return Boolean.TRUE;
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ if (e.getException() instanceof RuntimeException) {
+ throw (RuntimeException)e.getException();
+ }
+ throw new Fault(e);
+ }
+ }
+ public BusApplicationContext(URL[] url, boolean include,
+ ApplicationContext parent) {
+ this(url, include, parent, null);
+ }
+ public BusApplicationContext(URL[] url, boolean include,
+ ApplicationContext parent,
+ NamespaceHandlerResolver res) {
+ super(new String[0], false, parent);
+ cfgFileURLs = url;
+ includeDefaults = include;
+ nsHandlerResolver = res;
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() throws Exception {
+ refresh();
+ return Boolean.TRUE;
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ if (e.getException() instanceof RuntimeException) {
+ throw (RuntimeException)e.getException();
+ }
+ throw new Fault(e);
+ }
+ }
+
+ @Override
+ protected Resource[] getConfigResources() {
+ List<Resource> resources = new ArrayList<Resource>();
+
+ if (includeDefaults) {
+ try {
+ PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread
+ .currentThread().getContextClassLoader());
+
+ Collections.addAll(resources, resolver.getResources(DEFAULT_CXF_CFG_FILE));
+
+ Resource[] exts = resolver.getResources(DEFAULT_CXF_EXT_CFG_FILE);
+ for (Resource r : exts) {
+ InputStream is = r.getInputStream();
+ BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ String line = rd.readLine();
+ while (line != null) {
+ if (!"".equals(line)) {
+ resources.add(resolver.getResource(line));
+ }
+ line = rd.readLine();
+ }
+ is.close();
+ }
+
+ } catch (IOException ex) {
+ // ignore
+ }
+ }
+
+ boolean usingDefault = false;
+ if (null == cfgFiles) {
+ String cfgFile = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+ if (cfgFile != null) {
+ cfgFiles = new String[] {cfgFile};
+ }
+ }
+ if (null == cfgFiles) {
+ cfgFiles = new String[] {Configurer.DEFAULT_USER_CFG_FILE};
+ usingDefault = true;
+ }
+ for (String cfgFile : cfgFiles) {
+ final Resource cpr = findResource(cfgFile);
+ boolean exists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ return cpr != null && cpr.exists();
+ }
+
+ });
+ if (exists) {
+ resources.add(cpr);
+ LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
+ } else {
+ if (!usingDefault) {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
+ String message = (new Message("USER_CFG_FILE_NOT_LOADED", LOG, cfgFile)).toString();
+ throw new ApplicationContextException(message);
+ }
+ }
+ }
+
+ if (null != cfgFileURLs) {
+ for (URL cfgFileURL : cfgFileURLs) {
+ UrlResource ur = new UrlResource(cfgFileURL);
+ if (ur.exists()) {
+ resources.add(ur);
+ } else {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", cfgFileURL);
+ }
+ }
+ }
+
+ String sysCfgFileUrl = SystemPropertyAction.getPropertyOrNull(Configurer.USER_CFG_FILE_PROPERTY_URL);
+ if (null != sysCfgFileUrl) {
+ try {
+ UrlResource ur = new UrlResource(sysCfgFileUrl);
+ if (ur.exists()) {
+ resources.add(ur);
+ } else {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_NOT_FOUND_MSG", sysCfgFileUrl);
+ }
+ } catch (MalformedURLException e) {
+ LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_URL_ERROR_MSG", sysCfgFileUrl);
+ }
+ }
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Creating application context with resources: " + resources);
+ }
+
+ if (0 == resources.size()) {
+ return null;
+ }
+ Resource[] res = new Resource[resources.size()];
+ res = resources.toArray(res);
+ return res;
+ }
+
+ public static Resource findResource(final String cfgFile) {
+ try {
+ return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
+ public Resource run() {
+ Resource cpr = new ClassPathResource(cfgFile);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ try {
+ //see if it's a URL
+ URL url = new URL(cfgFile);
+ cpr = new UrlResource(url);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ } catch (MalformedURLException e) {
+ //ignore
+ }
+ //try loading it our way
+ URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
+ if (url != null) {
+ cpr = new UrlResource(url);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ }
+ cpr = new FileSystemResource(cfgFile);
+ if (cpr.exists()) {
+ return cpr;
+ }
+ return null;
+ }
+ });
+ } catch (AccessControlException ex) {
+ //cannot read the user config file
+ return null;
+ }
+ }
+
+ @Override
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
+ // Spring always creates a new one of these, which takes a fair amount
+ // of time on startup (nearly 1/2 second) as it gets created for every
+ // spring context on the classpath
+ if (nsHandlerResolver == null) {
+ nsHandlerResolver = new DefaultNamespaceHandlerResolver();
+ }
+ reader.setNamespaceHandlerResolver(nsHandlerResolver);
+
+ String mode = getSpringValidationMode();
+ if (null != mode) {
+ reader.setValidationModeName(mode);
+ }
+ reader.setNamespaceAware(true);
+
+ setEntityResolvers(reader);
+ }
+
+ static String getSpringValidationMode() {
+ return AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ String mode = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.spring.validation.mode");
+ if (mode == null) {
+ mode = SystemPropertyAction.getPropertyOrNull("spring.validation.mode");
+ }
+ return mode;
+ }
+ });
+ }
+
+
+ void setEntityResolvers(XmlBeanDefinitionReader reader) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ reader.setEntityResolver(new BusEntityResolver(cl, new BeansDtdResolver(),
+ new PluggableSchemaResolver(cl)));
+ }
+ @Override
+ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException {
+ // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+ XmlBeanDefinitionReader beanDefinitionReader =
+ new ControlledValidationXmlBeanDefinitionReader(beanFactory);
+ beanDefinitionReader.setNamespaceHandlerResolver(nsHandlerResolver);
+
+ // Configure the bean definition reader with this context's
+ // resource loading environment.
+ beanDefinitionReader.setResourceLoader(this);
+ beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this));
+
+ // Allow a subclass to provide custom initialization of the reader,
+ // then proceed with actually loading the bean definitions.
+ initBeanDefinitionReader(beanDefinitionReader);
+ loadBeanDefinitions(beanDefinitionReader);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
new file mode 100644
index 0000000..434a851
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/bus/spring/BusApplicationContextResourceResolver.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.bus.spring;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.resource.ResourceResolver;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.core.io.Resource;
+
+@NoJSR250Annotations
+public class BusApplicationContextResourceResolver
+ implements ResourceResolver, ApplicationContextAware {
+
+ ApplicationContext context;
+
+ public BusApplicationContextResourceResolver() {
+ }
+ public BusApplicationContextResourceResolver(ApplicationContext c) {
+ context = c;
+ }
+
+
+ public InputStream getAsStream(String name) {
+ Resource r = context.getResource(name);
+ if (r != null && r.exists()) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ //ignore and return null
+ }
+ }
+ r = context.getResource("/" + name);
+ if (r != null && r.exists()) {
+ try {
+ return r.getInputStream();
+ } catch (IOException e) {
+ //ignore and return null
+ }
+ }
+ return null;
+ }
+
+ public <T> T resolve(String resourceName, Class<T> resourceType) {
+
+ try {
+ T resource = null;
+ if (resourceName == null) {
+ String names[] = context.getBeanNamesForType(resourceType);
+ if (names != null && names.length > 0) {
+ resource = resourceType.cast(context.getBean(names[0], resourceType));
+ }
+ } else {
+ resource = resourceType.cast(context.getBean(resourceName, resourceType));
+ }
+ return resource;
+ } catch (NoSuchBeanDefinitionException def) {
+ //ignore
+ }
+ try {
+ if (ClassLoader.class.isAssignableFrom(resourceType)) {
+ return resourceType.cast(context.getClassLoader());
+ } else if (URL.class.isAssignableFrom(resourceType)) {
+ Resource r = context.getResource(resourceName);
+ if (r != null && r.exists()) {
+ r.getInputStream().close(); //checks to see if the URL really can resolve
+ return resourceType.cast(r.getURL());
+ }
+ }
+ } catch (IOException e) {
+ //ignore
+ }
+ return null;
+ }
+
+
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ context = applicationContext;
+ }
+
+}
[7/9] Pull aries-blueprint support out
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/pom.xml
----------------------------------------------------------------------
diff --git a/rt/pom.xml b/rt/pom.xml
index aa04230..8efbef8 100644
--- a/rt/pom.xml
+++ b/rt/pom.xml
@@ -31,6 +31,7 @@
</parent>
<modules>
<module>spring</module>
+ <module>aries-blueprint</module>
<module>wsdl</module>
<module>transports/local</module>
<module>databinding/jaxb</module>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/rs/client/pom.xml
----------------------------------------------------------------------
diff --git a/rt/rs/client/pom.xml b/rt/rs/client/pom.xml
index 1c97db0..95c9af0 100644
--- a/rt/rs/client/pom.xml
+++ b/rt/rs/client/pom.xml
@@ -64,6 +64,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-local</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index 1925908..898a7f3 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -80,6 +80,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/transports/http-netty/netty-server/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/pom.xml b/rt/transports/http-netty/netty-server/pom.xml
index b015f23..0fd6bb7 100644
--- a/rt/transports/http-netty/netty-server/pom.xml
+++ b/rt/transports/http-netty/netty-server/pom.xml
@@ -59,6 +59,14 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${cxf.netty.version}</version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/transports/http/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http/pom.xml b/rt/transports/http/pom.xml
index 56b01b7..7168a04 100644
--- a/rt/transports/http/pom.xml
+++ b/rt/transports/http/pom.xml
@@ -89,6 +89,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/ws/addr/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/addr/pom.xml b/rt/ws/addr/pom.xml
index 63e062f..2e5dac1 100644
--- a/rt/ws/addr/pom.xml
+++ b/rt/ws/addr/pom.xml
@@ -84,6 +84,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/ws/policy/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/policy/pom.xml b/rt/ws/policy/pom.xml
index 6b16df9..2533bda 100644
--- a/rt/ws/policy/pom.xml
+++ b/rt/ws/policy/pom.xml
@@ -98,6 +98,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/ws/rm/pom.xml
----------------------------------------------------------------------
diff --git a/rt/ws/rm/pom.xml b/rt/ws/rm/pom.xml
index 2354f72..6645d63 100644
--- a/rt/ws/rm/pom.xml
+++ b/rt/ws/rm/pom.xml
@@ -77,6 +77,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/services/wsn/wsn-core/pom.xml
----------------------------------------------------------------------
diff --git a/services/wsn/wsn-core/pom.xml b/services/wsn/wsn-core/pom.xml
index 443f52f..33416bb 100644
--- a/services/wsn/wsn-core/pom.xml
+++ b/services/wsn/wsn-core/pom.xml
@@ -63,6 +63,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.apache.cxf.services.wsn</groupId>
<artifactId>cxf-services-wsn-api</artifactId>
<version>${project.version}</version>
[5/9] Experiment with pulling spring out of core
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/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 648431d..0000000
--- a/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java
+++ /dev/null
@@ -1,145 +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);
- }
-
- public void loadAdditionalFeatures() {
- super.loadAdditionalFeatures();
- }
-
- /** {@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/e46d0180/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/e46d0180/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/e46d0180/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 7fcc99f..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
+++ /dev/null
@@ -1,520 +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.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);
- 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)) {
- 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)) {
- setBus = processBusAttribute(element, ctx, bean, val);
- } else if (!"id".equals(name) && isAttribute(pre, name)) {
- mapAttribute(bean, element, name, val);
- }
- }
- return setBus;
- }
-
-
- 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;
- 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) {
- Unmarshaller u = getContext(c).createUnmarshaller();
- 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);
- }
- } 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);
- try {
- Unmarshaller 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);
- }
- }
- }
-
- 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/e46d0180/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/e46d0180/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/e46d0180/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 0b59288..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
+++ /dev/null
@@ -1,281 +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.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-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 HashMap<String, List<MatcherHolder>>();
- private BeanFactory beanFactory;
-
- static class MatcherHolder {
- Matcher matcher;
- String wildCardId;
- public MatcherHolder(String orig, Matcher matcher) {
- wildCardId = orig;
- this.matcher = matcher;
- }
- }
-
- 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/e46d0180/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 c542482..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.bind.Unmarshaller;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.cxf.staxutils.StaxUtils;
-
-/**
- *
- */
-public final class JAXBBeanFactory {
- private JAXBBeanFactory() {
- //nothing
- }
-
- public static Object createJAXBBean(JAXBContext context,
- String s,
- Class<?> c) {
-
- StringReader reader = new StringReader(s);
- XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
- Unmarshaller u;
- try {
- Object obj;
- u = context.createUnmarshaller();
- if (c != null) {
- obj = u.unmarshal(data, c);
- } else {
- obj = u.unmarshal(data);
- }
- if (obj instanceof JAXBElement<?>) {
- JAXBElement<?> el = (JAXBElement<?>)obj;
- obj = el.getValue();
-
- }
- 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/e46d0180/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/e46d0180/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/e46d0180/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/e46d0180/core/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/spring.handlers b/core/src/main/resources/META-INF/spring.handlers
deleted file mode 100644
index 0db2322..0000000
--- a/core/src/main/resources/META-INF/spring.handlers
+++ /dev/null
@@ -1,21 +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.
-#
-#
-http\://cxf.apache.org/core=org.apache.cxf.bus.spring.NamespaceHandler
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/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/e46d0180/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/e46d0180/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;
- }
- }
-
-}
[2/9] Experiment with pulling spring out of core
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
new file mode 100644
index 0000000..7fcc99f
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
@@ -0,0 +1,520 @@
+/**
+ * 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.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);
+ 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)) {
+ 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)) {
+ setBus = processBusAttribute(element, ctx, bean, val);
+ } else if (!"id".equals(name) && isAttribute(pre, name)) {
+ mapAttribute(bean, element, name, val);
+ }
+ }
+ return setBus;
+ }
+
+
+ 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;
+ 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) {
+ Unmarshaller u = getContext(c).createUnmarshaller();
+ 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);
+ }
+ } 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);
+ try {
+ Unmarshaller 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);
+ }
+ }
+ }
+
+ 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
new file mode 100644
index 0000000..b8ab25d
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/AbstractFactoryBeanDefinitionParser.java
@@ -0,0 +1,153 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
new file mode 100644
index 0000000..4a7042a
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/BusWiringType.java
@@ -0,0 +1,37 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
new file mode 100644
index 0000000..0b59288
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/ConfigurerImpl.java
@@ -0,0 +1,281 @@
+/**
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+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 HashMap<String, List<MatcherHolder>>();
+ private BeanFactory beanFactory;
+
+ static class MatcherHolder {
+ Matcher matcher;
+ String wildCardId;
+ public MatcherHolder(String orig, Matcher matcher) {
+ wildCardId = orig;
+ this.matcher = matcher;
+ }
+ }
+
+ 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
new file mode 100644
index 0000000..c542482
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
@@ -0,0 +1,73 @@
+/**
+ * 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.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.staxutils.StaxUtils;
+
+/**
+ *
+ */
+public final class JAXBBeanFactory {
+ private JAXBBeanFactory() {
+ //nothing
+ }
+
+ public static Object createJAXBBean(JAXBContext context,
+ String s,
+ Class<?> c) {
+
+ StringReader reader = new StringReader(s);
+ XMLStreamReader data = StaxUtils.createXMLStreamReader(reader);
+ Unmarshaller u;
+ try {
+ Object obj;
+ u = context.createUnmarshaller();
+ if (c != null) {
+ obj = u.unmarshal(data, c);
+ } else {
+ obj = u.unmarshal(data);
+ }
+ if (obj instanceof JAXBElement<?>) {
+ JAXBElement<?> el = (JAXBElement<?>)obj;
+ obj = el.getValue();
+
+ }
+ 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/Messages.properties b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
new file mode 100644
index 0000000..ed8f59a
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/Messages.properties
@@ -0,0 +1,26 @@
+#
+#
+# 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
new file mode 100644
index 0000000..442970c
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/SimpleBeanDefinitionParser.java
@@ -0,0 +1,33 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
new file mode 100644
index 0000000..064c43d
--- /dev/null
+++ b/rt/spring/src/main/java/org/apache/cxf/configuration/spring/StringBeanDefinitionParser.java
@@ -0,0 +1,39 @@
+/**
+ * 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/e46d0180/rt/spring/src/main/resources/META-INF/spring.handlers
----------------------------------------------------------------------
diff --git a/rt/spring/src/main/resources/META-INF/spring.handlers b/rt/spring/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000..0db2322
--- /dev/null
+++ b/rt/spring/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+http\://cxf.apache.org/core=org.apache.cxf.bus.spring.NamespaceHandler
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
new file mode 100644
index 0000000..60d6101
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationContextTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
new file mode 100644
index 0000000..9b0b7a3
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusApplicationListenerTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
new file mode 100644
index 0000000..2c63150
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/BusDefinitionParserTest.java
@@ -0,0 +1,168 @@
+/**
+ * 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/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java b/rt/spring/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
new file mode 100644
index 0000000..abb89a5
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java
@@ -0,0 +1,279 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.bus.spring;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+import java.util.SortedSet;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.bus.managers.PhaseManagerImpl;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.workqueue.WorkQueueManager;
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SpringBusFactoryTest extends Assert {
+
+ @After
+ public void tearDown() {
+ BusFactory.setDefaultBus(null);
+ }
+
+ @Test
+ public void testDefault() {
+ Bus bus = new SpringBusFactory().createBus();
+ assertNotNull(bus);
+ BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
+ assertNotNull("No binding factory manager", bfm);
+ assertNotNull("No configurer", bus.getExtension(Configurer.class));
+ assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
+ assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
+ assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
+ assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
+ assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
+ assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
+ assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
+
+ try {
+ bfm.getBindingFactory("http://cxf.apache.org/unknown");
+ } catch (BusException ex) {
+ // expected
+ }
+
+ assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
+ assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
+ assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
+ assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
+
+ }
+
+ @Test
+ public void testCustomFileName() {
+ String cfgFile = "org/apache/cxf/bus/spring/resources/bus-overwrite.xml";
+ Bus bus = new SpringBusFactory().createBus(cfgFile, true);
+ checkCustomerConfiguration(bus);
+ }
+
+ @Test
+ public void testCustomerBusShutdown() {
+ String cfgFile = "org/apache/cxf/bus/spring/customerBus.xml";
+ Bus bus = new SpringBusFactory().createBus(cfgFile, true);
+ // We have three bus here, which should be closed rightly
+ bus.shutdown(true);
+ }
+
+ @Test
+ public void testCustomFileURLFromSystemProperty() {
+ URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
+ System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());
+ Bus bus = new SpringBusFactory().createBus((String)null, true);
+ checkCustomerConfiguration(bus);
+ System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
+ }
+
+ @Test
+ public void testCustomFileURL() {
+ URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml");
+ Bus bus = new SpringBusFactory().createBus(cfgFileURL, true);
+ checkCustomerConfiguration(bus);
+ }
+
+ private void checkCustomerConfiguration(Bus bus) {
+ assertNotNull(bus);
+ List<Interceptor<? extends Message>> interceptors = bus.getInInterceptors();
+ assertEquals("Unexpected number of interceptors", 2, interceptors.size());
+ assertEquals("Unexpected interceptor", "in-a", interceptors.get(0).toString());
+ assertEquals("Unexpected interceptor", "in-b", interceptors.get(1).toString());
+ interceptors = bus.getInFaultInterceptors();
+ assertEquals("Unexpected number of interceptors", 1, interceptors.size());
+ assertEquals("Unexpected interceptor", "in-fault", interceptors.get(0).toString());
+ interceptors = bus.getOutFaultInterceptors();
+ assertEquals("Unexpected number of interceptors", 1, interceptors.size());
+ assertEquals("Unexpected interceptor", "out-fault", interceptors.get(0).toString());
+ interceptors = bus.getOutInterceptors();
+ assertEquals("Unexpected number of interceptors", 1, interceptors.size());
+ assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
+ }
+
+ @Test
+ public void testForLifeCycle() {
+ BusLifeCycleListener bl = EasyMock.createMock(BusLifeCycleListener.class);
+ Bus bus = new SpringBusFactory().createBus();
+ BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+ lifeCycleManager.registerLifeCycleListener(bl);
+ EasyMock.reset(bl);
+ bl.preShutdown();
+ EasyMock.expectLastCall();
+ bl.postShutdown();
+ EasyMock.expectLastCall();
+ EasyMock.replay(bl);
+ bus.shutdown(true);
+ EasyMock.verify(bl);
+
+ }
+
+ @Test
+ public void testPhases() {
+ Bus bus = new SpringBusFactory().createBus();
+ PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
+ PhaseManager defaultPM = new PhaseManagerImpl();
+ SortedSet<Phase> cxfPhases = cxfPM.getInPhases();
+ SortedSet<Phase> defaultPhases = defaultPM.getInPhases();
+ assertEquals(defaultPhases.size(), cxfPhases.size());
+ assertTrue(cxfPhases.equals(defaultPhases));
+ cxfPhases = cxfPM.getOutPhases();
+ defaultPhases = defaultPM.getOutPhases();
+ assertEquals(defaultPhases.size(), cxfPhases.size());
+ assertTrue(cxfPhases.equals(defaultPhases));
+ }
+
+ @Test
+ public void testJsr250() {
+ Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/testjsr250.xml");
+ TestExtension te = bus.getExtension(TestExtension.class);
+ assertTrue("@PostConstruct annotated method has not been called.", te.postConstructMethodCalled);
+ assertTrue("@PreDestroy annoated method has been called already.", !te.preDestroyMethodCalled);
+ bus.shutdown(true);
+ assertTrue("@PreDestroy annotated method has not been called.", te.preDestroyMethodCalled);
+
+ }
+
+ @Test
+ public void testInitialisation() {
+ Bus bus = new SpringBusFactory().createBus("org/apache/cxf/bus/spring/init.xml");
+ assertNotNull(bus.getExtension(TestListener.class));
+ assertSame(bus, bus.getExtension(BusApplicationContext.class).getBean("cxf"));
+ }
+
+
+ static class TestInterceptor implements Interceptor<Message> {
+
+ private String name;
+
+ public TestInterceptor() {
+ }
+
+ public void setName(String n) {
+ name = n;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public void handleFault(Message message) {
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ }
+
+ public void postHandleMessage(Message message) throws Fault {
+ }
+
+ }
+
+ static class TestExtension {
+
+ boolean postConstructMethodCalled;
+ boolean preDestroyMethodCalled;
+
+ public TestExtension(Bus bus) {
+ bus.setExtension(this, TestExtension.class);
+ }
+
+ @PostConstruct
+ void postConstructMethod() {
+ postConstructMethodCalled = true;
+ }
+
+ @PreDestroy
+ void preDestroyMethod() {
+ preDestroyMethodCalled = true;
+ }
+ }
+
+ static class TestFeature extends AbstractFeature {
+ boolean initialised;
+ public TestFeature() {
+ //nothing
+ }
+
+ @Override
+ public void initialize(Bus bus) {
+ initialised = true;
+ }
+ }
+
+ static class TestListener implements BusLifeCycleListener {
+
+ Bus bus;
+
+ @Resource
+ public void setBus(Bus b) {
+ bus = b;
+ }
+
+ @PostConstruct
+ public void register() {
+ bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
+ }
+
+ public void initComplete() {
+ assertNull(bus.getExtension(TestFeature.class));
+ Collection<Feature> features = bus.getFeatures();
+ assertEquals(1, features.size());
+ TestFeature tf = (TestFeature)features.iterator().next();
+ assertTrue(tf.initialised);
+ bus.setExtension(this, TestListener.class);
+ }
+
+ public void postShutdown() {
+ }
+
+ public void preShutdown() {
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/bus.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/bus.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/bus.xml
new file mode 100644
index 0000000..9b2085b
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/bus.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+ <c:bus>
+ <c:features>
+ <c:logging/>
+ <bean class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestFeature">
+ <property name="testBean" ref="tb"/>
+ </bean>
+ </c:features>
+ </c:bus>
+ <bean id="tb" class="org.apache.cxf.bus.spring.BusDefinitionParserTest$TestBean"/>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
new file mode 100644
index 0000000..0b0f8c9
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+ <cxf:bus bus="cxf1">
+ <cxf:outInterceptors>
+ <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxf:outInterceptors>
+ </cxf:bus>
+ <cxf:bus bus="cxf2">
+ <cxf:inInterceptors>
+ <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxf:inInterceptors>
+ </cxf:bus>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
new file mode 100644
index 0000000..0b0f8c9
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/customerBus2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:cxf="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+ <cxf:bus bus="cxf1">
+ <cxf:outInterceptors>
+ <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxf:outInterceptors>
+ </cxf:bus>
+ <cxf:bus bus="cxf2">
+ <cxf:inInterceptors>
+ <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxf:inInterceptors>
+ </cxf:bus>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/init.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/init.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/init.xml
new file mode 100644
index 0000000..55b13ff
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/init.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestListener">
+ <property name="bus" ref="cxf"/>
+ </bean>
+ <cxf:bus>
+ <cxf:features>
+ <bean class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestFeature"/>
+ </cxf:features>
+ </cxf:bus>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
new file mode 100644
index 0000000..6cc4f07
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/lazyInitBus.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://cxf.apache.org/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd" default-lazy-init="true">
+ <c:bus>
+ <c:features>
+ <c:logging/>
+ </c:features>
+ </c:bus>
+</beans>
http://git-wip-us.apache.org/repos/asf/cxf/blob/e46d0180/rt/spring/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
----------------------------------------------------------------------
diff --git a/rt/spring/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml b/rt/spring/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
new file mode 100644
index 0000000..64d5485
--- /dev/null
+++ b/rt/spring/src/test/java/org/apache/cxf/bus/spring/resources/bus-overwrite.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:foo="http://cxf.apache.org/configuration/foo" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="cxf" class="org.apache.cxf.bus.extension.ExtensionManagerBus">
+ <property name="inInterceptors">
+ <list>
+ <ref bean="in-a"/>
+ <ref bean="in-b"/>
+ </list>
+ </property>
+ <property name="inFaultInterceptors">
+ <list>
+ <ref bean="in-fault"/>
+ </list>
+ </property>
+ <property name="outInterceptors">
+ <list>
+ <ref bean="out"/>
+ </list>
+ </property>
+ <property name="outFaultInterceptors">
+ <list>
+ <ref bean="out-fault"/>
+ </list>
+ </property>
+ </bean>
+ <bean id="in-a" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
+ <property name="name" value="in-a"/>
+ </bean>
+ <bean id="in-b" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
+ <property name="name" value="in-b"/>
+ </bean>
+ <bean id="out" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
+ <property name="name" value="out"/>
+ </bean>
+ <bean id="in-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
+ <property name="name" value="in-fault"/>
+ </bean>
+ <bean id="out-fault" class="org.apache.cxf.bus.spring.SpringBusFactoryTest$TestInterceptor">
+ <property name="name" value="out-fault"/>
+ </bean>
+</beans>
[9/9] git commit: Pull aries-blueprint support out
Posted by dk...@apache.org.
Pull aries-blueprint support out
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fc2cbb29
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fc2cbb29
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fc2cbb29
Branch: refs/heads/split-spring
Commit: fc2cbb29030361ba07f668faddd455a2be4ca934
Parents: e46d018
Author: Daniel Kulp <dk...@apache.org>
Authored: Thu May 1 11:22:34 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu May 1 11:31:52 2014 -0400
----------------------------------------------------------------------
core/pom.xml | 17 +-
.../cxf/bus/blueprint/BlueprintBeanLocator.java | 214 ---------
.../apache/cxf/bus/blueprint/BlueprintBus.java | 77 ----
.../BlueprintNameSpaceHandlerFactory.java | 30 --
.../blueprint/BundleDelegatingClassLoader.java | 133 ------
.../cxf/bus/blueprint/BusDefinitionParser.java | 68 ---
.../cxf/bus/blueprint/ConfigurerImpl.java | 179 --------
.../cxf/bus/blueprint/Messages.properties | 26 --
.../blueprint/NamespaceHandlerRegisterer.java | 51 ---
.../org/apache/cxf/bus/osgi/CXFActivator.java | 20 -
.../AbstractBPBeanDefinitionParser.java | 439 -------------------
.../blueprint/InterceptorTypeConverter.java | 42 --
.../blueprint/SimpleBPBeanDefinitionParser.java | 87 ----
.../cxf/internal/CXFAPINamespaceHandler.java | 109 -----
.../main/resources/schemas/blueprint/core.xsd | 160 -------
.../internal/CXFAPINamespaceHandlerTest.java | 42 --
osgi/itests-felix/pom.xml | 5 +
.../cxf/osgi/itests/NoAriesBlueprintTest.java | 1 +
.../features/src/main/resources/features.xml | 9 +-
rt/aries-blueprint/pom.xml | 99 +++++
.../cxf/bus/blueprint/BlueprintBeanLocator.java | 214 +++++++++
.../apache/cxf/bus/blueprint/BlueprintBus.java | 77 ++++
.../BlueprintNameSpaceHandlerFactory.java | 30 ++
.../blueprint/BundleDelegatingClassLoader.java | 133 ++++++
.../cxf/bus/blueprint/BusDefinitionParser.java | 68 +++
.../cxf/bus/blueprint/ConfigurerImpl.java | 179 ++++++++
.../cxf/bus/blueprint/Messages.properties | 26 ++
.../blueprint/NamespaceHandlerRegisterer.java | 51 +++
.../AbstractBPBeanDefinitionParser.java | 439 +++++++++++++++++++
.../blueprint/InterceptorTypeConverter.java | 42 ++
.../blueprint/SimpleBPBeanDefinitionParser.java | 87 ++++
.../internal/CXFAPINamespaceHandler.java | 109 +++++
.../blueprint/internal/CXFActivator.java | 62 +++
.../main/resources/schemas/blueprint/core.xsd | 160 +++++++
.../internal/CXFAPINamespaceHandlerTest.java | 42 ++
rt/bindings/coloc/pom.xml | 7 +
rt/bindings/object/pom.xml | 7 +
rt/bindings/soap/pom.xml | 6 +
rt/features/clustering/pom.xml | 7 +
rt/frontend/jaxrs/pom.xml | 7 +
rt/frontend/jaxws/pom.xml | 8 +
rt/frontend/simple/pom.xml | 7 +
rt/pom.xml | 1 +
rt/rs/client/pom.xml | 7 +
rt/transports/http-jetty/pom.xml | 7 +
rt/transports/http-netty/netty-server/pom.xml | 8 +
rt/transports/http/pom.xml | 7 +
rt/ws/addr/pom.xml | 7 +
rt/ws/policy/pom.xml | 7 +
rt/ws/rm/pom.xml | 7 +
services/wsn/wsn-core/pom.xml | 6 +
51 files changed, 1939 insertions(+), 1694 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 7ec7609..566b240 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -54,20 +54,11 @@
com.sun.xml.bind.api;resolution:=optional,
com.sun.xml.bind.api.impl;resolution:=optional,
com.sun.xml.internal.bind.api;resolution:=optional,
- com.sun.xml.internal.bind.api.impl;resolution:=optional,
- org.apache.aries*;version="${cxf.aries.version.range}";resolution:=optional
+ com.sun.xml.internal.bind.api.impl;resolution:=optional
</cxf.osgi.import>
<cxf.osgi.dynamic.import>
org.apache.cxf.bus,org.apache.cxf.*,com.ctc.wstx.*
</cxf.osgi.dynamic.import>
- <!-- keep in sync with services exported in activator -->
- <cxf.export.service>
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/core",
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/beans",
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/parameterized-types",
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security"
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/wsdl/",
- </cxf.export.service>
</properties>
<dependencies>
<dependency>
@@ -154,12 +145,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint.core</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/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 70b547e..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
+++ /dev/null
@@ -1,214 +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()) {
- 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 {
- 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/fc2cbb29/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 9842ad3..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
+++ /dev/null
@@ -1,77 +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 loadAdditionalFeatures() {
- super.loadAdditionalFeatures();
- }
-
- 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);
- }
- public String getId() {
- if (id == null) {
- id = context.getBundle().getSymbolicName() + "-"
- + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
- }
- return id;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/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/fc2cbb29/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/fc2cbb29/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/fc2cbb29/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 128fee4..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
+++ /dev/null
@@ -1,179 +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.HashMap;
-import java.util.List;
-import java.util.Map;
-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 HashMap<String, List<MatcherHolder>>();
-
- static class MatcherHolder {
- Matcher matcher;
- String wildCardId;
- public MatcherHolder(String orig, Matcher matcher) {
- wildCardId = orig;
- this.matcher = matcher;
- }
- }
-
-
- 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/fc2cbb29/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/fc2cbb29/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 390b76c..0000000
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
+++ /dev/null
@@ -1,51 +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.info("Registered blueprint namespace handler for " + namespace);
- }
- } catch (Throwable e) {
- LOG.log(Level.WARNING, "Aries Blueprint packages not available. So namespaces will not be registered", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/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
index 3fed8a8..bab14e7 100644
--- a/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
+++ b/core/src/main/java/org/apache/cxf/bus/osgi/CXFActivator.java
@@ -23,11 +23,8 @@ 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;
@@ -68,23 +65,6 @@ public class CXFActivator implements BundleActivator {
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,
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/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 6be1e3c..0000000
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ /dev/null
@@ -1,439 +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.util.PackageUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.osgi.framework.Bundle;
-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");
-
- Bundle blueprintBundle = null;
- if (meta instanceof PassThroughMetadata) {
- blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
- }
- 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 (blueprintBundle != null && !cdr.containsComponentDefinition(name)) {
- //Create a bus
-
- MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
- bus.setId(name);
- bus.setRuntimeClass(BlueprintBus.class);
- 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 = ctx.createUnmarshaller().unmarshal(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;
- 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) {
- Unmarshaller u = getContext(c).createUnmarshaller();
- 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);
- }
- } 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/fc2cbb29/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/fc2cbb29/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/fc2cbb29/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 6275ca3..0000000
--- a/core/src/main/java/org/apache/cxf/internal/CXFAPINamespaceHandler.java
+++ /dev/null
@@ -1,109 +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.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;
-
-/**
- *
- */
-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/fc2cbb29/core/src/main/resources/schemas/blueprint/core.xsd
----------------------------------------------------------------------
diff --git a/core/src/main/resources/schemas/blueprint/core.xsd b/core/src/main/resources/schemas/blueprint/core.xsd
deleted file mode 100644
index 3b3c144..0000000
--- a/core/src/main/resources/schemas/blueprint/core.xsd
+++ /dev/null
@@ -1,160 +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.
--->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:beans="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cxf-beans="http://cxf.apache.org/configuration/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ptp="http://cxf.apache.org/configuration/parameterized-types"
-
- targetNamespace="http://cxf.apache.org/blueprint/core"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified" >
-
- <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"/>
- <xsd:import namespace="http://cxf.apache.org/configuration/beans" schemaLocation="http://cxf.apache.org/schemas/configuration/cxf-beans.xsd"/>
- <xsd:import namespace="http://cxf.apache.org/configuration/parameterized-types"
- schemaLocation="http://cxf.apache.org/schemas/configuration/parameterized-types.xsd"/>
-
- <xsd:annotation>
- <xsd:documentation>
- This schema defines beans representing the CXF bus and its core features.
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="logging">
- <xsd:annotation>
- <xsd:documentation>
- The logging feature enables you to log the content of inbound and outbound messages and faults.
- The content is logged by all log handlers configured in your java.util.logging configuration file,
- provided the log level for classes org.apache.cxf.interceptor.LoggingInInterceptor and
- org.apache.cxf.interceptor.LoggingOutInterceptor is at least INFO.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence />
- <xsd:attribute name="limit" type="xsd:int" use="optional" default="102400"/>
- <xsd:attribute name="id" type="xsd:string" use="optional"/>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="fastinfoset">
- <xsd:annotation>
- <xsd:documentation>
- The fastinfoset feature enables you to turn on using fastinfoset encoding of
- xml payloads.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence />
- <xsd:attribute name="force" type="xsd:boolean" use="optional" default="false"/>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="workqueue">
- <xsd:annotation>
- <xsd:documentation>
- Configuration for workqueues that CXF uses
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence />
- <xsd:attribute name="highWaterMark" type="ptp:ParameterizedInt" use="optional"/>
- <xsd:attribute name="lowWaterMark" type="ptp:ParameterizedInt" use="optional"/>
- <xsd:attribute name="initialSize" type="ptp:ParameterizedInt" use="optional"/>
- <xsd:attribute name="queueSize" type="ptp:ParameterizedInt" use="optional"/>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="dequeueTimeout" type="ptp:ParameterizedLong" use="optional"/>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="bus">
- <xsd:complexType>
- <xsd:all>
- <xsd:element name="features" type="xsd:anyType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The list of features that are applied to the bus.
- Child elements of this element must be beans whose bean class extends
- org.apache.cxf.AbstractFeature, or references to such beans.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The list of interceptors that the bus contributes to all inbound message interceptor chains.
- Child elements of this element must be beans whose bean class implements
- org.apache.cxf.Interceptor, or references to such beans.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The list of interceptors that the bus contributes to all inbound fault interceptor chains.
- Child elements of this element must be beans whose bean class implements
- org.apache.cxf.Interceptor, or references to such beans.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The list of interceptors that the bus contributes to all outbound message interceptor chains.
- Child elements of this element must be beans whose bean class implements
- org.apache.cxf.Interceptor, or references to such beans.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The list of interceptors that the bus contributes to all outbound fault interceptor chains.
- Child elements of this element must be beans whose bean class implements
- org.apache.cxf.Interceptor, or references to such beans.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="properties" type="beans:Tmap" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Specifies a map of properties that are passed to the bus.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:all>
- <xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
- <xsd:attribute name="bus" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Name of the bus that is being configured. Defaults to "cxf", but can
- be used to specify a different bus to allow for multiple Bus instances
- within an application.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="id" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Unique identifier for the particular Bus instance. Mostly used by the
- JMX management and OSGi service registry to provide some level of
- persitent naming to the Bus instances. The default is "cxf" + random number.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
-</xsd:schema>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/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"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/osgi/itests-felix/pom.xml
----------------------------------------------------------------------
diff --git a/osgi/itests-felix/pom.xml b/osgi/itests-felix/pom.xml
index b4953a3..057fdb8 100644
--- a/osgi/itests-felix/pom.xml
+++ b/osgi/itests-felix/pom.xml
@@ -39,6 +39,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
----------------------------------------------------------------------
diff --git a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
index 58f5e22..1f7ac25 100644
--- a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
+++ b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
@@ -56,6 +56,7 @@ public class NoAriesBlueprintTest extends OSGiTestSupport {
mavenBundle().groupId("org.apache.cxf").artifactId("cxf-core").versionAsInProject(),
mavenBundle().groupId("org.apache.servicemix.bundles")
.artifactId("org.apache.servicemix.bundles.wsdl4j").versionAsInProject(),
+ mavenBundle().groupId("org.apache.cxf").artifactId("cxf-aries-blueprint").versionAsInProject(),
mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-wsdl").versionAsInProject(),
mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-databinding-jaxb").versionAsInProject(),
mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-bindings-xml").versionAsInProject(),
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/osgi/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/osgi/karaf/features/src/main/resources/features.xml b/osgi/karaf/features/src/main/resources/features.xml
index 5231781..c0d5ab9 100644
--- a/osgi/karaf/features/src/main/resources/features.xml
+++ b/osgi/karaf/features/src/main/resources/features.xml
@@ -77,9 +77,15 @@
<bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/${cxf.xmlresolver.bundle.version}</bundle>
<bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.fastinfoset/${cxf.fastinfoset.bundle.version}</bundle>
<bundle start-level="40">mvn:org.apache.cxf/cxf-core/${project.version}</bundle>
+ <bundle start-level="40">mvn:org.apache.cxf/cxf-aries-blueprint/${project.version}</bundle>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-management/${project.version}</bundle>
<bundle start-level="40">mvn:org.apache.cxf.karaf/cxf-karaf-commands/${project.version}</bundle>
</feature>
+ <feature name="cxf-spring" version="${project.version}" resolver="(obr)">
+ <feature version="[3,4)">spring</feature>
+ <feature version="${project.version}">cxf-core</feature>
+ <bundle start-level="40">mvn:org.apache.cxf/cxf-spring/${project.version}</bundle>
+ </feature>
<feature name="cxf-wsdl" version="${project.version}" resolver="(obr)">
<feature version="${project.version}">cxf-core</feature>
<bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.wsdl4j/${cxf.wsdl4j.bundle.version}</bundle>
@@ -238,8 +244,8 @@
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-bindings-corba/${project.version}</bundle>
</feature>
<feature name="cxf-bindings-coloc" version="${project.version}" resolver="(obr)">
- <feature version="${project.version}">cxf-core</feature>
<feature version="[3,4)">spring</feature>
+ <feature version="${project.version}">cxf-core</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-bindings-coloc/${project.version}</bundle>
</feature>
<feature name="cxf-bindings-object" version="${project.version}" resolver="(obr)">
@@ -308,6 +314,7 @@
<feature version="[3,4)">spring</feature>
<feature version="[1.2,2)">spring-dm</feature>
<feature version="${project.version}">cxf-core</feature>
+ <feature version="${project.version}">cxf-spring</feature>
<feature version="${project.version}">cxf-jaxws</feature>
<feature version="${project.version}">cxf-jaxrs</feature>
<feature version="${project.version}">cxf-databinding-jaxb</feature>
[8/9] Pull aries-blueprint support out
Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/pom.xml b/rt/aries-blueprint/pom.xml
new file mode 100644
index 0000000..f188cb5
--- /dev/null
+++ b/rt/aries-blueprint/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Aries Blueprint Support</name>
+ <description>Apache CXF Aries Blueprint Support</description>
+ <url>http://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <cxf.bundle.activator>org.apache.cxf.configuration.blueprint.internal.CXFActivator</cxf.bundle.activator>
+ <cxf.osgi.export>
+ !org.apache.cxf.configuration.blueprint.internal,
+ org.apache.cxf.configuration.blueprint.*,
+ org.apache.cxf.bus.blueprint.*
+ </cxf.osgi.export>
+ <cxf.osgi.import>
+ org.apache.aries*;version="${cxf.aries.version.range}";resolution:=optional
+ </cxf.osgi.import>
+ <!-- keep in sync with services exported in activator -->
+ <cxf.export.service>
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/core",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/beans",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/parameterized-types",
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security"
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/wsdl/",
+ </cxf.export.service>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
new file mode 100644
index 0000000..70b547e
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
@@ -0,0 +1,214 @@
+/**
+ * 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()) {
+ 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 {
+ 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
new file mode 100644
index 0000000..9842ad3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
@@ -0,0 +1,77 @@
+/**
+ * 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 loadAdditionalFeatures() {
+ super.loadAdditionalFeatures();
+ }
+
+ 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);
+ }
+ public String getId() {
+ if (id == null) {
+ id = context.getBundle().getSymbolicName() + "-"
+ + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+ }
+ return id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
new file mode 100644
index 0000000..7f5d27c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BlueprintNameSpaceHandlerFactory.java
@@ -0,0 +1,30 @@
+/**
+ * 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
new file mode 100644
index 0000000..8c00dc3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BundleDelegatingClassLoader.java
@@ -0,0 +1,133 @@
+/**
+ * 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
new file mode 100644
index 0000000..2ea3559
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/BusDefinitionParser.java
@@ -0,0 +1,68 @@
+/**
+ * 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
new file mode 100644
index 0000000..128fee4
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
@@ -0,0 +1,179 @@
+/**
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+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 HashMap<String, List<MatcherHolder>>();
+
+ static class MatcherHolder {
+ Matcher matcher;
+ String wildCardId;
+ public MatcherHolder(String orig, Matcher matcher) {
+ wildCardId = orig;
+ this.matcher = matcher;
+ }
+ }
+
+
+ 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
new file mode 100644
index 0000000..ed8f59a
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/Messages.properties
@@ -0,0 +1,26 @@
+#
+#
+# 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
new file mode 100644
index 0000000..390b76c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/bus/blueprint/NamespaceHandlerRegisterer.java
@@ -0,0 +1,51 @@
+/**
+ * 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.info("Registered blueprint namespace handler for " + namespace);
+ }
+ } catch (Throwable e) {
+ LOG.log(Level.WARNING, "Aries Blueprint packages not available. So namespaces will not be registered", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
new file mode 100644
index 0000000..6be1e3c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -0,0 +1,439 @@
+/**
+ * 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.util.PackageUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.osgi.framework.Bundle;
+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");
+
+ Bundle blueprintBundle = null;
+ if (meta instanceof PassThroughMetadata) {
+ blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
+ }
+ 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 (blueprintBundle != null && !cdr.containsComponentDefinition(name)) {
+ //Create a bus
+
+ MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
+ bus.setId(name);
+ bus.setRuntimeClass(BlueprintBus.class);
+ 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 = ctx.createUnmarshaller().unmarshal(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;
+ 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) {
+ Unmarshaller u = getContext(c).createUnmarshaller();
+ 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);
+ }
+ } 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
new file mode 100644
index 0000000..fca633c
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/InterceptorTypeConverter.java
@@ -0,0 +1,42 @@
+/**
+ * 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
new file mode 100644
index 0000000..77ce8b3
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/SimpleBPBeanDefinitionParser.java
@@ -0,0 +1,87 @@
+/**
+ * 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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
new file mode 100644
index 0000000..67d713e
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandler.java
@@ -0,0 +1,109 @@
+/**
+ * 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.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.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;
+
+/**
+ *
+ */
+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/fc2cbb29/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
new file mode 100644
index 0000000..52cdd82
--- /dev/null
+++ b/rt/aries-blueprint/src/main/java/org/apache/cxf/configuration/blueprint/internal/CXFActivator.java
@@ -0,0 +1,62 @@
+/**
+ * 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.internal;
+
+import org.apache.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
+import org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * 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 {
+
+ /** {@inheritDoc}*/
+ public void start(BundleContext context) throws Exception {
+
+ 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");
+
+ }
+
+ /** {@inheritDoc}*/
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd b/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
new file mode 100644
index 0000000..3b3c144
--- /dev/null
+++ b/rt/aries-blueprint/src/main/resources/schemas/blueprint/core.xsd
@@ -0,0 +1,160 @@
+<?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.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:beans="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cxf-beans="http://cxf.apache.org/configuration/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ptp="http://cxf.apache.org/configuration/parameterized-types"
+
+ targetNamespace="http://cxf.apache.org/blueprint/core"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified" >
+
+ <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"/>
+ <xsd:import namespace="http://cxf.apache.org/configuration/beans" schemaLocation="http://cxf.apache.org/schemas/configuration/cxf-beans.xsd"/>
+ <xsd:import namespace="http://cxf.apache.org/configuration/parameterized-types"
+ schemaLocation="http://cxf.apache.org/schemas/configuration/parameterized-types.xsd"/>
+
+ <xsd:annotation>
+ <xsd:documentation>
+ This schema defines beans representing the CXF bus and its core features.
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="logging">
+ <xsd:annotation>
+ <xsd:documentation>
+ The logging feature enables you to log the content of inbound and outbound messages and faults.
+ The content is logged by all log handlers configured in your java.util.logging configuration file,
+ provided the log level for classes org.apache.cxf.interceptor.LoggingInInterceptor and
+ org.apache.cxf.interceptor.LoggingOutInterceptor is at least INFO.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="limit" type="xsd:int" use="optional" default="102400"/>
+ <xsd:attribute name="id" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="fastinfoset">
+ <xsd:annotation>
+ <xsd:documentation>
+ The fastinfoset feature enables you to turn on using fastinfoset encoding of
+ xml payloads.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="force" type="xsd:boolean" use="optional" default="false"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="workqueue">
+ <xsd:annotation>
+ <xsd:documentation>
+ Configuration for workqueues that CXF uses
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence />
+ <xsd:attribute name="highWaterMark" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="lowWaterMark" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="initialSize" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="queueSize" type="ptp:ParameterizedInt" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="dequeueTimeout" type="ptp:ParameterizedLong" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="bus">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="features" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of features that are applied to the bus.
+ Child elements of this element must be beans whose bean class extends
+ org.apache.cxf.AbstractFeature, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all inbound message interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="inFaultInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all inbound fault interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="outInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all outbound message interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="outFaultInterceptors" type="xsd:anyType" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The list of interceptors that the bus contributes to all outbound fault interceptor chains.
+ Child elements of this element must be beans whose bean class implements
+ org.apache.cxf.Interceptor, or references to such beans.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="properties" type="beans:Tmap" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>Specifies a map of properties that are passed to the bus.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
+ <xsd:attribute name="bus" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Name of the bus that is being configured. Defaults to "cxf", but can
+ be used to specify a different bus to allow for multiple Bus instances
+ within an application.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="id" type="xsd:string">
+ <xsd:annotation>
+ <xsd:documentation>
+ Unique identifier for the particular Bus instance. Mostly used by the
+ JMX management and OSGi service registry to provide some level of
+ persitent naming to the Bus instances. The default is "cxf" + random number.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
----------------------------------------------------------------------
diff --git a/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java b/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
new file mode 100644
index 0000000..dd0dd3c
--- /dev/null
+++ b/rt/aries-blueprint/src/test/java/org/apache/cxf/configuration/blueprint/internal/CXFAPINamespaceHandlerTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.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"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/coloc/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/coloc/pom.xml b/rt/bindings/coloc/pom.xml
index 9d8b1c5..c4e7b05 100644
--- a/rt/bindings/coloc/pom.xml
+++ b/rt/bindings/coloc/pom.xml
@@ -52,6 +52,13 @@
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/object/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/object/pom.xml b/rt/bindings/object/pom.xml
index ed7a2be..e4a89a1 100644
--- a/rt/bindings/object/pom.xml
+++ b/rt/bindings/object/pom.xml
@@ -54,6 +54,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/bindings/soap/pom.xml
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/pom.xml b/rt/bindings/soap/pom.xml
index fba8cd6..10a05d5 100644
--- a/rt/bindings/soap/pom.xml
+++ b/rt/bindings/soap/pom.xml
@@ -63,6 +63,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/features/clustering/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/clustering/pom.xml b/rt/features/clustering/pom.xml
index dac027a..fca832b 100644
--- a/rt/features/clustering/pom.xml
+++ b/rt/features/clustering/pom.xml
@@ -64,6 +64,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml
index 6b2948b..0c4b050 100644
--- a/rt/frontend/jaxrs/pom.xml
+++ b/rt/frontend/jaxrs/pom.xml
@@ -105,6 +105,13 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>${cxf.servlet-api.group}</groupId>
<artifactId>${cxf.servlet-api.artifact}</artifactId>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/pom.xml b/rt/frontend/jaxws/pom.xml
index 20ea597..cff30a1 100644
--- a/rt/frontend/jaxws/pom.xml
+++ b/rt/frontend/jaxws/pom.xml
@@ -107,6 +107,14 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${project.version}</version>
<scope>test</scope>
http://git-wip-us.apache.org/repos/asf/cxf/blob/fc2cbb29/rt/frontend/simple/pom.xml
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/pom.xml b/rt/frontend/simple/pom.xml
index d80ec4c..55831f0 100644
--- a/rt/frontend/simple/pom.xml
+++ b/rt/frontend/simple/pom.xml
@@ -80,6 +80,13 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-aries-blueprint</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
<version>${project.version}</version>
<scope>test</scope>