public JAXBContext findJAXBContext(Class<?> type, Annotation[] annotations, MediaType mediaType, boolean reader) throws JAXBException { ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { if (reader) throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); else throw new JAXBMarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } return finder.findCachedContext(type, mediaType, annotations); }
/** * Check for a user provided JAXBContext implementation. It takes priority over our builtin one. * @param type * @param mediaType * @return * @throws IOException */ private javax.xml.bind.JAXBContext getJAXBContext(Class<Object> type, MediaType mediaType) throws IOException { LogMessages.LOGGER.debugf("Provider : %s, Method : getJAXBContext", getClass().getName()); ContextResolver<javax.xml.bind.JAXBContext> resolver = providers.getContextResolver( javax.xml.bind.JAXBContext.class, mediaType); javax.xml.bind.JAXBContext finder = null; if (resolver != null) { finder = resolver.getContext(type); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindUsersJAXBContext(mediaType)); } } return finder; }
throw new JAXBMarshalException(Messages.MESSAGES.createMethodNotFound(type));
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedLocalPart(wrapped.map(), ele.getName().getLocalPart())); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI())); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappedFailedKeyAttribute()); for (int j = 0; j < attributeMap.getLength(); j++)
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedLocalPart(wrapped.element(), ele.getName().getLocalPart())); throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI()));
throw new JAXBException(Messages.MESSAGES.namespacePrefixMapperNotInClassPath()); throw new JAXBException(Messages.MESSAGES.errorTryingToLoadSchema(config.schema()), e);
@Override public JAXBContext findJAXBContext(Class<?> type, Annotation[] annotations, MediaType mediaType, boolean reader) throws JAXBException { ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { if (reader) throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); else throw new JAXBMarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } XmlSeeAlso seeAlso = type.getAnnotation(XmlSeeAlso.class); return finder.findCacheContext(mediaType, annotations, seeAlso.value()); }
/** * Check for the resteasy builtin JAXBContext implementation. * @param type * @param annotations * @param mediaType * @return * @throws IOException */ private JAXBContext getJAXBContextFinder(Class<Object> type, Annotation[] annotations, MediaType mediaType) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : getJAXBContextFinder", getClass().getName()); ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } JAXBContext jaxb = finder.findCacheXmlTypeContext(mediaType, annotations, type); return jaxb; } catch (JAXBException e) { throw new JAXBUnmarshalException(e); } }