Package io.cloudstate.javasupport
Class CloudState
- java.lang.Object
-
- io.cloudstate.javasupport.CloudState
-
public final class CloudState extends java.lang.ObjectThe CloudState class is the main interface to configuring entities to deploy, and subsequently starting a local server which will expose these entities to the CloudState Proxy Sidecar.
-
-
Constructor Summary
Constructors Constructor Description CloudState()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.cloudstate.javasupport.CloudStateRunnercreateRunner()Creates a CloudStateRunner using the currently configured services.io.cloudstate.javasupport.CloudStateRunnercreateRunner(com.typesafe.config.Config config)Creates a CloudStateRunner using the currently configured services, using the supplied configuration.CloudStatepreferJavaProtobufs()When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies that Java should be preferred.CloudStatepreferScalaProtobufs()When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies that Scala should be preferred.CloudStateregisterCrdtEntity(CrdtEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)Register an CRDt entity factory.CloudStateregisterCrdtEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)Register an annotated CRDT entity.CloudStateregisterEventSourcedEntity(EventSourcedEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, java.lang.String persistenceId, int snapshotEvery, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)Register an event sourced entity factor.CloudStateregisterEventSourcedEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)Register an annotated event sourced entity.java.util.concurrent.CompletionStage<akka.Done>start()Starts a server with the configured entities.java.util.concurrent.CompletionStage<akka.Done>start(com.typesafe.config.Config config)Starts a server with the configured entities, using the supplied configuration.CloudStatewithClassLoader(java.lang.ClassLoader classLoader)Sets the ClassLoader to be used for reflective access, the default value is the ClassLoader of the CloudState class.CloudStatewithTypeUrlPrefix(java.lang.String prefix)Sets the type URL prefix to be used when serializing and deserializing types from and to Protobyf Any values.
-
-
-
Method Detail
-
withClassLoader
public CloudState withClassLoader(java.lang.ClassLoader classLoader)
Sets the ClassLoader to be used for reflective access, the default value is the ClassLoader of the CloudState class.- Parameters:
classLoader- A non-null ClassLoader to be used for reflective access.- Returns:
- This CloudState instance.
-
withTypeUrlPrefix
public CloudState withTypeUrlPrefix(java.lang.String prefix)
Sets the type URL prefix to be used when serializing and deserializing types from and to Protobyf Any values. Defaults to "type.googleapis.com".- Parameters:
prefix- the type URL prefix to be used.- Returns:
- This CloudState instance.
-
preferJavaProtobufs
public CloudState preferJavaProtobufs()
When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies that Java should be preferred.- Returns:
- This CloudState instance.
-
preferScalaProtobufs
public CloudState preferScalaProtobufs()
When locating protobufs, if both a Java and a ScalaPB generated class is found on the classpath, this specifies that Scala should be preferred.- Returns:
- This CloudState instance.
-
registerEventSourcedEntity
public CloudState registerEventSourcedEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated event sourced entity.The entity class must be annotated with
EventSourcedEntity.- Parameters:
entityClass- The entity class.descriptor- The descriptor for the service that this entity implements.additionalDescriptors- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
registerEventSourcedEntity
public CloudState registerEventSourcedEntity(EventSourcedEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, java.lang.String persistenceId, int snapshotEvery, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an event sourced entity factor.This is a low level API intended for custom (eg, non reflection based) mechanisms for implementing the entity.
- Parameters:
factory- The event sourced factory.descriptor- The descriptor for the service that this entity implements.persistenceId- The persistence id for this entity.snapshotEvery- Specifies how snapshots of the entity state should be made: Zero means use default from configuration file. (Default) Any negative value means never snapshot. Any positive value means snapshot at-or-after that number of events.additionalDescriptors- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
registerCrdtEntity
public CloudState registerCrdtEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated CRDT entity.The entity class must be annotated with
CrdtEntity.- Parameters:
entityClass- The entity class.descriptor- The descriptor for the service that this entity implements.additionalDescriptors- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
registerCrdtEntity
public CloudState registerCrdtEntity(CrdtEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an CRDt entity factory.This is a low level API intended for custom (eg, non reflection based) mechanisms for implementing the entity.
- Parameters:
factory- The CRDT factory.descriptor- The descriptor for the service that this entity implements.additionalDescriptors- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
start
public java.util.concurrent.CompletionStage<akka.Done> start()
Starts a server with the configured entities.- Returns:
- a CompletionStage which will be completed when the server has shut down.
-
start
public java.util.concurrent.CompletionStage<akka.Done> start(com.typesafe.config.Config config)
Starts a server with the configured entities, using the supplied configuration.- Returns:
- a CompletionStage which will be completed when the server has shut down.
-
createRunner
public io.cloudstate.javasupport.CloudStateRunner createRunner()
Creates a CloudStateRunner using the currently configured services. In order to start the server, `run()` must be invoked on the returned CloudStateRunner.- Returns:
- a CloudStateRunner
-
createRunner
public io.cloudstate.javasupport.CloudStateRunner createRunner(com.typesafe.config.Config config)
Creates a CloudStateRunner using the currently configured services, using the supplied configuration. In order to start the server, `run()` must be invoked on the returned CloudStateRunner.- Returns:
- a CloudStateRunner
-
-