Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
version: 2.1
# CircleCi Build Config for CloudState
commands:
install-java-11:
description: install openjdk-11
steps:
- run:
name: Install java 11
command: |
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.8_10.tar.gz -O /tmp/openjdk-11.tar.gz

sudo mkdir -p /usr/lib/jvm
sudo tar xfvz /tmp/openjdk-11.tar.gz --directory /usr/lib/jvm
rm -f /tmp/openjdk-11.tar.gz

sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.8+10/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'
sudo sh -c 'for bin in /usr/lib/jvm/jdk-11.0.8+10/bin/*; do update-alternatives --set $(basename $bin) $bin; done'

setup_sbt:
description: "Set up sbt"
parameters:
Expand Down Expand Up @@ -63,6 +78,7 @@ jobs:
description: "Build core native images"
steps:
- checkout
- install-java-11
- setup_sbt
- restore_sbt_cache
- run:
Expand All @@ -83,6 +99,7 @@ jobs:
description: "Build postgres native images"
steps:
- checkout
- install-java-11
- setup_sbt
- restore_sbt_cache
- run:
Expand All @@ -103,6 +120,7 @@ jobs:
description: "Build cassandra native images"
steps:
- checkout
- install-java-11
- setup_sbt
- restore_sbt_cache
- run:
Expand All @@ -119,7 +137,7 @@ jobs:

build-sbt-images:
docker:
- image: circleci/openjdk:8
- image: cimg/openjdk:11.0
description: "Build sbt non-native images"
steps:
- checkout
Expand Down Expand Up @@ -179,6 +197,7 @@ jobs:
description: "native image tck tests"
steps:
- checkout
- install-java-11
- setup_sbt
- restore_sbt_cache
- attach_workspace:
Expand Down
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ lazy val `java-support` = (project in file("java-support"))
"com.fasterxml.jackson.core" % "jackson-databind" % JacksonDatabindVersion
),
javacOptions in Compile ++= Seq("-encoding", "UTF-8"),
javacOptions in (Compile, compile) ++= Seq("-source", "1.8", "-target", "1.8"),
javacOptions in (Compile, compile) ++= Seq("-source", "11", "-target", "11"),
akkaGrpcGeneratedSources in Compile := Seq(AkkaGrpc.Server),
akkaGrpcGeneratedLanguages in Compile := Seq(AkkaGrpc.Scala), // FIXME should be Java, but here be dragons
PB.protoSources in Compile ++= {
Expand Down Expand Up @@ -630,7 +630,7 @@ lazy val `java-support-docs` = (project in file("java-support/docs"))
Test / PB.protoSources += (baseDirectory in ThisBuild).value / "protocols" / "frontend",
Test / PB.protoSources += sourceDirectory.value / "modules" / "java" / "examples" / "proto",
Test / PB.targets := Seq(PB.gens.java -> (Test / sourceManaged).value),
Compile / javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8")
Compile / javacOptions ++= Seq("-encoding", "UTF-8", "-source", "11", "-target", "11")
)

lazy val `java-support-tck` = (project in file("java-support/tck"))
Expand All @@ -643,7 +643,7 @@ lazy val `java-support-tck` = (project in file("java-support/tck"))
akkaGrpcGeneratedLanguages := Seq(AkkaGrpc.Java),
PB.protoSources in Compile += (baseDirectory in ThisBuild).value / "protocols" / "tck",
PB.targets in Compile := Seq(PB.gens.java -> (sourceManaged in Compile).value),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "11", "-target", "11"),
assemblySettings("cloudstate-java-tck.jar")
)

Expand All @@ -663,7 +663,7 @@ lazy val `java-shopping-cart` = (project in file("samples/java-shopping-cart"))
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value
),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "11", "-target", "11"),
assemblySettings("java-shopping-cart.jar")
)

Expand All @@ -683,7 +683,7 @@ lazy val `java-pingpong` = (project in file("samples/java-pingpong"))
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value
),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "1.8", "-target", "1.8"),
javacOptions in Compile ++= Seq("-encoding", "UTF-8", "-source", "11", "-target", "11"),
assemblySettings("java-pingpong.jar")
)

Expand Down
8 changes: 8 additions & 0 deletions java-support/docs/src/modules/java/pages/getting-started.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,12 @@ Exactly which context parameters are available depend on the type of entity and
| link:{attachmentsdir}/api/io/cloudstate/javasupport/EntityId.html[`@EntityId`]
| The ID of the entity.

| link:{attachmentsdir}/api/io/cloudstate/javasupport/Metadata.html[`Metadata`]
|
| The metadata associated with the command.

| link:{attachmentsdir}/api/io/cloudstate/javasupport/CloudEvent.html[`CloudEvent`]
|
| The CloudEvent metadata associated with the command. May be wrapped in `java.util.Optional`.

|====
187 changes: 187 additions & 0 deletions java-support/src/main/java/io/cloudstate/javasupport/CloudEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* Copyright 2019 Lightbend Inc.
*
* 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.cloudstate.javasupport;

import java.net.URI;
import java.time.ZonedDateTime;
import java.util.Optional;

/** CloudEvent representation of Metadata. */
public interface CloudEvent {

/**
* The CloudEvent spec version.
*
* @return The spec version.
*/
String specversion();

/**
* The id of this CloudEvent.
*
* @return The id.
*/
String id();

/**
* Return a new CloudEvent with the given id.
*
* @param id The id to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withId(String id);

/**
* The source of this CloudEvent.
*
* @return The source.
*/
URI source();

/**
* Return a new CloudEvent with the given source.
*
* @param source The source to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withSource(URI source);

/**
* The type of this CloudEvent.
*
* @return The type.
*/
String type();

/**
* Return a new CloudEvent with the given type.
*
* @param type The type to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withType(String type);

/**
* The data content type of this CloudEvent.
*
* @return The data content type, if set.
*/
Optional<String> datacontenttype();

/**
* Return a new CloudEvent with the given data content type.
*
* @param datacontenttype The data content type to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withDatacontenttype(String datacontenttype);

/**
* Clear the data content type of this CloudEvent, if set.
*
* @return A copy of this CloudEvent.
*/
CloudEvent clearDatacontenttype();

/**
* The data schema of this CloudEvent.
*
* @return The data schema, if set.
*/
Optional<URI> dataschema();

/**
* Return a new CloudEvent with the given data schema.
*
* @param dataschema The data schema to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withDataschema(URI dataschema);

/**
* Clear the data schema of this CloudEvent, if set.
*
* @return A copy of this CloudEvent.
*/
CloudEvent clearDataschema();

/**
* The subject of this CloudEvent.
*
* @return The subject, if set.
*/
Optional<String> subject();

/**
* Return a new CloudEvent with the given subject.
*
* @param subject The subject to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withSubject(String subject);

/**
* Clear the subject of this CloudEvent, if set.
*
* @return A copy of this CloudEvent.
*/
CloudEvent clearSubject();

/**
* The time of this CloudEvent.
*
* @return The time, if set.
*/
Optional<ZonedDateTime> time();

/**
* Return a new CloudEvent with the given time.
*
* @param time The time to set.
* @return A copy of this CloudEvent.
*/
CloudEvent withTime(ZonedDateTime time);

/**
* Clear the time of this CloudEvent, if set.
*
* @return A copy of this CloudEvent.
*/
CloudEvent clearTime();

/**
* Return this CloudEvent represented as Metadata.
*
* <p>If this CloudEvent was created by {{@link Metadata#asCloudEvent()}}, then any non CloudEvent
* metadata that was present will still be present.
*
* @return This CloudEvent expressed as Cloudstate metadata.
*/
Metadata asMetadata();

/**
* Create a CloudEvent.
*
* @param id The id of the CloudEvent.
* @param source The source of the CloudEvent.
* @param type The type of the CloudEvent.
* @return The newly created CloudEvent.
*/
static CloudEvent of(String id, URI source, String type) {
return Metadata.EMPTY.asCloudEvent(id, source, type);
}
}
Loading