Beispiel #1
0
 /// <summary>
 /// 停止插件处理器
 /// </summary>
 /// <param name="options"></param>
 protected override void StopWorker(BundleOptions option)
 {
     if (framework.IsActive)
     {
         if ((state & (BundleState.Stopping | BundleState.Resolved | BundleState.Installed))
             != BundleState.None)
         {
             return;
         }
         state = BundleState.Stopping;
         // 发布事件
         try
         {
             if (context != null)
             {
                 context.Stop();
             }
         }
         finally
         {
             if (context != null)
             {
                 context.Close();
                 context = null;
             }
             state = BundleState.Resolved;
             // 发布事件
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// 启动插件处理器
 /// </summary>
 /// <param name="option"></param>
 protected override void StartWorker(BundleOptions option)
 {
     if (!framework.IsActive || state == BundleState.Active)
     {
         return;
     }
     if (state == BundleState.Installed)
     {
         if (!framework.packageAdmin.ResolveBundles(new IBundle[] { this }))
         {
             throw new BundleException("插件解析失败", BundleExceptionType.RESOLVE_ERROR);
         }
     }
     if (option == BundleOptions.Transient)
     {
         if (state == BundleState.Resolved)
         {
             // 设置当前状态为待启动状态
             state = BundleState.Starting;
             // 设置加载器状态为懒加载待启动状态
             AbstractClassLoader loader = (AbstractClassLoader)this.BundleLoader;
             loader.SetLazyTrigger();
             // 完成状态变化
             CompleteStateChange();
             // 解析扩展包
             framework.packageAdmin.ResolveExtension(this);
         }
         return;
     }
     state = BundleState.Starting;
     // 发布启动事件
     try
     {
         this.BundleContext.Start();
         if (framework.IsActive)
         {
             state = BundleState.Active;
             framework.packageAdmin.ResolveExtension(this);
             CompleteStateChange();
         }
     }
     catch (Exception ex)
     {
         state = BundleState.Stopping;
         context.Close();
         context = null;
         state   = BundleState.Resolved;
         // 发布事件
         throw ex;
     }
 }
        /// <summary>
        /// 停止操作
        /// </summary>
        /// <param name="context"></param>
        public void Stop(IBundleContext context)
        {
            if (packageAdmin != null)
            {
                packageAdmin.Unregister();
            }
            if (startLevel != null)
            {
                startLevel.Unregister();
            }

            framework    = null;
            bundle       = null;
            this.context = null;
        }
        /// <summary>
        /// 启动操作
        /// </summary>
        /// <param name="context"></param>
        public void Start(IBundleContext context)
        {
            this.context = context as BundleContextImpl;
            bundle       = (SystemBundle)context.Bundle;
            framework    = bundle.Framework;

            if (framework.packageAdmin != null)
            {
                packageAdmin = Register(new String[] { ConfigConstant.BUNDLE_PACKAGEADMIN_NAME }, framework.packageAdmin, null);
            }
            if (framework.startLevelManager != null)
            {
                startLevel = Register(new String[] { ConfigConstant.BUNDLE_STARTLEVEL_NAME }, framework.startLevelManager, null);
            }
        }
Beispiel #5
0
 public BundleHost(IBundleData bundledata, Framework framework)
     : base(bundledata, framework)
 {
     context   = null;
     fragments = null;
 }