diff --git a/core-tiger/src/test/java/org/springframework/ws/config/DummyMarshaller.java b/core-tiger/src/test/java/org/springframework/ws/config/DummyMarshaller.java new file mode 100644 index 00000000..9cb6e69e --- /dev/null +++ b/core-tiger/src/test/java/org/springframework/ws/config/DummyMarshaller.java @@ -0,0 +1,44 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import java.io.IOException; +import javax.xml.transform.Result; +import javax.xml.transform.Source; + +import org.springframework.oxm.Marshaller; +import org.springframework.oxm.Unmarshaller; +import org.springframework.oxm.XmlMappingException; + +/** + * @author Arjen Poutsma + * @since 1.1.0 + */ +public class DummyMarshaller implements Marshaller, Unmarshaller { + + public void marshal(Object graph, Result result) throws XmlMappingException, IOException { + throw new UnsupportedOperationException(); + } + + public boolean supports(Class clazz) { + throw new UnsupportedOperationException(); + } + + public Object unmarshal(Source source) throws XmlMappingException, IOException { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/core-tiger/src/test/resources/org/springframework/ws/config/SwsNamespaceHandlerTigerTest.java b/core-tiger/src/test/resources/org/springframework/ws/config/SwsNamespaceHandlerTigerTest.java new file mode 100644 index 00000000..ed310862 --- /dev/null +++ b/core-tiger/src/test/resources/org/springframework/ws/config/SwsNamespaceHandlerTigerTest.java @@ -0,0 +1,45 @@ +/* + * Copyright ${YEAR} the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import java.util.Map; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter; +import org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter; + +import junit.framework.TestCase; + +public class SwsNamespaceHandlerTigerTest extends TestCase { + + private ApplicationContext applicationContext; + + protected void setUp() throws Exception { + applicationContext = new ClassPathXmlApplicationContext("swsNamespaceHandlerTest-tiger.xml", getClass()); + } + + public void testMarshallingEndpoints() throws Exception { + Map result = applicationContext.getBeansOfType(GenericMarshallingMethodEndpointAdapter.class); + assertFalse("no MarshallingMethodEndpointAdapter found", result.isEmpty()); + } + + public void testXpathEndpoints() throws Exception { + Map result = applicationContext.getBeansOfType(XPathParamAnnotationMethodEndpointAdapter.class); + assertFalse("no XPathParamAnnotationMethodEndpointAdapter found", result.isEmpty()); + } +} \ No newline at end of file diff --git a/core-tiger/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest-tiger.xml b/core-tiger/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest-tiger.xml new file mode 100644 index 00000000..3ded1361 --- /dev/null +++ b/core-tiger/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest-tiger.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + diff --git a/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java new file mode 100644 index 00000000..0e67505e --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/MarshallingEndpointsBeanDefinitionParser.java @@ -0,0 +1,70 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.core.JdkVersion; +import org.springframework.util.ClassUtils; +import org.springframework.util.StringUtils; + +import org.w3c.dom.Element; + +/** + * Parser for the <sws:marshalling-endpoints/> element. + * + * @author Arjen Poutsma + * @since 1.1.0 + */ +class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { + + private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = + "org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"; + + private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = + "org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter"; + + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + protected String getBeanClassName(Element element) { + if (JdkVersion.isAtLeastJava15()) { + try { + ClassUtils.forName(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME); + return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; + } + catch (ClassNotFoundException e) { + // ignore, fall through; + } + } + return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; + } + + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { + String marshallerName = element.getAttribute("marshaller"); + if (StringUtils.hasText(marshallerName)) { + beanDefinitionBuilder.addPropertyReference("marshaller", marshallerName); + } + String unmarshallerName = element.getAttribute("unmarshaller"); + if (StringUtils.hasText(unmarshallerName)) { + beanDefinitionBuilder.addPropertyReference("unmarshaller", unmarshallerName); + } + } + +} diff --git a/core/src/main/java/org/springframework/ws/config/SwsNamespaceHandler.java b/core/src/main/java/org/springframework/ws/config/SwsNamespaceHandler.java new file mode 100644 index 00000000..d9b81dd9 --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/SwsNamespaceHandler.java @@ -0,0 +1,34 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import org.springframework.beans.factory.xml.NamespaceHandler; +import org.springframework.beans.factory.xml.NamespaceHandlerSupport; + +/** + * {@link NamespaceHandler} for the 'sws' namespace. + * + * @author Arjen Poutsma + * @since 1.1.0 + */ +public class SwsNamespaceHandler extends NamespaceHandlerSupport { + + public void init() { + registerBeanDefinitionParser("marshalling-endpoints", new MarshallingEndpointsBeanDefinitionParser()); + registerBeanDefinitionParser("xpath-endpoints", new XPathEndpointsBeanDefinitionParser()); + } +} diff --git a/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java new file mode 100644 index 00000000..6e24ac29 --- /dev/null +++ b/core/src/main/java/org/springframework/ws/config/XPathEndpointsBeanDefinitionParser.java @@ -0,0 +1,63 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.util.xml.DomUtils; + +import org.w3c.dom.Element; + +/** + * Parser for the <sws:xpath-endpoints/> element. + * + * @author Arjen Poutsma + * @since 1.1.0 + */ +class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { + + private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME = + "org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter"; + + protected boolean shouldGenerateIdAsFallback() { + return true; + } + + protected String getBeanClassName(Element element) { + return XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME; + } + + protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { + List namespaceElements = DomUtils.getChildElementsByTagName(element, "namespace"); + if (!namespaceElements.isEmpty()) { + Properties namespaces = new Properties(); + for (Iterator iterator = namespaceElements.iterator(); iterator.hasNext();) { + Element namespaceElement = (Element) iterator.next(); + String prefix = namespaceElement.getAttribute("prefix"); + String uri = namespaceElement.getAttribute("uri"); + namespaces.setProperty(prefix, uri); + } + beanDefinitionBuilder.addPropertyValue("namespaces", namespaces); + } + } + +} diff --git a/core/src/main/resources/META-INF/spring.handlers b/core/src/main/resources/META-INF/spring.handlers new file mode 100644 index 00000000..b4b41535 --- /dev/null +++ b/core/src/main/resources/META-INF/spring.handlers @@ -0,0 +1 @@ +http\://www.springframework.org/spring-ws/schema/sws=org.springframework.ws.config.SwsNamespaceHandler \ No newline at end of file diff --git a/core/src/main/resources/META-INF/spring.schemas b/core/src/main/resources/META-INF/spring.schemas new file mode 100644 index 00000000..b74d61a8 --- /dev/null +++ b/core/src/main/resources/META-INF/spring.schemas @@ -0,0 +1 @@ +http\://www.springframework.org/spring-ws/schema/sws/spring-ws-1.1.xsd=/org/springframework/ws/config/spring-ws-1.1.xsd \ No newline at end of file diff --git a/core/src/main/resources/org/springframework/ws/config/spring-ws-1.1.xsd b/core/src/main/resources/org/springframework/ws/config/spring-ws-1.1.xsd new file mode 100644 index 00000000..97c23b8d --- /dev/null +++ b/core/src/main/resources/org/springframework/ws/config/spring-ws-1.1.xsd @@ -0,0 +1,86 @@ + + + + + + + + + Defines the configuration elements for Spring Web Services. + + + + + + + Indicates that a unmarshaller should be used to convert incoming request + messages into method parameters, and return values marshalled into a response message. + + + + + + + The bean name of the Unmarshaller that is to be used to convert XML into objects. + + This attribute is not required, and only needs to be specified + explicitly if the bean name of the desired Unmarshaller + is not 'marshaller'. + + + + + + + + + + + + The bean name of the Marshaller that is to be used to convert objects into XML. + + This attribute is not required, and only needs to be specified + explicitly if the bean name of the desired Marshaller + is not 'marshaller'. + + + + + + + + + + + + + + + Indicates that a endpoints using @XPathParam annotations should be detected. + + + + + + + + Bind a namespace URI to a prefix + + + + + + + + + + + + + + + diff --git a/core/src/test/java/org/springframework/ws/config/DummyMarshaller.java b/core/src/test/java/org/springframework/ws/config/DummyMarshaller.java new file mode 100644 index 00000000..00b8a672 --- /dev/null +++ b/core/src/test/java/org/springframework/ws/config/DummyMarshaller.java @@ -0,0 +1,44 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import java.io.IOException; +import javax.xml.transform.Result; +import javax.xml.transform.Source; + +import org.springframework.oxm.Marshaller; +import org.springframework.oxm.Unmarshaller; +import org.springframework.oxm.XmlMappingException; + +/** + * @author Arjen Poutsma + * @since 1.1.0 + */ +public class DummyMarshaller implements Marshaller, Unmarshaller { + + public void marshal(Object graph, Result result) throws XmlMappingException, IOException { + throw new UnsupportedOperationException(); + } + + public boolean supports(Class clazz) { + throw new UnsupportedOperationException(); + } + + public Object unmarshal(Source source) throws XmlMappingException, IOException { + throw new UnsupportedOperationException(); + } +} diff --git a/core/src/test/java/org/springframework/ws/config/SwsNamespaceHandlerTest.java b/core/src/test/java/org/springframework/ws/config/SwsNamespaceHandlerTest.java new file mode 100644 index 00000000..11d9a5d3 --- /dev/null +++ b/core/src/test/java/org/springframework/ws/config/SwsNamespaceHandlerTest.java @@ -0,0 +1,39 @@ +/* + * Copyright ${YEAR} the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ws.config; + +import java.util.Map; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter; + +import junit.framework.TestCase; + +public class SwsNamespaceHandlerTest extends TestCase { + + private ApplicationContext applicationContext; + + protected void setUp() throws Exception { + applicationContext = new ClassPathXmlApplicationContext("swsNamespaceHandlerTest.xml", getClass()); + } + + public void testMarshallingMethods() throws Exception { + Map result = applicationContext.getBeansOfType(MarshallingMethodEndpointAdapter.class); + assertFalse("no MarshallingMethodEndpointAdapter found", result.isEmpty()); + } +} \ No newline at end of file diff --git a/core/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest.xml b/core/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest.xml new file mode 100644 index 00000000..5b710e65 --- /dev/null +++ b/core/src/test/resources/org/springframework/ws/config/swsNamespaceHandlerTest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java b/oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java index ae857ea6..df1ce8bc 100644 --- a/oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java +++ b/oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java @@ -36,10 +36,10 @@ import org.w3c.dom.Element; */ class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { - public static final String JAXB2_MARSHALLER_BEAN_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller"; + public static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller"; protected String getBeanClassName(Element element) { - return JAXB2_MARSHALLER_BEAN_NAME; + return JAXB2_MARSHALLER_CLASS_NAME; } protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) { @@ -49,7 +49,7 @@ class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionPa } List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound"); if (!classes.isEmpty()) { - ManagedList classesToBeBound = new ManagedList(); + ManagedList classesToBeBound = new ManagedList(classes.size()); for (Iterator iterator = classes.iterator(); iterator.hasNext();) { Element classToBeBound = (Element) iterator.next(); String className = classToBeBound.getAttribute("name"); diff --git a/oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java b/oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java index 3cfdb3c5..7b3f9277 100644 --- a/oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java +++ b/oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java @@ -4,9 +4,15 @@ package org.springframework.oxm.config; +import org.springframework.beans.factory.xml.NamespaceHandler; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; -/** @author Arjen Poutsma */ +/** + * {@link NamespaceHandler} for the 'oxm' namespace. + * + * @author Arjen Poutsma + * @since 1.1.0 + */ public class OxmNamespaceHandler extends NamespaceHandlerSupport { public void init() { diff --git a/pom.xml b/pom.xml index ab1400bb..34c0955f 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,27 @@ false - make-assembly + make-all-jar + package + + single + + + + + true + + + ${version} + + + + src/assembly/all.xml + + + + + make-minimal-zip package single @@ -132,7 +152,6 @@ src/assembly/minimal.xml - src/assembly/all.xml diff --git a/src/assembly/all.xml b/src/assembly/all.xml index e877a2eb..09752585 100644 --- a/src/assembly/all.xml +++ b/src/assembly/all.xml @@ -21,7 +21,22 @@ false true + + + **/oxm/* + + + **/spring.handlers + **/spring.schemas + + + + + src/main/resources/META-INF + META-INF + + \ No newline at end of file diff --git a/src/main/resources/META-INF/spring.handlers b/src/main/resources/META-INF/spring.handlers new file mode 100644 index 00000000..1cafc4cf --- /dev/null +++ b/src/main/resources/META-INF/spring.handlers @@ -0,0 +1,2 @@ +http\://www.springframework.org/spring-ws/schema/oxm=org.springframework.oxm.config.OxmNamespaceHandler +http\://www.springframework.org/spring-ws/schema/sws=org.springframework.ws.config.SwsNamespaceHandler \ No newline at end of file diff --git a/src/main/resources/META-INF/spring.schemas b/src/main/resources/META-INF/spring.schemas new file mode 100644 index 00000000..5be2458a --- /dev/null +++ b/src/main/resources/META-INF/spring.schemas @@ -0,0 +1,2 @@ +http\://www.springframework.org/spring-ws/schema/oxm/spring-oxm-1.1.xsd=/org/springframework/oxm/config/spring-oxm-1.1.xsd +http\://www.springframework.org/spring-ws/schema/sws/spring-ws-1.1.xsd=/org/springframework/ws/config/spring-ws-1.1.xsd \ No newline at end of file