jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Jackson JSON Processor
  • JACKSON-33

ObjectMapper: allow use of non-default constructors

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 0.9.4, 0.9.5, 1.0.0, 1.1
  • Fix Version/s: 1.2
  • Component/s: None
  • Labels:
    None

Description

Now that ObjectMapper's deserialization works quite well (minus annotation support, as of 0.9.6), it would be nice to improve construction of POJOs.
Specifically it would be good to allow using a non-default constructors (that is, constructor that takes one or more arguments). This feature would allow not having to add setters whose only purpose is to support data deserialization; similar to how dependency injection frameworks work.

The main open questions are:

(a) How to recognize that such a constructor should be used
(b) How to bind constuctor arguments.

Given that local names for constructor args are not guaranteed to be accessible (not sure if they are ever stored, but they need not be), for (b) it seems sensible to require annotations to be added.

As to (a) here is the initial thought:

  • If there are multiple acceptable constructor, an annotation is required to be used
  • If there is only one constructor, that can be used without annotation, as long as the arguments are properly annotated?

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Tatu Saloranta added a comment - 15/Jun/09 12:03 AM

Looks like this won't make it in 1.1, but will be a top priority for 1.2 – esp. since it will be required for proper object serialization support (or at least some of pre-requisites will be).

Show
Tatu Saloranta added a comment - 15/Jun/09 12:03 AM Looks like this won't make it in 1.1, but will be a top priority for 1.2 – esp. since it will be required for proper object serialization support (or at least some of pre-requisites will be).
Hide
Permalink
Tatu Saloranta added a comment - 30/Jun/09 12:36 AM

Will be one of required features for 1.2, along with mix-in annotations.

Show
Tatu Saloranta added a comment - 30/Jun/09 12:36 AM Will be one of required features for 1.2, along with mix-in annotations.
Hide
Permalink
Tatu Saloranta added a comment - 27/Jul/09 12:50 AM

Implemented as detailed above, with exception that @JsonCreator is always required, as well as @JsonProperty annotation for all parameters.

Show
Tatu Saloranta added a comment - 27/Jul/09 12:50 AM Implemented as detailed above, with exception that @JsonCreator is always required, as well as @JsonProperty annotation for all parameters.
Hide
Permalink
Tatu Saloranta added a comment - 03/Aug/09 10:47 PM

Included in 1.2.0 release.

Show
Tatu Saloranta added a comment - 03/Aug/09 10:47 PM Included in 1.2.0 release.

People

  • Assignee:
    Tatu Saloranta
    Reporter:
    Tatu Saloranta
Vote (1)
Watch (1)

Dates

  • Created:
    14/Jan/09 6:31 PM
    Updated:
    03/Aug/09 10:47 PM
    Resolved:
    27/Jul/09 1:01 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.