public Object getJAXBObject(JAXBContextFinder finder, MediaType mediaType, Class<?> clazz, Element element) throws JAXBException { JAXBContext ctx = finder.findCachedContext(clazz, mediaType, null); return ctx.createUnmarshaller().unmarshal(element); }
ctx = finder.findCacheContext(MediaType.APPLICATION_XML_TYPE, null, classes);
/** * 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); } }
public Object getJAXBObject(JAXBContextFinder finder, MediaType mediaType, Class<?> clazz, Element element) throws JAXBException { JAXBContext ctx = finder.findCachedContext(clazz, mediaType, null); return ctx.createUnmarshaller().unmarshal(element); }
ctx = finder.findCacheContext(MediaType.APPLICATION_XML_TYPE, null, classes);
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), e); } }
ctx = finder.findCacheContext(MediaType.APPLICATION_XML_TYPE, null, classes); } else { ctx = JAXBContext.newInstance(classes);
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); }
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, set.toArray(new Class[set.size()])); Marshaller marshaller = ctx.createMarshaller(); NamespacePrefixMapper mapper = new NamespacePrefixMapper()
JAXBContext ctx = finder.findCachedContext(JaxbCollection.class, mediaType, annotations); Unmarshaller unmarshaller = ctx.createUnmarshaller(); unmarshaller = new SecureUnmarshaller(unmarshaller, disableExternalEntities, enableSecureProcessingFeature, disableDTDs); JAXBContext ctx = finder.findCachedContext(JaxbCollection.class, mediaType, annotations); ele = ctx.createUnmarshaller().unmarshal(source, JaxbCollection.class); ctx = finder.findCachedContext(adaptedType, mediaType, null); ctx = finder.findCachedContext(baseType, mediaType, null);
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, set.toArray(new Class[set.size()])); Marshaller marshaller = ctx.createMarshaller(); NamespacePrefixMapper mapper = new NamespacePrefixMapper()
public Feed readFrom(Class<Feed> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Feed.class, mediaType, annotations); Feed feed = (Feed) ctx.createUnmarshaller().unmarshal(entityStream); for (Entry entry : feed.getEntries()) { entry.setFinder(finder); if (entry.getContent() != null) entry.getContent().setFinder(finder); } return feed; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), 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()); }
try JAXBContext ctx = finder.findCachedContext(baseType, mediaType, annotations); Marshaller marshaller = ctx.createMarshaller(); marshaller = AbstractJAXBProvider.decorateMarshaller(baseType, annotations, mediaType, marshaller);
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, JaxbMap.class, JaxbMap.Entry.class, valueType); if (needsSecurity())
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e); } }
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, JaxbMap.class, JaxbMap.Entry.class, valueType);
public Feed readFrom(Class<Feed> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType); } try { JAXBContext ctx = finder.findCachedContext(Feed.class, mediaType, annotations); Feed feed = (Feed) ctx.createUnmarshaller().unmarshal(entityStream); for (Entry entry : feed.getEntries()) { if (entry.getContent() != null) entry.getContent().setFinder(finder); } return feed; } catch (JAXBException e) { throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e); } }
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, JaxbCollection.class, baseType); JaxbCollection col = new JaxbCollection(); if (type.isArray())
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), e); } }