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
0b36ba97
Commit
0b36ba97
authored
Sep 30, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish order
parent
2169bbbc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
119 deletions
+123
-119
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+123
-119
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
0b36ba97
...
@@ -91,20 +91,21 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -91,20 +91,21 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
*/
*/
private
String
displayName
=
"application"
;
private
String
displayName
=
"application"
;
private
Session
session
=
new
Session
();
@NestedConfigurationProperty
private
Ssl
ssl
;
/**
/**
* Path of the main dispatcher servlet.
* Path of the main dispatcher servlet.
*/
*/
@NotNull
@NotNull
private
String
servletPath
=
"/"
;
private
String
servletPath
=
"/"
;
private
final
Tomcat
tomcat
=
new
Tomcat
();
/**
* ServletContext parameters.
*/
private
final
Map
<
String
,
String
>
contextParameters
=
new
HashMap
<
String
,
String
>();
private
final
Undertow
undertow
=
new
Undertow
();
private
Session
session
=
new
Session
();
@NestedConfigurationProperty
private
Ssl
ssl
;
@NestedConfigurationProperty
@NestedConfigurationProperty
private
Compression
compression
=
new
Compression
();
private
Compression
compression
=
new
Compression
();
...
@@ -112,53 +113,53 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -112,53 +113,53 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
@NestedConfigurationProperty
@NestedConfigurationProperty
private
JspServlet
jspServlet
;
private
JspServlet
jspServlet
;
/**
private
final
Tomcat
tomcat
=
new
Tomcat
();
* ServletContext parameters.
*/
private
final
Undertow
undertow
=
new
Undertow
();
private
final
Map
<
String
,
String
>
contextParameters
=
new
HashMap
<
String
,
String
>();
@Override
@Override
public
int
getOrder
()
{
public
int
getOrder
()
{
return
0
;
return
0
;
}
}
public
Tomcat
getTomcat
()
{
@Override
return
this
.
tomcat
;
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
}
if
(
getPort
()
!=
null
)
{
container
.
setPort
(
getPort
());
public
Undertow
getUndertow
()
{
return
this
.
undertow
;
}
public
Compression
getCompression
()
{
return
this
.
compression
;
}
public
String
getContextPath
()
{
return
this
.
contextPath
;
}
public
void
setContextPath
(
String
contextPath
)
{
this
.
contextPath
=
cleanContextPath
(
contextPath
);
}
private
String
cleanContextPath
(
String
contextPath
)
{
if
(
StringUtils
.
hasText
(
contextPath
)
&&
contextPath
.
endsWith
(
"/"
))
{
return
contextPath
.
substring
(
0
,
contextPath
.
length
()
-
1
);
}
}
return
contextPath
;
if
(
getAddress
()
!=
null
)
{
}
container
.
setAddress
(
getAddress
());
}
public
String
getDisplayName
()
{
if
(
getContextPath
()
!=
null
)
{
return
this
.
displayName
;
container
.
setContextPath
(
getContextPath
());
}
}
if
(
getDisplayName
()
!=
null
)
{
public
void
setDisplayName
(
String
displayName
)
{
container
.
setDisplayName
(
getDisplayName
());
this
.
displayName
=
displayName
;
}
}
if
(
getSession
().
getTimeout
()
!=
null
)
{
container
.
setSessionTimeout
(
getSession
().
getTimeout
());
public
String
getServletPath
()
{
}
return
this
.
servletPath
;
container
.
setPersistSession
(
getSession
().
isPersistent
());
if
(
getSsl
()
!=
null
)
{
container
.
setSsl
(
getSsl
());
}
if
(
getJspServlet
()
!=
null
)
{
container
.
setJspServlet
(
getJspServlet
());
}
if
(
getCompression
()
!=
null
)
{
container
.
setCompression
(
getCompression
());
}
if
(
container
instanceof
TomcatEmbeddedServletContainerFactory
)
{
getTomcat
()
.
customizeTomcat
((
TomcatEmbeddedServletContainerFactory
)
container
);
}
if
(
container
instanceof
UndertowEmbeddedServletContainerFactory
)
{
getUndertow
().
customizeUndertow
(
(
UndertowEmbeddedServletContainerFactory
)
container
);
}
container
.
addInitializers
(
new
SessionConfiguringInitializer
(
this
.
session
));
container
.
addInitializers
(
new
InitParameterConfiguringServletContextInitializer
(
getContextParameters
()));
}
}
public
String
getServletMapping
()
{
public
String
getServletMapping
()
{
...
@@ -174,6 +175,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -174,6 +175,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
return
this
.
servletPath
+
"/*"
;
return
this
.
servletPath
+
"/*"
;
}
}
public
String
getPath
(
String
path
)
{
String
prefix
=
getServletPrefix
();
if
(!
path
.
startsWith
(
"/"
))
{
path
=
"/"
+
path
;
}
return
prefix
+
path
;
}
public
String
getServletPrefix
()
{
public
String
getServletPrefix
()
{
String
result
=
this
.
servletPath
;
String
result
=
this
.
servletPath
;
if
(
result
.
contains
(
"*"
))
{
if
(
result
.
contains
(
"*"
))
{
...
@@ -185,8 +194,26 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -185,8 +194,26 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
return
result
;
return
result
;
}
}
public
void
setServletPath
(
String
servletPath
)
{
public
String
[]
getPathsArray
(
Collection
<
String
>
paths
)
{
this
.
servletPath
=
servletPath
;
String
[]
result
=
new
String
[
paths
.
size
()];
int
i
=
0
;
for
(
String
path
:
paths
)
{
result
[
i
++]
=
getPath
(
path
);
}
return
result
;
}
public
String
[]
getPathsArray
(
String
[]
paths
)
{
String
[]
result
=
new
String
[
paths
.
length
];
int
i
=
0
;
for
(
String
path
:
paths
)
{
result
[
i
++]
=
getPath
(
path
);
}
return
result
;
}
public
void
setLoader
(
String
value
)
{
// no op to support Tomcat running as a traditional container (not embedded)
}
}
public
Integer
getPort
()
{
public
Integer
getPort
()
{
...
@@ -205,6 +232,41 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -205,6 +232,41 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this
.
address
=
address
;
this
.
address
=
address
;
}
}
public
String
getContextPath
()
{
return
this
.
contextPath
;
}
public
void
setContextPath
(
String
contextPath
)
{
this
.
contextPath
=
cleanContextPath
(
contextPath
);
}
private
String
cleanContextPath
(
String
contextPath
)
{
if
(
StringUtils
.
hasText
(
contextPath
)
&&
contextPath
.
endsWith
(
"/"
))
{
return
contextPath
.
substring
(
0
,
contextPath
.
length
()
-
1
);
}
return
contextPath
;
}
public
String
getDisplayName
()
{
return
this
.
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
public
String
getServletPath
()
{
return
this
.
servletPath
;
}
public
void
setServletPath
(
String
servletPath
)
{
this
.
servletPath
=
servletPath
;
}
public
Map
<
String
,
String
>
getContextParameters
()
{
return
this
.
contextParameters
;
}
/**
/**
* Get the session timeout.
* Get the session timeout.
* @return the session timeout
* @return the session timeout
...
@@ -230,6 +292,10 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -230,6 +292,10 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
return
this
.
session
;
return
this
.
session
;
}
}
public
void
setSession
(
Session
session
)
{
this
.
session
=
session
;
}
public
Ssl
getSsl
()
{
public
Ssl
getSsl
()
{
return
this
.
ssl
;
return
this
.
ssl
;
}
}
...
@@ -238,6 +304,10 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -238,6 +304,10 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this
.
ssl
=
ssl
;
this
.
ssl
=
ssl
;
}
}
public
Compression
getCompression
()
{
return
this
.
compression
;
}
public
JspServlet
getJspServlet
()
{
public
JspServlet
getJspServlet
()
{
return
this
.
jspServlet
;
return
this
.
jspServlet
;
}
}
...
@@ -246,78 +316,12 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
...
@@ -246,78 +316,12 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this
.
jspServlet
=
jspServlet
;
this
.
jspServlet
=
jspServlet
;
}
}
public
Map
<
String
,
String
>
getContextParameters
()
{
public
Tomcat
getTomcat
()
{
return
this
.
contextParameters
;
return
this
.
tomcat
;
}
public
void
setLoader
(
String
value
)
{
// no op to support Tomcat running as a traditional container (not embedded)
}
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
if
(
getPort
()
!=
null
)
{
container
.
setPort
(
getPort
());
}
if
(
getAddress
()
!=
null
)
{
container
.
setAddress
(
getAddress
());
}
if
(
getContextPath
()
!=
null
)
{
container
.
setContextPath
(
getContextPath
());
}
if
(
getDisplayName
()
!=
null
)
{
container
.
setDisplayName
(
getDisplayName
());
}
if
(
getSession
().
getTimeout
()
!=
null
)
{
container
.
setSessionTimeout
(
getSession
().
getTimeout
());
}
container
.
setPersistSession
(
getSession
().
isPersistent
());
if
(
getSsl
()
!=
null
)
{
container
.
setSsl
(
getSsl
());
}
if
(
getJspServlet
()
!=
null
)
{
container
.
setJspServlet
(
getJspServlet
());
}
if
(
getCompression
()
!=
null
)
{
container
.
setCompression
(
getCompression
());
}
if
(
container
instanceof
TomcatEmbeddedServletContainerFactory
)
{
getTomcat
()
.
customizeTomcat
((
TomcatEmbeddedServletContainerFactory
)
container
);
}
if
(
container
instanceof
UndertowEmbeddedServletContainerFactory
)
{
getUndertow
().
customizeUndertow
(
(
UndertowEmbeddedServletContainerFactory
)
container
);
}
container
.
addInitializers
(
new
SessionConfiguringInitializer
(
this
.
session
));
container
.
addInitializers
(
new
InitParameterConfiguringServletContextInitializer
(
getContextParameters
()));
}
public
String
[]
getPathsArray
(
Collection
<
String
>
paths
)
{
String
[]
result
=
new
String
[
paths
.
size
()];
int
i
=
0
;
for
(
String
path
:
paths
)
{
result
[
i
++]
=
getPath
(
path
);
}
return
result
;
}
public
String
[]
getPathsArray
(
String
[]
paths
)
{
String
[]
result
=
new
String
[
paths
.
length
];
int
i
=
0
;
for
(
String
path
:
paths
)
{
result
[
i
++]
=
getPath
(
path
);
}
return
result
;
}
}
public
String
getPath
(
String
path
)
{
public
Undertow
getUndertow
()
{
String
prefix
=
getServletPrefix
();
return
this
.
undertow
;
if
(!
path
.
startsWith
(
"/"
))
{
path
=
"/"
+
path
;
}
return
prefix
+
path
;
}
}
public
static
class
Session
{
public
static
class
Session
{
...
...
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