Ejemplo n.º 1
0
        protected virtual void Init()
        {
            CheckRuntimeCompatibility();
            isClosed = false;
            isLocal  = baseIdentification.IsLocal();
            // The check if it is a new Database must be executed before object
            // writer initialization. Because Object Writer Init
            // Creates the file so the check (which is based on the file existence
            // would always return false*/
            bool isNewDatabase = IsNewDatabase();

            commitListeners   = new OdbArrayList <ICommitListener>();
            classIntrospector = provider.GetClassIntrospector();
            ISession session = BuildDefaultSession();

            // Object Writer must be created before object Reader
            objectWriter = BuildObjectWriter();
            // Object writer is a two Phase init object
            objectWriter.Init2();
            objectReader = BuildObjectReader();
            AddSession(session, false);
            // If the file does not exist, then a default header must be created
            if (isNewDatabase)
            {
                objectWriter.CreateEmptyDatabaseHeader(OdbTime.GetCurrentTimeInMs(), baseIdentification.GetUserName(), baseIdentification.GetPassword());
            }
            else
            {
                try
                {
                    GetObjectReader().ReadDatabaseHeader(baseIdentification.GetUserName(), baseIdentification.GetPassword());
                }
                catch (ODBAuthenticationRuntimeException e)
                {
                    Close();
                    throw;
                }
            }
            objectWriter.AfterInit();
            objectIntrospector  = BuildObjectIntrospector();
            this.triggerManager = BuildTriggerManager();
            // This forces the initialization of the meta model
            MetaModel metaModel = GetMetaModel();

            if (OdbConfiguration.CheckModelCompatibility())
            {
                CheckMetaModelCompatibility(classIntrospector.Instrospect(metaModel.GetAllClasses()));
            }
            // logically locks access to the file (only for this Virtual machine)
            FileMutex.GetInstance().OpenFile(GetStorageDeviceName());
            // Updates the Transaction Id in the file
            objectWriter.WriteLastTransactionId(GetCurrentTransactionId());
            this.objectWriter.SetTriggerManager(this.triggerManager);
            this.introspectionCallbackForInsert = new DefaultInstrumentationCallbackForStore(this, triggerManager, false);
            this.introspectionCallbackForUpdate = new DefaultInstrumentationCallbackForStore(this, triggerManager, true);
        }
Ejemplo n.º 2
0
 public DefaultInstrumentationCallbackForStore(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine
                                               engine, NeoDatis.Odb.Core.Trigger.ITriggerManager triggerManager, bool isUpdate
                                               ) : base()
 {
     this.engine         = engine;
     this.triggerManager = triggerManager;
     this.isUpdate       = isUpdate;
     // Just for junits
     if (engine != null)
     {
         this.crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory.GetCrossSessionCache
                                      (engine.GetBaseIdentification().GetIdentification());
     }
 }
		public DefaultInstrumentationCallbackForStore(NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine
			 engine, NeoDatis.Odb.Core.Trigger.ITriggerManager triggerManager, bool isUpdate
			) : base()
		{
			this.engine = engine;
			this.triggerManager = triggerManager;
			this.isUpdate = isUpdate;
			// Just for junits
			if (engine != null)
			{
				this.crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory.GetCrossSessionCache
					(engine.GetBaseIdentification().GetIdentification());
			}
		}
		public virtual void SetTriggerManager(NeoDatis.Odb.Core.Trigger.ITriggerManager triggerManager
			)
		{
			this.triggerManager = triggerManager;
		}
		protected virtual void Init()
		{
			CheckRuntimeCompatibility();
			isClosed = false;
			isLocal = baseIdentification.IsLocal();
			// The check if it is a new Database must be executed before object
			// writer initialization. Because Object Writer Init
			// Creates the file so the check (which is based on the file existence
			// would always return false*/
			bool isNewDatabase = IsNewDatabase();
			commitListeners = new OdbArrayList<ICommitListener>();
			classIntrospector = provider.GetClassIntrospector();
			ISession session = BuildDefaultSession();
			// Object Writer must be created before object Reader
			objectWriter = BuildObjectWriter();
			// Object writer is a two Phase init object
			objectWriter.Init2();
			objectReader = BuildObjectReader();
			AddSession(session, false);
			// If the file does not exist, then a default header must be created
			if (isNewDatabase)
			{
				objectWriter.CreateEmptyDatabaseHeader(OdbTime.GetCurrentTimeInMs(), baseIdentification.GetUserName(), baseIdentification.GetPassword());
			}
			else
			{
				try
				{
					GetObjectReader().ReadDatabaseHeader(baseIdentification.GetUserName(), baseIdentification.GetPassword());
				}
				catch (ODBAuthenticationRuntimeException e)
				{
					Close();
					throw;
				}
			}
			objectWriter.AfterInit();
			objectIntrospector = BuildObjectIntrospector();
			this.triggerManager = BuildTriggerManager();
			// This forces the initialization of the meta model
			MetaModel metaModel = GetMetaModel();
			if (OdbConfiguration.CheckModelCompatibility())
			{
				CheckMetaModelCompatibility(classIntrospector.Instrospect(metaModel.GetAllClasses()));
			}
			// logically locks access to the file (only for this Virtual machine)
			FileMutex.GetInstance().OpenFile(GetStorageDeviceName());
			// Updates the Transaction Id in the file
			objectWriter.WriteLastTransactionId(GetCurrentTransactionId());
			this.objectWriter.SetTriggerManager(this.triggerManager);
			this.introspectionCallbackForInsert = new DefaultInstrumentationCallbackForStore(this, triggerManager, false);
			this.introspectionCallbackForUpdate = new DefaultInstrumentationCallbackForStore(this, triggerManager, true);
		}