Uploaded image for project: 'Nuxeo Java Client'
  1. Nuxeo Java Client
  2. JAVACLIENT-162

Remove static modifier on entityTypeToClass

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0
    • Component/s: API

      Description

      Currently the NuxeoConverterFactory owns the static field entityTypeToClass used to determine java type from entity-type field present in JSON response.

      This field is static because we need it in EntityValueDeserializer to determine type of fetched/resolved properties and type of context properties.

      We want to avoid the static modifier by leveraging Jackson's attributes feature.

      We will need to give this Map to Jackson like this:

      ObjectReader objectReader = objectMapper.readerFor(javaType);
      return objectReader.withAttribute("entityTypeToClass", entityTypeToClass).readValue(reader);
      

      And then get it in deserializer like this:

      public Object deserialize(JsonParser jp, DeserializationContext ctx) throws IOException {
        Map<String, Class<?>> entityTypeToClass = (Map<String, Class<?>>) ctx.getAttribute("entityTypeToClass");
        ...
      }
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: