public void notifySessionDeletion(ISession session) throws ThinklabException {

    Collection<IThinklabSessionListener> listeners = session.getListeners();

    if (listeners != null)
      for (IThinklabSessionListener listener : listeners) listener.sessionDeleted(session);

    sessionManager.notifySessionDeletion(session);
  }
  /**
   * Request a user session to put stuff into. You can later make the session permanent by adding it
   * to the knowledge base. Note that all operations on sessions are typically synchronized.
   */
  public ISession requestNewSession() throws ThinklabException {

    ISession session = sessionManager.createNewSession();

    for (Class<?> lcl : sessionListeners.values()) {

      IThinklabSessionListener listener = null;

      try {
        listener = (IThinklabSessionListener) lcl.newInstance();
      } catch (Exception e) {
        throw new ThinklabMissingResourceException(
            "cannot create requested session listener: " + lcl + ": error during creation");
      }
      listener.sessionCreated(session);
      session.addListener(listener);
    }

    return session;
  }