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
61dd7d1d
Commit
61dd7d1d
authored
Nov 22, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add port scan to ServerProperties (server.scan=true)
Also moved ServerProperties to autoconfigure project.
parent
d6593fbe
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
9 deletions
+41
-9
EndpointWebMvcAutoConfiguration.java
...ctuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
+1
-1
ManagementServerProperties.java
...k/boot/actuate/properties/ManagementServerProperties.java
+1
-1
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-0
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+18
-3
ServerPropertiesAutoConfiguration.java
.../autoconfigure/web/ServerPropertiesAutoConfiguration.java
+1
-2
ServerPropertiesAutoConfigurationTests.java
...configure/web/ServerPropertiesAutoConfigurationTests.java
+0
-1
ServerPropertiesTests.java
...amework/boot/autoconfigure/web/ServerPropertiesTests.java
+13
-1
JettyEmbeddedServletContainerFactory.java
.../embedded/jetty/JettyEmbeddedServletContainerFactory.java
+1
-0
TomcatEmbeddedServletContainerFactory.java
...mbedded/tomcat/TomcatEmbeddedServletContainerFactory.java
+1
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java
View file @
61dd7d1d
...
...
@@ -40,9 +40,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
;
import
org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.boot.context.embedded.properties.ServerProperties
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.ApplicationListener
;
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/properties/ManagementServerProperties.java
View file @
61dd7d1d
...
...
@@ -21,7 +21,7 @@ import java.net.InetAddress;
import
javax.validation.constraints.NotNull
;
import
org.springframework.boot.autoconfigure.security.SecurityPrequisite
;
import
org.springframework.boot.
context.embedded.properties
.ServerProperties
;
import
org.springframework.boot.
autoconfigure.web
.ServerProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.security.config.http.SessionCreationPolicy
;
import
org.springframework.util.ClassUtils
;
...
...
spring-boot-autoconfigure/pom.xml
View file @
61dd7d1d
...
...
@@ -56,6 +56,11 @@
<artifactId>
hibernate-entitymanager
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.hibernate
</groupId>
<artifactId>
hibernate-validator
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.hibernate.javax.persistence
</groupId>
<artifactId>
hibernate-jpa-2.0-api
</artifactId>
...
...
spring-boot
/src/main/java/org/springframework/boot/context/embedded/properties
/ServerProperties.java
→
spring-boot
-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web
/ServerProperties.java
View file @
61dd7d1d
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
context
.
embedded
.
properties
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
java.io.File
;
import
java.net.InetAddress
;
...
...
@@ -35,6 +35,7 @@ import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomize
import
org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -53,6 +54,8 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
private
Integer
sessionTimeout
;
private
boolean
scan
=
false
;
@NotNull
private
String
contextPath
=
""
;
...
...
@@ -78,6 +81,14 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
this
.
port
=
port
;
}
public
boolean
getScan
()
{
return
this
.
scan
;
}
public
void
setScan
(
boolean
scan
)
{
this
.
scan
=
scan
;
}
public
InetAddress
getAddress
()
{
return
this
.
address
;
}
...
...
@@ -100,8 +111,12 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainerFactory
factory
)
{
if
(
getPort
()
!=
null
)
{
factory
.
setPort
(
getPort
());
Integer
port
=
getPort
();
if
(
this
.
scan
)
{
port
=
SocketUtils
.
findAvailableTcpPort
(
port
!=
null
?
8080
:
port
);
}
if
(
port
!=
null
)
{
factory
.
setPort
(
port
);
}
if
(
getAddress
()
!=
null
)
{
factory
.
setAddress
(
getAddress
());
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.java
View file @
61dd7d1d
...
...
@@ -21,7 +21,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.properties.ServerProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
...
...
@@ -44,7 +43,7 @@ public class ServerPropertiesAutoConfiguration implements ApplicationContextAwar
private
ApplicationContext
applicationContext
;
@Bean
(
name
=
"org.springframework.boot.
context.embedded.properties
.ServerProperties"
)
@Bean
(
name
=
"org.springframework.boot.
autoconfigure.web
.ServerProperties"
)
@ConditionalOnMissingBean
public
ServerProperties
serverProperties
()
{
return
new
ServerProperties
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfigurationTests.java
View file @
61dd7d1d
...
...
@@ -32,7 +32,6 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomi
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.properties.ServerProperties
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.context.ApplicationContextException
;
import
org.springframework.context.annotation.Bean
;
...
...
spring-boot
/src/test/java/org/springframework/boot/context/embedded/properties
/ServerPropertiesTests.java
→
spring-boot
-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web
/ServerPropertiesTests.java
View file @
61dd7d1d
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
context
.
embedded
.
properties
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
;
import
java.net.InetAddress
;
import
java.util.Collections
;
...
...
@@ -24,9 +24,12 @@ import java.util.Map;
import
org.junit.Test
;
import
org.springframework.beans.MutablePropertyValues
;
import
org.springframework.boot.bind.RelaxedDataBinder
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* Tests for {@link ServerProperties}.
...
...
@@ -68,6 +71,15 @@ public class ServerPropertiesTests {
.
getProtocolHeader
());
}
@Test
public
void
testPortScan
()
throws
Exception
{
this
.
properties
.
setScan
(
true
);
this
.
properties
.
setPort
(
1000
);
ConfigurableEmbeddedServletContainerFactory
factory
=
new
MockEmbeddedServletContainerFactory
();
this
.
properties
.
customize
(
factory
);
assertTrue
(
factory
.
getPort
()
>
1000
);
}
// FIXME test customize
}
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java
View file @
61dd7d1d
...
...
@@ -123,6 +123,7 @@ public class JettyEmbeddedServletContainerFactory extends
postProcessWebAppContext
(
context
);
server
.
setHandler
(
context
);
this
.
logger
.
info
(
"Server initialized with port: "
+
getPort
());
return
getJettyEmbeddedServletContainer
(
server
);
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java
View file @
61dd7d1d
...
...
@@ -134,6 +134,7 @@ public class TomcatEmbeddedServletContainerFactory extends
tomcat
.
getEngine
().
setBackgroundProcessorDelay
(-
1
);
prepareContext
(
tomcat
.
getHost
(),
initializers
);
this
.
logger
.
info
(
"Server initialized with port: "
+
getPort
());
return
getTomcatEmbeddedServletContainer
(
tomcat
);
}
...
...
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