コード例 #1
0
ファイル: HostBundle.cs プロジェクト: yshulin/OSGi
        public DefaultBundleState?GetBundleStartState()
        {
            BundlePersistentData persistentData = this.GetPersistentData();

            if (persistentData != null)
            {
                if (persistentData.State == BundleState.Active)
                {
                    return(0);
                }
                if (persistentData.State == BundleState.Installed)
                {
                    return(1);
                }
            }
            if (base.BundleData.InitializedState.HasValue)
            {
                switch (base.BundleData.InitializedState.Value)
                {
                case BundleInitializedState.Installed:
                    return(1);

                case BundleInitializedState.Active:
                    return(0);
                }
            }
            return(null);
        }
コード例 #2
0
ファイル: HostBundle.cs プロジェクト: yshulin/OSGi
 protected override void DoStart(BundleStartOptions option)
 {
     if (((base.State != BundleState.Starting) && (base.State != BundleState.Stopping)) && !base.IsActive)
     {
         if (!base.IsResolved)
         {
             base.Framework.FrameworkAdaptor.State.Resolve();
             if (!base.IsResolved)
             {
                 throw new BundleException($"The bundle '{base.SymbolicName}, {base.Version}' is started failed since it can not be resolved.");
             }
         }
         if (LicenseService.RequireBundleLicenseValidation)
         {
             try
             {
                 LicenseService.ValidateBundleLicense(base.BundleData, true);
             }
             catch (Exception exception)
             {
                 FileLogUtility.Error(exception);
                 return;
             }
         }
         if ((base.BundleData.Activator == null) || (base.BundleData.Activator.Policy != ActivatorPolicy.Lazy))
         {
             base.State = BundleState.Starting;
             if (option != BundleStartOptions.Transient)
             {
                 BundlePersistentData persistentData = this.GetPersistentData();
                 if ((persistentData != null) && (persistentData.State == BundleState.Active))
                 {
                     this.CallTryStart();
                     return;
                 }
             }
             this.CallTryStart();
             if (option != BundleStartOptions.Transient)
             {
                 this.SavePersistent();
             }
         }
         else if (base.State != BundleState.Starting)
         {
             base.State = BundleState.Starting;
             base.Framework.EventManager.DispatchBundleLazyActivateEvent(this, new BundleLazyActivatedEventArgs(this));
         }
     }
 }
コード例 #3
0
ファイル: HostBundle.cs プロジェクト: yshulin/OSGi
        public object Load(string file)
        {
            string path = string.IsNullOrEmpty(file) ? this.GetDefaultPersistFile() : file;

            if (!File.Exists(path))
            {
                return(null);
            }
            BundlePersistentData data = new BundlePersistentData();

            data.Load(path);
            if (data == null)
            {
                throw new Exception($"Load persistent file {path} fail!");
            }
            return(data);
        }