@Override public Object createExternal(Class<?> subjectType, ObjectInput input) throws IOException, ClassNotFoundException { return this.externalizer.readObject(input); } }
@Override public T readObject(ObjectInput input) throws IOException, ClassNotFoundException { return this.externalizer.readObject(input); }
@Override public Object readObject(ObjectInput input) throws IOException, ClassNotFoundException { return this.externalizer.readObject(input); }
@Override public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException { int index = this.indexSerializer.readInt(unmarshaller); if (index >= this.externalizers.size()) { throw new IllegalStateException(); } return this.externalizers.get(index).readObject(unmarshaller); }
@Override public LocalDateTime readObject(ObjectInput input) throws IOException, ClassNotFoundException { LocalDate date = DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).readObject(input); LocalTime time = DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).readObject(input); return LocalDateTime.of(date, time); }
@Override public URL readObject(ObjectInput input) throws IOException, ClassNotFoundException { return DefaultExternalizer.URI.cast(URI.class).readObject(input).toURL(); }
@Override public InfinispanBeanGroupEntry<I, T> readObject(ObjectInput input) throws IOException, ClassNotFoundException { return new InfinispanBeanGroupEntry<>(this.externalizer.readObject(input)); }
@Override public InetSocketAddress readObject(ObjectInput input) throws IOException, ClassNotFoundException { InetAddress address = DefaultExternalizer.INET_ADDRESS.cast(InetAddress.class).readObject(input); int port = IndexSerializer.UNSIGNED_SHORT.readInt(input); return (address != null) ? new InetSocketAddress(address, port) : InetSocketAddress.createUnresolved(input.readUTF(), port); }
@Override public YearMonth readObject(ObjectInput input) throws IOException, ClassNotFoundException { int year = input.readInt(); Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); return YearMonth.of(year, month); }
@Override public HashableMarshalledValue<T> readObject(ObjectInput input) throws IOException, ClassNotFoundException { SimpleMarshalledValue<T> value = this.externalizer.readObject(input); int hashCode = input.readInt(); return new HashableMarshalledValue<>(value.getBytes(), hashCode); }
@Override public SessionAttributeKey readObject(ObjectInput input) throws IOException, ClassNotFoundException { String sessionId = SessionIdentifierSerializer.INSTANCE.read(input); UUID attributeId = DefaultExternalizer.UUID.cast(UUID.class).readObject(input); return new SessionAttributeKey(sessionId, attributeId); }
@Override public MonthDay readObject(ObjectInput input) throws IOException, ClassNotFoundException { Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); int day = IndexSerializer.UNSIGNED_BYTE.readInt(input); return MonthDay.of(month, day); }
@Override public SessionCreationMetaDataEntry<Object> readObject(ObjectInput input) throws IOException, ClassNotFoundException { SessionCreationMetaData metaData = new SimpleSessionCreationMetaData(DefaultExternalizer.INSTANT.cast(Instant.class).readObject(input)); metaData.setMaxInactiveInterval(Duration.ofSeconds(IndexSerializer.VARIABLE.readInt(input))); return new SessionCreationMetaDataEntry<>(metaData); }
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 Object createExternal(Class<?> subjectType, ObjectInput input) throws IOException, ClassNotFoundException { return this.externalizer.readObject(input); } }
@Override public LocalDateTime readObject(ObjectInput input) throws IOException, ClassNotFoundException { LocalDate date = DefaultExternalizer.LOCAL_DATE.cast(LocalDate.class).readObject(input); LocalTime time = DefaultExternalizer.LOCAL_TIME.cast(LocalTime.class).readObject(input); return LocalDateTime.of(date, time); }
@Override public InetSocketAddress readObject(ObjectInput input) throws IOException, ClassNotFoundException { InetAddress address = DefaultExternalizer.INET_ADDRESS.cast(InetAddress.class).readObject(input); int port = IndexSerializer.UNSIGNED_SHORT.readInt(input); return (address != null) ? new InetSocketAddress(address, port) : InetSocketAddress.createUnresolved(input.readUTF(), port); }
@Override public YearMonth readObject(ObjectInput input) throws IOException, ClassNotFoundException { int year = input.readInt(); Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); return YearMonth.of(year, month); }
@Override public HashableMarshalledValue<T> readObject(ObjectInput input) throws IOException, ClassNotFoundException { SimpleMarshalledValue<T> value = this.externalizer.readObject(input); int hashCode = input.readInt(); return new HashableMarshalledValue<>(value.getBytes(), hashCode); }
@Override public MonthDay readObject(ObjectInput input) throws IOException, ClassNotFoundException { Month month = DefaultExternalizer.MONTH.cast(Month.class).readObject(input); int day = IndexSerializer.UNSIGNED_BYTE.readInt(input); return MonthDay.of(month, day); }