(Session session)
| 482 | } |
| 483 | |
| 484 | @Override |
| 485 | public void save(Session session) throws IOException { |
| 486 | String saveSql = "INSERT INTO " + sessionTable + " (" + sessionIdCol + ", " + sessionAppCol + ", " + |
| 487 | sessionDataCol + ", " + sessionValidCol + ", " + sessionMaxInactiveCol + ", " + sessionLastAccessedCol + |
| 488 | ") VALUES (?, ?, ?, ?, ?, ?)"; |
| 489 | |
| 490 | synchronized (session) { |
| 491 | |
| 492 | // First serialize session |
| 493 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| 494 | try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(bos))) { |
| 495 | ((StandardSession) session).writeObjectData(oos); |
| 496 | } |
| 497 | byte[] obs = bos.toByteArray(); |
| 498 | |
| 499 | withRetry(conn -> { |
| 500 | // Remove session if it exists and insert again. |
| 501 | remove(session.getIdInternal(), conn); |
| 502 | |
| 503 | int size = obs.length; |
| 504 | try (ByteArrayInputStream bis = new ByteArrayInputStream(obs, 0, size); |
| 505 | InputStream in = new BufferedInputStream(bis, size); |
| 506 | PreparedStatement preparedSaveSql = conn.prepareStatement(saveSql)) { |
| 507 | preparedSaveSql.setString(1, session.getIdInternal()); |
| 508 | preparedSaveSql.setString(2, getName()); |
| 509 | preparedSaveSql.setBinaryStream(3, in, size); |
| 510 | preparedSaveSql.setString(4, session.isValid() ? "1" : "0"); |
| 511 | preparedSaveSql.setInt(5, session.getMaxInactiveInterval()); |
| 512 | preparedSaveSql.setLong(6, session.getLastAccessedTime()); |
| 513 | preparedSaveSql.execute(); |
| 514 | } |
| 515 | return null; |
| 516 | }); |
| 517 | } |
| 518 | |
| 519 | if (manager.getContext().getLogger().isTraceEnabled()) { |
| 520 | manager.getContext().getLogger() |
| 521 | .trace(sm.getString("dataSourceStore.saving", session.getIdInternal(), sessionTable)); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | |
| 526 | // --------------------------------------------------------- Protected Methods |
nothing calls this directly
no test coverage detected