Beispiel #1
0
        private void CascadeActivation(IActivationContext context)
        {
            IActivationDepth depth = context.Depth();

            if (!depth.RequiresActivation())
            {
                return;
            }
            if (depth.Mode().IsDeactivate())
            {
                Container().StillToDeactivate(_transaction, context.TargetObject(), depth, false);
            }
            else
            {
                // FIXME: [TA] do we really need to check for isValueType here?
                Db4objects.Db4o.Internal.ClassMetadata classMetadata = context.ClassMetadata();
                if (classMetadata.IsStruct())
                {
                    classMetadata.CascadeActivation(context);
                }
                else
                {
                    Container().StillToActivate(context);
                }
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public virtual void TestDescendingFromNonTAAwareToTAAware()
        {
            IActivationDepth depth = NonTAAwareDepth();
            IActivationDepth child = depth.Descend(ClassMetadataFor(typeof(TransparentActivationDepthTestCase.TAAware
                                                                           )));

            Assert.IsFalse(child.RequiresActivation());
        }
Beispiel #4
0
        public virtual void Activate(Transaction ta, object obj,
                                     IActivationDepth depth)
        {
            var container = ta.Container();

            ActivateInternal(container.ActivationContextFor(ta, obj, depth));
            container.ActivatePending(ta);
        }
Beispiel #5
0
        public virtual void TestSpecificActivationDepth()
        {
            IActivationDepth depth = Provider().ActivationDepth(3, ActivationMode.Activate);

            AssertDescendingDepth(3, depth, typeof(TransparentActivationDepthTestCase.TAAware
                                                   ));
            AssertDescendingDepth(3, depth, typeof(TransparentActivationDepthTestCase.NonTAAware
                                                   ));
        }
Beispiel #6
0
        public virtual void TestDefaultActivationNonTAAware()
        {
            IActivationDepth depth = NonTAAwareDepth();

            Assert.IsTrue(depth.RequiresActivation());
            IActivationDepth child = depth.Descend(ClassMetadataFor(typeof(TransparentActivationDepthTestCase.NonTAAware
                                                                           )));

            Assert.IsTrue(child.RequiresActivation());
        }
Beispiel #7
0
		public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object
			 obj, IActivationDepth depth)
		{
			if (null == obj)
			{
				throw new ArgumentNullException();
			}
			_transaction = transaction;
			_targetObject = obj;
			_depth = depth;
		}
Beispiel #8
0
 public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object
                           obj, IActivationDepth depth)
 {
     if (null == obj)
     {
         throw new ArgumentNullException();
     }
     _transaction  = transaction;
     _targetObject = obj;
     _depth        = depth;
 }
Beispiel #9
0
        public object Read(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer
                           , object obj, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree
                           )
        {
            UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree
                                                                    , checkIDTree);

            context.PersistentObject(obj);
            context.ActivationDepth(instantiationDepth);
            return(context.Read());
        }
Beispiel #10
0
 private void AssertDescendingDepth(int expectedDepth, IActivationDepth depth, Type
                                    clazz)
 {
     if (expectedDepth < 1)
     {
         Assert.IsFalse(depth.RequiresActivation());
         return;
     }
     Assert.IsTrue(depth.RequiresActivation());
     AssertDescendingDepth(expectedDepth - 1, depth.Descend(ClassMetadataFor(clazz)),
                           clazz);
 }
Beispiel #11
0
 /// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
 public override object PeekPersisted(Transaction trans, object obj, IActivationDepth
                                      depth, bool committed)
 {
     _bypassSlotCache = true;
     try
     {
         return(base.PeekPersisted(trans, obj, depth, committed));
     }
     finally
     {
         _bypassSlotCache = false;
     }
 }
        public virtual object ReadFullyActivatedObjectForKeys(ITypeHandler4 handler)
        {
            object obj = ReadObject(handler);

            if (obj == null)
            {
                return(obj);
            }
            IActivationDepth activationDepth = ActivationDepthProvider().ActivationDepth(int.MaxValue
                                                                                         , ActivationMode.Activate);

            Container().Activate(Transaction(), obj, activationDepth);
            return(obj);
        }
Beispiel #13
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);
        }
Beispiel #14
0
        public virtual void Deactivate(Transaction trans, IActivationDepth
                                       depth)
        {
            if (!depth.RequiresActivation())
            {
                return;
            }
            var obj = GetObject();

            if (obj == null)
            {
                return;
            }
            var container = trans.Container();

            LogActivation(container, "deactivate");
            SetStateDeactivated();
            _class.Deactivate(trans, this, depth);
        }
Beispiel #15
0
        public object ReadObject()
        {
            int objectId = ReadInt();

            if (objectId == 0)
            {
                _lastReferenceReadWasReallyNull = true;
                return(null);
            }
            _lastReferenceReadWasReallyNull = false;
            if (objectId == Const4.InvalidObjectId)
            {
                return(null);
            }
            ClassMetadata classMetadata = ClassMetadataForObjectId(objectId);

            if (null == classMetadata)
            {
                // TODO: throw here
                return(null);
            }
            IActivationDepth depth = ActivationDepth().Descend(classMetadata);

            if (PeekPersisted())
            {
                return(Container().PeekPersisted(Transaction(), objectId, depth, false));
            }
            object obj = Container().GetByID2(Transaction(), objectId);

            if (null == obj)
            {
                return(null);
            }
            // this is OK for boxed value types. They will not be added
            // to the list, since they will not be found in the ID tree.
            Container().StillToActivate(Container().ActivationContextFor(Transaction(), obj,
                                                                         depth));
            return(obj);
        }
Beispiel #16
0
        public virtual void TestDefaultActivationTAAware()
        {
            IActivationDepth depth = TAAwareDepth();

            Assert.IsFalse(depth.RequiresActivation());
        }
Beispiel #17
0
 public virtual void ForceDeactivation(Transaction trans, IActivationDepth depth,
     object obj)
 {
     DeactivateFields(trans.Container().ActivationContextFor(trans, obj, depth));
 }
Beispiel #18
0
 public virtual void Deactivate(Transaction trans, IObjectInfo reference, IActivationDepth
     depth)
 {
     var obj = reference.GetObject();
     if (ObjectCanDeactivate(trans, reference))
     {
         ForceDeactivation(trans, depth, obj);
         ObjectOnDeactivate(trans, reference);
     }
 }
Beispiel #19
0
 public virtual void Deactivate(Transaction trans, IActivationDepth
     depth)
 {
     if (!depth.RequiresActivation())
     {
         return;
     }
     var obj = GetObject();
     if (obj == null)
     {
         return;
     }
     var container = trans.Container();
     LogActivation(container, "deactivate");
     SetStateDeactivated();
     _class.Deactivate(trans, this, depth);
 }
Beispiel #20
0
 internal object Read(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth
                      instantiationDepth, int addToIDTree, bool checkIDTree)
 {
     return(Read(trans, null, null, instantiationDepth, addToIDTree, checkIDTree));
 }
Beispiel #21
0
		public virtual ActivationContext4 ActivationContextFor(Transaction ta, object obj
			, IActivationDepth depth)
		{
			return new ActivationContext4(ta, obj, depth);
		}
Beispiel #22
0
			public _IFunction4_189(ObjectContainerBase _enclosing, object obj, IActivationDepth
				 depth)
			{
				this._enclosing = _enclosing;
				this.obj = obj;
				this.depth = depth;
			}
Beispiel #23
0
		public void Activate(Db4objects.Db4o.Internal.Transaction trans, object obj, IActivationDepth
			 depth)
		{
			lock (_lock)
			{
				AsTopLevelCall(new _IFunction4_189(this, obj, depth), trans);
			}
		}
Beispiel #24
0
		public virtual ObjectReference PeekReference(Transaction trans, int id, IActivationDepth
			 depth, bool resetJustPeeked)
		{
			ObjectReference @ref = new ObjectReference(id);
			@ref.PeekPersisted(trans, depth);
			if (resetJustPeeked)
			{
				_justPeeked = null;
			}
			return @ref;
		}
Beispiel #25
0
			public _IFunction4_1271(ObjectContainerBase _enclosing, object obj, bool committed
				, IActivationDepth depth)
			{
				this._enclosing = _enclosing;
				this.obj = obj;
				this.committed = committed;
				this.depth = depth;
			}
		private void AssertDescendingDepth(int expectedDepth, IActivationDepth depth, Type
			 clazz)
		{
			if (expectedDepth < 1)
			{
				Assert.IsFalse(depth.RequiresActivation());
				return;
			}
			Assert.IsTrue(depth.RequiresActivation());
			AssertDescendingDepth(expectedDepth - 1, depth.Descend(ClassMetadataFor(clazz)), 
				clazz);
		}
Beispiel #27
0
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
		public virtual object PeekPersisted(Transaction trans, object obj, IActivationDepth
			 depth, bool committed)
		{
			// TODO: peekPersisted is not stack overflow safe, if depth is too high. 
			lock (_lock)
			{
				CheckClosed();
				return AsTopLevelCall(new _IFunction4_1271(this, obj, committed, depth), trans);
			}
		}
Beispiel #28
0
 internal void PeekPersisted(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth
                             depth)
 {
     SetObject(Read(trans, depth, Const4.Transient, false));
 }
Beispiel #29
0
		public object PeekPersisted(Transaction trans, int id, IActivationDepth depth, bool
			 resetJustPeeked)
		{
			if (resetJustPeeked)
			{
				_justPeeked = null;
			}
			else
			{
				TreeInt ti = new TreeInt(id);
				TreeIntObject tio = (TreeIntObject)Tree.Find(_justPeeked, ti);
				if (tio != null)
				{
					return tio._object;
				}
			}
			ObjectReference @ref = PeekReference(trans, id, depth, resetJustPeeked);
			return @ref.GetObject();
		}
Beispiel #30
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);
		}
Beispiel #31
0
		// overridden to do nothing in YapObjectCarrier
		internal List4 StillTo1(Transaction trans, List4 still, object obj, IActivationDepth
			 depth)
		{
			if (obj == null || !depth.RequiresActivation())
			{
				return still;
			}
			ObjectReference @ref = trans.ReferenceForObject(obj);
			if (@ref != null)
			{
				if (HandledInCurrentTopLevelCall(@ref))
				{
					return still;
				}
				FlagAsHandled(@ref);
				return new List4(still, new ObjectContainerBase.PendingActivation(@ref, depth));
			}
			IReflectClass clazz = ReflectorForObject(obj);
			if (clazz.IsArray())
			{
				if (!clazz.GetComponentType().IsPrimitive())
				{
					IEnumerator arr = ArrayHandler.Iterator(clazz, obj);
					while (arr.MoveNext())
					{
						object current = arr.Current;
						if (current == null)
						{
							continue;
						}
						ClassMetadata classMetadata = ClassMetadataForObject(current);
						still = StillTo1(trans, still, current, depth.Descend(classMetadata));
					}
				}
				return still;
			}
			else
			{
				if (obj is Entry)
				{
					still = StillTo1(trans, still, ((Entry)obj).key, depth);
					still = StillTo1(trans, still, ((Entry)obj).value, depth);
				}
				else
				{
					if (depth.Mode().IsDeactivate())
					{
						// Special handling to deactivate .net structs
						ClassMetadata metadata = ClassMetadataForObject(obj);
						if (metadata != null && metadata.IsStruct())
						{
							metadata.ForceDeactivation(trans, depth, obj);
						}
					}
				}
			}
			return still;
		}
Beispiel #32
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);
		}
Beispiel #33
0
		public void StillToDeactivate(Transaction trans, object a_object, IActivationDepth
			 a_depth, bool a_forceUnknownDeactivate)
		{
			_stillToDeactivate = StillTo1(trans, _stillToDeactivate, a_object, a_depth);
		}
Beispiel #34
0
		internal void PeekPersisted(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth
			 depth)
		{
			SetObject(Read(trans, depth, Const4.Transient, false));
		}
Beispiel #35
0
			public PendingActivation(ObjectReference ref_, IActivationDepth depth_)
			{
				this.@ref = ref_;
				this.depth = depth_;
			}
Beispiel #36
0
		internal object Read(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth
			 instantiationDepth, int addToIDTree, bool checkIDTree)
		{
			return Read(trans, null, null, instantiationDepth, addToIDTree, checkIDTree);
		}
Beispiel #37
0
		private void DeactivateInternal(Transaction trans, object obj, IActivationDepth depth
			)
		{
			StillToDeactivate(trans, obj, depth, true);
			DeactivatePending(trans);
		}
Beispiel #38
0
		public object Read(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer
			, object obj, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree
			)
		{
			UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree
				, checkIDTree);
			context.PersistentObject(obj);
			context.ActivationDepth(instantiationDepth);
			return context.Read();
		}
Beispiel #39
0
		public virtual void ActivationDepth(IActivationDepth depth)
		{
			_activationDepth = depth;
		}
Beispiel #40
0
 public virtual void ActivationDepth(IActivationDepth depth)
 {
     _activationDepth = depth;
 }
Beispiel #41
0
		/// <exception cref="Db4objects.Db4o.Ext.DatabaseClosedException"></exception>
		public override object PeekPersisted(Transaction trans, object obj, IActivationDepth
			 depth, bool committed)
		{
			_bypassSlotCache = true;
			try
			{
				return base.PeekPersisted(trans, obj, depth, committed);
			}
			finally
			{
				_bypassSlotCache = false;
			}
		}
Beispiel #42
0
 public virtual void Activate(Transaction ta, object obj,
     IActivationDepth depth)
 {
     var container = ta.Container();
     ActivateInternal(container.ActivationContextFor(ta, obj, depth));
     container.ActivatePending(ta);
 }