Ejemplo n.º 1
0
		public virtual void ActivateOn(Db4objects.Db4o.Internal.Transaction transaction, 
			ActivationPurpose purpose)
		{
			if (Activating())
			{
				return;
			}
			try
			{
				Activating(true);
				ObjectContainerBase container = transaction.Container();
				if (!(container.ActivationDepthProvider() is ITransparentActivationDepthProvider))
				{
					return;
				}
				ITransparentActivationDepthProvider provider = (ITransparentActivationDepthProvider
					)container.ActivationDepthProvider();
				if (ActivationPurpose.Write == purpose)
				{
					lock (container.Lock())
					{
						provider.AddModified(GetObject(), transaction);
					}
				}
				if (IsActive())
				{
					return;
				}
				lock (container.Lock())
				{
					Activate(transaction, GetObject(), new DescendingActivationDepth(provider, ActivationMode
						.Activate));
				}
			}
			finally
			{
				Activating(false);
			}
		}
Ejemplo n.º 2
0
		protected virtual bool ObjectCanUpdate(Db4objects.Db4o.Internal.Transaction transaction
			, object obj)
		{
			ObjectContainerBase container = transaction.Container();
			return container.Callbacks().ObjectCanUpdate(transaction, this) && _class.DispatchEvent
				(transaction, obj, EventDispatchers.CanUpdate);
		}
Ejemplo n.º 3
0
		public virtual Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes(Db4objects.Db4o.Internal.Transaction
			 trans, bool lastCommitted)
		{
			if (trans == null)
			{
				return _virtualAttributes;
			}
			lock (trans.Container().Lock())
			{
				if (_virtualAttributes == null)
				{
					if (_class.HasVirtualAttributes())
					{
						_virtualAttributes = new Db4objects.Db4o.Internal.VirtualAttributes();
						_class.ReadVirtualAttributes(trans, this, lastCommitted);
					}
				}
				else
				{
					if (!_virtualAttributes.SuppliesUUID())
					{
						if (_class.HasVirtualAttributes())
						{
							_class.ReadVirtualAttributes(trans, this, lastCommitted);
						}
					}
				}
				return _virtualAttributes;
			}
		}
Ejemplo n.º 4
0
		public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction, 
			IUpdateDepth updatedepth)
		{
			ContinueSet(transaction, updatedepth);
			// make sure, a concurrent new, possibly triggered by objectOnNew
			// is written to the file
			// preventing recursive
			if (!BeginProcessing())
			{
				return;
			}
			object obj = GetObject();
			if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata
				().IsModified(obj))
			{
				EndProcessing();
				return;
			}
			MarshallingContext context = new MarshallingContext(transaction, this, updatedepth
				, false);
			if (context.UpdateDepth().Negative())
			{
				EndProcessing();
				return;
			}
			ObjectContainerBase container = transaction.Container();
			LogEvent(container, "update", Const4.State);
			SetStateClean();
			context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType
				(obj));
			Handlers4.Write(_class.TypeHandler(), context, obj);
			if (context.UpdateDepth().CanSkip(this))
			{
				EndProcessing();
				return;
			}
			Pointer4 pointer = context.AllocateSlot();
			ByteArrayBuffer buffer = context.ToWriteBuffer(pointer);
			container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType
				(obj), buffer);
			if (IsActive())
			{
				SetStateClean();
			}
			EndProcessing();
			container.Callbacks().ObjectOnUpdate(transaction, this);
			ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update);
		}
Ejemplo n.º 5
0
		internal void Store(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.ClassMetadata
			 classMetadata, object obj)
		{
			_object = obj;
			_class = classMetadata;
			int id = trans.Container().IdForNewUserObject(trans);
			SetID(id);
			// will be ended in continueset()
			BeginProcessing();
			BitTrue(Const4.Continue);
		}
Ejemplo n.º 6
0
		public virtual void Deactivate(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth
			 depth)
		{
			if (!depth.RequiresActivation())
			{
				return;
			}
			object obj = GetObject();
			if (obj == null)
			{
				return;
			}
			ObjectContainerBase container = trans.Container();
			LogActivation(container, "deactivate");
			SetStateDeactivated();
			_class.Deactivate(trans, this, depth);
		}
Ejemplo n.º 7
0
		private void ObjectOnNew(Db4objects.Db4o.Internal.Transaction transaction, object
			 obj)
		{
			ObjectContainerBase container = transaction.Container();
			container.Callbacks().ObjectOnNew(transaction, this);
			_class.DispatchEvent(transaction, obj, EventDispatchers.New);
		}
Ejemplo n.º 8
0
		/// <summary>return false if class not completely initialized, otherwise true</summary>
		internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth
			 updateDepth)
		{
			if (!BitIsTrue(Const4.Continue))
			{
				return true;
			}
			if (!_class.StateOK())
			{
				return false;
			}
			if (!_class.AspectsAreInitialized())
			{
				return false;
			}
			if (DTrace.enabled)
			{
				DTrace.Continueset.Log(GetID());
			}
			BitFalse(Const4.Continue);
			MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true
				);
			Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject());
			Pointer4 pointer = context.AllocateSlot();
			ByteArrayBuffer buffer = context.ToWriteBuffer(pointer);
			ObjectContainerBase container = trans.Container();
			container.WriteNew(trans, pointer, _class, buffer);
			object obj = _object;
			ObjectOnNew(trans, obj);
			if (_class.HasIdentity())
			{
				_object = container.NewWeakReference(this, obj);
			}
			SetStateClean();
			EndProcessing();
			return true;
		}
Ejemplo n.º 9
0
		public virtual void Activate(Db4objects.Db4o.Internal.Transaction ta, object obj, 
			IActivationDepth depth)
		{
			ObjectContainerBase container = ta.Container();
			ActivateInternal(container.ActivationContextFor(ta, obj, depth));
			container.ActivatePending(ta);
		}