svn commit: r1343673 - in /cocoon/subprojects/cocoon-spring-configurator/trunk: pom.xml src/main/java/org/apache/cocoon/spring/configurator/logback/ src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java

[email protected]
Newsgroups gmane.text.xml.cocoon.cvs
Message-ID <[email protected]>
Author: ilgrosso
Date: Tue May 29 11:32:54 2012
New Revision: 1343673

URL: http://svn.apache.org/viewvc?rev=1343673&view=rev
Log:
[COCOON3-69] Moving LogbackConfigurator to proper place (cocoon-spring-configurator)

Added:
    cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/
    cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java   (with props)
Modified:
    cocoon/subprojects/cocoon-spring-configurator/trunk/pom.xml

Modified: cocoon/subprojects/cocoon-spring-configurator/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/subprojects/cocoon-spring-configurator/trunk/pom.xml?rev=1343673&r1=1343672&r2=1343673&view=diff
==============================================================================
--- cocoon/subprojects/cocoon-spring-configurator/trunk/pom.xml (original)
+++ cocoon/subprojects/cocoon-spring-configurator/trunk/pom.xml Tue May 29 11:32:54 2012
@@ -66,25 +66,7 @@
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-      <exclusions>
-        <exclusion>
-          <artifactId>logkit</artifactId>
-          <groupId>logkit</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>avalon-framework</artifactId>
-          <groupId>avalon-framework</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <optional>true</optional>
-    </dependency>
+    
     <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
@@ -110,6 +92,45 @@
       <groupId>org.springframework</groupId>
       <artifactId>spring-web</artifactId>
     </dependency>
+        
+    <!-- Logging -->
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1.1</version>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.4</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <version>1.0.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>1.0.1</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+      <version>1.6.4</version>
+      <optional>true</optional>
+    </dependency>
+    
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <optional>true</optional>
+    </dependency>
   </dependencies>
 
   <build>

Added: cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java
URL: http://svn.apache.org/viewvc/cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java?rev=1343673&view=auto
==============================================================================
--- cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java (added)
+++ cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java Tue May 29 11:32:54 2012
@@ -0,0 +1,79 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.spring.configurator.logback;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.util.StatusPrinter;
+import org.apache.cocoon.configuration.Settings;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+public class LogbackConfigurator extends JoranConfigurator
+        implements InitializingBean {
+
+    /** The settings object that is used to substitute variable values. */
+    protected Settings settings;
+
+    /** The configuration resources. */
+    protected Resource resource;
+
+    /**
+     * Inject the settings object.
+     * @param settings The settings bean.
+     */
+    public void setSettings(final Settings settings) {
+        this.settings = settings;
+    }
+
+    /**
+     * Set the configuration resource.
+     * @param resource The resource.
+     */
+    public void setResource(final Resource resource) {
+        this.resource = resource;
+    }
+
+    /**
+     * This method is called after the instance is setup and before it is used.
+     * @throws Exception If anything during configuration goes wrong an exception
+     * is thrown.
+     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+     */
+    public void afterPropertiesSet()
+            throws Exception {
+
+        final LoggerContext loggerCtx =
+                (LoggerContext) LoggerFactory.getILoggerFactory();
+        setContext(loggerCtx);
+        loggerCtx.reset();
+
+        getContext().putProperty(Settings.KEY_CACHE_DIRECTORY,
+                this.settings.getCacheDirectory());
+        getContext().putProperty(Settings.KEY_CONTAINER_ENCODING,
+                this.settings.getContainerEncoding());
+        getContext().putProperty(Settings.KEY_FORM_ENCODING,
+                this.settings.getFormEncoding());
+        getContext().putProperty(Settings.KEY_WORK_DIRECTORY,
+                this.settings.getWorkDirectory());
+        for (Object propName : this.settings.getPropertyNames()) {
+            getContext().putProperty((String) propName,
+                    this.settings.getProperty((String) propName));
+        }
+
+        doConfigure(resource.getURL());
+        StatusPrinter.print(loggerCtx);
+    }
+}

Propchange: cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: cocoon/subprojects/cocoon-spring-configurator/trunk/src/main/java/org/apache/cocoon/spring/configurator/logback/LogbackConfigurator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.