@Context public void setMessageContext(MessageContext mc) { super.setContext(mc); }
@Override protected boolean canBeReadAsJaxbElement(Class<?> type) { return super.canBeReadAsJaxbElement(type) && type != XMLSource.class && !Source.class.isAssignableFrom(type); }
protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType) throws JAXBException { return createUnmarshaller(cls, genericType, false); }
protected QName getCollectionWrapperQName(Class<?> cls, Type type, Object object, boolean pluralName) throws Exception { String name = getCollectionWrapperName(cls); if (name == null) { return getJaxbQName(cls, type, object, pluralName); } return JAXRSUtils.convertStringToQName(name); }
protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection) throws JAXBException { JAXBContext context = isCollection ? getCollectionContext(cls) : getJAXBContext(cls, genericType); Unmarshaller unmarshaller = context.createUnmarshaller(); Schema theSchema = getSchema(cls); if (theSchema != null) { unmarshaller.setSchema(theSchema); } if (eventHandler != null) { unmarshaller.setEventHandler(eventHandler); } if (unmarshallerListener != null) { unmarshaller.setListener(unmarshallerListener); } if (uProperties != null) { for (Map.Entry<String, Object> entry : uProperties.entrySet()) { unmarshaller.setProperty(entry.getKey(), entry.getValue()); } } return unmarshaller; }
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) { DocumentDepthProperties props = getDepthProperties(); if (props != null && props.isEffective()) { reader = TransformUtils.createNewReaderIfNeeded(reader, is); reader = new DepthRestrictingStreamReader(reader, props); } else if (reader != null) { reader = configureReaderRestrictions(reader); } return reader; }
public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { if (InjectionUtils.isSupportedCollectionOrArray(type)) { type = InjectionUtils.getActualType(genericType); if (type == null) { return false; } } return canBeReadAsJaxbElement(type) || isSupported(type, genericType, anns); }
protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc) throws JAXBException { Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls) ? ((JAXBElement<?>)obj).getDeclaredType() : cls; JAXBContext context = getJAXBContext(objClazz, genericType); Marshaller marshaller = context.createMarshaller(); if (enc != null) { marshaller.setProperty(Marshaller.JAXB_ENCODING, enc); } if (marshallerListener != null) { marshaller.setListener(marshallerListener); } validateObjectIfNeeded(marshaller, cls, obj); return marshaller; }
@SuppressWarnings("unchecked") public JAXBContext getJAXBContext(Class<?> type, Type genericType) throws JAXBException { if (mc != null) { ContextResolver<JAXBContext> resolver = mc.getResolver(ContextResolver.class, JAXBContext.class); if (resolver != null) { JAXBContext customContext = resolver.getContext(type); if (customContext != null) { return customContext; } } } synchronized (classContexts) { JAXBContext context = classContexts.get(type); if (context != null) { return context; } } JAXBContext context = getPackageContext(type, genericType); return context != null ? context : getClassContext(type, genericType); } public JAXBContext getClassContext(Class<?> type) throws JAXBException {
protected DocumentDepthProperties getDepthProperties() { DocumentDepthProperties depthProperties = super.getDepthProperties(); if (depthProperties != null) { return depthProperties; } if (getContext() != null) { String totalElementCountStr = (String)getContext().getContextualProperty( DocumentDepthProperties.TOTAL_ELEMENT_COUNT); String innerElementCountStr = (String)getContext().getContextualProperty( DocumentDepthProperties.INNER_ELEMENT_COUNT); String elementLevelStr = (String)getContext().getContextualProperty( DocumentDepthProperties.INNER_ELEMENT_LEVEL); if (totalElementCountStr != null || innerElementCountStr != null || elementLevelStr != null) { try { int totalElementCount = totalElementCountStr != null ? Integer.parseInt(totalElementCountStr) : -1; int elementLevel = elementLevelStr != null ? Integer.parseInt(elementLevelStr) : -1; int innerElementCount = innerElementCountStr != null ? Integer.parseInt(innerElementCountStr) : -1; return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount); } catch (Exception ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } } } return null; }
public JAXBContext getClassContext(Class<?> type) throws JAXBException { return getClassContext(type, type); } protected JAXBContext getClassContext(Class<?> type, Type genericType) throws JAXBException {
public void setSchemaLocations(List<String> locations) { schema = SchemaHandler.createSchema(locations, catalogLocation, getBus()); }
protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType, boolean isCollection) throws JAXBException { JAXBContext context = isCollection ? getCollectionContext(cls) : getJAXBContext(cls, genericType); Unmarshaller unmarshaller = context.createUnmarshaller(); if (validateInputIfPossible) { Schema theSchema = getSchema(cls); if (theSchema != null) { unmarshaller.setSchema(theSchema); } } if (eventHandler != null) { unmarshaller.setEventHandler(eventHandler); } if (unmarshallerListener != null) { unmarshaller.setListener(unmarshallerListener); } if (uProperties != null) { for (Map.Entry<String, Object> entry : uProperties.entrySet()) { unmarshaller.setProperty(entry.getKey(), entry.getValue()); } } return unmarshaller; }
protected XMLStreamReader createDepthReaderIfNeeded(XMLStreamReader reader, InputStream is) { DocumentDepthProperties props = getDepthProperties(); if (props != null && props.isEffective()) { reader = TransformUtils.createNewReaderIfNeeded(reader, is); reader = new DepthRestrictingStreamReader(reader, props); } else if (reader != null) { reader = configureReaderRestrictions(reader); } return reader; }
public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { if (InjectionUtils.isSupportedCollectionOrArray(type)) { type = InjectionUtils.getActualType(genericType); if (type == null) { return false; } } return canBeReadAsJaxbElement(type) || isSupported(type, genericType, anns); }
protected QName getCollectionWrapperQName(Class<?> cls, Type type, Object object, boolean pluralName) throws Exception { String name = getCollectionWrapperName(cls); if (name == null) { return getJaxbQName(cls, type, object, pluralName); } return JAXRSUtils.convertStringToQName(name); }
protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType, String enc) throws JAXBException { Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls) ? ((JAXBElement<?>)obj).getDeclaredType() : cls; JAXBContext context = getJAXBContext(objClazz, genericType); Marshaller marshaller = context.createMarshaller(); if (enc != null) { marshaller.setProperty(Marshaller.JAXB_ENCODING, enc); } if (marshallerListener != null) { marshaller.setListener(marshallerListener); } validateObjectIfNeeded(marshaller, cls, obj); return marshaller; }
@SuppressWarnings("unchecked") public JAXBContext getJAXBContext(Class<?> type, Type genericType) throws JAXBException { if (mc != null) { ContextResolver<JAXBContext> resolver = mc.getResolver(ContextResolver.class, JAXBContext.class); if (resolver != null) { JAXBContext customContext = resolver.getContext(type); if (customContext != null) { return customContext; } } } synchronized (classContexts) { JAXBContext context = classContexts.get(type); if (context != null) { return context; } } JAXBContext context = getPackageContext(type, genericType); return context != null ? context : getClassContext(type, genericType); } public JAXBContext getClassContext(Class<?> type) throws JAXBException {
protected DocumentDepthProperties getDepthProperties() { DocumentDepthProperties depthProperties = super.getDepthProperties(); if (depthProperties != null) { return depthProperties; } if (getContext() != null) { String totalElementCountStr = (String)getContext().getContextualProperty( DocumentDepthProperties.TOTAL_ELEMENT_COUNT); String innerElementCountStr = (String)getContext().getContextualProperty( DocumentDepthProperties.INNER_ELEMENT_COUNT); String elementLevelStr = (String)getContext().getContextualProperty( DocumentDepthProperties.INNER_ELEMENT_LEVEL); if (totalElementCountStr != null || innerElementCountStr != null || elementLevelStr != null) { try { int totalElementCount = totalElementCountStr != null ? Integer.parseInt(totalElementCountStr) : -1; int elementLevel = elementLevelStr != null ? Integer.parseInt(elementLevelStr) : -1; int innerElementCount = innerElementCountStr != null ? Integer.parseInt(innerElementCountStr) : -1; return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount); } catch (Exception ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } } } return null; }
public JAXBContext getClassContext(Class<?> type) throws JAXBException { return getClassContext(type, type); } protected JAXBContext getClassContext(Class<?> type, Type genericType) throws JAXBException {