io.vlingo.symbio.store.object.ObjectStore Java Examples

The following examples show how to use io.vlingo.symbio.store.object.ObjectStore. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalculationTests.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() {
    final World world = TestWorld.start("calculation-test").world();

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(Calculation.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(CalculationState.class, new Object(), new Object());

    final ObjectTypeRegistry.Info<CalculationState> info =
            new ObjectTypeRegistry.Info(objectStore, CalculationState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    CalculationQueryProvider.using(world.stage(), objectStore);
}
 
Example #2
Source File: Bootstrap.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
private Bootstrap(final VlingoServer vlingoServer) {
    this.server = vlingoServer.getServer();
    this.world = vlingoServer.getVlingoScene().getWorld();

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(Calculation.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(Calculation.class, new Object(), new Object());

    final Info<CalculationState> info =
            new Info(objectStore, CalculationState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    CalculationQueryProvider.using(world.stage(), objectStore);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        stopAndCleanup();
    }));
}
 
Example #3
Source File: EmployeeEntityTest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setUp() {
  world = World.startWithDefaults("test-object-entity");
  objectStore = world.actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

  registry = new ObjectTypeRegistry(world);

  // NOTE: The InMemoryObjectStoreActor implementation currently
  // does not use PersistentObjectMapper, and thus the no-op decl.
  final Info<Employee> employeeInfo =
          new Info(
          objectStore,
          EmployeeState.class,
          "HR-Database",
          MapQueryExpression.using(Employee.class, "find", MapQueryExpression.map("number", "number")),
          StateObjectMapper.with(Employee.class, new Object(), new Object()));

  registry.register(employeeInfo);
}
 
Example #4
Source File: Bootstrap.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
private Bootstrap(final VlingoServer vlingoServer) {
    this.server = vlingoServer.getServer();
    this.world = vlingoServer.getVlingoScene().getWorld();

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(StockEntity.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(StockEntity.class, new Object(), new Object());

    final Info<StockState> info =
            new Info(objectStore, StockState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    StockQueryProvider.using(world.stage(), objectStore);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        stopAndCleanup();
    }));
}
 
Example #5
Source File: StockTest.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() {
    final World world = TestWorld.start("stock-test").world();

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(Stock.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(Stock.class, new Object(), new Object());

    final Info<StockState> info =
            new Info(objectStore, StockState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    StockQueryProvider.using(world.stage(), objectStore);
}
 
Example #6
Source File: OrganizationEntityTest.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() throws Exception {
  grid = Grid.start("object-entity-test", Configuration.define(), ClusterProperties.oneNode(), "node1");
  grid.quorumAchieved();
  objectStore = grid.actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());
  registry = new ObjectTypeRegistry(grid.world());

  final Info<Organization> info =
          new Info(
          objectStore,
          io.vlingo.entity.object.State.class,
          "ObjectStore",
          MapQueryExpression.using(Organization.class, "find", MapQueryExpression.map("id", "id")),
          StateObjectMapper.with(Organization.class, new Object(), new Object()));

  registry.register(info);
}
 
Example #7
Source File: OrderTest.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() {
    final World world = TestWorld.start("order-test").world();

    messagingClient = Mockito.mock(MessagingClient.class);
    applicationRegistry = Mockito.mock(ApplicationRegistry.class);
    Mockito.when(applicationRegistry.retrieveStage()).thenReturn(world.stage());
    Mockito.when(applicationRegistry.retrieveMessagingClient()).thenReturn(messagingClient);

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(Order.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(Order.class, new Object(), new Object());

    final ObjectTypeRegistry.Info<OrderState> info =
            new ObjectTypeRegistry.Info(objectStore, OrderState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    OrderQueryProvider.using(world.stage(), objectStore);
}
 
Example #8
Source File: Bootstrap.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
private Bootstrap(final VlingoServer vlingoServer) {
    this.server = vlingoServer.getServer();
    this.world = vlingoServer.getVlingoScene().getWorld();

    final MapQueryExpression objectQuery =
            MapQueryExpression.using(Order.class, "find", MapQueryExpression.map("id", "id"));

    final ObjectStore objectStore =
            world.stage().actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, new MockDispatcher());

    final StateObjectMapper stateObjectMapper =
            StateObjectMapper.with(Order.class, new Object(), new Object());

    final Info<OrderState> info =
            new Info(objectStore, OrderState.class,
                    "ObjectStore", objectQuery, stateObjectMapper);

    new ObjectTypeRegistry(world).register(info);

    OrderQueryProvider.using(world.stage(), objectStore);

    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        stopAndCleanup();
    }));
}
 
Example #9
Source File: ObjectProcessTest.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() {
  world = World.startWithDefaults("five-step-process-test");

  final MessageQueue queue = new AsyncMessageQueue(null);
  exchange = new LocalExchange(queue);
  final ProcessMessageTextAdapter adapter = new ProcessMessageTextAdapter();
  EntryAdapterProvider.instance(world).registerAdapter(ProcessMessage.class, adapter);

  dispatcher = new MockTextDispatcher();
  objectStore = world.actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, dispatcher);

  objectTypeRegistry = new ObjectTypeRegistry(world);

  final Info<StepCountObjectState> stepCountStateInfo =
          new ObjectTypeRegistry.Info(
          objectStore,
          StepCountObjectState.class,
          StepCountObjectState.class.getSimpleName(),
          MapQueryExpression.using(StepCountObjectState.class, "find", MapQueryExpression.map("id", "id")),
          StateObjectMapper.with(StepCountObjectState.class, new Object(), new Object()));

  objectTypeRegistry.register(stepCountStateInfo);

  exchangeReceivers = new ExchangeReceivers();
  exchangeSender = new LocalExchangeSender(queue);

  registerExchangeCoveys();

  processTypeRegistry = new ProcessTypeRegistry(world);
  processTypeRegistry.register(new ObjectProcessInfo(FiveStepEmittingObjectProcess.class, FiveStepEmittingObjectProcess.class.getSimpleName(), exchange, objectTypeRegistry));
}
 
Example #10
Source File: InMemoryObjectStoreActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  persistInterest = new MockPersistResultInterest();
  queryResultInterest = new MockQueryResultInterest();
  world = World.startWithDefaults("test-object-store");
  final EntryAdapterProvider entryAdapterProvider = new EntryAdapterProvider(world);
  entryAdapterProvider.registerAdapter(Test1Source.class, new Test1SourceAdapter());

  this.dispatcher = new MockDispatcher<>(new MockConfirmDispatchedResultInterest());
  objectStore = world.actorFor(ObjectStore.class, InMemoryObjectStoreActor.class, this.dispatcher);
}
 
Example #11
Source File: OrderQueriesActor.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public OrderQueriesActor(final ObjectStore objectStore) {
    super(objectStore);
}
 
Example #12
Source File: CalculationQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private CalculationQueryProvider(final Stage stage, final ObjectStore objectStore) {
    this.queries = stage.actorFor(CalculationQueries.class, CalculationQueriesActor.class, objectStore);
}
 
Example #13
Source File: CalculationQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public static CalculationQueryProvider using(final Stage stage, final ObjectStore objectStore) {
    if(instance == null) {
        instance = new CalculationQueryProvider(stage, objectStore);
    }
    return instance;
}
 
Example #14
Source File: CalculationQueriesActor.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public CalculationQueriesActor(final ObjectStore objectStore) {
    super(objectStore);
}
 
Example #15
Source File: OrderQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private OrderQueryProvider(final Stage stage, final ObjectStore objectStore) {
    this.queries = stage.actorFor(OrderQueries.class, OrderQueriesActor.class, objectStore);
}
 
Example #16
Source File: OrderQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public static OrderQueryProvider using(final Stage stage, final ObjectStore objectStore) {
    if(instance == null) {
        instance = new OrderQueryProvider(stage, objectStore);
    }
    return instance;
}
 
Example #17
Source File: StockQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private StockQueryProvider(final Stage stage, final ObjectStore objectStore) {
    this.queries = stage.actorFor(StockQueries.class, StockQueriesActor.class, objectStore);
}
 
Example #18
Source File: StockQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public static StockQueryProvider using(final Stage stage, final ObjectStore objectStore) {
    if(instance == null) {
        instance = new StockQueryProvider(stage, objectStore);
    }
    return instance;
}
 
Example #19
Source File: StockQueriesActor.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public StockQueriesActor(final ObjectStore objectStore) {
    super(objectStore);
}
 
Example #20
Source File: StateObjectQueryActor.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Construct my state.
 * @param objectStore the ObjectStore the query
 */
protected StateObjectQueryActor(final ObjectStore objectStore) {
  this.objectStore = objectStore;
  this.queryResultInterest = selfAs(QueryResultInterest.class);
}
 
Example #21
Source File: ObjectTypeRegistry.java    From vlingo-lattice with Mozilla Public License 2.0 3 votes vote down vote up
/**
 * Construct my default state.
 * @param store the ObjectStore instance
 * @param storeType the {@code Class<T>} Object type that uses the ObjectStore
 * @param storeName the String name of the ObjectStore
 * @param queryObjectExpression the QueryExpression used to retrieve a single instance
 * @param mapper the PersistentObjectMapper between Object type and persistent type
 */
public Info(final ObjectStore store, final Class<T> storeType, final String storeName, final QueryExpression queryObjectExpression, final StateObjectMapper mapper) {
  this.store = store;
  this.storeType = storeType;
  this.storeName = storeName;
  this.queryObjectExpression = queryObjectExpression;
  this.mapper = mapper;
}