/** * <b>INTENDED FOR TESTSUITE USE ONLY!</b> * <p/> * Much like {@link #addCacheableFile(File)} except that here we will fail immediately if * the cache version cannot be found or used for whatever reason * * @param xmlFile The xml file, not the bin! * * @return The dom "deserialized" from the cached file. * * @throws SerializationException Indicates a problem deserializing the cached dom tree * @throws FileNotFoundException Indicates that the cached file was not found or was not usable. */ public Configuration addCacheableFileStrictly(File xmlFile) throws SerializationException, FileNotFoundException { final File cachedFile = determineCachedDomFile( xmlFile ); final boolean useCachedFile = xmlFile.exists() && cachedFile.exists() && xmlFile.lastModified() < cachedFile.lastModified(); if ( ! useCachedFile ) { throw new FileNotFoundException( "Cached file could not be found or could not be used" ); } LOG.readingCachedMappings( cachedFile ); Document document = ( Document ) SerializationHelper.deserialize( new FileInputStream( cachedFile ) ); add( new XmlDocumentImpl( document, "file", xmlFile.getAbsolutePath() ) ); return this; }
@SuppressWarnings({ "unchecked" }) protected T fromBytes(byte[] bytes) { if ( getJavaType() == null ) { throw new IllegalStateException( "Cannot read bytes for Serializable type" ); } return (T) SerializationHelper.deserialize( bytes, getJavaType().getClassLoader() ); }
@Override @SuppressWarnings({ "unchecked" }) public S deepCopyNotNull(S value) { return (S) SerializationHelper.clone( value ); }
protected byte[] toBytes(T value) { return SerializationHelper.serialize( value ); }
@SuppressWarnings({ "unchecked" }) protected T fromBytes(byte[] bytes) { return (T) SerializationHelper.deserialize( bytes, getJavaTypeClass().getClassLoader() ); }
public static <T> T clone(T value) { return (value instanceof Serializable) ? (T) SerializationHelper.clone((Serializable) value) : fromString(toString(value), (Class<T>) value.getClass()); }
/** Performs deep copy of an object using serialization and de-serialization*/ @Override public Object deepCopy(Object value) throws HibernateException { return SerializationHelper.clone((Serializable) value); }