[jboss-jira] [JBoss JIRA] (WFLY-6057) JAXB bindings of XmlJavaTypeAdapter are ignored
Alessio Soldano (JIRA)
issues at jboss.org
Mon Mar 7 03:09:00 EST 2016
[ https://issues.jboss.org/browse/WFLY-6057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13172556#comment-13172556 ]
Alessio Soldano commented on WFLY-6057:
---------------------------------------
George,
in the "Steps to reproduce", I'm guessing you're referring to the discussion we had in Jun/Jul 2015 ( https://developer.jboss.org/thread/260559 ), which ended up with me not being able to reproduce your issue after having tried 2 times to work on a "reproducer" you provided which could not even be built initially.
Can you provide something I can actually try to isolate the problem, if any, and fix it?
Jeremy, same reasoning as above, can you provide a reproducer and/or exact steps to reproduce your issue (which might possibly be even a slightly different one) ?
Thanks
> JAXB bindings of XmlJavaTypeAdapter are ignored
> -----------------------------------------------
>
> Key: WFLY-6057
> URL: https://issues.jboss.org/browse/WFLY-6057
> Project: WildFly
> Issue Type: Bug
> Components: Web Services
> Affects Versions: 10.0.0.CR5
> Reporter: George Turner
> Assignee: Alessio Soldano
>
> I filed this problem in WF8, and I still cannot get it to work in WF10
> Every xsd:date field prints as a xs:dateTime, and ignores by custom bindings.
> Here is my setup:
> binding.xjb
> <?xml version="1.0" encoding="UTF-8"?>
> <bindings xmlns="http://java.sun.com/xml/ns/jaxb"
> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> extensionBindingPrefixes="xjc" version="2.1">
> <globalBindings
> choiceContentProperty="true" generateIsSetMethod="true" typesafeEnumMaxMembers="2000">
> <xjc:javaType name="java.util.Date" xmlType="xs:date"
> adapter="com.lmco.spacefence.infrastructure.webservices.util.XmlDateAdapter"/>
> <xjc:serializable/>
> </globalBindings>
> </bindings>
> package-info.java
> @XmlJavaTypeAdapters({
> @XmlJavaTypeAdapter(value = XmlDateAdapter.class, type = java.util.Date.class),
> @XmlJavaTypeAdapter(value = XmlDatetimeAdapter.class, type = java.util.Calendar.class)
> })
> package com.lmco.spacefence.infrastructure.webservices.util;
> import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
> import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
> XmlDateAdapter.java
> package com.lmco.spacefence.infrastructure.webservices.util;
> import java.text.SimpleDateFormat;
> import java.util.Date;
> import javax.xml.bind.annotation.adapters.XmlAdapter;
> /**
> * Class is used to marshal/unmarshal String/Date in XML.
> */
> public class XmlDateAdapter extends XmlAdapter<String, Date> {
> /**
> * Parses a Date value from the String.
> *
> * @param value to unmarshal
> * @return the parsed Date
> */
> @Override
> public Date unmarshal(String value) throws Exception {
> if (value == null) {
> return null;
> }
> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
> return sdf.parse(value);
> }
> /**
> * Prints the Date value as a String.
> *
> * @param value to marshal
> * @return the String of the Date
> */
> @Override
> public String marshal(Date value) throws Exception {
> if (value == null) {
> return null;
> }
> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
> return sdf.format(value);
> }
> }
> Field in generated source class from cxf-codegen-plugin using binding.xjb
> @XmlJavaTypeAdapter(XmlDateAdapter.class)
> protected Date createDate;
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list