
net.lecousin.core.javaee.BootstrapServlet Maven / Gradle / Ivy
The newest version!
package net.lecousin.core.javaee;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import javax.enterprise.concurrent.ManagedThreadFactory;
import javax.naming.InitialContext;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import net.lecousin.framework.application.Application;
import net.lecousin.framework.application.Artifact;
import net.lecousin.framework.application.Version;
import net.lecousin.framework.application.libraries.classpath.DefaultLibrariesManager;
import net.lecousin.framework.util.PropertiesUtil;
public class BootstrapServlet extends GenericServlet {
private static final long serialVersionUID = -6358069042161072659L;
@Override
@SuppressWarnings({
"squid:S2095", // input is closed
"squid:S106", // use System.err
"squid:S3776", // complexity
})
public void init() throws ServletException {
Map properties = null;
String propertiesURL = getServletConfig().getInitParameter("properties");
if (propertiesURL != null && !propertiesURL.isEmpty()) {
String[] urls = propertiesURL.split(",");
for (String u : urls) {
if (u.isEmpty()) continue;
try {
InputStream input;
if (u.toLowerCase().startsWith("classpath:")) {
input = getClass().getClassLoader().getResourceAsStream(u.substring(10));
if (input == null) throw new FileNotFoundException("File not found: " + u.substring(10));
} else {
URL url = new URL(u);
input = url.openStream();
}
Properties props = new Properties();
try {
props.load(input);
} finally {
input.close();
}
properties = new HashMap<>();
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy