forked from harbby/sylph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ideal
committed
Jul 14, 2018
1 parent
6e902a6
commit 919a1a6
Showing
44 changed files
with
2,017 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk10 | ||
- oraclejdk8 | ||
sudo: required | ||
dist: trusty | ||
services: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
dependencies { | ||
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0' | ||
|
||
compile (project(':sylph-spi')) | ||
|
||
compile group: 'org.eclipse.jetty', name: 'jetty-server', version:deps.jetty | ||
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version:deps.jetty | ||
compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version:deps.jetty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
sylph-controller/src/main/java/ideal/sylph/controller/JettyServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package ideal.sylph.controller; | ||
|
||
import ideal.sylph.controller.selvet.ETLJobServlet; | ||
import ideal.sylph.controller.selvet.JobMangerSerlvet; | ||
import ideal.sylph.controller.selvet.SylphServletHolder; | ||
import ideal.sylph.spi.SylphContext; | ||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.server.handler.HandlerList; | ||
import org.eclipse.jetty.servlet.DefaultServlet; | ||
import org.eclipse.jetty.servlet.ServletContextHandler; | ||
import org.eclipse.jetty.servlet.ServletHolder; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Created by ideal on 17-3-15. | ||
*/ | ||
@Deprecated | ||
public final class JettyServer | ||
{ | ||
private static final Logger logger = LoggerFactory.getLogger(JettyServer.class); | ||
private Server server; | ||
private final ServerConfig serverConfig; | ||
private final SylphContext sylphContext; | ||
|
||
JettyServer( | ||
ServerConfig serverConfig, | ||
SylphContext sylphContext | ||
) | ||
{ | ||
this.serverConfig = requireNonNull(serverConfig, "serverConfig is null"); | ||
this.sylphContext = requireNonNull(sylphContext, "sylphContext is null"); | ||
} | ||
|
||
public void start() | ||
throws Exception | ||
{ | ||
//-------初始化------获取Context句柄------ | ||
int jettyPort = serverConfig.getServerPort(); | ||
int maxFormContentSize = serverConfig.getMaxFormContentSize(); | ||
|
||
// 创建Server | ||
this.server = new Server(jettyPort); | ||
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", | ||
maxFormContentSize); | ||
|
||
HandlerList handlers = loadHandlers(); //加载路由 | ||
server.setHandler(handlers); | ||
|
||
logger.info("web Server started... the port {}", jettyPort); | ||
server.start(); | ||
} | ||
|
||
private HandlerList loadHandlers() | ||
{ | ||
HandlerList handlers = new HandlerList(); | ||
//--------------------全局的---------------------- | ||
//selvet | ||
ServletContextHandler contextHandler = new ServletContextHandler( | ||
ServletContextHandler.NO_SESSIONS); | ||
contextHandler.setContextPath("/"); | ||
|
||
contextHandler.addServlet(new ServletHolder(new JobMangerSerlvet(sylphContext)), "/_sys/job_manger/*"); | ||
contextHandler.addServlet(new SylphServletHolder(new ETLJobServlet(sylphContext)), "/_sys/job_graph_edit/*"); | ||
|
||
final ServletHolder staticServlet = new ServletHolder(new DefaultServlet()); | ||
contextHandler.addServlet(staticServlet, "/css/*"); | ||
contextHandler.addServlet(staticServlet, "/js/*"); | ||
contextHandler.addServlet(staticServlet, "/images/*"); | ||
contextHandler.addServlet(staticServlet, "/fonts/*"); | ||
contextHandler.addServlet(staticServlet, "/favicon.ico"); | ||
contextHandler.addServlet(staticServlet, "/"); | ||
contextHandler.setResourceBase("webapps"); | ||
|
||
//-----------------加载所有app的-路由------------------ | ||
//runnerLoader.loadAppHandlers(handlers, contextHandler); | ||
|
||
//----selvet--结束-- | ||
String mainHome = System.getProperty("user.dir"); | ||
File[] webs = new File(mainHome + "/webapps").listFiles(); | ||
if (webs != null) { | ||
Arrays.stream(webs).forEach(file -> { | ||
if (file.isDirectory()) { | ||
WebAppContext webapp = new WebAppContext(); | ||
webapp.setContextPath("/_web/" + file.getName().toLowerCase()); //_web/postman | ||
webapp.setResourceBase(file.getAbsolutePath()); | ||
handlers.addHandler(webapp); | ||
} | ||
}); | ||
} | ||
handlers.addHandler(contextHandler); | ||
return handlers; | ||
} | ||
} |
Oops, something went wrong.