logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1403858 - in /logging/log4j/log4j2/trunk: core/pom.xml core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java src/changes/changes.xml
Date Tue, 30 Oct 2012 20:17:21 GMT
Author: rgoers
Date: Tue Oct 30 20:17:21 2012
New Revision: 1403858

URL: http://svn.apache.org/viewvc?rev=1403858&view=rev
Log:
LOG4J2-95 - Add support for loading plugins inside the OSGi bundle.

Modified:
    logging/log4j/log4j2/trunk/core/pom.xml
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/pom.xml?rev=1403858&r1=1403857&r2=1403858&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/pom.xml (original)
+++ logging/log4j/log4j2/trunk/core/pom.xml Tue Oct 30 20:17:21 2012
@@ -39,6 +39,12 @@
       <artifactId>log4j-api</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>core</artifactId>
+      <version>4.3.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-core-asl</artifactId>
       <version>1.9.2</version>

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java?rev=1403858&r1=1403857&r2=1403858&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/plugins/ResolverUtil.java
Tue Oct 30 20:17:21 2012
@@ -19,6 +19,8 @@ package org.apache.logging.log4j.core.co
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.helpers.Loader;
 import org.apache.logging.log4j.status.StatusLogger;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.wiring.BundleWiring;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -28,6 +30,7 @@ import java.lang.annotation.Annotation;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
@@ -76,6 +79,8 @@ public class ResolverUtil<T> {
 
     private static final String VFSZIP = "vfszip";
 
+    private static final String BUNDLE_RESOURCE = "bundleresource";
+
     /** The set of matches being accumulated. */
     private Set<Class<? extends T>> classMatches = new HashSet<Class<?extends
T>>();
 
@@ -254,6 +259,8 @@ public class ResolverUtil<T> {
                     URL newURL = new URL(url.getProtocol(), url.getHost(), path);
                     JarInputStream stream = new JarInputStream(newURL.openStream());
                     loadImplementationsInJar(test, packageName, path, stream);
+                } else if (BUNDLE_RESOURCE.equals(url.getProtocol())) {
+                    loadImplementationsInBundle(test, packageName);
                 } else {
                     File file = new File(urlPath);
                     if (file.isDirectory()) {
@@ -268,6 +275,14 @@ public class ResolverUtil<T> {
         }
     }
 
+    private void loadImplementationsInBundle(Test test, String packageName) {
+        Collection<String> list = FrameworkUtil.getBundle(ResolverUtil.class).adapt(BundleWiring.class)
+            .listResources(packageName, "*.class", BundleWiring.LISTRESOURCES_RECURSE);
+        for (String name : list) {
+            addIfMatching(test, name);
+        }
+    }
+
 
     /**
      * Finds matches in a physical directory on a filesystem.  Examines all
@@ -383,7 +398,7 @@ public class ResolverUtil<T> {
             }
         } catch (Throwable t) {
             LOG.warn("Could not examine class '" + fqn + "' due to a " +
-                     t.getClass().getName() + " with message: " + t.getMessage());
+                t.getClass().getName() + " with message: " + t.getMessage());
         }
     }
 

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1403858&r1=1403857&r2=1403858&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Oct 30 20:17:21 2012
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-beta3" date="TBD" description= "Bug fixes and enhancements">
+      <action issue="LOG4J2-95" dev="rgoers" type="fix">
+        Add support for loading plugins inside the OSGi bundle.
+      </action>
       <action issue="LOG4J2-85" dev="rgoers" type="update">
         Add ThreadContext.push(String format, Object... args)
       </action>



Mime
View raw message