use of org.eclipse.scout.rt.client.IClientSession in project scout.rt by eclipse.
the class AbstractObservableNotificationHandler method sessionChanged.
/**
* Automatically removes listeners for stopped sessions.
*/
@Override
public void sessionChanged(SessionEvent event) {
if (event.getType() == SessionEvent.TYPE_STOPPED) {
// only interested in session stopped
ISession session = Assertions.assertNotNull(event.getSource());
if (session instanceof IClientSession) {
IClientSession clientSession = (IClientSession) session;
synchronized (m_listeners) {
for (INotificationListener<T> notificationListener : getListeners(clientSession)) {
removeListener(clientSession, notificationListener);
LOG.warn("Auto fallback removal of session listener due to stopped session. This must be done explicitly by the one that registered the listener: {}", notificationListener);
}
}
}
}
}
use of org.eclipse.scout.rt.client.IClientSession in project scout.rt by eclipse.
the class ClientSessionRegistry method sessionStopped.
/**
* this method is expected to be called in the context of the specific session.
*
* @param session
*/
protected void sessionStopped(final IClientSession session) {
checkSession(session);
final String sessionId = session.getId();
final String userId = session.getUserId();
LOG.debug("Unregister client session [sessionid={}, userId={}].", sessionId, userId);
// client session household
synchronized (m_cacheLock) {
m_sessionIdToSession.remove(session.getId());
List<WeakReference<IClientSession>> userSessions = m_userToSessions.get(userId);
if (userSessions != null) {
for (Iterator<WeakReference<IClientSession>> it = userSessions.iterator(); it.hasNext(); ) {
WeakReference<IClientSession> ref = it.next();
IClientSession clientSession = ref.get();
if (clientSession == null || ObjectUtility.equals(clientSession.getId(), session.getId())) {
it.remove();
}
}
if (userSessions.isEmpty()) {
m_userToSessions.remove(userId);
}
}
}
}
use of org.eclipse.scout.rt.client.IClientSession in project scout.rt by eclipse.
the class BookmarkService method getServiceState.
private ServiceState getServiceState() {
IClientSession session = ClientSessionProvider.currentSession();
if (session == null) {
throw new IllegalStateException("null client session in current job context");
}
ServiceState data = (ServiceState) session.getData(SESSION_DATA_KEY);
if (data == null) {
data = new ServiceState();
data.m_model = new BookmarkData();
session.setData(SESSION_DATA_KEY, data);
}
return data;
}
use of org.eclipse.scout.rt.client.IClientSession in project scout.rt by eclipse.
the class SharedContextNotificationHandler method handleNotification.
@Override
public void handleNotification(SharedContextChangedNotification notification) {
// the client session must be available for shared context variable updates otherwise it is a wrong usage of the notification.
IClientSession session = (IClientSession) Assertions.assertNotNull(IClientSession.CURRENT.get());
session.replaceSharedVariableMapInternal(notification.getSharedVariableMap());
}
use of org.eclipse.scout.rt.client.IClientSession in project scout.rt by eclipse.
the class PageDataExtensionTest method before.
@Before
public void before() {
final IClientSession session = Mockito.mock(IClientSession.class);
System.setProperty("user.area", "${user.home}/test");
Mockito.when(session.getUserId()).thenReturn("userid");
Mockito.when(session.getUserAgent()).thenReturn(UserAgents.createDefault());
ISession.CURRENT.set(session);
}
Aggregations