public final class ServiceRuntime extends Object
Server; allows the native code to load and unload artifacts (JAR archives with Exonum
services), create and stop services defined in the loaded artifacts.
This class is thread-safe and does not support client-side locking. The thread-safety is provided because the class is a singleton and may be provided to other objects. Currently, however, there is a single injection point where ServiceRuntime is instantiated (during bootstrap) and it is used by the native runtime only in a single-threaded context, hence thread-safety isn't strictly required, but rather provided to avoid possible errors if it is ever accessed by other objects.
| Constructor and Description |
|---|
ServiceRuntime(com.google.inject.Injector frameworkInjector,
com.exonum.binding.core.runtime.ServiceLoader serviceLoader,
Server server,
int serverPort)
Creates a new runtime with the given framework injector.
|
| Modifier and Type | Method and Description |
|---|---|
UserServiceAdapter |
createService(String artifactId)
Creates a new service instance of the given type.
|
String |
loadArtifact(String serviceArtifactPath)
Loads an artifact from the specified location.
|
@Inject
public ServiceRuntime(com.google.inject.Injector frameworkInjector,
com.exonum.binding.core.runtime.ServiceLoader serviceLoader,
Server server,
int serverPort)
frameworkInjector - the injector that has been configured with the Exonum framework
bindings. It serves as a parent for service injectorsserviceLoader - a loader of service artifactsserver - a web server providing transport to Java servicesserverPort - a port for the web server providing transport to Java servicespublic String loadArtifact(String serviceArtifactPath) throws ServiceLoadingException
serviceArtifactPath - a filesystem path from which
to load the service artifactServiceLoadingException - if it failed to load an artifact; or if the given artifact is
already loadedpublic UserServiceAdapter createService(String artifactId)
artifactId - a unique identifier of the loaded artifactIllegalArgumentException - if the artifactId is unknownRuntimeException - if it failed to instantiate the serviceCopyright © 2019 Exonum. All rights reserved.