directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcon...@apache.org
Subject svn commit: r481458 - in /directory/sandbox/jconlon/osgi-services/logging-service: pom.xml src/main/java/org/apache/directory/osgi/services/logging/Activator.java
Date Sat, 02 Dec 2006 00:30:53 GMT
Author: jconlon
Date: Fri Dec  1 16:30:52 2006
New Revision: 481458

URL: http://svn.apache.org/viewvc?view=rev&rev=481458
Log:
Using DynamicImports, made the org.osgi.compendium bundle optional.  When the optional bundle
is present a slf4j implemenation of the org.osgi.service.log.LogService will be registered.


Modified:
    directory/sandbox/jconlon/osgi-services/logging-service/pom.xml
    directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/Activator.java

Modified: directory/sandbox/jconlon/osgi-services/logging-service/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-services/logging-service/pom.xml?view=diff&rev=481458&r1=481457&r2=481458
==============================================================================
--- directory/sandbox/jconlon/osgi-services/logging-service/pom.xml (original)
+++ directory/sandbox/jconlon/osgi-services/logging-service/pom.xml Fri Dec  1 16:30:52 2006
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<groupId>org.apache.directory.osgi.services</groupId>
@@ -22,6 +22,7 @@
 		        <configuration>
 		          <instructions>
 		            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+		            <DynamicImport-Package>org.osgi.service.log</DynamicImport-Package>
 		            <Import-Package>
 		            !javax.jms, 
 		            !javax.mail, 

Modified: directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/Activator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/Activator.java?view=diff&rev=481458&r1=481457&r2=481458
==============================================================================
--- directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/Activator.java
(original)
+++ directory/sandbox/jconlon/osgi-services/logging-service/src/main/java/org/apache/directory/osgi/services/logging/Activator.java
Fri Dec  1 16:30:52 2006
@@ -13,7 +13,6 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.service.log.LogService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -75,11 +74,29 @@
         registerLogService( bundleContext );
     }
 
+    /**
+     * We dynamically import the osgi log service service API, so it 
+     * might not actually be available, so we catch and ignore
+     * the exception when we try to register the service.
+     * @param bundleContext
+     */
     private void registerLogService( BundleContext bundleContext )
     {
         Dictionary<String, String> parameters = new Hashtable<String, String>();
         parameters.put( Constants.SERVICE_VENDOR, VENDOR );
-        bundleContext.registerService( LogService.class.getName(), new LogServiceImpl(),
parameters );
+        
+        try
+        {
+            
+            bundleContext.registerService(
+                    org.osgi.service.log.LogService.class.getName(),
+                new LogServiceImpl(), parameters);
+        }
+        catch (Throwable th)
+        {
+            // Ignore.
+        }
+    
     }
 
     public void stop( BundleContext arg0 ) throws Exception



Mime
View raw message