Class SingleComponentManager<S>

  • All Implemented Interfaces:
    ComponentManager<S>, org.osgi.framework.ServiceFactory<S>
    Direct Known Subclasses:
    ServiceFactoryComponentManager

    public class SingleComponentManager<S>
    extends AbstractComponentManager<S>
    implements org.osgi.framework.ServiceFactory<S>
    The default ComponentManager. Objects of this class are responsible for managing implementation object's lifecycle.
    • Field Detail

      • m_useCount

        private final java.util.concurrent.atomic.AtomicInteger m_useCount
      • m_configurationProperties

        private java.util.Map<java.lang.String,​java.lang.Object> m_configurationProperties
      • m_factoryProperties

        private java.util.Map<java.lang.String,​java.lang.Object> m_factoryProperties
      • m_properties

        private java.util.Map<java.lang.String,​java.lang.Object> m_properties
      • m_serviceProperties

        private java.util.Dictionary<java.lang.String,​java.lang.Object> m_serviceProperties
    • Constructor Detail

      • SingleComponentManager

        public SingleComponentManager​(ComponentContainer<S> container,
                                      ComponentMethods<S> componentMethods)
        The constructor receives both the activator and the metadata
        Parameters:
        componentMethods -
    • Method Detail

      • clearServiceProperties

        void clearServiceProperties()
      • getComponentInstance

        public org.osgi.service.component.ComponentInstance<S> getComponentInstance()
      • getInstance

        private S getInstance()
        Get the object that is implementing this descriptor
        Returns:
        the object that implements the services
      • disposeImplementationObject

        protected void disposeImplementationObject​(ComponentContextImpl<S> componentContext,
                                                   int reason)
      • setFactoryProperties

        protected void setFactoryProperties​(java.util.Dictionary<java.lang.String,​?> dictionary)
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties()
        Returns the (private copy) of the Component properties to be used for the ComponentContext as well as eventual service registration.

        Method implements the Component Properties provisioning as described in 112.6, Component Properties.

        Specified by:
        getProperties in interface ComponentManager<S>
        Specified by:
        getProperties in class AbstractComponentManager<S>
        Returns:
        a private map of component properties
      • getServiceProperties

        public java.util.Dictionary<java.lang.String,​java.lang.Object> getServiceProperties()
        Description copied from class: AbstractComponentManager
        Returns the subset of component properties to be used as service properties. These properties are all component properties where property name does not start with dot (.), properties which are considered private.
        Overrides:
        getServiceProperties in class AbstractComponentManager<S>
      • getServiceReference

        final org.osgi.framework.ServiceReference<S> getServiceReference()
      • updateServiceRegistration

        private void updateServiceRegistration()
      • reconfigure

        public void reconfigure​(java.util.Map<java.lang.String,​java.lang.Object> configuration,
                                boolean configurationDeleted,
                                TargetedPID factoryPid)
        Called by the Configuration Admin Service to update the component with Configuration properties.

        This causes the component to be reactivated with the new configuration unless no configuration has ever been set on this component and the configuration parameter is null. In this case nothing is to be done. If a configuration has previously been set and now the configuration is deleted, the configuration parameter is null and the component has to be reactivated with the default configuration.

        Specified by:
        reconfigure in class AbstractComponentManager<S>
        Parameters:
        configuration - The configuration properties for the component from the Configuration Admin Service or null if there is no configuration or if the configuration has just been deleted.
        configurationDeleted - TODO
        factoryPid - TODO
      • reconfigure

        void reconfigure​(boolean configurationDeleted)
      • modify

        private boolean modify​(boolean configurationDeleted)
      • invokeModifiedMethod

        protected MethodResult invokeModifiedMethod()
      • servicePropertiesMatches

        private boolean servicePropertiesMatches​(org.osgi.framework.ServiceRegistration<S> reg,
                                                 java.util.Dictionary<java.lang.String,​java.lang.Object> props)
        Checks if the given service registration properties matches another set of properties.
        Parameters:
        reg - the service registration whose service properties will be compared to the props parameter
        props - the properties to be compared with the registration service properties.
        Returns:
        true if the registration service properties equals the prop properties, false if not.
      • getService

        public S getService​(org.osgi.framework.Bundle bundle,
                            org.osgi.framework.ServiceRegistration<S> serviceRegistration)
        Specified by:
        getService in interface org.osgi.framework.ServiceFactory<S>
      • ungetService

        public void ungetService​(org.osgi.framework.Bundle bundle,
                                 org.osgi.framework.ServiceRegistration<S> serviceRegistration,
                                 S o)
        Specified by:
        ungetService in interface org.osgi.framework.ServiceFactory<S>
      • keepInstances

        private boolean keepInstances()