Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////
        public void Init()
        {
            /*
            After calling this method, this Framework must:
            Be in the Bundle.STARTING state.
            Have a valid Bundle Context.
            Be at start level 0.
            Have event handling enabled.
            Have reified Bundle objects for all installed bundles.
            Have registered any framework services. For example, PackageAdmin, ConditionalPermissionAdmin, StartLevel.
            This Framework will not actually be started until start is called.

            This method does nothing if called when this Framework is in the Bundle.STARTING, Bundle.ACTIVE or Bundle.STOPPING states.
            */

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

                m_shutdownResult = new FrameworkEvent(FrameworkEvent.Type.STOPPED, this, null);
                m_bundleRepository = new CBundleRepository(this);
                m_serviceRegistry = new CServiceRegistry(this);
                m_eventServer = new CEventServer();

                m_bundleListeners = new ListenerQueue<IBundleListener>();
                m_syncBundleListeners = new ListenerQueue<ISynchronousBundleListener>();
                m_frameworkListeners = new ListenerQueue<IFrameworkListener>();
                m_serviceListeners = new ListenerQueue<IServiceListener>();
                m_allServiceListeners = new ListenerQueue<IAllServiceListener>();

                if(getState() == BundleState.INSTALLED)
                    setState(BundleState.RESOLVED);
                setState(BundleState.STARTING);

                m_context = new CBundleContext(this, this);
                m_activator = new CSystemBundleActivator();
                m_activator.Start(m_context);
            }
        }
Ejemplo n.º 2
0
        //////////////////////////////////////////////////////////////////////////
        void doStop(object dummy)
        {
            /*
            The method returns immediately to the caller after initiating the following steps to be taken on another thread.

            1.This Framework's state is set to Bundle.STOPPING.
            2.All installed bundles must be stopped without changing each bundle's persistent autostart setting.
             * If this Framework implements the optional Start Level Service Specification, then the start
             * level of this Framework is moved to start level zero (0), as described in the Start Level
             * Service Specification. Any exceptions that occur during bundle stopping must be wrapped in a
             * BundleException and then published as a framework event of type FrameworkEvent.ERROR
            3.Unregister all services registered by this Framework.
            4.Event handling is disabled.
            5.This Framework's state is set to Bundle.RESOLVED.
            6.All resources held by this Framework are released. This includes threads, bundle class loaders, open files, etc.
            7.Notify all threads that are waiting at waitForStop that the stop operation has completed.
            8.After being stopped, this Framework may be discarded, initialized or started.
            */

            lock (m_lock)
            {
                m_activator.Stop(m_context);

                setState(BundleState.RESOLVED);

                m_eventServer.WaitAll(0);

                m_context.Dispose();
                m_context = null;

                m_bundleRepository = null;
                m_serviceRegistry = null;
                m_eventServer = null;

                m_shutdownResult = new FrameworkEvent(FrameworkEvent.Type.STOPPED, this, null);
                Monitor.PulseAll(m_lock);
            }
        }
Ejemplo n.º 3
0
        //////////////////////////////////////////////////////////////////////////
        public void Init()
        {
            /*
            After calling this method, this Framework must:
            Be in the Bundle.STARTING state.
            Have a valid Bundle Context.
            Be at start level 0.
            Have event handling enabled.
            Have reified Bundle objects for all installed bundles.
            Have registered any framework services. For example, PackageAdmin, ConditionalPermissionAdmin, StartLevel.
            This Framework will not actually be started until start is called.

            This method does nothing if called when this Framework is in the Bundle.STARTING, Bundle.ACTIVE or Bundle.STOPPING states.
            */

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

                m_bundleRepository = new CBundleRepository(this);
                m_serviceRegistry = new CServiceRegistry(this);
                m_eventServer = new CEventServer();

                m_bundleListeners = new ListenerQueue<IBundleListener>();
                m_syncBundleListeners = new ListenerQueue<ISynchronousBundleListener>();
                m_frameworkListeners = new ListenerQueue<IFrameworkListener>();
                m_serviceListeners = new ListenerQueue<IServiceListener>();
                m_allServiceListeners = new ListenerQueue<IAllServiceListener>();

                m_state = BundleState.STARTING;
                m_context = new CBundleContext(this, this);
                m_activator = new CSystemBundleActivator();
                m_activator.Start(m_context);
            }
        }
Ejemplo n.º 4
0
        //////////////////////////////////////////////////////////////////////////
        void doStop(object dummy)
        {
            /*
            The method returns immediately to the caller after initiating the following steps to be taken on another thread.

            1.This Framework's state is set to Bundle.STOPPING.
            2.All installed bundles must be stopped without changing each bundle's persistent autostart setting.
             * If this Framework implements the optional Start Level Service Specification, then the start
             * level of this Framework is moved to start level zero (0), as described in the Start Level
             * Service Specification. Any exceptions that occur during bundle stopping must be wrapped in a
             * BundleException and then published as a framework event of type FrameworkEvent.ERROR
            3.Unregister all services registered by this Framework.
            4.Event handling is disabled.
            5.This Framework's state is set to Bundle.RESOLVED.
            6.All resources held by this Framework are released. This includes threads, bundle class loaders, open files, etc.
            7.Notify all threads that are waiting at waitForStop that the stop operation has completed.
            8.After being stopped, this Framework may be discarded, initialized or started.
            */

            lock (m_lock)
            {
                m_activator.Stop(m_context);

                setState(BundleState.RESOLVED);

                m_eventServer.WaitAll(0);

                m_context.Dispose();
                m_context = null;

                m_bundleRepository = null;
                m_serviceRegistry = null;
                m_eventServer = null;

                m_shutdownResult = new FrameworkEvent(FrameworkEvent.Type.STOPPED, this, null);
                Monitor.PulseAll(m_lock);
            }
        }