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));
}
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);
}
Aggregations