[ https://issues.apache.org/jira/browse/FELIX-2994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre De Rop updated FELIX-2994: --------------------------------- Attachment: FELIX-2994.tgz attached the proposed implementation for delayed components. > Delayed Components in Dependency Manager > ---------------------------------------- > > Key: FELIX-2994 > URL: https://issues.apache.org/jira/browse/FELIX-2994 > Project: Felix > Issue Type: Improvement > Components: Dependency Manager > Reporter: Pierre De Rop > Priority: Minor > Attachments: FELIX-2994.tgz > > > This issue proposes a lightweight implementation for the support of "delayed > components" in Dependency Manager. > (see patch attached to this issue). > It allows components to delay their possibly expensive activation until they > are really used, and allows > Dependency Manager to instantiate/initialize components only as needed. > For system where many services are installed, and where not every services > are actually used, then this feature > can significantly speed up startup time, especially when some unused > components require an expensive > processing from their "init" / "start" methods. > A new "setDelayed(boolean)" method has been added in the Component interface, > and also a new "delayed" state > has been added in the ComponentDeclaration, allowing to browse delayed > components from the DM shell. > Here is a code example which defines a delayed component: > dm.add(createComponent() > .setImplementation(DelayedServiceImpl.class) > .setInterface(DelayedService.class.getName, null) > .setDelayed(true)); > Implementation notes > -------------------------- > - By default, components are not delayed (as before). > - A new DelayedComponentTest has been added in the test sub-project > > - This implementation is simple and is not intrusive: DM core classes > *have not* been modified > (excepts a micro-modif in ComponentImpl.java, and in > ComponentDeclaration.java). Basically, > we track every service listeners, and when a listener is matching a > delayed component, then > the component is started. Else, the component is not started, hence > avoiding the useless component > instantiation/initialization. > - A new state has been added in the ComponentDeclaration class > (STATE_DELAYED), allowing to track > delayed components from the Dependency Manager shell. > - The new filter index recently introduced in DM has not yet been used, > but it might be useful to > integrate it in the delayed component manager, since the DM indexer > greatly speeds up service listeners lookup, > especially when using many (thousands) of services. But this enhancement > could be done in a next step. > - The ListenerHook (from ServiceHook specification) is used for the > implementation: this allows to trigger the > activation of DM delayed components not only using DependencyManager > dependencies, but also using other libraries, > like Declarative Service, iPOJO, blueprint, or even ServiceTracker. > This is important because > in our environment, we are using both dependency manager and Declarative > Service, and we need to be able to > activate a delayed DM component from a Declarative Service "Reference" > dependency. ListenerHook > allows to do this because using ListenerHook, we are able to track every > service listeners registered in the framework. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira