title: OSGi: passing parameters to a specific bundle
body: <p>I have a custom jar with a custom Main class, which starts the OSGi Framework and installs/starts the bundles. This main jar also includes a properties file.</p>
  
  <p>Goal: I have a bundle A which should pick up the properties of this properties file of the main jar somehow.</p>
  
  <p>My first attempt was to define a component in bundle A (using Apache Felix SCR/ Declarative Services) and retrieve the properties in its activate-method. This works so far that I'm getting the default value specified in the @Property-annotation.</p>
  
  <p>But how can I now pass the properties of the properties file to this component?</p>
  
  <p><a href="https://stackoverflow.com/questions/7132866/passing-arguments-to-osgi-application">Passing arguments to OSGi application</a>
  mentions to use the Config Admin, but how can I use this in the Main class?</p>
  
  <ul>
  <li>The Config Admin is in a bundle, not in the main jar, and the bundles are not installed in any specific order</li>
  <li>The Main class doesn't know anything about the bundles it installs, let alone a specific service.pid.</li>
  </ul>
  
  <h2>Update:</h2>
  
  <p>I'm trying now an approach suggested by @vizier (which doesn't use Config Admin and thus doesn't have the mentioned issues):</p>
  
  <ul>
  <li>define a service interface in the main jar (system bundle)</li>
  <li>provide an implementation, which reads the property file (the properties file is in the same jar)</li>
  <li>export the package X containing this service interface</li>
  <li>bundle A then can import the package X and e.g. reference the service using Declarative Services</li>
  </ul>
  
  <p>But in my bundle A I'm getting: </p>
  
  <pre><code>org.osgi.framework.BundleException: Unresolved constraint in bundle &lt;bundle A&gt; [14]: Unable to resolve 14.0: missing requirement [14.0] osgi.wiring.package; (&amp;(osgi.wiring.package=&lt;package X&gt;)(version&gt;=0.1.0)(!(version&gt;=1.0.0)))
      at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826)
      at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
      at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
      at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>Does the system bundle only export osgi packages even if some custom packages were added to Export-Package in the Manifest file? Or what is going wrong?</p>