Package de.novanic.eventservice.config

Examples of de.novanic.eventservice.config.EventServiceConfiguration


    @Test
    public void testTimeOut_CustomUnlistenEvent() throws Exception {
        //set the default waiting time greater than time out time to produce a time out
        EventRegistry theEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();
        EventServiceConfiguration theEventServiceConfiguration = theEventRegistry.getConfiguration();

        final int theTimeoutTime = 400;
        final int theNewMaxWaitingTime = theTimeoutTime + 1700;
        EventServiceConfiguration theNewEventServiceConfiguration = createConfiguration(
                theEventServiceConfiguration.getMinWaitingTime(),
                theNewMaxWaitingTime,
                theTimeoutTime);

        tearDownEventServiceConfiguration();
        setUp(theNewEventServiceConfiguration);

        theEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();

        theEventRegistry.registerUser(TEST_DOMAIN, TEST_USER_ID, null);
        theEventRegistry.addEvent(TEST_DOMAIN, new DummyEvent());
        assertTrue(theEventRegistry.isUserRegistered(TEST_USER_ID));

        theEventRegistry.registerUnlistenEvent(TEST_USER_ID, UnlistenEventListener.Scope.UNLISTEN, new TestUnlistenEvent("testuser", "123"));

        List<DomainEvent> theEvents = theEventRegistry.listen(getLongPollingListener(), TEST_USER_ID);
        assertNotNull(theEvents);
        assertEquals(1, theEvents.size());
        assertFalse(theEvents.get(0).getEvent() instanceof UnlistenEvent);

        assertTrue(theEventRegistry.isUserRegistered(TEST_USER_ID));

        //It is waiting for events and will cause a timeout, because the max. waiting time is configured longer than the timeout time.
        //The result is a UnlistenEvent, because the timeout doesn't effect that method, but the next call.
        theEvents = theEventRegistry.listen(getLongPollingListener(), TEST_USER_ID);

        //wait for the UserActivityScheduler-Thread
        Thread.yield();
        Thread.sleep(theNewEventServiceConfiguration.getTimeoutTime() + 100);

        assertNotNull(theEvents);
        assertEquals(1, theEvents.size());
        assertTrue(theEvents.get(0).getEvent() instanceof UnlistenEvent);
        assertFalse(theEventRegistry.isUserRegistered(TEST_USER_ID));
View Full Code Here


    protected EventServiceConfiguration createConfiguration(int aMinTime, int aMaxTime, int aTimeoutTime, String aConnectionIdGeneratorClassName, String aConnectionStrategyServerConnectorClassName) {
        return new RemoteEventServiceConfiguration("TestConfiguration", aMinTime, aMaxTime, aTimeoutTime, 0, aConnectionIdGeneratorClassName, null, aConnectionStrategyServerConnectorClassName, "utf-8", 100000);
    }

    protected ConnectionStrategyServerConnector getLongPollingListener() {
        EventServiceConfiguration theConfiguration = EventServiceConfigurationFactory.getInstance().loadEventServiceConfiguration();
        return getLongPollingListener(theConfiguration);
    }
View Full Code Here

     */
    public EventRegistry getEventRegistry() {
        if(myEventRegistry == null) {
            synchronized(this) {
                if(myEventRegistry == null) {
                    EventServiceConfiguration theConfiguration = getEventServiceConfiguration();
                    myEventRegistry = new DefaultEventRegistry(theConfiguration);
                }
            }
        }
        return myEventRegistry;
View Full Code Here

     * @throws ServletException
     */
    public void init(ServletConfig aConfig) throws ServletException {
        super.init(aConfig);
        myEventRegistry = initEventRegistry(aConfig);
        EventServiceConfiguration theConfiguration = myEventRegistry.getConfiguration();
        myConfigurationDependentFactory = ConfigurationDependentFactory.getInstance(theConfiguration);
    }
View Full Code Here

     * Initializes the {@link de.novanic.eventservice.client.event.service.EventService}.
     * @return EventServiceConfigurationTransferable a transferable configuration for the client side
     */
    public EventServiceConfigurationTransferable initEventService() {
        final String theClientId = generateClientId();
        final EventServiceConfiguration theConfiguration = myEventRegistry.getConfiguration();

        String theClientIdTransferable;
        if(SessionConnectionIdGenerator.class.getName().equals(theConfiguration.getConnectionIdGeneratorClassName())) {
            theClientIdTransferable = null;
        } else {
            theClientIdTransferable = theClientId;
        }
        LOG.info("Client \"{}\" initialized.", theClientId);
        return new RemoteEventServiceConfigurationTransferable(theConfiguration.getMinWaitingTime(), theConfiguration.getMaxWaitingTime(),
                theConfiguration.getTimeoutTime(), theConfiguration.getReconnectAttemptCount(), theClientIdTransferable, theConfiguration.getConnectionStrategyClientConnectorClassName());
    }
View Full Code Here

     * @return EventExecutorService
     */
    public EventExecutorService getEventExecutorService(HttpServletRequest aRequest) {
        String theConnectionId = null;
        if(aRequest != null) {
            EventServiceConfiguration theConfiguration = EventRegistryFactory.getInstance().getEventRegistry().getConfiguration();

            ConnectionIdGenerator theConnectionIdGenerator = ConfigurationDependentFactory.getInstance(theConfiguration).getConnectionIdGenerator();
            theConnectionId = theConnectionIdGenerator.getConnectionId(aRequest);
        }
        return getEventExecutorService(theConnectionId);
View Full Code Here

TOP

Related Classes of de.novanic.eventservice.config.EventServiceConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.