//////////////////////////////////////////////////////////////////////////
        public override void Start(BundleStartOption options)
        {
            /*
            The following steps are taken to start this Framework:
            1.If this Framework is not in the Bundle.STARTING state, initialize this Framework.
            2.All installed bundles must be started in accordance with each bundle's persistent autostart setting.
             * This means some bundles will not be started, some will be started with eager activation
             * and some will be started with their declared activation policy.
             * If this Framework implements the optional Start Level Service Specification, then the start
             * level of this Framework is moved to the start level specified by the beginning start level
             * framework property, as described in the Start Level Service Specification.
             * If this framework property is not specified, then the start level of this Framework
             * is moved to start level one (1). Any exceptions that occur during bundle starting must be
             * wrapped in a BundleException and then published as a framework event of type FrameworkEvent.ERROR
            3.This Framework's state is set to Bundle.ACTIVE.
            4.A framework event of type FrameworkEvent.STARTED is fired
            */

            lock (m_lock)
            {
                if (getState() == BundleState.ACTIVE)
                    return;

                if (getState() != BundleState.STARTING)
                    Init();

                setState(BundleState.ACTIVE);
                RaiseFrameworkEvent(new FrameworkEvent(FrameworkEvent.Type.STARTED, this, null));
            }
        }
Example #2
0
        //////////////////////////////////////////////////////////////////////////

        public virtual void Start(BundleStartOption options)
        {
            // TODO: replace with timeout-based lock
            // TODO: add start-level support

            lock (m_lock)
            {
                if (m_state == BundleState.UNINSTALLED)
                {
                    throw new BundleException("Bundle is uninstalled", BundleException.ErrorCode.ILLEGAL_STATE);
                }

                if (m_state == BundleState.ACTIVE)
                {
                    return;
                }

                if (m_state == BundleState.INSTALLED)
                {
                    Resolve();
                    Debug.Assert(m_state == BundleState.RESOLVED);
                }

                PreStart();
                Debug.Assert(m_state == BundleState.STARTING);

                if (m_activator != null)
                {
                    try
                    {
                        m_activator.Start(m_context);
                    }
                    catch (Exception ex)
                    {
                        PreStop();
                        PostStop();
                        throw new BundleException("Bundle activation failed", BundleException.ErrorCode.ACTIVATOR_ERROR, ex);
                    }

                    if (m_state == BundleState.UNINSTALLED)
                    {
                        throw new BundleException("Bundle was unregistered in time of activation");
                    }
                }

                PostStart();
            }
        }
        //////////////////////////////////////////////////////////////////////////
        public override void Start(BundleStartOption options)
        {
            /*
            The following steps are taken to start this Framework:
            1.If this Framework is not in the Bundle.STARTING state, initialize this Framework.
            2.All installed bundles must be started in accordance with each bundle's persistent autostart setting.
             * This means some bundles will not be started, some will be started with eager activation
             * and some will be started with their declared activation policy.
             * If this Framework implements the optional Start Level Service Specification, then the start
             * level of this Framework is moved to the start level specified by the beginning start level
             * framework property, as described in the Start Level Service Specification.
             * If this framework property is not specified, then the start level of this Framework
             * is moved to start level one (1). Any exceptions that occur during bundle starting must be
             * wrapped in a BundleException and then published as a framework event of type FrameworkEvent.ERROR
            3.This Framework's state is set to Bundle.ACTIVE.
            4.A framework event of type FrameworkEvent.STARTED is fired
            */

            lock (m_lock)
            {
                if (m_state == BundleState.ACTIVE)
                    return;

                if (m_state != BundleState.STARTING)
                    Init();

                m_state = BundleState.ACTIVE;
                RaiseFrameworkEvent(new FrameworkEvent(FrameworkEvent.Type.STARTED, this, null));
            }
        }
Example #4
0
        //////////////////////////////////////////////////////////////////////////
        public virtual void Start(BundleStartOption options)
        {
            // TODO: replace with timeout-based lock
            // TODO: add start-level support

            lock(m_lock)
            {
                if(m_state == BundleState.UNINSTALLED)
                    throw new BundleException("Bundle is uninstalled", BundleException.ErrorCode.ILLEGAL_STATE);

                if(m_state == BundleState.ACTIVE)
                    return;

                if(m_state == BundleState.INSTALLED)
                {
                    Resolve();
                    Debug.Assert(m_state == BundleState.RESOLVED);
                }

                PreStart();
                Debug.Assert(m_state == BundleState.STARTING);

                if(m_activator != null)
                {
                    try
                    {
                        m_activator.Start(m_context);
                    }
                    catch(Exception ex)
                    {
                        PreStop();
                        PostStop();
                        throw new BundleException("Bundle activation failed", BundleException.ErrorCode.ACTIVATOR_ERROR, ex);
                    }

                    if(m_state == BundleState.UNINSTALLED)
                        throw new BundleException("Bundle was unregistered in time of activation");
                }

                PostStart();
            }
        }