/// <summary> /// It is the entry point to the SIMINOV FRAMEWORK. /// <para> /// When application starts it should call this method to activate SIMINOV-FRAMEWORK, by providing ApplicationContext as the parameter. /// Siminov will read all descriptor defined by application, and do necessary processing. /// EXAMPLE /// There are two ways to make a call. /// <list type="bullet"> /// <item> /// Call it from Application class. /// <code> /// public App() /// { /// this.InitializeComponent(); /// this.Suspending += this.OnSuspending; /// /// new Siminov.Core.Sample.Siminov().InitializeSiminov(); /// } /// </code> /// </item> /// </list> /// </para> /// </summary> /// <exception cref="Siminov.Core.Exception.DeploymentException">If any exception occur while deploying application it will through DeploymentException, which is RuntimeException.</exception> public static void Start() { if (isActive) { return; } Process(); isActive = true; ISiminovEvents coreEventHandler = coreResourceManager.GetSiminovEventHandler(); if (coreResourceManager.GetSiminovEventHandler() != null) { if (firstTimeProcessed) { coreEventHandler.OnFirstTimeSiminovInitialized(); } else { coreEventHandler.OnSiminovInitialized(); } } }
/// <summary> /// It is the entry point to the SIMINOV FRAMEWORK. /// <p> /// When application starts it should call this method to activate SIMINOV-FRAMEWORK, by providing ApplicationContext as the parameter. /// </p> /// /// <p> /// Siminov will read all descriptor defined by application, and do necessary processing. /// </p> /// /// EXAMPLE /// ///public class Siminov extends Application { /// /// public void onCreate() { /// super.onCreate(); /// /// initializeSiminov(); /// } /// /// private void initializeSiminov() { /// siminov.connect.Siminov.initialize(this); /// } ///} /// /// </summary> /// <exception cref="Siminov.Core.Exception.DeploymentException">If any exception occur while deploying application it will through DeploymentException, which is RuntimeException.</exception> public static void Start() { ProcessApplicationDescriptor(); ProcessDatabaseDescriptors(); ProcessLibraries(); ProcessEntityDescriptors(); ProcessSyncDescriptors(); ProcessDatabase(); ProcessServices(); isActive = true; Core.Siminov.isActive = true; ISiminovEvents coreEventHandler = coreResourceManager.GetSiminovEventHandler(); if (coreResourceManager.GetSiminovEventHandler() != null) { if (firstTimeProcessed) { coreEventHandler.OnFirstTimeSiminovInitialized(); } else { coreEventHandler.OnSiminovInitialized(); } } }
/// <summary> /// Event Handler Constructor /// </summary> private EventHandler() { IEnumerator<String> events = resourceManager.GetApplicationDescriptor().GetEvents(); while (events.MoveNext()) { String eventNotifier = events.Current; Object model = ClassUtils.CreateClassInstance(eventNotifier); if (model is ISiminovEvents) { coreEventHandler = (ISiminovEvents)model; } else if (model is IDatabaseEvents) { databaseEventHandler = (IDatabaseEvents)model; } } }
/// <summary> /// Event Handler Constructor /// </summary> private EventHandler() { IEnumerator <String> events = resourceManager.GetApplicationDescriptor().GetEvents(); while (events.MoveNext()) { String eventNotifier = events.Current; Object model = ClassUtils.CreateClassInstance(eventNotifier); if (model is ISiminovEvents) { coreEventHandler = (ISiminovEvents)model; } else if (model is IDatabaseEvents) { databaseEventHandler = (IDatabaseEvents)model; } } }
/// <summary> /// It is used to stop all service started by SIMINOV. /// When application shutdown they should call this. It do following services: /// /// <list type="bullet"> /// <item> /// <description>Close all database's opened by SIMINOV.</description> /// </item> /// <item> /// <description>Deallocate all resources held by SIMINOV.</description> /// </item> /// </list> /// </summary> public static void Shutdown() { IsActive(); IEnumerator <DatabaseDescriptor> databaseDescriptors = coreResourceManager.GetDatabaseDescriptors(); bool failed = false; while (databaseDescriptors.MoveNext()) { DatabaseDescriptor databaseDescriptor = databaseDescriptors.Current; DatabaseBundle databaseBundle = coreResourceManager.GetDatabaseBundle(databaseDescriptor.GetDatabaseName()); IDatabaseImpl database = databaseBundle.GetDatabase(); try { database.Close(databaseDescriptor); } catch (DatabaseException databaseException) { failed = true; Log.Log.Error(typeof(Siminov).FullName, "Shutdown", "DatabaseException caught while closing database, " + databaseException.GetMessage()); continue; } } if (failed) { throw new SiminovCriticalException(typeof(Siminov).FullName, "Shutdown", "DatabaseException caught while closing database."); } ISiminovEvents coreEventHandler = coreResourceManager.GetSiminovEventHandler(); if (coreResourceManager.GetSiminovEventHandler() != null) { coreEventHandler.OnSiminovStopped(); } }