You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Roland <wg...@ids.de> on 2013/06/18 10:06:10 UTC

Best Practice System Startup

Hi there.
I use the RepositoryAdmin to install my application and the requirements
automatically. My Felix-Launcher starts felix and deploys my application.
But I have to suppose that on the first start of Felix the RepositoryAdmin
is not installed. Thus, I can not load the OBR. I have to take care that the
RepositoryAdmin is started as soon as the systembundle. I have a similar
problem with Felix-logger (org.apache.felix.log). I want to log Felix on
startup but the Log-Service does not yet exist.
My solution is the following...
To I embed the RepositoyAdmin into my Felix-lauchner and I add it's
Acitvator-class together with the HostActivator-Class to the Felilx-property
FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP. This works fine. But I also
export some Utility-Packages that I need in my Bundles. I'm running into
Export/Import-issue because I can not export "embedded" Packages
(RepositoryAdmin) and export my own packages at the same time (???).

In short: "Which came first: the chicken or the egg?"

What is the best practice for resolve requirements of a
customer-felix-launcher? (The autostart-directory is not an option for me.)

regards
Roland



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
http://java2s.com/Article-Tutorial/Java/OSGi/Log.htm
http://ekkes-corner.blogspot.de/2008/10/logging-in-osgi-enterprise-applications_20.html
http://ekkes-corner.blogspot.de/2008/10/logging-in-osgi-enterprise-applications_11.html



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004019.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
Addendum: Both...

I have third-party bundles which use various loggers such as Log4j or
commons-logging. My own bundles use the LogService of OSGi. SLF4J is needed
as a bridge for the different loggers. I'm using logback (ch.qos.logback) or
Log4J in my LogListener, I have not decided yet.



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004018.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
Hi Felix,
thanks for your answer. That's how I'll do it but I have the problem that I
want to log also error messages that are triggered by the RepositoryAdmin.
For instance if the OBR file is corrupted. I.e. that the logging system
(LogService, LogReader, LogListener, ...) has to be started before the
RepositoryAdmin. Since I have embedded the RepositoryAdmin into the
Felix-Launcher, I have to embed also the logging system. The time when a
service is started depends on the order in which the activator-classes are
added to list of the FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP-property.
That is the reason why I asked how the order is defined and whether there is
a better way.



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004017.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

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

Am 18.06.2013 um 13:01 schrieb Roland:

> You mean I have to implement the white-board-pattern for any logger, do you?
> Each bundle registers a logservice. But this is incompatible to my
> logback-architecture, i think. Let me think about...

How do you use loggers ? As a service or the traditional SLF4J style "Logger l = LoggerFactory.getLogger("")" ?

Assuming the SLF4J way for now:

First thing: This call will only succeed if the API is available at all. Of course the API may use some stdout logging because the implementation might still be missing.

What we do here is leveraging start levels: We deploy the logging infrastructure at start level 1 and make sure all other bundles are deployed at higher start levels -- by either explicitly setting the start level or using a default start level of, say, 20.

If you are usig a LogService, you have to get the LogService and cope with the situation of the service not available (yet). Again, this can be mitigated by using start levels in your deployment.

Regards
Felix

> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004001.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
You mean I have to implement the white-board-pattern for any logger, do you?
Each bundle registers a logservice. But this is incompatible to my
logback-architecture, i think. Let me think about...



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004001.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

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

Am 18.06.2013 um 10:42 schrieb Roland:

> BTW: How is the call-order of Activator-classes defined?

What Activator classes ? The BundleActivator's ?

These are called during bundle startup as defined in the Bundle lifecycle part of the Core specification. As such they depend on the order of bundle startup. This startup is influenced by the StartLevel service and other factors.

At the end of the day, your bundles must not depend on any particular order because in any deployment that order may be different. Plus: A bundle may be stopped at any time -- so even if you somehow can cope with the actual startup order, expectations due to startup order may fail due to such situations.

Hence, again: As a Bundle developer you must not depend on startup order.

Regards
Felix


> 
> Thanks
> Roland
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5003990.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
BTW: How is the call-order of Activator-classes defined?

Thanks
Roland



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5003990.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Best Practice System Startup

Posted by Roland <wg...@ids.de>.
Ok, I get it.



*It is a drawback that the OSGi core has no logging and ORB functionality
which is often needed during Felix-start.* There are definitely reasons for
this but maybe that is indeed implemented in the next version. You'd have to
move only a few packages from the Compendium in the Core and to integrate
the RepositoryAdmin in the Felix-framework.



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Best-Practice-System-Startup-tp5003987p5004038.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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