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

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

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

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

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

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

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

    .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")))));
org.springframework.core.serializer.supportSerializingConverterconvert

Javadoc

Serializes the source object and returns the byte array result.

Popular methods of SerializingConverter

  • <init>
    Create a SerializingConverter that delegates to the provided Serializer.

Popular in Java

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • onCreateOptionsMenu (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Runner (org.openjdk.jmh.runner)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • 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