blob: b5437170b5ec2558c345a0735058bb67a6749020 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>OSGi Frequently Asked Questions :: Apache Felix</title>
<link rel="canonical" href="https://felix.apache.org/documentation/tutorials-examples-and-presentations/apache-felix-osgi-faq.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="../subprojects/apache-felix-dependency-manager.html">Dependency Manager</a>
<a class="navbar-item" href="../subprojects/apache-felix-event-admin.html">Event Admin</a>
<a class="navbar-item" href="../subprojects/apache-felix-file-install.html">File Install</a>
<a class="navbar-item" href="../subprojects/apache-felix-framework.html">Framework</a>
<a class="navbar-item" href="../subprojects/apache-felix-gogo.html">Gogo Shell</a>
<a class="navbar-item" href="../subprojects/apache-felix-healthchecks.html">Health Checks</a>
<a class="navbar-item" href="../subprojects/apache-felix-inventory.html">Inventory</a>
<a class="navbar-item" href="../subprojects/apache-felix-log.html">Log</a>
<a class="navbar-item" href="../subprojects/apache-felix-logback.html">Logback</a>
<a class="navbar-item" href="../subprojects/apache-felix-maven-bundle-plugin.html">Maven bundle plugin</a>
<a class="navbar-item" href="../subprojects/apache-felix-maven-scr-plugin.html">Maven SCR plugin</a>
<a class="navbar-item" href="../subprojects/apache-felix-metatype-service.html">Metatype Service</a>
<a class="navbar-item" href="../subprojects/apache-felix-preferences-service.html">Preferences Service</a>
<a class="navbar-item" href="../subprojects/apache-felix-remote-shell.html">Remote Shell</a>
<a class="navbar-item" href="../subprojects/apache-felix-script-console-plugin.html">Script console plugin</a>
<a class="navbar-item" href="../subprojects/apache-felix-shell.html">Lightweight shell</a>
<a class="navbar-item" href="../subprojects/apache-felix-shell-tui.html">Shell TUI</a>
<a class="navbar-item" href="../subprojects/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="../subprojects/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="../subprojects/apache-felix-dependency-manager/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="../subprojects/apache-felix-dependency-manager/guides/annotations.html">Dependency Manager - Annotations</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/background.html">Dependency Manager - Background</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/bundles-and-dependencies.html">Dependency Manager - Bundles and Dependencies</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/design-patterns.html">Dependency Manager - Design Patterns</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/development.html">Dependency Manager - Development</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/history.html">Dependency Manager - History</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/javadocs.html">Dependency Manager - JavaDocs</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/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="../subprojects/apache-felix-dependency-manager/guides/performance-tuning.html">Dependency Manager - Performance Tuning</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/resources.html">Dependency Manager - Resource adapters</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/whatsnew.html">Dependency Manager - What&#8217;s new in version 4?</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/dm-lambda.html">Dependency Manager Lambda</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/guides/whatsnew-r15.html">What&#8217;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="../subprojects/apache-felix-dependency-manager/reference/component-adapter.html">Dependency Manager - Adapter</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/component-aspect.html">Dependency Manager - Aspect</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/component-bundle-adapter.html">Dependency Manager - Bundle Adapter</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/dependency-bundle.html">Dependency Manager - Bundle Dependency</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/components.html">Dependency Manager - Components</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/dependency-configuration.html">Dependency Manager - Configuration Dependency</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/dependencies.html">Dependency Manager - Dependencies</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/external-links.html">Dependency Manager - External Links</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/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="../subprojects/apache-felix-dependency-manager/reference/component-resource-adapter.html">Dependency Manager - Resource Adapter</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/dependency-resource.html">Dependency Manager - Resource Dependency</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/dependency-service.html">Dependency Manager - Service Dependency</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/service-scopes.html">Dependency Manager - Service Scopes</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/component-singleton.html">Dependency Manager - Singleton Component</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/thread-model.html">Dependency Manager - Thread Model</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/reference/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="../subprojects/apache-felix-dependency-manager/tutorials/working-with-annotations.html">Dependency Manager - Annotations</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/tutorials/getting-started.html">Dependency Manager - Getting Started</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/tutorials/leveraging-the-shell.html">Dependency Manager - Leveraging the shell</a>
</li>
<li class="nav-item" data-depth="4">
<a class="nav-link" href="../subprojects/apache-felix-dependency-manager/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="../subprojects/apache-felix-event-admin.html">Apache Felix Event Admin</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/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="../subprojects/apache-felix-framework.html">Apache Felix Framework</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/apache-felix-gogo.html">Apache Felix Gogo</a>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/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="../subprojects/apache-felix-healthchecks.html">Apache Felix Health Checks</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/apache-felix-inventory.html">Apache Felix Inventory Printer</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/apache-felix-log.html">Apache Felix Log</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/apache-felix-logback.html">Apache Felix Logback</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/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="../subprojects/apache-felix-metatype-service.html">Apache Felix Metatype Service</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/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="../subprojects/apache-felix-preferences-service.html">Apache Felix Preferences Service</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/apache-felix-remote-shell.html">Apache Felix Remote Shell</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/apache-felix-shell.html">Apache Felix Shell</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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="../subprojects/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>
<li class="nav-item" data-depth="2">
<button class="nav-item-toggle"></button>
<span class="nav-text">Maven SCR plugin</span>
<ul class="nav-list">
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html">Apache Felix Maven SCR Plugin Use</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-bndtools-use.html">Apache Felix SCR Annotations BndTools Use</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/apache-felix-scr-ant-task-use.html">Apache Felix SCR Ant Task Use</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/extending-scr-annotations.html">Extending SCR Annotations Excerpt: How add new Annotations extending the base Annotations</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/scr-annotations.html">SCR Annotations Excerpt: Using Java 5 Annotations to describe the component or service.</a>
</li>
<li class="nav-item" data-depth="3">
<a class="nav-link" href="../subprojects/apache-felix-maven-scr-plugin/scr-javadoc-tags.html">SCR JavaDoc Tags Excerpt: Using JavaDoc Tags to describe the component or service.</a>
</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="apache-felix-application-demonstration.html">Apache Felix Application Demonstration</a>
</li>
<li class="nav-item" data-depth="2">
<a class="nav-link" href="apache-felix-osgi-tutorial.html">Apache Felix OSGi Tutorial</a>
</li>
<li class="nav-item is-current-page" data-depth="2">
<a class="nav-link" href="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="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="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="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="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="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="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="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="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="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="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="../tutorials-examples-and-presentations.html">Tutorials</a></li>
<li><a href="apache-felix-osgi-faq.html">OSGi Frequently Asked Questions</a></li>
</ul>
</nav>
<div class="edit-this-page"><a href="https://github.com/apache/felix-antora-site/edit/main/modules/ROOT/pages/tutorials-examples-and-presentations/apache-felix-osgi-faq.adoc">Edit this Page</a></div>
</div>
<div class="content">
<article class="doc">
<h1 class="page">OSGi Frequently Asked Questions</h1>
<div class="sect1">
<h2 id="subproject-independence"><a class="anchor" href="#subproject-independence"></a>If I use bundles from Felix, will my application be tied to the Felix framework?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>No.
The Felix community is very serious about creating technology that is "pure" OSGi.
This means that we will always strive to make sure our subprojects work on all OSGi framework implementations.
The Felix framework provides very few "containerisms", so there are generally no "special" Felix features available on which subprojects may depend.
Even though it is common to use the name "Felix" to refer to the Felix framework, in reality the framework is just one subproject in the Apache Felix project.
All subprojects are intended to be used either together or separately.</p>
</div>
<div class="paragraph">
<p>Note that not all subprojects are tested on all available OSGi framework implementations, but it is the goal for them to run on them.
Any difficulties in doing so should be filed as bugs in <a href="http://issues.apache.org/jira/browse/FELIX">JIRA</a>.
Additionally, due to specification ambiguity, it is possible the Felix framework may exhibit different behavior than other implementations, but this is normal;
if in doubt, file a bug.
In the future, it is also possible some subprojects may require Felix, but they will explicitly state this fact.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="bundle-update-visibility"><a class="anchor" href="#bundle-update-visibility"></a>When I update my bundle, why are my bundle&#8217;s old classes still being used?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Updating a bundle does not necessarily cause the new classes to be used immediately, it depends on two factors:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If the classes are from a private package or an exported package.</p>
</li>
<li>
<p>If the classes are from an exported package, whether or not they are being used by another bundle.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Regarding (1), if the classes come from a private package (i.e., it is <strong>not</strong> exported), then the new classes will become available immediately.
However, if they are from an exported package, then their visibility depends on whether any other bundles are using the exported packages.</p>
</div>
<div class="paragraph">
<p>If no other bundles are using the exported packages, then the new classes will become available immediately since the old version of the classes are no longer needed.
On the other hand, if any other bundles are using the exported packages, then the new classes will <strong>not</strong> become available immediately since the old version is still required by any dependent bundles.
In this case, the new classes will not be made available until <code>PackageAdmin.refreshPackages()</code> is called (this can be invoked in the Felix shell using the <code>refresh</code> command).</p>
</div>
<div class="paragraph">
<p>There is one partial exception to this latter case, it occurs when the exporting bundle does <strong>not</strong> also import its own exported packages (see "<a href="#import-own-exports">Should a bundle import its own exported packages?</a>" below for more information on this topic).
In this case, the new classes become immediately accessible to the updated exporting bundle, but not to the dependent bundles;
the dependent bundles continue to see the old version of the classes.
This situation generally requires <code>PackageAdmin.refreshPackages()</code> to be invoked to bring the bundles back to a useful state.</p>
</div>
<div class="paragraph">
<p>This is the normal update process as defined by the OSGi specification.
Updating a bundle is a two-step process, where older versions of exported packages are kept around until explicitly refreshed.
This is done to reduce disruption when performing several updates.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_should_a_service_providerconsumer_bundle_be_packaged_with_its_service_api_packages"><a class="anchor" href="#_should_a_service_providerconsumer_bundle_be_packaged_with_its_service_api_packages"></a>Should a service provider/consumer bundle be packaged with its service API packages?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There is no easy answer to this question and it largely depends on the specific usage scenario.
The OSGi specification had originally suggested that it was good practice to embed service API packages in the service provider bundle.
In this case in OSGi R4, the service provider should both <a href="#import-own-exports">export and import</a> the service API packages, which was the default for previous versions of the OSGi specification.</p>
</div>
<div class="paragraph">
<p>The OSGi specification never had an explicit stance on whether or not a consumer bundle should embed its dependent service API packages;
although, it would not appear to be a best practice.
Logically, there is some sense to this approach, since it potentially allows the consumer bundle to gracefully handle broken service dependencies.
Of course, this depends on whether there is anything the bundle can do in the face of broken dependencies.
If service API packages are embedded in the consumer bundle, then it should <a href="#import-own-exports">export and import</a> the packages.
An alternative approach in this case is to dynamically import the service API (or even use optional imports if the dependency should only be considered once).</p>
</div>
<div class="paragraph">
<p>The main advantages of embedding service API packages in bundles are that the dependencies can always be resolved and it does not require installing a lot of other bundles to resolve the dependencies.
There are disadvantages, however.
One disadvantage is resource consumption caused by potential code duplication.
Probably a more serious disadvantage is that it makes it harder to dynamically swap out providers.</p>
</div>
<div class="paragraph">
<p>For example, assume a provider bundle is used to export service API packages and all consumers are wired to that bundle.
If the provider bundle is updated or uninstalled and then refreshed, then all consumer bundles will be stopped and refreshed as well.
Even without a refresh, such a configuration would potentially inhibit garbage collection of the class loader of the service provider, since consumers would be using it for the API package.</p>
</div>
<div class="paragraph">
<p>This situation would be different if the service API were package in a separate bundle.
In this situation, all consumer bundles would be wired to the API bundle, not to the provider bundle.
Thus, if the provider were updated or uninstalled and then refreshed, the consumer bundles would only be minimally impacted (i.e., they would either switch to the new version of the provider or to a different provider).</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="import-own-exports"><a class="anchor" href="#import-own-exports"></a>Should a bundle import its own exported packages?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In OSGi R3 this was always the case, since Export-Package implied Import-Package.
It was a good idea then and is generally a good idea now.</p>
</div>
<div class="paragraph">
<p>The whole point is substitutability of providers.</p>
</div>
<div class="paragraph">
<p>If you import the packages you export, then the framework is free to choose a different provider of those packages for your bundle at resolve time, which means that your exports may go unused.
However, this is a good thing, because the framework tries to minimize the number of active versions of a given package.
The reason why this is a good thing is because it allows for higher levels of bundle interoperability.
The more versions of a given package that are in use at any given time can lead to conflicts when trying to resolve bundle package dependencies and this also leads to partitioning of the service registry, since bundles can only see a single version of a given service package.</p>
</div>
<div class="paragraph">
<p>If your bundle only exports its packages, then it is forcing the framework to wire itself to its own version, which will result in more active versions of the given package and thus less interoperability.</p>
</div>
<div class="paragraph">
<p>The main time you want to export only, is if your bundle is purely a library bundle, then its packages will only be used if they are needed.
Another case might be if you have tightly coupled bundles sharing implementation packages.
However, if your bundle will be started and especially if the exported packages define service interfaces or are referenced from service interfaces, then you will generally want to export and import them.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_why_is_my_bundle_not_able_to_see_annotations_at_run_time"><a class="anchor" href="#_why_is_my_bundle_not_able_to_see_annotations_at_run_time"></a>Why is my bundle not able to see annotations at run time?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This is typically a class loading issue.
At runtime the JVM will only return annotations that are visible to the current class loader, so if your bundle doesn&#8217;t import the appropriate package(s) then you won&#8217;t see them.</p>
</div>
<div class="paragraph">
<p>This is not a bug, as such, it is simply how OSGi class loading works - your bundle cannot see classes that its hasn&#8217;t imported (or acquired via <code>Require-Bundle</code>).
It is also part of the design of annotations, since annotated classes are supposed to continue to load and resolve even if their annotation types aren&#8217;t available on the class path.
This lets you annotate a class with EJB3 annotations, for example, but also use it in a non-EJB container where you won&#8217;t then see the EJB3 annotations.</p>
</div>
<div class="paragraph">
<p>Try importing the annotation package inside your bundle to resolve the visibility issue.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_to_provide_optional_services"><a class="anchor" href="#_how_to_provide_optional_services"></a>How to provide optional services?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Imagine a bundle wants to provide a service only if a consumer is actually using the service.
To increase the complexity lets assume the API for the optional service may not always be available.
So assuming there is no service consumer, the bundle should not fail to start if the API is not available.</p>
</div>
<div class="paragraph">
<p>Lets illustrate with a concrete example: Consider a bundle executes some business logic.
Optionally the bundle provides information through the <a href="../subprojects/apache-felix-web-console.html" class="page">Apache Felix Web Console</a>.
The bundle should resolve and be active regardless of whether the web console is present or not.</p>
</div>
<div class="paragraph">
<p>The OSGi Core specification has two helpful mechanism at hand for these situations: <code>ServiceFactory</code> and <code>DynamicImport-Package</code>.
With the <code>ServiceFactory</code> a place holder object is registered with the Service Registry instead of the actual service object.
Only when the service is actually requested, will the <code>ServiceFactory</code> create the service object.</p>
</div>
<div class="paragraph">
<p>The second mechanism is a bit frowned upon in the OSGi community because it has the potential to be overused and thus break the promise of OSGi to be explicit with the requirements of a bundle.
In the specific context we are using the <code>DynamicImport-Package</code>, though, I think it is worth using.
This mechanism allows deferring to wire a particular package to the moment, the respective API is actually used.</p>
</div>
<div class="paragraph">
<p>Here&#8217;s how to implement the the example from above:</p>
</div>
<div class="paragraph">
<p>(1) Create a <code>ServiceFactory</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> private class PluginServiceFactory {
private final BusinessObject bo;
public Object getService(Bundle bundle, ServiceRegistration registration) {
return new BusinessObjectPlugin(bo);
}
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
// no cleanup required, have GC do the rest
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>(2) Register the service</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> Hashtable props = new Hashtable();
props.put("", "Business Object");
props.put("", "bo");
bundleContext.registerService("javax.servlet.Servlet",
new PluginServiceFactory(bo),
props);</code></pre>
</div>
</div>
<div class="paragraph">
<p>(3) Dynamically import the API</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml"> DynamicImport-Package: javax.servlet;javax.servlet.http;version=2.3</code></pre>
</div>
</div>
<div class="paragraph">
<p>For an example of using this pattern, you might want to look at the <a href="http://svn.apache.org/repos/asf/felix/trunk/jaas">Apache Felix JAAS bundle</a>, particularly the <a href="http://svn.apache.org/repos/asf/felix/trunk/jaas/pom.xml">POM File</a> and the <a href="http://svn.apache.org/repos/asf/felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java">Activator class</a> with the <code>ServiceFactory</code>.</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>