基于OSGi规范开发模块化应用能否跨Felix、Concierge等平台运行?
Great questions—let’s break these down to help you build a modular OSGi app that works across Felix, Concierge, and other compliant frameworks.
1. Can code using Felix dependencies run on Concierge?
It depends on which Felix dependencies you’re using:
- If your code only relies on standard OSGi API packages (e.g.,
org.osgi.core,org.osgi.service.component,org.osgi.framework) that Felix implements, then yes—your bundles should run on Concierge without issues. Concierge is a fully compliant OSGi framework, so it supports all core spec APIs. - If you’re using Felix-specific non-standard APIs (e.g., internal packages like
org.apache.felix.framework.internal, or Felix-only extensions like custom config handlers), then Concierge won’t have those implementations, and your code will fail.
The fix here is straightforward: stick to the official OSGi specification APIs as much as possible. If you need a specific service, depend on the OSGi service interface rather than Felix’s concrete implementation.
2. High-quality Concierge tutorials with examples
Concierge has a smaller community than Felix, but there are still solid resources to get started:
- Concierge Official Documentation: The official docs include a getting started guide that walks through creating basic bundles, registering services, and deploying them. It’s lightweight but covers the core basics you need.
- GitHub Sample Repos: Search for Concierge-specific sample projects—you’ll find small, focused examples that demonstrate things like Declarative Services, bundle lifecycle, and inter-bundle communication. Many of these are maintained by the Concierge community or contributors.
- OSGi Core Spec Tutorials: Since Concierge adheres strictly to the OSGi spec, any good OSGi core tutorial (like those focused on Felix) will apply to Concierge too. Just skip sections that cover Felix-only features, and test your code on Concierge to verify.
- Stack Overflow Concierge Q&A: Browse existing Concierge questions here—you’ll find real-world examples of troubleshooting deployment issues, service registration, and cross-framework compatibility.
3. Can you develop cross-framework (Concierge/Felix) apps using OSGi specs?
Absolutely—this is exactly what the OSGi specification is designed for! The key is to program to the OSGi standard, not to a specific framework implementation. Here’s how to do it:
- Only depend on OSGi API packages: Use Maven/Gradle to pull in the official OSGi API artifacts (e.g.,
org.osgi:org.osgi.core) instead of Felix-specific bundles. - Use standard OSGi service patterns: Stick to the core Service Registry, Declarative Services (per the OSGi DS spec), and Config Admin service instead of framework-specific alternatives.
- Avoid implementation-specific configuration: Don’t rely on Felix-specific config parameters (like those in
config.ini) or Concierge-only flags. Use OSGi’s standard configuration mechanisms instead. - Test across frameworks: Set up a simple test pipeline where you deploy your bundles to both Felix and Concierge to catch compatibility issues early. Tools like the Maven OSGi plugin can help automate this.
By following these practices, you’ll build bundles that are portable across any OSGi-compliant framework, not just Felix and Concierge.
内容的提问来源于stack exchange,提问作者rod.dinis

