karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Pieber <anpie...@gmail.com>
Subject Re: Starting embedded Karaf from Java - reliance on System properties
Date Wed, 14 Sep 2011 18:40:48 GMT
Hey Lindsay,

Well, the problem here is that Karaf is not really made to run embedded.
This is similar to a situation where you would like to start JBoss or
Glassfish embedded. Even if you use jetty/tomcat embedded you do so to add
one functionality: servlets. Something similar is true for Karaf. I'm
curious if it isn't the better solution to use plain felix/equinox if you
like to start an embedded OSGi engine. Nevertheless, may I ask what you like
to do with an embedded Karaf?

OK, back to you question: currently there is no option to configure Karaf by
a map of properties. In addition the question is: how useful this will be.
The internal parts of Karaf make quite heavy use of
System.getProperty(KARAF_HOME) and similar properties. This is also the
reason why Karaf does the following shortly after startup:

System.setProperty(PROP_KARAF_HOME, karafHome.getPath());
System.setProperty(PROP_KARAF_BASE, karafBase.getPath());
System.setProperty(PROP_KARAF_DATA, karafData.getPath());
System.setProperty(PROP_KARAF_INSTANCES, karafInstances.getPath());

Therefore, even if you can put those properties in via a MAP they will (and
have to be) still be set as system props. So no real solution here.

@The system.properties: Karaf doesn't uses this file but rather provides the
values in there as system properties again. You can see all this behavior
here [1]

I'm afraid there is no way to remove all of them. Some things wouldn't even
work if the sys properties aren't set.

Kind regards,


On Mon, Sep 12, 2011 at 04:38, Lindsay Smith <linsmi@coretech.co.nz> wrote:

> I'm investigating launching Karaf from within Java and I have some
> questions about setting Karaf's configuration properties.
> I think Karaf shows a whole lot of promise as the foundation for OSGi
> products, I'd love to be able to use it and I'm looking forward to the 3.0
> release as it appears to have a bunch of stuff I think makes it very useful.
>  The embedded scenario is very important to me as well, hence the questions.
>   We currently use Equinox directly with their servlet bridge.
> When using the startup script, a bunch of system properties are set when
> launching the Java process.     When launching Karaf from Java, the only
> example I've seen is the web container example that I think is in the
> source.  It sets a bunch of system properties via Java before calling the
> launcher class.
> Is Karaf dependent on system properties to configure itself?  Is there any
> other way to give Karaf the config information it needs?
> I see that there is a system.properties file in the /etc folder - does
> Karaf simply use this file - after modifying the values from matching system
> properties that are present?
> While system properties are fine when you have are launching the Java
> process yourself, it's not appropriate to set them or read them in an
> embedded situation, as you don't always have control over how that process
> was launched, or what other classes are reading or setting system properties
> within the same process.    In an embedded situation if you set system
> properties in code then you've limited yourself to a single Karaf instance
> being launched from that process.
> As an ideal solution, lauching Karaf from Java would pass in a map of
> configuration values.  We could then write wrappers that, for example, pull
> configuration values from the servlet context, or from an external
> properties file that contains the initial values.
> Thanks for any feedback
> Lindsay

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message