spring-projects / spring-projects/spring-data-rest

org.springframework.hateoas.hal.Jackson2HalModule provide new constructor. i think use that is good idea [DATAREST-1339]

Open
#1,698 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: enhancement
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

jiacheng Yang opened DATAREST-1339 and commented

org.springframework.hateoas.hal.Jackson2HalModule provided a new constructor.

the constructor can encapsulate a springBeanFactory to create Jackson2HalModule Bean

if use that. can autowired properites to a custom JsonDeserializer. and i does not register my JsonDeserializer to spring bean factory. 
Because register my JsonDeserializer will affect the entire project, just a domain property JsonDeserializer. 

show some code.

/**
 * properties
 */
@JsonDeserialize(using = PropertiesJsonDeserializer.class)
private Map<String, Object> properties = new LinkedHashMap<>();

/**
 * JsonDeserializer - properties
 */
@RequiredArgsConstructor
public static class PropertiesJsonDeserializer extends JsonDeserializer<Map<String, Object>> {
   @Inject
   private final ConversionService defaultConversionService;

   @Override
   public Map<String, Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
      Assert.nonNull(defaultConversionService, "defaultConversionService must not be null");
      // dosomething
      return something;
   }
}



 i read Jackson2HalModule source code. it will first use beanFactory to instance bean, i think that good idea. i hope spring data rest can direct support this method. i dislike my project exist redundant configuration. but you have discretion.

just suggest. thank you every much. and thank provid 'spring-data' project. you and your team is big hero


Affects: 3.0.13 (Kay SR13)

Referenced from: pull request https://github.com/spring-projects/spring-data-rest/pull/304

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.