com.sun.xml.internal.bind.v2.ContextFactory Java Examples

The following examples show how to use com.sun.xml.internal.bind.v2.ContextFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXBRIContextFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #2
Source File: JAXBRIContextFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #3
Source File: JAXBRIContextFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #4
Source File: JAXBRIContextFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #5
Source File: JAXBRIContextFactory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #6
Source File: JAXBRIContextFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #7
Source File: JAXBRIContextFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #8
Source File: JAXBRIContextFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BindingContext newContext(BindingInfo bi) {
    Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
    for (int i = 0; i < classes.length; i++) {
        if (WrapperComposite.class.equals(classes[i])) {
            classes[i] = CompositeStructure.class;
        }
    }
    Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
    Map<Class, Class> subclassReplacements = bi.subclassReplacements();
    String defaultNamespaceRemap = bi.getDefaultNamespace();
    Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
    RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
    JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
    try {
        JAXBRIContext context = (jaxbContextFactory != null)
                ? jaxbContextFactory.createJAXBContext(
                bi.getSEIModel(),
                toList(classes),
                toList(typeInfoMappings.values()))
                : ContextFactory.createContext(
                classes, typeInfoMappings.values(),
                subclassReplacements, defaultNamespaceRemap,
                (c14nSupport != null) ? c14nSupport : false,
                ar, false, false, false);
        return new JAXBRIContextWrapper(context, typeInfoMappings);
    } catch (Exception e) {
        throw new DatabindingException(e);
    }
}
 
Example #9
Source File: RegistryInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #10
Source File: JAXBRIContext.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #11
Source File: RegistryInfoImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #12
Source File: JAXBRIContext.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #13
Source File: RegistryInfoImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #14
Source File: JAXBRIContext.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #15
Source File: RegistryInfoImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #16
Source File: JAXBRIContext.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #17
Source File: RegistryInfoImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #18
Source File: JAXBRIContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #19
Source File: RegistryInfoImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #20
Source File: JAXBRIContext.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #21
Source File: RegistryInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #22
Source File: JAXBRIContext.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}
 
Example #23
Source File: RegistryInfoImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Picks up references in this registry to other types.
 */
RegistryInfoImpl(ModelBuilder<T,C,F,M> builder, Locatable upstream, C registryClass) {
    this.nav = builder.nav;
    this.registryClass = registryClass;
    this.upstream = upstream;
    builder.registries.put(getPackageName(),this);

    if(nav.getDeclaredField(registryClass,ContextFactory.USE_JAXB_PROPERTIES)!=null) {
        // the user is trying to use ObjectFactory that we generate for interfaces,
        // that means he's missing jaxb.properties
        builder.reportError(new IllegalAnnotationException(
            Messages.MISSING_JAXB_PROPERTIES.format(getPackageName()),
            this
        ));
        // looking at members will only add more errors, so just abort now
        return;
    }

    for( M m : nav.getDeclaredMethods(registryClass) ) {
        XmlElementDecl em = builder.reader.getMethodAnnotation(
            XmlElementDecl.class, m, this );

        if(em==null) {
            if(nav.getMethodName(m).startsWith("create")) {
                // this is a factory method. visit this class
                references.add(
                    builder.getTypeInfo(nav.getReturnType(m),
                        new MethodLocatable<M>(this,m,nav)));
            }

            continue;
        }

        ElementInfoImpl<T,C,F,M> ei;
        try {
            ei = builder.createElementInfo(this,m);
        } catch (IllegalAnnotationException e) {
            builder.reportError(e);
            continue;   // recover by ignoring this element
        }

        // register this mapping
        // TODO: any chance this could cause a stack overflow (by recursively visiting classes)?
        builder.typeInfoSet.add(ei,builder);
        references.add(ei);
    }
}
 
Example #24
Source File: JAXBRIContext.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link JAXBRIContext}.
 *
 * <p>
 * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
 * return other JAXB providers that are not compatible with the JAX-RPC RI.
 * This method guarantees that the JAX-WS RI will finds the JAXB RI.
 *
 * @param classes
 *      Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
 * @param typeRefs
 *      See {@link #TYPE_REFERENCES} for the meaning of this parameter.
 *      Can be null.
 * @param subclassReplacements
 *      See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
 *      Can be null.
 * @param defaultNamespaceRemap
 *      See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
 *      Can be null (and should be null for ordinary use of JAXB.)
 * @param c14nSupport
 *      See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
 * @param ar
 *      See {@link #ANNOTATION_READER} for the meaning of this parameter.
 *      Can be null.
 * @param xmlAccessorFactorySupport
 *      See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
 * @param allNillable
 *      See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
 * @param retainPropertyInfo
 *      See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
 * @param supressAccessorWarnings
 *      See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
 */
public static JAXBRIContext newInstance(@NotNull Class[] classes,
   @Nullable Collection<TypeReference> typeRefs,
   @Nullable Map<Class,Class> subclassReplacements,
   @Nullable String defaultNamespaceRemap, boolean c14nSupport,
   @Nullable RuntimeAnnotationReader ar,
   boolean xmlAccessorFactorySupport,
   boolean allNillable,
   boolean retainPropertyInfo,
   boolean supressAccessorWarnings) throws JAXBException {
    Map<String, Object> properties = new HashMap<String, Object>();
    if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
    if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
    if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
    if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
    properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
    properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
    properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
    properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
    properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
    return (JAXBRIContext) ContextFactory.createContext(classes, properties);
}