Tabnine Logo
org.springframework.core.serializer.support
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.core.serializer.support

Best Java code snippets using org.springframework.core.serializer.support (Showing top 20 results out of 315)

origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link JdkSerializationRedisSerializer} using the default class loader.
 */
public JdkSerializationRedisSerializer() {
  this(new SerializingConverter(), new DeserializingConverter());
}
origin: spring-projects/spring-framework

private Object deserializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
  ByteArrayInputStream in = new ByteArrayInputStream((byte[]) storeValue);
  try {
    return serialization.deserialize(in);
  }
  finally {
    in.close();
  }
}
origin: spring-projects/spring-framework

private Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try {
    serialization.serialize(storeValue, out);
    return out.toByteArray();
  }
  finally {
    out.close();
  }
}
origin: spring-projects/spring-framework

@Test
public void serializeAndDeserializeString() {
  SerializingConverter toBytes = new SerializingConverter();
  byte[] bytes = toBytes.convert("Testing");
  DeserializingConverter fromBytes = new DeserializingConverter();
  assertEquals("Testing", fromBytes.convert(bytes));
}
origin: spring-projects/spring-framework

@Test
public void nonSerializableObject() {
  SerializingConverter toBytes = new SerializingConverter();
  try {
    toBytes.convert(new Object());
    fail("Expected IllegalArgumentException");
  }
  catch (SerializationFailedException e) {
    assertNotNull(e.getCause());
    assertTrue(e.getCause() instanceof IllegalArgumentException);
  }
}
origin: spring-projects/spring-integration

/**
 * A converter for serializing messages to byte arrays for storage.
 *
 * @param serializer the serializer to set
 */
@SuppressWarnings("unchecked")
public void setSerializer(Serializer<? super Message<?>> serializer) {
  this.serializer = new SerializingConverter((Serializer<Object>) serializer);
}
origin: spring-projects/spring-framework

@Override
public Object convert(byte[] source) {
  ByteArrayInputStream byteStream = new ByteArrayInputStream(source);
  try {
    return this.deserializer.deserialize(byteStream);
  }
  catch (Throwable ex) {
    throw new SerializationFailedException("Failed to deserialize payload. " +
        "Is the byte array a result of corresponding serialization for " +
        this.deserializer.getClass().getSimpleName() + "?", ex);
  }
}
origin: spring-projects/spring-framework

@Test(expected = SerializationFailedException.class)
public void deserializationFailure() {
  DeserializingConverter fromBytes = new DeserializingConverter();
  fromBytes.convert("Junk".getBytes());
}
origin: spring-projects/spring-framework

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
  this.serialization = new SerializationDelegate(classLoader);
  // Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
  if (isStoreByValue()) {
    recreateCaches();
  }
}
origin: spring-projects/spring-data-redis

/**
 * Creates a new {@link JdkSerializationRedisSerializer} using a {@link ClassLoader}.
 *
 * @param classLoader the {@link ClassLoader} to use for deserialization. Can be {@literal null}.
 * @since 1.7
 */
public JdkSerializationRedisSerializer(@Nullable ClassLoader classLoader) {
  this(new SerializingConverter(), new DeserializingConverter(classLoader));
}
origin: spring-projects/spring-framework

@Test
public void nonSerializableField() {
  SerializingConverter toBytes = new SerializingConverter();
  try {
    toBytes.convert(new UnSerializable());
    fail("Expected SerializationFailureException");
  }
  catch (SerializationFailedException e) {
    assertNotNull(e.getCause());
    assertTrue(e.getCause() instanceof NotSerializableException);
  }
}
origin: spring-projects/spring-framework

/**
 * Serializes the source object and returns the byte array result.
 */
@Override
public byte[] convert(Object source) {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024);
  try  {
    this.serializer.serialize(source, byteStream);
    return byteStream.toByteArray();
  }
  catch (Throwable ex) {
    throw new SerializationFailedException("Failed to serialize object using " +
        this.serializer.getClass().getSimpleName(), ex);
  }
}
origin: spring-projects/spring-framework

private ConcurrentMapCache createCacheWithStoreByValue() {
  return new ConcurrentMapCache(CACHE_NAME, this.nativeCache, true,
      new SerializationDelegate(ConcurrentMapCacheTests.class.getClassLoader()));
}
origin: org.springframework/spring-context

private Object serializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try {
    serialization.serialize(storeValue, out);
    return out.toByteArray();
  }
  finally {
    out.close();
  }
}
origin: org.springframework/spring-context

private Object deserializeValue(SerializationDelegate serialization, Object storeValue) throws IOException {
  ByteArrayInputStream in = new ByteArrayInputStream((byte[]) storeValue);
  try {
    return serialization.deserialize(in);
  }
  finally {
    in.close();
  }
}
origin: spring-projects/spring-session

private static GenericConversionService createDefaultConversionService() {
  GenericConversionService converter = new GenericConversionService();
  converter.addConverter(Object.class, byte[].class,
      new SerializingConverter());
  converter.addConverter(byte[].class, Object.class,
      new DeserializingConverter());
  return converter;
}
origin: org.springframework/spring-core

@Override
public Object convert(byte[] source) {
  ByteArrayInputStream byteStream = new ByteArrayInputStream(source);
  try {
    return this.deserializer.deserialize(byteStream);
  }
  catch (Throwable ex) {
    throw new SerializationFailedException("Failed to deserialize payload. " +
        "Is the byte array a result of corresponding serialization for " +
        this.deserializer.getClass().getSimpleName() + "?", ex);
  }
}
origin: org.springframework/spring-context

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
  this.serialization = new SerializationDelegate(classLoader);
  // Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
  if (isStoreByValue()) {
    recreateCaches();
  }
}
origin: spring-projects/spring-session

private GenericConversionService createConversionServiceWithBeanClassLoader() {
  GenericConversionService conversionService = new GenericConversionService();
  conversionService.addConverter(Object.class, byte[].class,
      new SerializingConverter());
  conversionService.addConverter(byte[].class, Object.class,
      new DeserializingConverter(this.classLoader));
  return conversionService;
}
origin: org.springframework/spring-core

/**
 * Serializes the source object and returns the byte array result.
 */
@Override
public byte[] convert(Object source) {
  ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024);
  try  {
    this.serializer.serialize(source, byteStream);
    return byteStream.toByteArray();
  }
  catch (Throwable ex) {
    throw new SerializationFailedException("Failed to serialize object using " +
        this.serializer.getClass().getSimpleName(), ex);
  }
}
org.springframework.core.serializer.support

Most used classes

  • SerializingConverter
    A Converter that delegates to a org.springframework.core.serializer.Serializerto convert an object t
  • SerializationFailedException
    Wrapper for the native IOException (or similar) when a org.springframework.core.serializer.Serialize
  • DeserializingConverter
    A Converter that delegates to a org.springframework.core.serializer.Deserializerto convert data in a
  • SerializationDelegate
    A convenient delegate with pre-arranged configuration state for common serialization needs. Implemen
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now