@Override public void writeObject(ObjectOutput output, T object) throws IOException { this.externalizer.writeObject(output, object); }
@Override public void writeExternal(Object subject, ObjectOutput output) throws IOException { this.externalizer.writeObject(output, subject); }
@Override public void writeObject(ObjectOutput output, Object object) throws IOException { this.externalizer.writeObject(output, object); }
@Override public void writeObject(ObjectOutput output, HashableMarshalledValue<T> object) throws IOException { this.externalizer.writeObject(output, object); output.writeInt(object.hashCode()); }
@Override public void writeObject(Marshaller marshaller, Object object) throws IOException { this.serializer.writeInt(marshaller, this.index); this.externalizer.writeObject(marshaller, object); } }
@Override public void writeObject(ObjectOutput output, URL url) throws IOException { try { DefaultExternalizer.URI.cast(URI.class).writeObject(output, url.toURI()); } catch (URISyntaxException e) { throw new IOException(e); } }
@Override public void writeObject(ObjectOutput output, InfinispanBeanGroupEntry<I, T> entry) throws IOException { SimpleMarshalledValue<Map<I, T>> value = (SimpleMarshalledValue<Map<I, T>>) entry.getBeans(); this.externalizer.writeObject(output, value); }
@Override public void writeObject(ObjectOutput output, LocalDateTime dateTime) throws IOException { DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).writeObject(output, dateTime.toLocalDate()); DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).writeObject(output, dateTime.toLocalTime()); }
@Override public void writeObject(ObjectOutput output, YearMonth value) throws IOException { output.writeInt(value.getYear()); DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, value.getMonth()); }
@Override public void writeObject(ObjectOutput output, SessionCreationMetaDataEntry<Object> entry) throws IOException { SessionCreationMetaData metaData = entry.getMetaData(); DefaultExternalizer.INSTANT.cast(Instant.class).writeObject(output, metaData.getCreationTime()); IndexSerializer.VARIABLE.writeInt(output, (int) metaData.getMaxInactiveInterval().getSeconds()); }
@Override public void writeObject(ObjectOutput output, MonthDay monthDay) throws IOException { DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, monthDay.getMonth()); IndexSerializer.UNSIGNED_BYTE.writeInt(output, monthDay.getDayOfMonth()); }
@Override public void writeObject(ObjectOutput output, SessionAttributeKey key) throws IOException { SessionIdentifierSerializer.INSTANCE.write(output, key.getValue()); DefaultExternalizer.UUID.cast(UUID.class).writeObject(output, key.getAttributeId()); }
public void test(T subject) throws IOException, ClassNotFoundException { assertTrue(this.externalizer.getTargetClass().isInstance(subject)); ByteArrayOutputStream externalizedOutput = new ByteArrayOutputStream(); try (ObjectOutputStream output = new ObjectOutputStream(externalizedOutput)) { this.externalizer.writeObject(output, subject); } byte[] externalizedBytes = externalizedOutput.toByteArray(); try (ObjectInputStream input = new ObjectInputStream(new ByteArrayInputStream(externalizedBytes))) { T result = this.externalizer.readObject(input); assertTrue(this.externalizer.getTargetClass().isInstance(result)); this.assertion.accept(subject, result); } // If object is serializable, make sure we've actually improved upon default serialization size if (subject instanceof java.io.Serializable) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try (ObjectOutputStream output = new ObjectOutputStream(out)) { output.writeObject(subject); } byte[] bytes = out.toByteArray(); Assert.assertTrue(externalizedBytes.length < bytes.length); } } }
@Override public void writeObject(ObjectOutput output, Object object) throws IOException { this.externalizer.writeObject(output, object); }
@Override public void writeObject(ObjectOutput output, InfinispanBeanGroupEntry<I, T> entry) throws IOException { SimpleMarshalledValue<Map<I, T>> value = (SimpleMarshalledValue<Map<I, T>>) entry.getBeans(); this.externalizer.writeObject(output, value); }
@Override public void writeObject(Marshaller marshaller, Object object) throws IOException { this.serializer.writeInt(marshaller, this.index); this.externalizer.writeObject(marshaller, object); } }
@Override public void writeObject(ObjectOutput output, URL url) throws IOException { try { DefaultExternalizer.URI.cast(URI.class).writeObject(output, url.toURI()); } catch (URISyntaxException e) { throw new IOException(e); } }
@Override public void writeObject(ObjectOutput output, LocalDateTime dateTime) throws IOException { DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).writeObject(output, dateTime.toLocalDate()); DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).writeObject(output, dateTime.toLocalTime()); }
@Override public void writeObject(ObjectOutput output, MonthDay monthDay) throws IOException { DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, monthDay.getMonth()); IndexSerializer.UNSIGNED_BYTE.writeInt(output, monthDay.getDayOfMonth()); }
@Override public void writeObject(ObjectOutput output, MonthDay monthDay) throws IOException { DefaultExternalizer.MONTH.cast(Month.class).writeObject(output, monthDay.getMonth()); IndexSerializer.UNSIGNED_BYTE.writeInt(output, monthDay.getDayOfMonth()); }