Tabnine Logo
SerializingConverter
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using org.springframework.core.serializer.support.SerializingConverter (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

@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-integration

@Override
@SuppressWarnings("unchecked")
public <T> Message<T> addMessage(final Message<T> message) {
  UUID id = message.getHeaders().getId();
  Assert.notNull(id, "Cannot store messages without an ID header");
  final String messageId = getKey(id);
  final byte[] messageBytes = this.serializer.convert(message);
  if (logger.isDebugEnabled()) {
    logger.debug("Inserting message with id key=" + messageId);
  }
  try {
    this.jdbcTemplate.update(getQuery(Query.CREATE_MESSAGE), ps -> {
      ps.setString(1, messageId);
      ps.setString(2, this.region);
      ps.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
      this.lobHandler.getLobCreator().setBlobAsBytes(ps, 4, messageBytes);
    });
  }
  catch (DuplicateKeyException e) {
    if (logger.isDebugEnabled()) {
      logger.debug("The Message with id [" + id + "] already exists.\n" +
          "Ignoring INSERT and SELECT existing...");
    }
    return (Message<T>) getMessage(id);
  }
  return message;
}
origin: spring-projects/spring-integration

byte[] messageBytes = this.serializer.convert(requestMessage);
this.lobHandler.getLobCreator().setBlobAsBytes(preparedStatement, 6, messageBytes);
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 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

@Override
public void setValues(PreparedStatement preparedStatement, Message<?> requestMessage, Object groupId,
    String region, boolean priorityEnabled) throws SQLException {
  super.setValues(preparedStatement, requestMessage, groupId, region, priorityEnabled);
  byte[] messageBytes = this.serializer.convert(requestMessage);
  this.lobHandler.getLobCreator().setBlobAsBytes(preparedStatement, 6, messageBytes);
}
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: 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-integration-aws

@Override
public byte[] convert(Object source) {
  if (source instanceof String) {
    return ((String) source).getBytes();
  }
  else {
    return this.serializingConverter.convert(source);
  }
}
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: spring-projects/spring-integration-aws

    .willThrow(new ExpiredIteratorException("Iterator expired"));
SerializingConverter serializingConverter = new SerializingConverter();
                .withPartitionKey("partition1")
                .withSequenceNumber("1")
                .withData(ByteBuffer.wrap(serializingConverter.convert("foo"))),
            new Record()
                .withPartitionKey("partition1")
                .withSequenceNumber("2")
                .withData(ByteBuffer.wrap(serializingConverter.convert("bar")))));
            .withPartitionKey("partition1")
            .withSequenceNumber("2")
            .withData(ByteBuffer.wrap(serializingConverter.convert("bar")))));
origin: spring-projects/spring-integration-aws

@Override
public byte[] convert(Object source) {
  if (source instanceof String) {
    return ((String) source).getBytes();
  }
  else {
    return this.serializingConverter.convert(source);
  }
}
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: org.springframework.integration/spring-integration-jdbc

@Override
@SuppressWarnings("unchecked")
public <T> Message<T> addMessage(final Message<T> message) {
  UUID id = message.getHeaders().getId();
  Assert.notNull(id, "Cannot store messages without an ID header");
  final String messageId = getKey(id);
  final byte[] messageBytes = this.serializer.convert(message);
  if (logger.isDebugEnabled()) {
    logger.debug("Inserting message with id key=" + messageId);
  }
  try {
    this.jdbcTemplate.update(getQuery(Query.CREATE_MESSAGE), ps -> {
      ps.setString(1, messageId);
      ps.setString(2, this.region);
      ps.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
      this.lobHandler.getLobCreator().setBlobAsBytes(ps, 4, messageBytes);
    });
  }
  catch (DuplicateKeyException e) {
    if (logger.isDebugEnabled()) {
      logger.debug("The Message with id [" + id + "] already exists.\n" +
          "Ignoring INSERT and SELECT existing...");
    }
    return (Message<T>) getMessage(id);
  }
  return message;
}
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) {
  Assert.notNull(serializer, "The provided serializer must not be null.");
  this.serializer = new SerializingConverter((Serializer<Object>) serializer);
}
origin: org.springframework.integration/spring-integration-jdbc

byte[] messageBytes = this.serializer.convert(requestMessage);
this.lobHandler.getLobCreator().setBlobAsBytes(preparedStatement, 6, messageBytes);
origin: spring-projects/spring-integration

/**
 * Create a {@link MessageStore} with all mandatory properties.
 * @param jdbcOperations a {@link JdbcOperations}
 * @since 4.3.9
 */
public JdbcMessageStore(JdbcOperations jdbcOperations) {
  Assert.notNull(jdbcOperations, "'dataSource' must not be null");
  this.jdbcTemplate = jdbcOperations;
  this.deserializer = new WhiteListDeserializingConverter();
  this.serializer = new SerializingConverter();
}
origin: spring-projects/spring-integration

/**
 * Instantiate based on the {@link SerializingConverter} with the
 * {@link org.springframework.core.serializer.DefaultSerializer}.
 */
public PayloadSerializingTransformer() {
  doSetConverter(new SerializingConverter());
}
origin: spring-projects/spring-integration

/**
 * Convenient constructor for configuration use.
 */
public JdbcChannelMessageStore() {
  this.deserializer = new WhiteListDeserializingConverter();
  this.serializer = new SerializingConverter();
}
org.springframework.core.serializer.supportSerializingConverter

Javadoc

A Converter that delegates to a org.springframework.core.serializer.Serializerto convert an object to a byte array.

Most used methods

  • <init>
    Create a SerializingConverter that delegates to the provided Serializer.
  • convert
    Serializes the source object and returns the byte array result.

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • compareTo (BigDecimal)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • JPanel (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top PhpStorm plugins
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