Skip to content

Conversation

@slinkydeveloper
Copy link
Member

@slinkydeveloper slinkydeveloper commented Nov 19, 2020

This PR moves PojoCloudEventData from Jackson in core and generalize it, allowing users to carry their pojos as CloudEvent data.

You can use PojoCloudEventData#wrap to wrap the pojo, together with the marshalling function.

For example you can do PojoCloudEventData.wrap(myPojo, objectMapper::writeValueAsBytes) to wrap myPojo in a CloudEventData, expliciting the objectMapper::writeValueAsBytes as the method that will serialize the pojo, if needed, back to bytes.

For a sample use case, look at: https://github.com/cloudevents/sdk-java/pull/288/files#diff-d32fb9f764f16209b2cb69f1239b4309975c5601affe825cc4ff9428eca42d1bR64

Signed-off-by: Francesco Guardiani francescoguard@gmail.com

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper slinkydeveloper added the enhancement New feature or request label Nov 19, 2020
@slinkydeveloper slinkydeveloper added this to the 2.0.0.CR1 milestone Nov 19, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper slinkydeveloper changed the title Add a static method to wrap a pojo in PojoCloudEventData Move PojoCloudEventData in core Nov 19, 2020
slinkydeveloper added a commit to slinkydeveloper/sdk-java that referenced this pull request Nov 19, 2020
…events#289

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper
Copy link
Member Author

Related PR #291

@johanhaleby
Copy link
Contributor

I've added some comments, otherwise I think this would be a nice contribution.

@slinkydeveloper slinkydeveloper merged commit c9b3fa4 into cloudevents:master Nov 23, 2020
@slinkydeveloper slinkydeveloper deleted the public_pojo_cloudevent_data branch November 23, 2020 14:59
slinkydeveloper added a commit to slinkydeveloper/sdk-java that referenced this pull request Nov 24, 2020
…events#289

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
slinkydeveloper added a commit that referenced this pull request Nov 24, 2020
* Add the method `BytesCloudEventData#wrap` to be consistent with #289

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Removed all usages of constructor

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants