@@ -0,0 +1,2073 @@
+package com.lance.shiro.utils;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutputStream;%0Aimport java.io.Serializable;%0A%0Aimport org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0A%0Apublic final class SerializeUtils %7B%0A%09private static Logger logger = LogManager.getLogger();%0A%0A%09/**%0A%09 * deserialize%0A%09 * @param bytes%0A%09 * @return%0A%09 */%0A%09public static Object deserialize(byte%5B%5D bytes) %7B%0A%0A%09%09Object result = null;%0A%0A%09%09if (isEmpty(bytes)) %7B%0A%09%09%09return null;%0A%09%09%7D%0A%0A%09%09try %7B%0A%09%09%09ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);%0A%09%09%09try %7B%0A%09%09%09%09ObjectInputStream objectInputStream = new ObjectInputStream(byteStream);%0A%09%09%09%09try %7B%0A%09%09%09%09%09result = objectInputStream.readObject();%0A%09%09%09%09%7D catch (ClassNotFoundException ex) %7B%0A%09%09%09%09%09throw new Exception(%22Failed to deserialize object type%22, ex);%0A%09%09%09%09%7D%0A%09%09%09%7D catch (Throwable ex) %7B%0A%09%09%09%09throw new Exception(%22Failed to deserialize%22, ex);%0A%09%09%09%7D%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09logger.error(%22Failed to deserialize%22, e);%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%0A%09public static boolean isEmpty(byte%5B%5D data) %7B%0A%09%09return (data == null %7C%7C data.length == 0);%0A%09%7D%0A%0A%09/**%0A%09 * serialize%0A%09 * @param object%0A%09 * @return%0A%09 */%0A%09public static byte%5B%5D serialize(Object object) %7B%0A%09%09byte%5B%5D result = null;%0A%09%09if (object == null) %7B%0A%09%09%09return new byte%5B0%5D;%0A%09%09%7D%0A%09%09try %7B%0A%09%09%09ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128);%0A%09%09%09try %7B%0A%09%09%09%09if (!(object instanceof Serializable)) %7B%0A%09%09%09%09%09throw new IllegalArgumentException(%0A%09%09%09%09%09%09%09SerializeUtils.class.getSimpleName() + %22 requires a Serializable payload %22%0A%09%09%09%09%09%09%09%09%09+ %22but received an object of type %5B%22 + object.getClass().getName() + %22%5D%22);%0A%09%09%09%09%7D%0A%09%09%09%09ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream);%0A%09%09%09%09objectOutputStream.writeObject(object);%0A%09%09%09%09objectOutputStream.flush();%0A%09%09%09%09result = byteStream.toByteArray();%0A%09%09%09%7D catch (Throwable ex) %7B%0A%09%09%09%09throw new Exception(%22Failed to serialize%22, ex);%0A%09%09%09%7D%0A%09%09%7D catch (Exception ex) %7B%0A%09%09%09logger.error(%22Failed to serialize%22, ex);%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%7D%0A

add redis serizlizeutils