예제 #1
0
        /// <summary>
        /// 启动
        /// </summary>
        public void Start()
        {
            log.Debug(string.Format("模块{0}启动开始!", this.GetBundleAssemblyFileName()));

            if (this.state == BundleStateConst.INSTALLED)
            {
                try
                {
                    Resolve();
                }
                catch (Exception ex)
                {
                    this.state = BundleStateConst.INSTALLED;
                    log.Debug(string.Format("模块{0}启动失败!", this.GetBundleAssemblyFileName()));
                    throw ex;
                }
            }
            if (this.state == BundleStateConst.RESOLVED)
            {
                this.state = BundleStateConst.STARTING;

                try
                {
                    var frameworkFireEvent = (IFrameworkFireEvent)framework;
                    frameworkFireEvent.FireBundleEvent(new BundleEventArgs(BundleEventArgs.STARTING, this));

                    if (this.activatorClass != null)
                    {
                        log.Debug("激活器启动!");
                        bundleActivator = Activator.CreateInstance(activatorClass) as IBundleActivator;
                        //启动激活器
                        bundleActivator.Start(bundleContext);

                        log.Debug("加载扩展点数据!");
                        //初始化扩展信息
                        LoadExtensions();
                    }
                    this.state = BundleStateConst.ACTIVE;

                    frameworkFireEvent.FireBundleEvent(new BundleEventArgs(BundleEventArgs.STARTED, this));
                }
                catch (Exception ex)
                {
                    this.state = BundleStateConst.RESOLVED;
                    log.Debug(string.Format("模块{0}启动失败!", this.GetBundleAssemblyFileName()));
                    throw ex.InnerException;
                }
            }

            log.Debug(string.Format("模块{0}启动结束!", this.GetBundleAssemblyFileName()));
        }
예제 #2
0
        /// <summary>
        /// 启动激活器
        /// </summary>
        /// <param name="bundleActivator"></param>
        internal void StartActivator(IBundleActivator bundleActivator)
        {
            try
            {
                if (bundleActivator != null)
                {
                    bundleActivator.Start(this);
                }
            }
            catch (Exception ex)
            {
                string clazz = null;
                clazz = bundleActivator.GetType().FullName;

                throw new BundleException(string.Format("Activator Start Exception. [Clazz:{0}] - [Method:{1}] -[Bundle:{2}] ", new object[] { clazz, "start", string.IsNullOrEmpty(bundle.SymbolicName) ? "" + bundle.BundleId : bundle.SymbolicName }), ex, BundleExceptionType.ACTIVATOR_ERROR); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
예제 #3
0
        public void Start()
        {
            try
            {
                this.state = BundleState.Starting;

                IBundleActivator activator = this.Activator;
                if (activator == null)
                {
                    throw new Exception("No activator for: " + this.Location);
                }

                activator.Start(this.Context);
                this.state = BundleState.Active;
            }
            catch (Exception e)
            {
                this.state = BundleState.Installed;
                TracesProvider.TracesOutput.OutputTrace(e.Message);
                throw new BundleException(e.Message, e);
            }
        }