Search in sources :

Example 1 with DefaultDolphinEventBus

use of com.canoo.dp.impl.server.event.DefaultDolphinEventBus in project dolphin-platform by canoo.

the class DolphinPlatformSpringTestBootstrap method createEventBus.

/**
 * Method to create a spring managed {@link RemotingEventBus} instance in singleton scope.
 *
 * @return the instance
 */
@Bean(name = "dolphinEventBus")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
protected RemotingEventBus createEventBus(final TestConfiguration testConfiguration) {
    Assert.requireNonNull(testConfiguration, "testConfiguration");
    final DolphinContextProvider contextProvider = new DolphinContextProvider() {

        @Override
        public DolphinContext getContext(ClientSession clientSession) {
            return getCurrentDolphinContext();
        }

        @Override
        public DolphinContext getContextById(String clientSessionId) {
            return getCurrentDolphinContext();
        }

        @Override
        public DolphinContext getCurrentDolphinContext() {
            return testConfiguration.getDolphinTestContext();
        }
    };
    final DefaultDolphinEventBus eventBus = new DefaultDolphinEventBus();
    eventBus.init(contextProvider, new ClientSessionLifecycleHandlerImpl());
    return eventBus;
}
Also used : ClientSessionLifecycleHandlerImpl(com.canoo.dp.impl.server.client.ClientSessionLifecycleHandlerImpl) DolphinContextProvider(com.canoo.dp.impl.server.context.DolphinContextProvider) DefaultDolphinEventBus(com.canoo.dp.impl.server.event.DefaultDolphinEventBus) ClientSession(com.canoo.platform.server.client.ClientSession) Scope(org.springframework.context.annotation.Scope) Bean(org.springframework.context.annotation.Bean)

Aggregations

ClientSessionLifecycleHandlerImpl (com.canoo.dp.impl.server.client.ClientSessionLifecycleHandlerImpl)1 DolphinContextProvider (com.canoo.dp.impl.server.context.DolphinContextProvider)1 DefaultDolphinEventBus (com.canoo.dp.impl.server.event.DefaultDolphinEventBus)1 ClientSession (com.canoo.platform.server.client.ClientSession)1 Bean (org.springframework.context.annotation.Bean)1 Scope (org.springframework.context.annotation.Scope)1