JBossWS SVN: r17859 - stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
by jbossws-commits@lists.jboss.org
Author: mmusaji
Date: 2013-08-07 07:49:37 -0400 (Wed, 07 Aug 2013)
New Revision: 17859
Added:
stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java
Log:
[JBPAPP-9534] Merged fix from JBWS-2669 to omplement missing endpoint metrics
Added: stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java (rev 0)
+++ stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/HttpServletResponseExt.java 2013-08-07 11:49:37 UTC (rev 17859)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A HttpServletResponse delegate that externalizes fields.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 17-Jul-2009
+ */
+public class HttpServletResponseExt implements HttpServletResponse
+{
+ private HttpServletResponse delegate;
+ private int sc;
+
+ public HttpServletResponseExt(HttpServletResponse delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ /**
+ * Get the status currently set in the HttpServletResponse
+ *
+ * @return the http status
+ */
+ public int getStatus()
+ {
+ return this.sc;
+ }
+
+ /* HttpServletResponse API */
+
+ public void addCookie(Cookie cookie)
+ {
+ delegate.addCookie(cookie);
+ }
+
+ public void addDateHeader(String name, long date)
+ {
+ delegate.addDateHeader(name, date);
+ }
+
+ public void addHeader(String name, String value)
+ {
+ delegate.addHeader(name, value);
+ }
+
+ public void addIntHeader(String name, int value)
+ {
+ delegate.addIntHeader(name, value);
+ }
+
+ public boolean containsHeader(String name)
+ {
+ return delegate.containsHeader(name);
+ }
+
+ public String encodeRedirectURL(String url)
+ {
+ return delegate.encodeRedirectURL(url);
+ }
+
+ @Deprecated
+ public String encodeRedirectUrl(String url)
+ {
+ return delegate.encodeRedirectUrl(url);
+ }
+
+ public String encodeURL(String url)
+ {
+ return delegate.encodeURL(url);
+ }
+
+ @Deprecated
+ public String encodeUrl(String url)
+ {
+ return delegate.encodeUrl(url);
+ }
+
+ public void sendError(int sc) throws IOException
+ {
+ delegate.sendError(sc);
+ }
+
+ public void sendError(int sc, String msg) throws IOException
+ {
+ delegate.sendError(sc, msg);
+ }
+
+ public void sendRedirect(String location) throws IOException
+ {
+ delegate.sendRedirect(location);
+ }
+
+ public void setDateHeader(String name, long date)
+ {
+ delegate.setDateHeader(name, date);
+ }
+
+ public void setHeader(String name, String value)
+ {
+ delegate.setHeader(name, value);
+ }
+
+ public void setIntHeader(String name, int value)
+ {
+ delegate.setIntHeader(name, value);
+ }
+
+ public void setStatus(int sc)
+ {
+ delegate.setStatus(sc);
+ this.sc = sc;
+ }
+
+ @Deprecated
+ public void setStatus(int sc, String sm)
+ {
+ delegate.setStatus(sc, sm);
+ this.sc = sc;
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ delegate.flushBuffer();
+ }
+
+ public int getBufferSize()
+ {
+ return delegate.getBufferSize();
+ }
+
+ public String getCharacterEncoding()
+ {
+ return delegate.getCharacterEncoding();
+ }
+
+ public String getContentType()
+ {
+ return delegate.getContentType();
+ }
+
+ public Locale getLocale()
+ {
+ return delegate.getLocale();
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ return delegate.getOutputStream();
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ return delegate.getWriter();
+ }
+
+ public boolean isCommitted()
+ {
+ return delegate.isCommitted();
+ }
+
+ public void reset()
+ {
+ delegate.reset();
+ }
+
+ public void resetBuffer()
+ {
+ delegate.resetBuffer();
+ }
+
+ public void setBufferSize(int size)
+ {
+ delegate.setBufferSize(size);
+ }
+
+ public void setCharacterEncoding(String charset)
+ {
+ delegate.setCharacterEncoding(charset);
+ }
+
+ public void setContentLength(int len)
+ {
+ delegate.setContentLength(len);
+ }
+
+ public void setContentType(String type)
+ {
+ delegate.setContentType(type);
+ }
+
+ public void setLocale(Locale loc)
+ {
+ delegate.setLocale(loc);
+ }
+
+}
11 years, 4 months
JBossWS SVN: r17858 - stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf.
by jbossws-commits@lists.jboss.org
Author: mmusaji
Date: 2013-08-07 07:49:10 -0400 (Wed, 07 Aug 2013)
New Revision: 17858
Modified:
stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
Log:
[JBPAPP-9534] Merged fix from JBWS-2669 to omplement missing endpoint metrics
Modified: stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2013-08-06 21:38:31 UTC (rev 17857)
+++ stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2013-08-07 11:49:10 UTC (rev 17858)
@@ -54,11 +54,11 @@
public void handleHttpRequest(Endpoint ep, HttpServletRequest req, HttpServletResponse res, ServletContext context) throws ServletException, IOException
{
- ServletController controller = (ServletController)context.getAttribute(ServletController.class.getName());
+ ServletControllerExt controller = (ServletControllerExt)context.getAttribute(ServletController.class.getName());
if (controller == null)
throw new IllegalStateException("Cannot obtain servlet controller");
- controller.invoke(req, res);
+ controller.invoke(req, res, ep);
}
public void handleRequest(Endpoint endpoint, InputStream inStream, OutputStream outStream, InvocationContext context)
Modified: stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java
===================================================================
--- stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2013-08-06 21:38:31 UTC (rev 17857)
+++ stack/cxf/branches/jbossws-cxf-3.1.2.SP7_JBPAPP-9534/modules/server/src/main/java/org/jboss/wsf/stack/cxf/ServletControllerExt.java 2013-08-07 11:49:10 UTC (rev 17858)
@@ -163,14 +163,50 @@
return false;
}
- public void invoke(HttpServletRequest req, HttpServletResponse res) throws ServletException
+ public void invoke(HttpServletRequest req, HttpServletResponse res, Endpoint ep) throws ServletException
{
ServletDestination dest = findDestination(req);
boolean requestHandled = handleQuery(req, res, dest);
if (false == requestHandled)
{
- invokeDestination(req, res, dest);
+ Long beginTime = initRequestMetrics(ep);
+ HttpServletResponseExt response = new HttpServletResponseExt(res);
+ invokeDestination(req, response, dest);
+ if (response.getStatus() < 500)
+ {
+ processResponseMetrics(ep, beginTime);
+ }
+ else
+ {
+ processFaultMetrics(ep, beginTime);
+ }
}
}
+
+ private long initRequestMetrics(Endpoint endpoint)
+ {
+ long beginTime = 0;
+
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ beginTime = metrics.processRequestMessage();
+
+ return beginTime;
+ }
+
+ private void processResponseMetrics(Endpoint endpoint, long beginTime)
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ metrics.processResponseMessage(beginTime);
+ }
+
+ private void processFaultMetrics(Endpoint endpoint, long beginTime)
+ {
+ EndpointMetrics metrics = endpoint.getEndpointMetrics();
+ if (metrics != null)
+ metrics.processFaultMessage(beginTime);
+ }
+
}
11 years, 4 months
JBossWS SVN: r17857 - thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/rt/core/src/main/java/org/apache/cxf/databinding/source.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-06 17:38:31 -0400 (Tue, 06 Aug 2013)
New Revision: 17857
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
Log:
[JBPAPP-10838] SourceDataBinding doesn't create a thread safe DataReader
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java 2013-08-06 21:05:08 UTC (rev 17856)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java 2013-08-06 21:38:31 UTC (rev 17857)
@@ -35,18 +35,8 @@
public static final String PREFERRED_FORMAT = "source-preferred-format";
- private XMLStreamDataReader xsrReader;
- private XMLStreamDataWriter xswWriter;
- private NodeDataWriter nodeWriter;
- private NodeDataReader nodeReader;
-
public SourceDataBinding() {
super();
- this.xsrReader = new XMLStreamDataReader();
- this.xswWriter = new XMLStreamDataWriter();
-
- this.nodeReader = new NodeDataReader();
- this.nodeWriter = new NodeDataWriter();
}
public void initialize(Service service) {
@@ -57,9 +47,9 @@
@SuppressWarnings("unchecked")
public <T> DataReader<T> createReader(Class<T> cls) {
if (cls == XMLStreamReader.class) {
- return (DataReader<T>) xsrReader;
+ return (DataReader<T>) new XMLStreamDataReader();
} else if (cls == Node.class) {
- return (DataReader<T>) nodeReader;
+ return (DataReader<T>) new NodeDataReader();
} else {
throw new UnsupportedOperationException("The type " + cls.getName() + " is not supported.");
}
@@ -72,9 +62,9 @@
@SuppressWarnings("unchecked")
public <T> DataWriter<T> createWriter(Class<T> cls) {
if (cls == XMLStreamWriter.class) {
- return (DataWriter<T>) xswWriter;
+ return (DataWriter<T>) new XMLStreamDataWriter();
} else if (cls == Node.class) {
- return (DataWriter<T>) nodeWriter;
+ return (DataWriter<T>) new NodeDataWriter();
} else {
throw new UnsupportedOperationException("The type " + cls.getName() + " is not supported.");
}
11 years, 4 months
JBossWS SVN: r17856 - thirdparty/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-06 17:05:08 -0400 (Tue, 06 Aug 2013)
New Revision: 17856
Added:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10838/
Log:
[JBPAPP-10838] creating one-off branch
11 years, 4 months
JBossWS SVN: r17855 - thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/databinding/source.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-06 16:59:13 -0400 (Tue, 06 Aug 2013)
New Revision: 17855
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
Log:
[JBPAPP-10819] SourceDataBinding doesn't create a thread safe DataReader
Modified: thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java 2013-08-03 02:37:23 UTC (rev 17854)
+++ thirdparty/cxf/branches/cxf-2.2.12/rt/core/src/main/java/org/apache/cxf/databinding/source/SourceDataBinding.java 2013-08-06 20:59:13 UTC (rev 17855)
@@ -35,18 +35,8 @@
public static final String PREFERRED_FORMAT = "source-preferred-format";
- private XMLStreamDataReader xsrReader;
- private XMLStreamDataWriter xswWriter;
- private NodeDataWriter nodeWriter;
- private NodeDataReader nodeReader;
-
public SourceDataBinding() {
super();
- this.xsrReader = new XMLStreamDataReader();
- this.xswWriter = new XMLStreamDataWriter();
-
- this.nodeReader = new NodeDataReader();
- this.nodeWriter = new NodeDataWriter();
}
public void initialize(Service service) {
@@ -57,9 +47,9 @@
@SuppressWarnings("unchecked")
public <T> DataReader<T> createReader(Class<T> cls) {
if (cls == XMLStreamReader.class) {
- return (DataReader<T>) xsrReader;
+ return (DataReader<T>) new XMLStreamDataReader();
} else if (cls == Node.class) {
- return (DataReader<T>) nodeReader;
+ return (DataReader<T>) new NodeDataReader();
} else {
throw new UnsupportedOperationException("The type " + cls.getName() + " is not supported.");
}
@@ -72,9 +62,9 @@
@SuppressWarnings("unchecked")
public <T> DataWriter<T> createWriter(Class<T> cls) {
if (cls == XMLStreamWriter.class) {
- return (DataWriter<T>) xswWriter;
+ return (DataWriter<T>) new XMLStreamDataWriter();
} else if (cls == Node.class) {
- return (DataWriter<T>) nodeWriter;
+ return (DataWriter<T>) new NodeDataWriter();
} else {
throw new UnsupportedOperationException("The type " + cls.getName() + " is not supported.");
}
11 years, 4 months
JBossWS SVN: r17854 - in thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-02 22:37:23 -0400 (Fri, 02 Aug 2013)
New Revision: 17854
Added:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Log:
[JBPAPP-10835] Support marshalling exception classes with @XmlAccessorOrder in JAXBEncoderDecoder
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java 2013-08-03 00:37:24 UTC (rev 17853)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java 2013-08-03 02:37:23 UTC (rev 17854)
@@ -361,6 +361,9 @@
}
return false;
}
+ public static void writeTo(Node node, OutputStream os) throws XMLStreamException {
+ copy(new DOMSource(node), os);
+ }
public static void copy(Source source, OutputStream os) throws XMLStreamException {
XMLStreamWriter writer = createXMLStreamWriter(os);
try {
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java 2013-08-03 00:37:24 UTC (rev 17853)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java 2013-08-03 02:37:23 UTC (rev 17854)
@@ -26,6 +26,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
@@ -34,6 +35,8 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
@@ -47,7 +50,9 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessOrder;
import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
@@ -346,10 +351,31 @@
} else {
LOG.warning("Schema associated with " + namespace + " is null");
}
-
+
+ List<Member> combinedMembers = new ArrayList<Member>();
+
for (Field f : Utils.getFields(cls, accessType)) {
XmlAttribute at = f.getAnnotation(XmlAttribute.class);
if (at == null) {
+ combinedMembers.add(f);
+ }
+ }
+ for (Method m : Utils.getGetters(cls, accessType)) {
+ combinedMembers.add(m);
+ }
+
+ XmlAccessorOrder xmlAccessorOrder = cls.getAnnotation(XmlAccessorOrder.class);
+ if (xmlAccessorOrder != null && xmlAccessorOrder.value().equals(XmlAccessOrder.ALPHABETICAL)) {
+ Collections.sort(combinedMembers, new Comparator<Member>() {
+ public int compare(Member m1, Member m2) {
+ return m1.getName().compareTo(m2.getName());
+ }
+ });
+ }
+
+ for (Member member : combinedMembers) {
+ if (member instanceof Field) {
+ Field f = (Field)member;
QName fname = new QName(namespace, f.getName());
f.setAccessible(true);
if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
@@ -358,20 +384,20 @@
Object o = Utils.getFieldValue(f, elValue);
writeObject(marshaller, writer, new JAXBElement(fname, String.class, o));
}
+ } else { // it's a Method
+ Method m = (Method)member;
+ int idx = m.getName().startsWith("get") ? 3 : 2;
+ String name = m.getName().substring(idx);
+ name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
+ QName mname = new QName(namespace, name);
+ if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
+ writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
+ } else {
+ Object o = Utils.getMethodValue(m, elValue);
+ writeObject(marshaller, writer, new JAXBElement(mname, String.class, o));
+ }
}
}
- for (Method m : Utils.getGetters(cls, accessType)) {
- int idx = m.getName().startsWith("get") ? 3 : 2;
- String name = m.getName().substring(idx);
- name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
- QName mname = new QName(namespace, name);
- if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
- writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
- } else {
- Object o = Utils.getMethodValue(m, elValue);
- writeObject(marshaller, writer, new JAXBElement(mname, String.class, o));
- }
- }
writer.writeEndElement();
writer.flush();
} catch (Exception e) {
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java 2013-08-03 00:37:24 UTC (rev 17853)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java 2013-08-03 02:37:23 UTC (rev 17854)
@@ -53,8 +53,13 @@
import org.apache.cxf.jaxb_form.ObjectWithQualifiedElementElement;
import org.apache.cxf.jaxb_misc.Base64WithDefaultValueType;
import org.apache.cxf.jaxb_misc.ObjectFactory;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessageInfo;
import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.staxutils.StaxStreamFilter;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.testutil.common.TestUtil;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.types.GreetMe;
@@ -389,6 +394,47 @@
}
@Test
+ public void testMarshallExceptionWithOrder() throws Exception {
+ Document doc = DOMUtils.createDocument();
+ Element elNode = doc.createElementNS("http://cxf.apache.org", "ExceptionRoot");
+
+ OrderException exception = new OrderException("Mymessage");
+ exception.setAValue("avalue");
+ exception.setDetail("detail");
+ exception.setInfo1("info1");
+ exception.setInfo2("info2");
+ exception.setIntVal(10000);
+
+ QName elName = new QName("http://cxf.apache.org", "OrderException");
+ ServiceInfo serviceInfo = new ServiceInfo();
+ InterfaceInfo interfaceInfo = new InterfaceInfo(serviceInfo, null);
+ OperationInfo op = interfaceInfo.addOperation(new QName("http://cxf.apache.org", "operation"));
+ MessageInfo message = new MessageInfo(op, null, null);
+ MessagePartInfo part = new MessagePartInfo(elName, message);
+ part.setElement(true);
+ part.setElementQName(elName);
+ part.setTypeClass(OrderException.class);
+
+ //just need a simple generic context to handle the exceptions internal primitives
+ JAXBContext exceptionContext = JAXBContext.newInstance(new Class[] {
+ String.class,
+ });
+ JAXBEncoderDecoder.marshallException(exceptionContext.createMarshaller(), exception, part, elNode);
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ StaxUtils.writeTo(elNode, bout);
+ int a = bout.toString().lastIndexOf("aValue");
+ int b = bout.toString().lastIndexOf("detail");
+ int c = bout.toString().lastIndexOf("info1");
+ int d = bout.toString().lastIndexOf("info2");
+ int e = bout.toString().lastIndexOf("intVal");
+ assertTrue(a < b);
+ assertTrue(b < c);
+ assertTrue(c < d);
+ assertTrue(d < e);
+ }
+
+ @Test
public void testMarshallWithoutQNameInfo() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
Added: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java (rev 0)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java 2013-08-03 02:37:23 UTC (rev 17854)
@@ -0,0 +1,84 @@
+/**
+ * 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.jaxb;
+
+import javax.xml.bind.annotation.XmlAccessOrder;
+import javax.xml.bind.annotation.XmlAccessorOrder;
+
+(a)XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
+public class OrderException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private String info1;
+
+ private String info2;
+
+ private String aValue;
+
+ private int intVal;
+
+ private String detail;
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+
+ public String getAValue() {
+ return aValue;
+ }
+
+ public void setAValue(String value) {
+ this.aValue = value;
+ }
+
+ public String getInfo1() {
+ return info1;
+ }
+
+ public void setInfo1(String info1) {
+ this.info1 = info1;
+ }
+
+ public String getInfo2() {
+ return info2;
+ }
+
+ public void setInfo2(String info2) {
+ this.info2 = info2;
+ }
+
+
+ public int getIntVal() {
+ return intVal;
+ }
+
+ public void setIntVal(int intVal) {
+ this.intVal = intVal;
+ }
+
+ public String getDetail() {
+ return detail;
+ }
+
+ public void setDetail(String detail) {
+ this.detail = detail;
+ }
+
+}
11 years, 4 months
JBossWS SVN: r17853 - thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-02 20:37:24 -0400 (Fri, 02 Aug 2013)
New Revision: 17853
Modified:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
Log:
Fixing checkstyle errors
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java 2013-08-03 00:09:58 UTC (rev 17852)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java 2013-08-03 00:37:24 UTC (rev 17853)
@@ -583,8 +583,8 @@
//we want to return the right type for collections so if we get null
//from the return type we check if it's ParameterizedType and get the
//generic return type.
- if((type==null) && (m.getGenericReturnType() instanceof ParameterizedType)) {
- type = m.getGenericReturnType();
+ if ((type == null) && (m.getGenericReturnType() instanceof ParameterizedType)) {
+ type = m.getGenericReturnType();
}
JAXBBeanInfo beanInfo = getBeanInfo(type);
if (beanInfo != null) {
Modified: thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java 2013-08-03 00:09:58 UTC (rev 17852)
+++ thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java 2013-08-03 00:37:24 UTC (rev 17853)
@@ -209,17 +209,15 @@
}
static Class<?> getMethodReturnType(Method m) {
- XmlJavaTypeAdapter adapter = getMethodXJTA(m);
- //if there is no adapter, yet we have a collection make sure
- //we return the Generic type; if there is an annotation let the
- //adapter handle what gets populated
- if(adapter==null) {
- if(m.getGenericReturnType() instanceof ParameterizedType) {
- return null;
- }
- }
- Class<?> adapterType = getTypeFromXmlAdapter(adapter);
- return adapterType != null ? adapterType : m.getReturnType();
+ XmlJavaTypeAdapter adapter = getMethodXJTA(m);
+ //if there is no adapter, yet we have a collection make sure
+ //we return the Generic type; if there is an annotation let the
+ //adapter handle what gets populated
+ if (adapter == null && m.getGenericReturnType() instanceof ParameterizedType) {
+ return null;
+ }
+ Class<?> adapterType = getTypeFromXmlAdapter(adapter);
+ return adapterType != null ? adapterType : m.getReturnType();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
11 years, 4 months
JBossWS SVN: r17852 - thirdparty/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-02 20:09:58 -0400 (Fri, 02 Aug 2013)
New Revision: 17852
Added:
thirdparty/cxf/branches/cxf-2.2.12-patch-04_JBPAPP-10835/
Log:
[JBPAPP-10835] Creating one off branch from r17847 of JBPAPP-10657 one off branch
11 years, 4 months
JBossWS SVN: r17851 - in thirdparty/cxf/branches/cxf-2.2.12: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2013-08-02 19:57:58 -0400 (Fri, 02 Aug 2013)
New Revision: 17851
Added:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java
Modified:
thirdparty/cxf/branches/cxf-2.2.12/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Log:
[JBPAPP-10834] Support marshalling exception classes with @XmlAccessorOrder in JAXBEncoderDecoder
Modified: thirdparty/cxf/branches/cxf-2.2.12/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java 2013-08-02 00:34:53 UTC (rev 17850)
+++ thirdparty/cxf/branches/cxf-2.2.12/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java 2013-08-02 23:57:58 UTC (rev 17851)
@@ -361,6 +361,9 @@
}
return false;
}
+ public static void writeTo(Node node, OutputStream os) throws XMLStreamException {
+ copy(new DOMSource(node), os);
+ }
public static void copy(Source source, OutputStream os) throws XMLStreamException {
XMLStreamWriter writer = createXMLStreamWriter(os);
try {
Modified: thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java 2013-08-02 00:34:53 UTC (rev 17850)
+++ thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java 2013-08-02 23:57:58 UTC (rev 17851)
@@ -26,6 +26,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
@@ -34,6 +35,8 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
@@ -47,7 +50,9 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessOrder;
import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
@@ -346,10 +351,31 @@
} else {
LOG.warning("Schema associated with " + namespace + " is null");
}
-
+
+ List<Member> combinedMembers = new ArrayList<Member>();
+
for (Field f : Utils.getFields(cls, accessType)) {
XmlAttribute at = f.getAnnotation(XmlAttribute.class);
if (at == null) {
+ combinedMembers.add(f);
+ }
+ }
+ for (Method m : Utils.getGetters(cls, accessType)) {
+ combinedMembers.add(m);
+ }
+
+ XmlAccessorOrder xmlAccessorOrder = cls.getAnnotation(XmlAccessorOrder.class);
+ if (xmlAccessorOrder != null && xmlAccessorOrder.value().equals(XmlAccessOrder.ALPHABETICAL)) {
+ Collections.sort(combinedMembers, new Comparator<Member>() {
+ public int compare(Member m1, Member m2) {
+ return m1.getName().compareTo(m2.getName());
+ }
+ });
+ }
+
+ for (Member member : combinedMembers) {
+ if (member instanceof Field) {
+ Field f = (Field)member;
QName fname = new QName(namespace, f.getName());
f.setAccessible(true);
if (JAXBSchemaInitializer.isArray(f.getGenericType())) {
@@ -358,20 +384,20 @@
Object o = Utils.getFieldValue(f, elValue);
writeObject(marshaller, writer, new JAXBElement(fname, String.class, o));
}
+ } else { // it's a Method
+ Method m = (Method)member;
+ int idx = m.getName().startsWith("get") ? 3 : 2;
+ String name = m.getName().substring(idx);
+ name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
+ QName mname = new QName(namespace, name);
+ if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
+ writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
+ } else {
+ Object o = Utils.getMethodValue(m, elValue);
+ writeObject(marshaller, writer, new JAXBElement(mname, String.class, o));
+ }
}
}
- for (Method m : Utils.getGetters(cls, accessType)) {
- int idx = m.getName().startsWith("get") ? 3 : 2;
- String name = m.getName().substring(idx);
- name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
- QName mname = new QName(namespace, name);
- if (JAXBSchemaInitializer.isArray(m.getGenericReturnType())) {
- writeArrayObject(marshaller, writer, mname, m.invoke(elValue));
- } else {
- Object o = Utils.getMethodValue(m, elValue);
- writeObject(marshaller, writer, new JAXBElement(mname, String.class, o));
- }
- }
writer.writeEndElement();
writer.flush();
} catch (Exception e) {
Modified: thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java 2013-08-02 00:34:53 UTC (rev 17850)
+++ thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java 2013-08-02 23:57:58 UTC (rev 17851)
@@ -53,8 +53,13 @@
import org.apache.cxf.jaxb_form.ObjectWithQualifiedElementElement;
import org.apache.cxf.jaxb_misc.Base64WithDefaultValueType;
import org.apache.cxf.jaxb_misc.ObjectFactory;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.MessageInfo;
import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.staxutils.StaxStreamFilter;
+import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.testutil.common.TestUtil;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.types.GreetMe;
@@ -389,6 +394,47 @@
}
@Test
+ public void testMarshallExceptionWithOrder() throws Exception {
+ Document doc = DOMUtils.createDocument();
+ Element elNode = doc.createElementNS("http://cxf.apache.org", "ExceptionRoot");
+
+ OrderException exception = new OrderException("Mymessage");
+ exception.setAValue("avalue");
+ exception.setDetail("detail");
+ exception.setInfo1("info1");
+ exception.setInfo2("info2");
+ exception.setIntVal(10000);
+
+ QName elName = new QName("http://cxf.apache.org", "OrderException");
+ ServiceInfo serviceInfo = new ServiceInfo();
+ InterfaceInfo interfaceInfo = new InterfaceInfo(serviceInfo, null);
+ OperationInfo op = interfaceInfo.addOperation(new QName("http://cxf.apache.org", "operation"));
+ MessageInfo message = new MessageInfo(op, null, null);
+ MessagePartInfo part = new MessagePartInfo(elName, message);
+ part.setElement(true);
+ part.setElementQName(elName);
+ part.setTypeClass(OrderException.class);
+
+ //just need a simple generic context to handle the exceptions internal primitives
+ JAXBContext exceptionContext = JAXBContext.newInstance(new Class[] {
+ String.class,
+ });
+ JAXBEncoderDecoder.marshallException(exceptionContext.createMarshaller(), exception, part, elNode);
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ StaxUtils.writeTo(elNode, bout);
+ int a = bout.toString().lastIndexOf("aValue");
+ int b = bout.toString().lastIndexOf("detail");
+ int c = bout.toString().lastIndexOf("info1");
+ int d = bout.toString().lastIndexOf("info2");
+ int e = bout.toString().lastIndexOf("intVal");
+ assertTrue(a < b);
+ assertTrue(b < c);
+ assertTrue(c < d);
+ assertTrue(d < e);
+ }
+
+ @Test
public void testMarshallWithoutQNameInfo() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
Added: thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java (rev 0)
+++ thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/OrderException.java 2013-08-02 23:57:58 UTC (rev 17851)
@@ -0,0 +1,84 @@
+/**
+ * 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.jaxb;
+
+import javax.xml.bind.annotation.XmlAccessOrder;
+import javax.xml.bind.annotation.XmlAccessorOrder;
+
+(a)XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
+public class OrderException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private String info1;
+
+ private String info2;
+
+ private String aValue;
+
+ private int intVal;
+
+ private String detail;
+
+ public OrderException(String message) {
+ super(message);
+ }
+
+
+ public String getAValue() {
+ return aValue;
+ }
+
+ public void setAValue(String value) {
+ this.aValue = value;
+ }
+
+ public String getInfo1() {
+ return info1;
+ }
+
+ public void setInfo1(String info1) {
+ this.info1 = info1;
+ }
+
+ public String getInfo2() {
+ return info2;
+ }
+
+ public void setInfo2(String info2) {
+ this.info2 = info2;
+ }
+
+
+ public int getIntVal() {
+ return intVal;
+ }
+
+ public void setIntVal(int intVal) {
+ this.intVal = intVal;
+ }
+
+ public String getDetail() {
+ return detail;
+ }
+
+ public void setDetail(String detail) {
+ this.detail = detail;
+ }
+
+}
11 years, 4 months