Class CloudState
- java.lang.Object
-
- io.cloudstate.javasupport.CloudState
-
public final class CloudState extends java.lang.Object
The 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.CloudStateRunner
createRunner()
Creates a CloudStateRunner using the currently configured services.io.cloudstate.javasupport.CloudStateRunner
createRunner(com.typesafe.config.Config config)
Creates a CloudStateRunner using the currently configured services, using the supplied configuration.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.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.CloudState
registerAction(ActionHandler actionHandler, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an Action handler.CloudState
registerAction(java.lang.Object action, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated Action service.CloudState
registerCrdtEntity(CrdtEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, CrdtEntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register a CRDT entity factory.CloudState
registerCrdtEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated CRDT entity.CloudState
registerCrdtEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, CrdtEntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated CRDT entity.CloudState
registerEntity(EntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, java.lang.String persistenceId, EntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register a value based entity factory.CloudState
registerEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated value based entity.CloudState
registerEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, EntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated value based entity.CloudState
registerEventSourcedEntity(EventSourcedEntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, java.lang.String persistenceId, int snapshotEvery, EventSourcedEntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an event sourced entity factory.CloudState
registerEventSourcedEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated event sourced entity.CloudState
registerEventSourcedEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, EventSourcedEntityOptions entityOptions, 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.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.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.
-
-
-
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(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, EventSourcedEntityOptions entityOptions, 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.entityOptions
- The entity options.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, EventSourcedEntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an event sourced entity factory.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.entityOptions
- the options for this entity.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(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, CrdtEntityOptions entityOptions, 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.entityOptions
- The options for this entity.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, CrdtEntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register a 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.entityOptions
- The options for this entity.additionalDescriptors
- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
registerAction
public CloudState registerAction(java.lang.Object action, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated Action service.The action class must be annotated with
Action
.- Parameters:
action
- The action object.descriptor
- The descriptor for the service that this action implements.additionalDescriptors
- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This Cloudstate builder.
-
registerAction
public CloudState registerAction(ActionHandler actionHandler, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an Action handler.This is a low level API intended for custom (eg, non reflection based) mechanisms for implementing the action.
- Parameters:
actionHandler
- The action handler.descriptor
- The descriptor for the service that this action implements.additionalDescriptors
- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This Cloudstate builder.
-
registerEntity
public CloudState registerEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated value based entity.The entity class must be annotated with
Entity
.- 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.
-
registerEntity
public CloudState registerEntity(java.lang.Class<?> entityClass, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, EntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register an annotated value based entity.The entity class must be annotated with
Entity
.- Parameters:
entityClass
- The entity class.descriptor
- The descriptor for the service that this entity implements.entityOptions
- The options for this entity.additionalDescriptors
- Any additional descriptors that should be used to look up protobuf types when needed.- Returns:
- This stateful service builder.
-
registerEntity
public CloudState registerEntity(EntityFactory factory, com.google.protobuf.Descriptors.ServiceDescriptor descriptor, java.lang.String persistenceId, EntityOptions entityOptions, com.google.protobuf.Descriptors.FileDescriptor... additionalDescriptors)
Register a value based entity factory.This is a low level API intended for custom (eg, non reflection based) mechanisms for implementing the entity.
- Parameters:
factory
- The value based entity factory.descriptor
- The descriptor for the service that this entity implements.persistenceId
- The persistence id for this entity.entityOptions
- The options for this entity.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
-
-