@Override
  public void handleRequest(HttpServerExchange exchange) throws Exception {
    final String incomingSessionId = servletContext.getSessionConfig().findSessionId(exchange);
    if (incomingSessionId == null || !data.containsKey(incomingSessionId)) {
      next.handleRequest(exchange);
      return;
    }

    // we have some old data
    PersistentSession result = data.remove(incomingSessionId);
    if (result != null) {
      long time = System.currentTimeMillis();
      if (time < result.getExpiration().getTime()) {
        final HttpSessionImpl session = servletContext.getSession(exchange, true);
        final HttpSessionEvent event = new HttpSessionEvent(session);
        for (Map.Entry<String, Object> entry : result.getSessionData().entrySet()) {

          if (entry.getValue() instanceof HttpSessionActivationListener) {
            ((HttpSessionActivationListener) entry.getValue()).sessionDidActivate(event);
          }
          if (entry.getKey().startsWith(HttpSessionImpl.IO_UNDERTOW)) {
            session.getSession().setAttribute(entry.getKey(), entry.getValue());
          } else {
            session.setAttribute(entry.getKey(), entry.getValue());
          }
        }
      }
    }
    next.handleRequest(exchange);
  }
Пример #2
0
 public static BRADYSET getBRADYSETByORMID(PersistentSession session, int ID) {
   try {
     return (BRADYSET) session.get(tr.com.srdc.icardea.hibernate.BRADYSET.class, new Integer(ID));
   } catch (Exception e) {
     _logger.error("getBRADYSETByORMID(PersistentSession session, int ID)", e);
     return null;
   }
 }
Пример #3
0
 public static Medication getMedicationByORMID(PersistentSession session, int ID) {
   try {
     return (Medication)
         session.get(tr.com.srdc.icardea.hibernate.Medication.class, new Integer(ID));
   } catch (Exception e) {
     _logger.error("getMedicationByORMID(PersistentSession session, int ID)", e);
     return null;
   }
 }
Пример #4
0
 public static Medication loadMedicationByORMID(
     PersistentSession session, int ID, org.hibernate.LockMode lockMode) {
   try {
     return (Medication)
         session.load(tr.com.srdc.icardea.hibernate.Medication.class, new Integer(ID), lockMode);
   } catch (Exception e) {
     _logger.error(
         "loadMedicationByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)",
         e);
     return null;
   }
 }
Пример #5
0
 public static java.util.Iterator iterateBRADYSETByQuery(
     PersistentSession session, String condition, String orderBy) {
   StringBuffer sb = new StringBuffer("From tr.com.srdc.icardea.hibernate.BRADYSET as BRADYSET");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     return query.iterate();
   } catch (Exception e) {
     _logger.error(
         "iterateBRADYSETByQuery(PersistentSession session, String condition, String orderBy)", e);
     return null;
   }
 }
Пример #6
0
 public static BRADYSET[] listBRADYSETByQuery(
     PersistentSession session, String condition, String orderBy) {
   StringBuffer sb = new StringBuffer("From tr.com.srdc.icardea.hibernate.BRADYSET as BRADYSET");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     List list = query.list();
     return (BRADYSET[]) list.toArray(new BRADYSET[list.size()]);
   } catch (Exception e) {
     _logger.error(
         "listBRADYSETByQuery(PersistentSession session, String condition, String orderBy)", e);
     return null;
   }
 }
Пример #7
0
 /**
  * @param session
  * @param condition
  * @param orderBy
  * @return
  * @throws PersistentException
  */
 public CommentTask[] listCommentTaskByQuery(
     PersistentSession session, String condition, String orderBy) throws PersistentException {
   StringBuffer sb = new StringBuffer("From de.fhb.jproject.data.CommentTask as CommentTask");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     List list = query.list();
     return (CommentTask[]) list.toArray(new CommentTask[list.size()]);
   } catch (Exception e) {
     _logger.error(
         "listCommentTaskByQuery(PersistentSession session, String condition, String orderBy)", e);
     throw new PersistentException(e);
   }
 }
Пример #8
0
 /**
  * @param session
  * @param condition
  * @param orderBy
  * @return
  * @throws PersistentException
  */
 public static java.util.Iterator iterateCommentTaskByQuery(
     PersistentSession session, String condition, String orderBy) throws PersistentException {
   StringBuffer sb = new StringBuffer("From de.fhb.jproject.data.CommentTask as CommentTask");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     return query.iterate();
   } catch (Exception e) {
     _logger.error(
         "iterateCommentTaskByQuery(PersistentSession session, String condition, String orderBy)",
         e);
     throw new PersistentException(e);
   }
 }
Пример #9
0
 public static java.util.Iterator iterateMedicationByQuery(
     PersistentSession session,
     String condition,
     String orderBy,
     org.hibernate.LockMode lockMode) {
   StringBuffer sb =
       new StringBuffer("From tr.com.srdc.icardea.hibernate.Medication as Medication");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     query.setLockMode("this", lockMode);
     return query.iterate();
   } catch (Exception e) {
     _logger.error(
         "iterateMedicationByQuery(PersistentSession session, String condition, String orderBy)",
         e);
     return null;
   }
 }
Пример #10
0
 public static Medication[] listMedicationByQuery(
     PersistentSession session,
     String condition,
     String orderBy,
     org.hibernate.LockMode lockMode) {
   StringBuffer sb =
       new StringBuffer("From tr.com.srdc.icardea.hibernate.Medication as Medication");
   if (condition != null) sb.append(" Where ").append(condition);
   if (orderBy != null) sb.append(" Order By ").append(orderBy);
   try {
     Query query = session.createQuery(sb.toString());
     query.setLockMode("this", lockMode);
     List list = query.list();
     return (Medication[]) list.toArray(new Medication[list.size()]);
   } catch (Exception e) {
     _logger.error(
         "listMedicationByQuery(PersistentSession session, String condition, String orderBy)", e);
     return null;
   }
 }