Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: MOXyJsonProvider.java
- ===================================================================
- --- MOXyJsonProvider.java (revision 557)
- +++ MOXyJsonProvider.java (revision 556)
- @@ -68,8 +68,8 @@
- import org.eclipse.persistence.internal.queries.CollectionContainerPolicy;
- import org.eclipse.persistence.internal.queries.ContainerPolicy;
- import org.eclipse.persistence.jaxb.JAXBContextFactory;
- -import org.eclipse.persistence.jaxb.JAXBContextProperties;
- import org.eclipse.persistence.jaxb.MarshallerProperties;
- +import org.eclipse.persistence.jaxb.UnmarshallerProperties;
- import org.eclipse.persistence.oxm.JSONWithPadding;
- /**
- @@ -217,12 +217,12 @@
- private char namespaceSeperator = Constants.DOT;
- private String valueWrapper;
- private boolean wrapperAsArrayName = false;
- - private Object oxmMetadataSource = null;
- /**
- * The value that will be prepended to all keys that are mapped to an XML
- * attribute. By default there is no attribute prefix.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_ATTRIBUTE_PREFIX
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_ATTRIBUTE_PREFIX
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_ATTRIBUTE_PREFIX
- */
- public String getAttributePrefix() {
- return attributePrefix;
- @@ -300,43 +300,18 @@
- resolver = providers.getContextResolver(JAXBContext.class, mediaType);
- }
- if(null == resolver || null == (jaxbContext = resolver.getContext(domainClass))) {
- - jaxbContext = JAXBContextFactory.createContext(new Class[] {domainClass},
- - prepareContextProperties());
- + jaxbContext = JAXBContextFactory.createContext(new Class[] {domainClass}, null);
- contextCache.put(domainClass, jaxbContext);
- return jaxbContext;
- } else if (jaxbContext instanceof org.eclipse.persistence.jaxb.JAXBContext) {
- return jaxbContext;
- } else {
- - jaxbContext = JAXBContextFactory.createContext(new Class[] {domainClass},
- - prepareContextProperties());
- + jaxbContext = JAXBContextFactory.createContext(new Class[] {domainClass}, null);
- contextCache.put(domainClass, jaxbContext);
- return jaxbContext;
- }
- }
- - private Map<String, Object> prepareContextProperties() {
- - Map<String, Object> contextProperties = new HashMap<>();
- -
- - contextProperties.put(JAXBContextProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
- - contextProperties.put(JAXBContextProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- - contextProperties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, includeRoot);
- - contextProperties.put(JAXBContextProperties.NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- - contextProperties.put(JAXBContextProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeperator);
- - if(null != valueWrapper) {
- - contextProperties.put(JAXBContextProperties.JSON_VALUE_WRAPPER, valueWrapper);
- - }
- - contextProperties.put(JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME, wrapperAsArrayName);
- - contextProperties.put(JAXBContextProperties.OXM_METADATA_SOURCE, oxmMetadataSource);
- -
- - overrideContextProperties(contextProperties);
- -
- - return contextProperties;
- - }
- -
- - protected void overrideContextProperties(Map<String, Object> contextProperties) {
- -
- - }
- -
- private JAXBContext getJAXBContext(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- if(null == genericType) {
- genericType = type;
- @@ -354,7 +329,8 @@
- * By default the JSON-binding will ignore namespace qualification. If this
- * property is set the portion of the key before the namespace separator
- * will be used to determine the namespace URI.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.NAMESPACE_PREFIX_MAPPER
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.NAMESPACE_PREFIX_MAPPER
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER
- */
- public Map<String, String> getNamespacePrefixMapper() {
- return namespacePrefixMapper;
- @@ -364,16 +340,13 @@
- * This character (default is '.') separates the prefix from the key name.
- * It is only used if namespace qualification has been enabled be setting a
- * namespace prefix mapper.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_NAMESPACE_SEPARATOR
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.NAMESPACE_SEPARATOR
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.NAMESPACE_SEPARATOR
- */
- public char getNamespaceSeparator() {
- return this.namespaceSeperator;
- }
- - public Object getOxmMetadataSource() {
- - return this.oxmMetadataSource;
- - }
- -
- /*
- * @return -1 since the size of the JSON message is not known.
- * @see javax.ws.rs.ext.MessageBodyWriter#getSize(java.lang.Object, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType)
- @@ -385,7 +358,8 @@
- /**
- * The key that will correspond to the property mapped with @XmlValue. This
- * key will only be used if there are other mapped properties.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_VALUE_WRAPPER
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_VALUE_WRAPPER
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_VALUE_WRAPPER
- */
- public String getValueWrapper() {
- return valueWrapper;
- @@ -401,7 +375,8 @@
- /**
- * @return true if the root node is included in the JSON message (default is
- * false).
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_INCLUDE_ROOT
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_INCLUDE_ROOT
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_INCLUDE_ROOT
- */
- public boolean isIncludeRoot() {
- return includeRoot;
- @@ -502,6 +477,8 @@
- * </pre>
- * @since 2.4.2
- * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME
- */
- public boolean isWrapperAsArrayName() {
- return wrapperAsArrayName;
- @@ -609,6 +586,15 @@
- Class<?> domainClass = getDomainClass(genericType);
- JAXBContext jaxbContext = getJAXBContext(domainClass, annotations, mediaType, httpHeaders);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- + unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, includeRoot);
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeperator);
- + if(null != valueWrapper) {
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_VALUE_WRAPPER, valueWrapper);
- + }
- + unmarshaller.setProperty(UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, wrapperAsArrayName);
- preReadFrom(type, genericType, annotations, mediaType, httpHeaders, unmarshaller);
- StreamSource jsonSource;
- @@ -707,7 +693,8 @@
- /**
- * Specify a value that will be prepended to all keys that are mapped to an
- * XML attribute. By default there is no attribute prefix.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_ATTRIBUTE_PREFIX
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_ATTRIBUTE_PREFIX
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_ATTRIBUTE_PREFIX
- */
- public void setAttributePrefix(String attributePrefix) {
- this.attributePrefix = attributePrefix;
- @@ -727,7 +714,8 @@
- * is false).
- * @param includeRoot - true if the message includes the root node, else
- * false.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_INCLUDE_ROOT
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_INCLUDE_ROOT
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_INCLUDE_ROOT
- */
- public void setIncludeRoot(boolean includeRoot) {
- this.includeRoot = includeRoot;
- @@ -747,7 +735,8 @@
- * property is set then a prefix corresponding to the namespace URI and a
- * namespace separator will be prefixed to the key.
- * include it you can specify a Map of namespace URI to prefix.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.NAMESPACE_PREFIX_MAPPER
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.NAMESPACE_PREFIX_MAPPER
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER
- */
- public void setNamespacePrefixMapper(Map<String, String> namespacePrefixMapper) {
- this.namespacePrefixMapper = namespacePrefixMapper;
- @@ -757,7 +746,8 @@
- * This character (default is '.') separates the prefix from the key name.
- * It is only used if namespace qualification has been enabled be setting a
- * namespace prefix mapper.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_NAMESPACE_SEPARATOR
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.NAMESPACE_SEPARATOR
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.NAMESPACE_SEPARATOR
- */
- public void setNamespaceSeparator(char namespaceSeparator) {
- this.namespaceSeperator = namespaceSeparator;
- @@ -802,6 +792,8 @@
- * </pre>
- * @since 2.4.2
- * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME
- + * @see org.eclipse.persistence.jaxb.MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME
- + * @see org.eclipse.persistence.jaxb.UnmarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME
- */
- public void setWrapperAsArrayName(boolean wrapperAsArrayName) {
- this.wrapperAsArrayName = wrapperAsArrayName;
- @@ -811,16 +803,13 @@
- * Specify the key that will correspond to the property mapped with
- * @XmlValue. This key will only be used if there are other mapped
- * properties.
- - * @see org.eclipse.persistence.jaxb.JAXBContextProperties.JSON_VALUE_WRAPPER
- + * @see org.eclipse.persistence.jaxb.MarshallerPropertes.JSON_VALUE_WRAPPER
- + * @see org.eclipse.persistence.jaxb.UnmarshallerPropertes.JSON_VALUE_WRAPPER
- */
- public void setValueWrapper(String valueWrapper) {
- this.valueWrapper = valueWrapper;
- }
- - public void setOxmMetadataSource(Object oxmMetadataSource) {
- - this.oxmMetadataSource = oxmMetadataSource;
- - }
- -
- /**
- * @return true for all media types of the pattern */json and
- * */*+json.
- @@ -846,7 +835,16 @@
- JAXBContext jaxbContext = getJAXBContext(domainClass, annotations, mediaType, httpHeaders);
- Marshaller marshaller = jaxbContext.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, formattedOutput);
- + marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
- + marshaller.setProperty(MarshallerProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- + marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, includeRoot);
- marshaller.setProperty(MarshallerProperties.JSON_MARSHAL_EMPTY_COLLECTIONS, marshalEmptyCollections);
- + marshaller.setProperty(MarshallerProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeperator);
- + if(null != valueWrapper) {
- + marshaller.setProperty(MarshallerProperties.JSON_VALUE_WRAPPER, valueWrapper);
- + }
- + marshaller.setProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, wrapperAsArrayName);
- + marshaller.setProperty(MarshallerProperties.NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- Map<String, String> mediaTypeParameters = null;
- if(null != mediaType) {
- Index: MoxyJsonConfig.java
- ===================================================================
- --- MoxyJsonConfig.java (revision 557)
- +++ MoxyJsonConfig.java (revision 556)
- @@ -46,8 +46,8 @@
- import javax.xml.bind.Marshaller;
- -import org.eclipse.persistence.jaxb.JAXBContextProperties;
- import org.eclipse.persistence.jaxb.MarshallerProperties;
- +import org.eclipse.persistence.jaxb.UnmarshallerProperties;
- import org.eclipse.persistence.oxm.XMLConstants;
- /**
- @@ -57,7 +57,6 @@
- */
- public final class MoxyJsonConfig {
- - private final Map<String, Object> contextProperties = new HashMap<>();
- private final Map<String, Object> marshallerProperties = new HashMap<>();
- private final Map<String, Object> unmarshallerProperties = new HashMap<>();
- @@ -105,20 +104,20 @@
- * @param that config to make a copy of.
- */
- private MoxyJsonConfig(final MoxyJsonConfig that) {
- - this.contextProperties.putAll(that.contextProperties);
- this.marshallerProperties.putAll(that.marshallerProperties);
- this.unmarshallerProperties.putAll(that.unmarshallerProperties);
- }
- /**
- - * Set the value of the property for used {@code JAXBContext}.
- + * Set the value of the property for both {@code Marshaller} / {@code Unmarshaller}.
- *
- * @param name name of the property.
- * @param value value of the property.
- * @return a {@code MoxyJsonConfig} instance.
- */
- - public MoxyJsonConfig contextProperty(final String name, final Object value) {
- - contextProperties.put(name, value);
- + public MoxyJsonConfig property(final String name, final Object value) {
- + marshallerProperty(name, value);
- + unmarshallerProperty(name, value);
- return this;
- }
- @@ -147,17 +146,6 @@
- }
- /**
- - * Add properties from the given map to the existing context properties.
- - *
- - * @param contextProperties map of marshaller properties.
- - * @return a {@code MoxyJsonConfig} instance.
- - */
- - public MoxyJsonConfig setContextProperties(final Map<String, Object> contextProperties) {
- - this.contextProperties.putAll(contextProperties);
- - return this;
- - }
- -
- - /**
- * Add properties from the given map to the existing marshaller properties.
- *
- * @param marshallerProperties map of marshaller properties.
- @@ -180,15 +168,6 @@
- }
- /**
- - * Get context properties.
- - *
- - * @return mutable map of context properties.
- - */
- - public Map<String, Object> getContextProperties() {
- - return contextProperties;
- - }
- -
- - /**
- * Get marshaller properties.
- *
- * @return mutable map of marshaller properties.
- @@ -210,7 +189,7 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#getAttributePrefix()
- */
- public String getAttributePrefix() {
- - return (String) contextProperties.get(JAXBContextProperties.JSON_ATTRIBUTE_PREFIX);
- + return (String) marshallerProperties.get(MarshallerProperties.JSON_ATTRIBUTE_PREFIX);
- }
- /**
- @@ -218,9 +197,11 @@
- */
- public MoxyJsonConfig setAttributePrefix(final String attributePrefix) {
- if (attributePrefix != null) {
- - contextProperties.put(JAXBContextProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- + marshallerProperties.put(MarshallerProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- + unmarshallerProperties.put(UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX, attributePrefix);
- } else {
- - contextProperties.remove(MarshallerProperties.JSON_ATTRIBUTE_PREFIX);
- + marshallerProperties.remove(MarshallerProperties.JSON_ATTRIBUTE_PREFIX);
- + unmarshallerProperties.remove(UnmarshallerProperties.JSON_ATTRIBUTE_PREFIX);
- }
- return this;
- }
- @@ -244,7 +225,7 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#isIncludeRoot()
- */
- public boolean isIncludeRoot() {
- - return (Boolean) contextProperties.get(JAXBContextProperties.JSON_INCLUDE_ROOT);
- + return (Boolean) marshallerProperties.get(MarshallerProperties.JSON_INCLUDE_ROOT);
- }
- /**
- @@ -251,7 +232,8 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#setIncludeRoot(boolean)
- */
- public MoxyJsonConfig setIncludeRoot(final boolean includeRoot) {
- - contextProperties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, includeRoot);
- + marshallerProperties.put(MarshallerProperties.JSON_INCLUDE_ROOT, includeRoot);
- + unmarshallerProperties.put(UnmarshallerProperties.JSON_INCLUDE_ROOT, includeRoot);
- return this;
- }
- @@ -274,7 +256,7 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#getNamespacePrefixMapper()
- */
- public Map<String, String> getNamespacePrefixMapper() {
- - return (Map<String, String>) contextProperties.get(JAXBContextProperties.NAMESPACE_PREFIX_MAPPER);
- + return (Map<String, String>) marshallerProperties.get(MarshallerProperties.NAMESPACE_PREFIX_MAPPER);
- }
- /**
- @@ -282,9 +264,11 @@
- */
- public MoxyJsonConfig setNamespacePrefixMapper(final Map<String, String> namespacePrefixMapper) {
- if (namespacePrefixMapper != null) {
- - contextProperties.put(JAXBContextProperties.NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- + marshallerProperties.put(MarshallerProperties.NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- + unmarshallerProperties.put(UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER, namespacePrefixMapper);
- } else {
- - contextProperties.remove(JAXBContextProperties.NAMESPACE_PREFIX_MAPPER);
- + marshallerProperties.remove(MarshallerProperties.NAMESPACE_PREFIX_MAPPER);
- + unmarshallerProperties.remove(UnmarshallerProperties.JSON_NAMESPACE_PREFIX_MAPPER);
- }
- return this;
- }
- @@ -293,7 +277,7 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#getNamespaceSeparator()
- */
- public char getNamespaceSeparator() {
- - return (Character) contextProperties.get(JAXBContextProperties.JSON_NAMESPACE_SEPARATOR);
- + return (Character) marshallerProperties.get(MarshallerProperties.JSON_NAMESPACE_SEPARATOR);
- }
- /**
- @@ -300,7 +284,8 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#setNamespaceSeparator(char)
- */
- public MoxyJsonConfig setNamespaceSeparator(final char namespaceSeparator) {
- - contextProperties.put(JAXBContextProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeparator);
- + marshallerProperties.put(MarshallerProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeparator);
- + unmarshallerProperties.put(UnmarshallerProperties.JSON_NAMESPACE_SEPARATOR, namespaceSeparator);
- return this;
- }
- @@ -308,7 +293,7 @@
- * @see org.eclipse.persistence.jaxb.rs.MOXyJsonProvider#getValueWrapper()
- */
- public String getValueWrapper() {
- - return (String) contextProperties.get(JAXBContextProperties.JSON_VALUE_WRAPPER);
- + return (String) marshallerProperties.get(MarshallerProperties.JSON_VALUE_WRAPPER);
- }
- /**
- @@ -316,33 +301,16 @@
- */
- public MoxyJsonConfig setValueWrapper(final String valueWrapper) {
- if (valueWrapper != null) {
- - contextProperties.put(JAXBContextProperties.JSON_VALUE_WRAPPER, valueWrapper);
- + marshallerProperties.put(MarshallerProperties.JSON_VALUE_WRAPPER, valueWrapper);
- + unmarshallerProperties.put(UnmarshallerProperties.JSON_VALUE_WRAPPER, valueWrapper);
- } else {
- - contextProperties.remove(JAXBContextProperties.JSON_VALUE_WRAPPER);
- + marshallerProperties.remove(MarshallerProperties.JSON_VALUE_WRAPPER);
- + unmarshallerProperties.remove(UnmarshallerProperties.JSON_VALUE_WRAPPER);
- }
- return this;
- }
- /**
- - *
- - */
- - public Object getOxmMedatadataSource() {
- - return contextProperties.get(JAXBContextProperties.OXM_METADATA_SOURCE);
- - }
- -
- - /**
- - *
- - */
- - public MoxyJsonConfig setOxmMedatadataSource(final Object oxmMedatadataSource) {
- - if (oxmMedatadataSource != null) {
- - contextProperties.put(JAXBContextProperties.OXM_METADATA_SOURCE, oxmMedatadataSource);
- - } else {
- - contextProperties.remove(JAXBContextProperties.OXM_METADATA_SOURCE);
- - }
- - return this;
- - }
- -
- - /**
- * Create a {@link ContextResolver context resolver} for a current state of this {@code MoxyJsonConfig}.
- *
- * @return context resolver for this config.
- Index: ConfigurableMoxyJsonProvider.java
- ===================================================================
- --- ConfigurableMoxyJsonProvider.java (revision 557)
- +++ ConfigurableMoxyJsonProvider.java (revision 556)
- @@ -68,7 +68,6 @@
- import ...jersey.moxy.json.MoxyJsonConfig;
- import org.eclipse.persistence.internal.core.helper.CoreClassConstants;
- -import org.eclipse.persistence.jaxb.JAXBContextProperties;
- import org.eclipse.persistence.jaxb.MarshallerProperties;
- import org.eclipse.persistence.jaxb.UnmarshallerProperties;
- @@ -80,17 +79,11 @@
- @Singleton
- public class ConfigurableMoxyJsonProvider extends MOXyJsonProvider {
- - private final static Set<String> CONTEXT_PROPERTY_NAMES;
- - private final static Set<String> MARSHALLER_PROPERTY_NAMES;
- + private final static Set<String> MARSHALLER_PROPERTY_NAMES;
- private final static Set<String> UNMARSHALLER_PROPERTY_NAMES;
- - private enum PropertiesType {
- - MARSHALLER, UNMARSHALLER, CONTEXT;
- - }
- -
- static {
- - CONTEXT_PROPERTY_NAMES = getPropertyNames(JAXBContextProperties.class);
- - MARSHALLER_PROPERTY_NAMES = getPropertyNames(MarshallerProperties.class);
- + MARSHALLER_PROPERTY_NAMES = getPropertyNames(MarshallerProperties.class);
- UNMARSHALLER_PROPERTY_NAMES = getPropertyNames(UnmarshallerProperties.class);
- }
- @@ -122,7 +115,6 @@
- private MoxyJsonConfig getGlobalConfig() {
- if (globalConfig == null) {
- globalConfig = new MoxyJsonConfig()
- - .setContextProperties(getConfigProperties(config, CONTEXT_PROPERTY_NAMES))
- .setMarshallerProperties(getConfigProperties(config, MARSHALLER_PROPERTY_NAMES))
- .setUnmarshallerProperties(getConfigProperties(config, UNMARSHALLER_PROPERTY_NAMES));
- }
- @@ -161,33 +153,21 @@
- }
- private void initializeUnmarshaller(final Unmarshaller unmarshaller) throws PropertyException {
- - for (final Map.Entry<String, Object> property : getProperties(PropertiesType.UNMARSHALLER).entrySet()) {
- + for (final Map.Entry<String, Object> property : getProperties(false).entrySet()) {
- unmarshaller.setProperty(property.getKey(), property.getValue());
- }
- }
- private void initializeMarshaller(final Marshaller marshaller) throws PropertyException {
- - for (final Map.Entry<String, Object> property : getProperties(PropertiesType.MARSHALLER).entrySet()) {
- + for (final Map.Entry<String, Object> property : getProperties(true).entrySet()) {
- marshaller.setProperty(property.getKey(), property.getValue());
- }
- }
- - private Map<String, Object> getProperties(final PropertiesType propertiesType) {
- + private Map<String, Object> getProperties(final boolean forMarshaller) {
- + final Map<String, Object> properties = new HashMap<>(
- + forMarshaller ? getGlobalConfig().getMarshallerProperties() : getGlobalConfig().getUnmarshallerProperties());
- - final Map<String, Object> properties = new HashMap<>();
- -
- - switch(propertiesType) {
- - case MARSHALLER:
- - properties.putAll(getGlobalConfig().getMarshallerProperties());
- - break;
- - case UNMARSHALLER:
- - properties.putAll(getGlobalConfig().getUnmarshallerProperties());
- - break;
- - case CONTEXT:
- - properties.putAll(getGlobalConfig().getContextProperties());
- - break;
- - }
- -
- final ContextResolver<MoxyJsonConfig> contextResolver =
- providers.getContextResolver(MoxyJsonConfig.class, MediaType.APPLICATION_JSON_TYPE);
- if (contextResolver != null) {
- @@ -194,17 +174,8 @@
- final MoxyJsonConfig jsonConfiguration = contextResolver.getContext(MoxyJsonConfig.class);
- if (jsonConfiguration != null) {
- - switch(propertiesType) {
- - case MARSHALLER:
- - properties.putAll(jsonConfiguration.getMarshallerProperties());
- - break;
- - case UNMARSHALLER:
- - properties.putAll(jsonConfiguration.getUnmarshallerProperties());
- - break;
- - case CONTEXT:
- - properties.putAll(jsonConfiguration.getContextProperties());
- - break;
- - }
- + properties.putAll(forMarshaller ?
- + jsonConfiguration.getMarshallerProperties() : jsonConfiguration.getUnmarshallerProperties());
- }
- }
- @@ -212,11 +183,6 @@
- }
- @Override
- - protected void overrideContextProperties(Map<String, Object> contextProperties) {
- - contextProperties.putAll(getProperties(PropertiesType.CONTEXT));
- - }
- -
- - @Override
- public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
- return !isPrimitiveType(type) && !Map.class.isAssignableFrom(type) && super.isReadable(type, genericType, annotations,
- mediaType);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement