org.hibernate.cache.infinispan.util.Externalizers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-infinispan
Show all versions of hibernate-infinispan
A module of the Hibernate Core project
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.cache.infinispan.util;
import org.infinispan.commons.marshall.AdvancedExternalizer;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
/**
* @author Radim Vansa <[email protected]>
*/
public class Externalizers {
public final static int UUID = 1200;
public final static int TOMBSTONE = 1201;
public final static int EXCLUDE_TOMBSTONES_FILTER = 1202;
public final static int TOMBSTONE_UPDATE = 1203;
public final static int FUTURE_UPDATE = 1204;
public final static int VALUE_EXTRACTOR = 1205;
public final static int VERSIONED_ENTRY = 1206;
public final static int EXCLUDE_EMPTY_EXTRACT_VALUE = 1207;
public final static AdvancedExternalizer[] ALL_EXTERNALIZERS = new AdvancedExternalizer[] {
new UUIDExternalizer(),
new Tombstone.Externalizer(),
new Tombstone.ExcludeTombstonesFilterExternalizer(),
new TombstoneUpdate.Externalizer(),
new FutureUpdate.Externalizer(),
new FutureUpdate.ValueExtractorExternalizer(),
new VersionedEntry.Externalizer(),
new VersionedEntry.ExcludeEmptyExtractValueExternalizer()
};
public static class UUIDExternalizer implements AdvancedExternalizer {
@Override
public Set> getTypeClasses() {
return Collections.>singleton(UUID.class);
}
@Override
public Integer getId() {
return UUID;
}
@Override
public void writeObject(ObjectOutput output, UUID uuid) throws IOException {
output.writeLong(uuid.getMostSignificantBits());
output.writeLong(uuid.getLeastSignificantBits());
}
@Override
public UUID readObject(ObjectInput input) throws IOException, ClassNotFoundException {
return new UUID(input.readLong(), input.readLong());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy