Java Code Examples for org.ehcache.impl.serialization.CharSerializer

Following code examples demonstrate how to use org.ehcache.impl.serialization.CharSerializerfrom ehcache. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.ehcache.impl.serialization.CharSerializerand various code implementation of this class.

  public void start(ServiceProvider<Service> serviceProvider) {
    addDefaultSerializerIfNoneRegistered(serializers, Serializable.class, CompactJavaSerializer.<Serializable>asTypedSerializer());
    addDefaultSerializerIfNoneRegistered(serializers, Long.class, LongSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, Integer.class, IntegerSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, Float.class, FloatSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, Double.class, DoubleSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, Character.class, CharSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, String.class, StringSerializer.class);
    addDefaultSerializerIfNoneRegistered(serializers, byte[].class, ByteArraySerializer.class);
  } 


  public void testDefaultCharSerializer() throws Exception {
    DefaultSerializationProvider provider = getStartedProvider();
    Serializer<Character> keySerializer = provider.createKeySerializer(Character.class, getSystemClassLoader());
    assertThat(keySerializer, instanceOf(CharSerializer.class));

    keySerializer = provider.createKeySerializer(Character.class, getSystemClassLoader(), getPersistenceSpaceIdentifierMock());
    assertThat(keySerializer, instanceOf(CharSerializer.class));
  } 

Advertisement
Javadoc
Default Serializer for Char type. Simply writes the char value to a byte buffer.
Advertisement