@Override public Object deserialize(Object bytes, Session session) { ByteArrayInputStream byteIn = new ByteArrayInputStream((byte[])bytes); try (ObjectInputStream objectIn = session == null ? new ObjectInputStream(byteIn) : new CustomObjectInputStream(byteIn, session)) { return objectIn.readObject(); } catch (IOException | ClassNotFoundException exception) { throw new RuntimeException(exception); } }
/** * INTERNAL: * The fieldValue will be a byte array. Create a ByteArrayInputStream * on the fieldValue. Create an ObjectInputStream on the ByteArrayInputStream * to read in the objects. */ public Object convertDataValueToObjectValue(Object fieldValue, Session session) throws DescriptorException { byte[] bytes; try { bytes = (byte[])((AbstractSession)session).getDatasourcePlatform().convertObject(fieldValue, ClassConstants.APBYTE); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } if ((bytes == null) || (bytes.length == 0)) { return null; } ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes); Object object = null; try { // BUG# 2813583 CustomObjectInputStream objectIn = new CustomObjectInputStream(byteIn, session); object = objectIn.readObject(); } catch (Exception exception) { throw DescriptorException.notDeserializable(getMapping(), exception); } return object; }
public Object deserialize(Object bytes, Session session) { ByteArrayInputStream byteIn = new ByteArrayInputStream((byte[])bytes); try { ObjectInputStream objectIn = null; if (session == null) { objectIn = new ObjectInputStream(byteIn); } else { objectIn = new CustomObjectInputStream(byteIn, session); } return objectIn.readObject(); } catch (Exception exception) { throw new RuntimeException(exception); } }
/** * INTERNAL: * Recreate a UnitOfWorkChangeSet that has been converted to a byte array with the * getByteArrayRepresentation() method. * The passed session ensures that the correct class loader is used for deserialization. * That allows to deserialize instances of user-defined classes such as enums. * See Bug 280129: WLS JMS CacheCoordination fails if enum changed with ClassNotFoundException. */ public UnitOfWorkChangeSet(byte[] bytes, AbstractSession session) throws java.io.IOException, ClassNotFoundException { java.io.ByteArrayInputStream byteIn = new java.io.ByteArrayInputStream(bytes); ObjectInputStream objectIn; objectIn = new CustomObjectInputStream(byteIn, session); // bug 4416412: allChangeSets set directly instead of using setInternalAllChangeSets allChangeSets = (Map)objectIn.readObject(); deletedObjects = (Map)objectIn.readObject(); }