From 0ce981c907ddec5bd6532c8e39a55400d523daec Mon Sep 17 00:00:00 2001
From: Shinsuke Sugaya <shinsuke@yahoo.co.jp>
Date: Sat, 25 Jan 2014 23:02:01 +0900
Subject: [PATCH] fix #84

---
 .../jp/sf/fess/log/MobyletLoggerImpl.java     | 45 +++++++++++++++++++
 src/main/mysql/webapp/WEB-INF/web.xml         |  4 ++
 src/main/oracle/webapp/WEB-INF/web.xml        |  4 ++
 src/main/resources/fess_suggest.dicon         |  5 ++-
 src/main/resources/solrlib.dicon              |  5 ++-
 src/main/webapp/WEB-INF/web.xml               |  4 ++
 6 files changed, 63 insertions(+), 4 deletions(-)
 create mode 100644 src/main/java/jp/sf/fess/log/MobyletLoggerImpl.java

diff --git a/src/main/java/jp/sf/fess/log/MobyletLoggerImpl.java b/src/main/java/jp/sf/fess/log/MobyletLoggerImpl.java
new file mode 100644
index 000000000..382c62d03
--- /dev/null
+++ b/src/main/java/jp/sf/fess/log/MobyletLoggerImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2009-2014 the CodeLibs Project and the Others.
+ *
+ * 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 jp.sf.fess.log;
+
+import org.mobylet.core.log.MobyletLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MobyletLoggerImpl implements MobyletLogger {
+    private static final Logger logger = LoggerFactory.getLogger("org.mobylet");
+
+    private final boolean loggable;
+
+    public MobyletLoggerImpl() {
+        final String value = System.getProperty("mobylet.log");
+        loggable = "true".equalsIgnoreCase(value);
+    }
+
+    @Override
+    public boolean isLoggable() {
+        return loggable;
+    }
+
+    @Override
+    public void log(final String msg) {
+        if (loggable) {
+            logger.info(msg);
+        }
+    }
+
+}
diff --git a/src/main/mysql/webapp/WEB-INF/web.xml b/src/main/mysql/webapp/WEB-INF/web.xml
index 784504f2e..8f8e831e7 100644
--- a/src/main/mysql/webapp/WEB-INF/web.xml
+++ b/src/main/mysql/webapp/WEB-INF/web.xml
@@ -42,6 +42,10 @@
       <param-name>encoding</param-name>
       <param-value>UTF-8</param-value>
     </init-param>
+    <init-param>
+      <param-name>mobylet.logger.class</param-name>
+      <param-value>jp.sf.fess.log.MobyletLoggerImpl</param-value>
+    </init-param>
   </filter>
 
   <filter>
diff --git a/src/main/oracle/webapp/WEB-INF/web.xml b/src/main/oracle/webapp/WEB-INF/web.xml
index 784504f2e..8f8e831e7 100644
--- a/src/main/oracle/webapp/WEB-INF/web.xml
+++ b/src/main/oracle/webapp/WEB-INF/web.xml
@@ -42,6 +42,10 @@
       <param-name>encoding</param-name>
       <param-value>UTF-8</param-value>
     </init-param>
+    <init-param>
+      <param-name>mobylet.logger.class</param-name>
+      <param-value>jp.sf.fess.log.MobyletLoggerImpl</param-value>
+    </init-param>
   </filter>
 
   <filter>
diff --git a/src/main/resources/fess_suggest.dicon b/src/main/resources/fess_suggest.dicon
index 62f2af578..c0ce49681 100644
--- a/src/main/resources/fess_suggest.dicon
+++ b/src/main/resources/fess_suggest.dicon
@@ -114,13 +114,14 @@
 	</component>
 
 	<!-- Solr Server Configuration -->
-	<component name="suggestInterceptor" class="org.codelibs.solr.lib.server.interceptor.PreemptiveAuthInterceptor">
+	<component name="suggestInterceptor" class="org.codelibs.solr.lib.server.interceptor.PreemptiveAuthInterceptor"
+		autoBinding="none">
 	</component>
 	<component name="suggestCredentials" class="org.apache.http.auth.UsernamePasswordCredentials">
 		<arg>"solradmin"</arg><!-- Username -->
 		<arg>"solradmin"</arg><!-- Password -->
 	</component>
-	<component name="suggestHttpClient" class="org.apache.http.impl.client.DefaultHttpClient">
+	<component name="suggestHttpClient" class="org.apache.http.impl.client.DefaultHttpClient" autoBinding="none">
 		<arg>clientConnectionManager</arg>
 	</component>
 	<component name="suggestSolrServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer">
diff --git a/src/main/resources/solrlib.dicon b/src/main/resources/solrlib.dicon
index 2598238a8..dcd50ed0f 100644
--- a/src/main/resources/solrlib.dicon
+++ b/src/main/resources/solrlib.dicon
@@ -92,13 +92,14 @@
 	</component>
 
 	<!-- Solr Server Configuration -->
-	<component name="interceptor1" class="org.codelibs.solr.lib.server.interceptor.PreemptiveAuthInterceptor">
+	<component name="interceptor1" class="org.codelibs.solr.lib.server.interceptor.PreemptiveAuthInterceptor"
+		autoBinding="none">
 	</component>
 	<component name="credentials1" class="org.apache.http.auth.UsernamePasswordCredentials">
 		<arg>"solradmin"</arg><!-- Username -->
 		<arg>"solradmin"</arg><!-- Password -->
 	</component>
-	<component name="httpClient1" class="org.apache.http.impl.client.DefaultHttpClient">
+	<component name="httpClient1" class="org.apache.http.impl.client.DefaultHttpClient" autoBinding="none">
 		<arg>clientConnectionManager</arg>
 	</component>
 	<component name="solrServer1" class="org.apache.solr.client.solrj.impl.HttpSolrServer">
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 409c5a754..437190918 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -42,6 +42,10 @@
       <param-name>encoding</param-name>
       <param-value>UTF-8</param-value>
     </init-param>
+    <init-param>
+      <param-name>mobylet.logger.class</param-name>
+      <param-value>jp.sf.fess.log.MobyletLoggerImpl</param-value>
+    </init-param>
   </filter>
 
   <filter>
-- 
GitLab