Search in sources :

Example 1 with SessionStoreHousekeepingDelayProperty

use of org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty in project scout.rt by eclipse.

the class UiSessionTest method before.

@Before
public void before() {
    m_oldRunContext = RunContext.CURRENT.get();
    // Because this test must be executed by a bare JUnit runner (see JavaDoc of test class).
    RunContext.CURRENT.set(RunContexts.empty());
    m_beans = TestingUtility.registerBeans(new BeanMetaData(JobCompletionDelayOnSessionShutdown.class).withProducer(new IBeanInstanceProducer<JobCompletionDelayOnSessionShutdown>() {

        @Override
        public JobCompletionDelayOnSessionShutdown produce(IBean<JobCompletionDelayOnSessionShutdown> bean) {
            return new JobCompletionDelayOnSessionShutdown() {

                @Override
                protected Long getDefaultValue() {
                    return 0L;
                }
            };
        }
    }), new BeanMetaData(SessionStoreHousekeepingDelayProperty.class).withInitialInstance(new SessionStoreHousekeepingDelayProperty() {

        @Override
        protected Integer getDefaultValue() {
            return 0;
        }
    }), new BeanMetaData(SessionStoreHousekeepingMaxWaitShutdownProperty.class).withInitialInstance(new SessionStoreHousekeepingMaxWaitShutdownProperty() {

        @Override
        protected Integer getDefaultValue() {
            return 1;
        }
    }), new BeanMetaData(SessionStoreMaxWaitWriteLockProperty.class).withInitialInstance(new SessionStoreMaxWaitWriteLockProperty() {

        @Override
        protected Integer getDefaultValue() {
            return 1;
        }
    }), new BeanMetaData(SessionStoreMaxWaitAllShutdownProperty.class).withInitialInstance(new SessionStoreMaxWaitAllShutdownProperty() {

        @Override
        protected Integer getDefaultValue() {
            return 1;
        }
    }), new BeanMetaData(TestEnvironmentClientSession.class));
}
Also used : SessionStoreMaxWaitWriteLockProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitWriteLockProperty) SessionStoreMaxWaitAllShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitAllShutdownProperty) BeanMetaData(org.eclipse.scout.rt.platform.BeanMetaData) SessionStoreHousekeepingMaxWaitShutdownProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingMaxWaitShutdownProperty) SessionStoreHousekeepingDelayProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty) JobCompletionDelayOnSessionShutdown(org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown) Before(org.junit.Before)

Example 2 with SessionStoreHousekeepingDelayProperty

use of org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty in project scout.rt by eclipse.

the class SessionStore method startHousekeeping.

/**
 * If the given client session is still active, schedule a job that checks whether it is still in use after some time
 * (see {@link SessionStoreHousekeepingDelayProperty}). If not, it will be stopped and removed from the store. If the
 * session is inactive from the beginning, it is just removed from the store.
 * <p>
 * <b>Important:</b>: This method must be called from within a lock!
 */
protected void startHousekeeping(final IClientSession clientSession) {
    // No client session, no house keeping necessary
    if (clientSession == null) {
        return;
    }
    // If client session is already inactive, simply update the maps, but take no further action.
    if (!clientSession.isActive()) {
        LOG.info("Session housekeeping: Removing inactive client session with ID {} from store", clientSession.getId());
        removeClientSession(clientSession);
        return;
    }
    // Check if client session is still used after a few moments
    LOG.debug("Session housekeeping: Schedule job for client session with ID {}", clientSession.getId());
    final IFuture<Void> future = Jobs.schedule(new IRunnable() {

        @Override
        public void run() throws Exception {
            doHousekeeping(clientSession);
        }
    }, Jobs.newInput().withName("Performing session housekeeping for client session with ID {}", clientSession.getId()).withExecutionTrigger(Jobs.newExecutionTrigger().withStartIn(CONFIG.getPropertyValue(SessionStoreHousekeepingDelayProperty.class), TimeUnit.SECONDS)));
    // Put the future in a list, so we can cancel it if the session is requested again
    m_housekeepingFutures.put(clientSession.getId(), future);
}
Also used : SessionStoreHousekeepingDelayProperty(org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable)

Aggregations

SessionStoreHousekeepingDelayProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingDelayProperty)2 JobCompletionDelayOnSessionShutdown (org.eclipse.scout.rt.client.ClientConfigProperties.JobCompletionDelayOnSessionShutdown)1 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 IRunnable (org.eclipse.scout.rt.platform.util.concurrent.IRunnable)1 SessionStoreHousekeepingMaxWaitShutdownProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreHousekeepingMaxWaitShutdownProperty)1 SessionStoreMaxWaitAllShutdownProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitAllShutdownProperty)1 SessionStoreMaxWaitWriteLockProperty (org.eclipse.scout.rt.ui.html.UiHtmlConfigProperties.SessionStoreMaxWaitWriteLockProperty)1 Before (org.junit.Before)1