io.vlingo.symbio.store.dispatch.DispatcherControl Java Examples

The following examples show how to use io.vlingo.symbio.store.dispatch.DispatcherControl. 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: 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 #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: 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 #5
Source File: Bootstrap.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@NotNull
@SuppressWarnings("rawtypes")
private Dispatcher createNoOpDispatcher() {
    return new Dispatcher() {
            public void controlWith(final DispatcherControl control) { }
            public void dispatch(Dispatchable d) { }
        };
}
 
Example #6
Source File: CommandModelStoreProvider.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private CommandModelStoreProvider(final StatefulTypeRegistry registry, final StateStore store, final DispatcherControl dispatcherControl) {
  this.store = store;
  this.dispatcherControl = dispatcherControl;

  registry
    .register(new Info(store, User.UserState.class, User.UserState.class.getSimpleName()))
    .register(new Info(store, Profile.ProfileState.class, Profile.ProfileState.class.getSimpleName()))
    .register(new Info(store, UserData.class, UserData.class.getSimpleName()))
    .register(new Info(store, ProfileData.class, ProfileData.class.getSimpleName()));
}
 
Example #7
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 #8
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 #9
Source File: MockTextDispatcher.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
  this.control = control;
}
 
Example #10
Source File: MockDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
}
 
Example #11
Source File: ExchangeDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(DispatcherControl control) {
  this.control = control;
}
 
Example #12
Source File: MockDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
}
 
Example #13
Source File: MockDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
}
 
Example #14
Source File: MockStateStoreDispatcher.java    From vlingo-symbio with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
  this.control = control;
}
 
Example #15
Source File: ProjectionDispatcherActor.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
  this.control = control;
}
 
Example #16
Source File: ExchangeDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void controlWith(DispatcherControl control) {
    this.control = control;
}
 
Example #17
Source File: NoopEventJournalDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
  
}
 
Example #18
Source File: NoOpStateDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(DispatcherControl dispatcherControl) {

}
 
Example #19
Source File: MockJournalDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
    
}
 
Example #20
Source File: MockJournalDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {

}
 
Example #21
Source File: MockDispatcher.java    From vlingo-lattice with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {

}
 
Example #22
Source File: MockJournalDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {

}
 
Example #23
Source File: MockDispatcher.java    From vlingo-examples with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {

}
 
Example #24
Source File: MockJournalDispatcher.java    From vlingo-lattice with Mozilla Public License 2.0 2 votes vote down vote up
@Override
public void controlWith(final DispatcherControl control) {
  
}