/** * Deletes the specified object. * * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#delete(java.lang.String) */ public final void delete(String name) { delete(null, name); }
/** * Load the specified object. * * @param name the name of the object. * @return the loaded object. * * @see fr.dyade.aaa.util.Transaction#load(java.lang.String) */ public final Object load(String name) throws IOException, ClassNotFoundException { return load(null, name); }
/** * Load the specified byte array. * * @param name the name of the object. * @return the loaded byte array. * * @see fr.dyade.aaa.util.Transaction#loadByteArray(java.lang.String) */ public final byte[] loadByteArray(String name) throws IOException { return loadByteArray(null, name); }
loadProperties(dir); onlyUseJavaSerialization = getBoolean("Transaction.OnlyUseJavaSerialization"); initRepository(); saveProperties(dir); setPhase(FREE);
/** * Register a modified byte array in the current transaction. * * @param buf the byte array to store. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#saveByteArray(byte[], java.lang.String) */ public final void saveByteArray(byte[] buf, String name) throws IOException { saveByteArray(buf, null, name, true, false); }
/** * Register the state of a newly created object in the current transaction. * * @param obj the object to store. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#create(java.io.Serializable, java.lang.String) */ public final void create(Serializable obj, String name) throws IOException { save(obj, null, name, true); }
/** * Release the mutual exclusion. * @see fr.dyade.aaa.util.Transaction#release() */ public synchronized void release() throws IOException { if ((phase != RUN) && (phase != COMMIT) && (phase != ROLLBACK)) throw new IllegalStateException("Can not release transaction: " + getPhaseInfo() + '.'); // Change the transaction state. setPhase(FREE); // wake-up an eventually user's thread in begin notify(); }
byte[] buf = loadByteArray(dirName, name); if (buf != null) { if (onlyUseJavaSerialization) { return deserialize(buf, 0); } else if (buf.length > 0) { byte tag = buf[0]; switch (tag) { case JAVA_SERIALIZATION_TAG: return deserialize(buf, 1); case ENCODING_TAG: return decode(buf, 1); default: throw new IOException("Unexpected tag: " + tag);
byte[] encodedObject; if (onlyUseJavaSerialization) { encodedObject = serialize(obj, ctx); } else { Encodable encodable = isEncodable(obj); if (encodable == null) { encodedObject = serialize(obj, ctx); } else { try { saveInLog(encodedObject, dirName, name, ctx.log, false, first);
/** * Register a modified byte array in the current transaction. * * @param buf the byte array to store. * @param dirName the directory name of the object. * @param name the name of the object. * @param copy the byte array can be modified, copy it. * @param first the object is a new one. * * @see fr.dyade.aaa.util.Transaction#saveByteArray(byte[], java.lang.String, java.lang.String, boolean, boolean) */ public final void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOException { saveInLog(buf, dirName, name, perThreadContext.get().log, copy, first); }
loadProperties(dir); initRepository(); saveProperties(dir); setPhase(FREE);
/** * Register a modified byte array in the current transaction. * * @param buf the byte array to store. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#saveByteArray(byte[], java.lang.String) */ public final void saveByteArray(byte[] buf, String name) throws IOException { saveByteArray(buf, null, name, true, false); }
/** * Register the modified state of an object in the current transaction. * * @param obj the object to store. * @param dirName the directory name of the object. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#save(java.io.Serializable, java.lang.String, java.lang.String) */ public final void save(Serializable obj, String dirName, String name) throws IOException { save(obj, dirName, name, false); }
/** * Release the mutual exclusion. * @see fr.dyade.aaa.util.Transaction#release() */ public synchronized void release() throws IOException { if ((phase != RUN) && (phase != COMMIT) && (phase != ROLLBACK)) throw new IllegalStateException("Can not release transaction: " + getPhaseInfo() + '.'); // Change the transaction state. setPhase(FREE); // wake-up an eventually user's thread in begin notify(); } }
/** * Register a modified byte array in the current transaction. * * @param buf the byte array to store. * @param dirName the directory name of the object. * @param name the name of the object. * @param copy the byte array can be modified, copy it. * @param first the object is a new one. * * @see fr.dyade.aaa.util.Transaction#saveByteArray(byte[], java.lang.String, java.lang.String, boolean, boolean) */ public final void saveByteArray(byte[] buf, String dirName, String name, boolean copy, boolean first) throws IOException { saveInLog(buf, dirName, name, ((Context) perThreadContext.get()).log, copy, first); }
/** * Register a new byte array in the current transaction. * * @param buf the byte array to store. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#createByteArray(byte[], java.lang.String) */ public final void createByteArray(byte[] buf, String name) throws IOException { saveByteArray(buf, null, name, true, true); }
/** * Register the state of a newly created object in the current transaction. * * @param obj the object to store. * @param name the name of the object. * * @see fr.dyade.aaa.util.Transaction#create(java.io.Serializable, java.lang.String) */ public final void create(Serializable obj, String name) throws IOException { save(obj, null, name, true); }
/** * Load the specified byte array. * * @param name the name of the object. * @return the loaded byte array. * * @see fr.dyade.aaa.util.Transaction#loadByteArray(java.lang.String) */ public final byte[] loadByteArray(String name) throws IOException { return loadByteArray(null, name); }
/** * Register the state of an object in the current transaction. * * @param obj the object to store. * @param dirName the directory name of the object. * @param name the name of the object. * @param first the object is a new one. * * @see fr.dyade.aaa.util.Transaction#save(java.io.Serializable, java.lang.String, java.lang.String, boolean) */ public final void save(Serializable obj, String dirName, String name, boolean first) throws IOException { Context ctx = (Context) perThreadContext.get(); if (ctx.oos == null) { ctx.bos.reset(); ctx.oos = new ObjectOutputStream(ctx.bos); } else { ctx.oos.reset(); ctx.bos.reset(); ctx.bos.write(OOS_STREAM_HEADER, 0, 4); } ctx.oos.writeObject(obj); ctx.oos.flush(); saveInLog(ctx.bos.toByteArray(), dirName, name, ctx.log, false, first); }
/** * Load the specified object. * * @param name the name of the object. * @return the loaded object. * * @see fr.dyade.aaa.util.Transaction#load(java.lang.String) */ public final Object load(String name) throws IOException, ClassNotFoundException { return load(null, name); }