Java源码示例:com.sun.xml.internal.bind.v2.ContextFactory

示例1
@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);
    }
}
 
示例2
@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);
    }
}
 
示例3
@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);
    }
}
 
示例4
@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);
    }
}
 
示例5
@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);
    }
}
 
示例6
@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);
    }
}
 
示例7
@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);
    }
}
 
示例8
@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);
    }
}
 
示例9
/**
 * 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);
}
 
示例10
/**
 * 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);
    }
}
 
示例11
/**
 * 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);
}
 
示例12
/**
 * 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);
    }
}
 
示例13
/**
 * 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);
}
 
示例14
/**
 * 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);
    }
}
 
示例15
/**
 * 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);
}
 
示例16
/**
 * 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);
    }
}
 
示例17
/**
 * 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);
}
 
示例18
/**
 * 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);
    }
}
 
示例19
/**
 * 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);
}
 
示例20
/**
 * 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);
    }
}
 
示例21
/**
 * 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);
}
 
示例22
/**
 * 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);
    }
}
 
示例23
/**
 * 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);
}
 
示例24
/**
 * 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);
    }
}