You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by lessonz <le...@gmail.com> on 2012/10/12 01:01:19 UTC

Injecting Dependency Into Embedded Apache Felix Instance

I have a standalone application in which I've embedded Felix basically
following the process outlined here:
https://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html

This application is a super or uber jar that embeds all of the necessary
bundles:

        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>

<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${bundle.name}</Bundle-Name>
                        <Embed-Dependency>
                            org.restlet.lib.org.json,

*;artifactId=org.apache.felix.framework;inline=true,
                            *;artifactId=org.apache.felix.configadmin,
                            *;artifactId=org.apache.felix.ipojo,
                            *;groupId=org.apache.servicemix.bundles,
                            *;groupId=org.bouncycastle,
                            *;groupId=org.ops4j.pax.logging,
                            *;groupId=org.restlet.android,
                            *;groupId=${project.groupId};scope=runtime
                        </Embed-Dependency>
                        <Embed-Directory>bundle</Embed-Directory>
                        <Embed-Transitive>true</Embed-Transitive>

<Main-Class>${project.groupId}.${project.artifactId}.Main</Main-Class>
                    </instructions>
                    <obrRepository>NONE</obrRepository>
                </configuration>
            </plugin>
        </plugins>

At runtime, it iterates over those embedded bundles and installs them via
org.osgi.framework.BundleContext.installBundle(String location). The
problem stems from the org.restlet.lib.org.json dependency. It is not a
bundle. So, trying to install it results in a BundleException. That makes
sense. The problem is I'm not sure how I'm supposed to inject it into my
embedded instance of Felix. See, if I deploy it to a regular standalone
instance of felix in it's ./bundle directory, everything appears to work
just fine. How do I replicate that behavior via the maven-bundle-plugin
and/or programmatically?

Thanks.

Re: Injecting Dependency Into Embedded Apache Felix Instance

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

Am 12.10.2012 um 01:01 schrieb lessonz:

> 
> At runtime, it iterates over those embedded bundles and installs them via
> org.osgi.framework.BundleContext.installBundle(String location). The
> problem stems from the org.restlet.lib.org.json dependency. It is not a
> bundle. So, trying to install it results in a BundleException. That makes
> sense. The problem is I'm not sure how I'm supposed to inject it into my
> embedded instance of Felix. See, if I deploy it to a regular standalone
> instance of felix in it's ./bundle directory, everything appears to work
> just fine. How do I replicate that behavior via the maven-bundle-plugin
> and/or programmatically?

Are you sure that deployment to the bundle folder really works out-of-the-box ? Or do you have something else installed, which is able to convert a library into a bundle before installing  it ?

If you want to deploy as you intend the data supplied to the BundleContext.installBundle method must be a valid bundle. So you have to turn that library into a bundle at build time.

Now, this org.restlet.lib.org.json library (I don't know it) looks like it is just packing up the normal org.json library. Maybe the Geronimo org.json bundle might help here as a replacement ?

Regards
Felix
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org