| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| <title>Dependency Manager - Components :: Apache Felix</title> |
| <link rel="canonical" href="https://felix.apache.org/documentation/subprojects/apache-felix-dependency-manager/reference/components.html"> |
| <meta name="generator" content="Antora 2.3.4"> |
| <link rel="stylesheet" href="../../../../_/css/site.css"> |
| <link rel="icon" href="../../../../_/img/favicon.png" type="image/x-icon"> |
| </head> |
| <body class="article"> |
| <header class="header"> |
| <nav class="navbar"> |
| <div class="navbar-brand"> |
| <a class="navbar-item" href="https://felix.apache.org/index.html"> |
| <span> |
| <img src="../../../../_/img/logo.png"> |
| </span> |
| </a> |
| <button class="navbar-burger" data-target="topbar-nav"> |
| <span></span> |
| <span></span> |
| <span></span> |
| </button> |
| </div> |
| <div id="topbar-nav" class="navbar-menu"> |
| <div class="navbar-end"> |
| <a class="navbar-item" href="https://felix.apache.org/index.html">Home</a> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Subprojects</a> |
| <div class="navbar-dropdown"> |
| <a class="navbar-item" href="../../apache-felix-dependency-manager.html">Dependency Manager</a> |
| <a class="navbar-item" href="../../apache-felix-event-admin.html">Event Admin</a> |
| <a class="navbar-item" href="../../apache-felix-file-install.html">File Install</a> |
| <a class="navbar-item" href="../../apache-felix-framework.html">Framework</a> |
| <a class="navbar-item" href="../../apache-felix-gogo.html">Gogo Shell</a> |
| <a class="navbar-item" href="../../apache-felix-healthchecks.html">Health Checks</a> |
| <a class="navbar-item" href="../../apache-felix-inventory.html">Inventory</a> |
| <a class="navbar-item" href="../../apache-felix-log.html">Log</a> |
| <a class="navbar-item" href="../../apache-felix-logback.html">Logback</a> |
| <a class="navbar-item" href="../../apache-felix-maven-bundle-plugin.html">Maven bundle plugin</a> |
| <a class="navbar-item" href="../../apache-felix-maven-scr-plugin.html">Maven SCR plugin</a> |
| <a class="navbar-item" href="../../apache-felix-metatype-service.html">Metatype Service</a> |
| <a class="navbar-item" href="../../apache-felix-preferences-service.html">Preferences Service</a> |
| <a class="navbar-item" href="../../apache-felix-remote-shell.html">Remote Shell</a> |
| <a class="navbar-item" href="../../apache-felix-script-console-plugin.html">Script console plugin</a> |
| <a class="navbar-item" href="../../apache-felix-shell.html">Lightweight shell</a> |
| <a class="navbar-item" href="../../apache-felix-shell-tui.html">Shell TUI</a> |
| <a class="navbar-item" href="../../apache-felix-web-console.html">Web Console</a> |
| </div> |
| </div> |
| <div class="navbar-item"> |
| <span class="control"> |
| <a class="button is-primary" href="../../../downloads.html">Downloads</a> |
| </span> |
| </div> |
| </div> |
| </div> |
| </nav> |
| </header> |
| <div class="body"> |
| <div class="nav-container" data-component="documentation" data-version="master"> |
| <aside class="nav"> |
| <div class="panels"> |
| <div class="nav-panel-menu is-active" data-panel="menu"> |
| <nav class="nav-menu"> |
| <h3 class="title"><a href="../../../index.html">Documentation</a></h3> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="0"> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../documentation.html">Documentation</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../downloads.html">Downloads</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../getting-started.html">Getting Started</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../news.html">News</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Community</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../community/project-info.html">Apache Felix Project Info</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../community/contributing.html">Contributing</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../community/projects-using-felix.html">Projects Using Felix</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Development</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/coding-standards.html">Coding Standards</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/dependencies-file-template.html">DEPENDENCIES file template</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/provisional-osgi-api-policy.html">Provisional OSGi API Policy</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/release-management-nexus.html">Release Management</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/site-how-to.html">Site How To</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../development/using-the-osgi-compliance-tests.html">Using the OSGi Compliance Tests</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../../faqs.html">FAQS</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../faqs/apache-felix-bundle-plugin-faq.html">Apache Felix Bundle Plugin Frequently Asked Questions</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../faqs/apache-felix-scr-plugin-faq.html">Apache Felix SCR Plugin Frequently Asked Questions</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../../subprojects.html">Subprojects</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="3"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Guides</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/migrating-from-earlier-versions.html">Apache Felix Dependency Manager - Migrating from earlier versions</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/annotations.html">Dependency Manager - Annotations</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/background.html">Dependency Manager - Background</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/bundles-and-dependencies.html">Dependency Manager - Bundles and Dependencies</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/design-patterns.html">Dependency Manager - Design Patterns</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/development.html">Dependency Manager - Development</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/history.html">Dependency Manager - History</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/javadocs.html">Dependency Manager - JavaDocs</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/migrating-from-other-solutions.html">Dependency Manager - Migrating from other solutions.</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/performance-tuning.html">Dependency Manager - Performance Tuning</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/resources.html">Dependency Manager - Resource adapters</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/whatsnew.html">Dependency Manager - What’s new in version 4?</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/dm-lambda.html">Dependency Manager Lambda</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../guides/whatsnew-r15.html">What’s New in R15</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Reference</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-adapter.html">Dependency Manager - Adapter</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-aspect.html">Dependency Manager - Aspect</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-bundle-adapter.html">Dependency Manager - Bundle Adapter</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dependency-bundle.html">Dependency Manager - Bundle Dependency</a> |
| </li> |
| <li class="nav-item is-current-page" data-depth="4"> |
| <a class="nav-link" href="components.html">Dependency Manager - Components</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dependency-configuration.html">Dependency Manager - Configuration Dependency</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dependencies.html">Dependency Manager - Dependencies</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="external-links.html">Dependency Manager - External Links</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-factory-configuration-adapter.html">Dependency Manager - Factory Configuration Adapter Service</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-resource-adapter.html">Dependency Manager - Resource Adapter</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dependency-resource.html">Dependency Manager - Resource Dependency</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dependency-service.html">Dependency Manager - Service Dependency</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="service-scopes.html">Dependency Manager - Service Scopes</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="component-singleton.html">Dependency Manager - Singleton Component</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="thread-model.html">Dependency Manager - Thread Model</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="dm-annotations.html">Dependency Manager Annotations</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Tutorials</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../tutorials/working-with-annotations.html">Dependency Manager - Annotations</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../tutorials/getting-started.html">Dependency Manager - Getting Started</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../tutorials/leveraging-the-shell.html">Dependency Manager - Leveraging the shell</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../tutorials/sample-code.html">Dependency Manager sample projects</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-event-admin.html">Apache Felix Event Admin</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-file-install.html">Apache Felix File Install</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../apache-felix-framework.html">Apache Felix Framework</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-framework/apache-felix-framework-bundle-cache.html">Apache Felix Framework Bundle Cache</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-framework/apache-felix-framework-configuration-properties.html">Apache Felix Framework Configuration Properties</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-framework/apache-felix-framework-faq.html">Apache Felix Framework Frequently Asked Questions</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-framework/apache-felix-framework-launching-and-embedding.html">Apache Felix Framework Launching and Embedding</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-framework/apache-felix-framework-usage-documentation.html">Apache Felix Framework Usage Documentation</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-framework-security.html">Apache Felix Framework Security</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../apache-felix-gogo.html">Apache Felix Gogo</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-gogo/rfc-147-overview.html">RFC 147 Overview</a> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-healthchecks.html">Apache Felix Health Checks</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-inventory.html">Apache Felix Inventory Printer</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-log.html">Apache Felix Log</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-logback.html">Apache Felix Logback</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-maven-bundle-plugin-bnd.html">Apache Felix Maven Bundle Plugin (BND)</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-metatype-service.html">Apache Felix Metatype Service</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-osgi-bundle-repository.html">Apache Felix OSGi Bundle Repository (OBR)</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-preferences-service.html">Apache Felix Preferences Service</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-remote-shell.html">Apache Felix Remote Shell</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-shell.html">Apache Felix Shell</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../apache-felix-shell-tui.html">Apache Felix Shell TUI</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../apache-felix-web-console.html">Apache Felix Web Console</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console.html">Extending the Apache Felix Web Console</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-web-console/web-console-restful-api.html">Web Console RESTful API</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../apache-felix-web-console/web-console-security-provider.html">Web Console Security Provider</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Extensions</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console/branding-the-web-console.html">Branding the Web Console</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console/providing-resources.html">Providing Resources</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console/providing-web-console-plugins.html">Providing Web Console Plugins</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console/web-console-logging.html">Web Console Logging</a> |
| </li> |
| <li class="nav-item" data-depth="4"> |
| <a class="nav-link" href="../../apache-felix-web-console/extending-the-apache-felix-web-console/web-console-output-templating.html">Web Console Output Templating</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations.html">Tutorials</a> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-application-demonstration.html">Apache Felix Application Demonstration</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial.html">Apache Felix OSGi Tutorial</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-faq.html">OSGi Frequently Asked Questions</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">OSGI Tutorial</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-1.html">Apache Felix Tutorial Example 1 - Service Event Listener Bundle</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-2.html">Apache Felix Tutorial Example 2</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-2b.html">Apache Felix Tutorial Example 2b</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-3.html">Apache Felix Tutorial Example 3</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-4.html">Apache Felix Tutorial Example 4</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-5.html">Apache Felix Tutorial Example 5</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-6.html">Example 6 - Spell Checker Service Bundle</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-7.html">Example 7 - Spell Checker Client Bundle</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-8.html">Example 8 - Spell Checker Service using Service Binder</a> |
| </li> |
| <li class="nav-item" data-depth="3"> |
| <a class="nav-link" href="../../../tutorials-examples-and-presentations/apache-felix-osgi-tutorial/apache-felix-tutorial-example-9.html">Example 9 - Spell Checker Service using Declarative Services</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../license.html">Apache License 2.0</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="../../../site-map.html">Site map</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </nav> |
| </div> |
| <div class="nav-panel-explore" data-panel="explore"> |
| <div class="context"> |
| <span class="title">Documentation</span> |
| <span class="version">master</span> |
| </div> |
| <ul class="components"> |
| <li class="component is-current"> |
| <span class="title">Documentation</span> |
| <ul class="versions"> |
| <li class="version is-current is-latest"> |
| <a href="../../../index.html">master</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </aside> |
| </div> |
| <main class="article"> |
| <div class="toolbar" role="navigation"> |
| <button class="nav-toggle"></button> |
| <a href="../../../index.html" class="home-link"></a> |
| <nav class="breadcrumbs" aria-label="breadcrumbs"> |
| <ul> |
| <li><a href="../../../index.html">Documentation</a></li> |
| <li><a href="../../../subprojects.html">Subprojects</a></li> |
| <li><a href="../../apache-felix-dependency-manager.html">Apache Felix Dependency Manager</a></li> |
| <li>Reference</li> |
| <li><a href="components.html">Dependency Manager - Components</a></li> |
| </ul> |
| </nav> |
| <div class="edit-this-page"><a href="https://github.com/apache/felix-antora-site/edit/main/modules/ROOT/pages/subprojects/apache-felix-dependency-manager/reference/components.adoc">Edit this Page</a></div> |
| </div> |
| <div class="content"> |
| <article class="doc"> |
| <h1 class="page">Dependency Manager - Components</h1> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Components are declared by the dependency manager and can be implemented by POJOs that contain no references to the OSGi framework whatsoever. |
| Components are the main building blocks of your OSGi application. |
| They have a life cycle, can register themselves as services and have zero or more dependencies.</p> |
| </div> |
| <div class="paragraph"> |
| <p>You can either use the Java API or the Java Annotations and this reference section describes both.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_types_of_components"><a class="anchor" href="#_types_of_components"></a>Types of Components</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>There are different types of Dependency Manager components:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><a href="component-singleton.html" class="page"><em>Component</em></a>: Components are the main building blocks for OSGi applications. |
| They can publish themselves as a service, and/or they can have dependencies. |
| These dependencies will influence their life cycle as component will only be activated when all required dependencies are available.</p> |
| </li> |
| <li> |
| <p><a href="component-aspect.html" class="page"><em>Aspect Service</em></a>: A service that provides a non-functional aspect on top of an existing service. |
| In aspect oriented programming, an aspect, or interceptor can sit between a client and another target service used by the client. |
| An Aspect Service first tracks a target service and is created once the target service is detected. |
| Then the Aspect Service is provided, but with a higher ranking, and the client is transparently updated with the aspect. |
| Aspects can be chained and may apply to the same target service (and in this case, the ranking of the Aspect service is used to chain aspects in the proper order).</p> |
| </li> |
| <li> |
| <p><a href="component-adapter.html" class="page"><em>Adapter Service</em></a>: A Service that adapts another existing service into a new one. |
| Like with aspects, sometimes you want to create adapters for certain services, which add certain behavior that results in the publication of (in this case) a different service. |
| Adapters can dynamically be added and removed and allow you to keep your basic services implementations clean and simple, adding extra features on top of them in a modular way.</p> |
| </li> |
| <li> |
| <p><a href="component-bundle-adapter.html" class="page"><em>Bundle Adapter Service</em></a>: creates an OSGi service a service on top of a given bundle.</p> |
| </li> |
| <li> |
| <p><a href="component-resource-adapter.html" class="page"><em>Resource Adapter Service</em></a>: creates an OSGi service on top of a specific Resource.</p> |
| </li> |
| <li> |
| <p><a href="component-factory-configuration-adapter.html" class="page"><em>Factory Configuration Adapter Service</em></a>: creates an OSGi service from ConfigAdmin, using a factoryPid, and a ManagedServiceFactory.</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_life_cycle"><a class="anchor" href="#_life_cycle"></a>Life cycle</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>The dependency manager, as part of a bundle, shares the generic bundle life cycle explained in the OSGi specification. |
| The life cycle of the dependency manager itself, and the components it manages, can be located inside the <em>active</em> state of the hosting bundle.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Each component you define gets its own life cycle, which is explained in the state diagram below.</p> |
| </div> |
| <div class="imageblock"> |
| <div class="content"> |
| <img src="../../../_images/documentation/subprojects/apache-felix-dependency-manager/reference/diagrams/statediagram.png" alt="State diagram" width="430"> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>A component is associated with an instance. |
| This instance can either be specified directly, or you can specify its class. |
| If you do the latter, the actual instance will be created lazily.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Changes in the state of the component will trigger the following life cycle methods:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><code>init</code>,</p> |
| </li> |
| <li> |
| <p><code>start</code>,</p> |
| </li> |
| <li> |
| <p><code>stop</code> and</p> |
| </li> |
| <li> |
| <p><code>destroy</code>.</p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>The dependency manager will look for methods with these names and one of the following signatures in this order:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><code>(Component)</code>,</p> |
| </li> |
| <li> |
| <p><code>()</code>.</p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>If you don’t specify anything, the methods with these names will be invoked on the instance. |
| By using <code>setCallbacks()</code> you can however change this behavior: You can change the names of the methods to look for. |
| Any methods that are set to ` null ` will not be invoked at all. |
| Another thing you can do is to specify a different instance to invoke these methods on. |
| If you do that, you will usually want to use the first signature, which gives you a reference to the ` Component ` whose life cycle method was invoked.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Here is a descrition of the component states:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><em>Inactive state</em>: The Component is defined, but not enabled (not yet added to a DependencyManager object, or the bundle has been stopped).</p> |
| </li> |
| <li> |
| <p><em>Waiting for required</em> state: The Component is enabled (has been added to a DependencyManager object) and the required dependencies declared in the Activator are tracked. |
| The component remains in the current state until all required dependencies are available.</p> |
| </li> |
| <li> |
| <p><em>Instantiated and waiting for required</em> state: All required dependencies declared in the Activator are available. |
| The Component has been instantiated with required dependencies injected, and has been invoked in the <em>init</em> callback. |
| Now, if some extra required dependencies have been dynamically added in the <em>init</em> callback, then the component remains in the current state until all extra required dependencies become available.</p> |
| </li> |
| <li> |
| <p><em>Tracking optional</em>: All Required dependencies are injected (including the ones you dynamically added from the <em>init</em> method), the component <em>start</em> callback is called, the component service is registered in the OSGi registry, and finally the optional dependencies (with callbacks) are then tracked.</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_what_happens_during_component_instantiation"><a class="anchor" href="#_what_happens_during_component_instantiation"></a>What happens during component instantiation ?</h2> |
| <div class="sectionbody"> |
| <div class="olist arabic"> |
| <ol class="arabic"> |
| <li> |
| <p>The service is instantiated.</p> |
| </li> |
| <li> |
| <p>The following special objects are injected through reflection on class fields, if they exist (but you can deactivate this behavior from the API):</p> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>BundleContext</p> |
| </li> |
| <li> |
| <p>ServiceRegistration</p> |
| </li> |
| <li> |
| <p>DependencyManager</p> |
| </li> |
| <li> |
| <p>Component</p> |
| </li> |
| </ul> |
| </div> |
| </li> |
| <li> |
| <p><em>autoconfig</em> dependencies are injected through reflection on class fields, if they exist. |
| If an <em>autoconfig</em> optional dependency is unavailable, a NullObject is then injected.</p> |
| </li> |
| <li> |
| <p>Required dependency callbacks defined from the Activator are called.</p> |
| </li> |
| <li> |
| <p>The component <em>init</em> method is called, and from that method you can then dynamically add more dependencies by using the Component parameter passed to the init method, or using a class field of <em>Component</em> type (which in this case has been injected during step 2).</p> |
| </li> |
| <li> |
| <p>When all required dependencies (including dependencies dynamically added from the <em>init</em> method) are available, they are injected (using callbacks, or autoconfig).</p> |
| </li> |
| <li> |
| <p>The component <em>start</em> callback is invoked.</p> |
| </li> |
| <li> |
| <p>Optional dependencies (with callbacks) are then tracked.</p> |
| </li> |
| <li> |
| <p>The component service(s) is then registered in the OSGi service registry</p> |
| </li> |
| </ol> |
| </div> |
| <div class="paragraph"> |
| <p>When using Annotations, there are some specific behaviors:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>The <em>@init</em> method may return a Map that contains filters in order to dynamically configure dependencies annotated with a <em>name</em> attribute, and the dependencies will then be injected after the <em>@init</em> method (exactly if you would have added the dependencies from the init method using the API).</p> |
| </li> |
| <li> |
| <p>The <em>@start</em> method may return a Map in order to dynamically add more service properties (if the component provides some services).</p> |
| </li> |
| <li> |
| <p>The component can be dynamically stopped or restarted using a special <em>@LifecycleController</em> annotation.</p> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_interfaces_and_properties"><a class="anchor" href="#_interfaces_and_properties"></a>Interfaces and properties</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Components in the context of the dependency manager can be published as OSGi services under one or more interface names, plus optionally a set of properties. |
| This is no different than a normal OSGi service. |
| It’s important to mention that you don’t have to register a service. |
| If you don’t, you basically created a component that can do work and have dependencies and a managed life cycle.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_composition"><a class="anchor" href="#_composition"></a>Composition</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>When implementing more complex components, you often find yourself using more than one instance. |
| However, several of these instances might want to have dependencies injected. |
| In such cases you need to tell the dependency manager which instances to consider. |
| This has to be a fixed set of instances however.</p> |
| </div> |
| <div class="paragraph"> |
| <p>We now describe how to declare a service composition using the Api, and the Annotations:</p> |
| </div> |
| <div class="paragraph"> |
| <p>Example:</p> |
| </div> |
| <div class="paragraph"> |
| <p>When using the DependencyManager API, you can use the <em>Component.setComposition</em> method to declare a special callback in your component that returns the list of object that are part of the component, and all dependencies and lifecycle callbacks will be invoked on the objects returned by the method. |
| Let’s take an example, with a <em>ProviderImpl</em> top-level service implementation that is internally implemented using three Pojos: <em>ProviderImpl</em>, <em>ProviderParticipant1</em>, and <em>ProviderParticipant2</em>:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public class ProviderImpl implements Provider { |
| private final ProviderParticipant1 m_participant1 = new ProviderParticipant1(); |
| private final ProviderParticipant2 m_participant2 = new ProviderParticipant2(); |
| private volatile LogService m_log; // injected |
| |
| Object[] getComposition() { |
| return new Object[] { this, m_participant1, m_participant2 }; |
| } |
| |
| void start() { |
| m_log.log(LogService.LOG_INFO, "ProviderImpl.start(): participants=" + m_participant1 + "," + m_participant2 |
| + ", conf=" + m_conf); |
| } |
| } |
| |
| public class ProviderParticipant1 { |
| private volatile LogService m_log; // also injected since we are part of the composition |
| |
| void start() { |
| m_log.log(LogService.LOG_INFO, "ProviderParticipant1.start()"); |
| } |
| } |
| |
| public class ProviderParticipant2 { |
| private volatile LogService m_log; // also injected since we are part of the composition |
| |
| void start() { |
| m_log.log(LogService.LOG_INFO, "ProviderParticipant2.start()"); |
| } |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>And here is the Activator, which uses the <em>setComposition</em> method:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> public class Activator extends DependencyActivatorBase { |
| public void init(BundleContext ctx, DependencyManager m) throws Exception { |
| m.add(createComponent() |
| .setImplementation(ProviderImpl.class) |
| .setComposition("getComposition") |
| .add(createServiceDependency().setService(LogService.class).setRequired(true))); |
| } |
| }</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="_factories"><a class="anchor" href="#_factories"></a>Factories</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Out of the box, there already is support for lazy instantiation, meaning that the dependency manager can create component instances for you when their required dependencies are resolved. |
| However, sometimes creating a single instance using a default constructor is not enough. |
| In those cases, you can tell the dependency manager to delegate the creation process to a factory.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Interestingly, you can also mix the usage of a Factory object and a Composition of objects returned by the Factory. |
| The following is the same example as in the previous section (Composition), but using a Factory approach in order to instantiate a composition of objects: The "ProviderFactory" is first injected with a Configuration that can possibly be used to create and configure all the other objects that are part of the composition; |
| each object will also be injected with the dependencies defined in the Activator.</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public class ProviderFactory { |
| private ProviderParticipant1 m_participant1; |
| private ProviderParticipant2 m_participant2; |
| private ProviderImpl m_providerImpl; |
| private Dictionary<String, String> m_conf; |
| |
| public void updated(Dictionary<String, String> conf) throws Exception { |
| // validate configuration and throw an exception if the properties are invalid |
| m_conf = conf; |
| } |
| |
| /** |
| * Builds the composition of objects used to implement the "Provider" service. |
| * The Configuration injected by Config Admin will be used to configure the components |
| * @return The "main" object providing the "Provider" service. |
| */ |
| Object create() { |
| // Here, we can instantiate our object composition based on our injected configuration ... |
| |
| if ("true".equals(m_conf.get("some.parameter")) { |
| m_participant1 = new ProviderParticipant1(); // depenencies and lifecycle callbacks will also be applied |
| m_participant2 = new ProviderParticipant2(); // depenencies and lifecycle callbacks will also be applied |
| } else { |
| // Compose with some other objects ... |
| m_participant1 = new ProviderParticipant3(); // depenencies and lifecycle callbacks will also be applied |
| m_participant2 = new ProviderParticipant4(); // depenencies and lifecycle callbacks will also be applied |
| } |
| |
| m_providerImpl = new ProviderImpl(m_participant1, m_participant2); |
| return m_providerImpl; // Main object implementing the Provider service |
| } |
| |
| /** |
| * Returns the list of objects that are part of the composition for the Provider implementation. |
| */ |
| Object[] getComposition() { |
| return new Object[] { m_providerImpl, m_participant1, m_participant2 }; |
| } |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>And here is the Activator: notice the <em>setFactory</em> method that specifies the factory to use to create the implementation. |
| Also pay attention to the <em>setComposition</em> method, which indicates the method to call in order to get all instances that are part of a composition and need dependencies injected:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> public class Activator extends DependencyActivatorBase { |
| public void init(BundleContext ctx, DependencyManager m) throws Exception { |
| ProviderFactory factory = new ProviderFactory(); |
| m.add(createComponent() |
| .setFactory(factory, "create") // factory.create() will return the implementation instance |
| .setComposition(factory, "getComposition") |
| .add(createConfigurationDependency() |
| .setPid("some.pid") |
| .setCallback(factory, "updated")) // will invoke "updated" on the factory instance |
| .add(createServiceDependency().setService(LogService.class).setRequired(true))); |
| } |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>You can refer to this <a href="https://svn.apache.org/repos/asf/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/compositefactory/">sample code</a>, which is part of the source distribution.</p> |
| </div> |
| </div> |
| </div> |
| </article> |
| <aside class="toc sidebar" data-title="Contents" data-levels="2"> |
| <div class="toc-menu"></div> |
| </aside> |
| </div> |
| </main> |
| </div> |
| <footer class="footer"> |
| <p>Content licensed under AL2. UI licensed under MPL-2.0 with extensions licensed under AL2</p> |
| </footer> |
| <script src="../../../../_/js/site.js"></script> |
| <script async src="../../../../_/js/vendor/highlight.js"></script> |
| </body> |
| </html> |