@@ -0,0 +1,3290 @@
+/*%0A * Copyright 2015, TeamDev Ltd. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage org.spine3.examples.eventstore;%0A%0Aimport com.google.common.util.concurrent.MoreExecutors;%0Aimport io.grpc.Server;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.spine3.server.EventStore;%0Aimport org.spine3.server.storage.memory.InMemoryStorageFactory;%0A%0A/**%0A * @author Alexander Yevsyukov%0A */%0Apublic class EventStoreServer %7B%0A%0A    /* The port on which the server should run */%0A    private static final int port = 50051;%0A    private Server server;%0A%0A    private void start() throws InterruptedException %7B%0A        server = EventStore.createServer(%0A                       MoreExecutors.directExecutor(),%0A                       InMemoryStorageFactory.getInstance().createEventStorage(),%0A                       port);%0A        log().info(%22EventStore server started. Listening on port: %22 + port);%0A        addShutdownHook();%0A    %7D%0A%0A    private void addShutdownHook() %7B%0A        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() %7B%0A            // Use stderr here since the logger may have been reset by its JVM shutdown hook.%0A            @SuppressWarnings(%22UseOfSystemOutOrSystemErr%22)%0A            @Override%0A            public void run() %7B%0A                System.err.println(%22Shutting down the EventStore server since JVM is shutting down...%22);%0A                server.shutdown();%0A                System.err.println(%22EventStore server shut down.%22);%0A            %7D%0A        %7D));%0A    %7D%0A%0A    private void stop() %7B%0A        if (server != null) %7B%0A            server.shutdown();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Await termination on the main thread since the grpc library uses daemon threads.%0A     */%0A    private void blockUntilShutdown() throws InterruptedException %7B%0A        if (server != null) %7B%0A            server.awaitTermination();%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws InterruptedException %7B%0A        final EventStoreServer server = new EventStoreServer();%0A        server.start();%0A        server.blockUntilShutdown();%0A    %7D%0A%0A    private enum LogSingleton %7B%0A        INSTANCE;%0A%0A        @SuppressWarnings(%22NonSerializableFieldInSerializableClass%22)%0A        private final Logger value = LoggerFactory.getLogger(EventStoreServer.class);%0A    %7D%0A%0A    private static Logger log() %7B%0A        return LogSingleton.INSTANCE.value;%0A    %7D%0A%0A%7D%0A

Add EventStoreServer example.