MicroStream Reference Manual
MicroStream HomeAPI Docs
3.0
3.0
  • Preface
  • System Requirements
  • License
  • Changelog
  • Installation
  • Data-Store
    • Overview
    • Getting Started
    • Root Instances
    • Configuration
      • Properties
      • Storage Files and Directories
      • Using Channels
      • Housekeeping
      • Backup
      • Lock File
    • Storing Data
      • Convenience Methods and Explicit Storing (Transactions)
      • Lazy and Eager Storing
      • Transient Fields
      • Best Practice
    • Loading Data
      • Lazy Loading
        • Touched Timestamp, Null-Safe Variant
        • Clearing Lazy References
    • Deleting Data
    • Queries
    • Application Life-Cycle
    • Legacy Type Mapping
      • User Interaction
    • Backup Strategies
    • Import / Export
    • Housekeeping
    • Customizing
      • Custom Type Handler
      • Custom Legacy Type Handler
      • Custom Class Loader
      • Custom Storing Behavior
      • Optional Storage Manager Reference in Entities
    • REST Interface
      • Setup
      • REST API
      • Client GUI
    • FAQ
      • Data Model
      • Data Management
      • File Storage
      • Java Features
      • Miscellaneous
    • Addendum
      • Supported Java Features
      • Specialized Type Handlers
      • Examples and Demo Projects
  • Cache
    • Overview
    • Getting Started
    • Configuration
      • Properties
      • Storage
    • Use Cases
      • Hibernate Second Level Cache
      • Spring Cache
  • Basic Concepts
    • Layered Entities
      • Configuration
      • Defining Entities
      • Creating Entities
      • Updating Entities
      • Versioning
      • Logging
      • Multiple Layers
    • Wrapping
      • Configuration
      • Usage
Powered by GitBook
On this page
  • REST Service
  • Configuration
Export as PDF
  1. Data-Store
  2. REST Interface

Setup

PreviousREST InterfaceNextREST API

Last updated 3 years ago

This is the manual for older MicroStream versions (Version < 5.0).

The new documentation (Version >= 5.0) is located at:

REST Service

First of all we have to connect a storage to a REST service.

Just add the REST service implementation to your dependencies, the logger is optional.

pom.xml
<repositories>
    <repository>
        <id>microstream-releases</id>
        <url>https://repo.microstream.one/repository/maven-public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>one.microstream</groupId>
        <artifactId>storage.restservice.sparkjava</artifactId>
        <version>03.00.00-MS-GA</version>
    </dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>1.7.30</version>
		</dependency>
</dependencies>

Now use the resolver to connect the service to a storage, start it, and you're good to go.

EmbeddedStorageManager storage = EmbeddedStorage.start();
if(storage.root() == null)
{
		storage.setRoot(new Object[] {
				LocalDate.now(),
				X.List("a", "b", "c"),
				1337
		});
		storage.storeRoot();
}

StorageRestService service = StorageRestServiceResolver.resolve(storage);
service.start();

1) An example storage manager 12) Create the REST service, 13) and start it.

That's all you have to do to open the REST endpoints to access the storage data.

The base URL of the opened endpoints is per default: http://localhost:4567/microstream/

Configuration

If you want to change the default port (4567) or instance name (microstream) it can be done by using the rest service implementation directly. The spark service can then be customized by your liking.

StorageRestServiceSparkJava service = StorageRestServiceSparkJava.New(storage);
service.setSparkService(
		Service.ignite().port(80)
);
service.setInstanceName("my-name");

This will change the base URL to http://localhost/my-name/

Internally, there is a REST adapter which opens access to the low-level storage data. This is used by the REST service layer, which is an abstract service interface. The default implementation of it, which uses , is used to open the REST endpoints. We just have to use this one to get started.

https://docs.microstream.one/
Sparkjava