/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> /// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception> public virtual void Activate(object obj) { lock (Lock()) { CheckClosed(); _server.Activate(_transaction, obj); } }
/// <exception cref="System.IO.IOException"></exception> public virtual File ServerFile(string promptName, bool writeToServer) { lock (i_stream.Lock()) { i_stream.Activate(i_trans, this, new FixedActivationDepth(2)); } var path = ServerPath(); i_stream.ConfigImpl.EnsureDirExists(path); if (writeToServer) { if (fileName == null) { if (promptName != null) { fileName = promptName; } else { fileName = "b_" + Runtime.CurrentTimeMillis(); } var tryPath = fileName + i_ext; var i = 0; while (new File(path, tryPath).Exists()) { tryPath = fileName + "_" + i++ + i_ext; if (i == 99) { // should never happen i_status = Status.Error; throw new IOException(Messages.Get(40)); } } fileName = tryPath; lock (i_stream.Lock()) { i_stream.StoreInternal(i_trans, this, false); } } } else { if (fileName == null) { throw new IOException(Messages.Get(38)); } } var lastTryPath = path + File.separator + fileName; if (!writeToServer) { if (!(new File(lastTryPath).Exists())) { throw new IOException(Messages.Get(39)); } } return(new File(lastTryPath)); }
internal override void Instantiate1(ObjectReferenceContext context) { int dbID = context.ReadInt(); Transaction trans = context.Transaction(); ObjectContainerBase container = trans.Container(); container.ShowInternalClasses(true); try { Db4oDatabase db = (Db4oDatabase)container.GetByID2(trans, dbID); if (db != null && db.i_signature == null) { container.Activate(trans, db, new FixedActivationDepth(2)); } VirtualAttributes va = context.ObjectReference().VirtualAttributes(); va.i_database = db; va.i_uuid = context.ReadLong(); } finally { container.ShowInternalClasses(false); } }
public static Db4objects.Drs.Db4o.ReplicationRecord QueryForReplicationRecord(ObjectContainerBase container, Transaction trans, Db4oDatabase younger, Db4oDatabase older) { container.ShowInternalClasses(true); try { IQuery q = container.Query(trans); q.Constrain(typeof(Db4objects.Drs.Db4o.ReplicationRecord)); q.Descend("_youngerPeer").Constrain(younger).Identity(); q.Descend("_olderPeer").Constrain(older).Identity(); IObjectSet objectSet = q.Execute(); if (objectSet.HasNext()) { Db4objects.Drs.Db4o.ReplicationRecord replicationRecord = (Db4objects.Drs.Db4o.ReplicationRecord )objectSet.Next(); container.Activate(replicationRecord, int.MaxValue); return replicationRecord; } return null; } finally { container.ShowInternalClasses(false); } }