io.vlingo.symbio.EntryAdapterProvider Java Examples

The following examples show how to use io.vlingo.symbio.EntryAdapterProvider. 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: SourcedTypeRegistry.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Construct my default state with {@code sourcedTypes} creating the {@code Journal}
 * of type {@code journalType}, and register me with the {@code world}.
 * @param world the World to which I am registered
 * @param journalType the concrete {@code Actor} type of the Journal to create
 * @param dispatcher the {@code Dispatcher<Dispatchable<Entry<?>,State<?>>>} of the journalType
 * @param sourcedTypes all {@code Class<Sourced<?>>} types of to register
 * @param <A> the type of Actor used for the Journal implementation
 * @param <S> the {@code Sourced<?>} types to register
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <A extends Actor, S extends Sourced<?>> SourcedTypeRegistry(
        final World world,
        final Class<A> journalType,
        final Dispatcher<Dispatchable<Entry<?>,State<?>>> dispatcher,
        final Class<S> ... sourcedTypes) {

  this(world);

  final Journal<?> journal = world.actorFor(Journal.class, journalType, dispatcher);

  EntryAdapterProvider.instance(world);

  for (Class<S> sourcedType : sourcedTypes) {
    this.register(new Info(journal, sourcedType, sourcedType.getSimpleName()));
  }
}
 
Example #2
Source File: QueryModelStoreProvider.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public static QueryModelStoreProvider using(final Stage stage, final StatefulTypeRegistry registry) {
  if (instance != null) return instance;

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(stage.world());
  stateAdapterProvider.registerAdapter(UserData.class, new UserDataStateAdapter());
  stateAdapterProvider.registerAdapter(ProfileData.class, new ProfileDataStateAdapter());
  new EntryAdapterProvider(stage.world()); // future

  final Dispatcher noop = new Dispatcher() {
    public void controlWith(final DispatcherControl control) { }
    public void dispatch(Dispatchable d) { }
  };

  final StateStore store = stage.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(noop));

  final Queries queries = stage.actorFor(Queries.class, QueriesActor.class, store);

  instance = new QueryModelStoreProvider(registry, store, queries);

  return instance;
}
 
Example #3
Source File: CommandModelStoreProvider.java    From vlingo-examples with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public static CommandModelStoreProvider using(final Stage stage, final StatefulTypeRegistry registry, final Dispatcher dispatcher) {
  if (instance != null) return instance;
  
  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(stage.world());
  stateAdapterProvider.registerAdapter(UserState.class, new UserStateAdapter());
  stateAdapterProvider.registerAdapter(ProfileState.class, new ProfileStateAdapter());
  stateAdapterProvider.registerAdapter(UserData.class, new UserDataStateAdapter());
  stateAdapterProvider.registerAdapter(ProfileData.class, new ProfileDataStateAdapter());
  new EntryAdapterProvider(stage.world()); // future

  final Protocols storeProtocols =
          stage.actorFor(
                  new Class<?>[] { StateStore.class, DispatcherControl.class },
                  Definition.has(InMemoryStateStoreActor.class, Definition.parameters(Arrays.asList(dispatcher))));

  final Protocols.Two<StateStore, DispatcherControl> storeWithControl = Protocols.two(storeProtocols);

  instance = new CommandModelStoreProvider(registry, storeWithControl._1, storeWithControl._2);

  return instance;
}
 
Example #4
Source File: InMemoryStateStoreEntryReaderActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-store");
  world = testWorld.world();

  interest = new MockStateStoreResultInterest();
  dispatcher = new MockStateStoreDispatcher(interest);

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  entryAdapterProvider = new EntryAdapterProvider(world);

  stateAdapterProvider.registerAdapter(Entity1.class, new Entity1StateAdapter());
  // NOTE: No adapter registered for Entity2.class because it will use the default

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));

  final Completes<StateStoreEntryReader<TextEntry>> completes = store.entryReader("test");
  reader = completes.await();

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, Entity1.class.getSimpleName());
  StateTypeStateStoreMap.stateTypeToStoreName(Entity2.class, Entity2.class.getSimpleName());
}
 
Example #5
Source File: SourcedProcessTest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private <T extends Sourced<?>> void registerSourcedTypes(final Class<T> sourcedType) {
  EntryAdapterProvider entryAdapterProvider = EntryAdapterProvider.instance(world);

  sourcedTypeRegistry.register(new Info(journal, sourcedType, sourcedType.getSimpleName()));

  sourcedTypeRegistry.info(sourcedType)
    .registerEntryAdapter(ProcessMessage.class, new ProcessMessageTextAdapter(),
            (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter))
    .registerEntryAdapter(DoStepOne.class, new DoStepOneAdapter(),
            (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter))
    .registerEntryAdapter(DoStepTwo.class, new DoStepTwoAdapter(),
            (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter))
    .registerEntryAdapter(DoStepThree.class, new DoStepThreeAdapter(),
            (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter))
    .registerEntryAdapter(DoStepFour.class, new DoStepFourAdapter(),
            (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter))
    .registerEntryAdapter(DoStepFive.class, new DoStepFiveAdapter(),
          (type, adapter) -> entryAdapterProvider.registerAdapter(type, adapter));
}
 
Example #6
Source File: InMemoryStateStoreRedispatchControlTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  world = World.startWithDefaults("test-store");

  interest = new MockStateStoreResultInterest();
  dispatcher = new MockStateStoreDispatcher(interest);

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  new EntryAdapterProvider(world);

  stateAdapterProvider.registerAdapter(Entity1.class, new Entity1StateAdapter());
  // NOTE: No adapter registered for Entity2.class because it will use the default

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, StoreName);

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));
}
 
Example #7
Source File: InMemoryObjectStoreActor.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public InMemoryObjectStoreActor(
        final List<Dispatcher<Dispatchable<BaseEntry<?>,State<?>>>> dispatchers,
        final long checkConfirmationExpirationInterval,
        final long confirmationExpiration ) {

  this.entryAdapterProvider = EntryAdapterProvider.instance(stage().world());

  this.dispatchers = dispatchers;

  this.entryReaders = new HashMap<>();

  this.storeDelegate = new InMemoryObjectStoreDelegate(StateAdapterProvider.instance(stage().world()));

  this.dispatcherControl = stage().actorFor(
          DispatcherControl.class,
          Definition.has(
                  DispatcherControlActor.class,
                  new DispatcherControlInstantiator(
                          dispatchers,
                          this.storeDelegate,
                          checkConfirmationExpirationInterval,
                          confirmationExpiration)));
}
 
Example #8
Source File: EventSourcedTest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-es");

  world = testWorld.world();

  dispatcher = new MockJournalDispatcher();

  EntryAdapterProvider entryAdapterProvider = EntryAdapterProvider.instance(world);

  entryAdapterProvider.registerAdapter(Test1Happened.class, new Test1HappenedAdapter());
  entryAdapterProvider.registerAdapter(Test2Happened.class, new Test2HappenedAdapter());
  entryAdapterProvider.registerAdapter(Test3Happened.class, new Test3HappenedAdapter());

  journal = world.actorFor(Journal.class, InMemoryJournalActor.class, dispatcher);

  registry = new SourcedTypeRegistry(world);
  registry.register(new Info(journal, TestEventSourcedEntity.class, TestEventSourcedEntity.class.getSimpleName()));
  registry.register(new Info(journal, ProductEntity.class, ProductEntity.class.getSimpleName()));
  registry.register(new Info(journal, ProductParent.class, ProductParent.class.getSimpleName()));
  registry.register(new Info(journal, ProductGrandparent.class, ProductGrandparent.class.getSimpleName()));

  result = new Result();
  entity = world.actorFor(Entity.class, TestEventSourcedEntity.class, result);
}
 
Example #9
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-store");
  world = testWorld.world();

  interest = new MockStateStoreResultInterest();
  dispatcher = new MockStateStoreDispatcher(interest);

  dispatcher.afterCompleting(0); // avoid NPE

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  new EntryAdapterProvider(world);

  stateAdapterProvider.registerAdapter(Entity1.class, new Entity1StateAdapter());
  // NOTE: No adapter registered for Entity2.class because it will use the default

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, StoreName1);
  StateTypeStateStoreMap.stateTypeToStoreName(Entity2.class, StoreName2);
}
 
Example #10
Source File: StatefulEntityTest.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  world = World.startWithDefaults("stateful-entity");
  dispatcher = new MockTextDispatcher();

  stateAdapterProvider = new StateAdapterProvider(world);
  stateAdapterProvider.registerAdapter(Entity1State.class, new Entity1StateAdapter());
  new EntryAdapterProvider(world);
  registry = new StatefulTypeRegistry(world);

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));

  registry.register(new Info<>(store, Entity1State.class, Entity1State.class.getSimpleName()));
}
 
Example #11
Source File: ProjectionDispatcherTest.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  world = World.startWithDefaults("test-store");

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  stateAdapterProvider.registerAdapter(Entity1State.class, new Entity1StateAdapter());
  new EntryAdapterProvider(world);

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, Entity1.class.getSimpleName());
  StateTypeStateStoreMap.stateTypeToStoreName(Entity2.class, Entity2.class.getSimpleName());

  final Protocols dispatcherProtocols =
          world.actorFor(
                  new Class<?>[] { dispatcherInterfaceClass(), ProjectionDispatcher.class },
                  projectionDispatcherClass());

  final Protocols.Two<Dispatcher, ProjectionDispatcher> dispatchers = Protocols.two(dispatcherProtocols);
  dispatcher = dispatchers._1;
  projectionDispatcher = dispatchers._2;

  final Protocols storeProtocols =
          world.actorFor(
                  new Class<?>[] { stateStoreInterfaceClass(), DispatcherControl.class },
                  InMemoryStateStoreActor.class,
                  Arrays.asList(dispatcher));

  final Protocols.Two<StateStore, DispatcherControl> storeWithControl = Protocols.two(storeProtocols);
  store = storeWithControl._1;
  dispatcherControl = storeWithControl._2;
}
 
Example #12
Source File: JournalProjectionDispatcherTest.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
@Before
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setUp() {
  world = World.startWithDefaults("test-journal-projections");

  accessHolder = new AccessHolder();

  final List<ProjectToDescription> descriptions =
          Arrays.asList(
                  ProjectToDescription.with(OneHappenedProjectionActor.class, Optional.of(accessHolder), OneHappened.class),
                  ProjectToDescription.with(TwoHappenedProjectionActor.class, Optional.of(accessHolder), TwoHappened.class),
                  ProjectToDescription.with(AllHappenedProjectionActor.class, Optional.of(accessHolder), OneHappened.class.getPackage()));

  final Protocols dispatcherProtocols =
          world.stage().actorFor(
                  new Class<?>[] { Dispatcher.class, ProjectionDispatcher.class },
                  Definition.has(TextProjectionDispatcherActor.class, new TextProjectionDispatcherInstantiator(descriptions)));

  final Protocols.Two<Dispatcher, ProjectionDispatcher> dispatchers = Protocols.two(dispatcherProtocols);

  this.dispatcher = dispatchers._1;

  journal = Journal.using(world.stage(), InMemoryJournalActor.class, this.dispatcher);

  EntryAdapterProvider.instance(world).registerAdapter(OneHappened.class, new OneHappenedAdapter());
  EntryAdapterProvider.instance(world).registerAdapter(TwoHappened.class, new TwoHappenedAdapter());
  EntryAdapterProvider.instance(world).registerAdapter(ThreeHappened.class, new ThreeHappenedAdapter());

  appendInterest = world.stage().actorFor(AppendResultInterest.class, JournalAppendResultInterest.class);
}
 
Example #13
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 #14
Source File: StatefulProcessTest.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");

  dispatcher = new MockTextDispatcher();
  final MessageQueue queue = new AsyncMessageQueue(null);
  exchange = new LocalExchange(queue);
  stateStore = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));
  EntryAdapterProvider.instance(world);
  statefulTypeRegistry = new StatefulTypeRegistry(world);

  final Info<StepCountState> stepCountStateInfo =
          new StatefulTypeRegistry.Info(
          stateStore,
          StepCountState.class,
          StepCountState.class.getSimpleName());

  statefulTypeRegistry.register(stepCountStateInfo);

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

  registerExchangeCoveys();

  processTypeRegistry = new ProcessTypeRegistry(world);
  processTypeRegistry.register(new StatefulProcessInfo(FiveStepEmittingStatefulProcess.class, FiveStepEmittingStatefulProcess.class.getSimpleName(), exchange, statefulTypeRegistry));
}
 
Example #15
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 #16
Source File: CounterQueryActorTest.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
    journalReader = mock(JournalReader.class);
    this.entryAdapterProvider = new EntryAdapterProvider();
    counterIncreasedAdapter = new CounterIncreasedAdapter();
    this.entryAdapterProvider.registerAdapter(CounterIncreased.class, counterIncreasedAdapter);
    counterDecreasedAdapter = new CounterDecreasedAdapter();
    this.entryAdapterProvider.registerAdapter(CounterDecreased.class, counterDecreasedAdapter);
}
 
Example #17
Source File: CounterQueryActor.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public CounterQueryActor(JournalReader<TextEntry> streamReader, EntryAdapterProvider entryAdapterProvider) {
    this.streamReader = streamReader;
    this.entryAdapterProvider = entryAdapterProvider;
    this.cancellable = scheduler().schedule(selfAs(Scheduled.class), null, 0, 5);
    this.currentCount = Optional.empty();
    intervalSignal(null, null);
}
 
Example #18
Source File: SourcedTypeRegistry.java    From vlingo-lattice with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Construct my default state.
 * @param journal the {@code Journal<T>} of the registration
 * @param sourcedType the {@code Class<Sourced<T>>} of the registration
 * @param sourcedName the String name of the sourcedType
 */
public Info(final Journal<T> journal, final Class<Sourced<T>> sourcedType, final String sourcedName) {
  this.journal = journal;
  this.sourcedType = sourcedType;
  this.sourcedName = sourcedName;
  this.entryAdapterProvider = new EntryAdapterProvider();
  this.stateAdapterProvider = new StateAdapterProvider();
}
 
Example #19
Source File: InMemoryEventJournalActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  world = World.startWithDefaults("test-journal");
  this.dispatcher = new MockDispatcher<>(new MockConfirmDispatchedResultInterest());

  journal = Journal.using(world.stage(), InMemoryJournalActor.class, this.dispatcher);
  EntryAdapterProvider.instance(world).registerAdapter(Test1Source.class, new Test1SourceAdapter());
  EntryAdapterProvider.instance(world).registerAdapter(Test2Source.class, new Test2SourceAdapter());
  StateAdapterProvider.instance(world).registerAdapter(SnapshotState.class, new SnapshotStateAdapter());
}
 
Example #20
Source File: InMemoryStateStoreActor.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public InMemoryStateStoreActor(
        final List<Dispatcher<Dispatchable<Entry<?>, RS>>> dispatchers,
        final long checkConfirmationExpirationInterval,
        final long confirmationExpiration) {

  if (dispatchers == null) {
    throw new IllegalArgumentException("Dispatcher must not be null.");
  }
  this.dispatchers = dispatchers;
  this.entryAdapterProvider = EntryAdapterProvider.instance(stage().world());
  this.stateAdapterProvider = StateAdapterProvider.instance(stage().world());
  this.entries = new CopyOnWriteArrayList<>();
  this.entryReaders = new HashMap<>();
  this.store = new HashMap<>();
  this.dispatchables = new CopyOnWriteArrayList<>();
  this.readAllResultCollector = new ReadAllResultCollector();

  final InMemoryDispatcherControlDelegate<Entry<?>, RS> dispatcherControlDelegate = new InMemoryDispatcherControlDelegate<>(dispatchables);

  this.dispatcherControl = stage().actorFor(
    DispatcherControl.class,
    Definition.has(
      DispatcherControlActor.class,
      new DispatcherControlInstantiator(
        dispatchers,
        dispatcherControlDelegate,
        checkConfirmationExpirationInterval,
        confirmationExpiration)));
}
 
Example #21
Source File: EntryReaderSource.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Constructs my default state.
 * @param entryReader the {@code EntryReader<T>} from which to read entry elements
 * @param entryAdapterProvider the EntryAdapterProvider used to turn Entry instances into {@code Source<?>} instances
 * @param flowElementsRate the long maximum elements to read at once
 */
@SuppressWarnings("unchecked")
public EntryReaderSource(
        final EntryReader<T> entryReader,
        final EntryAdapterProvider entryAdapterProvider,
        final long flowElementsRate) {

  this.entryReader = entryReader;
  this.entryAdapterProvider = entryAdapterProvider;
  this.flowElementsRate = flowElementsRate;
  this.cache = new ArrayDeque<>();

  this.cancellable = scheduler().schedule(selfAs(Scheduled.class), null, 0, Stream.FastProbeInterval);
}
 
Example #22
Source File: InMemoryJournal.java    From vlingo-symbio with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
public InMemoryJournal(
        final List<Dispatcher<Dispatchable<Entry<T>,RS>>> dispatchers,
        final World world,
        final long checkConfirmationExpirationInterval,
        final long confirmationExpiration) {

  this.entryAdapterProvider = EntryAdapterProvider.instance(world);
  this.stateAdapterProvider = StateAdapterProvider.instance(world);
  this.journal = new ArrayList<>();
  this.journalReaders = new HashMap<>(1);
  this.streamReaders = new HashMap<>(1);
  this.streamIndexes = new HashMap<>();
  this.snapshots = new HashMap<>();

  this.dispatchers = dispatchers;
  this.dispatchables = new CopyOnWriteArrayList<>();
  final InMemoryDispatcherControlDelegate<Entry<T>, RS> dispatcherControlDelegate = new InMemoryDispatcherControlDelegate<>(dispatchables);

  this.dispatcherControl = world.stage().actorFor(
          DispatcherControl.class,
          Definition.has(
                  DispatcherControlActor.class,
                  new DispatcherControlInstantiator(
                          dispatchers,
                          dispatcherControlDelegate,
                          checkConfirmationExpirationInterval,
                          confirmationExpiration)));
}
 
Example #23
Source File: CartQueryProvider.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private static void registerStateAdapter(Stage stage) {
  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(stage.world());
  stateAdapterProvider.registerAdapter(CartUserSummaryData.class, new CartStateAdapter());
  stateAdapterProvider.registerAdapter(UserId.class, new UserIdStateAdapter() );
  new EntryAdapterProvider(stage.world()); // future?
}
 
Example #24
Source File: DiscussionTest.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private EntryAdapterProvider postAdapter() {
  return registry.info(PostEntity.class).entryAdapterProvider;
}
 
Example #25
Source File: ForumTest.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private EntryAdapterProvider adapter() {
  return registry.info(ForumEntity.class).entryAdapterProvider;
}
 
Example #26
Source File: ForumTest.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private EntryAdapterProvider discussionAdapter() {
  return registry.info(DiscussionEntity.class).entryAdapterProvider;
}
 
Example #27
Source File: PostTest.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private EntryAdapterProvider adapter() {
  return registry.info(PostEntity.class).entryAdapterProvider;
}
 
Example #28
Source File: DiscussionTest.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
private EntryAdapterProvider adapter() {
  return registry.info(DiscussionEntity.class).entryAdapterProvider;
}
 
Example #29
Source File: EntryReaderStream.java    From vlingo-symbio with Mozilla Public License 2.0 4 votes vote down vote up
public EntryReaderStream(final Stage stage, final EntryReader<T> entryReader, final EntryAdapterProvider entryAdapterProvider) {
  this.stage = stage;
  this.entryReader = entryReader;
  this.entryAdapterProvider = entryAdapterProvider;
}
 
Example #30
Source File: Bootstrap.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Flyway.configure().dataSource(DB_URL, DB_USER, DB_PWD).load().migrate();
    final Configuration configuration = new Configuration(
    		DatabaseType.Postgres,
            new NoopConfigurationInterest(),
            "org.postgresql.Driver",
            DataFormat.Text,
            DB_URL,
            DB_NAME,
            DB_USER,
            DB_PWD,
            false,
            "",
            false
    );

    final World world = World.startWithDefaults("event-journal");

    final NoopEventJournalDispatcher journalDispatcher = new NoopEventJournalDispatcher();
    Journal<String> journal = Journal.using(world.stage(), JDBCJournalActor.class, journalDispatcher, configuration);

    final Counter counter = world.actorFor(
            Counter.class,
            Definition.has(CounterActor.class, Definition.parameters(DB_NAME, journal))
    );

    final CounterQuery counterQuery = world.actorFor(
            CounterQuery.class,
            Definition.has(CounterQueryActor.class, Definition.parameters(journal.journalReader(DB_NAME).<JournalReader<Entry<?>>>await(), new EntryAdapterProvider()))
    );

    for (int i = 0; i < 5000; i++) {
        if (i % 10 == 0) {
            counter.decrease();
        } else {
            counter.increase();
        }

        pause();
        counterQuery.counter().andThenConsume(System.out::println);
    }

    world.terminate();
}