Compare commits

..

741 Commits

Author SHA1 Message Date
Pierangelo Di Pilato 0d96691f6d
Migrate from OSSRH to Central Portal (#698)
Ref: https://central.sonatype.org/publish/publish-portal-maven/

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2025-06-26 09:44:36 +02:00
Sleiman Jneidi c8a22b5175
build: upgrage to protobuf sdk 4.31.1 (#695)
Signed-off-by: Sleiman <sleiman.jneidi@apple.com>
Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2025-06-20 14:56:34 +02:00
Sleiman Jneidi 57f9867a5c
build: remove maven cache (#696)
Signed-off-by: Sleiman <sleiman.jneidi@apple.com>
2025-06-20 09:43:41 +02:00
dependabot[bot] 43f0d5b138
Bump nokogiri from 1.16.5 to 1.18.3 in /docs (#685)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.5 to 1.18.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/v1.18.3/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.16.5...v1.18.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-12 08:18:56 +01:00
dependabot[bot] efe7e01b75
Bump org.apache.maven.plugins:maven-antrun-plugin from 3.0.0 to 3.1.0 (#682)
Bumps [org.apache.maven.plugins:maven-antrun-plugin](https://github.com/apache/maven-antrun-plugin) from 3.0.0 to 3.1.0.
- [Commits](https://github.com/apache/maven-antrun-plugin/compare/maven-antrun-plugin-3.0.0...maven-antrun-plugin-3.1.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-antrun-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-27 10:03:16 +01:00
dependabot[bot] 188c3c7085
Bump org.apache.qpid:proton-j from 0.33.7 to 0.34.1 (#678)
Bumps org.apache.qpid:proton-j from 0.33.7 to 0.34.1.

---
updated-dependencies:
- dependency-name: org.apache.qpid:proton-j
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-20 13:13:12 +01:00
dependabot[bot] 659bb8cc01
Bump org.apache.kafka:kafka-clients from 3.0.0 to 3.7.1 in /kafka (#681)
Bumps org.apache.kafka:kafka-clients from 3.0.0 to 3.7.1.

---
updated-dependencies:
- dependency-name: org.apache.kafka:kafka-clients
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-20 13:12:46 +01:00
Kristiyan Marinov 9981635e7d
fix: disallow empty 'subject' context attribute (#679)
Specification clearly states that 'subject' is optional but if present, MUST be non-empty
(spec at https://github.com/cloudevents/spec/blob/v1.0/spec.md#subject)

Signed-off-by: Kristiyan Marinov <kristiyanm@gmail.com>
2024-11-04 09:53:36 +01:00
dependabot[bot] b54df5ca0c
Bump io.projectreactor:reactor-core from 3.5.1 to 3.6.11 (#677)
Bumps [io.projectreactor:reactor-core](https://github.com/reactor/reactor-core) from 3.5.1 to 3.6.11.
- [Release notes](https://github.com/reactor/reactor-core/releases)
- [Commits](https://github.com/reactor/reactor-core/compare/v3.5.1...v3.6.11)

---
updated-dependencies:
- dependency-name: io.projectreactor:reactor-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-30 06:47:37 +01:00
dependabot[bot] a3decf768c
Bump org.slf4j:slf4j-simple from 1.7.36 to 2.0.16 (#674)
Bumps org.slf4j:slf4j-simple from 1.7.36 to 2.0.16.

---
updated-dependencies:
- dependency-name: org.slf4j:slf4j-simple
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-29 08:01:59 +01:00
dependabot[bot] 215e67f2c3
Bump rexml from 3.3.6 to 3.3.9 in /docs (#675)
Bumps [rexml](https://github.com/ruby/rexml) from 3.3.6 to 3.3.9.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.3.6...v3.3.9)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-29 08:01:19 +01:00
dependabot[bot] 514e00d75b
Bump rexml from 3.2.8 to 3.3.6 in /docs (#665)
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.8 to 3.3.6.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.8...v3.3.6)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-22 14:24:28 +02:00
dependabot[bot] f7ac215bf1
Bump org.eclipse.jetty:jetty-server in /examples/basic-http (#672)
Bumps org.eclipse.jetty:jetty-server from 9.4.51.v20230217 to 9.4.55.v20240627.

---
updated-dependencies:
- dependency-name: org.eclipse.jetty:jetty-server
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-22 14:23:36 +02:00
dependabot[bot] 5f4abd144a
Bump org.apache.avro:avro from 1.11.3 to 1.11.4 in /formats/avro-compact (#671)
Bumps org.apache.avro:avro from 1.11.3 to 1.11.4.

---
updated-dependencies:
- dependency-name: org.apache.avro:avro
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-08 17:25:38 +02:00
github-actions[bot] 8d59d29bb1
Bump to 4.0.1 (#656)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2024-10-02 19:49:23 +02:00
Rohan Mallya 6ab42de007
docs: correcting import to EventFormatProvider (#658)
Signed-off-by: Rohan R Mallya <bangalorerohan@gmail.com>
2024-10-02 19:48:40 +02:00
dependabot[bot] 2e87988d0c
Bump org.apache.maven.plugins:maven-install-plugin from 2.5.1 to 3.1.3 (#664)
Bumps [org.apache.maven.plugins:maven-install-plugin](https://github.com/apache/maven-install-plugin) from 2.5.1 to 3.1.3.
- [Release notes](https://github.com/apache/maven-install-plugin/releases)
- [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-2.5.1...maven-install-plugin-3.1.3)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-install-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-02 19:48:09 +02:00
David Simansky 6d958b69d4
Fix cloudevents-sql artifactId in bom (#669)
Signed-off-by: David Simansky <dsimansk@redhat.com>
2024-10-02 19:47:43 +02:00
dependabot[bot] 1de03ad38a
Bump org.apache.rocketmq:rocketmq-client-java from 5.0.4 to 5.0.7 (#653)
Bumps [org.apache.rocketmq:rocketmq-client-java](https://github.com/apache/rocketmq-clients) from 5.0.4 to 5.0.7.
- [Release notes](https://github.com/apache/rocketmq-clients/releases)
- [Commits](https://github.com/apache/rocketmq-clients/compare/java-5.0.4...java-5.0.7)

---
updated-dependencies:
- dependency-name: org.apache.rocketmq:rocketmq-client-java
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-03 14:48:32 +02:00
Pierangelo Di Pilato 4c5d0efb89
Make CloudEventValidatorProvider thread safe (#650)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2024-07-02 17:39:05 +02:00
github-actions[bot] 01a9111d8b
Bump to 4.0.0 in docs (#649)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2024-07-01 20:29:40 +02:00
Pierangelo Di Pilato e056d1b2d8
Allow bumping versions in `/docs` only (#648)
This will allow changing the version in the documentation website
when a new release is published.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2024-07-01 17:24:48 +02:00
github-actions[bot] efdf0ba866
Bump to 4.1.0-SNAPSHOT (#645)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2024-07-01 12:10:47 +02:00
github-actions[bot] bd90d903ce
Bump to 4.0.0-SNAPSHOT (#644)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2024-07-01 11:41:33 +02:00
dependabot[bot] 52a98d778c
Bump rexml from 3.2.5 to 3.2.8 in /docs (#635)
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.2.8.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.2.8)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 10:59:57 +02:00
Calum Murray 010627e784
CE SQL v1 (#641)
- add exception factory for cesql exceptions
- extend EvaluationResult to be usable internally
- expressions use results instead of a thrower interface
- functions use results instead of a thrower interface
- parser handles not equals correctly, does not eagerly evaluate when there may be an error
- parser handles integer literals properly
- updated test files to test v1 spec

Signed-off-by: Calum Murray <cmurray@redhat.com>
Co-authored-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2024-06-21 17:28:26 +02:00
Juan Martinez a7904823c3
fix: invalid automatic module name (#639)
Inspired by [Automatic-Module-Name: Calling All Java Library Maintainers](https://dzone.com/articles/automatic-module-name-calling-all-java-library-maintainers), I added the module names for the non-specified modules on their respective `pom.xml` file

Signed-off-by: Juan MARTINEZ <Jummartinezro@users.noreply.github.com>
2024-06-21 09:24:33 +02:00
Mickaël Schoentgen e5a35ac472
doc: update & uniformize package version (#640)
Signed-off-by: Mickaël Schoentgen <Mickael.Schoentgen@hyland.com>
2024-06-20 12:08:07 +02:00
dependabot[bot] 4d204cef89
Bump org.xmlunit:xmlunit-core from 2.9.0 to 2.10.0 in /formats/xml (#631)
Bumps [org.xmlunit:xmlunit-core](https://github.com/xmlunit/xmlunit) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/xmlunit/xmlunit/releases)
- [Changelog](https://github.com/xmlunit/xmlunit/blob/main/RELEASE_NOTES.md)
- [Commits](https://github.com/xmlunit/xmlunit/compare/v2.9.0...v2.10.0)

---
updated-dependencies:
- dependency-name: org.xmlunit:xmlunit-core
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-14 11:04:06 +02:00
dependabot[bot] 43afb6ceaa
Bump nokogiri from 1.16.3 to 1.16.5 in /docs (#632)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.16.3 to 1.16.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.16.3...v1.16.5)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-14 11:03:01 +02:00
dependabot[bot] 9c6e7fd11e
Bump io.vertx:vertx-core from 4.3.7 to 4.5.3 in /http/vertx (#622)
Bumps [io.vertx:vertx-core](https://github.com/eclipse/vert.x) from 4.3.7 to 4.5.3.
- [Commits](https://github.com/eclipse/vert.x/compare/4.3.7...4.5.3)

---
updated-dependencies:
- dependency-name: io.vertx:vertx-core
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-09 10:13:49 +02:00
github-actions[bot] 98deac1599
Bump to 3.1.0-SNAPSHOT (#613)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2024-03-26 09:59:22 +01:00
Pierangelo Di Pilato 05baf9be8a
Run workflows on any major version branch (#615)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2024-03-26 08:42:45 +01:00
Pierangelo Di Pilato 3add823e00
Run workflows on any major version branch (#614)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2024-03-26 08:39:35 +01:00
dependabot[bot] 5a03173dde
Bump org.apache.maven.plugins:maven-source-plugin from 2.2.1 to 3.3.0 (#608)
Bumps [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin) from 2.2.1 to 3.3.0.
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-2.2.1...maven-source-plugin-3.3.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-source-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-26 08:12:40 +01:00
dependabot[bot] 9ee16fb48c
Bump nokogiri from 1.13.10 to 1.16.3 in /docs (#609)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.10 to 1.16.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.10...v1.16.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-26 08:11:52 +01:00
dependabot[bot] 0db4446163
Bump com.github.hanleyt:jersey-junit from 2.1.0 to 2.2.0 (#584)
Bumps [com.github.hanleyt:jersey-junit](https://github.com/hanleyt/jersey-junit) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/hanleyt/jersey-junit/releases)
- [Commits](https://github.com/hanleyt/jersey-junit/compare/2.1.0...2.2.0)

---
updated-dependencies:
- dependency-name: com.github.hanleyt:jersey-junit
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2024-03-11 15:57:25 +01:00
touchkey 111fb55cfd
feat: Customizing Cloudevents validation (#594)
Add SPI for custom CloudEvent validation.

Signed-off-by: vbhat6 <vinayas_bhat@intuit.com>
2024-02-15 07:48:55 +01:00
Matej Vasek 55fddb35fc
feat: JSON format to assume JSON content-type where possible (#604)
Signed-off-by: Matej Vašek <mvasek@redhat.com>
2024-02-08 09:49:19 +01:00
Calum Murray 7b9d020acc
Update cesql TCK tests (#603)
Signed-off-by: Calum Murray <cmurray@redhat.com>
2024-01-31 11:51:03 +01:00
Doug Davis fb11b94f2b
Add link to CloudEvent security mailing list (#599)
Signed-off-by: Doug Davis <dug@microsoft.com>
2023-10-16 15:26:53 +02:00
Boris Stumm eaef3becdd
#588 Update jackson to 2.15.2 (#589)
Signed-off-by: Boris Stumm <bs@boris-stumm.de>
2023-10-02 10:08:48 +02:00
dependabot[bot] b30324e916
Bump org.apache.avro:avro from 1.11.2 to 1.11.3 in /formats/avro-compact (#593)
Bumps org.apache.avro:avro from 1.11.2 to 1.11.3.

---
updated-dependencies:
- dependency-name: org.apache.avro:avro
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-02 10:08:22 +02:00
Doug Davis 1f9fa13231
Align SDK governance docs (#590)
Related to https://github.com/cloudevents/spec/pull/1226

Signed-off-by: Doug Davis <dug@microsoft.com>
2023-09-28 09:29:59 +02:00
dependabot[bot] a135755ec6
Bump jackson-dataformat-yaml from 2.11.2 to 2.15.2 (#577)
Bumps [jackson-dataformat-yaml](https://github.com/FasterXML/jackson-dataformats-text) from 2.11.2 to 2.15.2.
- [Commits](https://github.com/FasterXML/jackson-dataformats-text/compare/jackson-dataformats-text-2.11.2...jackson-dataformats-text-2.15.2)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-21 09:19:35 +02:00
dependabot[bot] 677a2c2628
Bump jetty-server in /examples/basic-http (#579)
Bumps [jetty-server](https://github.com/eclipse/jetty.project) from 9.4.41.v20210516 to 9.4.51.v20230217.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.41.v20210516...jetty-9.4.51.v20230217)

---
updated-dependencies:
- dependency-name: org.eclipse.jetty:jetty-server
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-21 09:19:06 +02:00
dependabot[bot] 826e099fc0
Bump io.openliberty.arquillian:arquillian-liberty-managed-jakarta-junit (#582)
Bumps [io.openliberty.arquillian:arquillian-liberty-managed-jakarta-junit](https://github.com/OpenLiberty/arquillian-liberty-dependencies) from 2.1.0 to 2.1.4.
- [Release notes](https://github.com/OpenLiberty/arquillian-liberty-dependencies/releases)
- [Commits](https://github.com/OpenLiberty/arquillian-liberty-dependencies/compare/arquillian-liberty-jakarta-dependencies-2.1.0...arquillian-liberty-jakarta-dependencies-2.1.4)

---
updated-dependencies:
- dependency-name: io.openliberty.arquillian:arquillian-liberty-managed-jakarta-junit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-21 09:18:34 +02:00
dependabot[bot] 76366338fc
Bump truth-proto-extension from 1.1 to 1.1.5 (#580)
Bumps truth-proto-extension from 1.1 to 1.1.5.

---
updated-dependencies:
- dependency-name: com.google.truth.extensions:truth-proto-extension
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-20 18:03:41 +02:00
Alex Collins 4ef304115a
[working-draft] Support Avro Compact Format (#578)
Add support for working-draft spec Avro compact format: 777d0c0398

Signed-off-by: Alex Collins <alex_collins@intuit.com>
2023-07-20 18:02:59 +02:00
dependabot[bot] 582feed520
Bump maven-gpg-plugin from 1.6 to 3.1.0 (#564)
Bumps [maven-gpg-plugin](https://github.com/apache/maven-gpg-plugin) from 1.6 to 3.1.0.
- [Commits](https://github.com/apache/maven-gpg-plugin/compare/maven-gpg-plugin-1.6...maven-gpg-plugin-3.1.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-gpg-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-23 12:08:54 +02:00
github-actions[bot] 5ef1088a19
Bump to 3.0.0-SNAPSHOT (#571)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierDipi@users.noreply.github.com>
2023-05-23 10:55:49 +02:00
Aaron Ai 698cdf7ad4
feat: add rocketmq binding (#554)
Spec details: a6978cf562/rocketmq-cloudevents-binding/rocketmq-transport-binding.md

Signed-off-by: Aaron Ai <yangkun.ayk@alibaba-inc.com>
2023-05-23 10:49:08 +02:00
skepticoitusInteruptus 4ebeab0e0f
Refactor to Facilitate Decoupling from Concrete Implementations of EventFormat (#539)
- Introduce ContentType enum
- Resolve formats by using the ContentType enum

Signed-off-by: Randi Sheaffer-Klass <97033958+skepticoitusInteruptus@users.noreply.github.com>
2023-04-21 10:41:10 +02:00
Jem Day 4c81f3eacc
Make ProtoCloudEventData consistent (#535)
Modified ProtoCloudEventData to always return a 
Protobuf Any object - this ensures it is coherent with
the Protobuf CloudEvent format specification.

It remains possible to wrap any Protobuf 'Message'
object directly (which includes an 'Any') as a
convienience to reduce application code.

Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
2023-03-10 09:35:24 +01:00
Pierangelo Di Pilato 569e025cf0
Fix javadoc build (#529) (#534)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2023-03-06 18:25:53 +01:00
Jem Day 3614a4f5f4
Fixed Protobuf data corruption for CloudEvent serialized/deserialized several times (#524)
Fixed issue where mutiple serialize/de-serialize operations
would result in corrupted data if the data was a protobuf
message object.

- Introduced equality checks for ProtoDataWrapper.
- Refactored and cleaned up data-wrappers.

Fixes https://github.com/cloudevents/sdk-java/issues/523

Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
2023-02-27 11:48:07 +01:00
mxsm d64aff7327
[#521] Remove unused imports (#522)
Signed-off-by: mxsm <ljbmxsm@gmail.com>
2023-02-20 18:06:28 +01:00
dependabot[bot] d1cff75230
Bump activesupport from 6.0.6 to 6.0.6.1 in /docs (#517)
Bumps [activesupport](https://github.com/rails/rails) from 6.0.6 to 6.0.6.1.
- [Release notes](https://github.com/rails/rails/releases)
- [Changelog](https://github.com/rails/rails/blob/v7.0.4.2/activesupport/CHANGELOG.md)
- [Commits](https://github.com/rails/rails/compare/v6.0.6...v6.0.6.1)

---
updated-dependencies:
- dependency-name: activesupport
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-20 08:42:50 +01:00
Ruben Romero Montes 1591cb337a
[#465] Upgrade Quarkus examples with binary and structured events (#515)
Signed-off-by: ruromero <rromerom@redhat.com>
2023-01-24 16:54:22 +01:00
Pierangelo Di Pilato f71303b7b7
Switch default branch to main (#506)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2023-01-12 19:03:51 +01:00
Pierangelo Di Pilato d59b33307a
Run tests before deploy on Java 17 (#504)
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2023-01-10 16:49:47 +01:00
dependabot[bot] e0d1961f35
Bump nokogiri from 1.13.9 to 1.13.10 in /docs (#496)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.13.10.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.13.10)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-10 16:41:29 +01:00
dependabot[bot] 7c6b52ab30
Bump reactor-core from 3.4.21 to 3.5.1 (#499)
Bumps [reactor-core](https://github.com/reactor/reactor-core) from 3.4.21 to 3.5.1.
- [Release notes](https://github.com/reactor/reactor-core/releases)
- [Commits](https://github.com/reactor/reactor-core/compare/v3.4.21...v3.5.1)

---
updated-dependencies:
- dependency-name: io.projectreactor:reactor-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-10 16:10:42 +01:00
Jem Day 433ec5b274
Initial Implementation of XML Format (#448)
Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>
Signed-off-by: Jem Day <Jem.Day@cliffhanger.com>
2023-01-10 09:48:36 +01:00
Doug Davis 40fe91a5e0
Use UTF-8 when using getBytes (#491)
Closes #488

Signed-off-by: Doug Davis <dug@microsoft.com>
2023-01-05 18:01:14 +01:00
Pierangelo Di Pilato a43f90f4e2
Create dependabot.yml 2023-01-02 15:19:06 +01:00
dependabot[bot] e488269510
Bump nokogiri from 1.13.6 to 1.13.9 in /docs (#486)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.6 to 1.13.9.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.6...v1.13.9)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 15:11:24 +01:00
Fabio José 7d50c7fc7a
Bump Vertx to 4.3.7 (#495)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-3167773

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
2023-01-02 15:10:38 +01:00
Averi Kitsch f1a86af656
Fix curl command for Spring example (#478)
Signed-off-by: Averi Kitsch <akitsch@google.com>
2023-01-02 13:36:30 +01:00
Doug Davis 354f7a16ef
Upgrade kafka, protobuf, and vert.x versions (#492)
Closes #489

Signed-off-by: Doug Davis <dug@microsoft.com>
2022-12-09 12:35:19 +01:00
Pierangelo Di Pilato 9132a13d81
Remove deprecated constructor usage for JsonCloudEventData (#483)
Fixes #482

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-10-12 08:58:41 +02:00
dependabot[bot] a491c85eb2
Bump tzinfo from 1.2.8 to 1.2.10 in /docs (#467)
Bumps [tzinfo](https://github.com/tzinfo/tzinfo) from 1.2.8 to 1.2.10.
- [Release notes](https://github.com/tzinfo/tzinfo/releases)
- [Changelog](https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md)
- [Commits](https://github.com/tzinfo/tzinfo/compare/v1.2.8...v1.2.10)

---
updated-dependencies:
- dependency-name: tzinfo
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-12 08:56:14 +02:00
Frédéric Déléchamp 6362bfbcd6
Strip parameters from data content types to assess if it's JSON format (#484)
Signed-off-by: Frederic Delechamp <fdelechamp@guidewire.com>
2022-10-06 10:42:37 +02:00
Alex Butcher f08a099ed9
Restful-ws jakarta ee9 namespace support (#469)
* Replace javax restful-ws namespace usage with jakarata in own module
* Add microprofile with openliberty example using new jar
* Update gitignore to cover all copied directories
* Update Jersey Version to support jakarta.* namespace packages
* Port jersey integration tests from javax.* to jakarta.*
* Undo changes to existing integration test package names
* Add Integration test for Microprofile/Liberty for Jee9 package
* Add documentation for new Jakarta package

Signed-off-by: alex-butcher <21243172+abutch3r@users.noreply.github.com>
2022-09-27 09:16:03 +02:00
Vikram Vuppla 4139fb7e57
Fix typo in word Covert (#480)
Signed-off-by: Vikram Vuppla <naga.vicky@gmail.com>
2022-09-19 17:31:31 +02:00
Gerard Klijs adde53c817
Correct URL to naming-conventions (#477)
Signed-off-by: Gerard Klijs <gerard.klijs@axoniq.io>
2022-09-14 15:46:09 +02:00
Jorge Oliva 0dc10251ff
Fix example in "Materialize an Extension" (#475)
Was using `ExtensionParser` instead `ExtensionProvider`

Signed-off-by: Jorge Oliva <Jorge.OlivaFernandez@santander.co.uk>
2022-09-14 11:39:25 +02:00
github-actions[bot] b9eaa2fcaa
Bump to 2.5.0-SNAPSHOT (#474)
Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: pierDipi <pierdipi@redhat.com>
2022-09-06 15:52:34 +02:00
Isaac Aymerich f8d27b08bf
Support dynamic JSON data content type (#471)
Now checks if `datacontenttype` matches the regex:

`^(application|text)\/([a-zA-Z]+\+)?json$")`

This regex support 
`application/foobar+json`
or standard
```
application/json
text/json
```

Signed-off-by: Isaac Aymerich <isaac.aymerich@roche.com>
2022-09-05 13:14:38 +02:00
Matej Vasek 9125136530
chore: update Quarkus example (#466)
* Server accepts both: binary and structured encoded events.
* Emitter contains comment describing how to switch between binary and
  structured encoding for emitted events.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2022-07-19 12:27:44 +02:00
Gustavo Tedesco f35e6e610a
CVE-2020-36518 - bump jackson from 2.11.2 to 2.13.3 (#464)
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-36518

Signed-off-by: Gustavo Tedesco <gustavo.tedesco@unico.io>
2022-07-13 17:16:38 +02:00
Pierangelo Di Pilato 45ec85f8c1
Optimize `isCloudEventsHeader` check (#445)
Instead of using:
```java
key.substring(0, CE_PREFIX.length()).toLowerCase().startsWith(CE_PREFIX);
```
we can just use:
```java
key.regionMatches(true /* ignoreCase */, 0, CE_PREFIX, 0, CE_PREFIX.length());
```

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-07-13 10:18:17 +02:00
dependabot[bot] 1d87fb7191
Bump nokogiri from 1.13.3 to 1.13.6 in /docs (#457)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.3 to 1.13.6.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.3...v1.13.6)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-25 16:06:16 +02:00
Snyk bot 8f9b741306
[Snyk] Security upgrade io.vertx:vertx-core from 4.0.0 to 4.2.5 (#455)
* fix: http/vertx/pom.xml to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1020439
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1070799
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1082234
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1082235
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1082236
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1083991
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1089809
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1317097
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1584063
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-1584064
- https://snyk.io/vuln/SNYK-JAVA-IONETTY-2314893

* Bump Vert.x to 4.2.5

Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-04-08 11:13:07 +02:00
dependabot[bot] 2dd8ba95dd
Bump nokogiri from 1.12.5 to 1.13.3 in /docs (#447)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.12.5 to 1.13.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.12.5...v1.13.3)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-04-01 19:01:24 +02:00
Pierangelo Di Pilato 1c29726e8c
Add `CONTRIBUTING.md` and `MAINTAINERS.md` files (#454)
These 2 new files are based on the existing `pr_guidelines.md`
and `maintainers_guide.md`

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-04-01 19:00:37 +02:00
mEstrazulas 6681205733
Fix Spring structured example (#451)
Signed-off-by: Micael Vianna <estrazulas@gmail.com>
Signed-off-by: Micael Estrazulas Vianna <m.vianna@kigroup.de>
2022-03-18 23:24:37 +01:00
Jem Day a4bc7a8368
Protobuf: Enhance textual content-types detection (#444)
- Move content-type introspection in a separate support class.
- Add unit tests to ensure introspection is correct.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>
2022-01-31 10:18:22 +01:00
github-actions[bot] 4784f03e8c
Bump to 2.4.0-SNAPSHOT (#439)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: pierDipi <pierdipi@redhat.com>
2021-12-21 12:18:07 +01:00
Pierangelo Di Pilato ace6859ae0
Bump version to 2.3.0 (#437)
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-12-21 12:06:57 +01:00
Pierangelo Di Pilato cc786251d5
Handle NullNode for optional attributes in Jackson CloudEventDeserializer (#432)
In `getOptionalStringNode` we should handle `JsonNode`s that are
instances of `NullNode`.

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-12-21 11:22:02 +01:00
Myeonghyeon-Lee ceb06757a3
Ignore invalid extension names in jackson CloudEventDeserializer (#429)
Signed-off-by: mhyeon-lee <mhyeon.lee@navercorp.com>
2021-12-10 10:26:47 +01:00
Pierangelo Di Pilato 8d91cdaee6
Run tests with Java 17 (#426)
Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-12-01 09:05:02 +01:00
Pierangelo Di Pilato d00ad967c0
Fix the Java Doc build (#424)
- https://vertx.io/docs/apidocs/ returns 404, so removing it
- Fix Java Doc error for missing `@param`

Signed-off-by: Pierangelo Di Pilato <pdipilat@redhat.com>
2021-11-17 16:55:27 +01:00
Dave Syer 9231e6d230
Add example of Spring WebClient usage (#418)
- Add example of WebClient usage
- Add additional test case with WebClient usage

Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-11-17 16:25:59 +01:00
Joke de Buhr a94bc5c81c
Close input stream on CloudEventHttpMessageReader (#421)
Signed-off-by: Joke de Buhr <joke.debuhr@eventim.de>
2021-11-03 09:54:38 +01:00
Dmitrii Bocharov 32adfe9123
Fix NPE in CloudEventDeserializer when deserializing header with null value (#415)
Signed-off-by: Dmitrii Bocharov <dmitrii.bocharov@embedit.cz>
2021-11-03 08:28:54 +01:00
dependabot[bot] 0277ee4ae4
Bump spring-framework-bom in /examples/restful-ws-spring-boot (#423)
Bumps [spring-framework-bom](https://github.com/spring-projects/spring-framework) from 5.2.8.RELEASE to 5.2.9.RELEASE.
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE)

---
updated-dependencies:
- dependency-name: org.springframework:spring-framework-bom
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-03 08:26:35 +01:00
dependabot[bot] 202849307c
Bump addressable from 2.7.0 to 2.8.0 in /docs (#406)
Bumps [addressable](https://github.com/sporkmonger/addressable) from 2.7.0 to 2.8.0.
- [Release notes](https://github.com/sporkmonger/addressable/releases)
- [Changelog](https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sporkmonger/addressable/compare/addressable-2.7.0...addressable-2.8.0)

---
updated-dependencies:
- dependency-name: addressable
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-03 08:07:20 +01:00
dependabot[bot] 624ac693d8
Bump nokogiri from 1.11.5 to 1.12.5 in /docs (#419)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.5 to 1.12.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.5...v1.12.5)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-03 08:06:43 +01:00
dependabot[bot] 5a323942d3
Bump jetty-server in /examples/basic-http (#403)
Bumps [jetty-server](https://github.com/eclipse/jetty.project) from 9.4.38.v20210224 to 9.4.41.v20210516.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.38.v20210224...jetty-9.4.41.v20210516)

---
updated-dependencies:
- dependency-name: org.eclipse.jetty:jetty-server
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 12:22:52 +02:00
dependabot[bot] 1587708805
Bump spring-framework-bom (#382)
Bumps [spring-framework-bom](https://github.com/spring-projects/spring-framework) from 5.2.8.RELEASE to 5.2.9.RELEASE.
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.2.8.RELEASE...v5.2.9.RELEASE)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-05 12:22:46 +02:00
Francesco Guardiani 06c4ec5385
Moved exception factory methods internally (#402)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-07-05 11:43:46 +02:00
Nicolas Vervelle 73a3c370d5
build: provide a Bill of Materials artifact for easier integration in projects (#405)
Signed-off-by: Nicolas Vervelle <nicolas.vervelle@quicksign.com>
2021-06-28 09:30:41 +02:00
github-actions[bot] 722f5205b3
Bump to 2.3.0-SNAPSHOT (#400)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-06-17 12:18:55 +02:00
github-actions[bot] 8ad857d8c7
Bump to 2.2.0 (#399)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-06-17 12:05:04 +02:00
Francesco Guardiani baa9b5927a
[CESQL] Reorganize package implementation classes (#397)
* Move classes around to improve package organization

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

* Removed bad imports

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-06-15 10:31:14 +02:00
Francesco Guardiani c41a2c3ba7
Cleanup CloudEventUtils (#398)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-06-14 16:30:07 +02:00
Francesco Guardiani 3651cdae18
Add a method to simplify casting (#396)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-06-07 08:36:02 +02:00
dependabot[bot] ee4c85b1a1
Bump nokogiri from 1.11.1 to 1.11.5 in /docs (#393)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.11.1 to 1.11.5.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.11.1...v1.11.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-06-04 09:41:26 +02:00
Francesco Guardiani a0b0835180
[CESQL] Constant folding (#392)
* Added visitor for the expressions

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

* First constant folding draft

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

* Constant folding for unary expressions

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

* More testing
Constant folding for exists expression

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

* Little mistake

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

* Added a ParserBuilder

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-06-04 09:19:38 +02:00
Pei-Tang Huang 687e03bac5
Update the link to http4k Cloud Events module. (#394)
Signed-off-by: Pei-Tang Huang <tangtheone@gmail.com>
2021-05-26 09:36:30 +02:00
Francesco Guardiani 208b18c299
Build release branches too (#386)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-05-06 14:07:52 +02:00
Francesco Guardiani 9d45943844
Fix like expression (#381)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-05-03 10:05:26 +02:00
shnplr 0a1a03db64
fix: Update encoding for structured event (#384)
Signed-off-by: Paul Strachan <paul.strachan@det.nsw.edu.au>
2021-05-03 09:39:48 +02:00
dependabot[bot] 7f355d10c1
Bump rexml from 3.2.4 to 3.2.5 in /docs (#383)
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.4...v3.2.5)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-03 09:34:47 +02:00
Francesco Guardiani 3234e30e55
CESQL Benchmark (#380)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-04-30 11:01:02 +02:00
github-actions[bot] c8f10e9215
Bump to 2.2.0-SNAPSHOT (#378)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-04-28 15:50:41 +02:00
github-actions[bot] ba9ccad5d2
Bump to 2.1.0 (#377)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-04-28 15:24:41 +02:00
Francesco Guardiani 78355bb225
Fix #326 (#376)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-04-28 15:15:45 +02:00
Francesco Guardiani 2730ae4a13
Expression language (#363)
* Configured the sql package

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

* Bootstrap implementation

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

* Literal done

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

* More progress

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

* Progress

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

* Sync contract

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

* Fix type cohercion for event type system

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

* In expression + sync grammar

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

* Implemented binary expressions

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

* Implemented Like expression

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

* Big refactor

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

* More testing
Fix math

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

* Implemented all the functions!

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

* Refactored logical expressions implementation
More testing

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

* More coverage and tests

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

* Fixed ConcatFunction and added ConcatWSFunction

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

* Fixed IN type casting

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

* Added ABS function

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

* Fix SUBSTRING implementation

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

* More nits

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

* WIP Javadoc-ing

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

* Fix division by 0

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

* Bootstrapped TCK

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

* Added comparison operators to tck

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

* Added logical operators, case sensitivity and casting functions

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

* Copied all the tests to the tck

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

* Removed Java tests now covered by the TCK

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

* Added integer builtin test case

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

* Added fail fast evaluation mode

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

* More changes
More Javadoc

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

* Typo

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

* Fix bad javadoc

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

* Another CONCAT_WS test case

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

* Import yaml just for testing

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-04-28 14:58:55 +02:00
Johan Haleby 30fd6769eb
fix: Adding withoutData, withoutDataContentType and withoutDataSchema to CloudEventBuilder (#374)
Signed-off-by: Johan Haleby <johan.haleby@gmail.com>
2021-04-23 13:59:39 +02:00
dependabot[bot] ff07dd8315
Bump jetty-server in /examples/basic-http (#372)
Bumps [jetty-server](https://github.com/eclipse/jetty.project) from 9.4.35.v20201120 to 9.4.38.v20210224.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.35.v20201120...jetty-9.4.38.v20210224)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-19 12:38:51 +02:00
Erik Paulson 928ebcfd6f
formats: Add support for protobuf format (#348)
* formats: Add support for protobuf format

Adds support for the Protocol Buffer CloudEvent format defined at
https://github.com/cloudevents/spec/blob/v1.0.1/protobuf-format.md.

Compiles the Proto3 file taken from the spec repo into generated Java
protobuf classes. These classes are used to convert the SDK
representation of a CloudEvent to and from the protobuf format.

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Address feedback in PR #348

- Adds service file for event format autoloading
- Addresses some field access issues
- Treats unset fields as omitted
- Updates and adds documentation

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Add missing attribute writer methods for CloudEventBuilders

Without these methods, binary attributes are interpreted as
Strings instead of byte[].

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Added test data files.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* - Now executes tests related to wire-format files.
- Supports V03 dialect

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* - Added new ProtoCloudEventData construct to support proto message based data.
- Added some more test files.

- When the PR related to binary context attributes is merged we can extend the
test use-cases appropriately.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* - Merged changes related to binary context attributes.
- Modified proto format to process binary context attributes
- Added CloudEventData varient to hold proto messages (requires tests)
- Will add further tests once the failing test is addressed

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Added test for protobuf data

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Indicate that v0.3 events are supported by Protobuf Format

Even though the protobuf spec came out for v1, the attributes are
fairly easily mapped back to v0.3.

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Add missing comments; fix formatting; minor refactoring

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Create a full Protobuf CloudEventWriter

Converts the ProtoContextWriter class to a ProtoCloudEventWriter class
and modifies the format code to use it instead of manually writing
data to the output.

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* - Addressed Review Comments.
- Introduced a default ProtoDataWrapper
- Tests updated.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Address Review Comments

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Test cleanup and timezone testing

This does some tweaking to tests by moving to using assertj and fixing
whitespace. It also adds a new test to ensure that timezones are handled
correctly.

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

* Formatting cleanup

- Remove unecessary whitespace
- Fix Javadocs
- Delete unused code

Signed-off-by: Erik Paulson <epaulson@apexclearing.com>

Co-authored-by: Day, Jeremy(jday) <jday@paypal.com>
2021-04-19 09:24:26 +02:00
Pierangelo Di Pilato a4613c00d2
Avoid allocating an array on extension validation (#367)
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2021-04-06 10:14:08 +02:00
Pierangelo Di Pilato 69f0e20549
CloudEvents attribute names SHOULD NOT exceed 20 chars (#366)
As per spec [1], attribute names SHOULD NOT and not MUST NOT
exceed 20 characters in length.

[1] https://github.com/cloudevents/spec/blob/master/spec.md#attribute-naming-conventionthis

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2021-04-06 10:00:55 +02:00
Jem Day e2b13109e4
Throw exceptions when atempting to handling unsupport CloudEvent formats. (#362)
- Modfy logic that selects between structured and binary modes during reception.
- Introduced new test scenarios to veify behavior.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>
2021-03-26 09:55:23 +01:00
Jem Day 5e3bfc890f
Specification Compliant handling of numeric context attributes (#358)
* - Added tests case to verify expected handling of numeric context attributes
- Updated serializer.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* - Added @deprecated marker for CloudEventContextWriter.set(name, Number)
- Added use of new method for JSON serializer.

Cleanup of deprecated implementations can occur independantly.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Addressed Review Comments

- Now throws exception when non specification compliant numeric
  attribute values are received during deserialization.

- Added test cases to verify deserialization exceptions.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Address Review Comments

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Address Review Comment

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>
2021-03-24 16:58:33 +01:00
Jem Day 13f8b56618
Introduced support for Binary attribute types. (#353)
* Introduced support for Binary attribute types.

Added test data example
Added unit-test for JSON Format

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* documentation tweak

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* - Addressed review comment.
- Removed the withContextAttribute(string, Integer).
   - This should be a seperate PR, was mixed-in by accident.

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>

* Address review comments

Signed-off-by: Day, Jeremy(jday) <jday@paypal.com>
2021-03-10 11:29:38 +01:00
Dave Syer a419d8bba3
Add Spring Cloud Function sample (#356)
* Add Spring Cloud Function sample

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Fix example curl command with structured event

Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-03-08 15:08:16 +01:00
Dave Syer 47bed5616d
Flesh out the docs in the Spring module a bit (#355)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-03-08 14:39:17 +01:00
Dave Syer baba37ccfd
Regularize copyright headers (#354)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-03-05 10:19:47 +01:00
dependabot[bot] 32bcdcd3b9
Bump nokogiri from 1.10.10 to 1.11.1 in /docs (#347)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.10 to 1.11.1.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.10.10...v1.11.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-05 09:18:32 +01:00
Dave Syer 8b382734d9
Add support for RSockets with Spring (#349)
* Add support for RSockets with Spring

Also generically can support structured events with any Spring
API that works with Encoder and Decoder. There's a sample for
the RSocket case with a simple request-response echo server.

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Use supported mime types from format provider

Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-03-05 09:18:19 +01:00
Dave Syer f05418cba9
Allow user to enumerate supported content types (#350)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2021-03-01 11:02:54 +01:00
David Denton 23cd08fcfd
Fix #344 - add http4k references to docs (#345)
Signed-off-by: David Denton <denton.david@gmail.com>
2021-02-15 09:42:13 +01:00
github-actions[bot] 70782da2c2
Bump to 2.1.0-SNAPSHOT (#346)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-02-15 09:19:58 +01:00
github-actions[bot] 48fc69e058
Bump to 2.0.0 (#343)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-02-15 09:09:09 +01:00
Mark Scott e7e6e46bd5
fix: prevent NPE on deserializing JSON containing invalid `specversion` value (#342)
* fix: prevent NPE on deserializing JSON containing invalid `specversion` value

Signed-off-by: Mark Scott <mark@codebrewer.org>

* refactor: move test per PR review comment

Signed-off-by: Mark Scott <mark@codebrewer.org>
2021-02-03 08:30:29 +01:00
Francesco Guardiani e523bfbfbf
Rename extension (#339)
* Fixed broken links

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

* Renamed Extension to CloudEventExtension

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

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2021-02-02 08:32:43 +01:00
Thomas Qvarnström 12eee4da6e
Use scheduler instead of StartupEvent. Fixes #332 (#333)
Signed-off-by: Thomas Qvarnström <tqvarnst@redhat.com>
2020-12-16 11:36:28 +01:00
Alfusainey Jallow d49ff9f69d
update AMQP docs (#331)
Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-12-14 11:08:41 +01:00
github-actions[bot] 611f2292a7
Bump to 2.0.0-SNAPSHOT (#329)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-12-11 11:15:02 +01:00
github-actions[bot] 296230719b
Bump to 2.0.0.RC2 (#327)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-12-11 11:04:09 +01:00
Francesco Guardiani d9592d5201
Fixed broken links (#328)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-12-11 10:57:40 +01:00
Francesco Guardiani 00cdf9cb42
Jackson javadocs (#319)
* Jackson javadocs

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

* Reverted public constructor and deprecated it

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-11 10:45:21 +01:00
Francesco Guardiani bd11010138
Kafka javadocs (#321)
* Kafka javadocs

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

* Nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-11 10:42:43 +01:00
Francesco Guardiani 3a22557b83
Website docs (#324)
* Halfway through it

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

* That should be it

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

* Prettier run

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

* Removed code sample

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

* Suggestions + fixed up the mess made by prettier

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

* Suggestion

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-11 10:38:04 +01:00
Francesco Guardiani 87c6915d9a
AMQP javadocs (#322)
* Javadocs

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

* Removed createReader for structured mode and refactored createReader(String, ApplicationProperties, byte[]) to createReader(String, ApplicationProperties, Section)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-11 08:41:40 +01:00
Francesco Guardiani a7f87cf6cb
Javadocs to http mods (#320)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-10 19:28:02 +01:00
Francesco Guardiani 711277eacb
Vert.x 4! (#325)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-10 17:51:45 +01:00
Francesco Guardiani 58570cf4d9
Spring Javadocs (#323)
* Spring Javadocs

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

* Rebase fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-10 17:15:07 +01:00
Dave Syer 24d108fe5d
Improve CloudEventHeaderUtils with narrower scoped method (#318)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-12-10 10:25:21 +01:00
Francesco Guardiani f5d9b47c1c
Javadocs api and core (#313)
* Javadocs!!!

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

* Missing module name?

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

* Excluding javadocs

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

* clean install only release artifacts, but verify them all!

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

* Reverted the crazy idea to use the release profile

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

* Suggestions

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

* Suggestion

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

* Nit

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

* Nit

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

* Nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-09 18:31:56 +01:00
Dave Syer 59643c3368
Add support for Message<CloudEvent> (#315)
* Add support for Message<CloudEvent>

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Add support for structured messages with Spring Message<?>

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Push private classes out to shared utilities

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Resolve some more review comments

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Restructure MessageReader and MessageWriter

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Remove integration test (depends on snapshots still)

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Simplify message converter but drop support for structured format

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Make HTTP optional

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Drop snapshot reporitory declarations

Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-12-09 18:12:09 +01:00
Alfusainey Jallow 34483025df
Fix 404 Not Found in AMQP module Readme (#316)
Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-12-02 21:28:14 +01:00
dependabot[bot] e9d15daf28
Bump jetty-server in /examples/basic-http (#317)
Bumps [jetty-server](https://github.com/eclipse/jetty.project) from 9.4.30.v20200611 to 9.4.35.v20201120.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.30.v20200611...jetty-9.4.35.v20201120)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-02 19:54:54 +01:00
Francesco Guardiani b89f45265b
Simplify the Reader/Writer implementations, reducing the knowledge of spec details (#309)
* Messing up stuff

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

* Collapse CloudEventAttributesWriter and CloudEventAttributesWriter into CloudEventContextWriter

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

* Rebase fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-12-01 17:27:50 +01:00
Dave Syer a14f5eabec
Add a Spring sample with webflux (#314)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-11-30 18:16:20 +01:00
Dave Syer 5099b31f6c
HTTP converters for CloudEvent in Spring (#312)
Supports MVC and WebFlux (blocking and non-blocking) HTTP.
User can work with `CloudEvent` as a `POJO` type and inject it
into `@ReqestMapping` methods.

Signed-off-by: Dave Syer <dsyer@vmware.com>

Co-authored-by: Oleg Zhurakousky <ozhurakousky@pivotal.io>
2020-11-30 11:27:44 +01:00
github-actions[bot] bcc1434a39
Bump to 2.0.0-SNAPSHOT (#310)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-11-26 16:48:45 +01:00
github-actions[bot] c1c55ac1d6
Bump to 2.0.0.RC1 (#305)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-11-26 16:34:41 +01:00
Pierangelo Di Pilato 5ca2c2de91
[Vertx] Fail promise on create reader exception (#307)
When a request contains an invalid event, the body handler doesn't
handle the exception, which leads to an unhandled exception.

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2020-11-26 12:56:08 +01:00
Francesco Guardiani 2524cdf324
Fix NPE on null body with structured message (#306)
* Fix NPE on null body with structured message

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

* Improved test robustness

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-26 12:49:57 +01:00
Francesco Guardiani eeb83c3567
Bump junit5 (#304)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-26 11:24:39 +01:00
Sreenath Madasu 5a926820b4
Remove UnknownEncodingMessageReader and replace with exceptions #262 (#277)
* Javadoc'ed + Cleanup of the api module (#267)

* Javadoc'ed more and more the api module
Cleanup the CloudEventRWException
More tests on the API module

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

* Use parseTime

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

* Better docs on the Extensions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Sreenath Madasu <MADASUSX@legal.regn.net>

* Remove UnknownEncodingMessageReader and replace with exceptions #262

Signed-off-by: Sreenath Madasu <Sreenath.Madasu@gmail.com>

* Remove UnknownEncodingMessageReader and replace with exceptions -- Added Unit tests #262

Signed-off-by: Sreenath Madasu <Sreenath.Madasu@gmail.com>

* Remove UnknownEncodingMessageReader and replace with exceptions -- Fixed compile error #262

Signed-off-by: Sreenath Madasu <Sreenath.Madasu@gmail.com>

* Remove UnknownEncodingMessageReader and replace with exceptions -- changed exception name and details #262

    Signed-off-by: Sreenath Madasu <Sreenath.Madasu@gmail.com>

Signed-off-by: Sreenath Madasu <MADASUSX@legal.regn.net>

* Fixed

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

Co-authored-by: Francesco Guardiani <francescoguard@gmail.com>
Co-authored-by: Sreenath Madasu <MADASUSX@legal.regn.net>
2020-11-26 11:23:24 +01:00
Alfusainey Jallow 7c0b1e3c49
add README.md for AMQP binding (#303)
Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-11-24 20:21:15 +01:00
Dave Syer 377850cb61
Simplify BaseCloudEventBuilder constructor (#300)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-11-24 11:40:15 +01:00
Francesco Guardiani d2a89a4e08
Examples readme (#298)
* Added readme

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

* Improved the quarkus example

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

* Added amqp proton
Fixed and added stuff to the root readme
Added link to examples readme to the main readme

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-24 10:17:44 +01:00
Pierangelo Di Pilato de786322aa
Bump Vertx from 4.0.0.Beta1 to 4.0.0.RC2 (#299)
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2020-11-24 10:17:20 +01:00
Francesco Guardiani 5037a69a80
Add method `BytesCloudEventData#wrap` (#291)
* 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>
2020-11-24 09:57:16 +01:00
Francesco Guardiani ceb5a2eeb2
Pom cleanup (#290)
* Fix poms warnings
Bumped javadoc plugin to latest version

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

* Dumped back the javadoc version

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-24 09:56:42 +01:00
Francesco Guardiani 78a023d08c
Removed some travis leftovers (#295)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-24 09:42:16 +01:00
Alfusainey Jallow bbce65aa64
Add AMQP example (#294)
* Add AMQP example

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* close client connection after sending msg

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* use Vert.x 4 and refactor according to feedback

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* resolve conflicts + move to examples/amqp-proton

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-11-24 09:38:37 +01:00
Francesco Guardiani cc0892a440
Restful WS Spring boot example (#288)
* WIP Spring boot example

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

* Applied suggestions

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

* Updated after rebase

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-24 08:43:46 +01:00
Alfusainey Jallow 2d68c4843f
Use constants added in #280 (#282)
Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-11-24 08:43:12 +01:00
Dave Syer 7f65c92dec
Introduce CloudEventContext (#296)
* Introduce CloudEventContext

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Extract some code into a base class

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Ensure extensions get copied in constructor

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Introduce a CloudEventContextReaderAdapter

Signed-off-by: Dave Syer <dsyer@vmware.com>

* Use inheritance instead of composition

Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-11-23 21:05:26 +01:00
Francesco Guardiani c9b3fa4b65
Move PojoCloudEventData in core (#289)
* Add a static method to wrap a pojo in PojoCloudEventData

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

* WIP

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

* Cleanup

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

* Reverted BytesCloudEventData and moved to a separate PR

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-23 15:59:33 +01:00
Francesco Guardiani 394347db07
CloudEventAttributesWriter and CloudEventExtensionsWriter accepts only not nil attributes/extensions (#287)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-23 11:28:56 +01:00
Francesco Guardiani 6c78428513
Removing ContextAttributes enums (#280)
* Removed ContextAttributes.java in CloudEventV03

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

* Rebase changes

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

* Removed ContextAttributes.java in CloudEventV1

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

* Public constants + javadoc

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-20 11:27:36 +01:00
Sung Kyu Park bf60a25098
Update dataref extension value to string to be supported by BaseCloudEvent.readExtensions (#292)
Signed-off-by: kpark <kpark@guidewire.com>

Co-authored-by: kpark <kpark@guidewire.com>
2020-11-20 08:30:23 +01:00
Francesco Guardiani baf3b56d6d
Introduce CloudEventDataMapper.identity() (#286)
* CloudEventDataMapper cannot be null
Cleanup of all mapper != null and replaced with CloudEventDataMapper.NOOP
Fixed all the missing wildcards

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

* I forgot a bunch of them

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

* CloudEventDataMapper.NOOP to CloudEventDataMapper.identity

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

* Now it should be fine

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-19 18:24:14 +01:00
Dave Syer 8ac23dc479
Add sources plugin to Maven build (#284)
Signed-off-by: Dave Syer <dsyer@vmware.com>
2020-11-18 11:24:06 +01:00
Arghya Sadhu 84fbb0c801
CloudEventBuilder should fail when providing an invalid extension name (#281)
Signed-off-by: Arghya Sadhu <arghya88@gmail.com>
2020-11-17 12:11:34 +01:00
Alfusainey Jallow 20ebdbf87f
[#30] Implement AMQP 1.0 transport binding (#270)
* [#30] Implement AMQP 1.0 transport binding

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* incorporate comments and rename class names.

Now the classes include proton in their names

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* incorporate feedback

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>

* fix javadoc issues

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
2020-11-16 18:01:15 +01:00
Francesco Guardiani 2411fe3508
Fix getAttribute("datacontentencoding") in CloudEventV03 (#279)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-16 16:26:58 +01:00
Matej Vasek 554198d9e0
Build javadoc in all profiles (#275)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-11-16 09:46:42 +01:00
Francesco Guardiani c1ff628511
Javadoc'ed + Cleanup of the api module (#267)
* Javadoc'ed more and more the api module
Cleanup the CloudEventRWException
More tests on the API module

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

* Use parseTime

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

* Better docs on the Extensions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-13 14:31:32 +01:00
Matej Vasek 62fe155604
fix javadoc (#274)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-11-13 13:21:38 +01:00
Francesco Guardiani 34408236db
Moved CloudEventUtils from impl to io.cloudevents.core (#261)
Renamed CloudEventUtils#toVisitable to CloudEventUtils#toReader
Added CloudEventUtils#toEvent

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-13 10:00:49 +01:00
Francesco Guardiani 7696ffe4ec
Update website deps to latest version (#265)
Include in the header the GH edit link for any page
Add favicon

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-13 09:58:52 +01:00
Matej Vasek b1aa399b63
feat: new overload for mapper factory (#268)
* feat: new overload for mapper factory

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* test: updates for mapper

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* doc: updated javadoc for PojoCloudEventDataMapper

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* doc: update javadoc

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-11-13 09:58:28 +01:00
Francesco Guardiani 42a732623b
Improvements to CloudEventReader (#263)
* Extracted readAttributes and readExtensions from CloudEventReader
Added CloudEventUtils#toContextReader to create a context reader starting from a CloudEvent
Improved documentation of *Reader interfaces
Renamed MessageReader#visit to the proper name MessageReader#read

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

* Typo

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-13 09:54:07 +01:00
Francesco Guardiani db745fd309
PartitionKey Kafka Interceptor (#260)
* PartitionKey Kafka Interceptor

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

* Bound

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-13 09:53:55 +01:00
Francesco Guardiani c7baada605
Json mapper (#258)
* Implemented Pojo mapper using jackson
Added other exception kinds

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

* Fixup for the rebase

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

* Removed comment

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

* Equals and hash code

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

* Fixed rebase issues

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-11 08:54:01 +01:00
Francesco Guardiani 3bd9a6922f
CloudEventUtils.mapData(event, mapper) (#257)
* Generified the return value of CloudEventDataMapper
Added toData(CloudEventDataMapper) method to map the data

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

* Moved to CloudEventUtils

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

* public static

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

* Test

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

* wildcard bound

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-11 08:48:45 +01:00
Matej Vasek 118fc82f2b
fix: NPE (#259)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-11-10 18:16:59 +01:00
Francesco Guardiani d09b621409
Cleanup readme (#256)
* Cleanup readme

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

* Cleanup readme

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

* Cleanup readme

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-09 14:40:40 +01:00
github-actions[bot] b3cdfc1ded
Bump to 2.0.0-SNAPSHOT (#255)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-11-09 14:13:56 +01:00
github-actions[bot] f52356e93a
Bump to 2.0.0-milestone4 (#254)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-11-09 14:06:44 +01:00
Francesco Guardiani de2052c4d6
CloudEventDataMapper (#252)
* Defined an interface to perform mapping of data

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

* All code compiles and run

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

* Added a sample + fixed copyrights

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

* More test

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-11-09 09:37:37 +01:00
Francesco Guardiani 5e747e7278
Introduce JsonCloudEventData (#251)
* Implemented JsonCloudEventData

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

* Suggestion

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-10-29 15:59:15 +01:00
Francesco Guardiani f9e31efaa3
Introduce CloudEventData (#250)
* Introduce CloudEventData

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

* Javadocs

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

* Removed to

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

* Applied changes throughout the sdk

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

* Fix javadoc

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-10-29 10:01:39 +01:00
Zhixuan Lai a09b03bd2f
Serialize time to RFC3339 compliant string (#249)
Signed-off-by: Zhixuan Lai <zhixuan@squareup.com>

Co-authored-by: Zhixuan Lai <zhixuan@squareup.com>
2020-09-30 13:03:13 +02:00
Francesco Guardiani f219b6937c
Release process docs (#248)
* Doc of the new release process using GH actions and cleanup of the old release scripts

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

* Nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 13:35:57 +02:00
github-actions[bot] 3cea0245b3
Bump to 2.0.0-SNAPSHOT (#247)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-09-29 12:54:27 +02:00
github-actions[bot] 7abf0c82ed
Bump to 2.0.0-milestone3 (#246)
Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
2020-09-29 12:26:16 +02:00
Francesco Guardiani bb33df53d3
Fix search and replace and remove pom backups (#245)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 12:12:22 +02:00
Francesco Guardiani b30c1dc2ec
Issue in the bump github action (#243)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 11:55:24 +02:00
Francesco Guardiani e481d6feaf
GH Actions, round 3 (#242)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 11:51:19 +02:00
Francesco Guardiani 36c6a78455
GH Actions, round 2 (#241)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 11:07:27 +02:00
Francesco Guardiani 8d3e86e672
Added GH Actions, removed Travis (#240)
* Added GH Actions, removed Travis

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-29 10:47:33 +02:00
Francesco Guardiani 3d86cdd8f4
Added editorconfig check during the verify phase (#239)
* Enabled editorconfig check

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

* Run editorconfig + a bunch of exclusions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-28 10:00:21 +02:00
Francesco Guardiani 2982f07f55
Renamed methods of writes to coerce with the builder apis (#237)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-28 08:58:57 +02:00
Pierangelo Di Pilato 1f58088f3c
Add Knative Eventing in "Used By" section (#236)
Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2020-09-16 13:13:50 +02:00
Johan Haleby 3841e74e1e
Added "Used By" section in README.md and added link to "Occurrent" under this section (#235)
Signed-off-by: Johan Haleby <johan.haleby@gmail.com>
2020-09-16 10:04:00 +02:00
Ruben Romero Montes dda867a6ea
Add CloudEventsProvider to services (#233)
Signed-off-by: ruromero <rromerom@redhat.com>
2020-09-15 12:08:13 +02:00
Ruben Romero Montes e9c8da021a
Fix graalvm build (#232)
Signed-off-by: ruromero <rromerom@redhat.com>
2020-09-11 16:56:17 +02:00
Ruben Romero Montes 53c0a84f43
Use Graalvm 20.1.0 in CI (#230)
Signed-off-by: ruromero <rromerom@redhat.com>
2020-09-11 15:01:35 +02:00
dependabot[bot] 0a4caad417
Bump jetty-server in /examples/basic-http (#228)
Bumps [jetty-server](https://github.com/eclipse/jetty.project) from 9.4.28.v20200408 to 9.4.30.v20200611.
- [Release notes](https://github.com/eclipse/jetty.project/releases)
- [Commits](https://github.com/eclipse/jetty.project/compare/jetty-9.4.28.v20200408...jetty-9.4.30.v20200611)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-09-10 08:37:08 +02:00
Matej Vasek 8a14cf4182
fix: link in readme (#229)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-09-10 08:32:42 +02:00
Matej Vasek 6eecf29cf7
Generic http binding (#225)
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-09-09 19:28:40 +02:00
Ruben Romero Montes 29c9eaa23f
Add Quarkus example (#226)
* Add Quarkus example

Signed-off-by: ruromero <rromerom@redhat.com>

* Rename project and remove unrelated files

Signed-off-by: ruromero <rromerom@redhat.com>
2020-09-07 10:34:11 +02:00
slinkydeveloper c3904fbff4 Fixed some docs
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 12:34:48 +02:00
Francesco Guardiani 69e605e2ef Release 2.0.0-SNAPSHOT
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
(cherry picked from commit 08aed3bc40)
2020-09-01 12:05:36 +02:00
Francesco Guardiani b54a46fd07 Release 2.0.0-milestone2
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 11:56:36 +02:00
Francesco Guardiani 08aed3bc40 Release 2.0.0-SNAPSHOT
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 11:44:18 +02:00
Francesco Guardiani f20208aec7 Release 2.0.0-milestone2
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 11:44:18 +02:00
Francesco Guardiani c61f87f4d5
Release automation (#191)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 11:35:53 +02:00
Francesco Guardiani 0ca907be49
Vertx 4 (#206)
* Something wrong

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

* Update to Vert.x 4

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

* Removed wrong pom bits

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

* Updated readme

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

* Updated the sample code of vertx

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

* Avoid recreating the JsonFormat

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 10:18:05 +02:00
Francesco Guardiani 8b4e586b64
Added a method to remove the extensions (#218)
* Added a method to remove the extensions

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

* Added a method to remove the materialized extension

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

* Better test

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 10:10:47 +02:00
Francesco Guardiani 75171b9705
Switch `ZonedDateTime` to `OffsetDateTime` (#216)
* Switch `ZonedDateTime` to `OffsetDateTime`. Fix #214

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

* Removed useless date format

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

* Removed time format

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-09-01 10:10:35 +02:00
Francesco Guardiani 700661b664
Added core package test-jar again to poms (#217)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-08-31 17:33:53 +02:00
Grant Timmerman 6a982d83fa
docs: fix README link. Fixes #210 (#213)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-08-31 10:35:49 +02:00
Doug Davis b572bd88cf
add coc ref (#209)
Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-08-11 16:42:08 +02:00
Francesco Guardiani 39b9fc159c
Simplified poms (#205)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-08-11 10:14:39 +02:00
Francesco Guardiani 4c98031c3b
Fix #200 (#202)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-08-10 16:10:37 +02:00
Francesco Guardiani 0ce5f9535d
Dependency bumps (#203)
* Updates

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

* Let's avoid to upgrade junit5, it seems that surefire plugin doesn't like it...

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-08-04 18:03:28 +02:00
Francesco Guardiani 58a6426fe8
Reorganized some readmes/docs (#193)
* Added javadocs links both to READMEs and docs

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

* Removed old docs of v1 of the sdk

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-07-08 11:12:26 +02:00
Francesco Guardiani d4ee5a6930
Benchmarks (#192)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-07-08 11:12:10 +02:00
Pierangelo Di Pilato e71cc5358c
Add Vertx example (#195)
* Add Vertx example

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>

* Apply suggestion

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
2020-07-02 11:13:38 +02:00
Francesco Guardiani 862e4a657a
Created kafka example (#194)
* Created kafka example

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

* Applied suggestions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-07-02 09:25:43 +02:00
Francesco Guardiani f42020333a
Back to SNAPSHOT (#189)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 15:54:22 +02:00
Francesco Guardiani 63ffe3be14
Release 2.0.0-milestone1 - attempt 2 (#188)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 15:28:59 +02:00
Francesco Guardiani 900decaed0
Release 2.0.0-milestone1 (#187)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 15:01:48 +02:00
Francesco Guardiani bd50e6f284
Now all javadocs pass the minimum checks (#186)
* Fixed all javadocs

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

* Applied suggestions

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 14:36:54 +02:00
Francesco Guardiani a012e1e434
Added javadoc for jax-rs (#184)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 14:32:26 +02:00
Francesco Guardiani fd1e6b2728
Improved a bit the docs website (#185)
* Improved a bit the docs
Changed the docs website theme

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

* Using constants

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-25 11:24:18 +02:00
Francesco Guardiani 12cca34d21
Missing docs in kafka and vertx implementation (#183)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-23 17:20:25 +02:00
Francesco Guardiani 83d9045897
Javadoc-ed cloudevents-core (#182)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-23 17:20:18 +02:00
Francesco Guardiani 98a6b87d5b
Javadoc-ed cloudevents-api (#181)
* Javadoc-ed cloudevents-api

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

* nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-23 17:20:09 +02:00
Francesco Guardiani c632f56f8b
Added Automatic-Module-Name to manifests of published modules (#179)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-22 16:29:42 +02:00
Matej Vasek 7d85d19f1a
fix: sub-second resolution `time` attribute (#176)
* fix: sub-second resolution `time` attribute

Fixes parsing of dates like: 2018-04-26T14:48:09.1234Z

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* test: added test for datetime parsing formatting

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2020-06-18 16:59:12 +02:00
Francesco Guardiani fd1c3268d9
Refactor mocks (#180)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-18 16:10:01 +02:00
Francesco Guardiani 1bebbbbb68
Improved Vertx Message APIs (#177)
* Improved Vertx Message APIs

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

* Javadoc

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

* Improved code

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-18 15:00:39 +02:00
Francesco Guardiani 14dc3e5b8a
Simplified Kafka Message APIs (#178)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-18 13:24:37 +02:00
Francesco Guardiani 5c32b566e7
Merge pull request #167 from slinkydeveloper/rename_reader_writer
Rename Visitor/Visitable to Writer/Reader
2020-06-15 09:06:36 +02:00
slinkydeveloper 28dcc2a009 Renamed package io.cloudevents.visitor to io.cloudevents.rw
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-09 11:37:07 +02:00
Francesco Guardiani c386423787
Created method to create a builder from a builder (#166)
* Created method to create a builder from a builder (using the first one as template)

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

* Docs

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-08 19:12:31 +02:00
Paul Schwarz 815c9cff26
feat: 70 implement dataref extension (#151)
Signed-off-by: Paul Schwarz <paulsschwarz@gmail.com>
2020-06-08 17:12:53 +02:00
slinkydeveloper 57bb81cc5c Rename Visitor/Visitable to Writer/Reader
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-04 16:56:19 +02:00
Doug Davis 1d07d9c392
copy guidance from javascript repo (#159)
* copy guidance from javascript repo

Signed-off-by: Doug Davis <dug@us.ibm.com>

* s/javascript/java/g

Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-06-04 15:02:20 +02:00
Francesco Guardiani 1ebf662b9b
Moved EventFormatProvider and ExtensionsParser into provider (#162)
Renamed ExtensionsParser in ExtensionProvider

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-04 15:02:01 +02:00
Francesco Guardiani 6d057aa64d
CloudEventBuilder interface now has withAttribute methods (#165)
* Progress

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

* Javadoc-ed
Now works

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

* Test fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-04 15:01:48 +02:00
Francesco Guardiani 34cd81455b
Reorganized some READMEs (#160)
* Reorganized some READMEs

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

* Suggestions

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

* Progress

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

* Last fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-01 11:34:23 +02:00
Francesco Guardiani 73d90d11bb
Reworked a bit the Extension interface (#158)
* Reworked a bit the `Extension` interface

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

* Renamed readFromEvent as readFrom

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

* Removed Extension extends CloudEventExtensions

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

* getValue() throws an exception if the key is not recognized by the materialized extension

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

* typo

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-06-01 09:22:54 +02:00
Francesco Guardiani c4f2902dd6
Glue core & api (#157)
* Implement Visitor/Visitable mechanism

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

* First pass on reimplementing spec version conversion

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

* Removed again toV1 & toV03

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

* Flattened attributes iface and impl

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

* Removed assumption that CloudEvent implements CloudEventVisitable

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

* Removed interfaces from core

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

* Moved io.cloudevents subpackages in core to io.cloudevents.core

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

* Changed signature of `fromSpecVersion`

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

* Changed signature of `fromSpecVersion`

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-29 15:12:17 +02:00
Francesco Guardiani 0fdfcc378d
Moved cloudevents-api to cloudevents-core (#155)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Proposed set of apis for CloudEvent

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

Changes

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

Javadocs

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

Removed CloudEventBuilder.java

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

Nits

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-22 16:30:36 +02:00
Francesco Guardiani c616a71947
Fixed the maven deployment config to avoid integration test packages deploy (#154)
* Fixed the maven deploy

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

* More maven magic

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-19 20:22:28 +02:00
Francesco Guardiani fb10bd3da5
Removed quiet flag (#153)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-19 19:56:48 +02:00
Matej Vasek 2ff79c06b6
Test Jax-rs integration with Resteasy & Spring Jersey (#152)
* Added test for resteasy

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

* resteasy and jersey now don't conflict each other anymore

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

* Small nits

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

* Removed pom piece not needed

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

* Little mistake

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

* Trying to test spring

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

* Fix spring package version mismatch

Also updated calls from junit4 to junit5

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Fix assertions in test

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Split restful-ws tests to sub-modules

Managing test for multiple jax-rs implemetations
using exclusions is not practical.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Implement simpler solution

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Add exclusions for junit4

We are using junit5

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Add name to integration test artifacts

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Add exclusions from deploy

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Update README.md

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Remove unused property

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Add copyright headers

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Rename property

Signed-off-by: Matej Vasek <mvasek@redhat.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
2020-05-19 18:32:08 +02:00
Francesco Guardiani 199f8c02e0
Revert "Proposal for reworking the unstructured read/write of events (#146)" (#149)
This reverts commit cd5777791c.
2020-05-15 15:56:48 +02:00
Francesco Guardiani cd5777791c
Proposal for reworking the unstructured read/write of events (#146)
* Proposal for handling unstructured read/write of events

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

* cloudevents-json-jackson fixed

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

* Everything builds

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

* Added two utility methods to Message

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

* Signature was wrong

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-15 11:41:41 +02:00
Francesco Guardiani a485edffdb
Integration with Jakarta RESTful Web Services (#145)
* Bootstrapped http/restful-ws module

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

* Bootstrapped http/restful-ws module

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

* Going forward with jax-rs

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

* Going forward with jax-rs

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

* Fix

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

* Trying another jaxrs impl

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

* Flush fix

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

* Reverted Jersey, now all works as it should

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

* Constant

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-05-04 08:55:54 +02:00
Oleg Zhurakousky 9c167a67bb
Add Maven wrapper (#144)
This will ensure that developers have a chance to  use the same version of maven.

Signed-off-by: Oleg Zhurakousky <ozhurakousky@pivotal.io>
2020-04-29 18:21:22 +02:00
Francesco Guardiani 30ca27afd8
Formatted code and added copyright headers (#140)
* Formatted code and added headers

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

* Updated all copyright years with 2018-Present

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-28 13:56:06 +02:00
Francesco Guardiani 5586404278
Removed CDI module (#141)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-28 12:25:57 +02:00
Sergei Egorov ba2db45f38
Introduce JSR-305 compatible nullability, remove `Optional` (#138)
* Introduce JSR-305 compatible nullability, remove `Optional`

Closes #123.

Signed-off-by: Sergei Egorov <segorov@pivotal.io>

* fix wrong indentation

Signed-off-by: Sergei Egorov <segorov@pivotal.io>

* fix wrong indentation (2)

Signed-off-by: Sergei Egorov <segorov@pivotal.io>
2020-04-28 12:02:30 +02:00
Francesco Guardiani 5c28b36967
Reworked Kafka module (#134)
* WIP kafka

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

* Worked on some abstractions to simplify implementation of Message

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

* Reworked kafka module

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

* Applied suggestions + documented Kafka module usage

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

* Renaming

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

* Docs fix

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

* small fixes

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

* small fixes

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-28 10:33:00 +02:00
Francesco Guardiani d5f87a6df1
Fixed table (#136)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-27 20:23:11 +02:00
Francesco Guardiani bf3514459b
Docs (#135)
* Added jemoji

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

* Renamed vertx module to cloudevents-http-vertx
Fixed docs

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-27 19:47:23 +02:00
Francesco Guardiani 1b03ee1a93 Set theme jekyll-theme-slate 2020-04-27 19:01:16 +02:00
Francesco Guardiani 7d80d7263b
Bootstrap docs (#133)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-27 19:00:07 +02:00
Francesco Guardiani 2b5e72c50a
Reworked Vert.x Integration (#129)
* Started http-vertx module reworking

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

* Vertx integration done

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

* Adjusted the READMEs

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

* Case sensitivity fix

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-24 12:17:49 +02:00
Francesco Guardiani 4e38fc805d
GraalVM travis fix (#132)
* test graalvm travis

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

* Mhh

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

* Reenabled conditional run

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-24 12:05:03 +02:00
Francesco Guardiani f50f28ef3d
Testing matrix with various JDKs + GraalVM (#131)
* Testing matrix with various JDKs + GraalVM
Enabled deployment on master

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

* Lemme try this config

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

* Maybe now it works

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

* Editor config fix

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

* Editor config

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

* Removed deprecated flag

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

* Maybe now it works

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

* Applied suggestions

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

* Maybe now it works

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

* This should do it

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

* Small nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-24 11:51:40 +02:00
Francesco Guardiani 924dbed6e7
Test for implementation of equals (#126)
* Test for equals

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

* Maven fix

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

* Funny pom issues

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

* Fixed pom issues

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-22 17:05:04 +02:00
Francesco Guardiani cd913f368f
Changed version to 2.0.0-SNAPSHOT (#127)
* Changed version to 2.0.0-SNAPSHOT

Changed the README for the V2 to specify the sdk is currently under development

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

* Fixed poms

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

* Fixed json-jackson pom

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-22 16:59:41 +02:00
Fabio José 8d7c785afd
Merge pull request #108 from slinkydeveloper/refactor-event-class
Rework the Event interface
2020-04-22 09:09:58 -03:00
slinkydeveloper d207ecc311 Fixed structuredToEvent test
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-21 18:49:51 +02:00
slinkydeveloper 92c205a941 Json deserialization works
Json roundtrip works
Added extensions to tests

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-21 18:43:03 +02:00
slinkydeveloper d420efcda7 Json serialization works
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-21 15:23:48 +02:00
slinkydeveloper ae4028d59d Wrong filenames
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 21:03:00 +02:00
slinkydeveloper 4df01cd279 Progress on implementing serialization
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 21:01:10 +02:00
slinkydeveloper 7dcfdba30d Tests ready, starting implementing
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 19:26:24 +02:00
slinkydeveloper 30c5fcf1e4 Json added mock data
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 19:11:14 +02:00
slinkydeveloper 0f94976f7b All tests in cloudevents-api pass!
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 17:45:40 +02:00
slinkydeveloper 41f48a5c84 cloudevents-api does not depend on jackson anymore
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 16:57:58 +02:00
slinkydeveloper 814bf80745 Removed JsonNode from Data (now jackson should be easily pluggable)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 16:44:49 +02:00
slinkydeveloper 3eecb4d7a9 Enable JUnit 5
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 15:59:17 +02:00
slinkydeveloper c7b9f3dab5 Compiles!
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 15:52:49 +02:00
slinkydeveloper 8f1b8d2da9 Completed implementation of message interfaces for events.
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 13:21:54 +02:00
slinkydeveloper 223d786a3f Message interfaces should be fine now
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 12:30:55 +02:00
slinkydeveloper d54dcf7f83 Added conversion between spec versions
Added copy builder

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-20 10:45:04 +02:00
slinkydeveloper ad5ab5d491 WIP
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-17 14:35:11 +02:00
slinkydeveloper 59d4a79ed6 Sketching Message APIs
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-16 16:40:55 +02:00
slinkydeveloper ce98e7cbda Extensions
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-16 12:52:50 +02:00
slinkydeveloper 0113207a45 After writing for months in a toy language, I forgot that modern languages like Java has method overloading
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-16 12:49:17 +02:00
slinkydeveloper 670d1c13f4 Some steps forward
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-04-16 11:41:49 +02:00
Fabio José 242b58a530
Merge pull request #105 from duglin/addemail
add link to email
2020-04-15 09:21:07 -03:00
slinkydeveloper 5362a80afe Proposal to refactor the Event class
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2020-03-23 10:06:47 +01:00
Doug Davis 5096753658 add link to email
Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-03-20 14:47:29 +00:00
Fabio José 361a34cc63 🔖 Set versions to 1.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2020-03-04 20:48:47 -03:00
Fabio José c35b313d15 Changelog for version 1.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2020-03-04 20:39:27 -03:00
Fabio José 200aa6cd02 EditorConfig for file editing patterns
Signed-off-by: Fabio José <fabiojose@gmail.com>
2020-03-04 20:38:59 -03:00
Fabio José dd07320779
Merge pull request #98 from skpark-tech/master
Map extensions with prefix for Kafka CloudEvent header
2020-03-04 20:14:27 -03:00
Fabio José d25aaf8f49
Merge pull request #90 from fhussonnois/master
Add new CloudEventsKafkaHeaders class for kafka API
2020-03-04 20:12:40 -03:00
Fabio José a79f8f9431
Merge pull request #78 from cricket007/patch-1
Fix Kafka Transport references
2020-03-04 20:09:25 -03:00
kpark 833db5bd92 Map extensions with prefix for Kafka CloudEvent header
Signed-off-by: kpark <kpark@guidewire.com>

Apply suggestions from code review

Co-Authored-By: Sergei Egorov <bsideup@gmail.com>
Signed-off-by: kpark <kpark@guidewire.com>
2020-02-27 10:02:04 -08:00
Fabio José e39291f655
Merge pull request #92 from jponge/patch-1
Removing wrong email
2020-02-13 13:25:32 -03:00
Fabio José ae6dff25aa
Merge pull request #91 from duglin/editreadme
add helpful text to README
2020-02-13 13:25:08 -03:00
Julien Ponge dfa4d2c30e
Removing wrong email
This was not my email. Also I am removing any email reference just like the other contributors.

Signed-off-by: Julien Ponge <jponge@redhat.com>
2020-02-03 10:37:45 +01:00
Doug Davis 2f0e22c560 add helpful text to README
Signed-off-by: Doug Davis <dug@us.ibm.com>
2020-01-28 18:49:56 +00:00
Florian Hussonnois a5f88c3408 Add new CloudEventsKafkaHeaders class for kafka API
This commit add a new CloudEventsKafkaHeaders helper class used to build the Kafka headers
that should be attached either a binary or structured event message.

Signed-off-by: Florian Hussonnois <florian.hussonnois@gmail.com>
2020-01-28 15:57:18 +01:00
Fabio José 6861823eb8 Document the version of changelog
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-12-30 08:52:44 -03:00
Fabio José a6e3bc8d2a Merge branch 'master' into develop 2019-12-30 08:51:32 -03:00
Fabio José 0b1d2d27d5 🔖 Set versions to 1.2.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-12-30 08:50:43 -03:00
Fabio José 8e53e66ed0 Merge branch 'master' into develop 2019-12-30 08:47:10 -03:00
Fabio José 7055740465
Merge pull request #79 from ruromero/base64
Fix base64 marshalling
2019-12-30 08:40:50 -03:00
Jordan Moore d183489f04 Fix top level README as well
Signed-off-by: Jordan Moore <crikket.007@gmail.com>
2019-12-18 12:23:04 -06:00
Jordan Moore d0178c0bea kafka s/Transport/Protocol/g
Signed-off-by: Jordan Moore <crikket.007@gmail.com>
2019-12-18 12:21:05 -06:00
Ruben Romero Montes e895a6e596 Updated CHANGELOG
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-12-18 16:51:08 +01:00
Ruben Romero Montes b753661af2 Fix json annotations for data
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-12-04 12:55:46 +01:00
Ruben Romero Montes 3049f587d8 Fix base64 marshalling
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-12-03 23:12:35 +01:00
Fabio José e0e562b787 👷 Auto release at Sonatype Nexus
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-29 08:41:53 -03:00
Fabio José 0d7c86025c
Merge pull request #76 from cloudevents/develop
Release v1.1.0
2019-11-29 08:32:34 -03:00
Fabio José c3460ee150 🔖 Set versions to 1.1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-28 20:42:21 -03:00
Fabio José 01ae643f67 📝 Changelogs for v1.1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-28 20:41:51 -03:00
Fabio José 0376e12e11 🔖 Set versions to 1.0.1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-28 20:34:49 -03:00
Fabio José 6994c2244b Merge branch 'master' into develop 2019-11-28 20:11:19 -03:00
Fabio José dfd71734d0
Merge pull request #73 from ruromero/validator
Allow using an existing Validator instance
2019-11-28 20:08:46 -03:00
Fabio José cbab54ed88 🔥 Remove skip long running annotation
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 15:11:59 -03:00
Fabio José 7a1326f182 Remove the kafka embedded deps
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 15:11:42 -03:00
Fabio José 962d10cb48 🔥 Remove the dependency of embedded kafka
Now using MockProducer

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 15:07:57 -03:00
Fabio José 457962402a Constructor to provide custom kafka producer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 15:07:39 -03:00
Fabio José b451c1d7d6 🔥 Remove the dependency of embedded kafka
Now using MockConsumer

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 14:25:39 -03:00
Fabio José d732c0d153 🔥 Remove the dependency of embedded kafka
Now using MockConsumer

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 14:14:05 -03:00
Fabio José 2dfed7e782 🔥 Remove the dependency of embedded kafka
Now using MockConsumer

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 14:06:25 -03:00
Fabio José c205299065 Constructor to provide custom kafka consumer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 13:59:09 -03:00
Fabio José c047c754f0 Dep for jackson core
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 13:46:24 -03:00
Fabio José 6328b86c96 📝 Changelog for the issue 67
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 11:17:10 -03:00
Fabio José 88c078af57 ⬆️ Bump the jackson version to 2.10.1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 11:13:56 -03:00
Fabio José 25e90caf43 🐛 Closes #67 - Maps the datacontenttype to content-type
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 10:12:01 -03:00
Fabio José 39427f3162 Test for kafka content type header mapping
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 10:06:16 -03:00
Fabio José ffdcca6dd1 📝 Changelog for issue 74
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 09:54:23 -03:00
Fabio José b5bb261e22 🐛 Closes #74 - @JsonIgnore at getData() method to avoid duplication for json encode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 09:23:19 -03:00
Fabio José 50f8015d18 Test for data attribute duplication for json encode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-21 09:21:08 -03:00
Ruben Romero Montes 1291497f1d Small cleanup
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-11-17 16:40:40 +01:00
Ruben Romero Montes de45795d29 Allow using an existing Validator instance
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-11-17 10:33:28 +01:00
Fabio José f641cb1957
Merge pull request #66 from cloudevents/v1
Support for Spec v1.0
2019-11-01 12:19:21 -03:00
Fabio José d8fc237466 Fixing to camelCase
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-29 08:00:20 -03:00
Fabio José 179cc1972c base64 test with binary mode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-27 16:17:12 -03:00
Fabio José 6bf0af1555 Example for data_base64
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-27 10:20:05 -03:00
Fabio José c5abaef45b Test for data_base64 unmarshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-27 10:11:06 -03:00
Fabio José 37b4854775 read from inputstream using typeinference
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-27 10:10:39 -03:00
Fabio José 79dd762367 Json example for data_base64 test
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-27 10:10:06 -03:00
Fabio José 59962ba689 Support for data_base64 in json message format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 17:29:57 -03:00
Fabio José 9e97e10ac6 Update snippets examples to v1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 17:28:31 -03:00
Fabio José c02fcecb5b Merge branch 'master' into v1 2019-10-26 16:06:07 -03:00
Fabio José a635f429f8 Update examples to version 1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 16:05:43 -03:00
Fabio José 84441cd0f9 Set version to 1.0.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:45:31 -03:00
Fabio José 9eea7587a1 Document the PR
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:34:26 -03:00
Fabio José f35dc6bbf8
Merge pull request #65 from ruromero/validator
Allow providing an external validator
2019-10-26 15:33:20 -03:00
Fabio José 313040f7f6 Kafka marshallers and unmarshallers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:22:47 -03:00
Fabio José 43f779e010 Mapper for headers in kafka binding
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:20:18 -03:00
Fabio José 893ee567f0 Mapper for extension in kafka binding
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:17:44 -03:00
Fabio José 73f6c9572c Mapper for attributes in kafka binding
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 15:14:43 -03:00
Fabio José 835058f32b Unmarshal method
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:30:08 -03:00
Fabio José d9434f5408 Builder method wiht attributes, data and extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:29:50 -03:00
Fabio José ba0ccb1e1e Unmarshallers for http binding
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:29:26 -03:00
Fabio José 73bbda9c17 http marshallers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:13:00 -03:00
Fabio José b1a473894d Mapper for http headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:07:26 -03:00
Fabio José 372af07c64 License comment
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:03:46 -03:00
Fabio José 92c4f78829 Fix comment version
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:03:20 -03:00
Fabio José 9f14242ed8 Mapper for extension in spec v1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 14:02:57 -03:00
Fabio José 769254bb75 Http attr mapper for spec v1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 13:58:34 -03:00
Fabio José 984b05b75e Register changelog
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 13:54:05 -03:00
Fabio José 821273139a Tests for json marshalling and unmarshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 13:49:00 -03:00
Fabio José 698a3d1131 Spec v1 support
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-26 13:34:38 -03:00
Ruben Romero Montes 3df3b29e09 Added unit tests
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-10-25 15:42:12 +02:00
Fabio José 50508ba4b3
Merge pull request #62 from rinormaloku/doc-update
improved readme to end request for vertx sample
2019-10-25 08:47:25 -03:00
Ruben Romero Montes 1cff239ab4 Allow providing an external validator
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
2019-10-24 16:40:34 +02:00
rinormaloku cf65ce0309 improved readme to end request
Signed-off-by: rinormaloku <rinormaloku37@gmail.com>
2019-10-03 20:45:15 +02:00
Fabio José b0a6101b23
Merge pull request #59 from cloudevents/develop
Release 0.3.1 - CVE issues
2019-09-30 14:23:50 -03:00
Fabio José bf72800220 Set the release version to 0.3.1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 13:34:45 -03:00
Fabio José fe94d00437 The current spec version is 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 13:31:27 -03:00
Fabio José 1ad66b0da4 Changelog for v0.3.1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 13:28:10 -03:00
Fabio José 680f8cdf13
Merge pull request #58 from cloudevents/cve
Cve
2019-09-30 13:19:55 -03:00
Fabio José 2cacd5fc80 Merge branch 'master' into cve 2019-09-30 12:55:11 -03:00
Fabio José 56331feb2e Fixing vulnerable deps: Closes #45
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 12:50:06 -03:00
Fabio José 3c600a3538
Merge pull request #57 from cloudevents/develop
Fix the release configuration
2019-09-30 12:36:07 -03:00
Fabio José 685d2a0dbf Fix github release api_key
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 10:28:37 -03:00
Fabio José ac45ce9045 Fix the release configuration
Set autoReleaseAfterClose to false

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-30 09:36:08 -03:00
Fabio José ccc55e9e4c
Merge pull request #56 from cloudevents/develop
Automated release - round V
2019-09-28 11:42:58 -03:00
Fabio José 291df4b1e0 Remove the gpg sign test
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 11:26:34 -03:00
Fabio José 76946e63f3 gpg batch sign: finally works
Remove the test commands

Remove the plugin args from pom.xml

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 11:18:59 -03:00
Fabio José 4db13f58e6 Enable the sign command for tests
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:41:07 -03:00
Fabio José d66adea035 New secring
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:40:48 -03:00
Fabio José 53cde4cae6 Remove the gpg1 installation
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:15:51 -03:00
Fabio José 436dae661e Install the gpg1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:10:17 -03:00
Fabio José 9b2e420e4a Search for gpg1
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 10:07:42 -03:00
Fabio José 082bb529b7 Remove pinentry mode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 09:39:59 -03:00
Fabio José b0814a97be Enable the full command
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 09:30:45 -03:00
Fabio José 67b1303d2a Adding pinentry mode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 09:21:42 -03:00
Fabio José a95cb50483 Passphrase as argument
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 09:13:13 -03:00
Fabio José aa79390ee9 Add keyname
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-28 08:53:48 -03:00
Fabio José b9d55cfdfc Enable the release profile
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 22:28:41 -03:00
Fabio José f5b6eab1ee Adding --batch arg for gpg plugin
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 22:16:26 -03:00
Fabio José fabebe5ef3 Fixing CI error
gpg: signing failed: Inappropriate ioctl for device
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 22:07:35 -03:00
Fabio José 78896687b3 Adding batch to secret key import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:58:03 -03:00
Fabio José 47ab16a7eb Remove the decrypt for pubring
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:48:30 -03:00
Fabio José 0a6a65b53a Pubring open at all
Does not make sense encrypt the public key

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:47:59 -03:00
Fabio José 2d7944cf23 Print gpg version from travis
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:35:51 -03:00
Fabio José fb267a050d Test the new gpg configuration
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:27:46 -03:00
Fabio José 855949ce5f Temporary stage to test the gpg keyring
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 21:27:22 -03:00
Fabio José 6962a97997
Merge pull request #55 from cloudevents/develop
Round VI - Automated release
2019-09-27 17:17:52 -03:00
Fabio José bab23ab8be Using the new keys
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 17:02:40 -03:00
Fabio José ec0bbb6aad New gpg keys
Remove the old one

Split in two files

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 17:01:06 -03:00
Fabio José cb2b930fef
Merge pull request #53 from cloudevents/develop
Fix the keyname alias
2019-09-27 14:38:15 -03:00
Fabio José f7175593e7 Fix the keyname alias
Identation too

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 14:16:00 -03:00
Fabio José 50bbd8f62a
Merge pull request #52 from cloudevents/develop
Fixing the travis deploy job
2019-09-27 13:22:04 -03:00
Fabio José 4d54386c7c Fixing the travis deploy job
script directive must be single line

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 12:46:36 -03:00
Fabio José b4553fcae6
Merge pull request #51 from cloudevents/travis
Travis CI configurations for automated release
2019-09-27 12:20:22 -03:00
Fabio José fb3c59c6a9 Caching the dependencies
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 09:37:47 -03:00
Fabio José 82581ddf18 Skip script on relase, tuning the deploy command
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 09:29:59 -03:00
Fabio José 25bdc70645 Parameter to use the maven profile on relase
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 09:19:04 -03:00
Fabio José dde76aabec Configurations for automated release to maven central
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 09:18:33 -03:00
Fabio José 2da5a54263 Github release stage, remove cr from commands
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 09:00:40 -03:00
Fabio José 49a6dda3cb Fixing identation
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-27 08:46:08 -03:00
Fabio José c086de98cb Fixing the deployment script
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:22:57 -03:00
Fabio José c2bbfa7a27 Remove branch filter, turning on the CI
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:07:57 -03:00
Fabio José b469da4388 Set the version 0.3.0 for release (without snapshot)
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:06:04 -03:00
Fabio José 33ac91972a Job configuration for releases on tags
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:01:07 -03:00
Fabio José d7af439944 Maven settings for automated release
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:00:41 -03:00
Fabio José 639e5b4480 Gpg key for release process
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-26 17:00:16 -03:00
Fabio José e625f3a33a
Merge pull request #49 from fabiojose/master
Kafka binding, spec 0.3 support, preparing for the future
2019-09-25 15:16:27 -03:00
Fabio José cc4325d52e HTTP (un)marshallers for 0.3
Marshallers

Unmarshallers

Unit testing

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:44:16 -03:00
Fabio José fda0e73429 Tests for kafka consumer
Structured content mode

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:43:28 -03:00
Fabio José 064785f549 Copy subject attribute when using builder with base event
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:42:53 -03:00
Fabio José 154a93e3c4 Fix the extension header map
No prefix at all

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:42:22 -03:00
Fabio José b14b6b0652 Adding imports in the examples docs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:41:51 -03:00
Fabio José 0857dfa4ca Preparation for pr, add right version compare links
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-20 12:41:15 -03:00
Fabio José b7aa38eacb Kafka consumer tests
Binary content mode

Spec 0.3

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 23:05:04 -03:00
Fabio José efc32d5c09 Top-level unmarshallers for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 23:04:25 -03:00
Fabio José b0483f3a8c Filter to remove non-ce headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 23:04:02 -03:00
Fabio José cac367cf8e Builder with base instance
Fix of() method to process extensions

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 23:03:08 -03:00
Fabio José 5e86c215bc Attributes v0.3 unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 23:02:12 -03:00
Fabio José 272c6ad568 Testing for kafka producer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:53:49 -03:00
Fabio José f57cc6ad65 Common marshall method
Takes an attributes impl and produces a map

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:44:30 -03:00
Fabio José 838a730258 Top-level marshallers for kafka
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:43:27 -03:00
Fabio José 528563b563 License comment and new attributes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:31:15 -03:00
Fabio José af39059327 Private constructor to prevent instances creationg
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:30:50 -03:00
Fabio José c11ca15fc4 Kafka header mapper for (un)marshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:30:04 -03:00
Fabio José 9b41ae001d Kafka extension mapper for (un)marshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:29:43 -03:00
Fabio José 8327a97b04 Kafka Attributes mapper for spec 0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:19:49 -03:00
Fabio José cb3364e714 Override (de)serializers
The value (de)serializer always must be bytearray

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:05:05 -03:00
Fabio José 61e63ed367 Document the low-level (un)marshallers
The structured and binary content modes to create your own

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-19 21:03:06 -03:00
Fabio José 879c6e81b1 Fix english grammer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:28:31 -03:00
Fabio José e626dc45ce Unreleased link
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:25:10 -03:00
Fabio José f6a85d0b40 Document the dependency config
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:19:54 -03:00
Fabio José 6a248907f9 Update snippets with new sdk api
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:19:24 -03:00
Fabio José 4b47abe4e4 Update version of maven deps
Fix kafka docs link

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:12:55 -03:00
Fabio José cac81e32ad Link to kafka and api docs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:11:20 -03:00
Fabio José 1f6a6009d9 Document the use of (un)marshalelrs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 22:02:02 -03:00
Fabio José 29466509f4 Json decoding using JavaType
Decode binary and string

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:42:03 -03:00
Fabio José 7aedf64ea8 Document how to use (un)marshallers
The structured and binary hight level

How to create my own (un)marshaller

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:41:09 -03:00
Fabio José 33393ce26c Document the changes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:39:48 -03:00
Fabio José d4c1cb2825 Tests for structured kafka consumer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:39:24 -03:00
Fabio José 4e4ded70dc Right name for the test
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:39:02 -03:00
Fabio José 089f976540 structure unmarshaller definition
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:38:37 -03:00
Fabio José f3cd10ac93 Use of hight level unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:37:36 -03:00
Fabio José b2436c94ee Remove the unused steps tests
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:36:57 -03:00
Fabio José de58785f62 Umarshaller for structured content mode
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:36:18 -03:00
Fabio José 0ac54691d7 Remove unused steps
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:35:52 -03:00
Fabio José b4b7b2a37b Use of constants
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-18 21:35:21 -03:00
Fabio José 90d08f0678 Boilerplate
KafkaConsumer and KafkaPRoducer to delegate calls, as internal attribute by composition

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:58:40 -03:00
Fabio José 3ec841c33c Test the tracing unmarshal from header
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:57:11 -03:00
Fabio José f23bb3e8a3 Test the extensions unmarshal from headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:56:30 -03:00
Fabio José 58449faa87 Tests with extensions list
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:55:58 -03:00
Fabio José a62510671f Top level private constructor
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:55:36 -03:00
Fabio José 0b58bc9bc7 Builder method with base event to copy attributes, extensions and data
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:55:07 -03:00
Fabio José 8fb128e992 Process extensions from headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:54:27 -03:00
Fabio José f0ed9b9786 Way get the extensions from headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-17 22:53:55 -03:00
Fabio José cdb638157d Impl the send that pass a callback arg
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 22:12:26 -03:00
Fabio José 533e95b755 java doc @see
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 22:06:50 -03:00
Fabio José e6f4b691d5 Line feed
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 22:06:28 -03:00
Fabio José ad2074d48d Use of (un)marshallers
Reduce the boilerplate

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 22:06:09 -03:00
Fabio José 5df373310e Kafka marshallers and unmarshallers for json
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 22:05:30 -03:00
Fabio José efd60454ee Use of marshallers and unmarshallers for HTTP
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:43:40 -03:00
Fabio José 0b11866d83 Fix doc reference for headers type
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:35:21 -03:00
Fabio José 816c03ab67 Fix doc reference for headers type
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:35:04 -03:00
Fabio José d8b24f8953 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:34:39 -03:00
Fabio José 14e873d3f2 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:34:11 -03:00
Fabio José d46300b57b Remove unused code
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:33:24 -03:00
Fabio José 6e63ce20e2 Using the Marshallers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:33:05 -03:00
Fabio José 62a9c133c4 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:32:07 -03:00
Fabio José 7b97f3714c Fix type
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:31:50 -03:00
Fabio José ff1ee9d694 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:31:04 -03:00
Fabio José 33d75f43d4 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:30:28 -03:00
Fabio José 4eb6cfaa95 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:29:58 -03:00
Fabio José 3f87394cbb Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:29:43 -03:00
Fabio José 322e9cee4a Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:29:25 -03:00
Fabio José cf39dd5a39 Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:28:56 -03:00
Fabio José c2a982dc0c Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:28:20 -03:00
Fabio José 1a7ecafeeb Typing the header's value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:27:51 -03:00
Fabio José 87bea3cca2 Tests for kafka structured producer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:27:21 -03:00
Fabio José ac8561003c Tests for http marshallers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:26:41 -03:00
Fabio José a971933128 HTTP Unmarshaller with default setup
Just the binary

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:25:47 -03:00
Fabio José 5ce4c08563 HTTP Marshallers with default setup
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-16 21:25:12 -03:00
Fabio José 8cfc47b41d Header value as Object argument
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-15 15:34:09 -03:00
Fabio José ca377dbb61 How to use binary kafka producer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-14 18:16:08 -03:00
Fabio José 5b53529dcd Change the use of procuder constructor
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-14 18:15:21 -03:00
Fabio José 43945a9356 Remove the unused contructor
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 23:21:29 -03:00
Fabio José 1f58ddfc88 Use of common marshal interfaces
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 22:20:55 -03:00
Fabio José 16f81f522a Common marshaller interfaces
Event step and marshal step used by builders

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 22:19:57 -03:00
Fabio José e2b05808ca Fix broken class import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:41:47 -03:00
Fabio José aabd8c7847 Readme for kafka module
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:35:43 -03:00
Fabio José 667f22a060 Meaninful name for kafka tests
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:34:58 -03:00
Fabio José 9ad2486176 Remove unused resources
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:34:27 -03:00
Fabio José 9568fc339f Use the common interfaces
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:34:04 -03:00
Fabio José da2c2e7f51 Use the common interfaces
Remove the main methods

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:33:41 -03:00
Fabio José e21fd99ff1 Remove the main method
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:32:57 -03:00
Fabio José 2d0538f4f9 Define the common interfaces
Common interfaces for unmarshallers

Meaninful names for kafka tests

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-13 21:31:57 -03:00
Fabio José dc97d6f565 Fixing the name references
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:27:41 -03:00
Fabio José d3492c5edd Remove sysout println
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:27:07 -03:00
Fabio José 18e2b19b71 Fix the expected json data
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:26:49 -03:00
Fabio José f9ebd5a7e0 Tests for null args
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:26:19 -03:00
Fabio José 16b7c48754 Fixing the name references
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:25:48 -03:00
Fabio José 1bdab88d95 Change to more generic definition of mapper
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:25:17 -03:00
Fabio José e03db54f33 Add javadoc license
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:24:46 -03:00
Fabio José f6d0d1fba1 Fixing the name references
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:24:20 -03:00
Fabio José d84211dea4 Fix the name references
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:23:43 -03:00
Fabio José 80b8a1ddc5 Tests for the unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:23:04 -03:00
Fabio José 9b515cbff2 Envelope unmarshaller funcional interface
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:22:38 -03:00
Fabio José 2d878fc146 hashCode and equals for test assertions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:21:49 -03:00
Fabio José 50f5e5d81e the structured unmashaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:21:08 -03:00
Fabio José 47c445f710 Ignore the media type in the structured content mode marshal
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:20:30 -03:00
Fabio José 061619b39a Document the use of marshaller and unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-12 22:19:46 -03:00
Fabio José 58d54b4ecc Structure marshaller
Unit tests

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:30:01 -03:00
Fabio José 97bac365bb HTTP Structured Tests
Tests using the structured marshaller

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:25:20 -03:00
Fabio José f038be561e Fixing the header mapper import
License docs

Javadocs

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:24:25 -03:00
Fabio José a4bedf04af Fixing the examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:23:19 -03:00
Fabio José 2a1075af0e Builder definition
The interface

Implementing in the v02 event builder

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:22:42 -03:00
Fabio José 9939e69d76 toString for testing
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:21:42 -03:00
Fabio José d2497338f3 Tests for kafka consumer using binary format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:20:00 -03:00
Fabio José 4482e2200b Tests for kafka producer using binary format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:19:16 -03:00
Fabio José 4bea5a311f Java docs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:18:26 -03:00
Fabio José e4237f3a26 Kafka Consumer for cloudevents
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:18:02 -03:00
Fabio José 08a3c4ea66 The step builder to create a structured marshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:17:02 -03:00
Fabio José 3f3c547310 Envelope marshaller
functional interface

to marshall a cloud event instance into the wire format

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:16:23 -03:00
Fabio José 156f8561b8 Test for builder that uses a base event instance
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:11:00 -03:00
Fabio José eede6b2625 Java doc arguments
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:05:56 -03:00
Fabio José a525b08ddf Change the reference to functional interface header mapper
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:04:11 -03:00
Fabio José a06f5c5109 Change the reference to functional interface header mapper
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:02:37 -03:00
Fabio José 480c7b5443 Change the reference to functional interface header mapper
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 22:01:42 -03:00
Fabio José 2a5108ebce Remove the binary prefix
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 21:59:41 -03:00
Fabio José 8c03752e86 License in the package comment
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 21:57:49 -03:00
Fabio José fbaac5a73b Binary marshaller and binary unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 21:57:19 -03:00
Fabio José 9063b5d923 Use of trace attributes constants
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 21:55:35 -03:00
Fabio José 18a4578b0c Add license docs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-10 21:54:50 -03:00
Fabio José 98b3d8980b type for tests
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-04 21:21:50 -03:00
Fabio José 6237e569d0 Cloud events kafka producer
Binary marshal

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-04 21:21:24 -03:00
Fabio José de1e54272c Map the values as byte array
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-04 21:16:28 -03:00
Fabio José d6611de540 Binary marshall
Marshals a json to byte array

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-04 21:15:28 -03:00
Fabio José 7467513636 java doc
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 22:01:06 -03:00
Fabio José 9a561d3e52 Remove blank lines
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 22:00:47 -03:00
Fabio José 60bbac06de java doc
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 22:00:26 -03:00
Fabio José b5e72d7beb Remove blank lines
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 22:00:01 -03:00
Fabio José 469ba5a81e Kafka header mapper
Implementation for 0.2

Unit tests

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:58:07 -03:00
Fabio José aa3d5b75af Kafka extension mapper
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:49:48 -03:00
Fabio José 049fc8c7d7 Kafka Attribute mapper
Unit tests

Fixes due the tests

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:49:14 -03:00
Fabio José 4e6695525b Kafka clients consumer example config
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:18:03 -03:00
Fabio José 9fd1a26e94 Using directly the marshaller and unmarshaller for binary
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:16:47 -03:00
Fabio José bcc9fd4784 Set version to 0.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:07:11 -03:00
Fabio José 842ce70fa4 Changes to use the way to process binary format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:06:54 -03:00
Fabio José fe6bbc89df Changes to use the way to process binary format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:06:33 -03:00
Fabio José 4afc34399b Typing with spec 0.2 impl
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:05:50 -03:00
Fabio José 0f89086d0d Set version to 0.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:05:14 -03:00
Fabio José 24e071a62c Set version to 0.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:04:43 -03:00
Fabio José ae719c9984 Set version to 0.3.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:02:40 -03:00
Fabio José ec11c44a47 Fix on null attribute or extension value
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:01:52 -03:00
Fabio José 1e4f84f41f Fix on null and no ce prefix for extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:01:17 -03:00
Fabio José 880b85b786 Header mapping tests
For spec 0.2

For spec 0.3

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 21:00:12 -03:00
Fabio José 6c54ff32e7 Fix on null or empty json string
Decode on class type

Decode on type reference

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 20:58:20 -03:00
Fabio José e815d7c75b Import the new v0.2 impl for CloudEvent
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 15:33:48 -03:00
Fabio José 7df1d1536d Update vesion and dep
Set version to 0.3.0

Set jee dep to 8 due the error java.lang.NoSuchMethodError: javax.validation.BootstrapConfiguration.getClockProviderClassName()Ljava/lang/String;

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-03 15:33:02 -03:00
Fabio José 5d29d4f00d Kafka Binding
Build configuration

Attributer mapper for v0.2

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 22:11:46 -03:00
Fabio José 01b715d4fc Changes for wire remaning
Typing the wire

Fix the class import name

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 22:01:00 -03:00
Fabio José 785c4cb9b9 Fix the imports
After removing the implements of functional interfaces

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:59:39 -03:00
Fabio José 7ad4d4e308 Private list of extension format
Package level method to get that list

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:58:36 -03:00
Fabio José a9635b5d93 Tests for extension mapper
Spec 0.3 HTTP

Handle on null values

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:57:39 -03:00
Fabio José b65f91120a Tests for attributer mapper
Spec 0.3 HTTP

Handle on null values

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:56:46 -03:00
Fabio José 8608be402a Tests for the extension mapper
Right handling when null values

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:55:12 -03:00
Fabio José 799fd57881 Tests for attribute mapper
Some fixies based on the tests

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:54:09 -03:00
Fabio José 30953e7657 Test for the immutable result
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:52:32 -03:00
Fabio José 52dad12ed6 Accessor for the package level attributes
To get access to the collection extension format

Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:49:51 -03:00
Fabio José a1539f4c08 Rename to wire instead of format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:48:30 -03:00
Fabio José d782c0b4ec javadoc and private constructor to avoid instances
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-09-02 21:47:32 -03:00
Fabio José a11b443a76 The extension format accessor tests
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 09:54:26 -03:00
Fabio José bb4fcaa52a License in the package comment
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 08:56:56 -03:00
Fabio José be956f60a9 Clean the class names
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 08:53:40 -03:00
Fabio José b416aa9c35 Clean the class names
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 08:52:51 -03:00
Fabio José 15909cd087 Fix the valueType of in memory format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 08:50:22 -03:00
Fabio José ecd250a698 Tests for the tracing extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-30 08:50:01 -03:00
Fabio José 3026d9a35b Generics for the header map, immutable header map
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 22:20:43 -03:00
Fabio José 57076ab49d Wire unit testing
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 22:19:43 -03:00
Fabio José 46b9dd2653 Meanninful names for funcional impls
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:59:11 -03:00
Fabio José a7d2249ab5 Fix the visibility of header prefix, to prevent incorrect imports
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:55:30 -03:00
Fabio José 41729e800c Fix the visibility of header prefix, to prevent incorrect imports
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:55:06 -03:00
Fabio José ec2564dd0c Fix import of header prefix
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:54:31 -03:00
Fabio José 6d18806ff4 Meanninful names for funcional impls
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:49:49 -03:00
Fabio José e89b3c1f13 Remove the implements of funcional interface
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:31:09 -03:00
Fabio José 51450a363d Using the static methods instead of funcional impls
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:28:27 -03:00
Fabio José aa70190226 The header mapper for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:23:05 -03:00
Fabio José 5bee36db53 The extension mapper for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:22:45 -03:00
Fabio José f939c21fd7 Add the javadoc @version to 0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:18:59 -03:00
Fabio José 9c549706f8 Remove the implements of funcional interface
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:18:06 -03:00
Fabio José 5359a1ece0 Java doc @version to 0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:06:42 -03:00
Fabio José 0257406506 A signature to access CloudEvents' internal list of ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:06:11 -03:00
Fabio José 2462b4637f Removed the unused import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:04:39 -03:00
Fabio José f2ace570aa Removing the checked exception form marshaller and unmarshaller static methods
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:03:54 -03:00
Fabio José b06e6106a6 Remove the checked exception
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:02:29 -03:00
Fabio José efca35b6f0 Remove the checked exception
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:02:11 -03:00
Fabio José 201b5ab21b Default marshaller for ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 21:01:39 -03:00
Fabio José e9fd715325 Tracing extensions unmarshaller as static method
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:57:55 -03:00
Fabio José a0047bef6e Turning the marshaller to lazy eval
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:57:03 -03:00
Fabio José 9c11207c84 Fix the class name typo
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:56:11 -03:00
Fabio José a892517682 method to access the media type, marshaller and unmarshaller as static methods
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:55:03 -03:00
Fabio José a9ecd31562 method to the access the media type of data
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:54:17 -03:00
Fabio José 982a359731 Basic binary unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-29 20:52:40 -03:00
Fabio José 38c8f3d1b2 Remove the impl due the functional interface
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-27 13:14:58 -03:00
Fabio José dbd5c366a1 Code format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 22:25:42 -03:00
Fabio José 3a48e913d0 The JSON Data Marshaller implementation
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 22:23:36 -03:00
Fabio José dccb1cd57c Fixing typo: unmarshall
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 22:19:42 -03:00
Fabio José 0606036c31 Implementation of DataUnmarshaller for JSON
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 22:15:05 -03:00
Fabio José d040bcef32 getting the builder instance of the builder() method
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:54:16 -03:00
Fabio José 3cecb769f1 fix changelog anchor
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:43:54 -03:00
Fabio José 92f2a3f8b8 Builds instances of Format using payload and headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:42:13 -03:00
Fabio José 8968802bf8 Turns a map o extensions into instances of ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:41:34 -03:00
Fabio José a32976e44b Turns a collection of extensions into map
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:40:59 -03:00
Fabio José 92f463c661 Gets data, attributes and extensions and builds CloudEvent instance
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:40:25 -03:00
Fabio José 4f1bf875f3 Turns payload into data
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:39:54 -03:00
Fabio José 740d67d42a Turns data into payload for the wire transmission
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:39:29 -03:00
Fabio José c9f3998c15 Header mapper, that gets a map of attributes and extensions and turns into map of headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:38:56 -03:00
Fabio José 607c2cf43d Extensions mapper, that gets a map o headers and turns into another map
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:38:05 -03:00
Fabio José 1f45b0f230 Attribute mapper, that gets a map of headers and turns into another map
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:37:26 -03:00
Fabio José d93866f856 Attribute unmarshaller, that receives a map and result a instance of Attributes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:36:47 -03:00
Fabio José 7078603fc8 Attribute marshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:36:01 -03:00
Fabio José c941799977 The format, to use as a result of binary marshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:34:58 -03:00
Fabio José 0d2e1d7579 License and tests with new way to play with extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:32:05 -03:00
Fabio José a3bab6f860 License and tests with new way to play with extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:31:29 -03:00
Fabio José 809a6e4bbc License and tests with new way to play with extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:31:09 -03:00
Fabio José b3753002af Testing the http header marshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:30:10 -03:00
Fabio José 69481e3075 Deleted due the spec 0.1 support removal
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:29:22 -03:00
Fabio José 7f70261981 Deleted due the new SDK API
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:28:55 -03:00
Fabio José c8ac595435 Fix the extension from '.mq' to '.md'
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:28:25 -03:00
Fabio José d41b528221 License and code format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:27:37 -03:00
Fabio José 236f1597a2 Annotations to igore cast issues
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:22:09 -03:00
Fabio José 1721fd387e Mapping from extensions too
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:21:09 -03:00
Fabio José 5c171dbf39 The extension mapper, that maps from http headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:19:36 -03:00
Fabio José 20cef92ee1 Adds the license
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 21:18:39 -03:00
Fabio José 01ae400193 Remove: implements Extension, Add: impls for ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:53:13 -03:00
Fabio José fda22ed938 The representation for in memory and transport formats for extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:52:19 -03:00
Fabio José 5e230ddeff The representation for in memory format for extensions
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:51:58 -03:00
Fabio José 3bf55af44d License and use of new ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:39:22 -03:00
Fabio José 77bbca5943 License and use of new ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:38:54 -03:00
Fabio José 7de013719e License and uses the ContextAttributes enumeration
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:38:20 -03:00
Fabio José 5fc30f5f06 Remove: set import, Add: license
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:37:36 -03:00
Fabio José c3a94c90d1 The method for Accessor, license and use of new ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:36:13 -03:00
Fabio José 66adbdada5 Changes to receive the extensions set
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:35:15 -03:00
Fabio José 63d693d694 The marshaller and unmarshaller methods
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:34:09 -03:00
Fabio José 91b89d51fe A way to access the internal Set of ExtensionFormat
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:27:04 -03:00
Fabio José 30e7fb681c Context attributes as enumeration
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:20:41 -03:00
Fabio José abbdf66686 Context attributes as enumeration
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-26 17:20:23 -03:00
Fabio José 806a2dacc9 Maps the attributes to http headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 15:58:56 -03:00
Fabio José 98df3e997e Remove due the abstract envelop evolution
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 14:05:33 -03:00
Fabio José a12d29eaf6 bean to use with test
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 14:03:21 -03:00
Fabio José 5ac588c8d9 Assertions using the new envelop signature
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 13:57:43 -03:00
Fabio José 3a2ee97847 Binary mapper for http headers
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 13:54:41 -03:00
Fabio José 87d63b2ccd Assertions using the new envelop signature
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 13:53:56 -03:00
Fabio José b2934fad99 Remove methods: decodeCloudEvent, Change signature: fromInputStream
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 12:40:02 -03:00
Fabio José 861b3410ce Fix the import for abstract envelop import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:14:14 -03:00
Fabio José 171b9652b3 Fix the abstract envelop import, comments typo
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:13:36 -03:00
Fabio José 87fdd9f9de Fix the import for abstract envelop
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:12:50 -03:00
Fabio José 279d0d6806 Rename the attribute unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:10:44 -03:00
Fabio José 7c85f338ac Rename the attribute unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:10:23 -03:00
Fabio José 385153a552 Implements the unmarshaller
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:04:56 -03:00
Fabio José afc6f3deef Changes to support the new signature
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 11:03:52 -03:00
Fabio José 024e7b18fe Adds the serial no
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 10:21:34 -03:00
Fabio José a636b9b518 Documenting the signature changes and removals
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 10:21:02 -03:00
Fabio José 2323b4cf2d Update the tests for the new signature
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 10:20:13 -03:00
Fabio José 9a75b23566 Attributes impl for spec 0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-21 10:19:36 -03:00
Fabio José 7aac31892c Fix the extension format import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 13:16:49 -03:00
Fabio José ef3753f8d9 Documenting the changes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 13:03:35 -03:00
Fabio José 12860fafaf License docs
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 13:02:55 -03:00
Fabio José 2d4828f02b Removed: 0.1 builder and impl, due the new abstract envelop signture
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 13:02:11 -03:00
Fabio José fe7e40973d New abstract envelop signature
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 13:01:21 -03:00
Fabio José 10a7931393 Start the changelog records
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 11:02:57 -03:00
Fabio José 5dde66e8d8 Marker interface for context attributes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 10:45:22 -03:00
Fabio José 137dcaa016 Impl of EventBuilder interface
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-20 10:36:21 -03:00
Fabio José 059a3e7206 Builder method 'of' to build event from data and attributes object
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-19 22:48:14 -03:00
Fabio José 06fb04e42f Support for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-19 22:07:08 -03:00
Fabio José 4d5ed04fd9 JSON Resources for spec 0.3 testing
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-19 22:04:36 -03:00
Matthias Wessendorf 8c635e3c53
Merge pull request #43 from fabiojose/master
To marshall and unmarshall extensions
2019-08-16 14:32:53 +02:00
Fabio José ff074c2758 Document the extension usage
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:44:04 -03:00
Fabio José b26ecda111 Change the test method name
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:43:38 -03:00
Fabio José 49f318c251 Merge remote-tracking branch 'upstream/master' 2019-08-14 14:25:55 -03:00
Fabio José 937a3abe5a Fix the extension marshalling and unmarshalling: Closes #31
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:19:58 -03:00
Fabio José 2acad53ba8 Remove the print stacktrace
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:16:48 -03:00
Fabio José 676a32a60d Extension key as public const
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:16:20 -03:00
Fabio José c9f4292604 Class for in menory extension format
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:15:51 -03:00
Fabio José 7f11e22a76 event payload to tests extensions unmarshalling
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:14:16 -03:00
Fabio José 2e464adeb7 event payload for tests with spec v0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 14:13:10 -03:00
Fabio José 2a6e56e5f4 hashCode and equals methods
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 13:44:35 -03:00
Fabio José 4655bc89d9 InMemory representation for distributed tracing extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-14 13:42:39 -03:00
Matthias Wessendorf a00ddcad35
Merge pull request #42 from fabiojose/master
Fixing the issue #32
2019-08-14 15:18:53 +02:00
Fabio José 5326476d55 Remove the oraclejdk8 due the ci error
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 19:01:27 -03:00
Fabio José 935c17bb16 Document the new way to create typed event and update the version
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 18:16:25 -03:00
Fabio José 8350a78ce5 Add fabiojose as developer
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 18:10:36 -03:00
Fabio José 9f2d568598 Test for time attribute
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 18:01:01 -03:00
Fabio José af57ffb57d Package level constructor
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:59:24 -03:00
Fabio José cee02dead8 Exclusive impl for spec 0.2. Closes #32
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:56:31 -03:00
Fabio José 47ca69c435 fromInputStream using generics
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:53:15 -03:00
Fabio José f11c773f8a content type as lowercase, as-is spec v0.2
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:52:46 -03:00
Fabio José 6b32537972 Adding alias to work with 'contenttype' and 'contentType' on deserialization
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:52:06 -03:00
Fabio José 0b2585048c Deps for Bean Validation 2.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-13 17:51:08 -03:00
Matthias Wessendorf 19ac10b176
Merge pull request #35 from brunoborges/master
Update to 0.2.1
2019-03-20 14:02:25 +01:00
Bruno Borges 9035156ec2 Update to 0.2.1
Signed-off-by: Bruno Borges <bruno.borges@microsoft.com>
2019-03-20 14:01:31 +01:00
Matthias Wessendorf c85c691ea6
Merge pull request #28 from gunnarmorling/patch-1
Update README.md
2018-12-21 12:30:46 +01:00
Gunnar Morling 27fe1a686e Update README.md
Signed-off-by: Gunnar Morling <gunnar.morling@googlemail.com>
2018-12-21 11:22:05 +01:00
Matthias Wessendorf c8a27e50dc [maven-release-plugin] prepare for next development iteration 2018-12-18 14:09:28 +01:00
540 changed files with 34680 additions and 2595 deletions

14
.editorconfig Normal file
View File

@ -0,0 +1,14 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
[{*.yaml, *.yml}]
indent_size = 2
[*.java]
max_line_length = 160

11
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "maven"
directory: "/" # Location of package manifests
schedule:
interval: "daily"

48
.github/workflows/branch.yaml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Test and Deploy
on:
push:
branches:
- master
- main
- '[0-9]+.[0-9]+'
jobs:
test:
name: Java ${{ matrix.java }} Test
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
steps:
- uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- run: |
./mvnw clean install -DskipTests -B
./mvnw verify -B
deploy:
runs-on: ubuntu-latest
name: Deploy
needs: test
steps:
- uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 8
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Publish to Apache Maven Central
run: ./mvnw clean deploy -Drelease -DskipTests -B
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

47
.github/workflows/bump.yaml vendored Normal file
View File

@ -0,0 +1,47 @@
name: Bump version
on:
workflow_dispatch:
inputs:
version:
description: 'Version to bump (without prepending "v")'
required: true
maven-modules:
description: "Whether to bump versions in pom.xml files"
type: choice
required: true
default: 'true'
options:
- 'true'
- 'false'
jobs:
bump:
name: Bump Java version
runs-on: ubuntu-latest
env:
NEW_VERSION: ${{ github.event.inputs.version }}
steps:
- uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Bump version using Maven
if: ${{ inputs.maven-modules == 'true' }}
run: './mvnw versions:set -DnewVersion=$NEW_VERSION -DgenerateBackupPoms=false -B'
- name: Bump version in docs
if: ${{ !endsWith(github.event.inputs.version, 'SNAPSHOT') }}
run: 'find . -type f -name "*.md" -exec sed -i -e "s+<version>[a-zA-Z0-9.-]*<\/version>+<version>$NEW_VERSION</version>+g" {} +'
- name: Create version bump PR
uses: peter-evans/create-pull-request@v3
with:
title: "[Release] Bump to ${{ github.event.inputs.version }}"
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Bump to ${{ github.event.inputs.version }}"
signoff: true
branch: "bump/${{ github.event.inputs.version }}"
body: >
This PR performs the bump of the SDK to ${{ github.event.inputs.version }}.
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).

27
.github/workflows/pr.yaml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Test
on:
pull_request:
branches:
- master
- main
- '[0-9]+.[0-9]+'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
name: Java ${{ matrix.java }} Test
steps:
- uses: actions/checkout@v2
- name: Setup java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- run: |
./mvnw clean install -DskipTests -B
./mvnw verify -B
./mvnw javadoc:javadoc

13
.gitignore vendored
View File

@ -13,6 +13,8 @@ release.properties
.classpath
.project
.settings/
.vscode/
.attach_pid*
# Log file
*.log
@ -34,3 +36,14 @@ release.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Jekyll stuff
_site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata
# MacOS
*.DS_Store
/http/restful-ws-jakarta/src/main/*

117
.mvn/wrapper/MavenWrapperDownloader.java vendored Normal file
View File

@ -0,0 +1,117 @@
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}

2
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

View File

@ -1,15 +0,0 @@
language: java
sudo: false
jdk:
- oraclejdk8
- openjdk8
- openjdk9
- openjdk10
- openjdk11
branches:
only:
- master

167
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,167 @@
# Contributing to CloudEvents' Java SDK
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
We welcome contributions from the community! Please take some time to become
acquainted with the process before submitting a pull request. There are just
a few things to keep in mind.
# Pull Requests
Typically, a pull request should relate to an existing issue. If you have
found a bug, want to add an improvement, or suggest an API change, please
create an issue before proceeding with a pull request. For very minor changes
such as typos in the documentation this isn't really necessary.
## Pull Request Guidelines
Here you will find step by step guidance for creating, submitting and updating
a pull request in this repository. We hope it will help you have an easy time
managing your work and a positive, satisfying experience when contributing
your code. Thanks for getting involved! :rocket:
* [Getting Started](#getting-started)
* [Branches](#branches)
* [Commit Messages](#commit-messages)
* [Staying current with main](#staying-current-with-main)
* [Submitting and Updating a Pull Request](#submitting-and-updating-a-pull-request)
* [Congratulations!](#congratulations)
## Getting Started
When creating a pull request, first fork this repository and clone it to your
local development environment. Then add this repository as the upstream.
```console
git clone https://github.com/mygithuborg/sdk-java.git
cd sdk-java
git remote add upstream https://github.com/cloudevents/sdk-java.git
```
## Branches
The first thing you'll need to do is create a branch for your work.
If you are submitting a pull request that fixes or relates to an existing
GitHub issue, you can use the issue number in your branch name to keep things
organized.
```console
git fetch upstream
git reset --hard upstream/main
git checkout FETCH_HEAD
git checkout -b 48-fix-http-agent-error
```
## Commit Messages
Please follow the
[Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary).
The first line of your commit should be prefixed with a type, be a single
sentence with no period, and succinctly indicate what this commit changes.
All commit message lines should be kept to fewer than 80 characters if possible.
An example of a good commit message.
```log
docs: remove 0.1, 0.2 spec support from README
```
### Signing your commits
Each commit must be signed. Use the `--signoff` flag for your commits.
```console
git commit --signoff
```
This will add a line to every git commit message:
Signed-off-by: Joe Smith <joe.smith@email.com>
Use your real name (sorry, no pseudonyms or anonymous contributions.)
The sign-off is a signature line at the end of your commit message. Your
signature certifies that you wrote the patch or otherwise have the right to pass
it on as open-source code. See [developercertificate.org](http://developercertificate.org/)
for the full text of the certification.
Be sure to have your `user.name` and `user.email` set in your git config.
If your git config information is set properly then viewing the `git log`
information for your commit will look something like this:
```
Author: Joe Smith <joe.smith@email.com>
Date: Thu Feb 2 11:41:15 2018 -0800
Update README
Signed-off-by: Joe Smith <joe.smith@email.com>
```
Notice the `Author` and `Signed-off-by` lines match. If they don't your PR will
be rejected by the automated DCO check.
## Staying Current with `main`
As you are working on your branch, changes may happen on `main`. Before
submitting your pull request, be sure that your branch has been updated
with the latest commits.
```console
git fetch upstream
git rebase upstream/main
```
This may cause conflicts if the files you are changing on your branch are
also changed on main. Error messages from `git` will indicate if conflicts
exist and what files need attention. Resolve the conflicts in each file, then
continue with the rebase with `git rebase --continue`.
If you've already pushed some changes to your `origin` fork, you'll
need to force push these changes.
```console
git push -f origin 48-fix-http-agent-error
```
## Submitting and Updating Your Pull Request
Before submitting a pull request, you should make sure that all of the tests
successfully pass.
Once you have sent your pull request, `main` may continue to evolve
before your pull request has landed. If there are any commits on `main`
that conflict with your changes, you may need to update your branch with
these changes before the pull request can land. Resolve conflicts the same
way as before.
```console
git fetch upstream
git rebase upstream/main
# fix any potential conflicts
git push -f origin 48-fix-http-agent-error
```
This will cause the pull request to be updated with your changes, and
CI will rerun.
A maintainer may ask you to make changes to your pull request. Sometimes these
changes are minor and shouldn't appear in the commit log. For example, you may
have a typo in one of your code comments that should be fixed before merge.
You can prevent this from adding noise to the commit log with an interactive
rebase. See the [git documentation](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History)
for details.
```console
git commit -m "fixup: fix typo"
git rebase -i upstream/main # follow git instructions
```
Once you have rebased your commits, you can force push to your fork as before.
## Congratulations!
Congratulations! You've done it! We really appreciate the time and energy
you've given to the project. Thank you.

View File

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Copyright 2018-Present The CloudEvents Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

5
MAINTAINERS.md Normal file
View File

@ -0,0 +1,5 @@
# Maintainers
Current active maintainers of this SDK:
- [Pierangelo Di Pilato](https://github.com/pierDipi)

39
MAINTAINERS_GUIDE.md Normal file
View File

@ -0,0 +1,39 @@
# Maintainer's Guide
## Tips
Here are a few tips for repository maintainers.
* Stay on top of your pull requests. PRs that languish for too long can become difficult to merge.
* Work from your own fork. As you are making contributions to the project, you should be working from your own fork just as outside contributors do. This keeps the branches in github to a minimum and reduces unnecessary CI runs.
* Try to proactively label issues and pull requests with labels
* Actively review pull requests as they are submitted
* Triage issues once in a while in order to keep the repository alive.
* If some issues are stale for too long because they are no longer valid/relevant or because the discussion reached no significant action items to perform, close them and invite the users to reopen if they need it.
* If some PRs are no longer valid due to conflicts, but the PR is still needed, ask the contributor to rebase their PR.
* If some issues and PRs are still relevant, use labels to help organize tasks.
* If you find an issue that you want to create a pull request for, be sure to assign it to yourself so that other maintainers don't start working on it at the same time.
## Landing Pull Requests
When landing pull requests, be sure to check the first line uses an appropriate commit message prefix (e.g. docs, feat, lib, etc). If there is more than one commit, try to squash into a single commit. Usually this can just be done with the GitHub UI when merging the PR. Use "Squash and merge". To help ensure that everyone in the community has an opportunity to review and comment on pull requests, it's often good to have some time after a pull request has been submitted, and before it has landed. Some guidelines here about approvals and timing.
* No pull request may land without passing all automated checks
* All pull requests require at least one approval from a maintainer before landing
* A pull request author may approve their own PR, but will need an additional approval to land it
* If a maintainer has submitted a pull request and it has not received approval from at least one other maintainer, it can be landed after 72 hours
* If a pull request has both approvals and requested changes, it can't be landed until those requested changes are resolved
## Branch Management
The `main` branch is the bleeding edge. New major versions of the module
are cut from this branch and tagged. If you intend to submit a pull request
you should use `main HEAD` as your starting point.
Each major release will result in a new branch and tag. For example, the
release of version 1.0.0 of the module will result in a `v1.0.0` tag on the
release commit, and a new branch `v1.x.y` for subsequent minor and patch
level releases of that major version. However, development will continue
apace on `main` for the next major version - e.g. 2.0.0. Version branches
are only created for each major version. Minor and patch level releases
are simply tagged.

140
README.md
View File

@ -1,49 +1,123 @@
# Java SDK for CloudEvents API
[![Build Status](https://travis-ci.org/cloudevents/sdk-java.png)](https://travis-ci.org/cloudevents/sdk-java)
[![License](https://img.shields.io/:license-Apache2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.cloudevents/cloudevents-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.cloudevents/cloudevents-parent)
[![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-api.svg?color=green)](http://www.javadoc.io/doc/io.cloudevents/cloudevents-api)
[![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-core.svg?color=green)](http://www.javadoc.io/doc/io.cloudevents/cloudevents-core)
A Java API for the [CloudEvents specification](https://github.com/cloudevents/spec)
The Java SDK for CloudEvents is a collection of Java packages to adopt
[CloudEvents](https://github.com/cloudevents/spec) in your Java application.
## Motivation
Using the Java SDK you can:
The [CloudEvents specification](https://github.com/cloudevents/spec) is vendor-neutral specification for defining the format of event data that is being exchanged between different cloud systems. The specification basically defines an abstract envelope for any event data payload, without knowing specific implementation details of the actual underlying event. The current version of the spec is at `0.2` and it describes a simple event format, which was demonstrated at last [KubeCon 2018](https://youtu.be/TZPPjAv12KU) using different _Serverless platforms_, such as [Apache Openwhisk](https://github.com/apache/incubator-openwhisk).
- Access, create and manipulate `CloudEvent` inside your application.
- Serialize and deserialize `CloudEvent` back and forth using the _CloudEvents
Event Format_, like Json.
- Read and write `CloudEvent` back and forth to HTTP, Kafka, AMQP using the
_CloudEvents Protocol Binding_ implementations we provide for a wide range
of well known Java frameworks/libraries.
## Java API
To check out the complete documentation and how to get started, look at the dedicated website
https://cloudevents.github.io/sdk-java/.
For Maven based projects, use the following to configure the CloudEvents Java SDK:
## Status
```xml
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>0.2.0</version>
</dependency>
```
This SDK is considered **work in progress**. The community is working hard to
bring you a new major version of the SDK with major enhancements both to APIs
and to implementation.
Application developers can now create strongly-typed CloudEvents, such as:
If you want to know more about v1 of this SDK, check out the
[v1 readme](https://github.com/cloudevents/sdk-java/tree/1.x)
```java
// given
final String eventId = UUID.randomUUID().toString();
final URI src = URI.create("/trigger");
final String eventType = "My.Cloud.Event.Type";
final MyCustomEvent payload = ...
Stay tuned!
// passing in the given attributes
final CloudEvent<MyCustomEvent> cloudEvent = new CloudEventBuilder<MyCustomEvent>()
.type(eventType)
.id(eventId)
.source(src)
.data(payload)
.build();
```
Supported features of the specification:
## Possible Integrations
| | [v0.3](https://github.com/cloudevents/spec/tree/v0.3) | [v1.0](https://github.com/cloudevents/spec/tree/v1.0) |
| :-------------------------------------: | :---------------------------------------------------: | :---------------------------------------------------: |
| CloudEvents Core | :heavy_check_mark: | :heavy_check_mark: |
| AMQP Protocol Binding | :x: | :x: |
| - [Proton](amqp) | :heavy_check_mark: | :heavy_check_mark: |
| AVRO Event Format | :x: | :x: |
| HTTP Protocol Binding | :heavy_check_mark: | :heavy_check_mark: |
| - [Vert.x](http/vertx) | :heavy_check_mark: | :heavy_check_mark: |
| - [Jakarta Restful WS](http/restful-ws) | :heavy_check_mark: | :heavy_check_mark: |
| - [Basic](http/basic) | :heavy_check_mark: | :heavy_check_mark: |
| - [Spring](spring) | :heavy_check_mark: | :heavy_check_mark: |
| - [http4k][http4k]<sup></sup>| :heavy_check_mark: | :heavy_check_mark: |
| JSON Event Format | :heavy_check_mark: | :heavy_check_mark: |
| - [Jackson](formats/json-jackson) | :heavy_check_mark: | :heavy_check_mark: |
| Protobuf Event Format | :heavy_check_mark: | :heavy_check_mark: |
| - [Proto](formats/protobuf) | :heavy_check_mark: | :heavy_check_mark: |
| [Kafka Protocol Binding](kafka) | :heavy_check_mark: | :heavy_check_mark: |
| MQTT Protocol Binding | :x: | :x: |
| NATS Protocol Binding | :x: | :x: |
| Web hook | :x: | :x: |
The API kept simple, for allowing a wide range of possible integrations:
<sub>† Source/artifacts hosted externally</sub>
* [CDI](cdi/)
* [Eclipse Vert.x](http/vertx/)
## Documentation
Documentation is available at https://cloudevents.github.io/sdk-java/.
Javadocs are available on [javadoc.io](https://www.javadoc.io):
- [cloudevents-api](https://www.javadoc.io/doc/io.cloudevents/cloudevents-api)
- [cloudevents-core](https://www.javadoc.io/doc/io.cloudevents/cloudevents-core)
- [cloudevents-avro-compact](https://www.javadoc.io/doc/io.cloudevents/cloudevents-avro-compact)
- [cloudevents-json-jackson](https://www.javadoc.io/doc/io.cloudevents/cloudevents-json-jackson)
- [cloudevents-protobuf](https://www.javadoc.io/doc/io.cloudevents/cloudevents-protobuf)
- [cloudevents-xml](https://www.javadoc.io/doc/io.cloudevents/cloudevents-xml)
- [cloudevents-http-basic](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-basic)
- [cloudevents-http-restful-ws](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-restful-ws)
- [cloudevents-http-vertx](https://www.javadoc.io/doc/io.cloudevents/cloudevents-http-vertx)
- [cloudevents-kafka](https://www.javadoc.io/doc/io.cloudevents/cloudevents-kafka)
- [cloudevents-amqp](https://www.javadoc.io/doc/io.cloudevents/cloudevents-amqp)
- [cloudevents-spring](https://www.javadoc.io/doc/io.cloudevents/cloudevents-spring)
You can check out the examples in the [examples](examples) directory.
## Used By
| [Occurrent](https://occurrent.org) | [Knative Eventing](https://github.com/knative-sandbox/eventing-kafka-broker )| [http4k][http4k] |
| ---------------------------------- | ---------------------------------------------------------------------------- | ---------------|
| <a href="https://occurrent.org"><img src="https://raw.githubusercontent.com/johanhaleby/occurrent/master/occurrent-logo-196x196.png" width="98" height="98" alt="Occurrent" title="Occurrent - Event Sourcing Utilities for the JVM"></img></a> | <a href="https://github.com/knative-sandbox/eventing-kafka-broker"><img src="https://cloudevents.io/img/logos/integrations/knative.png" height="98"></img></a> | <a href="https://www.http4k.org/guide/modules/cloud_events/"><img src="https://http4k.org/img/favicon-310.png" height="98" alt="http4k" title="http4k"></img></a> | |
## Community
- There are bi-weekly calls immediately following the
[Serverless/CloudEvents call](https://github.com/cloudevents/spec#meeting-time)
at 9am PT (US Pacific). Which means they will typically start at 10am PT,
but if the other call ends early then the SDK call will start early as well.
See the
[CloudEvents meeting minutes](https://docs.google.com/document/d/1OVF68rpuPK5shIHILK9JOqlZBbfe91RNzQ7u_P7YCDE/edit#)
to determine which week will have the call.
- Slack: #cloudeventssdk channel under
[CNCF's Slack workspace](https://slack.cncf.io/).
- Email: https://lists.cncf.io/g/cncf-cloudevents-sdk
- Contact for additional information: Francesco Guardiani (`@slinkydeveloper`
on slack), Fabio José (`@fabiojose` on slack).
Each SDK may have its own unique processes, tooling and guidelines, common
governance related material can be found in the
[CloudEvents `community`](https://github.com/cloudevents/spec/tree/main/docs)
directory. In particular, in there you will find information concerning how SDK
projects are
[managed](https://github.com/cloudevents/spec/blob/main/docs/SDK-GOVERNANCE.md),
[guidelines](https://github.com/cloudevents/spec/blob/main/docs/SDK-maintainer-guidelines.md)
for how PR reviews and approval, and our
[Code of Conduct](https://github.com/cloudevents/spec/blob/main/docs/GOVERNANCE.md#additional-information)
information.
If there is a security concern with one of the CloudEvents specifications, or
with one of the project's SDKs, please send an email to
[cncf-cloudevents-security@lists.cncf.io](mailto:cncf-cloudevents-security@lists.cncf.io).
## Additional SDK Resources
- [List of current active maintainers](MAINTAINERS.md)
- [How to contribute to the project](CONTRIBUTING.md)
- [SDK's License](LICENSE)
- [SDK's Release process](RELEASING.md)
- [SDK Maintainer's guide](MAINTAINERS_GUIDE.md)
[http4k]: https://www.http4k.org/guide/reference/cloud_events/

12
RELEASING.md Normal file
View File

@ -0,0 +1,12 @@
# Release Process
The release process is automated with Github actions. In order to perform a release:
1. Check if main CI pass.
1. Open the Github repository main page and go in the tab "Actions". Trigger the workflow "Bump version" and insert the new version to release. This will create a new release PR.
1. Check the release PR, merge it and cleanup the created branch.
1. Wait for the CI to complete the deploy of the modules to OSSRH.
1. Using the Github UI, create a new release, specifying the release notes and the tag to use.
1. Trigger again the workflow "Bump version" to bump versions back to a snapshot version.
1. Check the snapshot release PR, merge it and cleanup the created branch.

5
amqp/README.md Normal file
View File

@ -0,0 +1,5 @@
# AMQP Protocol Binding
Javadoc: [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-amqp-proton.svg?color=green)](http://www.javadoc.io/doc/io.cloudevents/cloudevents-amqp-proton)
Documentation: https://cloudevents.github.io/sdk-java/amqp-proton

64
amqp/pom.xml Normal file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>cloudevents-amqp-proton</artifactId>
<name>CloudEvents - Proton AMQP Binding</name>
<packaging>jar</packaging>
<properties>
<protonj.version>0.34.1</protonj.version>
<jsr305.version>3.0.2</jsr305.version>
<module-name>io.cloudevents.amqp.proton</module-name>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>proton-j</artifactId>
<version>${protonj.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${jsr305.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,91 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp;
import io.cloudevents.SpecVersion;
import io.cloudevents.amqp.impl.AmqpConstants;
import io.cloudevents.amqp.impl.ProtonAmqpBinaryMessageReader;
import io.cloudevents.amqp.impl.ProtonAmqpMessageWriter;
import io.cloudevents.core.message.MessageReader;
import io.cloudevents.core.message.MessageWriter;
import io.cloudevents.core.message.impl.GenericStructuredMessageReader;
import io.cloudevents.core.message.impl.MessageUtils;
import io.cloudevents.lang.Nullable;
import io.cloudevents.rw.CloudEventRWException;
import io.cloudevents.rw.CloudEventWriter;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.amqp.messaging.Section;
import org.apache.qpid.proton.message.Message;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* A factory class providing convenience methods for creating {@link MessageReader} and {@link MessageWriter} instances based on Qpid Proton {@link Message}.
*/
@ParametersAreNonnullByDefault
public final class ProtonAmqpMessageFactory {
private ProtonAmqpMessageFactory() {
// prevent instantiation
}
/**
* Creates a {@link MessageReader} to read a proton-based {@link Message}.
* This reader is able to read both binary and structured encoded {@link io.cloudevents.CloudEvent}.
*
* @param message The proton {@link Message} to read from.
* @return A {@link MessageReader} that can read the given proton {@link Message} to a {@link io.cloudevents.CloudEvent} representation.
* @throws CloudEventRWException if something goes wrong while resolving the {@link SpecVersion} or if the message has unknown encoding
* @see #createReader(String, ApplicationProperties, Section)
*/
public static MessageReader createReader(final Message message) throws CloudEventRWException {
return createReader(message.getContentType(), message.getApplicationProperties(), message.getBody());
}
/**
* Creates a MessageReader to read using the {@code content-type} property, {@code application-properties} and data payload
* of a proton-based {@link Message}. This reader is able to read both binary and structured encoded {@link io.cloudevents.CloudEvent}.
*
* @param contentType The {@code content-type} of the message payload.
* @param props The {@code application-properties} section of the proton-message containing cloud event metadata (attributes and/or extensions).
* @param body The message body or {@code null} if the message does not contain any body.
* @return A {@link MessageReader} capable of representing a {@link io.cloudevents.CloudEvent} from the {@code application-properties},
* {@code content-type} and payload of a proton message.
* @throws CloudEventRWException if something goes wrong while resolving the {@link SpecVersion} or if the message has unknown encoding
*/
public static MessageReader createReader(final String contentType, final ApplicationProperties props, @Nullable final Section body) throws CloudEventRWException {
final byte[] payload = AmqpConstants.getPayloadAsByteArray(body);
return MessageUtils.parseStructuredOrBinaryMessage(
() -> contentType,
format -> new GenericStructuredMessageReader(format, payload),
() -> AmqpConstants.getApplicationProperty(props, AmqpConstants.APP_PROPERTY_SPEC_VERSION, String.class),
sv -> new ProtonAmqpBinaryMessageReader(sv, props, contentType, payload)
);
}
/**
* Creates a {@link MessageWriter} capable of translating both a structured and binary CloudEvent
* to a proton-based AMQP 1.0 {@link Message}.
*
* @return A {@link MessageWriter} to write a {@link io.cloudevents.CloudEvent} to Proton {@link Message} using structured or binary encoding.
*/
public static MessageWriter<CloudEventWriter<Message>, Message> createWriter() {
return new ProtonAmqpMessageWriter<>();
}
}

View File

@ -0,0 +1,129 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp.impl;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.amqp.messaging.Data;
import org.apache.qpid.proton.amqp.messaging.Section;
import io.cloudevents.core.message.impl.MessageUtils;
/**
* Constants and methods used throughout the Proton-based implementation of the AMQP 1.0 protocol
* binding for cloud events.
*/
public final class AmqpConstants {
private AmqpConstants() {
// prevent instantiation
}
/**
* The prefix name for CloudEvent attributes for use in the <em>application-properties</em> section
* of an AMQP 1.0 message.
*/
public static final String CE_PREFIX = "cloudEvents:";
/**
* The AMQP 1.0 <em>content-type</em> message property
*/
public static final String PROPERTY_CONTENT_TYPE = "content-type";
/**
* Map a cloud event attribute name to a value. All values except the <em>datacontenttype</em> attribute are prefixed
* with "cloudEvents:" as mandated by the spec.
*/
public static final Map<String, String> ATTRIBUTES_TO_PROPERTYNAMES = MessageUtils.generateAttributesToHeadersMapping(CEA -> {
if (CEA.equals("datacontenttype")) {
return PROPERTY_CONTENT_TYPE;
}
// prefix the attribute
return CE_PREFIX + CEA;
});
public static final String APP_PROPERTY_SPEC_VERSION = ATTRIBUTES_TO_PROPERTYNAMES.get("specversion");
/**
* Gets the value of a specific <em>application property</em>.
*
* @param <T> The expected type of the property to retrieve.
* @param props The application properties to retrieve the value from.
* @param name The name of the application property.
* @param type The expected value type.
* @return The value or {@code null} if the properties do not contain a value of the expected type for the given
* name.
*/
@SuppressWarnings("unchecked")
public static <T> T getApplicationProperty(final ApplicationProperties props, final String name,
final Class<T> type) {
if (props == null) {
return null;
} else {
final Object value = props.getValue().get(name);
if (type.isInstance(value)) {
return (T) value;
} else {
return null;
}
}
}
/**
* Parses a message payload into a byte array.
* <p>
* The bytes in the array are determined as follows:
* <ul>
* <li>If the body is a Data section, the bytes contained in the
* Data section are returned.</li>
* <li>If the body is an AmqpValue section and contains a byte array,
* the bytes in the array are returned.</li>
* <li>If the body is an AmqpValue section and contains a non-empty String,
* the UTF-8 encoding of the String is returned.</li>
* <li>In all other cases, {@code null} is returned.</li>
* </ul>
* @param payload The message payload to extract the bytes from.
* @return The payload bytes or {@code null} if the above stated conditions are not met.
*/
public static byte[] getPayloadAsByteArray(final Section payload) {
if (payload == null) {
return null;
}
if (payload instanceof Data) {
final Data body = (Data) payload;
return body.getValue().getArray();
} else if (payload instanceof AmqpValue) {
final AmqpValue body = (AmqpValue) payload;
if (body.getValue() instanceof byte[]) {
return (byte[]) body.getValue();
} else if (body.getValue() instanceof String &&
((String) body.getValue()).length() > 0 ) {
return ((String) body.getValue()).getBytes(StandardCharsets.UTF_8);
}
}
return null;
}
}

View File

@ -0,0 +1,130 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp.impl;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.data.BytesCloudEventData;
import io.cloudevents.core.message.impl.BaseGenericBinaryMessageReaderImpl;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import java.util.Objects;
import java.util.function.BiConsumer;
/**
* An AMQP 1.0 message reader that can be read as a <em>CloudEvent</em>.
* <p>
*
* This reader reads sections of an AMQP message to construct a CloudEvent representation by doing the following:
* <ul>
* <li> If the content-type property is set for an AMQP message, the value of the property
* is represented as a cloud event datacontenttype attribute.
* <li> If the (mandatory) application-properties of the AMQP message contains attributes and/or extentions,
* this reader will represent each property/extension as a cloud event attribute.
* </ul>
*
*/
public final class ProtonAmqpBinaryMessageReader extends BaseGenericBinaryMessageReaderImpl<String, Object> {
private final String contentType;
private final ApplicationProperties applicationProperties;
/**
* Create an instance of an AMQP message reader.
*
* @param version The version of the cloud event message.
* @param applicationProperties The application properties of the AMQP message that contains
* the cloud event metadata (i.e attributes and extensions).
* The applicationProperties MUST not be {@code null}.
* @param contentType The content-type property of the AMQP message or {@code null} if the message content type is unknown.
* @param payload The message payload or {@code null} if the message does not contain any payload.
*
* @throws NullPointerException if the applicationPropereties is {@code null}.
*/
public ProtonAmqpBinaryMessageReader(final SpecVersion version, final ApplicationProperties applicationProperties,
final String contentType, final byte[] payload) {
super(version, payload != null && payload.length > 0 ? BytesCloudEventData.wrap(payload) : null);
this.contentType = contentType;
this.applicationProperties = Objects.requireNonNull(applicationProperties);
}
@Override
protected boolean isContentTypeHeader(final String key) {
return key.equals(AmqpConstants.PROPERTY_CONTENT_TYPE);
}
/**
* Tests whether the given attribute key is prefixed with <em>cloudEvents:</em>
*
* @param key The key to test for the presence of the prefix.
* @return True if the specified key starts with the prefix or
* false otherwise.
*/
@Override
protected boolean isCloudEventsHeader(final String key) {
final int prefixLength = AmqpConstants.CE_PREFIX.length();
return key.length() > prefixLength && key.startsWith(AmqpConstants.CE_PREFIX);
}
/**
* Gets the cloud event attribute key without the preceding prefix.
*
* @param key The key containing the AMQP specific prefix.
*
* @return The key without the prefix.
*/
@Override
protected String toCloudEventsKey(final String key) {
return key.substring(AmqpConstants.CE_PREFIX.length());
}
/**
* Visits the <em>content-type</em> message property and all <em>application-properties</em> of this message reader.
* <p>
* This method only visits properties containing a name and value which are not {@code null}.
*
* @param fn A callback to consume this reader's application-properties
* and content-type property.
*/
@Override
protected void forEachHeader(final BiConsumer<String, Object> fn) {
if (contentType != null) {
// visit the content-type message property
fn.accept(AmqpConstants.PROPERTY_CONTENT_TYPE, contentType);
}
// visit application-properties
applicationProperties.getValue().forEach((k, v) -> {
if (k != null && v != null) {
fn.accept(k, v);
}
});
}
/**
* Gets the cloud event representation of the value.
* <p>
* This method simply returns the string representation of the type of value passed as argument.
*
* @param value The value of a CloudEvent attribute or extension.
*
* @return The string representation of the specified value.
*/
@Override
protected String toCloudEventsValue(final Object value) {
return value.toString();
}
}

View File

@ -0,0 +1,101 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp.impl;
import io.cloudevents.CloudEventData;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.format.EventFormat;
import io.cloudevents.core.message.MessageWriter;
import io.cloudevents.core.v1.CloudEventV1;
import io.cloudevents.rw.CloudEventContextWriter;
import io.cloudevents.rw.CloudEventRWException;
import io.cloudevents.rw.CloudEventWriter;
import org.apache.qpid.proton.amqp.Binary;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.amqp.messaging.Data;
import org.apache.qpid.proton.message.Message;
import java.util.HashMap;
/**
* A proton-based MessageWriter capable of writing both structured and binary CloudEvent messages to an AMQP 1.0 representation as
* mandated by the AMQP 1.0 protocol binding specification for cloud events.
* <p>
* This writer returns an AMQP message at the end of the write process.
*/
public final class ProtonAmqpMessageWriter<R> implements MessageWriter<CloudEventWriter<Message>, Message>, CloudEventWriter<Message> {
private ApplicationProperties applicationProperties;
private Message message;
/**
* Creates a proton-base message writer.
*/
public ProtonAmqpMessageWriter() {
message = Message.Factory.create();
}
@Override
public CloudEventContextWriter withContextAttribute(String name, String value) throws CloudEventRWException {
if (name.equals(CloudEventV1.DATACONTENTTYPE)) {
message.setContentType(value);
} else {
// for now, extensions are mapped to application-properties
// see https://github.com/cloudevents/sdk-java/issues/30#issuecomment-723982190
if (applicationProperties == null) {
throw new IllegalStateException("This Writer is not initialized");
}
String propName = AmqpConstants.ATTRIBUTES_TO_PROPERTYNAMES.get(name);
if (propName == null) {
propName = name;
}
applicationProperties.getValue().put(propName, value);
}
return this;
}
@Override
public ProtonAmqpMessageWriter<R> create(final SpecVersion version) {
if (applicationProperties == null) {
applicationProperties = new ApplicationProperties(new HashMap<>());
}
applicationProperties.getValue().put(AmqpConstants.APP_PROPERTY_SPEC_VERSION, version.toString());
return this;
}
@Override
public Message setEvent(final EventFormat format, final byte[] value) throws CloudEventRWException {
message.setContentType(format.serializedContentType());
message.setBody(new Data(new Binary(value)));
return message;
}
@Override
public Message end(final CloudEventData data) throws CloudEventRWException {
message.setBody(new Data(new Binary(data.toBytes())));
message.setApplicationProperties(applicationProperties);
return message;
}
@Override
public Message end() {
message.setBody(null);
message.setApplicationProperties(applicationProperties);
return message;
}
}

View File

@ -0,0 +1,240 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp;
import io.cloudevents.CloudEvent;
import io.cloudevents.SpecVersion;
import io.cloudevents.amqp.impl.AmqpConstants;
import io.cloudevents.core.message.Encoding;
import io.cloudevents.core.message.MessageReader;
import io.cloudevents.core.mock.CSVFormat;
import io.cloudevents.core.test.Data;
import io.cloudevents.core.v03.CloudEventV03;
import io.cloudevents.core.v1.CloudEventV1;
import io.cloudevents.types.Time;
import org.apache.qpid.proton.amqp.Binary;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.amqp.messaging.Section;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests verifying the behavior of the {@code ProtonAmqpMessageFactory}.
*/
public class ProtonAmqpMessageFactoryTest {
private static final String PREFIX_TEMPLATE = AmqpConstants.CE_PREFIX + "%s";
private static final String DATACONTENTTYPE_NULL = null;
private static final byte[] DATAPAYLOAD_NULL = null;
@ParameterizedTest()
@MethodSource("binaryTestArguments")
public void readBinary(final Map<String, Object> props, final String contentType, final byte[] body,
final CloudEvent event) {
final Section bodySection = body != null ? new org.apache.qpid.proton.amqp.messaging.Data(new Binary(body)) : null;
final MessageReader amqpReader = ProtonAmqpMessageFactory.createReader(contentType, new ApplicationProperties(props), bodySection);
assertThat(amqpReader.getEncoding()).isEqualTo(Encoding.BINARY);
assertThat(amqpReader.toEvent()).isEqualTo(event);
}
@ParameterizedTest()
@MethodSource("io.cloudevents.core.test.Data#allEventsWithoutExtensions")
public void readStructured(final CloudEvent event) {
final String contentType = CSVFormat.INSTANCE.serializedContentType() + "; charset=utf8";
final byte[] contentPayload = CSVFormat.INSTANCE.serialize(event);
final MessageReader amqpReader = ProtonAmqpMessageFactory.createReader(contentType, null, new org.apache.qpid.proton.amqp.messaging.Data(new Binary(contentPayload)));
assertThat(amqpReader.getEncoding()).isEqualTo(Encoding.STRUCTURED);
assertThat(amqpReader.toEvent()).isEqualTo(event);
}
private static Stream<Arguments> binaryTestArguments() {
return Stream.of(
// V03
Arguments.of(
properties(
property(CloudEventV03.SPECVERSION, SpecVersion.V03.toString()),
property(CloudEventV03.ID, Data.ID),
property(CloudEventV03.TYPE, Data.TYPE),
property(CloudEventV03.SOURCE, Data.SOURCE),
property("ignored", "ignore")
),
DATACONTENTTYPE_NULL,
DATAPAYLOAD_NULL,
Data.V03_MIN
),
Arguments.of(
properties(
property(CloudEventV03.SPECVERSION, SpecVersion.V03.toString()),
property(CloudEventV03.ID, Data.ID),
property(CloudEventV03.TYPE, Data.TYPE),
property(CloudEventV03.SOURCE, Data.SOURCE.toString()),
property(CloudEventV03.SCHEMAURL, Data.DATASCHEMA.toString()),
property(CloudEventV03.SUBJECT, Data.SUBJECT),
property(CloudEventV03.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignore")
),
Data.DATACONTENTTYPE_JSON,
Data.DATA_JSON_SERIALIZED,
Data.V03_WITH_JSON_DATA
),
Arguments.of(
properties(
property(CloudEventV03.SPECVERSION, SpecVersion.V03.toString()),
property(CloudEventV03.ID, Data.ID),
property(CloudEventV03.TYPE, Data.TYPE),
property(CloudEventV03.SOURCE, Data.SOURCE.toString()),
property(CloudEventV03.SCHEMAURL, Data.DATASCHEMA.toString()),
property(CloudEventV03.SUBJECT, Data.SUBJECT),
property(CloudEventV03.TIME, Time.writeTime(Data.TIME)),
property("astring", "aaa"),
property("aboolean", "true"),
property("anumber", "10"),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_JSON,
Data.DATA_JSON_SERIALIZED,
Data.V03_WITH_JSON_DATA_WITH_EXT_STRING
),
Arguments.of(
properties(
property(CloudEventV03.SPECVERSION, SpecVersion.V03.toString()),
property(CloudEventV03.ID, Data.ID),
property(CloudEventV03.TYPE, Data.TYPE),
property(CloudEventV03.SOURCE, Data.SOURCE.toString()),
property(CloudEventV03.SUBJECT, Data.SUBJECT),
property(CloudEventV03.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_XML,
Data.DATA_XML_SERIALIZED,
Data.V03_WITH_XML_DATA
),
Arguments.of(
properties(
property(CloudEventV03.SPECVERSION, SpecVersion.V03.toString()),
property(CloudEventV03.ID, Data.ID),
property(CloudEventV03.TYPE, Data.TYPE),
property(CloudEventV03.SOURCE, Data.SOURCE.toString()),
property(CloudEventV03.SUBJECT, Data.SUBJECT),
property(CloudEventV03.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_TEXT,
Data.DATA_TEXT_SERIALIZED,
Data.V03_WITH_TEXT_DATA
),
// V1
Arguments.of(
properties(
property(CloudEventV1.SPECVERSION, SpecVersion.V1.toString()),
property(CloudEventV1.ID, Data.ID),
property(CloudEventV1.TYPE, Data.TYPE),
property(CloudEventV1.SOURCE, Data.SOURCE.toString()),
property("ignored", "ignored")
),
DATACONTENTTYPE_NULL,
DATAPAYLOAD_NULL,
Data.V1_MIN
),
Arguments.of(
properties(
property(CloudEventV1.SPECVERSION, SpecVersion.V1.toString()),
property(CloudEventV1.ID, Data.ID),
property(CloudEventV1.TYPE, Data.TYPE),
property(CloudEventV1.SOURCE, Data.SOURCE.toString()),
property(CloudEventV1.DATASCHEMA, Data.DATASCHEMA.toString()),
property(CloudEventV1.SUBJECT, Data.SUBJECT),
property(CloudEventV1.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_JSON,
Data.DATA_JSON_SERIALIZED,
Data.V1_WITH_JSON_DATA
),
Arguments.of(
properties(
property(CloudEventV1.SPECVERSION, SpecVersion.V1.toString()),
property(CloudEventV1.ID, Data.ID),
property(CloudEventV1.TYPE, Data.TYPE),
property(CloudEventV1.SOURCE, Data.SOURCE.toString()),
property(CloudEventV1.DATASCHEMA, Data.DATASCHEMA.toString()),
property(CloudEventV1.SUBJECT, Data.SUBJECT),
property(CloudEventV1.TIME, Time.writeTime(Data.TIME)),
property("astring", "aaa"),
property("aboolean", "true"),
property("anumber", "10"),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_JSON,
Data.DATA_JSON_SERIALIZED,
Data.V1_WITH_JSON_DATA_WITH_EXT_STRING
),
Arguments.of(
properties(
property(CloudEventV1.SPECVERSION, SpecVersion.V1.toString()),
property(CloudEventV1.ID, Data.ID),
property(CloudEventV1.TYPE, Data.TYPE),
property(CloudEventV1.SOURCE, Data.SOURCE.toString()),
property(CloudEventV1.SUBJECT, Data.SUBJECT),
property(CloudEventV1.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_XML,
Data.DATA_XML_SERIALIZED,
Data.V1_WITH_XML_DATA
),
Arguments.of(
properties(
property(CloudEventV1.SPECVERSION, SpecVersion.V1.toString()),
property(CloudEventV1.ID, Data.ID),
property(CloudEventV1.TYPE, Data.TYPE),
property(CloudEventV1.SOURCE, Data.SOURCE.toString()),
property(CloudEventV1.SUBJECT, Data.SUBJECT),
property(CloudEventV1.TIME, Time.writeTime(Data.TIME)),
property("ignored", "ignored")
),
Data.DATACONTENTTYPE_TEXT,
Data.DATA_TEXT_SERIALIZED,
Data.V1_WITH_TEXT_DATA
)
);
}
private static final SimpleEntry<String, Object> property(final String name, final Object value) {
return name.equalsIgnoreCase("ignored") ?
new SimpleEntry<>(name, value) :
new SimpleEntry<>(String.format(PREFIX_TEMPLATE, name), value);
}
@SafeVarargs
private static final Map<String, Object> properties(final SimpleEntry<String, Object>... entries) {
return Stream.of(entries)
.collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue));
}
}

View File

@ -0,0 +1,124 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.amqp;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.qpid.proton.amqp.Binary;
import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
import org.apache.qpid.proton.amqp.messaging.Section;
import org.apache.qpid.proton.message.Message;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import io.cloudevents.CloudEvent;
import io.cloudevents.amqp.impl.ProtonAmqpMessageWriter;
import io.cloudevents.core.format.EventFormat;
import io.cloudevents.core.message.MessageWriter;
import io.cloudevents.core.mock.CSVFormat;
/**
* Tests verifying the behavior of the {@code ProtonAmqpMessageWriter}.
*/
public class ProtonAmqpMessageWriterTest {
/**
* Verifies that a binary CloudEvent message can be successfully represented
* as an AMQP message.
*/
@ParameterizedTest()
@MethodSource("io.cloudevents.core.test.Data#allEventsWithStringExtensions")
public void testWriteBinaryCloudEventToAmqpRepresentation(final CloudEvent binaryEvent) {
final Message expectedMessage = translateBinaryEvent(binaryEvent);
final MessageWriter<?, Message> writer = new ProtonAmqpMessageWriter<Message>();
final Message actualMessage = writer.writeBinary(binaryEvent);
assertThat(actualMessage.getContentType()).isEqualTo(expectedMessage.getContentType());
assertThat(Objects.toString(actualMessage.getBody())).isEqualTo(Objects.toString(expectedMessage.getBody()));
assertThat(actualMessage.getApplicationProperties().getValue()).
isEqualTo(expectedMessage.getApplicationProperties().getValue());
}
/**
* Verifies that a structured CloudEvent message (in CSV format) can be successfully represented
* as an AMQP message.
*/
@ParameterizedTest()
@MethodSource("io.cloudevents.core.test.Data#allEventsWithoutExtensions")
public void testWriteStructuredCloudEventToAmqpRepresentation(final CloudEvent event) {
final EventFormat format = CSVFormat.INSTANCE;
final Message expectedMessage = translateStructured(event, format);
final MessageWriter<?, Message> writer = new ProtonAmqpMessageWriter<Message>();
final Message actualMessage = writer.writeStructured(event, format.serializedContentType());
assertThat(actualMessage.getContentType()).isEqualTo(expectedMessage.getContentType());
assertThat(Objects.toString(actualMessage.getBody())).isEqualTo(Objects.toString(expectedMessage.getBody()));
assertThat(actualMessage.getApplicationProperties()).isNull();
}
private Message translateBinaryEvent(final CloudEvent event) {
final Message message = Message.Factory.create();
final Map<String, Object> map = new HashMap<>();
if (!event.getAttributeNames().isEmpty()) {
event.getAttributeNames().forEach(name -> {
if (name.equals("datacontentencoding")) {
// ignore
} else if (name.equals("datacontenttype") && event.getAttribute(name) != null) {
message.setContentType(event.getAttribute(name).toString());
} else {
addProperty(map, name, Objects.toString(event.getAttribute(name)), true);
}
});
}
if (!event.getExtensionNames().isEmpty()) {
event.getExtensionNames().forEach(name -> addProperty(map, name, Objects.toString(event.getExtension(name)), false));
}
if (event.getData() != null) {
final Section payload = new org.apache.qpid.proton.amqp.messaging.Data(new Binary(event.getData().toBytes()));
message.setBody(payload);
}
message.setApplicationProperties(new ApplicationProperties(map));
return message;
}
private Message translateStructured(final CloudEvent event, final EventFormat format) {
final Message message = Message.Factory.create();
message.setContentType(format.serializedContentType());
message.setBody(new org.apache.qpid.proton.amqp.messaging.Data(new Binary(format.serialize(event))));
return message;
}
private void addProperty(final Map<String, Object> map, final String name, final String value, final boolean prefix) {
if (prefix) {
map.put(String.format("cloudEvents:%s", name), value);
} else {
map.put(name, value);
}
}
}

5
api/README.md Normal file
View File

@ -0,0 +1,5 @@
# CloudEvents API
Javadoc: [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-api.svg?color=green)](http://www.javadoc.io/doc/io.cloudevents/cloudevents-api)
Documentation: https://cloudevents.github.io/sdk-java/api

View File

@ -1,67 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2018 The CloudEvents Authors
~ Copyright 2018-Present The CloudEvents Authors
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>0.2.1</version>
<version>4.1.0-SNAPSHOT</version>
</parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<name>CloudEvents - API</name>
<version>0.2.1</version>
<packaging>jar</packaging>
<properties>
<module-name>io.cloudevents.api</module-name>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.10.0</version>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<jackson.version>2.9.6</jackson.version>
</properties>
</project>

View File

@ -1,78 +1,32 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.cloudevents.impl.DefaultCloudEventImpl;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
import io.cloudevents.lang.Nullable;
/**
* An abstract event envelope, representing the 0.2 version of the <a href="https://github.com/cloudevents/spec/blob/master/spec.md">CNCF CloudEvent spec</a>.
*
* Interface representing an in memory read only representation of a CloudEvent,
* as specified by the <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md">CloudEvents specification</a>.
*/
@JsonDeserialize(as = DefaultCloudEventImpl.class)
public interface CloudEvent<T> {
public interface CloudEvent extends CloudEventContext {
/**
* Type of occurrence which has happened. Often this property is used for routing, observability, policy enforcement, etc.
* @return The event data, if any, otherwise {@code null}
*/
String getType();
/**
* The version of the CloudEvents specification which the event uses. This enables the interpretation of the context.
*/
String getSpecVersion();
/**
* This describes the event producer. Often this will include information such as the type of the event source, the organization publishing the event, and some unique identifiers.
* The exact syntax and semantics behind the data encoded in the URI is event producer defined.
*/
URI getSource();
/**
* ID of the event. The semantics of this string are explicitly undefined to ease the implementation of producers. Enables deduplication.
*/
String getId();
/**
* Timestamp of when the event happened.
*/
Optional<ZonedDateTime> getTime();
/**
* A link to the schema that the data attribute adheres to.
*/
Optional<URI> getSchemaURL();
/**
* Describe the data encoding format
*/
Optional<String> getContentType();
/**
* The event payload. The payload depends on the eventType, schemaURL and eventTypeVersion, the payload is encoded into a media format which is specified by the contentType attribute (e.g. application/json).
*/
Optional<T> getData();
/**
*
*/
Optional<List<Extension>> getExtensions();
}
@Nullable
CloudEventData getData();
}

View File

@ -0,0 +1,103 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import io.cloudevents.lang.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.net.URI;
import java.time.OffsetDateTime;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Interface which defines CloudEvent attributes as per specification
* <p>
* For more info: <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#context-attributes">Context attributes</a>
*/
@ParametersAreNonnullByDefault
public interface CloudEventAttributes {
/**
* @return The version of the CloudEvents specification which the event uses
*/
SpecVersion getSpecVersion();
/**
* @return Identifies the event. Producers MUST ensure that source + id is unique for each distinct event
*/
String getId();
/**
* @return A value describing the type of event related to the originating occurrence.
*/
String getType();
/**
* @return The context in which an event happened.
*/
URI getSource();
/**
* A common way to get the media type of CloudEvents 'data';
*
* @return If has a value, it MUST follows the <a href="https://tools.ietf.org/html/rfc2046">RFC2046</a>
*/
@Nullable
String getDataContentType();
/**
* @return Return the URI specifying the location of the schema for the provided data
*/
@Nullable
URI getDataSchema();
/**
* @return <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#subject">Subject</a> of the event
*/
@Nullable
String getSubject();
/**
* @return <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#time">Timestamp</a> of when the occurrence happened
*/
@Nullable
OffsetDateTime getTime();
/**
* Get the <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#context-attributes">context attribute</a> named {@code attributeName}
*
* @param attributeName a valid attribute name
* @return the attribute value or null if this instance doesn't contain such attribute
* @throws IllegalArgumentException if the provided attribute name it's not a valid attribute for this spec
*/
@Nullable
Object getAttribute(String attributeName) throws IllegalArgumentException;
/**
* @return The non-null <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#context-attributes">context attributes</a> names in this instance
*/
default Set<String> getAttributeNames() {
return getSpecVersion()
.getAllAttributes()
.stream()
.filter(s -> getAttribute(s) != null)
.collect(Collectors.toSet());
}
}

View File

@ -1,130 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents;
import io.cloudevents.impl.DefaultCloudEventImpl;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Builder class to create a Java Object representing a CloudEvent implementation
* @param <T> type of the data field
*/
public class CloudEventBuilder<T> {
private String specversion;
private String contentType;
private String type;
private URI source;
private String id;
private ZonedDateTime time;
private URI schemaURL;
private T data;
private final List<Extension> extensions = new ArrayList<>();
/**
* The version of the CloudEvents specification which the event uses.
*/
public CloudEventBuilder<T> specVersion(final String specVersion) {
this.specversion = specVersion;
return this;
}
/**
* Type of occurrence which has happened. Often this property is used for routing, observability, policy enforcement, etc.
*/
public CloudEventBuilder<T> type(final String type) {
this.type = type;
return this;
}
/**
* This describes the event producer. Often this will include information such as the type of the event source, the organization publishing the event, and some unique identifiers.
* The exact syntax and semantics behind the data encoded in the URI is event producer defined.
*/
public CloudEventBuilder<T> source(final URI source) {
this.source = source;
return this;
}
/**
* ID of the event. The semantics of this string are explicitly undefined to ease the implementation of producers. Enables deduplication.
*/
public CloudEventBuilder<T> id(final String id) {
this.id = id;
return this;
}
/**
* Timestamp of when the event happened.
*/
public CloudEventBuilder<T> time(final ZonedDateTime time) {
this.time = time;
return this;
}
/**
* A link to the schema that the data attribute adheres to.
*/
public CloudEventBuilder<T> schemaURL(final URI schemaURL) {
this.schemaURL = schemaURL;
return this;
}
/**
* Describe the data encoding format
*/
public CloudEventBuilder<T> contentType(final String contentType) {
this.contentType = contentType;
return this;
}
/**
* The event payload. The payload depends on the type and schemaURL, the payload is encoded into a media format which is specified by the contenttype attribute (e.g. application/json).
*/
public CloudEventBuilder<T> data(final T data) {
this.data = data;
return this;
}
public CloudEventBuilder<T> extension(final Extension extension) {
this.extensions.add(extension);
return this;
}
/**
* Constructs a new {@link CloudEvent} with the previously-set configuration.
*/
public CloudEvent<T> build() {
// forcing latest (default) version
if (specversion == null) {
specversion = SpecVersion.DEFAULT.toString();
}
if (type == null || source == null || id == null) {
throw new IllegalArgumentException("please provide all required fields");
}
return new DefaultCloudEventImpl<T>(type, specversion, source, id, time, schemaURL, contentType, data, extensions);
}
}

View File

@ -1,19 +1,23 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
public interface Extension {
/**
* Interface representing an in memory read only representation of CloudEvent attributes and extensions.
*/
public interface CloudEventContext extends CloudEventAttributes, CloudEventExtensions {
}

View File

@ -0,0 +1,36 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
/**
* Interface that defines a wrapper for CloudEvent data.
* <p>
* This interface can be overridden to include any type of data inside a {@link CloudEvent}, given it has a method to convert back to bytes.
*/
public interface CloudEventData {
/**
* Returns the bytes representation of this data instance.
* <p>
* Note: depending on the implementation, this operation may be expensive.
*
* @return this data, represented as bytes.
*/
byte[] toBytes();
}

View File

@ -0,0 +1,55 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import io.cloudevents.lang.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Set;
/**
* Materialized CloudEvent extension interface to read/write the extension attributes key/values.
*/
@ParametersAreNonnullByDefault
public interface CloudEventExtension {
/**
* Fill this materialized extension with values from a {@link CloudEventExtensions} implementation.
*
* @param extensions the extensions where to read from
*/
void readFrom(CloudEventExtensions extensions);
/**
* Get the attribute of extension named {@code key}.
*
* @param key the name of the extension attribute
* @return the extension value in one of the valid types String/Number/Boolean/URI/OffsetDateTime/byte[]
* @throws IllegalArgumentException if the key is unknown to this extension
*/
@Nullable
Object getValue(String key) throws IllegalArgumentException;
/**
* Get the set of possible extension attribute keys
*
* @return set of possible extension attribute keys
*/
Set<String> getKeys();
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import io.cloudevents.lang.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Set;
/**
* The event extensions.
* <p>
* Extensions values could be String/Number/Boolean
*/
@ParametersAreNonnullByDefault
public interface CloudEventExtensions {
/**
* Get the extension attribute named {@code extensionName}
*
* @param extensionName the extension name
* @return the extension value in one of the valid types String/Number/Boolean or null if this instance doesn't contain such extension
*/
@Nullable
Object getExtension(String extensionName);
/**
* @return The non-null extension attributes names in this instance
*/
Set<String> getExtensionNames();
}

View File

@ -1,68 +1,106 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import java.util.HashMap;
import java.util.Map;
import io.cloudevents.rw.CloudEventRWException;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Represents one of the supported CloudEvents specification versions by this library
*/
@ParametersAreNonnullByDefault
public enum SpecVersion {
/**
* @see <a href="https://github.com/cloudevents/spec/releases/tag/v0.3">CloudEvents release v0.3</a>
*/
V03(
"0.3",
Arrays.asList("specversion", "id", "type", "source"),
Arrays.asList("datacontenttype", "datacontentencoding", "schemaurl", "subject", "time")
),
/**
* @see <a href="https://github.com/cloudevents/spec/releases/tag/v1.0">CloudEvents release v1.0</a>
*/
V1(
"1.0",
Arrays.asList("specversion", "id", "type", "source"),
Arrays.asList("datacontenttype", "dataschema", "subject", "time")
);
V_01("0.1"),
V_02("0.2"),
DEFAULT(V_02.toString());
private final String stringValue;
private final Set<String> mandatoryAttributes;
private final Set<String> optionalAttributes;
private final Set<String> allAttributes;
private final String version;
SpecVersion(final String version) {
this.version = version;
SpecVersion(String stringValue, Collection<String> mandatoryAttributes, Collection<String> optionalAttributes) {
this.stringValue = stringValue;
this.mandatoryAttributes = Collections.unmodifiableSet(new HashSet<>(mandatoryAttributes));
this.optionalAttributes = Collections.unmodifiableSet(new HashSet<>(optionalAttributes));
this.allAttributes = Collections.unmodifiableSet(
Stream.concat(mandatoryAttributes.stream(), optionalAttributes.stream()).collect(Collectors.toSet())
);
}
@Override
public String toString() {
return version;
return this.stringValue;
}
public String version() {
return version;
}
public static SpecVersion fromVersion(final String version) {
if (version == null)
return null;
final SpecVersion specVersion= VERSION_TO_SPEC.get(version);
if (specVersion == null)
throw new IllegalArgumentException();
return specVersion;
}
private static final Map<String, SpecVersion> VERSION_TO_SPEC =
new HashMap<>();
static
{
SpecVersion[] instances = SpecVersion.class.getEnumConstants();
for (int i = 0; i < instances.length; i++)
{
VERSION_TO_SPEC.put(instances[i].toString(), instances[i]);
/**
* Parse a string as {@link SpecVersion}
*
* @param sv String representing the spec version
* @return The parsed spec version
* @throws CloudEventRWException When the spec version string is unrecognized
*/
public static SpecVersion parse(String sv) {
switch (sv) {
case "0.3":
return SpecVersion.V03;
case "1.0":
return SpecVersion.V1;
default:
throw CloudEventRWException.newInvalidSpecVersion(sv);
}
}
/**
* @return mandatory attributes of the spec version
*/
public Set<String> getMandatoryAttributes() {
return mandatoryAttributes;
}
/**
* @return optional attributes of the spec version
*/
public Set<String> getOptionalAttributes() {
return optionalAttributes;
}
/**
* @return all attributes for this spec
*/
public Set<String> getAllAttributes() {
return allAttributes;
}
}

View File

@ -1,33 +0,0 @@
package io.cloudevents.extensions;
import io.cloudevents.Extension;
public class DistributedTracingExtension implements Extension {
private String traceparent;
private String tracestate;
public String getTraceparent() {
return traceparent;
}
public void setTraceparent(String traceparent) {
this.traceparent = traceparent;
}
public String getTracestate() {
return tracestate;
}
public void setTracestate(String tracestate) {
this.tracestate = tracestate;
}
@Override
public String toString() {
return "DistributedTracingExtension{" +
"traceparent='" + traceparent + '\'' +
", tracestate='" + tracestate + '\'' +
'}';
}
}

View File

@ -1,46 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.http;
import io.cloudevents.SpecVersion;
import static io.cloudevents.SpecVersion.V_01;
public interface HttpTransportAttributes {
// required attrs
String typeKey();
String specVersionKey();
String sourceKey();
String idKey();
// none-required attrs
String timeKey();
String schemaUrlKey();
static HttpTransportAttributes getHttpAttributesForSpec(final SpecVersion specVersion) {
switch (specVersion) {
case V_01: return new V01HttpTransportMappers();
case V_02:
case DEFAULT: return new V02HttpTransportMappers();
}
// you should not be here!
throw new IllegalArgumentException("Could not find proper version");
}
}

View File

@ -1,51 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.http;
public class V01HttpTransportMappers implements HttpTransportAttributes {
public static final String SPEC_VERSION_KEY = "ce-cloudEventsVersion";
@Override
public String typeKey() {
return "ce-eventType";
}
@Override
public String specVersionKey() {
return SPEC_VERSION_KEY;
}
@Override
public String sourceKey() {
return "ce-source";
}
@Override
public String idKey() {
return "ce-eventID";
}
@Override
public String timeKey() {
return "ce-eventTime";
}
@Override
public String schemaUrlKey() {
return "ce-schemaURL";
}
}

View File

@ -1,47 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.http;
public class V02HttpTransportMappers extends V01HttpTransportMappers {
public static final String SPEC_VERSION_KEY = "ce-specversion";
@Override
public String typeKey() {
return "ce-type";
}
@Override
public String specVersionKey() {
return SPEC_VERSION_KEY;
}
@Override
public String idKey() {
return "ce-id";
}
@Override
public String timeKey() {
return "ce-time";
}
@Override
public String schemaUrlKey() {
return "ce-schemaurl";
}
}

View File

@ -1,164 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.impl;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.cloudevents.CloudEvent;
import io.cloudevents.Extension;
import io.cloudevents.json.ZonedDateTimeDeserializer;
import java.io.Serializable;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Optional;
/**
* Default Java implementation of the CloudEvent API.
*
* @param <T> generic type of the underlying data field.
*/
@JsonIgnoreProperties(value = { "eventTypeVersion", "extensions" }) // was removed from 0.1
public class DefaultCloudEventImpl<T> implements CloudEvent<T>, Serializable {
private static final long serialVersionUID = 2L;
private String specversion;
private String type = null;
private URI source = null;
private String id = null;
private ZonedDateTime time = null;
private URI schemaURL = null;
private String contentType = null;
private T data = null;
private List<Extension> extensions = null;
public DefaultCloudEventImpl(final String type, final String specversion, final URI source, final String id, final ZonedDateTime time, final URI schemaURL, final String contentType, final T data, final List<Extension> extensions) {
this.specversion = specversion;
this.type = type;
this.source = source;
this.id = id;
this.time = time;
this.schemaURL = schemaURL;
this.contentType = contentType;
this.data = data;
this.extensions = extensions;
}
DefaultCloudEventImpl() {
// no-op
}
@Override
public String getSpecVersion() {
return specversion;
}
@Override
public String getType() {
return type;
}
@Override
public URI getSource() {
return source;
}
@Override
public String getId() {
return id;
}
@Override
public Optional<ZonedDateTime> getTime() {
return Optional.ofNullable(time);
}
@Override
public Optional<URI> getSchemaURL() {
return Optional.ofNullable(schemaURL);
}
@Override
public Optional<String> getContentType() {
return Optional.ofNullable(contentType);
}
@Override
public Optional<T> getData() {
return Optional.ofNullable(data);
}
@Override
public Optional<List<Extension>> getExtensions() {
return Optional.ofNullable(extensions);
}
// protected setters, used for (JSON) deserialization
@JsonAlias({"specversion", "specVersion", "cloudEventsVersion"})
void setSpecversion(String specversion) {
this.specversion = specversion;
}
@JsonAlias({"type", "eventType"})
void setType(String type) {
this.type = type;
}
void setSource(URI source) {
this.source = source;
}
@JsonAlias({"id", "eventID"})
void setId(String id) {
this.id = id;
}
@JsonDeserialize(using = ZonedDateTimeDeserializer.class)
@JsonAlias({"time", "eventTime"})
void setTime(ZonedDateTime time) {
this.time = time;
}
void setSchemaURL(URI schemaURL) {
this.schemaURL = schemaURL;
}
void setContentType(String contentType) {
this.contentType = contentType;
}
void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return "DefaultCloudEventImpl{" +
"specversion='" + specversion + '\'' +
", type='" + type + '\'' +
", source=" + source +
", id='" + id + '\'' +
", time=" + time +
", schemaURL=" + schemaURL +
", contentType='" + contentType + '\'' +
", data=" + data +
'}';
}
}

View File

@ -1,113 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.json;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import io.cloudevents.CloudEvent;
import io.cloudevents.impl.DefaultCloudEventImpl;
import java.io.InputStream;
import java.time.ZonedDateTime;
public final class Json {
public static final ObjectMapper MAPPER = new ObjectMapper();
static {
// add Jackson datatype for ZonedDateTime
MAPPER.registerModule(new Jdk8Module());
final SimpleModule module = new SimpleModule();
module.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer());
module.addDeserializer(ZonedDateTime.class, new ZonedDateTimeDeserializer());
MAPPER.registerModule(module);
}
/**
* Encode a POJO to JSON using the underlying Jackson mapper.
*
* @param obj a POJO
* @return a String containing the JSON representation of the given POJO.
* @throws IllegalStateException if a property cannot be encoded.
*/
public static String encode(final Object obj) throws IllegalStateException {
try {
return MAPPER.writeValueAsString(obj);
} catch (Exception e) {
throw new IllegalStateException("Failed to encode as JSON: " + e.getMessage());
}
}
public static CloudEvent fromInputStream(final InputStream inputStream) {
try {
return MAPPER.readValue(inputStream, DefaultCloudEventImpl.class);
} catch (Exception e) {
throw new IllegalStateException("Failed to encode as JSON: " + e.getMessage());
}
}
/**
* Decode a given JSON string to a CloudEvent .
*
* @param str the JSON string.
* @return an instance of CloudEvent
* @throws IllegalStateException when there is a parsing or invalid mapping.
*/
public static DefaultCloudEventImpl decodeCloudEvent(final String str) throws IllegalStateException {
return decodeValue(str, DefaultCloudEventImpl.class);
}
/**
* Decode a given JSON string to a POJO of the given class type.
*
* @param str the JSON string.
* @param clazz the class to map to.
* @param <T> the generic type.
* @return an instance of T
* @throws IllegalStateException when there is a parsing or invalid mapping.
*/
protected static <T> T decodeValue(final String str, final Class<T> clazz) throws IllegalStateException {
try {
return MAPPER.readValue(str, clazz);
} catch (Exception e) {
throw new IllegalStateException("Failed to decode: " + e.getMessage());
}
}
/**
* Decode a given JSON string to a POJO of the given type.
*
* @param str the JSON string.
* @param type the type to map to.
* @param <T> the generic type.
* @return an instance of T
* @throws IllegalStateException when there is a parsing or invalid mapping.
*/
public static <T> T decodeValue(final String str, final TypeReference<T> type) throws IllegalStateException {
try {
return MAPPER.readValue(str, type);
} catch (Exception e) {
throw new IllegalStateException("Failed to decode: " + e.getMessage(), e);
}
}
private Json() {
// no-op
}
}

View File

@ -1,46 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.json;
import java.io.IOException;
import java.time.DateTimeException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
public class ZonedDateTimeDeserializer extends StdDeserializer<ZonedDateTime> {
public ZonedDateTimeDeserializer() {
this(null);
}
public ZonedDateTimeDeserializer(Class<?> vc) {
super(vc);
}
@Override
public ZonedDateTime deserialize(JsonParser jsonparser, DeserializationContext ctxt) throws IOException {
// not serializing timezone data yet
try {
return ZonedDateTime.parse(jsonparser.getText(), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
} catch (DateTimeException e) {
throw new IllegalArgumentException("could not parse");
}
}
}

View File

@ -1,46 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.json;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
public class ZonedDateTimeSerializer extends StdSerializer<ZonedDateTime> {
private static final long serialVersionUID = 6245182835980474796L;
public ZonedDateTimeSerializer() {
this(null, false);
}
protected ZonedDateTimeSerializer(Class<?> t, boolean dummy) {
super(t, dummy);
}
@Override
public void serialize(ZonedDateTime time, JsonGenerator generator,
SerializerProvider provider) throws IOException {
generator.writeString(time.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.lang;
import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierNickname;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static javax.annotation.meta.When.MAYBE;
/**
* This annotation is used to define a method parameter or return type as nullable.
*/
@Target(value = {METHOD, PARAMETER, FIELD})
@Retention(value = RUNTIME)
@Documented
@Nonnull(when = MAYBE)
@TypeQualifierNickname
public @interface Nullable {
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Represents an object that can be read as CloudEvent context attributes and extensions.
* <p>
* An object (in particular, buffered objects) can implement both this interface and {@link CloudEventReader}.
*/
@ParametersAreNonnullByDefault
public interface CloudEventContextReader {
/**
* Read the context attributes and extensions using the provided writer
*
* @param writer context writer
* @throws CloudEventRWException if something went wrong during the read.
*/
void readContext(CloudEventContextWriter writer) throws CloudEventRWException;
}

View File

@ -0,0 +1,138 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.types.Time;
import javax.annotation.ParametersAreNonnullByDefault;
import java.net.URI;
import java.time.OffsetDateTime;
import java.util.Base64;
/**
* Interface to write the context attributes/extensions from a {@link io.cloudevents.rw.CloudEventContextReader} to a new representation.
*/
@ParametersAreNonnullByDefault
public interface CloudEventContextWriter {
/**
* Set attribute with type {@link String}.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this attribute.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
CloudEventContextWriter withContextAttribute(String name, String value) throws CloudEventRWException;
/**
* Set attribute with type {@link URI}.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this attribute.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
default CloudEventContextWriter withContextAttribute(String name, URI value) throws CloudEventRWException {
return withContextAttribute(name, value.toString());
}
/**
* Set attribute with type {@link OffsetDateTime} attribute.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this attribute.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
default CloudEventContextWriter withContextAttribute(String name, OffsetDateTime value) throws CloudEventRWException {
return withContextAttribute(name, Time.writeTime(name, value));
}
/**
* Set attribute with type {@link Number}.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this extension.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*
* @deprecated CloudEvent specification only permits {@link Integer} type as a
* numeric value.
*/
default CloudEventContextWriter withContextAttribute(String name, Number value) throws CloudEventRWException {
return withContextAttribute(name, value.toString());
}
/**
* Set attribute with type {@link Integer}.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this extension.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
default CloudEventContextWriter withContextAttribute(String name, Integer value) throws CloudEventRWException {
return withContextAttribute(name, value.toString());
}
/**
* Set attribute with type {@link Boolean} attribute.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this extension.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
default CloudEventContextWriter withContextAttribute(String name, Boolean value) throws CloudEventRWException {
return withContextAttribute(name, value.toString());
}
/**
* Set attribute with a binary type.
* This setter should not be invoked for specversion, because the writer should
* already know the specversion or because it doesn't need it to correctly write the value.
*
* @param name name of the attribute
* @param value value of the attribute
* @return self
* @throws CloudEventRWException if anything goes wrong while writing this extension.
* @throws IllegalArgumentException if you're trying to set the specversion attribute.
*/
default CloudEventContextWriter withContextAttribute(String name, byte[] value) throws CloudEventRWException {
return withContextAttribute(name, Base64.getEncoder().encodeToString(value));
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.CloudEventData;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Interface to convert a {@link CloudEventData} instance to another one.
*
* @param <R> the returned {@link CloudEventData} from this mapper.
*/
@FunctionalInterface
@ParametersAreNonnullByDefault
public interface CloudEventDataMapper<R extends CloudEventData> {
/**
* Map {@code data} to another {@link CloudEventData} instance.
*
* @param data the input data
* @return The new data
* @throws CloudEventRWException is anything goes wrong while mapping the input data
*/
R map(CloudEventData data) throws CloudEventRWException;
/**
* @return No-op identity mapper which can be used as default when no mapper is provided.
*/
static CloudEventDataMapper<CloudEventData> identity() {
return d -> d;
}
}

View File

@ -0,0 +1,230 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.lang.Nullable;
/**
* This class is the exception Protocol Binding and Event Format implementers can use to signal errors while serializing/deserializing CloudEvent.
*/
public class CloudEventRWException extends RuntimeException {
/**
* The kind of error that happened while serializing/deserializing
*/
public enum CloudEventRWExceptionKind {
/**
* Spec version string is not recognized by this particular SDK version.
*/
INVALID_SPEC_VERSION,
/**
* The attribute name is not a valid/known context attribute.
*/
INVALID_ATTRIBUTE_NAME,
/**
* The extension name is not valid because it doesn't follow the naming convention enforced by the CloudEvents spec.
*
* @see <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#attribute-naming-convention">naming convention</a>
*/
INVALID_EXTENSION_NAME,
/**
* The attribute/extension type is not valid.
*/
INVALID_ATTRIBUTE_TYPE,
/**
* The attribute/extension value is not valid.
*/
INVALID_ATTRIBUTE_VALUE,
/**
* The data type is not valid.
*/
INVALID_DATA_TYPE,
/**
* Error while converting CloudEventData.
*/
DATA_CONVERSION,
/**
* Invalid content type or spec version
*/
UNKNOWN_ENCODING,
/**
* Other error.
*/
OTHER
}
private final CloudEventRWExceptionKind kind;
private CloudEventRWException(CloudEventRWExceptionKind kind, Throwable cause) {
super(cause);
this.kind = kind;
}
private CloudEventRWException(CloudEventRWExceptionKind kind, String message) {
super(message);
this.kind = kind;
}
private CloudEventRWException(CloudEventRWExceptionKind kind, String message, Throwable cause) {
super(message, cause);
this.kind = kind;
}
/**
* @return the {@link CloudEventRWExceptionKind} associated to this exception instance.
*/
public CloudEventRWExceptionKind getKind() {
return kind;
}
/**
* @param specVersion the invalid input spec version
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidSpecVersion(String specVersion) {
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_SPEC_VERSION,
"Invalid specversion: " + specVersion
);
}
/**
* @param attributeName the invalid attribute name
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidAttributeName(String attributeName) {
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_ATTRIBUTE_NAME,
"Invalid attribute: " + attributeName
);
}
/**
* @param extensionName the invalid extension name
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidExtensionName(String extensionName) {
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_EXTENSION_NAME,
"Invalid extensions name: " + extensionName
);
}
/**
* @param attributeName the invalid attribute name
* @param clazz the type of the attribute
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidAttributeType(String attributeName, Class<?> clazz) {
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_ATTRIBUTE_TYPE,
"Invalid attribute/extension type for \"" + attributeName + "\": " + clazz.getCanonicalName()
);
}
public static CloudEventRWException newInvalidAttributeType(String attributeName,Object value){
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_ATTRIBUTE_TYPE,
"Invalid attribute/extension type for \""
+ attributeName
+ "\": Type" + value.getClass().getCanonicalName()
+ ". Value: " + value
);
}
/**
* @param attributeName the invalid attribute name
* @param value the value of the attribute
* @param cause an optional cause identifying the eventual validation error
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidAttributeValue(String attributeName, Object value, @Nullable Throwable cause) {
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_ATTRIBUTE_VALUE,
"Invalid attribute/extension value for \"" + attributeName + "\": " + value,
cause
);
}
/**
* @param actual the actual data type
* @param allowed the list of allowed data types
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newInvalidDataType(String actual, String... allowed) {
String message;
if (allowed.length == 0) {
message = "Invalid data type: " + actual;
} else {
message = "Invalid data type: " + actual + ". Allowed: " + String.join(", ", allowed);
}
return new CloudEventRWException(
CloudEventRWExceptionKind.INVALID_DATA_TYPE,
message
);
}
/**
* @param cause the cause of the conversion failure
* @param from the input data type
* @param to the target data type
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newDataConversion(Throwable cause, String from, String to) {
return new CloudEventRWException(
CloudEventRWExceptionKind.DATA_CONVERSION,
"Error while trying to convert data from " + from + " to " + to,
cause
);
}
/**
* @return a new {@link CloudEventRWException} instance.
*/
public static CloudEventRWException newUnknownEncodingException() {
return new CloudEventRWException(
CloudEventRWExceptionKind.UNKNOWN_ENCODING,
"Could not parse. Unknown encoding. Invalid content type or spec version"
);
}
/**
* This wraps a {@link Throwable} in a new generic instance of this exception.
*
* @param cause the cause of the exception
* @return a new {@link CloudEventRWException} instance
*/
public static CloudEventRWException newOther(Throwable cause) {
return new CloudEventRWException(
CloudEventRWExceptionKind.OTHER,
cause
);
}
/**
* An exception for use where none of the other variants are
* appropriate.
*
* @param msg A description error message.
* @return a new {@link CloudEventRWException}
*/
public static CloudEventRWException newOther(String msg){
return new CloudEventRWException(CloudEventRWExceptionKind.OTHER, msg);
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.CloudEventData;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Represents an object that can be read as CloudEvent.
* <p>
* The read may consume this object, hence it's not safe to invoke it multiple times, unless it's explicitly allowed by the implementer.
*/
@ParametersAreNonnullByDefault
public interface CloudEventReader {
/**
* Like {@link #read(CloudEventWriterFactory, CloudEventDataMapper)}, but with the identity {@link CloudEventDataMapper}.
*
* @param <W> The type of the {@link CloudEventWriter} created by writerFactory
* @param <R> The return value of the {@link CloudEventWriter} created by writerFactory
* @param writerFactory a factory that generates a visitor starting from the SpecVersion of the event
* @see #read(CloudEventWriterFactory, CloudEventDataMapper)
* @return the value returned by {@link CloudEventWriter#end()} or {@link CloudEventWriter#end(CloudEventData)}
* @throws CloudEventRWException if something went wrong during the read.
*/
default <W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> writerFactory) throws CloudEventRWException {
return read(writerFactory, CloudEventDataMapper.identity());
}
/**
* Read self using the provided writer factory.
*
* @param <W> the {@link CloudEventWriter} type
* @param <R> the return type of the {@link CloudEventWriter}
* @param writerFactory a factory that generates a visitor starting from the SpecVersion of the event
* @param mapper the mapper to invoke when building the {@link CloudEventData}
* @return the value returned by {@link CloudEventWriter#end()} or {@link CloudEventWriter#end(CloudEventData)}
* @throws CloudEventRWException if something went wrong during the read.
*/
<W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> writerFactory, CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException;
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.CloudEventData;
/**
* Interface to write the content (CloudEvents attributes, extensions and payload) from a
* {@link io.cloudevents.rw.CloudEventReader} to a new representation.
*
* @param <R> return value at the end of the write process
*/
public interface CloudEventWriter<R> extends CloudEventContextWriter {
/**
* End the write with a data payload.
*
* @param data the data to write
* @return an eventual return value
* @throws CloudEventRWException if the message writer cannot be ended.
*/
R end(CloudEventData data) throws CloudEventRWException;
/**
* End the write.
*
* @return an eventual return value
* @throws CloudEventRWException if the message writer cannot be ended.
*/
R end() throws CloudEventRWException;
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.rw;
import io.cloudevents.SpecVersion;
/**
* This factory is used to enforce setting the {@link SpecVersion} as first step in the writing process.
*
* @param <W> The type of the {@link CloudEventWriter} created by this factory
* @param <R> The return value of the {@link CloudEventWriter} created by this factory
*/
@FunctionalInterface
public interface CloudEventWriterFactory<W extends CloudEventWriter<R>, R> {
/**
* Create a {@link CloudEventWriter} starting from the provided {@link SpecVersion}
*
* @param version the spec version to create the writer
* @return the new writer
* @throws CloudEventRWException if the spec version is invalid or the writer cannot be instantiated.
*/
W create(SpecVersion version) throws CloudEventRWException;
}

View File

@ -0,0 +1,89 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.types;
import io.cloudevents.rw.CloudEventRWException;
import java.time.DateTimeException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeParseException;
import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
/**
* Utilities to handle the <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#type-system">CloudEvent Attribute Timestamp type</a>
*/
public final class Time {
private Time() {
}
/**
* Parse a {@link String} RFC3339 compliant as {@link OffsetDateTime}.
*
* @param time the value to parse as time
* @return the parsed {@link OffsetDateTime}
* @throws DateTimeParseException if something went wrong when parsing the provided time.
*/
public static OffsetDateTime parseTime(String time) throws DateTimeParseException {
return OffsetDateTime.parse(time);
}
/**
* Parse an attribute/extension with RFC3339 compliant {@link String} value as {@link OffsetDateTime}.
*
* @param attributeName the attribute/extension name
* @param time the value to parse as time
* @return the parsed {@link OffsetDateTime}
* @throws CloudEventRWException if something went wrong when parsing the attribute/extension.
*/
public static OffsetDateTime parseTime(String attributeName, String time) throws CloudEventRWException {
try {
return parseTime(time);
} catch (DateTimeParseException e) {
throw CloudEventRWException.newInvalidAttributeValue(attributeName, time, e);
}
}
/**
* Convert a {@link OffsetDateTime} to a RFC3339 compliant {@link String}.
*
* @param time the time to write as {@link String}
* @return the serialized time
* @throws DateTimeException if something went wrong when serializing the provided time.
*/
public static String writeTime(OffsetDateTime time) throws DateTimeException {
return ISO_OFFSET_DATE_TIME.format(time);
}
/**
* Convert an attribute/extension {@link OffsetDateTime} to a RFC3339 compliant {@link String}.
*
* @param attributeName the attribute/extension name
* @param time the time to write as {@link String}
* @return the serialized time
* @throws CloudEventRWException if something went wrong when serializing the attribute/extension.
*/
public static String writeTime(String attributeName, OffsetDateTime time) throws DateTimeException {
try {
return writeTime(time);
} catch (DateTimeParseException e) {
throw CloudEventRWException.newInvalidAttributeValue(attributeName, time, e);
}
}
}

View File

@ -1,198 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents;
import io.cloudevents.extensions.DistributedTracingExtension;
import org.junit.Test;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.HashMap;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
public class CloudEventBuilderTest {
@Test
public void testBuilderWithData() {
// given
final Map<String, String> keyValueStore = new HashMap<>();
keyValueStore.put("key1", "value1");
keyValueStore.put("key2", "value2");
final String id = UUID.randomUUID().toString();
final URI src = URI.create("/trigger");
final String type = "My.Cloud.Event.Type";
final ZonedDateTime eventTime = ZonedDateTime.now();
final String contentType = "application/json";
final URI schemaUri = URI.create("http://cloudevents.io/schema");
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.data(keyValueStore)
.contentType(contentType)
.type(type)
.schemaURL(schemaUri)
.time(eventTime)
.id(id)
.source(src)
.build();
// than
simpleKeyValueEvent.getData().ifPresent(data -> {
assertThat(data).isNotNull();
assertThat(data).containsKeys("key1", "key2");
assertThat(data).containsValues("value1", "value2");
});
assertThat(simpleKeyValueEvent.getContentType().get()).isEqualTo(contentType);
assertThat(simpleKeyValueEvent.getTime().get()).isEqualTo(eventTime);
assertThat(simpleKeyValueEvent.getId()).isEqualTo(id);
assertThat(simpleKeyValueEvent.getSchemaURL().get()).isEqualTo(schemaUri);
assertThat(simpleKeyValueEvent.getType()).isEqualTo(type);
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
assertThat(simpleKeyValueEvent.getSpecVersion()).isEqualTo(SpecVersion.DEFAULT.toString());
}
@Test
public void testBuilderWithoutData() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("/trigger");
final String type = "My.Cloud.Event.Type";
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.type(type)
.id(id)
.source(src)
.build();
// than
assertThat(simpleKeyValueEvent.getData().isPresent()).isFalse();
assertThat(simpleKeyValueEvent.getTime().isPresent()).isFalse();
assertThat(simpleKeyValueEvent.getId()).isEqualTo(id);
assertThat(simpleKeyValueEvent.getType()).isEqualTo(type);
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
assertThat(simpleKeyValueEvent.getSpecVersion()).isEqualTo(SpecVersion.DEFAULT.toString());
}
@Test
public void testBuilderWithoutDataAndUrn() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("urn:event:from:myapi/resourse/123");
final String type = "some.Cloud.Event.Type";
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.type(type)
.id(id)
.source(src)
.build();
// than
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
}
@Test
public void test01BuilderWithoutDataAndUrn() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("urn:event:from:myapi/resourse/123");
final String type = "some.Cloud.Event.Type";
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.specVersion("0.1")
.type(type)
.id(id)
.source(src)
.build();
// than
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
assertThat(simpleKeyValueEvent.getSpecVersion()).isEqualTo(SpecVersion.V_01.toString());
}
@Test
public void testBuilderWithoutDataAndURISchema() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("urn:event:from:myapi/resourse/123");
final String type = "some.Cloud.Event.Type";
final URI schema = URI.create("urn:oasis:names:specification:docbook:dtd:xml:4.1.2");
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.type(type)
.id(id)
.source(src)
.schemaURL(schema)
.build();
// than
assertThat(simpleKeyValueEvent.getSchemaURL().get()).isEqualTo(schema);
}
@Test
public void testBuilderWithoutDataAndMailto() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("mailto:cncf-wg-serverless@lists.cncf.io");
final String type = "My.Cloud.Event.Type";
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.type(type)
.id(id)
.source(src)
.build();
// than
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
}
@Test
public void testBuilderWithoutDataAndDistributedTracingExtension() {
// given
final String id = UUID.randomUUID().toString();
final URI src = URI.create("mailto:cncf-wg-serverless@lists.cncf.io");
final String type = "My.Cloud.Event.Type";
final DistributedTracingExtension dte = new DistributedTracingExtension();
dte.setTraceparent("00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01");
dte.setTracestate("congo=BleGNlZWRzIHRohbCBwbGVhc3VyZS4");
// when
final CloudEvent<Map<String, String>> simpleKeyValueEvent = new CloudEventBuilder()
.type(type)
.id(id)
.source(src)
.extension(dte)
.build();
// than
assertThat(simpleKeyValueEvent.getSource()).isEqualTo(src);
assertThat(simpleKeyValueEvent.getExtensions().get()).contains(dte);
Extension receivedDte = simpleKeyValueEvent.getExtensions().get().get(0);
assertThat(receivedDte).extracting("traceparent", "tracestate")
.contains("00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01", "congo=BleGNlZWRzIHRohbCBwbGVhc3VyZS4");
}
}

View File

@ -1,76 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents;
import io.cloudevents.json.Json;
import org.junit.Test;
import java.net.URI;
import java.time.ZonedDateTime;
import java.util.Map;
import static java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME;
import static org.assertj.core.api.Assertions.assertThat;
public class CloudEventJacksonTest {
@Test
public void testParseAzure01JSON() {
CloudEvent<Map<String, ?>> ce = Json.fromInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream("01_azure.json"));
assertThat(ce.getSpecVersion()).isEqualTo(SpecVersion.V_01.toString());
assertAzureCloudEvent(ce);
}
@Test
public void testParseAzure02JSON() {
CloudEvent<Map<String, ?>> ce = Json.fromInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream("02_azure.json"));
assertThat(ce.getSpecVersion()).isEqualTo(SpecVersion.V_02.toString());
assertAzureCloudEvent(ce);
}
private void assertAzureCloudEvent(CloudEvent<Map<String, ?>> ce) {
assertThat(ce.getType()).isEqualTo("Microsoft.Storage.BlobCreated");
ce.getData().ifPresent(data -> {
assertThat(Map.class).isAssignableFrom(data.getClass());
assertThat(data.get("clientRequestId")).isEqualTo("a23b4aba-2755-4107-8020-8ba6c54b203d");
assertThat(Map.class).isAssignableFrom(data.get("storageDiagnostics").getClass());
Map<String, String> storageDiagnostics = (Map<String, String>) data.get("storageDiagnostics");
assertThat(storageDiagnostics).containsOnlyKeys("batchId");
assertThat(storageDiagnostics.get("batchId")).isEqualTo("ba4fb664-f289-4742-8067-6c859411b066");
});
}
@Test
public void testParseAmazon01JSON() {
CloudEvent ce = Json.fromInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream("01_aws.json"));
assertAmazonCloudEvent(ce);
}
@Test
public void testParseAmazon02JSON() {
CloudEvent ce = Json.fromInputStream(Thread.currentThread().getContextClassLoader().getResourceAsStream("02_aws.json"));
assertAmazonCloudEvent(ce);
}
private void assertAmazonCloudEvent(CloudEvent ce) {
assertThat(ce.getType()).isEqualTo("aws.s3.object.created");
assertThat(ce.getId()).isEqualTo("C234-1234-1234");
assertThat(ce.getData().isPresent());
assertThat(ce.getSource().equals(URI.create("https://serverless.com")));
assertThat(ce.getTime().get()).isEqualTo(ZonedDateTime.parse("2018-04-26T14:48:09.769Z", ISO_ZONED_DATE_TIME));
}
}

View File

@ -0,0 +1,21 @@
package io.cloudevents;
import io.cloudevents.rw.CloudEventRWException;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.jupiter.api.Assertions.assertAll;
class SpecVersionTest {
@Test
void parse() {
assertAll(
() -> assertThat(SpecVersion.parse("1.0")).isEqualTo(SpecVersion.V1),
() -> assertThat(SpecVersion.parse("0.3")).isEqualTo(SpecVersion.V03),
() -> assertThatCode(() -> SpecVersion.parse("9000.1"))
.hasMessage(CloudEventRWException.newInvalidSpecVersion("9000.1").getMessage())
);
}
}

View File

@ -1,52 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.http;
import io.cloudevents.SpecVersion;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class HttpTransportAttributesTest {
@Test
public void testVersion01Headers() {
final HttpTransportAttributes v01 = HttpTransportAttributes.getHttpAttributesForSpec(SpecVersion.V_01);
assertThat(v01.specVersionKey()).isEqualTo("ce-cloudEventsVersion");
assertThat(v01.timeKey()).isEqualTo("ce-eventTime");
assertThat(v01.idKey()).isEqualTo("ce-eventID");
assertThat(v01.schemaUrlKey()).isEqualTo("ce-schemaURL");
assertThat(v01.typeKey()).isEqualTo("ce-eventType");
// non-changed between 01 / 02
assertThat(v01.sourceKey()).isEqualTo("ce-source");
}
@Test
public void testVersion02Headers() {
final HttpTransportAttributes v02 = HttpTransportAttributes.getHttpAttributesForSpec(SpecVersion.V_02);
assertThat(v02.specVersionKey()).isEqualTo("ce-specversion");
assertThat(v02.timeKey()).isEqualTo("ce-time");
assertThat(v02.idKey()).isEqualTo("ce-id");
assertThat(v02.schemaUrlKey()).isEqualTo("ce-schemaurl");
assertThat(v02.typeKey()).isEqualTo("ce-type");
// non-changed between 01 / 02
assertThat(v02.sourceKey()).isEqualTo("ce-source");
}
}

View File

@ -1,56 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.json;
import com.fasterxml.jackson.core.type.TypeReference;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventBuilder;
import io.cloudevents.json.types.GlusterVolumeClaim;
import org.junit.Test;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.UUID;
import static io.cloudevents.json.Json.MAPPER;
import static org.assertj.core.api.Assertions.assertThat;
public class CustomEventTypesTest {
@Test
public void testBinding() throws IOException {
// given
final Map<String, Object> storagePayload = (MAPPER.readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream("pvc.json"), Map.class));
final CloudEvent<Map<String, Object>> storageCloudEventWrapper = new CloudEventBuilder<Map<String, Object>>()
.type("ProvisioningSucceeded")
.source(URI.create("/scheduler"))
.id(UUID.randomUUID().toString())
.data(storagePayload)
.build();
// when
final String httpSerializedPayload = MAPPER.writeValueAsString(storageCloudEventWrapper);
assertThat(httpSerializedPayload).contains("PersistentVolumeClaim");
//PARSE into real object, on the other side
final CloudEvent<GlusterVolumeClaim> event = Json.decodeValue(httpSerializedPayload, new TypeReference<CloudEvent<GlusterVolumeClaim>>() {});
// then
assertThat(event.getData().get()).isNotNull();
assertThat(event.getData().get().getSpec().getCapacity().get("storage")).isEqualTo("2Gi");
assertThat(event.getData().get().getSpec().getAccessModes()).containsExactly("ReadWriteMany");
}
}

View File

@ -1,121 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.json.types;
import java.util.List;
import java.util.Map;
public class GlusterVolumeClaim {
private String apiVersion = null;
private String kind = null;
private Map<String, String> metadata = null;
private PVCSpec spec = null;
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public Map<String, String> getMetadata() {
return metadata;
}
public void setMetadata(Map<String, String> metadata) {
this.metadata = metadata;
}
public PVCSpec getSpec() {
return spec;
}
public void setSpec(PVCSpec spec) {
this.spec = spec;
}
public static class PVCSpec {
public PVCSpec() {
}
private Map<String, String> capacity;
private List<String> accessModes;
private GlusterFS glusterfs;
public Map<String, String> getCapacity() {
return capacity;
}
public void setCapacity(Map<String, String> capacity) {
this.capacity = capacity;
}
public List<String> getAccessModes() {
return accessModes;
}
public void setAccessModes(List<String> accessModes) {
this.accessModes = accessModes;
}
public GlusterFS getGlusterfs() {
return glusterfs;
}
public void setGlusterfs(GlusterFS glusterfs) {
this.glusterfs = glusterfs;
}
};
public static class GlusterFS {
public GlusterFS() {
}
private String endpoints;
private String path;
public String getEndpoints() {
return endpoints;
}
public void setEndpoints(String endpoint) {
this.endpoints = endpoint;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.types;
import io.cloudevents.rw.CloudEventRWException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
public class TimeTest {
@ParameterizedTest
@MethodSource("parseDateArguments")
void testParseAndFormatDate(String ts) {
OffsetDateTime offsetDateTime = Time.parseTime(ts);
assertThat(ts).isEqualTo(offsetDateTime.toString());
}
@Test
void testParseDateOffset() {
assertThat(Time.parseTime("1937-01-01T12:20:27.87+00:20"))
.isEqualTo("1937-01-01T12:00:27.87Z");
}
@Test
void testParseTimeException() {
assertThatCode(() -> Time.parseTime("time", "01-01T12:20:27.87+00:20"))
.isInstanceOf(CloudEventRWException.class)
.hasMessage(CloudEventRWException.newInvalidAttributeValue("time", "01-01T12:20:27.87+00:20", null).getMessage());
}
@Test
void testSerializeDateOffset() {
assertThat(Time.writeTime(OffsetDateTime.of(
LocalDateTime.of(2020, 8, 3, 18, 10, 0, 0),
ZoneOffset.ofHours(2)
))).isEqualTo("2020-08-03T18:10:00+02:00");
}
public static Stream<Arguments> parseDateArguments() {
return Stream.of(
Arguments.of("1985-04-12T23:20:50.520Z"),
Arguments.of("1990-12-31T23:59Z"),
Arguments.of("1990-12-31T15:59-08:00"),
Arguments.of("1937-01-01T12:00:27.870+00:20")
);
}
}

View File

@ -1,24 +0,0 @@
{
"eventType": "aws.s3.object.created",
"eventID": "C234-1234-1234",
"eventTime": "2018-04-26T14:48:09.769Z",
"eventTypeVersion": "2.0",
"source": "https://serverless.com",
"extensions": {},
"contentType": "application/json",
"cloudEventsVersion": "0.1",
"data":
{ "s3SchemaVersion": "1.0",
"configurationId": "cd267a38-30df-400e-9e3d-d0f1ca6e2410",
"bucket":
{ "name": "cloudevents",
"ownerIdentity": {},
"arn": "arn:aws:s3:::cloudevents" },
"object":
{ "key": "dan_kohn.jpg",
"size": 444684,
"eTag": "38b01ff16138d7ca0a0eb3f7a88ff815",
"sequencer": "005AE1E6A9A3D61490"
}
}
}

View File

@ -1,21 +0,0 @@
{
"eventID": "96fb5f0b-001e-0108-6dfe-da6e2806f124",
"eventTime": "2018-04-23T12:28:22.4579346Z",
"eventType": "Microsoft.Storage.BlobCreated",
"cloudEventsVersion": "0.1",
"data": {
"api": "PutBlockList",
"clientRequestId": "a23b4aba-2755-4107-8020-8ba6c54b203d",
"requestId": "96fb5f0b-001e-0108-6dfe-da6e28000000",
"eTag": "0x8D5A915B425AFFD",
"contentType": "image/jpeg",
"contentLength": 2779325,
"blobType": "BlockBlob",
"url": "https://cvtest34.blob.core.windows.net/myfiles/IMG_20180224_0004.jpg",
"sequencer": "000000000000000000000000000000BA00000000003db46c",
"storageDiagnostics": {
"batchId": "ba4fb664-f289-4742-8067-6c859411b066"
}
},
"source": "/subscriptions/326100e2-f69d-4268-8503-075374f62b6e/resourceGroups/cvtest34/providers/Microsoft.Storage/storageAccounts/cvtest34#/blobServices/default/containers/myfiles/blobs/IMG_20180224_0004.jpg"
}

View File

@ -1,22 +0,0 @@
{
"type": "aws.s3.object.created",
"id": "C234-1234-1234",
"time": "2018-04-26T14:48:09.769Z",
"source": "https://serverless.com",
"contentType": "application/json",
"specversion": "0.2",
"data":
{ "s3SchemaVersion": "1.0",
"configurationId": "cd267a38-30df-400e-9e3d-d0f1ca6e2410",
"bucket":
{ "name": "cloudevents",
"ownerIdentity": {},
"arn": "arn:aws:s3:::cloudevents" },
"object":
{ "key": "dan_kohn.jpg",
"size": 444684,
"eTag": "38b01ff16138d7ca0a0eb3f7a88ff815",
"sequencer": "005AE1E6A9A3D61490"
}
}
}

View File

@ -1,21 +0,0 @@
{
"id": "96fb5f0b-001e-0108-6dfe-da6e2806f124",
"time": "2018-04-23T12:28:22.4579346Z",
"type": "Microsoft.Storage.BlobCreated",
"specversion": "0.2",
"data": {
"api": "PutBlockList",
"clientRequestId": "a23b4aba-2755-4107-8020-8ba6c54b203d",
"requestId": "96fb5f0b-001e-0108-6dfe-da6e28000000",
"eTag": "0x8D5A915B425AFFD",
"contentType": "image/jpeg",
"contentLength": 2779325,
"blobType": "BlockBlob",
"url": "https://cvtest34.blob.core.windows.net/myfiles/IMG_20180224_0004.jpg",
"sequencer": "000000000000000000000000000000BA00000000003db46c",
"storageDiagnostics": {
"batchId": "ba4fb664-f289-4742-8067-6c859411b066"
}
},
"source": "/subscriptions/326100e2-f69d-4268-8503-075374f62b6e/resourceGroups/cvtest34/providers/Microsoft.Storage/storageAccounts/cvtest34#/blobServices/default/containers/myfiles/blobs/IMG_20180224_0004.jpg"
}

View File

@ -1,17 +0,0 @@
{
"apiVersion": "v1",
"kind": "PersistentVolumeClaim",
"metadata": {
"name": "gluster-default-volume"
},
"spec": {
"capacity": {
"storage": "2Gi"
},
"accessModes": [ "ReadWriteMany" ],
"glusterfs": {
"endpoints": "glusterfs-cluster",
"path": "myVol1"
}
}
}

174
benchmarks/pom.xml Normal file
View File

@ -0,0 +1,174 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
~ Copyright 2018-Present The CloudEvents Authors
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>cloudevents-benchmarks</artifactId>
<packaging>jar</packaging>
<name>CloudEvents - Benchmarks</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.23</jmh.version>
<javac.target>1.8</javac.target>
<!-- Name of the benchmark Uber-JAR to generate. -->
<uberjar.name>benchmarks</uberjar.name>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-json-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-kafka</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-sql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerVersion>${javac.target}</compilerVersion>
<source>${javac.target}</source>
<target>${javac.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.3</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,58 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.bench.jackson;
import io.cloudevents.jackson.JsonFormat;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;
import static io.cloudevents.core.test.Data.V1_WITH_XML_DATA;
public class JsonFormatDeserializationBenchmark {
@State(Scope.Thread)
public static class DeserializationState {
public byte[] eventWithJson;
public byte[] eventWithXml;
public JsonFormat format = new JsonFormat();
public DeserializationState() {
eventWithJson = format.serialize(V1_WITH_JSON_DATA_WITH_EXT);
eventWithXml = format.serialize(V1_WITH_XML_DATA);
}
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void deserializeWithJsonData(DeserializationState state, Blackhole bh) {
bh.consume(
state.format.deserialize(state.eventWithJson)
);
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void deserializeWithXmlData(DeserializationState state, Blackhole bh) {
bh.consume(
state.format.deserialize(state.eventWithXml)
);
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.bench.jackson;
import io.cloudevents.CloudEvent;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.jackson.JsonFormat;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;
import static io.cloudevents.core.test.Data.V1_WITH_XML_DATA;
public class JsonFormatSerializationBenchmark {
@State(Scope.Thread)
public static class SerializationState {
public CloudEvent eventWithJson = CloudEventBuilder.v1(V1_WITH_JSON_DATA_WITH_EXT).build();
public CloudEvent eventWithXml = CloudEventBuilder.v1(V1_WITH_XML_DATA).build();
public JsonFormat format = new JsonFormat();
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void serializeWithJsonData(SerializationState state, Blackhole bh) {
bh.consume(
state.format.serialize(state.eventWithJson)
);
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void serializeWithXmlData(SerializationState state, Blackhole bh) {
bh.consume(
state.format.serialize(state.eventWithXml)
);
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.bench.kafka;
import io.cloudevents.CloudEvent;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.jackson.JsonFormat;
import io.cloudevents.kafka.KafkaMessageFactory;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;
public class CloudEventToKafkaProducerMessageBenchmark {
@State(Scope.Thread)
public static class Event {
public CloudEvent event = CloudEventBuilder.v1(V1_WITH_JSON_DATA_WITH_EXT).build();
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testBinaryEncoding(Event event, Blackhole bh) {
bh.consume(
KafkaMessageFactory
.createWriter("aaa")
.writeBinary(event.event)
);
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testStructuredJsonEncoding(Event event, Blackhole bh) {
bh.consume(
KafkaMessageFactory
.createWriter("aaa")
.writeStructured(event.event, JsonFormat.CONTENT_TYPE)
);
}
}

View File

@ -0,0 +1,104 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.bench.kafka;
import io.cloudevents.jackson.JsonFormat;
import io.cloudevents.kafka.KafkaMessageFactory;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.record.TimestampType;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;
public class KafkaConsumerMessageToCloudEventBenchmark {
@State(Scope.Thread)
public static class BinaryMessage {
public ConsumerRecord<String, byte[]> message;
public BinaryMessage() {
// Hack to generate a consumer message
ProducerRecord<Void, byte[]> inRecord = KafkaMessageFactory
.createWriter("aaa")
.writeBinary(V1_WITH_JSON_DATA_WITH_EXT);
this.message = new ConsumerRecord<>(
"aaa",
0,
0,
0,
TimestampType.NO_TIMESTAMP_TYPE,
-1L,
ConsumerRecord.NULL_SIZE,
ConsumerRecord.NULL_SIZE,
"aaa",
inRecord.value(),
inRecord.headers()
);
}
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testBinaryEncoding(BinaryMessage binaryMessage, Blackhole bh) {
bh.consume(
KafkaMessageFactory
.createReader(binaryMessage.message)
.toEvent()
);
}
@State(Scope.Thread)
public static class StructuredJsonMessage {
public ConsumerRecord<String, byte[]> message;
public StructuredJsonMessage() {
// Hack to generate a consumer message
ProducerRecord<Void, byte[]> inRecord = KafkaMessageFactory
.createWriter("aaa")
.writeStructured(V1_WITH_JSON_DATA_WITH_EXT, JsonFormat.CONTENT_TYPE);
this.message = new ConsumerRecord<>(
"aaa",
0,
0,
0,
TimestampType.NO_TIMESTAMP_TYPE,
-1L,
ConsumerRecord.NULL_SIZE,
ConsumerRecord.NULL_SIZE,
"aaa",
inRecord.value(),
inRecord.headers()
);
}
}
@Benchmark
@BenchmarkMode(Mode.Throughput)
public void testStructuredJsonEncoding(StructuredJsonMessage structuredJsonMessage, Blackhole bh) {
bh.consume(
KafkaMessageFactory
.createReader(structuredJsonMessage.message)
.toEvent()
);
}
}

View File

@ -0,0 +1,35 @@
package io.cloudevents.bench.sql;
import io.cloudevents.sql.Parser;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.infra.Blackhole;
public class CompileBenchmark {
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testCompileSmallExpression(Blackhole bh) {
bh.consume(
Parser.parseDefault("(a + b + c) = 10 AND TRUE OR CONCAT('1', '2', id) = '123'")
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testCompileSmallTrueConstantExpression(Blackhole bh) {
bh.consume(
Parser.parseDefault("(1 + 2 + 3) = 10 AND TRUE OR CONCAT('1', '2', '3') = 123")
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testCompileSmallFalseConstantExpression(Blackhole bh) {
bh.consume(
Parser.parseDefault("(1 + 2 + 3) = 10 AND FALSE OR CONCAT('1', '2', '3') = 124")
);
}
}

View File

@ -0,0 +1,92 @@
package io.cloudevents.bench.sql;
import io.cloudevents.CloudEvent;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.sql.Expression;
import io.cloudevents.sql.Parser;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import static io.cloudevents.core.test.Data.V1_WITH_JSON_DATA_WITH_EXT;
public class RunBenchmark {
@State(Scope.Thread)
public static class TestCaseSmallExpression {
public CloudEvent event = CloudEventBuilder
.v1(V1_WITH_JSON_DATA_WITH_EXT)
.withExtension("a", "10")
.withExtension("b", 3)
.withExtension("c", "-3")
.build();
public Expression expression = Parser
.parseDefault("(a + b + c) = 10 AND TRUE OR CONCAT('1', '2', id) = '123'");
}
@State(Scope.Thread)
public static class TestCaseSmallTrueConstantExpression {
public CloudEvent event = CloudEventBuilder
.v1(V1_WITH_JSON_DATA_WITH_EXT)
.build();
public Expression expression = Parser
.parseDefault("(1 + 2 + 3) = 10 AND TRUE OR CONCAT('1', '2', '3') = 123");
}
@State(Scope.Thread)
public static class TestCaseSmallFalseConstantExpression {
public CloudEvent event = CloudEventBuilder
.v1(V1_WITH_JSON_DATA_WITH_EXT)
.build();
public Expression expression = Parser
.parseDefault("(1 + 2 + 3) = 10 AND FALSE OR CONCAT('1', '2', '3') = 124");
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testEvaluateSmallExpression(TestCaseSmallExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.evaluate(testCase.event)
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testTryEvaluateSmallExpression(TestCaseSmallExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.tryEvaluate(testCase.event)
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testEvaluateSmallTrueConstantExpression(TestCaseSmallTrueConstantExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.evaluate(testCase.event)
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testTryEvaluateSmallTrueConstantExpression(TestCaseSmallTrueConstantExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.tryEvaluate(testCase.event)
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testEvaluateSmallFalseConstantExpression(TestCaseSmallFalseConstantExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.evaluate(testCase.event)
);
}
@Benchmark
@BenchmarkMode({Mode.Throughput, Mode.AverageTime})
public void testTryEvaluateSmallFalseConstantExpression(TestCaseSmallFalseConstantExpression testCase, Blackhole bh) {
bh.consume(
testCase.expression.tryEvaluate(testCase.event)
);
}
}

91
bom/pom.xml Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018-Present The CloudEvents Authors
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>cloudevents-bom</artifactId>
<name>CloudEvents - Bill of Materials</name>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-json-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-protobuf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-amqp-proton</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-basic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-vertx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-http-restful-ws</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-kafka</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-spring</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-sql</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -1,64 +0,0 @@
# CDI Integration
## Firing CloudEvents using CDI
For Maven based projects, use the following to configure the CloudEvents CDI library:
```xml
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cdi</artifactId>
<version>0.2.0</version>
</dependency>
```
In _Enterprise Java_ applications, implemented with [Jakarta EE](https://jakarta.ee/) or the [Eclipse MicroProfile](https://microprofile.io/), it's trivial to combine this CloudEvents API with CDI. Application developers can now fire a CloudEvent for further processing inside of the application:
```java
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventBuilder;
import io.cloudevents.cdi.EventTypeQualifier;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import java.net.URI;
import java.util.UUID;
public class Router {
@Inject
private Event<CloudEvent<MyCustomEvent>> cloudEvent;
public void routeMe() throws Exception {
final CloudEvent<MyCustomEvent> event = new CloudEventBuilder<MyCustomEvent>()
.type("Cloud.Storage.Item.Created")
.source(new URI("/trigger"))
.id(UUID.randomUUID().toString())
.data(new MyCustomEvent(...))
.build();
cloudEvent.select(
new EventTypeQualifier("Cloud.Storage.Item.Created"))
.fire(event);
}
}
```
The method above creates a CloudEvent object, and uses the _injected_ CDI `Event` implementation,
where a `select()` is performed to fire a _qualified_ event, for all interested parties.
## Receiving CloudEvents with CDI
If other parts of the application are interested in the `Cloud.Storage.Item.Created` event,
it needs a matching `@Observes` annotation:
```java
public void receiveCloudEvent(
@Observes @EventType(name = "My.Cloud.Event.Type") CloudEvent cloudEvent) {
// handle the event
}
```
The application now is able to work with the _observed_ CloudEvent object.

View File

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2018 The CloudEvents Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>0.2.1</version>
<relativePath>../</relativePath>
</parent>
<artifactId>cdi</artifactId>
<name>CloudEvents - CDI</name>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.11.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.19.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>2.3.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,47 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents;
import io.cloudevents.beans.Receiver;
import io.cloudevents.beans.Router;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import javax.inject.Inject;
@RunWith(Arquillian.class)
public class CloudEventTest extends AbstractTestBase {
@Inject
private Router router;
@Deployment
public static JavaArchive createDeployment() {
return AbstractTestBase.createFrameworkDeployment()
.addPackage(Router.class.getPackage());
}
@Test
public void testDispatch(final Receiver receiver) throws Exception {
router.routeMe();
Mockito.verify(receiver, Mockito.times(1)).ack();
}
}

View File

@ -1,45 +0,0 @@
/**
* Copyright 2018 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.beans;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventBuilder;
import io.cloudevents.cdi.EventTypeQualifier;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import java.net.URI;
import java.util.UUID;
public class Router {
@Inject
private Event<CloudEvent<MyCustomEvent>> cloudEvent;
public void routeMe() throws Exception {
CloudEvent<MyCustomEvent> event = new CloudEventBuilder<MyCustomEvent>()
.type("Cloud.Storage.Item.Created")
.source(new URI("/trigger"))
.id(UUID.randomUUID().toString())
.build();
cloudEvent.select(
new EventTypeQualifier("Cloud.Storage.Item.Created"))
.fire(event);
}
}

5
core/README.md Normal file
View File

@ -0,0 +1,5 @@
# CloudEvents Core
Javadoc: [![Javadocs](http://www.javadoc.io/badge/io.cloudevents/cloudevents-core.svg?color=green)](http://www.javadoc.io/doc/io.cloudevents/cloudevents-core)
Documentation: https://cloudevents.github.io/sdk-java/core

83
core/pom.xml Normal file
View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018-Present The CloudEvents Authors
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
</parent>
<artifactId>cloudevents-core</artifactId>
<name>CloudEvents - Core</name>
<packaging>jar</packaging>
<properties>
<module-name>io.cloudevents.core</module-name>
</properties>
<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Test deps -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,111 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventContext;
import io.cloudevents.CloudEventData;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.core.impl.CloudEventContextReaderAdapter;
import io.cloudevents.core.impl.CloudEventReaderAdapter;
import io.cloudevents.lang.Nullable;
import io.cloudevents.rw.CloudEventContextReader;
import io.cloudevents.rw.CloudEventDataMapper;
import io.cloudevents.rw.CloudEventRWException;
import io.cloudevents.rw.CloudEventReader;
/**
* This class contains a set of utility methods to deal with conversions of {@link io.cloudevents} related interfaces
*/
public final class CloudEventUtils {
private CloudEventUtils() {}
/**
* Convert a {@link CloudEvent} to a {@link CloudEventReader}. This method provides a default implementation
* for CloudEvent that doesn't implement {@link CloudEventReader}.
* <p>
* It's safe to use the returned {@link CloudEventReader} multiple times.
*
* @param event the event to convert
* @return the reader implementation
*/
public static CloudEventReader toReader(CloudEvent event) {
if (event instanceof CloudEventReader) {
return (CloudEventReader) event;
} else {
return new CloudEventReaderAdapter(event);
}
}
/**
* Convert a {@link CloudEvent} to a {@link CloudEventContextReader}. This method provides a default implementation
* for {@link CloudEvent} that doesn't implement {@link CloudEventContextReader}.
* <p>
* It's safe to use the returned {@link CloudEventReader} multiple times.
*
* @param event the event to convert
* @return the context reader implementation
*/
public static CloudEventContextReader toContextReader(CloudEventContext event) {
if (event instanceof CloudEventContextReader) {
return (CloudEventContextReader) event;
} else {
return new CloudEventContextReaderAdapter(event);
}
}
/**
* Convert a {@link CloudEventReader} to a {@link CloudEvent}.
*
* @param reader the reader where to read the message from
* @return the reader implementation
*/
public static CloudEvent toEvent(CloudEventReader reader) throws CloudEventRWException {
return toEvent(reader, CloudEventDataMapper.identity());
}
/**
* Convert a {@link CloudEventReader} to a {@link CloudEvent} mapping the data with the provided {@code mapper}.
*
* @param reader the reader where to read the message from
* @param mapper the mapper to use when reading the data
* @return the reader implementation
*/
public static CloudEvent toEvent(CloudEventReader reader, CloudEventDataMapper<?> mapper) throws CloudEventRWException {
return reader.read(CloudEventBuilder::fromSpecVersion, mapper);
}
/**
* Get the data contained in {@code event} and map it using the provided mapper.
*
* @param event the event eventually containing the data
* @param mapper the mapper to use to map the data
* @param <R> the returned {@link CloudEventData} implementation from the provided mapper
* @return the data contained in {@code event} and mapped with {@code mapper}, if any, otherwise null
*/
@Nullable
public static <R extends CloudEventData> R mapData(CloudEvent event, CloudEventDataMapper<R> mapper) {
CloudEventData data = event.getData();
if (data == null) {
return null;
}
return mapper.map(data);
}
}

View File

@ -0,0 +1,343 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.builder;
import io.cloudevents.*;
import io.cloudevents.rw.CloudEventWriter;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNullableByDefault;
import java.net.URI;
import java.time.OffsetDateTime;
/**
* Builder interface to build a {@link CloudEvent}.
*/
@ParametersAreNullableByDefault
public interface CloudEventBuilder extends CloudEventWriter<CloudEvent> {
/**
* Set the {@code id} of the event
*
* @param id id of the event
* @return self
*/
CloudEventBuilder withId(String id);
/**
* Set the {@code source} of the event
*
* @param source source of the event
* @return self
*/
CloudEventBuilder withSource(URI source);
/**
* Set the {@code type} of the event
*
* @param type type of the event
* @return self
*/
CloudEventBuilder withType(String type);
/**
* Set the {@code dataschema} of the event. For CloudEvent v0.3, this will configure the {@code schemaurl} attribute.
*
* @param dataSchema dataschema of the event
* @return self
*/
CloudEventBuilder withDataSchema(URI dataSchema);
/**
* Set the {@code datacontenttype} of the event
*
* @param dataContentType datacontenttype of the event
* @return self
*/
CloudEventBuilder withDataContentType(String dataContentType);
/**
* Set the {@code subject} of the event
*
* @param subject subject of the event
* @return self
*/
CloudEventBuilder withSubject(String subject);
/**
* Set the {@code time} of the event
*
* @param time time of the event
* @return self
*/
CloudEventBuilder withTime(OffsetDateTime time);
/**
* Set the {@code data} of the event
*
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(byte[] data);
/**
* Set the {@code datacontenttype} and {@code data} of the event
*
* @param dataContentType datacontenttype of the event
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(String dataContentType, byte[] data);
/**
* Set the {@code datacontenttype}, {@code dataschema} and {@code data} of the event
*
* @param dataContentType datacontenttype of the event
* @param dataSchema dataschema of the event
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(String dataContentType, URI dataSchema, byte[] data);
/**
* Set the {@code data} of the event
*
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(CloudEventData data);
/**
* Set the {@code datacontenttype} and {@code data} of the event
*
* @param dataContentType datacontenttype of the event
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(String dataContentType, CloudEventData data);
/**
* Set the {@code datacontenttype}, {@code dataschema} and {@code data} of the event
*
* @param dataContentType datacontenttype of the event
* @param dataSchema dataschema of the event
* @param data data of the event
* @return self
*/
CloudEventBuilder withData(String dataContentType, URI dataSchema, CloudEventData data);
/**
* Remove the {@code datacontenttype}, {@code dataschema} and {@code data} from the event
*
* @return self
*/
CloudEventBuilder withoutData();
/**
* Remove the {@code dataschema} from the event
*
* @return self
*/
CloudEventBuilder withoutDataSchema();
/**
* Remove the {@code datacontenttype} from the event
*
* @return self
*/
CloudEventBuilder withoutDataContentType();
/**
* Set an extension with provided key and string value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull String value);
/**
* Set an extension with provided key and numeric value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull Number value);
/**
* Set an extension with provided key and boolean value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull Boolean value);
/**
* Set an extension with provided key and uri value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull URI value);
/**
* Set an extension with provided key and boolean value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull OffsetDateTime value);
/**
* Set an extension with provided key and binary value
*
* @param key key of the extension attribute
* @param value value of the extension attribute
* @return self
*/
CloudEventBuilder withExtension(@Nonnull String key, @Nonnull byte[] value);
/**
* Add to the builder all the extension key/values of the provided extension
*
* @param extension materialized extension to set in the builder
* @return self
*/
CloudEventBuilder withExtension(@Nonnull CloudEventExtension extension);
/**
* Remove from the the builder the provided extension key, if any
*
* @param key key of the extension attribute
* @return self
*/
CloudEventBuilder withoutExtension(@Nonnull String key);
/**
* Remove from the the builder the provided extension, if any
*
* @param extension materialized extension to remove from the builder
* @return self
*/
CloudEventBuilder withoutExtension(@Nonnull CloudEventExtension extension);
/**
* Build the event
*
* @return the built event
* @throws IllegalStateException if a required attribute is not configured
*/
CloudEvent build() throws IllegalStateException;
/**
* Copy this builder, creating a new instance with same values.
*
* @return A new builder with same values of this instance
*/
CloudEventBuilder newBuilder();
/**
* @return a new CloudEvent v1 builder
*/
static io.cloudevents.core.v1.CloudEventBuilder v1() {
return new io.cloudevents.core.v1.CloudEventBuilder();
}
/**
* @param event event to bootstrap the builder
* @return a new CloudEvent v1 builder filled with content of {@code event}
*/
static io.cloudevents.core.v1.CloudEventBuilder v1(@Nonnull CloudEvent event) {
return new io.cloudevents.core.v1.CloudEventBuilder(event);
}
/**
* @return a new CloudEvent v0.3 builder
*/
static io.cloudevents.core.v03.CloudEventBuilder v03() {
return new io.cloudevents.core.v03.CloudEventBuilder();
}
/**
* @param event event to bootstrap the builder
* @return a new CloudEvent v0.3 builder filled with content of {@code event}
*/
static io.cloudevents.core.v03.CloudEventBuilder v03(@Nonnull CloudEvent event) {
return new io.cloudevents.core.v03.CloudEventBuilder(event);
}
/**
* Create a new builder for the specified {@link SpecVersion}
*
* @param version version to use for the new builder
* @return a new builder
*/
static CloudEventBuilder fromSpecVersion(@Nonnull SpecVersion version) {
switch (version) {
case V1:
return CloudEventBuilder.v1();
case V03:
return CloudEventBuilder.v03();
}
throw new IllegalStateException(
"The provided spec version doesn't exist. Please make sure your io.cloudevents deps versions are aligned."
);
}
/**
* Create a new builder starting from the values of the provided event.
*
* @param event event to copy values from
* @return the new builder
*/
static CloudEventBuilder from(@Nonnull CloudEvent event) {
switch (event.getSpecVersion()) {
case V1:
return CloudEventBuilder.v1(event);
case V03:
return CloudEventBuilder.v03(event);
}
throw new IllegalStateException(
"The provided spec version doesn't exist. Please make sure your io.cloudevents deps versions are aligned."
);
}
/**
* Create a new builder starting from the values of the provided context.
*
* @param context context to copy values from
* @return the new builder
*/
static CloudEventBuilder fromContext(@Nonnull CloudEventContext context) {
switch (context.getSpecVersion()) {
case V1:
return new io.cloudevents.core.v1.CloudEventBuilder(context);
case V03:
return new io.cloudevents.core.v03.CloudEventBuilder(context);
}
throw new IllegalStateException(
"The provided spec version doesn't exist. Please make sure your io.cloudevents deps versions are aligned."
);
}
}

View File

@ -0,0 +1,56 @@
package io.cloudevents.core.data;
import io.cloudevents.CloudEventData;
import java.util.Arrays;
import java.util.Objects;
/**
* An implementation of {@link CloudEventData} that wraps a byte array.
*/
public class BytesCloudEventData implements CloudEventData {
private final byte[] value;
/**
* @param value the bytes to wrap
* @deprecated use {@link BytesCloudEventData#wrap(byte[])}
*/
public BytesCloudEventData(byte[] value) {
Objects.requireNonNull(value);
this.value = value;
}
@Override
public byte[] toBytes() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BytesCloudEventData that = (BytesCloudEventData) o;
return Arrays.equals(value, that.value);
}
@Override
public int hashCode() {
return Arrays.hashCode(value);
}
@Override
public String toString() {
return "BytesCloudEventData{" +
"value=" + Arrays.toString(value) +
'}';
}
/**
* @param value byte array to wrap
* @return byte array wrapped in a {@link BytesCloudEventData}, which implements {@link CloudEventData}.
*/
public static BytesCloudEventData wrap(byte[] value) {
return new BytesCloudEventData(value);
}
}

View File

@ -0,0 +1,92 @@
package io.cloudevents.core.data;
import io.cloudevents.CloudEventData;
import io.cloudevents.rw.CloudEventRWException;
import java.util.Objects;
/**
* An implementation of {@link CloudEventData} that wraps any POJO.
*
* @param <T> the type of the wrapped POJO.
*/
public class PojoCloudEventData<T> implements CloudEventData {
/**
* Interface defining a conversion from T to byte array. This is similar to {@link java.util.function.Function}
* but it allows checked exceptions.
*
* @param <T> the source type of the conversion
*/
@FunctionalInterface
public interface ToBytes<T> {
/**
* @param data the POJO to convert
* @return the serialized byte array.
* @throws Exception when something goes wrong during the conversion.
*/
byte[] convert(T data) throws Exception;
}
private final T value;
private byte[] memoizedValue;
private final ToBytes<T> mapper;
private PojoCloudEventData(T value, ToBytes<T> mapper) {
this(value, null, mapper);
}
private PojoCloudEventData(T value, byte[] memoizedValue, ToBytes<T> mapper) {
Objects.requireNonNull(value);
if (memoizedValue == null && mapper == null) {
throw new NullPointerException("You must provide the serialized data value or a mapper");
}
this.value = value;
this.memoizedValue = memoizedValue;
this.mapper = mapper;
}
/**
* @return the wrapped POJO
*/
public T getValue() {
return value;
}
@Override
public byte[] toBytes() {
if (this.memoizedValue == null) {
try {
this.memoizedValue = mapper.convert(this.value);
} catch (Exception e) {
throw CloudEventRWException.newDataConversion(e, value.getClass().toString(), "byte[]");
}
}
return this.memoizedValue;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PojoCloudEventData<?> that = (PojoCloudEventData<?>) o;
return Objects.equals(getValue(), that.getValue());
}
@Override
public int hashCode() {
return Objects.hash(getValue());
}
/**
* Wrap the provided data in a {@link PojoCloudEventData} serializable by the provided mapper.
*
* @param <T> The type of {@code data}
* @param data the POJO to wrap
* @param mapper converter from {@code data} to bytes, used to implement {@link #toBytes()}
* @return the new {@link PojoCloudEventData}
*/
public static <T> PojoCloudEventData<T> wrap(T data, ToBytes<T> mapper) {
return new PojoCloudEventData<>(data, mapper);
}
}

View File

@ -0,0 +1,111 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.extensions;
import io.cloudevents.CloudEventExtensions;
import io.cloudevents.CloudEventExtension;
import io.cloudevents.core.extensions.impl.ExtensionUtils;
import java.net.URI;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* This extension supports the "Claim Check Pattern". It allows to specify a reference to a location where the event payload is stored.
*
* @see <a href=https://github.com/cloudevents/spec/blob/v1.0/extensions/dataref.md>https://github.com/cloudevents/spec/blob/v1.0/extensions/dataref.md</a>
*/
public final class DatarefExtension implements CloudEventExtension {
/**
* The key of the {@code dataref} extension
*/
public static final String DATAREF = "dataref";
private static final Set<String> KEY_SET = Collections.unmodifiableSet(new HashSet<>(Collections.singletonList(DATAREF)));
private URI dataref;
/**
* @return the {@code dataref} contained in this extension.
*/
public URI getDataref() {
return dataref;
}
/**
* @param dataref the uri to set as {@code dataref}.
*/
public void setDataref(URI dataref) {
this.dataref = dataref;
}
@Override
public void readFrom(CloudEventExtensions extensions) {
Object value = extensions.getExtension(DATAREF);
if (value != null) {
this.dataref = URI.create(value.toString());
}
}
@Override
public Object getValue(String key) {
if (DATAREF.equals(key)) {
return this.dataref.toString();
}
throw ExtensionUtils.generateInvalidKeyException(this.getClass(), key);
}
@Override
public Set<String> getKeys() {
return KEY_SET;
}
@Override
public String toString() {
return "DatarefExtension{" +
"dataref='" + dataref + '\'' +
'}';
}
@Override
public int hashCode() {
final int prime = 31;
return prime + ((dataref == null) ? 0 : dataref.hashCode());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DatarefExtension other = (DatarefExtension) obj;
if (dataref == null) {
return other.dataref == null;
} else {
return dataref.equals(other.dataref);
}
}
}

View File

@ -0,0 +1,125 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.extensions;
import io.cloudevents.CloudEventExtensions;
import io.cloudevents.CloudEventExtension;
import io.cloudevents.core.extensions.impl.ExtensionUtils;
import java.util.*;
/**
* This extension embeds context from Distributed Tracing so that distributed systems can include traces that span an event-driven system.
*
* @see <a href="https://github.com/cloudevents/spec/blob/main/extensions/distributed-tracing.md">https://github.com/cloudevents/spec/blob/main/extensions/distributed-tracing.md</a>
*/
public final class DistributedTracingExtension implements CloudEventExtension {
/**
* The key of the {@code traceparent} extension
*/
public static final String TRACEPARENT = "traceparent";
/**
* The key of the {@code tracestate} extension
*/
public static final String TRACESTATE = "tracestate";
private static final Set<String> KEY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(TRACEPARENT, TRACESTATE)));
private String traceparent;
private String tracestate;
/**
* @return the {@code traceparent} contained in this extension.
*/
public String getTraceparent() {
return traceparent;
}
/**
* @param traceparent the string to set as {@code traceparent}.
*/
public void setTraceparent(String traceparent) {
this.traceparent = traceparent;
}
/**
* @return the {@code tracestate} contained in this extension.
*/
public String getTracestate() {
return tracestate;
}
/**
* @param tracestate the string to set as {@code tracestate}.
*/
public void setTracestate(String tracestate) {
this.tracestate = tracestate;
}
@Override
public void readFrom(CloudEventExtensions extensions) {
Object tp = extensions.getExtension(TRACEPARENT);
if (tp != null) {
this.traceparent = tp.toString();
}
Object ts = extensions.getExtension(TRACESTATE);
if (ts != null) {
this.tracestate = ts.toString();
}
}
@Override
public Object getValue(String key) {
switch (key) {
case TRACEPARENT:
return this.traceparent;
case TRACESTATE:
return this.tracestate;
}
throw ExtensionUtils.generateInvalidKeyException(this.getClass(), key);
}
@Override
public Set<String> getKeys() {
return KEY_SET;
}
@Override
public String toString() {
return "DistributedTracingExtension{" +
"traceparent='" + traceparent + '\'' +
", tracestate='" + tracestate + '\'' +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DistributedTracingExtension that = (DistributedTracingExtension) o;
return Objects.equals(getTraceparent(), that.getTraceparent()) &&
Objects.equals(getTracestate(), that.getTracestate());
}
@Override
public int hashCode() {
return Objects.hash(getTraceparent(), getTracestate());
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.extensions.impl;
import io.cloudevents.CloudEventExtension;
/**
* Collection of utilities to deal with materialized extensions
*/
public final class ExtensionUtils {
private ExtensionUtils() {
}
/**
* @param clazz the {@link CloudEventExtension} class
* @param key the invalid key
* @return an {@link IllegalArgumentException} when trying to access a key of the extension not existing.
*/
public static IllegalArgumentException generateInvalidKeyException(Class<? extends CloudEventExtension> clazz, String key) {
return new IllegalArgumentException(clazz.getName() + " doesn't expect the attribute key \"" + key + "\"");
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.format;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.rw.CloudEventDataMapper;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.Set;
/**
* <p>A construct that aggregates a two-part identifier of file formats and format contents transmitted on the Internet.
*
* <p>The two parts of a {@code ContentType} are its <em>type</em> and a <em>subtype</em>; separated by a forward slash ({@code /}).
*
* <p>The constants enumerated by {@code ContentType} correspond <em>only</em> to the specialized formats supported by the Java SDK for CloudEvents.
*
* @see io.cloudevents.core.format.EventFormat
*/
@ParametersAreNonnullByDefault
public enum ContentType {
/**
* Content type associated with the JSON event format
*/
JSON("application/cloudevents+json"),
/**
* The content type for transports sending cloudevents in the protocol buffer format.
*/
PROTO("application/cloudevents+protobuf"),
/**
* The content type for transports sending cloudevents in the compact Avro format.
*/
AVRO_COMPACT("application/cloudevents+avrocompact"),
/**
* The content type for transports sending cloudevents in XML format.
*/
XML("application/cloudevents+xml");
private String value;
private ContentType(String value) { this.value = value; }
/**
* Return a string consisting of the slash-delimited ({@code /}) two-part identifier for this {@code enum} constant.
*/
public String value() { return value; }
/**
* Return a string consisting of the slash-delimited ({@code /}) two-part identifier for this {@code enum} constant.
*/
@Override
public String toString() { return value(); }
}

View File

@ -0,0 +1,30 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.format;
/**
* Exception representing a deserialization error while using an {@link EventFormat}.
*/
public class EventDeserializationException extends RuntimeException {
/**
* @param cause the cause of the exception
*/
public EventDeserializationException(Throwable cause) {
super(cause);
}
}

View File

@ -0,0 +1,83 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.format;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.rw.CloudEventDataMapper;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;
import java.util.Set;
/**
* An <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#event-format">Event format</a>
* specifies how to serialize a CloudEvent as a sequence of bytes.
* <p>
* An implementation of this interface should support all specification versions of {@link CloudEvent}.
* <p>
* Implementations of this interface can be registered to the {@link io.cloudevents.core.provider.EventFormatProvider} to use them.
*
* @see io.cloudevents.core.provider.EventFormatProvider
*/
@ParametersAreNonnullByDefault
public interface EventFormat {
/**
* Serialize a {@link CloudEvent} to a byte array.
*
* @param event the event to serialize.
* @return the byte representation of the provided event.
* @throws EventSerializationException if something goes wrong during serialization.
*/
byte[] serialize(CloudEvent event) throws EventSerializationException;
/**
* Like {@link #deserialize(byte[], CloudEventDataMapper)}, but with the identity {@link CloudEventDataMapper}.
*
* @see #deserialize(byte[], CloudEventDataMapper)
*/
default CloudEvent deserialize(byte[] bytes) throws EventDeserializationException {
return this.deserialize(bytes, CloudEventDataMapper.identity());
}
/**
* Deserialize a byte array to a {@link CloudEvent}.
*
* @param bytes the serialized event.
* @param mapper the mapper to use to map the data.
* @return the deserialized event.
* @throws EventDeserializationException if something goes wrong during deserialization.
*/
CloudEvent deserialize(byte[] bytes, CloudEventDataMapper<? extends CloudEventData> mapper) throws EventDeserializationException;
/**
* @return the set of content types this event format can deserialize. These content types are used
* by the {@link io.cloudevents.core.provider.EventFormatProvider} to resolve an {@link EventFormat} starting
* from the content type {@link String}.
*/
default Set<String> deserializableContentTypes() {
return Collections.singleton(serializedContentType());
}
/**
* @return The content type to use when writing an event with this {@link EventFormat}.
*/
String serializedContentType();
}

View File

@ -1,33 +1,30 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents;
import io.cloudevents.beans.Receiver;
import org.mockito.Mockito;
package io.cloudevents.core.format;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
@ApplicationScoped
public class MockProvider {
private Receiver receiver = Mockito.mock(Receiver.class);
@Produces
public Receiver receiver() {
return receiver;
/**
* Exception representing a serialization error while using an {@link EventFormat}.
*/
public class EventSerializationException extends RuntimeException {
/**
* @param cause the cause of the exception
*/
public EventSerializationException(Throwable cause) {
super(cause);
}
}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.impl;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.rw.*;
import java.net.URI;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public abstract class BaseCloudEvent implements CloudEvent, CloudEventReader, CloudEventContextReader {
private final CloudEventData data;
protected final Map<String, Object> extensions;
protected BaseCloudEvent(CloudEventData data, Map<String, Object> extensions) {
this.data = data;
this.extensions = extensions != null ? extensions : new HashMap<>();
}
@Override
public CloudEventData getData() {
return this.data;
}
@Override
public Object getExtension(String extensionName) {
return this.extensions.get(extensionName);
}
@Override
public Set<String> getExtensionNames() {
return this.extensions.keySet();
}
@Override
public <T extends CloudEventWriter<V>, V> V read(CloudEventWriterFactory<T, V> writerFactory, CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException, IllegalStateException {
CloudEventWriter<V> writer = writerFactory.create(this.getSpecVersion());
this.readContext(writer);
if (this.data != null) {
return writer.end(mapper.map(this.data));
}
return writer.end();
}
protected void readExtensions(CloudEventContextWriter writer) throws CloudEventRWException {
// TODO to be improved
for (Map.Entry<String, Object> entry : this.extensions.entrySet()) {
if (entry.getValue() instanceof String) {
writer.withContextAttribute(entry.getKey(), (String) entry.getValue());
} else if (entry.getValue() instanceof Number) {
writer.withContextAttribute(entry.getKey(), (Number) entry.getValue());
} else if (entry.getValue() instanceof Boolean) {
writer.withContextAttribute(entry.getKey(), (Boolean) entry.getValue());
} else if (entry.getValue() instanceof URI) {
writer.withContextAttribute(entry.getKey(), (URI) entry.getValue());
} else if (entry.getValue() instanceof OffsetDateTime) {
writer.withContextAttribute(entry.getKey(), (OffsetDateTime) entry.getValue());
} else if (entry.getValue() instanceof byte[]) {
writer.withContextAttribute(entry.getKey(), (byte[]) entry.getValue());
} else {
// This should never happen because we build that map only through our builders
throw new IllegalStateException("Illegal value inside extensions map: " + entry);
}
}
}
}

View File

@ -0,0 +1,251 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.impl;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventContext;
import io.cloudevents.CloudEventData;
import io.cloudevents.CloudEventExtension;
import io.cloudevents.core.builder.CloudEventBuilder;
import io.cloudevents.core.data.BytesCloudEventData;
import io.cloudevents.rw.CloudEventRWException;
import javax.annotation.Nonnull;
import java.net.URI;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import static io.cloudevents.core.v03.CloudEventV03.SPECVERSION;
public abstract class BaseCloudEventBuilder<SELF extends BaseCloudEventBuilder<SELF, T>, T extends CloudEvent> implements CloudEventBuilder {
// This is a little trick for enabling fluency
private final SELF self;
protected CloudEventData data;
protected Map<String, Object> extensions = new HashMap<>();
@SuppressWarnings("unchecked")
public BaseCloudEventBuilder() {
this.self = (SELF) this;
}
public BaseCloudEventBuilder(CloudEventContext context) {
this();
setAttributes(context);
}
public BaseCloudEventBuilder(CloudEvent event) {
this();
this.setAttributes(event);
this.data = event.getData();
}
protected abstract void setAttributes(CloudEventContext event);
//TODO builder should accept data as Object and use data codecs (that we need to implement)
// to encode data
public SELF withData(byte[] data) {
this.data = BytesCloudEventData.wrap(data);
return this.self;
}
public SELF withData(String dataContentType, byte[] data) {
withDataContentType(dataContentType);
withData(data);
return this.self;
}
public SELF withData(String dataContentType, URI dataSchema, byte[] data) {
withDataContentType(dataContentType);
withDataSchema(dataSchema);
withData(data);
return this.self;
}
public SELF withData(CloudEventData data) {
this.data = data;
return this.self;
}
public SELF withData(String dataContentType, CloudEventData data) {
withDataContentType(dataContentType);
withData(data);
return this.self;
}
public SELF withData(String dataContentType, URI dataSchema, CloudEventData data) {
withDataContentType(dataContentType);
withDataSchema(dataSchema);
withData(data);
return this.self;
}
@Override
public CloudEventBuilder withoutData() {
this.data = null;
return this.self;
}
@Override
public CloudEventBuilder withoutDataSchema() {
withDataSchema(null);
return this.self;
}
@Override
public CloudEventBuilder withoutDataContentType() {
withDataContentType(null);
return this.self;
}
public SELF withExtension(@Nonnull String key, @Nonnull String value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
// @TODO - I think this method should be removed/deprecated
// **Number** Is NOT a valid CE Context atrribute type.
public SELF withExtension(@Nonnull String key, @Nonnull Number value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
public SELF withExtension(@Nonnull String key, @Nonnull Integer value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
public SELF withExtension(@Nonnull String key, @Nonnull Boolean value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
@Override
public SELF withExtension(@Nonnull String key, @Nonnull URI value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
@Override
public SELF withExtension(@Nonnull String key, @Nonnull OffsetDateTime value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
@Override
public CloudEventBuilder withExtension(@Nonnull String key, @Nonnull byte[] value) {
if (!isValidExtensionName(key)) {
throw CloudEventRWException.newInvalidExtensionName(key);
}
this.extensions.put(key, value);
return self;
}
@Override
public SELF withoutExtension(@Nonnull String key) {
this.extensions.remove(key);
return self;
}
@Override
public SELF withoutExtension(@Nonnull CloudEventExtension extension) {
extension.getKeys().forEach(this::withoutExtension);
return self;
}
public SELF withExtension(@Nonnull CloudEventExtension extension) {
for (String key : extension.getKeys()) {
Object value = extension.getValue(key);
if (value != null) {
this.extensions.put(key, value);
}
}
return self;
}
@Override
public CloudEvent end(CloudEventData value) throws CloudEventRWException {
this.data = value;
return build();
}
@Override
public CloudEvent end() {
try {
return build();
} catch (Exception e) {
throw CloudEventRWException.newOther(e);
}
}
protected static IllegalStateException createMissingAttributeException(String attributeName) {
return new IllegalStateException("Attribute '" + attributeName + "' cannot be null");
}
protected static IllegalStateException createEmptyAttributeException(String attributeName) {
return new IllegalStateException("Attribute '" + attributeName + "' cannot be empty");
}
/**
* Validates the extension name as defined in CloudEvents spec.
*
* @param name the extension name
* @return true if extension name is valid, false otherwise
* @see <a href="https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#naming-conventions">attribute-naming-conventions</a>
*/
private static boolean isValidExtensionName(String name) {
for (int i = 0; i < name.length(); i++) {
if (!isValidChar(name.charAt(i))) {
return false;
}
}
return true;
}
private static boolean isValidChar(char c) {
return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
}
protected void requireValidAttributeWrite(String name) {
if (name.equals(SPECVERSION)) {
throw new IllegalArgumentException("You should not set the specversion attribute through withContextAttribute methods");
}
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.impl;
import io.cloudevents.CloudEventContext;
import io.cloudevents.rw.CloudEventContextReader;
import io.cloudevents.rw.CloudEventContextWriter;
import io.cloudevents.rw.CloudEventRWException;
import java.net.URI;
import java.time.OffsetDateTime;
public class CloudEventContextReaderAdapter implements CloudEventContextReader {
private final CloudEventContext event;
public CloudEventContextReaderAdapter(CloudEventContext event) {
this.event = event;
}
public void readAttributes(CloudEventContextWriter writer) throws RuntimeException {
writer.withContextAttribute("id", event.getId());
writer.withContextAttribute("source", event.getSource());
writer.withContextAttribute("type", event.getType());
if (event.getDataContentType() != null) {
writer.withContextAttribute("datacontenttype", event.getDataContentType());
}
if (event.getDataSchema() != null) {
writer.withContextAttribute("dataschema", event.getDataSchema());
}
if (event.getSubject() != null) {
writer.withContextAttribute("subject", event.getSubject());
}
if (event.getTime() != null) {
writer.withContextAttribute("time", event.getTime());
}
}
public void readExtensions(CloudEventContextWriter writer) throws RuntimeException {
for (String key : event.getExtensionNames()) {
Object value = event.getExtension(key);
if (value instanceof String) {
writer.withContextAttribute(key, (String) value);
} else if (value instanceof Number) {
writer.withContextAttribute(key, (Number) value);
} else if (value instanceof Boolean) {
writer.withContextAttribute(key, (Boolean) value);
} else if (value instanceof URI) {
writer.withContextAttribute(key, (URI) value);
} else if (value instanceof OffsetDateTime) {
writer.withContextAttribute(key, (OffsetDateTime) value);
} else {
// This should never happen because we build that map only through our builders
throw new IllegalStateException("Illegal value inside extensions map: " + key + " " + value);
}
}
}
@Override
public void readContext(CloudEventContextWriter writer) throws CloudEventRWException {
this.readAttributes(writer);
this.readExtensions(writer);
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.impl;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.rw.*;
public class CloudEventReaderAdapter extends CloudEventContextReaderAdapter implements CloudEventReader {
private final CloudEvent event;
public CloudEventReaderAdapter(CloudEvent event) {
super(event);
this.event = event;
}
@Override
public <V extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<V, R> writerFactory,
CloudEventDataMapper<? extends CloudEventData> mapper) throws RuntimeException {
CloudEventWriter<R> visitor = writerFactory.create(event.getSpecVersion());
this.readAttributes(visitor);
this.readExtensions(visitor);
if (event.getData() != null) {
return visitor.end(mapper.map(event.getData()));
}
return visitor.end();
}
}

View File

@ -1,32 +1,31 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.cdi;
import javax.enterprise.util.AnnotationLiteral;
package io.cloudevents.core.impl;
public class EventTypeQualifier extends AnnotationLiteral<EventType> implements EventType {
import javax.annotation.Nonnull;
private static final long serialVersionUID = 1L;
private final String eventName;
final public class StringUtils {
public EventTypeQualifier(final String name) {
eventName=name;
private StringUtils() {
// Prevent construction.
}
public String name() {
return eventName;
public static boolean startsWithIgnoreCase(@Nonnull final String s, @Nonnull final String prefix) {
return s.regionMatches(true /* ignoreCase */, 0, prefix, 0, prefix.length());
}
}

View File

@ -1,21 +1,32 @@
/**
* Copyright 2018 The CloudEvents Authors
*
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.beans;
public interface Receiver {
package io.cloudevents.core.message;
void ack();
/**
* One of the possible encodings of a <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#message">CloudEvent message</a>
*/
public enum Encoding {
/**
* Structured mode
*/
STRUCTURED,
/**
* Binary mode
*/
BINARY
}

View File

@ -0,0 +1,126 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.CloudEventUtils;
import io.cloudevents.rw.*;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Represents a <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#message">CloudEvent message</a> reader.
* <p>
* This class expands the {@link CloudEventReader} to define reading both binary and structured messages.
*/
@ParametersAreNonnullByDefault
public interface MessageReader extends StructuredMessageReader, CloudEventReader {
/**
* Like {@link #read(CloudEventWriterFactory, CloudEventDataMapper)}, but with the identity {@link CloudEventDataMapper}.
*
* @see #read(CloudEventWriterFactory, CloudEventDataMapper)
*/
default <W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> writerFactory) throws CloudEventRWException, IllegalStateException {
return read(writerFactory, CloudEventDataMapper.identity());
}
/**
* Read the message as binary encoded message using the provided writer factory.
*
* @param <W> the {@link CloudEventWriter} type
* @param <R> the return type of the {@link CloudEventWriter}
* @param writerFactory a factory that generates a reader starting from the {@link SpecVersion} of the event
* @param mapper the mapper to use to map the data, if any.
* @throws CloudEventRWException if something went wrong during the visit.
* @throws IllegalStateException if the message is not in binary encoding.
*/
<W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> writerFactory, CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException, IllegalStateException;
/**
* Read the message as structured encoded message using the provided writer
*
* @param <R> the return type of the {@link StructuredMessageWriter}
* @param writer Structured Message writer
* @throws CloudEventRWException if something went wrong during the visit.
* @throws IllegalStateException if the message is not in structured encoding.
*/
<R> R read(StructuredMessageWriter<R> writer) throws CloudEventRWException, IllegalStateException;
/**
* @return The message encoding
*/
Encoding getEncoding();
/**
* Read the content of this object using a {@link MessageWriter}. This method allows to transcode an event from one transport to another without
* converting it to {@link CloudEvent}. The resulting encoding will be the same as the original encoding.
*
* @param <BW> the {@link CloudEventWriter} type
* @param <R> the return type of both {@link CloudEventWriter} and {@link StructuredMessageWriter}
* @param writer the {@link MessageWriter} accepting this Message
* @return The return value of the {@link MessageWriter}
* @throws CloudEventRWException if something went wrong during the visit.
* @throws IllegalStateException if the message has an unknown encoding.
*/
default <BW extends CloudEventWriter<R>, R> R read(MessageWriter<BW, R> writer) throws CloudEventRWException, IllegalStateException {
switch (getEncoding()) {
case BINARY:
return this.read((CloudEventWriterFactory<BW, R>) writer);
case STRUCTURED:
return this.read((StructuredMessageWriter<R>) writer);
default:
throw new IllegalStateException(
"The provided Encoding doesn't exist. Please make sure your io.cloudevents deps versions are aligned."
);
}
}
/**
* Like {@link #toEvent(CloudEventDataMapper)}, but with the identity {@link CloudEventDataMapper}.
*
* @see #toEvent(CloudEventDataMapper)
*/
default CloudEvent toEvent() throws CloudEventRWException, IllegalStateException {
return toEvent(CloudEventDataMapper.identity());
}
/**
* Translate this message into a {@link CloudEvent} representation, mapping the data with the provided {@code mapper}.
*
* @param mapper the mapper to use to map the data, if any.
* @return A {@link CloudEvent} with the contents of this message.
* @throws CloudEventRWException if something went wrong during the read.
* @throws IllegalStateException if the message has an unknown encoding.
*/
default CloudEvent toEvent(CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException, IllegalStateException {
switch (getEncoding()) {
case BINARY:
return CloudEventUtils.toEvent(this, mapper);
case STRUCTURED:
return this.read((format, value) -> format.deserialize(value, mapper));
default:
throw new IllegalStateException(
"The provided Encoding doesn't exist. Please make sure your io.cloudevents deps versions are aligned."
);
}
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message;
import io.cloudevents.CloudEvent;
import io.cloudevents.core.CloudEventUtils;
import io.cloudevents.core.format.EventFormat;
import io.cloudevents.core.message.impl.GenericStructuredMessageReader;
import io.cloudevents.rw.CloudEventWriter;
import io.cloudevents.rw.CloudEventWriterFactory;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Interface to write the {@link MessageReader} content (CloudEvents attributes, extensions and payload) to a new representation.
*
* @param <R> return value at the end of the write process.
*/
@ParametersAreNonnullByDefault
public interface MessageWriter<CEV extends CloudEventWriter<R>, R> extends CloudEventWriterFactory<CEV, R>, StructuredMessageWriter<R> {
/**
* Write the provided event as structured.
*
* @param event event to write.
* @param format {@link EventFormat} to use to serialize the event.
* @return return value at the end of the write process.
*/
default R writeStructured(CloudEvent event, String format) {
GenericStructuredMessageReader message = GenericStructuredMessageReader.from(event, format);
if (message == null) {
throw new IllegalArgumentException("Format " + format + " not found");
}
return message.read((StructuredMessageWriter<R>) this);
}
/**
* Write the provided event as structured.
*
* @param event event to write.
* @param format string to resolve the {@link EventFormat} to use to serialize the event.
* @return return value at the end of the write process.
*/
default R writeStructured(CloudEvent event, EventFormat format) {
return GenericStructuredMessageReader.from(event, format).read((StructuredMessageWriter<R>) this);
}
/**
* Write the provided event as binary.
*
* @param event event to write.
* @return return value at the end of the write process.
*/
default R writeBinary(CloudEvent event) {
return CloudEventUtils.toReader(event).read(this);
}
}

View File

@ -0,0 +1,77 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message;
import io.cloudevents.CloudEvent;
import io.cloudevents.CloudEventData;
import io.cloudevents.core.format.EventFormat;
import io.cloudevents.core.message.impl.GenericStructuredMessageReader;
import io.cloudevents.rw.CloudEventDataMapper;
import io.cloudevents.rw.CloudEventRWException;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Represents a <a href="https://github.com/cloudevents/spec/blob/v1.0/spec.md#message">CloudEvent message</a> in structured mode.
*/
@FunctionalInterface
@ParametersAreNonnullByDefault
public interface StructuredMessageReader {
/**
* Read self using the provided writer.
*
* @param <R> the return type of the {@link StructuredMessageWriter}
* @param writer the writer to use to write out the message
* @return the return value returned by {@link StructuredMessageWriter#setEvent(EventFormat, byte[])}
* @throws CloudEventRWException If something went wrong when
* @throws IllegalStateException If the message is not a valid structured message
*/
<R> R read(StructuredMessageWriter<R> writer) throws CloudEventRWException, IllegalStateException;
default CloudEvent toEvent() throws CloudEventRWException, IllegalStateException {
return this.read(EventFormat::deserialize);
}
default CloudEvent toEvent(CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException, IllegalStateException {
return this.read((format, value) -> format.deserialize(value, mapper));
}
/**
* Create a generic structured message from a {@link CloudEvent}.
*
* @param event the event to convert to {@link StructuredMessageReader}
* @param contentType content type to use to resolve the {@link EventFormat}
* @return null if format was not found, otherwise returns the built message
*/
static StructuredMessageReader from(CloudEvent event, String contentType) {
return GenericStructuredMessageReader.from(event, contentType);
}
/**
* Create a generic structured message from a {@link CloudEvent}.
*
* @param event the event to convert to {@link StructuredMessageReader}
* @param format the format to use to perform the conversion
* @return null if format was not found, otherwise returns the built message
*/
static StructuredMessageReader from(CloudEvent event, EventFormat format) {
return GenericStructuredMessageReader.from(event, format);
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message;
import io.cloudevents.core.format.EventFormat;
import io.cloudevents.rw.CloudEventRWException;
import javax.annotation.ParametersAreNonnullByDefault;
/**
* Interface to write the {@link MessageReader} content (CloudEvents attributes, extensions and payload) to a new representation structured representation.
*
* @param <R> return value at the end of the write process.
*/
@ParametersAreNonnullByDefault
@FunctionalInterface
public interface StructuredMessageWriter<R> {
/**
* Write an event using the provided {@link EventFormat}.
*/
R setEvent(EventFormat format, byte[] value) throws CloudEventRWException;
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message.impl;
import io.cloudevents.core.message.Encoding;
import io.cloudevents.core.message.MessageReader;
import io.cloudevents.core.message.StructuredMessageWriter;
import io.cloudevents.rw.CloudEventRWException;
/**
* Base {@link MessageReader} implementation for a binary message
*/
public abstract class BaseBinaryMessageReader implements MessageReader {
@Override
public Encoding getEncoding() {
return Encoding.BINARY;
}
@Override
public <T> T read(StructuredMessageWriter<T> writer) throws CloudEventRWException, IllegalStateException {
throw MessageUtils.generateWrongEncoding(Encoding.STRUCTURED, Encoding.BINARY);
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright 2018-Present The CloudEvents Authors
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.cloudevents.core.message.impl;
import io.cloudevents.CloudEventData;
import io.cloudevents.SpecVersion;
import io.cloudevents.core.v1.CloudEventV1;
import io.cloudevents.rw.CloudEventDataMapper;
import io.cloudevents.rw.CloudEventRWException;
import io.cloudevents.rw.CloudEventWriter;
import io.cloudevents.rw.CloudEventWriterFactory;
import java.util.Objects;
import java.util.function.BiConsumer;
/**
* This class implements a Binary {@link io.cloudevents.core.message.MessageReader},
* providing common logic to most protocol bindings which supports both Binary and Structured mode.
* <p>
* Content-type is handled separately using a key not prefixed with CloudEvents header prefix.
*
* @param <HK> Header key type
* @param <HV> Header value type
*/
public abstract class BaseGenericBinaryMessageReaderImpl<HK, HV> extends BaseBinaryMessageReader {
private final SpecVersion version;
private final CloudEventData body;
protected BaseGenericBinaryMessageReaderImpl(SpecVersion version, CloudEventData body) {
Objects.requireNonNull(version);
this.version = version;
this.body = body;
}
@Override
public <T extends CloudEventWriter<V>, V> V read(CloudEventWriterFactory<T, V> writerFactory, CloudEventDataMapper<? extends CloudEventData> mapper) throws CloudEventRWException, IllegalStateException {
CloudEventWriter<V> visitor = writerFactory.create(this.version);
// Grab from headers the attributes and extensions
// This implementation avoids to use visitAttributes and visitExtensions
// in order to complete the visit in one loop
this.forEachHeader((key, value) -> {
if (value == null) {
return;
}
if (isContentTypeHeader(key)) {
visitor.withContextAttribute(CloudEventV1.DATACONTENTTYPE, toCloudEventsValue(value));
} else if (isCloudEventsHeader(key)) {
String name = toCloudEventsKey(key);
if (name.equals(CloudEventV1.SPECVERSION)) {
return;
}
visitor.withContextAttribute(name, toCloudEventsValue(value));
}
});
// Set the payload
if (this.body != null) {
return visitor.end(mapper.map(this.body));
}
return visitor.end();
}
/**
* @param key header key
* @return true if this header is the content type header, false otherwise
*/
protected abstract boolean isContentTypeHeader(HK key);
/**
* @param key header key
* @return true if this header is a CloudEvents header, false otherwise
*/
protected abstract boolean isCloudEventsHeader(HK key);
/**
* @param key header key
* @return the key converted to a CloudEvents context attribute/extension name
*/
protected abstract String toCloudEventsKey(HK key);
/**
* Iterate over all the headers in the headers map.
*
* @param fn header consumer
*/
protected abstract void forEachHeader(BiConsumer<HK, HV> fn);
/**
* @param value header key
* @return the value converted to a valid CloudEvents attribute value as {@link String}.
*/
protected abstract String toCloudEventsValue(HV value);
}

Some files were not shown because too many files have changed in this diff Show More