update tomcat-boot
This commit is contained in:
parent
dac9c07da2
commit
07d97ff85d
4 changed files with 29 additions and 44 deletions
2
pom.xml
2
pom.xml
|
@ -66,7 +66,7 @@
|
|||
<cluster.runner.version>1.7.0.1-SNAPSHOT</cluster.runner.version>
|
||||
|
||||
<!-- Tomcat -->
|
||||
<tomcat.boot.version>0.3.7</tomcat.boot.version>
|
||||
<tomcat.boot.version>0.3.8-RC6</tomcat.boot.version>
|
||||
|
||||
<!-- Maven Repository -->
|
||||
<maven.snapshot.repo.url>https://oss.sonatype.org/content/repositories/snapshots</maven.snapshot.repo.url>
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
package org.codelibs.fess;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
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;
|
||||
|
||||
public class FessBoot extends TomcatBoot {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FessBoot.class.getPackage().getName());
|
||||
private static final String FESS_ENV_PROPERTIES = "fess_env.properties";
|
||||
|
||||
private static final String LOGGING_PROPERTIES = "/logging.properties";
|
||||
private static final String LOGGING_PROPERTIES = "logging.properties";
|
||||
|
||||
private static final String FESS_CONTEXT_PATH = "fess.context.path";
|
||||
|
||||
|
@ -31,10 +22,6 @@ public class FessBoot extends TomcatBoot {
|
|||
|
||||
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(final int port, final String contextPath) {
|
||||
super(port, contextPath);
|
||||
}
|
||||
|
@ -63,8 +50,12 @@ public class FessBoot extends TomcatBoot {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void info(final String msg) {
|
||||
logger.info(msg);
|
||||
protected void loadServerLoggingIfNeeds() {
|
||||
try {
|
||||
super.loadServerLoggingIfNeeds();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -72,38 +63,22 @@ public class FessBoot extends TomcatBoot {
|
|||
// ============
|
||||
|
||||
public static void main(final String[] args) {
|
||||
// load logging.properties
|
||||
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 (final IOException e) {
|
||||
logger.log(Level.WARNING, "Failed to load " + LOGGING_PROPERTIES, e);
|
||||
}
|
||||
|
||||
// update java.io.tmpdir
|
||||
final String value = System.getProperty(FESS_TEMP_PATH);
|
||||
if (value != null) {
|
||||
System.setProperty(JAVA_IO_TMPDIR, value);
|
||||
}
|
||||
|
||||
new FessBoot(getPort(), getContextPath()).useTldDetect().asDevelopment(isNoneEnv()).bootAwait();
|
||||
new FessBoot(getPort(), getContextPath()) //
|
||||
.useTldDetect() // for JSP
|
||||
.configure(FESS_ENV_PROPERTIES) // e.g. URIEncoding
|
||||
.logging(LOGGING_PROPERTIES, op -> {
|
||||
final String fessHomeDir = System.getProperty("fess.home");
|
||||
if (fessHomeDir != null) {
|
||||
op.replace("fess.home", fessHomeDir);
|
||||
}
|
||||
}) // uses jdk14logger
|
||||
.asDevelopment(isNoneEnv()).bootAwait();
|
||||
}
|
||||
|
||||
private static boolean isNoneEnv() {
|
||||
|
|
|
@ -45,3 +45,8 @@ mail.return.path = root@localhost
|
|||
# ========================================================================================
|
||||
# Web
|
||||
# =====
|
||||
# ----------------------------------------------------------
|
||||
# Tomcat
|
||||
# ------
|
||||
tomcat.URIEncoding = UTF-8
|
||||
tomcat.useBodyEncodingForURI = true
|
||||
|
|
|
@ -45,3 +45,8 @@ mail.return.path = root@localhost
|
|||
# ========================================================================================
|
||||
# Web
|
||||
# =====
|
||||
# ----------------------------------------------------------
|
||||
# Tomcat
|
||||
# ------
|
||||
tomcat.URIEncoding = UTF-8
|
||||
tomcat.useBodyEncodingForURI = true
|
||||
|
|
Loading…
Add table
Reference in a new issue