Java Code Examples for org.springframework.util.SerializationUtils#serialize()
The following examples show how to use
org.springframework.util.SerializationUtils#serialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DevToolsRunner.java From java-master with Apache License 2.0 | 5 votes |
@Override public void run(String... args) { // null意味着是BootstrapClassLoader System.out.println("Object classloader:" + Object.class.getClassLoader()); // RestartClassLoader System.out.println("ClassLoaderApplication classloader:" + ClassLoaderApplication.class.getClassLoader().getClass().getSimpleName()); // AppClassLoader System.out.println("ClassLoaderApplication classloader parent:" + ClassLoaderApplication.class.getClassLoader().getParent().getClass().getSimpleName()); // ExtClassLoader System.out.println("ClassLoaderApplication classloader parent's parent:" + ClassLoaderApplication.class.getClassLoader().getParent().getParent().getClass().getSimpleName()); // UserBaseDto是已导入到IDE的项目其它模块类文件 UserBaseDto userBaseDto = new UserBaseDto(); System.out.println("userBaseDto object classloader:" + userBaseDto.getClass().getClassLoader().getClass().getSimpleName()); byte[] bytes = SerializationUtils.serialize(userBaseDto); Object deserializeUserBaseDto = SerializationUtils.deserialize(bytes); System.out.println("deserialize userBaseDto object classloader:" + deserializeUserBaseDto.getClass().getClassLoader().getClass().getSimpleName()); // userBaseDto = (UserBaseDto) deserializeUserBaseDto; deserializeUserBaseDto = SerializeUtils.deserialize(bytes); userBaseDto = (UserBaseDto) deserializeUserBaseDto; System.out.println(userBaseDto); }
Example 2
Source File: MyRedisSessionDao.java From MyBlog with Apache License 2.0 | 5 votes |
@Override protected Serializable doCreate(Session session) { Serializable sessionId = generateSessionId(session); assignSessionId(session, sessionId); // session.setAttribute("user",session.get); byte[] keyByte = RedisKey.getKeyByte(RedisKey.SESSION_PRE, sessionId.toString()); byte[] sessionByte = SerializationUtils.serialize(session); client.setEx(keyByte, sessionByte, SESSION_EXPIRE); return sessionId; }
Example 3
Source File: WsMessage.java From yes-cart with Apache License 2.0 | 5 votes |
public WsMessage(final Message message) { this.source = message.getSource(); this.subject = message.getSubject(); if (message.getTargets() != null) { this.targets = new ArrayList<>(message.getTargets()); } this.payload = SerializationUtils.serialize(message.getPayload()); }
Example 4
Source File: RestMessage.java From yes-cart with Apache License 2.0 | 5 votes |
public RestMessage(final Message message) { this.source = message.getSource(); this.subject = message.getSubject(); if (message.getTargets() != null) { this.targets = new ArrayList<>(message.getTargets()); } this.payload = SerializationUtils.serialize(message.getPayload()); }
Example 5
Source File: SerializableProxyTest.java From jdal with Apache License 2.0 | 5 votes |
@Test public void testSerializablePostProcessor() { byte[] ser = SerializationUtils.serialize(configurableBean); ConfigurableBean cb = (ConfigurableBean) SerializationUtils.deserialize(ser); assertEquals(cb.getNoSerializableBean(), configurableBean.getNoSerializableBean()); ser = SerializationUtils.serialize(autowiredBean); AutowiredBean ab = (AutowiredBean) SerializationUtils.deserialize(ser); assertEquals(autowiredBean.getNoSerializableBean(), ab.getNoSerializableBean()); }
Example 6
Source File: SpringObjectSerialization.java From EasyTransaction with Apache License 2.0 | 4 votes |
@Override public byte[] serialization(Object obj) { return SerializationUtils.serialize(obj); }
Example 7
Source File: SerializableConverter.java From spring-cloud-sockets with Apache License 2.0 | 4 votes |
@Override public byte[] write(Object target) { return SerializationUtils.serialize(target); }
Example 8
Source File: MyRedisSessionDao.java From MyBlog with Apache License 2.0 | 4 votes |
@Override public void update(Session session) throws UnknownSessionException { byte[] keyByte = RedisKey.getKeyByte(RedisKey.SESSION_PRE, session.getId().toString()); byte[] sessionByte = SerializationUtils.serialize(session); client.setEx(keyByte, sessionByte, SESSION_EXPIRE); }
Example 9
Source File: HistoryBlob.java From uflo with Apache License 2.0 | 4 votes |
public HistoryBlob(Object obj){ byte[] b=SerializationUtils.serialize(obj); setBlobValue(b); }
Example 10
Source File: Blob.java From uflo with Apache License 2.0 | 4 votes |
public Blob(Object obj){ byte[] b=SerializationUtils.serialize(obj); setBlobValue(b); }
Example 11
Source File: BodyMethodGeneration.java From spring-cloud-contract with Apache License 2.0 | 4 votes |
default Object cloneBody(Object object) { byte[] serializedObject = SerializationUtils.serialize(object); return SerializationUtils.deserialize(serializedObject); }
Example 12
Source File: ProxySerializationTest.java From jdal with Apache License 2.0 | 4 votes |
private Object serialize(Object obj) { byte[] ser = SerializationUtils.serialize(obj); if (log.isDebugEnabled()) log.debug("Serialized [" + ser.length + "] bytes"); return SerializationUtils.deserialize(ser); }
Example 13
Source File: ProxySerializationTest.java From jdal with Apache License 2.0 | 4 votes |
@Test public void testUISerialization() { byte[] ser = SerializationUtils.serialize(testUI); TestUI deserialized = (TestUI) SerializationUtils.deserialize(ser); Assert.assertEquals(testUI.getClass(), deserialized.getClass()); }
Example 14
Source File: CloneUtils.java From spring-cloud-contract with Apache License 2.0 | 2 votes |
/** * Clones an object if it's serializable. * @param object to clone * @return a clone of the object */ public static Object clone(Object object) { byte[] serializedObject = SerializationUtils.serialize(object); return SerializationUtils.deserialize(serializedObject); }