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

The following examples show how to use io.vlingo.symbio.store.object.StateObjectMapper. 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: 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 #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(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 #3
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 #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(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 #5
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 #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: 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 #8
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 #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: InMemoryObjectStoreDelegate.java    From vlingo-symbio with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void registerMapper(final StateObjectMapper mapper) {
  //InMemory store does not require mappers
}
 
Example #11
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;
}