Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
b81930fc
Commit
b81930fc
authored
Dec 26, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for Jetty 9
parent
ffc4bd38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
9 deletions
+57
-9
howto.md
docs/howto.md
+43
-8
JettyEmbeddedServletContainer.java
...context/embedded/jetty/JettyEmbeddedServletContainer.java
+14
-1
No files found.
docs/howto.md
View file @
b81930fc
...
@@ -161,6 +161,39 @@ are quite rich so once you have access to the
...
@@ -161,6 +161,39 @@ are quite rich so once you have access to the
of ways. Or the nuclear option is to add your own
of ways. Or the nuclear option is to add your own
`JettyEmbeddedServletContainerFactory`
.
`JettyEmbeddedServletContainerFactory`
.
## Use Jetty 9
Jetty 9 works with Spring Boot, but the default is to use Jetty 8 (so
we can support Java 1.6 out of the box). You should only need to
change the classpath to use Jetty 9 for it to work.
If you are using the starter poms and parent you can just add the
Jetty starter and change the version properties, e.g. for a simple
webapp or service:
<properties>
<java.version>1.7</java.version>
<jetty.version>9.1.0.v20131115</jetty.version>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency
</dependencies>
## Terminate SSL in Tomcat
## Terminate SSL in Tomcat
Add a
`EmbeddedServletContainerCustomizer`
and in that add a
Add a
`EmbeddedServletContainerCustomizer`
and in that add a
...
@@ -733,7 +766,7 @@ In Spring Boot you can also set the active profile in
...
@@ -733,7 +766,7 @@ In Spring Boot you can also set the active profile in
spring.profiles.active
:
production
spring.profiles.active
:
production
```
```
A value set this is replaced by the System property or environment
A value set this
way
is replaced by the System property or environment
variable setting, but not by the
`SpringApplicationBuilder.profiles()`
variable setting, but not by the
`SpringApplicationBuilder.profiles()`
method. Thus the latter Java API can be used to augment the profiles
method. Thus the latter Java API can be used to augment the profiles
without changing the defaults.
without changing the defaults.
...
@@ -756,16 +789,18 @@ added using the default locations, but have lower priority than system
...
@@ -756,16 +789,18 @@ added using the default locations, but have lower priority than system
properties, environment variables or the command line.
properties, environment variables or the command line.
You can also provide System properties (or environment variables) to
You can also provide System properties (or environment variables) to
change the
default
behaviour:
change the behaviour:
*
`config.name`
(
`CONFIG_NAME`
), defaults to
`application`
as the root
*
`config.name`
(
`CONFIG_NAME`
), defaults to
`application`
as the root
of the file name
of the file name
*
`config.location`
(
`CONFIG_LOCATION`
) is a comma-separated list of
*
`config.location`
(
`CONFIG_LOCATION`
) is file to load (e.g. a
files to load. A separate
`Environment`
property source is set up
classpath resource or a URL). A separate
`Environment`
property
for each document found, so the priority order is most significant
source is set up for this document and it can be overridden by
first. Defaults to
system properties, environment variables or the command line.
`file:./application.properties,classpath:application.properties`
. If
YAML is used then those files are also added to the list by default.
No matter what you set in the environment, Spring Boot will always
load
`application.properties`
as described above. If YAML is used then
files with the ".yml" extension are also added to the list by default.
See
`ConfigFileApplicationContextInitializer`
for more detail.
See
`ConfigFileApplicationContextInitializer`
for more detail.
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java
View file @
b81930fc
...
@@ -23,6 +23,7 @@ import org.eclipse.jetty.server.Server;
...
@@ -23,6 +23,7 @@ import org.eclipse.jetty.server.Server;
import
org.springframework.boot.context.embedded.EmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerException
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerException
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
/**
/**
* {@link EmbeddedServletContainer} that can be used to control an embedded Jetty server.
* {@link EmbeddedServletContainer} that can be used to control an embedded Jetty server.
...
@@ -86,7 +87,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
...
@@ -86,7 +87,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
Connector
[]
connectors
=
this
.
server
.
getConnectors
();
Connector
[]
connectors
=
this
.
server
.
getConnectors
();
for
(
Connector
connector
:
connectors
)
{
for
(
Connector
connector
:
connectors
)
{
connector
.
start
();
connector
.
start
();
this
.
logger
.
info
(
"Jetty started on port: "
+
connector
.
getLocalPort
(
));
this
.
logger
.
info
(
"Jetty started on port: "
+
getLocalPort
(
connector
));
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
...
@@ -95,6 +96,18 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
...
@@ -95,6 +96,18 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
}
}
}
}
private
String
getLocalPort
(
Connector
connector
)
{
try
{
// Jetty 9 internals are different, but the method name is the same
return
((
Integer
)
ReflectionUtils
.
invokeMethod
(
ReflectionUtils
.
findMethod
(
connector
.
getClass
(),
"getLocalPort"
),
connector
)).
toString
();
}
catch
(
Exception
e
)
{
return
"could not determine port ( "
+
e
.
getMessage
()
+
")"
;
}
}
@Override
@Override
public
synchronized
void
stop
()
{
public
synchronized
void
stop
()
{
try
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment