Hi,

I'm not sure to follow what you are trying to achieve here?
To give a simple comparison:
- Karaf is a Container for OSGi applications as Tomcat is a Container for
web applications.

Now why would you want to embed a container, if you want to embed the OSGi
framework in your application you need to look
for Apache Felix, Eclipse Equinox, Knopflerfish .....
What kind of use-cases do you have?
Do you want to have a Web Application using OSGi services?
Well use Karaf as standalone Container cause it also supports Web
Application Bundles (WAB, aka std. War with OSGi Manifest).

regards, Achim



2013/3/19 azadbolour <[email protected]>

>
> Hi,
>
> I am a newbie to karaf, and I am trying to figure out how to embed it in
> another program. My understanding is that something like the following code
> should work (taken from
> http://njbartlett.name/2011/03/07/embedding-osgi.html):
>
> FrameworkFactory frameworkFactory =
> ServiceLoader.load(FrameworkFactory.class).iterator().next();
> Map<String, String> config = new HashMap<String, String>();
> // TODO: add some config properties
> Framework framework = frameworkFactory.newFramework(config);
> framework.start();
>
> Should this work for karaf? And if so what jar files need to be included to
> obtain the framework factory as in above?
>
> On the other hand, the karaf Main (2.3.1) does something different:
>
>         String factoryClass =
> configProps.getProperty(KARAF_FRAMEWORK_FACTORY);
>         if (factoryClass == null) {
>             InputStream is =
> classLoader.getResourceAsStream("META-INF/services/" +
> FrameworkFactory.class.getName());
>             BufferedReader br = new BufferedReader(new
> InputStreamReader(is,
> "UTF-8"));
>             factoryClass = br.readLine();
>             br.close();
>         }
>         FrameworkFactory factory = (FrameworkFactory)
> classLoader.loadClass(factoryClass).newInstance();
>         framework = factory.newFramework(new StringMap(configProps,
> false));
>
> Would this be the correct way of embedding karaf? If so, what jar file
> should include the FrameworkFactory services resource, and what jar file
> should include the actual factoryClass implementation?
>
> Thanks in advance for any help in clarifying the right way to embed karaf.
>
> Azad
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/embedding-karaf-tp4028257.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
OPS4J Pax for Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>

Reply via email to