-
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
Showing
6 changed files
with
200 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public class TestJetty { | ||
public static void main(String[] args){} | ||
} |
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,7 @@ | ||
/.gradle/ | ||
/.settings/ | ||
/bin/ | ||
/out/ | ||
/build/ | ||
/.classpath | ||
/.project |
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,65 @@ | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir 'src/main/java' | ||
|
||
} | ||
resources { | ||
srcDir 'src/main/resources' | ||
srcDir 'src/main/java' exclude '**/*.java' | ||
} | ||
|
||
} | ||
test { | ||
java { | ||
srcDir 'src/test/java' | ||
|
||
} | ||
resources { | ||
srcDir 'src/test/resources' | ||
srcDir 'src/test/java' exclude '**/*.java' | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
dependencies { | ||
compile project(':bboot-starter') | ||
// https://mvnrepository.com/artifact/org.eclipse.jetty.orbit/org.objectweb.asm | ||
//compile group: 'org.eclipse.jetty.orbit', name: 'org.objectweb.asm', version: '3.1.0.v200803061910' | ||
// https://mvnrepository.com/artifact/org.eclipse.jetty.orbit/javax.annotation | ||
//compile group: 'org.eclipse.jetty.orbit', name: 'javax.annotation', version: '1.1.0.v201108011116' | ||
|
||
compile ( | ||
// https://mvnrepository.com/artifact/org.eclipse.jetty.orbit/org.objectweb.asm | ||
|
||
[group: 'javax.servlet', name: 'javax.servlet-api', version: "3.0.1", transitive: false], | ||
//[group: 'javax.servlet', name: 'jsp-api', version: '2.0', transitive: false], | ||
[group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.1', transitive: false], | ||
|
||
[group: 'javax.el', name: 'javax.el-api', version: '2.2.1', transitive: false], | ||
[group: 'org.eclipse.jetty.aggregate', name: 'jetty-all-server', version: '8.1.19.v20160209', transitive: false], | ||
//[group: 'org.eclipse.jetty.orbit', name: 'org.apache.jasper.glassfish', version: '2.2.2.v201112011158', transitive: false], | ||
[group: 'org.eclipse.jetty.orbit', name: 'javax.servlet.jsp', version: '2.2.0.v201112011158', transitive: false], | ||
|
||
[group: 'org.eclipse.jetty.orbit', name: 'org.apache.taglibs.standard.glassfish', version: '1.2.0.v201112081803', transitive: false], | ||
[group: 'org.eclipse.jetty.orbit', name: 'com.sun.el', version: '2.2.0.v201108011116', transitive: false], | ||
|
||
[group: 'org.mortbay.jetty', name: 'jsp-2.1-glassfish', version: '9.1.02.B04.p0', transitive: true], | ||
[group: 'javax.servlet', name: 'jstl', version: '1.2', transitive: false], | ||
) | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
123 changes: 123 additions & 0 deletions
123
bboot-starter-jetty8/src/main/java/org/frameworkset/boot/ApplicationStart.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,123 @@ | ||
package org.frameworkset.boot; | ||
|
||
import org.eclipse.jetty.annotations.AnnotationConfiguration; | ||
import org.eclipse.jetty.server.Connector; | ||
import org.eclipse.jetty.server.Handler; | ||
import org.eclipse.jetty.server.Server; | ||
import org.eclipse.jetty.server.handler.ContextHandlerCollection; | ||
import org.eclipse.jetty.server.nio.SelectChannelConnector; | ||
import org.eclipse.jetty.util.thread.QueuedThreadPool; | ||
import org.eclipse.jetty.webapp.Configuration; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.eclipse.jetty.webapp.WebXmlConfiguration; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ApplicationStart extends BaseApplicationStart{ | ||
private static Logger log = LoggerFactory.getLogger(ApplicationStart.class); | ||
private Server server; | ||
public ApplicationStart() { | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
public String getServerType() { | ||
return "Jetty"; | ||
} | ||
|
||
@Override | ||
protected void startContainer(ApplicationBootContext applicationBootContext) throws Exception{ | ||
QueuedThreadPool threadPool = new QueuedThreadPool(); | ||
// threadPool.setIdleTimeout(getThreadPoolIdleTimeout()); | ||
threadPool.setMaxIdleTimeMs(getThreadPoolIdleTimeout()); | ||
threadPool.setMinThreads(getMinThreads()); | ||
threadPool.setMaxThreads(getMaxThreads()); | ||
Server server = new Server(); | ||
server.setThreadPool(threadPool); | ||
SelectChannelConnector connector = new SelectChannelConnector(); | ||
connector.setHost(applicationBootContext.getHost()); | ||
connector.setPort(applicationBootContext.getPort()); | ||
// connector.setIdleTimeout(getIdleTimeout()); | ||
server.setConnectors(new Connector[]{connector}); | ||
|
||
// 关联一个已经存在的上下文 | ||
WebAppContext context = new WebAppContext(); | ||
// 设置描述符位置 | ||
//context.setDescriptor("./"+webroot+"/WEB-INF/web.xml"); | ||
// 设置Web内容上下文路径 | ||
|
||
context.setResourceBase(applicationBootContext.getDocBase()); | ||
// 设置上下文路径 | ||
context.setContextPath(applicationBootContext.getContext()); | ||
context.setParentLoaderPriority(true); | ||
// 设置描述符位置 | ||
context.setDescriptor("./WebRoot/WEB-INF/web.xml"); | ||
/** | ||
// This webapp will use jsps and jstl. We need to enable the | ||
// AnnotationConfiguration in order to correctly | ||
// set up the jsp container | ||
Configuration.ClassList classlist = Configuration.ClassList | ||
.setServerDefault( server ); | ||
classlist.addBefore( | ||
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration", | ||
"org.eclipse.jetty.annotations.AnnotationConfiguration" ); | ||
*/ | ||
// context.setConfigurations(new Configuration[] {new WebXmlConfiguration(), | ||
// new AnnotationConfiguration() }); | ||
|
||
// Set the ContainerIncludeJarPattern so that jetty examines these | ||
// container-path jars for tlds, web-fragments etc. | ||
// If you omit the jar that contains the jstl .tlds, the jsp engine will | ||
// scan for them instead. | ||
context.setAttribute( | ||
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", | ||
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" ); | ||
|
||
|
||
ContextHandlerCollection contexts = new ContextHandlerCollection(); | ||
log.info("WebAppContext:"+context.toString()); | ||
|
||
contexts.setHandlers(new Handler[] { context }); | ||
|
||
|
||
|
||
|
||
// Configure a LoginService. | ||
// Since this example is for our test webapp, we need to setup a | ||
// LoginService so this shows how to create a very simple hashmap based | ||
// one. The name of the LoginService needs to correspond to what is | ||
// configured in the webapp's web.xml and since it has a lifecycle of | ||
// its own we register it as a bean with the Jetty server object so it | ||
// can be started and stopped according to the lifecycle of the server | ||
// itself. | ||
// HashLoginService loginService = new HashLoginService(); | ||
// loginService.setName( "Test Realm" ); | ||
// loginService.setConfig( "src/test/resources/realm.properties" ); | ||
// server.addBean( loginService ); | ||
|
||
server.setHandler(contexts); | ||
|
||
|
||
// 启动 | ||
server.start(); | ||
applicationBootContext.setServerStatus(server.getState()); | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
protected void afterStartContainer(ApplicationBootContext applicationBootContext) throws Exception{ | ||
server.join(); | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
ApplicationStart applicationStart = new ApplicationStart(); | ||
applicationStart.start(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
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,4 +1,5 @@ | ||
include 'bboot-starter' | ||
include 'bboot-starter-jetty' | ||
include 'bboot-starter-jetty8' | ||
include 'bboot-starter-tomcat' | ||
include 'bboot-starter-undertow' |