From dev-return-11801-apmail-directory-dev-archive=directory.apache.org@directory.apache.org Thu Apr 27 15:16:42 2006 Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 99022 invoked from network); 27 Apr 2006 15:16:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Apr 2006 15:16:38 -0000 Received: (qmail 95885 invoked by uid 500); 27 Apr 2006 15:16:30 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 95721 invoked by uid 500); 27 Apr 2006 15:16:29 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 95658 invoked by uid 99); 27 Apr 2006 15:16:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2006 08:16:29 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [207.190.94.33] (HELO gadget.mwt.net) (207.190.94.33) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2006 08:16:28 -0700 Received: from 192.168.1.8 (dsl-67-41.westby.mwt.net [207.190.67.41]) by gadget.mwt.net (8.13.6/8.12.11) with ESMTP id k3RFG5oS015730; Thu, 27 Apr 2006 10:16:06 -0500 Subject: Re: Upgrading the OSGi From: "John E. Conlon" Reply-To: jconlon@verticon.com To: erodriguez@apache.org Cc: Apache Directory Developers List In-Reply-To: <568753d90604261641m3c3bf31dqbd92ba5a0e27a6ce@mail.gmail.com> References: <1145394893.3696.43.camel@trout> <44455B7A.5020707@apache.org> <1145479264.3691.44.camel@trout> <4449FCAE.1070409@apache.org> <1145931473.3649.58.camel@trout> <444E9C43.4030707@apache.org> <1146091499.3935.19.camel@trout> <568753d90604261641m3c3bf31dqbd92ba5a0e27a6ce@mail.gmail.com> Content-Type: text/plain Organization: Verticon, Inc. Date: Thu, 27 Apr 2006 10:16:05 -0500 Message-Id: <1146150965.3663.29.camel@trout> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-27) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Wed, 2006-04-26 at 19:41 -0400, Enrique Rodriguez wrote: > On 4/26/06, John E. Conlon wrote: > > On Tue, 2006-04-25 at 18:01 -0400, Enrique Rodriguez wrote: > ... > > > I made a 'main' module that will > > > assemble ApacheDS deps with the Felix runtime and startup with an > > > ApacheDS Felix "profile." I just committed this on rev 396981. > > > > Yes I see it. Very nice. > > > > But, why the new org.apache.directory.server.Main class? Couldn't you > > have reused Felix's main? > > Hmm, good point. I copied it as a start and, in retrospect, it ended > up unchanged. I'll update to copy in the Felix main jar and test. > > ... > > Should the log4j.properties file go in the conf directory with the other > > the properties files? > > Sure. That would be consistent with Felix convention. > > > Regarding logging, I needed to create a similar logging bundle to yours > > because some of my other bundles had transitive dependencies on commons- > > logging as well, so I added jcl104-over-slf4j. While at it, I added an > > Activator that reset the configuration at start time. Now no need to > > restart the framework after changing the log4j.properties file, just > > stop and start the log bundle. > > That's a nice feature. I did my POM wrapper to get things working. I > don't plan on making any logging breakthroughs. At some point we can > check out how any logging bundles out there turn out. Too many choices for logging - Commons-Logging vs slf4j vs OSGi logService it is as bad as choosing an American Health Care plan. For what it's worth, below is a copy of the logging bundle Activator. -------------------------------------------- import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URL; import org.apache.log4j.LogManager; import org.apache.log4j.PropertyConfigurator; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Activator implements BundleActivator { private static final String LOG_PROPERTIES_LOCATION = "log4j.configuration"; private Logger log = null; public void start(BundleContext bundleContext) throws Exception { try { resetLog4j(bundleContext); } catch (Exception e) { //e.printStackTrace(); } log = LoggerFactory.getLogger(Activator.class); log.debug("Reset log configuration."); } public void stop(BundleContext arg0) throws Exception {} /** * @return url of the log4j.properties configuration file * * @throws MalformedURLException * */ private URL getLoggingProperty(BundleContext bundleContext) throws MalformedURLException { final String logPropertiesLocation = bundleContext .getProperty(LOG_PROPERTIES_LOCATION); return new URL(logPropertiesLocation); } /** * Reset the log4j configuration. * @param bundleContext * @throws MalformedURLException * @throws FileNotFoundException */ private void resetLog4j(BundleContext bundleContext) throws MalformedURLException, FileNotFoundException { LogManager.resetConfiguration(); URL log4jprops = getLoggingProperty(bundleContext); if (log4jprops != null) { PropertyConfigurator.configure(log4jprops); } else { throw new FileNotFoundException(bundleContext .getProperty(LOG_PROPERTIES_LOCATION) + " could not be found. " + "Please specify add the file and restart the " + bundleContext.getBundle().getLocation() + " bundle."); } } }