use of org.eclipse.jetty.util.resource.Resource in project spring-boot by spring-projects.
the class JettyServletWebServerFactory method configureDocumentRoot.
private void configureDocumentRoot(WebAppContext handler) {
File root = getValidDocumentRoot();
root = (root != null ? root : createTempDir("jetty-docbase"));
try {
List<Resource> resources = new ArrayList<>();
resources.add(root.isDirectory() ? Resource.newResource(root.getCanonicalFile()) : JarResource.newJarResource(Resource.newResource(root)));
for (URL resourceJarUrl : this.getUrlsOfJarsWithMetaInfResources()) {
Resource resource = createResource(resourceJarUrl);
// https://github.com/eclipse/jetty.project/issues/518
if (resource.exists() && resource.isDirectory()) {
resources.add(resource);
}
}
handler.setBaseResource(new ResourceCollection(resources.toArray(new Resource[resources.size()])));
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
use of org.eclipse.jetty.util.resource.Resource in project otter by alibaba.
the class JettyEmbedServer method start.
public void start() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
// Integer port = getPort();
// if (port != null && port > 0) {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// connector.setPort(port);
// }
// }
Handler handler = server.getHandler();
if (handler != null && handler instanceof WebAppContext) {
WebAppContext webAppContext = (WebAppContext) handler;
webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
use of org.eclipse.jetty.util.resource.Resource in project otter by alibaba.
the class JettyEmbedIntegration method main.
public static void main(String[] args) throws Exception {
Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
Server server = (Server) configuration.configure();
int port = 8081;
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
}
server.start();
server.join();
}
use of org.eclipse.jetty.util.resource.Resource in project otter by alibaba.
the class JettyEmbedServer method afterPropertiesSet.
public void afterPropertiesSet() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
Integer port = getPort();
if (port != null && port > 0) {
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
use of org.eclipse.jetty.util.resource.Resource in project blade by biezhi.
the class JDBCLoginService method doStart.
/* ------------------------------------------------------------ */
@Override
protected void doStart() throws Exception {
Properties properties = new Properties();
Resource resource = Resource.newResource(_config);
try (InputStream in = resource.getInputStream()) {
properties.load(in);
}
_jdbcDriver = properties.getProperty("jdbcdriver");
_url = properties.getProperty("url");
_userName = properties.getProperty("username");
_password = properties.getProperty("password");
String _userTable = properties.getProperty("usertable");
_userTableKey = properties.getProperty("usertablekey");
String _userTableUserField = properties.getProperty("usertableuserfield");
_userTablePasswordField = properties.getProperty("usertablepasswordfield");
String _roleTable = properties.getProperty("roletable");
String _roleTableKey = properties.getProperty("roletablekey");
_roleTableRoleField = properties.getProperty("roletablerolefield");
String _userRoleTable = properties.getProperty("userroletable");
String _userRoleTableUserKey = properties.getProperty("userroletableuserkey");
String _userRoleTableRoleKey = properties.getProperty("userroletablerolekey");
if (_jdbcDriver == null || _jdbcDriver.equals("") || _url == null || _url.equals("") || _userName == null || _userName.equals("") || _password == null) {
LOG.warn("UserRealm " + getName() + " has not been properly configured");
}
_userSql = "select " + _userTableKey + "," + _userTablePasswordField + " from " + _userTable + " where " + _userTableUserField + " = ?";
_roleSql = "select r." + _roleTableRoleField + " from " + _roleTable + " r, " + _userRoleTable + " u where u." + _userRoleTableUserKey + " = ?" + " and r." + _roleTableKey + " = u." + _userRoleTableRoleKey;
Loader.loadClass(_jdbcDriver).newInstance();
super.doStart();
}
Aggregations