Spring Framework DeserializingConverter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework DeserializingConverter class.

This code example shows how to use the following methods:convert
 
	@Test
	public void serializeAndDeserializeString() { 
		SerializingConverter toBytes = new SerializingConverter();
		byte[] bytes = toBytes.convert("Testing");
		DeserializingConverter fromBytes = new DeserializingConverter();
		assertEquals("Testing", fromBytes.convert(bytes));
	} 
 
	@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);
		} 
7
CodeRank
This code example shows how to use the following methods:
 * @since 1.0.1 
 */ 
public class PayloadDeserializingTransformer extends PayloadTypeConvertingTransformer<byte[], Object> { 
 
	public void setDeserializer(Deserializer<Object> deserializer) { 
		this.setConverter(new DeserializingConverter(deserializer)); 
	} 
 
	@Override 
	protected Object transformPayload(byte[] payload) throws Exception { 
		if (this.converter == null) { 
			this.setConverter(new DeserializingConverter()); 
		} 
		return this.converter.convert(payload); 
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:
 * @author Costin Leau 
 */ 
public class JdkSerializationRedisSerializer implements RedisSerializer<Object> {
 
	private Converter<Object, byte[]> serializer = new SerializingConverter();
	private Converter<byte[], Object> deserializer = new DeserializingConverter();
 
	public Object deserialize(byte[] bytes) {
		if (SerializationUtils.isEmpty(bytes)) {
			return null; 
		} 
 
		try { 
			return deserializer.convert(bytes);
		} catch (Exception ex) {
			throw new SerializationException("Cannot deserialize", ex);
		} 
	} 
 
	public byte[] serialize(Object object) {
5
CodeRank
This code example shows how to use the following methods:convert
        SerializingConverter sc = new SerializingConverter();
        return sc.convert(obj);
    } 
 
    private Object deserializeObject(byte[] b) {
        DeserializingConverter dc = new DeserializingConverter();
        return dc.convert(b);
    } 
 
    public boolean lock(Object key, Integer expireMsecs) throws InterruptedException {
 
        String lockKey = generateLockKey(key);
        long expires = System.currentTimeMillis() + expireMsecs + 1;
        String expiresStr = String.valueOf(expires);
        long timeout = expireMsecs;
 
        while (timeout >= 0) {
 
            try { 
                if (jedis.setnx(lockKey, expiresStr) == 1) {
4
CodeRank
This code example shows how to use the following methods:
 
	/** 
	 * Convenient constructor for configuration use. 
	 */ 
	public JdbcChannelMessageStore() { 
		deserializer = new DeserializingConverter(); 
		serializer = new SerializingConverter(); 
	} 
 
	/** 
	 * Create a {@link MessageStore} with all mandatory properties. The passed-in 
	 * {@link DataSource} is used to instantiate a {@link JdbcTemplate} 
	 * 
	 * with {@link JdbcTemplate#setFetchSize(int)} set to <code>1</code> 
	 * and with {@link JdbcTemplate#setMaxRows(int)} set to <code>1</code>. 
	 * 
	 * @param dataSource a {@link DataSource} 
	 */ 
	public JdbcChannelMessageStore(DataSource dataSource) { 
		this(); 
3
CodeRank