logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1601033 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/ log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/ log4j-core/src/test/java/org/apache/logg...
Date Fri, 06 Jun 2014 23:24:51 GMT
Author: mattsicker
Date: Fri Jun  6 23:24:50 2014
New Revision: 1601033

URL: http://svn.apache.org/r1601033
Log:
Move plugin cache file to META-INF for OSGi compatibility.

  - Using the same general location, just with META-INF/ before it.
  - Simplifies some constants.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java?rev=1601033&r1=1601032&r2=1601033&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.java
Fri Jun  6 23:24:50 2014
@@ -41,27 +41,22 @@ import javax.tools.StandardLocation;
 
 import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.util.Strings;
 
 /**
  * Annotation processor for pre-scanning Log4j 2 plugins.
  */
-@SupportedAnnotationTypes(PluginProcessor.PLUGINS_PACKAGE_NAME + ".*")
+@SupportedAnnotationTypes("org.apache.logging.log4j.core.config.plugins.*")
 @SupportedSourceVersion(SourceVersion.RELEASE_6)
 public class PluginProcessor extends AbstractProcessor {
 
     // TODO: this could be made more abstract to allow for compile-time and run-time plugin
processing
 
     /**
-     * Destination package for saving cache file.
+     * The location of the plugin cache data file. This file is written to by this processor,
and read from by
+     * {@link org.apache.logging.log4j.core.config.plugins.util.PluginManager}.
      */
-    public static final String PLUGINS_PACKAGE_NAME = "org.apache.logging.log4j.core.config.plugins";
-
-    public static final String DIRECTORY = "org/apache/logging/log4j/core/config/plugins/";
-
-    /**
-     * Name of cache file.
-     */
-    public static final String FILENAME = "Log4j2Plugins.dat";
+    public static final String PLUGIN_CACHE_FILE = "META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat";
 
     private final PluginCache pluginCache = new PluginCache();
 
@@ -104,8 +99,8 @@ public class PluginProcessor extends Abs
     }
 
     private void writeCacheFile(final Element... elements) throws IOException {
-        final FileObject fo = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,

-                PLUGINS_PACKAGE_NAME, FILENAME, elements);
+        final FileObject fo = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
+            Strings.EMPTY, PLUGIN_CACHE_FILE, elements);
         final OutputStream out = fo.openOutputStream();
         try {
             pluginCache.writeCache(out);

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java?rev=1601033&r1=1601032&r2=1601033&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
Fri Jun  6 23:24:50 2014
@@ -43,9 +43,6 @@ public class PluginManager {
     private static final PluginRegistry<PluginType<?>> REGISTRY =
         new PluginRegistry<PluginType<?>>();
 
-    private static final String PATH = PluginProcessor.DIRECTORY;
-    private static final String FILENAME = PluginProcessor.FILENAME;
-
     private static final Logger LOGGER = StatusLogger.getLogger();
 
     private Map<String, PluginType<?>> plugins = new HashMap<String, PluginType<?>>();
@@ -135,7 +132,7 @@ public class PluginManager {
     private static PluginRegistry<PluginType<?>> decode(final ResourceLoader
loader) {
         final Enumeration<URL> resources;
         try {
-            resources = loader.getResources(PATH + FILENAME);
+            resources = loader.getResources(PluginProcessor.PLUGIN_CACHE_FILE);
             if (resources == null) {
                 return null;
             }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java?rev=1601033&r1=1601032&r2=1601033&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/processor/PluginProcessorTest.java
Fri Jun  6 23:24:50 2014
@@ -33,15 +33,14 @@ import static org.junit.Assert.*;
 @RunWith(JUnit4.class)
 public class PluginProcessorTest {
 
-    private static final String CACHE_FILE = PluginProcessor.DIRECTORY + PluginProcessor.FILENAME;
-
     private static final PluginCache pluginCache = new PluginCache();
 
     private final Plugin p = FakePlugin.class.getAnnotation(Plugin.class);
 
     @BeforeClass
     public static void setUpClass() throws Exception {
-        final Enumeration<URL> resources = PluginProcessor.class.getClassLoader().getResources(CACHE_FILE);
+        final Enumeration<URL> resources =
+            PluginProcessor.class.getClassLoader().getResources(PluginProcessor.PLUGIN_CACHE_FILE);
         pluginCache.loadCacheFiles(resources);
     }
 

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1601033&r1=1601032&r2=1601033&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Fri Jun  6 23:24:50 2014
@@ -22,6 +22,9 @@
   </properties>
   <body>
     <release version="2.0-rc2" date="2014-MM-DD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-664" dev="mattsicker" type="fix">
+        Moved plugin cache file to META-INF for OSGi compatibility.
+      </action>
       <action issue="LOG4J2-640" dev="mattsicker" type="fix">
         Fix NPE that can be caused by a null ThreadContextClassLoader.
       </action>



Mime
View raw message