You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/12/28 12:45:00 UTC

[isis] branch v2 updated (fef99b8 -> 4a11018)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from fef99b8  ISIS-2050: fixes unit tests
     add 9cfacbd  ISIS-2057: checks if annotated
     add 45ded3b  ISIS-2050: ignoring broken tests.
     add b5bb224  ISIS-2051: adds troubleshooting hint for ugvro
     new 4a11018  Merge branch 'master' into v2

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../guides/ugvro/_ugvro_hints-and-tips.adoc        |  1 +
 .../_ugvro_hints-and-tips_troubleshooting.adoc     | 89 ++++++++++++++++++++++
 .../applib/services/jaxb/JaxbServiceDefault.java   |  7 +-
 3 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 adocs/documentation/src/main/asciidoc/guides/ugvro/_ugvro_hints-and-tips_troubleshooting.adoc


[isis] 01/01: Merge branch 'master' into v2

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 4a11018370c9db52463e6d675f78b3f7d5d595a4
Merge: fef99b8 b5bb224
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Dec 28 12:38:11 2018 +0000

    Merge branch 'master' into v2

 .../guides/ugvro/_ugvro_hints-and-tips.adoc        |  1 +
 .../_ugvro_hints-and-tips_troubleshooting.adoc     | 89 ++++++++++++++++++++++
 .../applib/services/jaxb/JaxbServiceDefault.java   |  7 +-
 3 files changed, 96 insertions(+), 1 deletion(-)

diff --cc core/applib/src/main/java/org/apache/isis/applib/services/jaxb/JaxbServiceDefault.java
index dda4091,0000000..c4ca34e
mode 100644,000000..100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/jaxb/JaxbServiceDefault.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/jaxb/JaxbServiceDefault.java
@@@ -1,102 -1,0 +1,107 @@@
 +/**
 + *  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.isis.applib.services.jaxb;
 +
 +import java.util.Map;
 +
 +import javax.xml.bind.JAXBContext;
 +import javax.xml.bind.JAXBException;
 +import javax.xml.bind.Marshaller;
 +import javax.xml.bind.Unmarshaller;
++import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 +
 +import org.apache.isis.applib.NonRecoverableException;
 +import org.apache.isis.applib.annotation.DomainService;
 +import org.apache.isis.applib.annotation.NatureOfService;
 +import org.apache.isis.applib.domain.DomainObjectList;
 +import org.apache.isis.applib.services.metamodel.MetaModelService;
 +import org.apache.isis.applib.services.registry.ServiceRegistry;
 +import org.apache.isis.schema.utils.jaxbadapters.PersistentEntitiesAdapter;
 +import org.apache.isis.schema.utils.jaxbadapters.PersistentEntityAdapter;
 +
 +@DomainService(
 +        nature = NatureOfService.DOMAIN,
 +        menuOrder = "" + Integer.MAX_VALUE
 +        )
 +public class JaxbServiceDefault extends JaxbService.Simple {
 +
 +    @Override
 +    public Object fromXml(final JAXBContext jaxbContext, final String xml, final Map<String, Object> unmarshallerProperties) {
 +        try {
 +            Object pojo = internalFromXml(jaxbContext, xml, unmarshallerProperties);
 +
 +            if(pojo instanceof DomainObjectList) {
 +
 +                // go around the loop again, so can properly deserialize the contents
 +                DomainObjectList list = (DomainObjectList) pojo;
 +                JAXBContext jaxbContextForList = jaxbContextFor(list);
 +
 +                return internalFromXml(jaxbContextForList, xml, unmarshallerProperties);
 +            }
 +
 +            return pojo;
 +
 +        } catch (final JAXBException ex) {
 +            throw new NonRecoverableException("Error unmarshalling XML", ex);
 +        }
 +    }
 +
 +    @Override
 +    protected JAXBContext jaxbContextFor(final Object domainObject) {
 +        final Class<?> domainClass = domainObject.getClass();
 +        if(domainObject instanceof DomainObjectList) {
 +            DomainObjectList list = (DomainObjectList) domainObject;
 +            try {
 +                final String elementObjectType = list.getElementObjectType();
 +                final Class<?> elementType = metaModelService5.fromObjectType(elementObjectType);
-                 return JAXBContext.newInstance(domainClass, elementType);
++                if (elementType.getAnnotation(XmlJavaTypeAdapter.class) == null) {
++                    return JAXBContext.newInstance(domainClass, elementType);
++                } else {
++                    return JAXBContext.newInstance(domainClass);
++                }
 +            } catch (JAXBException e) {
 +                throw new RuntimeException(e);
 +            }
 +        }
 +        return super.jaxbContextFor(domainObject);
 +    }
 +
 +
 +    @Override
 +    protected void configure(final Unmarshaller unmarshaller) {
 +        unmarshaller.setAdapter(PersistentEntityAdapter.class,
 +                serviceRegistry.injectServicesInto(new PersistentEntityAdapter()));
 +        unmarshaller.setAdapter(PersistentEntitiesAdapter.class,
 +                serviceRegistry.injectServicesInto(new PersistentEntitiesAdapter()));
 +    }
 +
 +    @Override
 +    protected void configure(final Marshaller marshaller) {
 +        marshaller.setAdapter(PersistentEntityAdapter.class,
 +                serviceRegistry.injectServicesInto(new PersistentEntityAdapter()));
 +        marshaller.setAdapter(PersistentEntitiesAdapter.class,
 +                serviceRegistry.injectServicesInto(new PersistentEntitiesAdapter()));
 +    }
 +
 +
 +    @javax.inject.Inject
 +    ServiceRegistry serviceRegistry;
 +
 +    @javax.inject.Inject
 +    MetaModelService metaModelService5;
 +}
 +