Class BundleComponentActivator

    • Field Detail

      • m_bundle

        private final org.osgi.framework.Bundle m_bundle
      • m_context

        private final org.osgi.framework.BundleContext m_context
      • m_active

        private final java.util.concurrent.atomic.AtomicBoolean m_active
      • m_closeLatch

        private final java.util.concurrent.CountDownLatch m_closeLatch
    • Constructor Detail

      • BundleComponentActivator

        public BundleComponentActivator​(ScrLogger scrLogger,
                                        ComponentRegistry componentRegistry,
                                        ComponentActorThread componentActor,
                                        org.osgi.framework.BundleContext context,
                                        ScrConfiguration configuration)
                                 throws org.osgi.service.component.ComponentException
        Called upon starting of the bundle. This method invokes initialize() which parses the metadata and creates the holders
        Parameters:
        componentRegistry - The ComponentRegistry used to register components with to ensure uniqueness of component names and to ensure configuration updates.
        context - The bundle context owning the components
        Throws:
        org.osgi.service.component.ComponentException - if any error occurrs initializing this class
    • Method Detail

      • initialize

        protected void initialize​(java.lang.String descriptorLocations)
        Gets the MetaData location, parses the meta data and requests the processing of binder instances
        Parameters:
        descriptorLocations - A comma separated list of locations of component descriptors. This must not be null.
        Throws:
        java.lang.IllegalStateException - If the bundle has already been uninstalled.
      • initialEnable

        void initialEnable()
        Called outside the constructor so that the m_managers field is completely initialized. A component might possibly start a thread to enable other components, which could access m_managers
      • findDescriptors

        static java.net.URL[] findDescriptors​(org.osgi.framework.Bundle bundle,
                                              java.lang.String descriptorLocation)
        Finds component descriptors based on descriptor location.
        Parameters:
        bundle - bundle to search for descriptor files
        descriptorLocation - descriptor location
        Returns:
        array of descriptors or empty array if none found
      • loadDescriptor

        private void loadDescriptor​(java.net.URL descriptorURL)
      • dispose

        void dispose​(int reason)
        Dispose of this component activator instance and all the component managers.
      • isActive

        public boolean isActive()
        Returns if this instance is active, that is if components may be activated for this component. The active flag is set early in the constructor indicating the activator is basically active (not fully setup, though) and reset early in the process of disposing this instance.
        Specified by:
        isActive in interface ComponentActivator
      • getBundleContext

        public org.osgi.framework.BundleContext getBundleContext()
        Returns the BundleContext
        Specified by:
        getBundleContext in interface ComponentActivator
        Returns:
        the BundleContext
      • enableComponent

        public void enableComponent​(java.lang.String name)
        Implements the ComponentContext.enableComponent(String) method by first finding the component(s) for the name and enabling them. The enable method will schedule activation.

        Specified by:
        enableComponent in interface ComponentActivator
        Parameters:
        name - The name of the component to enable or null to enable all components.
      • disableComponent

        public void disableComponent​(java.lang.String name)
        Implements the ComponentContext.disableComponent(String) method by first finding the component(s) for the name and disabling them. The disable method will schedule deactivation

        Specified by:
        disableComponent in interface ComponentActivator
        Parameters:
        name - The name of the component to disable or null to disable all components.
      • getSelectedComponents

        private java.util.List<ComponentHolder<?>> getSelectedComponents​(java.lang.String name)
        Returns an array of ComponentHolder instances which match the name. If the name is null an array of all currently known component managers is returned. Otherwise an array containing a single component manager matching the name is returned if one is registered. Finally, if no component manager with the given name is registered, null is returned.
        Parameters:
        name - The name of the component manager to return or null to return an array of all component managers.
        Returns:
        An array containing one or more component managers according to the name parameter or null if no component manager with the given name is currently registered.
      • schedule

        public void schedule​(java.lang.Runnable task)
        Schedules the given task for asynchrounous execution or synchronously runs the task if the thread is not running. If this instance is not active, the task is not executed.
        Specified by:
        schedule in interface ComponentActivator
        Parameters:
        task - The component task to execute
      • enterCreate

        public <T> boolean enterCreate​(org.osgi.framework.ServiceReference<T> serviceReference)
        Specified by:
        enterCreate in interface ComponentActivator
      • leaveCreate

        public <T> void leaveCreate​(org.osgi.framework.ServiceReference<T> serviceReference)
        Specified by:
        leaveCreate in interface ComponentActivator
      • missingServicePresent

        public <T> void missingServicePresent​(org.osgi.framework.ServiceReference<T> serviceReference)
        Specified by:
        missingServicePresent in interface ComponentActivator