/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
private String serialize(final Serializable serializable) { if (serializable == null) { return null; } ByteArrayOutputStream out = new ByteArrayOutputStream(); try { final Marshaller marshaller = factory.createMarshaller(configuration); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(serializable); marshaller.finish(); out.flush(); } catch (IOException e) { throw new RuntimeException(e); } return Base64.getEncoder().encodeToString(out.toByteArray()); }
@Override public void persistSessions(String deploymentName, Map<String, PersistentSession> sessionData) { try { final Marshaller marshaller = createMarshaller(); try { final Map<String, SessionEntry> serializedData = new HashMap<String, SessionEntry>(); for (Map.Entry<String, PersistentSession> sessionEntry : sessionData.entrySet()) { Map<String, byte[]> data = new HashMap<String, byte[]>(); for (Map.Entry<String, Object> sessionAttribute : sessionEntry.getValue().getSessionData().entrySet()) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(sessionAttribute.getValue()); marshaller.finish(); data.put(sessionAttribute.getKey(), out.toByteArray()); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.failedToPersistSessionAttribute(sessionAttribute.getKey(), sessionAttribute.getValue(), sessionEntry.getKey(), e); } } serializedData.put(sessionEntry.getKey(), new SessionEntry(sessionEntry.getValue().getExpiration(), data)); } persistSerializedSessions(deploymentName, serializedData); } finally { marshaller.close(); } } catch (Exception e) { UndertowServletLogger.ROOT_LOGGER.failedToPersistSessions(e); } }
@Override protected void persistSerializedSessions(String deploymentName, Map<String, SessionEntry> serializedData) throws IOException { File file = new File(baseDir, deploymentName); FileOutputStream out = new FileOutputStream(file, false); try { Marshaller marshaller = createMarshaller(); try { marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(serializedData); marshaller.finish(); } finally { marshaller.close(); } } finally { IoUtils.safeClose(out); } }
final Marshaller marshaller = factory.createMarshaller(configuration); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(stream)); marshaller.writeObject(((StatefulEJBLocator<?>) locator).getSessionId()); marshaller.finish(); final Marshaller marshaller = factory.createMarshaller(configuration); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(stream)); marshaller.writeObject(((EntityEJBLocator<?>) locator).getPrimaryKey()); marshaller.finish();
Marshaller marshaller = factory.createMarshaller(configuration); ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(timer.getInfo()); marshaller.finish(); Marshaller marshaller = factory.createMarshaller(configuration); ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(timer.getPrimaryKey()); marshaller.finish();
Marshaller marshaller = factory.createMarshaller(configuration); ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(timer.getInfo()); marshaller.finish(); Marshaller marshaller = factory.createMarshaller(configuration); ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(timer.getPrimaryKey()); marshaller.finish();
/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
/** * Create a {@code ByteOutput} wrapper for an {@code OutputStream}. * * @param outputStream the output stream * @return the byte output wrapper */ public static ByteOutput createByteOutput(final OutputStream outputStream) { return outputStream instanceof ByteOutput ? (ByteOutput) outputStream : new OutputStreamByteOutput(outputStream); }
@Override public void persistSessions(String deploymentName, Map<String, PersistentSession> sessionData) { try { final Marshaller marshaller = createMarshaller(); try { final Map<String, SessionEntry> serializedData = new HashMap<String, SessionEntry>(); for (Map.Entry<String, PersistentSession> sessionEntry : sessionData.entrySet()) { Map<String, byte[]> data = new HashMap<String, byte[]>(); for (Map.Entry<String, Object> sessionAttribute : sessionEntry.getValue().getSessionData().entrySet()) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(sessionAttribute.getValue()); marshaller.finish(); data.put(sessionAttribute.getKey(), out.toByteArray()); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.failedToPersistSessionAttribute(sessionAttribute.getKey(), sessionAttribute.getValue(), sessionEntry.getKey(), e); } } serializedData.put(sessionEntry.getKey(), new SessionEntry(sessionEntry.getValue().getExpiration(), data)); } persistSerializedSessions(deploymentName, serializedData); } finally { marshaller.close(); } } catch (Exception e) { UndertowServletLogger.ROOT_LOGGER.failedToPersistSessions(e); } }
@Override public void persistSessions(String deploymentName, Map<String, PersistentSession> sessionData) { try { final Marshaller marshaller = createMarshaller(); try { final Map<String, SessionEntry> serializedData = new HashMap<String, SessionEntry>(); for (Map.Entry<String, PersistentSession> sessionEntry : sessionData.entrySet()) { Map<String, byte[]> data = new HashMap<String, byte[]>(); for (Map.Entry<String, Object> sessionAttribute : sessionEntry.getValue().getSessionData().entrySet()) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(sessionAttribute.getValue()); marshaller.finish(); data.put(sessionAttribute.getKey(), out.toByteArray()); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.failedToPersistSessionAttribute(sessionAttribute.getKey(), sessionAttribute.getValue(), sessionEntry.getKey(), e); } } serializedData.put(sessionEntry.getKey(), new SessionEntry(sessionEntry.getValue().getExpiration(), data)); } persistSerializedSessions(deploymentName, serializedData); } finally { marshaller.close(); } } catch (Exception e) { UndertowServletLogger.ROOT_LOGGER.failedToPersistSessions(e); } }
@Override protected void persistSerializedSessions(String deploymentName, Map<String, SessionEntry> serializedData) throws IOException { File file = new File(baseDir, deploymentName); FileOutputStream out = new FileOutputStream(file, false); try { Marshaller marshaller = createMarshaller(); try { marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(serializedData); marshaller.finish(); } finally { marshaller.close(); } } finally { IoUtils.safeClose(out); } }
fileOutputStream = new FileOutputStream(file, false); final Marshaller marshaller = factory.createMarshaller(configuration); marshaller.start(new OutputStreamByteOutput(fileOutputStream)); marshaller.writeObject(entity); marshaller.finish();
@Override protected void persistSerializedSessions(String deploymentName, Map<String, SessionEntry> serializedData) throws IOException { File file = new File(baseDir, deploymentName); FileOutputStream out = new FileOutputStream(file, false); try { Marshaller marshaller = createMarshaller(); try { marshaller.start(new OutputStreamByteOutput(out)); marshaller.writeObject(serializedData); marshaller.finish(); } finally { marshaller.close(); } } finally { IoUtils.safeClose(out); } }
final Marshaller marshaller = factory.createMarshaller(configuration); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(stream)); marshaller.writeObject(((StatefulEJBLocator) locator).getSessionId()); marshaller.finish(); final Marshaller marshaller = factory.createMarshaller(configuration); final ByteArrayOutputStream stream = new ByteArrayOutputStream(); marshaller.start(new OutputStreamByteOutput(stream)); marshaller.writeObject(((EntityEJBLocator) locator).getPrimaryKey()); marshaller.finish();