|
@@ -1,11 +1,24 @@
|
|
package org.codelibs.fess;
|
|
package org.codelibs.fess;
|
|
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.nio.ByteBuffer;
|
|
|
|
+import java.util.logging.Level;
|
|
|
|
+import java.util.logging.LogManager;
|
|
|
|
+import java.util.logging.Logger;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import org.dbflute.tomcat.TomcatBoot;
|
|
import org.dbflute.tomcat.TomcatBoot;
|
|
|
|
|
|
public class FessBoot extends TomcatBoot {
|
|
public class FessBoot extends TomcatBoot {
|
|
|
|
|
|
|
|
+ private static final Logger logger = Logger.getLogger(FessBoot.class.getPackage().getName());
|
|
|
|
+
|
|
|
|
+ private static final String LOGGING_PROPERTIES = "/logging.properties";
|
|
|
|
+
|
|
private static final String FESS_CONTEXT_PATH = "fess.context.path";
|
|
private static final String FESS_CONTEXT_PATH = "fess.context.path";
|
|
|
|
|
|
private static final String FESS_PORT = "fess.port";
|
|
private static final String FESS_PORT = "fess.port";
|
|
@@ -18,6 +31,10 @@ public class FessBoot extends TomcatBoot {
|
|
|
|
|
|
private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
|
|
private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
|
|
|
|
|
|
|
|
+ private static final int DEFAULT_BUF_SIZE = 4096;
|
|
|
|
+
|
|
|
|
+ private static final String UTF_8 = "UTF-8";
|
|
|
|
+
|
|
public FessBoot(int port, String contextPath) {
|
|
public FessBoot(int port, String contextPath) {
|
|
super(port, contextPath);
|
|
super(port, contextPath);
|
|
}
|
|
}
|
|
@@ -52,7 +69,7 @@ public class FessBoot extends TomcatBoot {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void info(String msg) {
|
|
protected void info(String msg) {
|
|
- // TODO
|
|
|
|
|
|
+ logger.info(msg);
|
|
}
|
|
}
|
|
|
|
|
|
// ===================================================================================
|
|
// ===================================================================================
|
|
@@ -60,6 +77,29 @@ public class FessBoot extends TomcatBoot {
|
|
// ============
|
|
// ============
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
+ try (InputStream is = FessBoot.class.getResourceAsStream(LOGGING_PROPERTIES)) {
|
|
|
|
+ if (is != null) {
|
|
|
|
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
|
|
|
+ final ByteBuffer buffer = ByteBuffer.allocate(DEFAULT_BUF_SIZE);
|
|
|
|
+ final byte[] buf = buffer.array();
|
|
|
|
+ int len;
|
|
|
|
+ while ((len = is.read(buf)) != -1) {
|
|
|
|
+ out.write(buf, 0, len);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String configContent = out.toString(UTF_8);
|
|
|
|
+ final String fessHomeDir = System.getProperty("fess.home");
|
|
|
|
+ if (fessHomeDir != null) {
|
|
|
|
+ configContent = configContent.replaceAll(Pattern.quote("${fess.home}"), fessHomeDir);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(configContent.getBytes(UTF_8)));
|
|
|
|
+ logger.info(LOGGING_PROPERTIES + " is loaded.");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ logger.log(Level.WARNING, "Failed to load " + LOGGING_PROPERTIES, e);
|
|
|
|
+ }
|
|
new FessBoot(getPort(), getContextPath()).useTldDetect().asDevelopment(isNoneEnv()).bootAwait();
|
|
new FessBoot(getPort(), getContextPath()).useTldDetect().asDevelopment(isNoneEnv()).bootAwait();
|
|
}
|
|
}
|
|
|
|
|