This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.4.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit d6aeb541f945ee0c9e100a96890571418154a596 Author: Richard Opálka <[email protected]> AuthorDate: Wed Mar 3 00:07:12 2021 +0100 [CXF-8361] Finalized support for Jakarta NS (#746) * [CXF-8361] Finalized support for Jakarta NS * introduced new org.apache.cxf.jaxws.handler.jakartaee package for JAXB de/serialization * introduced JakartaEE to JavaEE adaptors for JAXB types * enhanced handlers de/serialization tests * [CXF-8361] Separating Jakarta EE & Java EE handler chain implementation details --- .../handler/AnnotationHandlerChainBuilder.java | 211 +--------------- .../cxf/jaxws/handler/BaseHandlerChainBuilder.java | 221 ++++++++++++++++ .../handler/JakartaeeHandlerChainBuilder.java | 66 +++++ .../jaxws/handler/JakartaeeToJavaeeAdaptor.java | 267 ++++++++++++++++++++ .../jaxws/handler/JavaeeHandlerChainBuilder.java | 67 +++++ .../cxf/jaxws/handler/jakartaee/CString.java | 97 ++++++++ .../jaxws/handler/jakartaee/DescriptionType.java | 73 ++++++ .../jaxws/handler/jakartaee/DisplayNameType.java | 70 ++++++ .../handler/jakartaee/FullyQualifiedClassType.java | 48 ++++ .../cxf/jaxws/handler/jakartaee/IconType.java | 142 +++++++++++ .../jaxws/handler/jakartaee/ParamValueType.java | 147 +++++++++++ .../cxf/jaxws/handler/jakartaee/PathType.java | 50 ++++ .../jakartaee/PortComponentHandlerType.java | 277 +++++++++++++++++++++ .../cxf/jaxws/handler/jakartaee/XsdQNameType.java | 95 +++++++ .../cxf/jaxws/handler/jakartaee/XsdStringType.java | 94 +++++++ .../cxf/jaxws/handler/jakartaee/package-info.java | 24 ++ .../JakartaAnnotationHandlerChainBuilderTest.java | 93 ++++++- .../JavaxAnnotationHandlerChainBuilderTest.java | 11 +- .../apache/cxf/jaxws/handler/jakarta-handlers.xml | 92 ++++++- .../apache/cxf/jaxws/handler/javax-handlers.xml | 36 +-- 20 files changed, 1951 insertions(+), 230 deletions(-) diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java index 3a72c06..1e8849e 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java @@ -25,44 +25,32 @@ import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.List; import java.util.ResourceBundle; -import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.regex.Pattern; import javax.jws.HandlerChain; import javax.jws.WebService; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import javax.xml.ws.WebServiceException; import javax.xml.ws.handler.Handler; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.apache.cxf.Bus; import org.apache.cxf.common.classloader.ClassLoaderUtils; import org.apache.cxf.common.i18n.BundleUtils; import org.apache.cxf.common.i18n.Message; -import org.apache.cxf.common.jaxb.JAXBUtils; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.common.util.StringUtils; import org.apache.cxf.jaxws.handler.types.PortComponentHandlerType; import org.apache.cxf.staxutils.StaxUtils; + @SuppressWarnings("rawtypes") public class AnnotationHandlerChainBuilder extends HandlerChainBuilder { - - private static final String HANDLER_CHAINS_E = "handler-chains"; - private static final String HANDLER_CHAIN_E = "handler-chain"; - private static final String JAKARTAEE_NS = "https://jakarta.ee/xml/ns/jakartaee"; - private static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee"; private static final Logger LOG = LogUtils.getL7dLogger(AnnotationHandlerChainBuilder.class); private static final ResourceBundle BUNDLE = LOG.getResourceBundle(); - private static JAXBContext context; - private ClassLoader classLoader; public AnnotationHandlerChainBuilder() { @@ -101,56 +89,20 @@ public class AnnotationHandlerChainBuilder extends HandlerChainBuilder { Document doc = StaxUtils.read(handlerFileURL.openStream()); Element el = doc.getDocumentElement(); - boolean isJavaEENamespace = JAVAEE_NS.equals(el.getNamespaceURI()); - boolean isJakartaEENamespace = JAKARTAEE_NS.equals(el.getNamespaceURI()); + boolean isJavaEENamespace = JavaeeHandlerChainBuilder.JAVAEE_NS.equals(el.getNamespaceURI()); + boolean isJakartaEENamespace = JakartaeeHandlerChainBuilder.JAKARTAEE_NS.equals(el.getNamespaceURI()); if (!isJavaEENamespace && !isJakartaEENamespace) { throw new WebServiceException( BundleUtils.getFormattedString(BUNDLE, "NOT_VALID_NAMESPACE", el.getNamespaceURI())); } - if (isJavaEENamespace && !HANDLER_CHAINS_E.equals(el.getLocalName())) { - String xml = StaxUtils.toString(el); - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_VALID_ROOT_ELEMENT", - JAVAEE_NS.equals(el.getNamespaceURI()), - HANDLER_CHAINS_E.equals(el.getLocalName()), - xml, handlerFileURL)); - } - if (isJakartaEENamespace && !HANDLER_CHAINS_E.equals(el.getLocalName())) { - String xml = StaxUtils.toString(el); - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_VALID_ROOT_ELEMENT", - JAKARTAEE_NS.equals(el.getNamespaceURI()), - HANDLER_CHAINS_E.equals(el.getLocalName()), - xml, handlerFileURL)); - } - chain = new ArrayList<>(); - Node node = el.getFirstChild(); - while (node != null) { - if (node instanceof Element) { - el = (Element)node; - isJavaEENamespace = JAVAEE_NS.equals(el.getNamespaceURI()); - isJakartaEENamespace = JAKARTAEE_NS.equals(el.getNamespaceURI()); - if (!isJavaEENamespace && !isJakartaEENamespace) { - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_VALID_NAMESPACE", - el.getNamespaceURI())); - } - if (!HANDLER_CHAIN_E.equals(el.getLocalName())) { - String xml = StaxUtils.toString(el); - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_VALID_ELEMENT_IN_HANDLER", - xml)); - } - processHandlerChainElement(el, chain, - portQName, serviceQName, bindingID); - } - node = node.getNextSibling(); + if (isJavaEENamespace) { + chain = new JavaeeHandlerChainBuilder(BUNDLE, handlerFileURL, this) + .build(el, portQName, serviceQName, bindingID); + } else { + chain = new JakartaeeHandlerChainBuilder(BUNDLE, handlerFileURL, this) + .build(el, portQName, serviceQName, bindingID); } } catch (WebServiceException e) { throw e; @@ -177,149 +129,8 @@ public class AnnotationHandlerChainBuilder extends HandlerChainBuilder { return clazz.getClassLoader(); } - private void processHandlerChainElement(Element el, List<Handler> chain, - QName portQName, QName serviceQName, String bindingID) { - Node node = el.getFirstChild(); - while (node != null) { - Node cur = node; - node = node.getNextSibling(); - if (cur instanceof Element) { - el = (Element)cur; - boolean isJavaEENamespace = JAVAEE_NS.equals(el.getNamespaceURI()); - boolean isJakartaEENamespace = JAKARTAEE_NS.equals(el.getNamespaceURI()); - if (!isJavaEENamespace && !isJakartaEENamespace) { - String xml = StaxUtils.toString(el); - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_VALID_ELEMENT_IN_HANDLER", - xml)); - } - String name = el.getLocalName(); - if ("port-name-pattern".equals(name)) { - if (!patternMatches(el, portQName)) { - return; - } - } else if ("service-name-pattern".equals(name)) { - if (!patternMatches(el, serviceQName)) { - return; - } - } else if ("protocol-bindings".equals(name)) { - if (!protocolMatches(el, bindingID)) { - return; - } - } else if ("handler".equals(name)) { - processHandlerElement(el, chain); - } - } - } - } - private boolean protocolMatches(Element el, String id) { - if (id == null) { - return true; - } - String name = el.getTextContent().trim(); - StringTokenizer st = new StringTokenizer(name, " ", false); - boolean result = false; - while (st.hasMoreTokens() && !result) { - result = result || singleProtocolMatches(st.nextToken(), id); - } - return result; - } - private boolean singleProtocolMatches(String name, String id) { - if ("##SOAP11_HTTP".equals(name)) { - return "http://schemas.xmlsoap.org/wsdl/soap/http".contains(id) - || "http://schemas.xmlsoap.org/soap/".contains(id); - } else if ("##SOAP11_HTTP_MTOM".equals(name)) { - return "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true".contains(id) - || "http://schemas.xmlsoap.org/soap/?mtom=true".contains(id); - } else if ("##SOAP12_HTTP".equals(name)) { - return "http://www.w3.org/2003/05/soap/bindings/HTTP/".contains(id) - || "http://schemas.xmlsoap.org/wsdl/soap12/".contains(id); - } else if ("##SOAP12_HTTP_MTOM".equals(name)) { - return "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true".contains(id) - || "http://schemas.xmlsoap.org/wsdl/soap12/?mtom=true".contains(id); - } else if ("##XML_HTTP".equals(name)) { - name = "http://www.w3.org/2004/08/wsdl/http"; - } - return name.contains(id); - } - private boolean patternMatches(Element el, QName comp) { - if (comp == null) { - return true; - } - String namePattern = el.getTextContent().trim(); - if ("*".equals(namePattern)) { - return true; - } - final int idx = namePattern.indexOf(':'); - if (idx < 0) { - String xml = StaxUtils.toString(el); - throw new WebServiceException( - BundleUtils.getFormattedString(BUNDLE, - "NOT_A_QNAME_PATTER", - namePattern, xml)); - } - String pfx = namePattern.substring(0, idx); - String ns = el.lookupNamespaceURI(pfx); - if (ns == null) { - ns = pfx; - } - if (!ns.equals(comp.getNamespaceURI())) { - return false; - } - String localPart = namePattern.substring(idx + 1, - namePattern.length()); - if (localPart.contains("*")) { - //wildcard pattern matching - return Pattern.matches(mapPattern(localPart), comp.getLocalPart()); - } else if (!localPart.equals(comp.getLocalPart())) { - return false; - } - return true; - } - - private String mapPattern(String s) { - StringBuilder buf = new StringBuilder(s); - for (int x = 0; x < buf.length(); x++) { - switch (buf.charAt(x)) { - case '*': - buf.insert(x, '.'); - x++; - break; - case '.': - case '\\': - case '^': - case '$': - case '{': - case '}': - case '(': - case ')': - buf.insert(x, '\\'); - x++; - break; - default: - //nothing to do - } - } - return buf.toString(); - } - - private void processHandlerElement(Element el, List<Handler> chain) { - try { - JAXBContext ctx = getContextForPortComponentHandlerType(); - PortComponentHandlerType pt = JAXBUtils.unmarshall(ctx, el, PortComponentHandlerType.class).getValue(); - chain.addAll(buildHandlerChain(pt, classLoader)); - } catch (JAXBException e) { - throw new IllegalArgumentException("Could not unmarshal handler chain", e); - } - } - - private static synchronized JAXBContext getContextForPortComponentHandlerType() - throws JAXBException { - if (context == null) { - context = JAXBContext.newInstance(PortComponentHandlerType.class); - } - return context; + List<Handler> buildHandlerChain(PortComponentHandlerType ht) { + return buildHandlerChain(ht, classLoader); } public List<Handler> buildHandlerChainFromClass(Class<?> clz, QName portQName, QName serviceQName, diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/BaseHandlerChainBuilder.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/BaseHandlerChainBuilder.java new file mode 100644 index 0000000..279eb4b --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/BaseHandlerChainBuilder.java @@ -0,0 +1,221 @@ +/** + * 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.jaxws.handler; + +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; +import java.util.StringTokenizer; +import java.util.regex.Pattern; + +import javax.xml.namespace.QName; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.handler.Handler; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import org.apache.cxf.common.i18n.BundleUtils; +import org.apache.cxf.staxutils.StaxUtils; + +abstract class BaseHandlerChainBuilder { + private static final String HANDLER_CHAINS_E = "handler-chains"; + private static final String HANDLER_CHAIN_E = "handler-chain"; + final AnnotationHandlerChainBuilder delegate; + private final ResourceBundle bundle; + private final URL handlerFileURL; + + protected BaseHandlerChainBuilder(ResourceBundle bundle, URL handlerFileURL, + AnnotationHandlerChainBuilder delegate) { + this.bundle = bundle; + this.handlerFileURL = handlerFileURL; + this.delegate = delegate; + } + + protected List<Handler> build(String namespace, Element el, QName portQName, QName serviceQName, String bindingID) { + if (!HANDLER_CHAINS_E.equals(el.getLocalName())) { + String xml = StaxUtils.toString(el); + throw new WebServiceException( + BundleUtils.getFormattedString(bundle, + "NOT_VALID_ROOT_ELEMENT", + namespace.equals(el.getNamespaceURI()), + HANDLER_CHAINS_E.equals(el.getLocalName()), + xml, handlerFileURL)); + } + + List<Handler> chain = new ArrayList<>(); + Node node = el.getFirstChild(); + while (node != null) { + if (node instanceof Element) { + el = (Element)node; + + if (!namespace.equals(el.getNamespaceURI())) { + throw new WebServiceException( + BundleUtils.getFormattedString(bundle, + "NOT_VALID_NAMESPACE", + el.getNamespaceURI())); + } + + if (!HANDLER_CHAIN_E.equals(el.getLocalName())) { + String xml = StaxUtils.toString(el); + throw new WebServiceException( + BundleUtils.getFormattedString(bundle, + "NOT_VALID_ELEMENT_IN_HANDLER", + xml)); + } + processHandlerChainElement(namespace, el, chain, + portQName, serviceQName, bindingID); + } + node = node.getNextSibling(); + } + + return chain; + } + + private void processHandlerChainElement(String namespace, Element el, List<Handler> chain, + QName portQName, QName serviceQName, String bindingID) { + Node node = el.getFirstChild(); + while (node != null) { + Node cur = node; + node = node.getNextSibling(); + if (cur instanceof Element) { + el = (Element)cur; + if (!namespace.equals(el.getNamespaceURI())) { + String xml = StaxUtils.toString(el); + throw new WebServiceException( + BundleUtils.getFormattedString(bundle, + "NOT_VALID_ELEMENT_IN_HANDLER", + xml)); + } + String name = el.getLocalName(); + if ("port-name-pattern".equals(name)) { + if (!patternMatches(el, portQName)) { + return; + } + } else if ("service-name-pattern".equals(name)) { + if (!patternMatches(el, serviceQName)) { + return; + } + } else if ("protocol-bindings".equals(name)) { + if (!protocolMatches(el, bindingID)) { + return; + } + } else if ("handler".equals(name)) { + processHandlerElement(el, chain); + } + } + } + } + + private boolean protocolMatches(Element el, String id) { + if (id == null) { + return true; + } + String name = el.getTextContent().trim(); + StringTokenizer st = new StringTokenizer(name, " ", false); + boolean result = false; + while (st.hasMoreTokens() && !result) { + result = result || singleProtocolMatches(st.nextToken(), id); + } + return result; + } + private boolean singleProtocolMatches(String name, String id) { + if ("##SOAP11_HTTP".equals(name)) { + return "http://schemas.xmlsoap.org/wsdl/soap/http".contains(id) + || "http://schemas.xmlsoap.org/soap/".contains(id); + } else if ("##SOAP11_HTTP_MTOM".equals(name)) { + return "http://schemas.xmlsoap.org/wsdl/soap/http?mtom=true".contains(id) + || "http://schemas.xmlsoap.org/soap/?mtom=true".contains(id); + } else if ("##SOAP12_HTTP".equals(name)) { + return "http://www.w3.org/2003/05/soap/bindings/HTTP/".contains(id) + || "http://schemas.xmlsoap.org/wsdl/soap12/".contains(id); + } else if ("##SOAP12_HTTP_MTOM".equals(name)) { + return "http://www.w3.org/2003/05/soap/bindings/HTTP/?mtom=true".contains(id) + || "http://schemas.xmlsoap.org/wsdl/soap12/?mtom=true".contains(id); + } else if ("##XML_HTTP".equals(name)) { + name = "http://www.w3.org/2004/08/wsdl/http"; + } + return name.contains(id); + } + private boolean patternMatches(Element el, QName comp) { + if (comp == null) { + return true; + } + String namePattern = el.getTextContent().trim(); + if ("*".equals(namePattern)) { + return true; + } + final int idx = namePattern.indexOf(':'); + if (idx < 0) { + String xml = StaxUtils.toString(el); + throw new WebServiceException( + BundleUtils.getFormattedString(bundle, + "NOT_A_QNAME_PATTER", + namePattern, xml)); + } + String pfx = namePattern.substring(0, idx); + String ns = el.lookupNamespaceURI(pfx); + if (ns == null) { + ns = pfx; + } + if (!ns.equals(comp.getNamespaceURI())) { + return false; + } + String localPart = namePattern.substring(idx + 1, + namePattern.length()); + if (localPart.contains("*")) { + //wildcard pattern matching + return Pattern.matches(mapPattern(localPart), comp.getLocalPart()); + } else if (!localPart.equals(comp.getLocalPart())) { + return false; + } + return true; + } + + private String mapPattern(String s) { + StringBuilder buf = new StringBuilder(s); + for (int x = 0; x < buf.length(); x++) { + switch (buf.charAt(x)) { + case '*': + buf.insert(x, '.'); + x++; + break; + case '.': + case '\\': + case '^': + case '$': + case '{': + case '}': + case '(': + case ')': + buf.insert(x, '\\'); + x++; + break; + default: + //nothing to do + } + } + return buf.toString(); + } + + abstract void processHandlerElement(Element el, List<Handler> chain); + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeHandlerChainBuilder.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeHandlerChainBuilder.java new file mode 100644 index 0000000..9022796 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeHandlerChainBuilder.java @@ -0,0 +1,66 @@ +/** + * 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.jaxws.handler; + +import java.net.URL; +import java.util.List; +import java.util.ResourceBundle; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; +import javax.xml.ws.handler.Handler; + +import org.w3c.dom.Element; + +import org.apache.cxf.common.jaxb.JAXBUtils; +import org.apache.cxf.jaxws.handler.jakartaee.PortComponentHandlerType; + +final class JakartaeeHandlerChainBuilder extends BaseHandlerChainBuilder { + static final String JAKARTAEE_NS = "https://jakarta.ee/xml/ns/jakartaee"; + private static JAXBContext context; + + JakartaeeHandlerChainBuilder(ResourceBundle bundle, URL handlerFileURL, + AnnotationHandlerChainBuilder delegate) { + super(bundle, handlerFileURL, delegate); + } + + public List<Handler> build(Element el, QName portQName, QName serviceQName, String bindingID) { + return build(JAKARTAEE_NS, el, portQName, serviceQName, bindingID); + } + + void processHandlerElement(Element el, List<Handler> chain) { + try { + JAXBContext ctx = getContextForPortComponentHandlerType(); + PortComponentHandlerType pt = JAXBUtils.unmarshall(ctx, el, PortComponentHandlerType.class).getValue(); + chain.addAll(delegate.buildHandlerChain(JakartaeeToJavaeeAdaptor.of(pt))); + } catch (JAXBException e) { + throw new IllegalArgumentException("Could not unmarshal handler chain", e); + } + } + + private static synchronized JAXBContext getContextForPortComponentHandlerType() + throws JAXBException { + if (context == null) { + context = JAXBContext.newInstance(PortComponentHandlerType.class); + } + return context; + } +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeToJavaeeAdaptor.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeToJavaeeAdaptor.java new file mode 100644 index 0000000..0834739 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JakartaeeToJavaeeAdaptor.java @@ -0,0 +1,267 @@ +/** + * 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.jaxws.handler; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.cxf.jaxws.handler.types.CString; +import org.apache.cxf.jaxws.handler.types.DescriptionType; +import org.apache.cxf.jaxws.handler.types.DisplayNameType; +import org.apache.cxf.jaxws.handler.types.FullyQualifiedClassType; +import org.apache.cxf.jaxws.handler.types.IconType; +import org.apache.cxf.jaxws.handler.types.ParamValueType; +import org.apache.cxf.jaxws.handler.types.PortComponentHandlerType; +import org.apache.cxf.jaxws.handler.types.XsdQNameType; +import org.apache.cxf.jaxws.handler.types.XsdStringType; + +public final class JakartaeeToJavaeeAdaptor { + + private JakartaeeToJavaeeAdaptor() { + // forbidden instantiation + } + + public static PortComponentHandlerType of(org.apache.cxf.jaxws.handler.jakartaee.PortComponentHandlerType pcht) { + return new PortComponentHandlerTypeAdaptor(pcht); + } + + private static CString of(org.apache.cxf.jaxws.handler.jakartaee.CString cs) { + return new CStringAdaptor(cs); + } + + private static FullyQualifiedClassType of(org.apache.cxf.jaxws.handler.jakartaee.FullyQualifiedClassType fqct) { + return new FullyQualifiedClassTypeAdaptor(fqct); + } + + private static XsdStringType of(org.apache.cxf.jaxws.handler.jakartaee.XsdStringType xst) { + return new XsdStringTypeAdaptor(xst); + } + + private static ParamValueType of(org.apache.cxf.jaxws.handler.jakartaee.ParamValueType pvt) { + return new ParamValueTypeAdaptor(pvt); + } + + private static final class PortComponentHandlerTypeAdaptor extends PortComponentHandlerType { + + private final org.apache.cxf.jaxws.handler.jakartaee.PortComponentHandlerType adaptee; + + PortComponentHandlerTypeAdaptor(org.apache.cxf.jaxws.handler.jakartaee.PortComponentHandlerType adaptee) { + this.adaptee = adaptee; + } + + @Override + public CString getHandlerName() { + return of(adaptee.getHandlerName()); + } + + @Override + public FullyQualifiedClassType getHandlerClass() { + return of(adaptee.getHandlerClass()); + } + + @Override + public List<ParamValueType> getInitParam() { + final List<org.apache.cxf.jaxws.handler.jakartaee.ParamValueType> temp = adaptee.getInitParam(); + if (temp == null || temp.isEmpty()) { + return Collections.emptyList(); + } else { + final List<ParamValueType> retVal = new ArrayList<>(temp.size()); + for (org.apache.cxf.jaxws.handler.jakartaee.ParamValueType pvt : temp) { + retVal.add(of(pvt)); + } + return retVal; + } + } + + // not implemented methods + + @Override + public List<DescriptionType> getDescription() { + throw new UnsupportedOperationException(); + } + + @Override + public List<DisplayNameType> getDisplayName() { + throw new UnsupportedOperationException(); + } + + @Override + public List<IconType> getIcon() { + throw new UnsupportedOperationException(); + } + + @Override + public List<XsdQNameType> getSoapHeader() { + throw new UnsupportedOperationException(); + } + + @Override + public List<CString> getSoapRole() { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public void setHandlerClass(FullyQualifiedClassType value) { + throw new UnsupportedOperationException(); + } + + @Override + public void setHandlerName(CString value) { + throw new UnsupportedOperationException(); + } + + @Override + public void setId(String value) { + throw new UnsupportedOperationException(); + } + } + + private static final class CStringAdaptor extends CString { + private final org.apache.cxf.jaxws.handler.jakartaee.CString adaptee; + + CStringAdaptor(org.apache.cxf.jaxws.handler.jakartaee.CString adaptee) { + this.adaptee = adaptee; + } + + @Override + public String getValue() { + return adaptee.getValue(); + } + + @Override + public void setValue(String value) { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public void setId(String v) { + throw new UnsupportedOperationException(); + } + } + + private static final class FullyQualifiedClassTypeAdaptor extends FullyQualifiedClassType { + private final org.apache.cxf.jaxws.handler.jakartaee.FullyQualifiedClassType adaptee; + + FullyQualifiedClassTypeAdaptor(org.apache.cxf.jaxws.handler.jakartaee.FullyQualifiedClassType adaptee) { + this.adaptee = adaptee; + } + + @Override + public String getValue() { + return adaptee.getValue(); + } + + @Override + public void setValue(String value) { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public void setId(String v) { + throw new UnsupportedOperationException(); + } + } + + private static final class ParamValueTypeAdaptor extends ParamValueType { + private final org.apache.cxf.jaxws.handler.jakartaee.ParamValueType adaptee; + + ParamValueTypeAdaptor(org.apache.cxf.jaxws.handler.jakartaee.ParamValueType adaptee) { + this.adaptee = adaptee; + } + + @Override + public CString getParamName() { + return of(adaptee.getParamName()); + } + + @Override + public XsdStringType getParamValue() { + return of(adaptee.getParamValue()); + } + + @Override + public List<DescriptionType> getDescription() { + throw new UnsupportedOperationException(); + } + + @Override + public void setParamName(CString value) { + throw new UnsupportedOperationException(); + } + + @Override + public void setParamValue(XsdStringType value) { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public void setId(String value) { + throw new UnsupportedOperationException(); + } + } + + private static final class XsdStringTypeAdaptor extends XsdStringType { + private final org.apache.cxf.jaxws.handler.jakartaee.XsdStringType adaptee; + + XsdStringTypeAdaptor(org.apache.cxf.jaxws.handler.jakartaee.XsdStringType adaptee) { + this.adaptee = adaptee; + } + + @Override + public String getValue() { + return adaptee.getValue(); + } + + @Override + public void setValue(String value) { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() { + throw new UnsupportedOperationException(); + } + + @Override + public void setId(String v) { + throw new UnsupportedOperationException(); + } + } +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JavaeeHandlerChainBuilder.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JavaeeHandlerChainBuilder.java new file mode 100644 index 0000000..2f122a8 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/JavaeeHandlerChainBuilder.java @@ -0,0 +1,67 @@ +/** + * 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.jaxws.handler; + +import java.net.URL; +import java.util.List; +import java.util.ResourceBundle; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; +import javax.xml.ws.handler.Handler; + +import org.w3c.dom.Element; + +import org.apache.cxf.common.jaxb.JAXBUtils; +import org.apache.cxf.jaxws.handler.types.PortComponentHandlerType; + + +final class JavaeeHandlerChainBuilder extends BaseHandlerChainBuilder { + static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee"; + private static JAXBContext context; + + JavaeeHandlerChainBuilder(ResourceBundle bundle, URL handlerFileURL, + AnnotationHandlerChainBuilder delegate) { + super(bundle, handlerFileURL, delegate); + } + + public List<Handler> build(Element el, QName portQName, QName serviceQName, String bindingID) { + return build(JAVAEE_NS, el, portQName, serviceQName, bindingID); + } + + void processHandlerElement(Element el, List<Handler> chain) { + try { + JAXBContext ctx = getContextForPortComponentHandlerType(); + PortComponentHandlerType pt = JAXBUtils.unmarshall(ctx, el, PortComponentHandlerType.class).getValue(); + chain.addAll(delegate.buildHandlerChain(pt)); + } catch (JAXBException e) { + throw new IllegalArgumentException("Could not unmarshal handler chain", e); + } + } + + private static synchronized JAXBContext getContextForPortComponentHandlerType() + throws JAXBException { + if (context == null) { + context = JAXBContext.newInstance(PortComponentHandlerType.class); + } + return context; + } +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/CString.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/CString.java new file mode 100644 index 0000000..d593664 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/CString.java @@ -0,0 +1,97 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +/** + * This is a special string datatype that is defined by Java EE as a base type for defining collapsed strings. + * When schemas require trailing/leading space elimination as well as collapsing the existing whitespace, this + * base type may be used. + * <p> + * Java class for string complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="string"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>token"> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "string", propOrder = { "value" }) +public class CString { + + @XmlValue + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + protected java.lang.String value; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + + /** + * Gets the value of the value property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setValue(java.lang.String value) { + this.value = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String v) { + this.id = v; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DescriptionType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DescriptionType.java new file mode 100644 index 0000000..aa58ab8 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DescriptionType.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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +/** + * The description type is used by a description element to provide text describing the parent element. The + * elements that use this type should include any information that the Deployment Component's Deployment File + * file producer wants to provide to the consumer of the Deployment Component's Deployment File (i.e., to the + * Deployer). Typically, the tools used by such a Deployment File consumer will display the description when + * processing the parent element that contains the description. The lang attribute defines the language that + * the description is provided in. The default value is "en" (English). + * <p> + * Java class for descriptionType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="descriptionType"> + * <simpleContent> + * <extension base="<http://java.sun.com/xml/ns/javaee>xsdStringType"> + * <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "descriptionType") +public class DescriptionType extends XsdStringType { + + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + protected java.lang.String lang; + + /** + * Gets the value of the lang property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setLang(java.lang.String value) { + this.lang = value; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DisplayNameType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DisplayNameType.java new file mode 100644 index 0000000..1e77b4c --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/DisplayNameType.java @@ -0,0 +1,70 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +/** + * The display-name type contains a short name that is intended to be displayed by tools. It is used by + * display-name elements. The display name need not be unique. Example: ... <display-name xml:lang="en"> + * Employee Self Service </display-name> The value of the xml:lang attribute is "en" (English) by default. + * <p> + * Java class for display-nameType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="display-nameType"> + * <simpleContent> + * <extension base="<http://java.sun.com/xml/ns/javaee>string"> + * <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "display-nameType") +public class DisplayNameType extends CString { + + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + protected java.lang.String lang; + + /** + * Gets the value of the lang property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setLang(java.lang.String value) { + this.lang = value; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/FullyQualifiedClassType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/FullyQualifiedClassType.java new file mode 100644 index 0000000..91da312 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/FullyQualifiedClassType.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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +/** + * The elements that use this type designate the name of a Java class or interface. The name is in the form of + * a "binary name", as defined in the JLS. This is the form of name used in Class.forName(). Tools that need + * the canonical name (the name used in source code) will need to convert this binary name to the canonical + * name. + * <p> + * Java class for fully-qualified-classType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="fully-qualified-classType"> + * <simpleContent> + * <restriction base="<http://java.sun.com/xml/ns/javaee>string"> + * </restriction> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "fully-qualified-classType") +public class FullyQualifiedClassType extends CString { + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/IconType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/IconType.java new file mode 100644 index 0000000..de8a437 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/IconType.java @@ -0,0 +1,142 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +/** + * The icon type contains small-icon and large-icon elements that specify the file names for small and large + * GIF, JPEG, or PNG icon images used to represent the parent element in a GUI tool. The xml:lang attribute + * defines the language that the icon file names are provided in. Its value is "en" (English) by default. + * <p> + * Java class for iconType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="iconType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="small-icon" type="{http://java.sun.com/xml/ns/javaee}pathType" minOccurs="0"/> + * <element name="large-icon" type="{http://java.sun.com/xml/ns/javaee}pathType" minOccurs="0"/> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "iconType", propOrder = { + "smallIcon", "largeIcon" }) +public class IconType { + + @XmlElement(name = "small-icon") + protected PathType smallIcon; + @XmlElement(name = "large-icon") + protected PathType largeIcon; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + protected java.lang.String lang; + + /** + * Gets the value of the smallIcon property. + * + * @return possible object is {@link PathType } + */ + public PathType getSmallIcon() { + return smallIcon; + } + + /** + * Sets the value of the smallIcon property. + * + * @param value allowed object is {@link PathType } + */ + public void setSmallIcon(PathType value) { + this.smallIcon = value; + } + + /** + * Gets the value of the largeIcon property. + * + * @return possible object is {@link PathType } + */ + public PathType getLargeIcon() { + return largeIcon; + } + + /** + * Sets the value of the largeIcon property. + * + * @param value allowed object is {@link PathType } + */ + public void setLargeIcon(PathType value) { + this.largeIcon = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String value) { + this.id = value; + } + + /** + * Gets the value of the lang property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setLang(java.lang.String value) { + this.lang = value; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/ParamValueType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/ParamValueType.java new file mode 100644 index 0000000..4973673 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/ParamValueType.java @@ -0,0 +1,147 @@ +/** + * 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.jaxws.handler.jakartaee; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +/** + * This type is a general type that can be used to declare parameter/value lists. + * <p> + * Java class for param-valueType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="param-valueType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="description" type="{http://java.sun.com/xml/ns/javaee}descriptionType" + * maxOccurs="unbounded" minOccurs="0"/> + * <element name="param-name" type="{http://java.sun.com/xml/ns/javaee}string"/> + * <element name="param-value" type="{http://java.sun.com/xml/ns/javaee}xsdStringType"/> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "param-valueType", propOrder = { + "description", "paramName", "paramValue" }) +public class ParamValueType { + + protected List<DescriptionType> description; + @XmlElement(name = "param-name", required = true) + protected CString paramName; + @XmlElement(name = "param-value", required = true) + protected XsdStringType paramValue; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + + /** + * Gets the value of the description property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the description property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getDescription().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link DescriptionType } + */ + public List<DescriptionType> getDescription() { + if (description == null) { + description = new ArrayList<>(); + } + return this.description; + } + + /** + * Gets the value of the paramName property. + * + * @return possible object is {@link CString } + */ + public CString getParamName() { + return paramName; + } + + /** + * Sets the value of the paramName property. + * + * @param value allowed object is {@link CString } + */ + public void setParamName(CString value) { + this.paramName = value; + } + + /** + * Gets the value of the paramValue property. + * + * @return possible object is {@link XsdStringType } + */ + public XsdStringType getParamValue() { + return paramValue; + } + + /** + * Sets the value of the paramValue property. + * + * @param value allowed object is {@link XsdStringType } + */ + public void setParamValue(XsdStringType value) { + this.paramValue = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String value) { + this.id = value; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PathType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PathType.java new file mode 100644 index 0000000..090da85 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PathType.java @@ -0,0 +1,50 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +/** + * The elements that use this type designate either a relative path or an absolute path starting with a "/". + * In elements that specify a pathname to a file within the same Deployment File, relative filenames (i.e., + * those not starting with "/") are considered relative to the root of the Deployment File's namespace. + * Absolute filenames (i.e., those starting with "/") also specify names in the root of the Deployment File's + * namespace. In general, relative names are preferred. The exception is .war files where absolute names are + * preferred for consistency with the Servlet API. + * <p> + * Java class for pathType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="pathType"> + * <simpleContent> + * <restriction base="<http://java.sun.com/xml/ns/javaee>string"> + * </restriction> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "pathType") +public class PathType extends CString { + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PortComponentHandlerType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PortComponentHandlerType.java new file mode 100644 index 0000000..4fdea80 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/PortComponentHandlerType.java @@ -0,0 +1,277 @@ +/** + * 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.jaxws.handler.jakartaee; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +/** + * Declares the handler for a port-component. Handlers can access the init-param name/value pairs using the + * HandlerInfo interface. Used in: port-component + * <p> + * Java class for port-component_handlerType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="port-component_handlerType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <group ref="{http://java.sun.com/xml/ns/javaee}descriptionGroup"/> + * <element name="handler-name" type="{http://java.sun.com/xml/ns/javaee}string"/> + * <element name="handler-class" type="{http://java.sun.com/xml/ns/javaee}fully-qualified-classType"/> + * <element name="init-param" type="{http://java.sun.com/xml/ns/javaee}param-valueType" + * maxOccurs="unbounded" minOccurs="0"/> + * <element name="soap-header" type="{http://java.sun.com/xml/ns/javaee}xsdQNameType" + * maxOccurs="unbounded" minOccurs="0"/> + * <element name="soap-role" type="{http://java.sun.com/xml/ns/javaee}string" + * maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "port-component_handlerType", propOrder = { + "description", "displayName", "icon", "handlerName", "handlerClass", "initParam", "soapHeader", + "soapRole" }) +public class PortComponentHandlerType { + + protected List<DescriptionType> description; + @XmlElement(name = "display-name") + protected List<DisplayNameType> displayName; + protected List<IconType> icon; + @XmlElement(name = "handler-name", required = true) + protected CString handlerName; + @XmlElement(name = "handler-class", required = true) + protected FullyQualifiedClassType handlerClass; + @XmlElement(name = "init-param") + protected List<ParamValueType> initParam; + @XmlElement(name = "soap-header") + protected List<XsdQNameType> soapHeader; + @XmlElement(name = "soap-role") + protected List<CString> soapRole; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + + /** + * Gets the value of the description property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the description property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getDescription().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link DescriptionType } + */ + public List<DescriptionType> getDescription() { + if (description == null) { + description = new ArrayList<>(); + } + return this.description; + } + + /** + * Gets the value of the displayName property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the displayName property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getDisplayName().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link DisplayNameType } + */ + public List<DisplayNameType> getDisplayName() { + if (displayName == null) { + displayName = new ArrayList<>(); + } + return this.displayName; + } + + /** + * Gets the value of the icon property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the icon property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getIcon().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link IconType } + */ + public List<IconType> getIcon() { + if (icon == null) { + icon = new ArrayList<>(); + } + return this.icon; + } + + /** + * Gets the value of the handlerName property. + * + * @return possible object is {@link CString } + */ + public CString getHandlerName() { + if (handlerName == null) { + handlerName = new CString(); + handlerName.setValue(""); + } + return handlerName; + } + + /** + * Sets the value of the handlerName property. + * + * @param value allowed object is {@link CString } + */ + public void setHandlerName(CString value) { + this.handlerName = value; + } + + /** + * Gets the value of the handlerClass property. + * + * @return possible object is {@link FullyQualifiedClassType } + */ + public FullyQualifiedClassType getHandlerClass() { + return handlerClass; + } + + /** + * Sets the value of the handlerClass property. + * + * @param value allowed object is {@link FullyQualifiedClassType } + */ + public void setHandlerClass(FullyQualifiedClassType value) { + this.handlerClass = value; + } + + /** + * Gets the value of the initParam property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the initParam property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getInitParam().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link ParamValueType } + */ + public List<ParamValueType> getInitParam() { + if (initParam == null) { + initParam = new ArrayList<>(); + } + return this.initParam; + } + + /** + * Gets the value of the soapHeader property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the soapHeader property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getSoapHeader().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link XsdQNameType } + */ + public List<XsdQNameType> getSoapHeader() { + if (soapHeader == null) { + soapHeader = new ArrayList<>(); + } + return this.soapHeader; + } + + /** + * Gets the value of the soapRole property. + * <p> + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification + * you make to the returned list will be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the soapRole property. + * <p> + * For example, to add a new item, do as follows: + * + * <pre> + * getSoapRole().add(newItem); + * </pre> + * <p> + * Objects of the following type(s) are allowed in the list {@link CString } + */ + public List<CString> getSoapRole() { + if (soapRole == null) { + soapRole = new ArrayList<>(); + } + return this.soapRole; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String value) { + this.id = value; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdQNameType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdQNameType.java new file mode 100644 index 0000000..e5270c6 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdQNameType.java @@ -0,0 +1,95 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + +/** + * This type adds an "id" attribute to xsd:QName. + * <p> + * Java class for xsdQNameType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="xsdQNameType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>QName"> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "xsdQNameType", propOrder = { "value" }) +public class XsdQNameType { + + @XmlValue + protected QName value; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + + /** + * Gets the value of the value property. + * + * @return possible object is {@link QName } + */ + public QName getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is {@link QName } + */ + public void setValue(QName value) { + this.value = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String v) { + this.id = v; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdStringType.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdStringType.java new file mode 100644 index 0000000..29571e7 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/XsdStringType.java @@ -0,0 +1,94 @@ +/** + * 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.jaxws.handler.jakartaee; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlID; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +/** + * This type adds an "id" attribute to xsd:string. + * <p> + * Java class for xsdStringType complex type. + * <p> + * The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="xsdStringType"> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "xsdStringType", propOrder = { "value" }) +public class XsdStringType { + + @XmlValue + protected java.lang.String value; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + protected java.lang.String id; + + /** + * Gets the value of the value property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setValue(java.lang.String value) { + this.value = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is {@link java.lang.String } + */ + public java.lang.String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is {@link java.lang.String } + */ + public void setId(java.lang.String v) { + this.id = v; + } + +} diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/package-info.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/package-info.java new file mode 100644 index 0000000..6ae4a55 --- /dev/null +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/jakartaee/package-info.java @@ -0,0 +1,24 @@ +/** + * 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. + */ + [email protected](namespace = "https://jakarta.ee/xml/ns/jakartaee", + elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED +) +package org.apache.cxf.jaxws.handler.jakartaee; + diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JakartaAnnotationHandlerChainBuilderTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JakartaAnnotationHandlerChainBuilderTest.java index f167343..832c449 100644 --- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JakartaAnnotationHandlerChainBuilderTest.java +++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JakartaAnnotationHandlerChainBuilderTest.java @@ -23,7 +23,11 @@ import java.util.List; import javax.jws.HandlerChain; import javax.jws.WebService; +import javax.xml.namespace.QName; import javax.xml.ws.handler.Handler; +import javax.xml.ws.handler.LogicalHandler; +import javax.xml.ws.handler.LogicalMessageContext; +import javax.xml.ws.handler.MessageContext; import org.junit.Before; import org.junit.Test; @@ -39,8 +43,8 @@ public class JakartaAnnotationHandlerChainBuilderTest { } @Test - public void testFindJakartaEmptyHandlerChainAnnotation() { - HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); + public void testFindHandlerChainAnnotation() { + JakartaHandlerTestImpl handlerTestImpl = new JakartaHandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); @SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder @@ -49,13 +53,92 @@ public class JakartaAnnotationHandlerChainBuilderTest { null, null); assertNotNull(handlers); - assertEquals(0, handlers.size()); + assertEquals(9, handlers.size()); + assertEquals(TestLogicalHandler.class, handlers.get(0).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(1).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(2).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(3).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(4).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(5).getClass()); + assertEquals(TestLogicalHandler.class, handlers.get(6).getClass()); + assertEquals(TestProtocolHandler.class, handlers.get(7).getClass()); + assertEquals(TestProtocolHandler.class, handlers.get(8).getClass()); + } + + @Test + public void testFindHandlerChainAnnotationPerPortServiceBinding() { + JakartaHandlerTestImpl handlerTestImpl = new JakartaHandlerTestImpl(); + AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); + QName portQName = new QName("namespacedoesntsupportyet", "SoapPort1"); + QName serviceQName = new QName("namespacedoesntsupportyet", "SoapService1"); + String bindingID = "http://schemas.xmlsoap.org/wsdl/soap/http"; + @SuppressWarnings("rawtypes") + List<Handler> handlers = chainBuilder + .buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID); + assertNotNull(handlers); + assertEquals(5, handlers.size()); + } + + @Test + public void testFindHandlerChainAnnotationPerPortServiceBindingNegative() { + JakartaHandlerTestImpl handlerTestImpl = new JakartaHandlerTestImpl(); + AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); + QName portQName = new QName("namespacedoesntsupportyet", "SoapPortUnknown"); + QName serviceQName = new QName("namespacedoesntsupportyet", "SoapServiceUnknown"); + String bindingID = "BindingUnknow"; + @SuppressWarnings("rawtypes") + List<Handler> handlers = chainBuilder + .buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID); + assertNotNull(handlers); + assertEquals(3, handlers.size()); + } + + @Test + public void testFindHandlerChainAnnotationPerPortServiceBindingWildcard() { + JakartaHandlerTestImpl handlerTestImpl = new JakartaHandlerTestImpl(); + AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); + QName portQName = new QName("http://apache.org/handler_test", "SoapPortWildcard"); + QName serviceQName = new QName("http://apache.org/handler_test", "SoapServiceWildcard"); + String bindingID = "BindingUnknow"; + @SuppressWarnings("rawtypes") + List<Handler> handlers = chainBuilder + .buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID); + assertNotNull(handlers); + assertEquals(7, handlers.size()); + } + + public static class TestLogicalHandler implements LogicalHandler<LogicalMessageContext> { + boolean initCalled; + + public void close(MessageContext arg0) { + } + + public boolean handleFault(LogicalMessageContext arg0) { + return false; + } + + public boolean handleMessage(LogicalMessageContext arg0) { + return false; + } + } + + public static class TestProtocolHandler implements Handler<MessageContext> { + + public void close(MessageContext arg0) { + } + + public boolean handleFault(MessageContext arg0) { + return false; + } + + public boolean handleMessage(MessageContext arg0) { + return false; + } } @WebService() @HandlerChain(file = "./jakarta-handlers.xml", name = "TestHandlerChain") - public class HandlerTestImpl { + public class JakartaHandlerTestImpl { } - } diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JavaxAnnotationHandlerChainBuilderTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JavaxAnnotationHandlerChainBuilderTest.java index deaf3eb..1ea6cbe 100644 --- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JavaxAnnotationHandlerChainBuilderTest.java +++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/JavaxAnnotationHandlerChainBuilderTest.java @@ -44,7 +44,7 @@ public class JavaxAnnotationHandlerChainBuilderTest { @Test public void testFindHandlerChainAnnotation() { - HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); + JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); @SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder @@ -67,7 +67,7 @@ public class JavaxAnnotationHandlerChainBuilderTest { @Test public void testFindHandlerChainAnnotationPerPortServiceBinding() { - HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); + JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); QName portQName = new QName("namespacedoesntsupportyet", "SoapPort1"); QName serviceQName = new QName("namespacedoesntsupportyet", "SoapService1"); @@ -81,7 +81,7 @@ public class JavaxAnnotationHandlerChainBuilderTest { @Test public void testFindHandlerChainAnnotationPerPortServiceBindingNegative() { - HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); + JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); QName portQName = new QName("namespacedoesntsupportyet", "SoapPortUnknown"); QName serviceQName = new QName("namespacedoesntsupportyet", "SoapServiceUnknown"); @@ -95,7 +95,7 @@ public class JavaxAnnotationHandlerChainBuilderTest { @Test public void testFindHandlerChainAnnotationPerPortServiceBindingWildcard() { - HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); + JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl(); AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder(); QName portQName = new QName("http://apache.org/handler_test", "SoapPortWildcard"); QName serviceQName = new QName("http://apache.org/handler_test", "SoapServiceWildcard"); @@ -138,8 +138,7 @@ public class JavaxAnnotationHandlerChainBuilderTest { @WebService() @HandlerChain(file = "./javax-handlers.xml", name = "TestHandlerChain") - public class HandlerTestImpl { + public class JavaxHandlerTestImpl { } - } diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/jakarta-handlers.xml b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/jakarta-handlers.xml index a31f8fe..f3e832e 100644 --- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/jakarta-handlers.xml +++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/jakarta-handlers.xml @@ -15,5 +15,95 @@ License. --> <handler-chains xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:cfg="http://cxf.apache.org/configuration/cfg" xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee"> - <handler-chain /> + <handler-chain> + <handler> + <handler-name>lh3</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestProtocolHandler + </handler-class> + <init-param> + <param-name>token</param-name> + <param-value>String</param-value> + </init-param> + </handler> + </handler-chain> + <handler-chain> + <handler> + <handler-name>lh1</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + <init-param> + <param-name>token</param-name> + <param-value>String</param-value> + </init-param> + </handler> + <handler> + <handler-name>lh2</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + <init-param> + <param-name>token</param-name> + <param-value>String</param-value> + </init-param> + </handler> + </handler-chain> + <handler-chain> + <port-name-pattern xmlns:ns1="http://apache.org/handler_test"> + ns1:Soap* + </port-name-pattern> + <handler> + <handler-name>Handler1</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + </handler> + <handler> + <handler-name>Handler2</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + </handler> + </handler-chain> + <handler-chain> + <service-name-pattern xmlns:ns1="http://apache.org/handler_test"> + ns1:Soap* + </service-name-pattern> + <handler> + <handler-name>Handler1</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + </handler> + <handler> + <handler-name>Handler2</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + </handler> + </handler-chain> + <!-- ====================== --> + <!-- protocol based handlers--> + <!-- ====================== --> + <handler-chain> + <!-- + REVISIT: valued used by TCK, do not understand... + <protocol-bindings>##SOAP11_HTTP</protocol-bindings> + --> + <protocol-bindings>http://schemas.xmlsoap.org/wsdl/soap/http + </protocol-bindings> + <handler> + <handler-name>Handler7</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> + </handler> + <handler> + <handler-name>Handler8</handler-name> + <handler-class> + org.apache.cxf.jaxws.handler.JakartaAnnotationHandlerChainBuilderTest$TestProtocolHandler + </handler-class> + </handler> + </handler-chain> </handler-chains> diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/javax-handlers.xml b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/javax-handlers.xml index 6327e06..3707856 100644 --- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/javax-handlers.xml +++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/javax-handlers.xml @@ -19,8 +19,8 @@ <handler> <handler-name>lh3</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestProtocolHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestProtocolHandler + </handler-class> <init-param> <param-name>token</param-name> <param-value>String</param-value> @@ -31,8 +31,8 @@ <handler> <handler-name>lh1</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> <init-param> <param-name>token</param-name> <param-value>String</param-value> @@ -41,8 +41,8 @@ <handler> <handler-name>lh2</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> <init-param> <param-name>token</param-name> <param-value>String</param-value> @@ -56,14 +56,14 @@ <handler> <handler-name>Handler1</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> </handler> <handler> <handler-name>Handler2</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> </handler> </handler-chain> <handler-chain> @@ -73,14 +73,14 @@ <handler> <handler-name>Handler1</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> </handler> <handler> <handler-name>Handler2</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> </handler> </handler-chain> <!-- ====================== --> @@ -96,14 +96,14 @@ <handler> <handler-name>Handler7</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestLogicalHandler + </handler-class> </handler> <handler> <handler-name>Handler8</handler-name> <handler-class> - org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestProtocolHandler - </handler-class> + org.apache.cxf.jaxws.handler.JavaxAnnotationHandlerChainBuilderTest$TestProtocolHandler + </handler-class> </handler> </handler-chain> </handler-chains>
