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
21d80d87
Commit
21d80d87
authored
May 26, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x' into 2.0.x
parents
606eb9dd
e69296d7
Changes
94
Hide whitespace changes
Inline
Side-by-side
Showing
94 changed files
with
401 additions
and
341 deletions
+401
-341
JerseyAutoConfiguration.java
...rk/boot/autoconfigure/jersey/JerseyAutoConfiguration.java
+3
-2
checkstyle-suppressions.xml
...ng-boot-parent/src/checkstyle/checkstyle-suppressions.xml
+5
-2
ZipCompression.java
...gframework/boot/gradle/tasks/bundling/ZipCompression.java
+1
-1
SampleAntApplicationIT.java
...-ant/src/test/java/sample/ant/SampleAntApplicationIT.java
+3
-2
application.properties
...boot-sample-ant/src/test/resources/application.properties
+1
-1
application.properties
...boot-sample-aop/src/main/resources/application.properties
+1
-1
SampleAtmosphereApplication.java
...n/java/sample/atmosphere/SampleAtmosphereApplication.java
+4
-4
SampleClient.java
...sample-cache/src/main/java/sample/cache/SampleClient.java
+2
-2
SampleLayout.java
...stom-layout/src/main/java/sample/layout/SampleLayout.java
+2
-0
CustomerRepository.java
...c/main/java/sample/data/cassandra/CustomerRepository.java
+3
-3
CustomerRepository.java
...in/java/sample/data/elasticsearch/CustomerRepository.java
+3
-3
CityServiceImpl.java
...rc/main/java/sample/data/jpa/service/CityServiceImpl.java
+1
-2
HotelServiceImpl.java
...c/main/java/sample/data/jpa/service/HotelServiceImpl.java
+3
-4
application-scratch.properties
...ata-jpa/src/test/resources/application-scratch.properties
+1
-1
Customer.java
...ata-mongodb/src/main/java/sample/data/mongo/Customer.java
+4
-3
application.properties
...le-data-mongodb/src/main/resources/application.properties
+0
-0
Customer.java
...-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
+2
-1
CustomerRepository.java
...j/src/main/java/sample/data/neo4j/CustomerRepository.java
+3
-3
SampleNeo4jApplicationTests.java
...t/java/sample/data/neo4j/SampleNeo4jApplicationTests.java
+3
-4
application.properties
...ample-data-rest/src/main/resources/application.properties
+1
-1
Message.java
...ample-devtools/src/main/java/sample/devtools/Message.java
+8
-2
Person.java
...oot-sample-flyway/src/main/java/sample/flyway/Person.java
+5
-1
SampleIntegrationApplicationTests.java
...tegration/consumer/SampleIntegrationApplicationTests.java
+2
-1
application.properties
...-sample-jersey1/src/main/resources/application.properties
+0
-0
application.properties
...ample-jetty-ssl/src/main/resources/application.properties
+1
-1
JooqExamples.java
...t-sample-jooq/src/main/java/sample/jooq/JooqExamples.java
+1
-0
SampleLiquibaseApplicationTests.java
...ava/sample/liquibase/SampleLiquibaseApplicationTests.java
+2
-1
SampleOAuth2ClientApplication.java
...a/sample/oauth2/client/SampleOAuth2ClientApplication.java
+1
-1
SampleOAuth2ClientApplicationTests.java
...ple/oauth2/client/SampleOAuth2ClientApplicationTests.java
+1
-1
SampleParentContextApplication.java
...in/java/sample/parent/SampleParentContextApplication.java
+5
-5
application.properties
...-parent-context/src/main/resources/application.properties
+1
-1
SampleIntegrationParentApplicationTests.java
...ent/consumer/SampleIntegrationParentApplicationTests.java
+2
-1
MessageService.java
.../src/main/java/sample/profile/service/MessageService.java
+1
-4
application.properties
...erty-validation/src/main/resources/application.properties
+1
-1
SampleJob.java
...-sample-quartz/src/main/java/sample/quartz/SampleJob.java
+4
-0
SampleQuartzApplication.java
.../src/main/java/sample/quartz/SampleQuartzApplication.java
+1
-1
SampleService.java
...ple-secure/src/main/java/sample/secure/SampleService.java
+1
-5
application.properties
...t-sample-secure/src/main/resources/application.properties
+1
-1
SampleSecureApplicationTests.java
...test/java/sample/secure/SampleSecureApplicationTests.java
+1
-1
test.properties
...ing-boot-sample-secure/src/test/resources/test.properties
+0
-0
SampleServletApplicationTests.java
...st/java/sample/servlet/SampleServletApplicationTests.java
+2
-1
VehicleIdentificationNumberNotFoundException.java
...service/VehicleIdentificationNumberNotFoundException.java
+3
-2
UserNameNotFoundException.java
.../main/java/sample/test/web/UserNameNotFoundException.java
+2
-2
application.properties
...mple-tomcat-jsp/src/main/resources/application.properties
+1
-1
SampleTomcatTwoConnectorsApplication.java
.../multiconnector/SampleTomcatTwoConnectorsApplication.java
+1
-1
SampleTomcatTwoConnectorsApplicationTests.java
...iconnector/SampleTomcatTwoConnectorsApplicationTests.java
+1
-1
NonAutoConfigurationSampleTomcatApplicationTests.java
...cat/NonAutoConfigurationSampleTomcatApplicationTests.java
+8
-8
WebConfig.java
...al/src/main/java/sample/traditional/config/WebConfig.java
+2
-1
application.properties
...le-undertow-ssl/src/main/resources/application.properties
+1
-1
application.properties
...sample-undertow/src/main/resources/application.properties
+1
-1
SampleWarApplication.java
...le-war/src/main/java/sample/war/SampleWarApplication.java
+2
-5
application.properties
...-web-freemarker/src/main/resources/application.properties
+1
-1
Message.java
...mplates/src/main/java/sample/groovytemplates/Message.java
+1
-1
application.properties
...roovy-templates/src/main/resources/application.properties
+1
-1
MessageControllerWebTests.java
...ava/sample/groovytemplates/MessageControllerWebTests.java
+6
-6
application.properties
...-sample-web-jsp/src/main/resources/application.properties
+1
-1
SampleMethodSecurityApplication.java
...mple/security/method/SampleMethodSecurityApplication.java
+14
-14
application.properties
...le-web-mustache/src/main/resources/application.properties
+1
-1
application.properties
...b-secure-custom/src/main/resources/application.properties
+1
-2
application.properties
...web-secure-jdbc/src/main/resources/application.properties
+1
-1
application.properties
...mple-web-secure/src/main/resources/application.properties
+1
-2
InMemoryMessageRepository.java
...rc/main/java/sample/web/ui/InMemoryMessageRepository.java
+1
-4
Message.java
...ot-sample-web-ui/src/main/java/sample/web/ui/Message.java
+1
-4
MessageRepository.java
...web-ui/src/main/java/sample/web/ui/MessageRepository.java
+9
-9
MessageController.java
...ui/src/main/java/sample/web/ui/mvc/MessageController.java
+3
-7
application.properties
...t-sample-web-ui/src/main/resources/application.properties
+1
-1
MessageControllerWebTests.java
...rc/test/java/sample/web/ui/MessageControllerWebTests.java
+9
-6
DefaultEchoService.java
...java/samples/websocket/jetty/echo/DefaultEchoService.java
+2
-2
ReverseWebSocketEndpoint.java
...les/websocket/jetty/reverse/ReverseWebSocketEndpoint.java
+2
-1
Direction.java
...rc/main/java/samples/websocket/jetty/snake/Direction.java
+7
-6
Location.java
...src/main/java/samples/websocket/jetty/snake/Location.java
+17
-16
Snake.java
...ty/src/main/java/samples/websocket/jetty/snake/Snake.java
+6
-6
SnakeTimer.java
...c/main/java/samples/websocket/jetty/snake/SnakeTimer.java
+10
-7
SnakeUtils.java
...c/main/java/samples/websocket/jetty/snake/SnakeUtils.java
+20
-7
SnakeWebSocketHandler.java
.../samples/websocket/jetty/snake/SnakeWebSocketHandler.java
+13
-15
SampleWebSocketsApplicationTests.java
...les/websocket/jetty/SampleWebSocketsApplicationTests.java
+2
-1
DefaultEchoService.java
...ava/samples/websocket/tomcat/echo/DefaultEchoService.java
+2
-2
ReverseWebSocketEndpoint.java
...es/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java
+2
-1
Direction.java
...c/main/java/samples/websocket/tomcat/snake/Direction.java
+7
-6
Location.java
...rc/main/java/samples/websocket/tomcat/snake/Location.java
+17
-16
Snake.java
...t/src/main/java/samples/websocket/tomcat/snake/Snake.java
+6
-6
SnakeTimer.java
.../main/java/samples/websocket/tomcat/snake/SnakeTimer.java
+13
-10
SnakeUtils.java
.../main/java/samples/websocket/tomcat/snake/SnakeUtils.java
+20
-7
SnakeWebSocketHandler.java
...samples/websocket/tomcat/snake/SnakeWebSocketHandler.java
+13
-15
SnakeTimerTests.java
.../java/samples/websocket/tomcat/snake/SnakeTimerTests.java
+2
-2
DefaultEchoService.java
...a/samples/websocket/undertow/echo/DefaultEchoService.java
+2
-2
ReverseWebSocketEndpoint.java
.../websocket/undertow/reverse/ReverseWebSocketEndpoint.java
+2
-1
Direction.java
...main/java/samples/websocket/undertow/snake/Direction.java
+7
-6
Location.java
.../main/java/samples/websocket/undertow/snake/Location.java
+17
-16
Snake.java
...src/main/java/samples/websocket/undertow/snake/Snake.java
+6
-6
SnakeTimer.java
...ain/java/samples/websocket/undertow/snake/SnakeTimer.java
+10
-7
SnakeUtils.java
...ain/java/samples/websocket/undertow/snake/SnakeUtils.java
+20
-7
SnakeWebSocketHandler.java
...mples/websocket/undertow/snake/SnakeWebSocketHandler.java
+13
-15
SnakeTimerTests.java
...ava/samples/websocket/undertow/snake/SnakeTimerTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java
View file @
21d80d87
...
@@ -237,8 +237,9 @@ public class JerseyAutoConfiguration implements ServletContextAware {
...
@@ -237,8 +237,9 @@ public class JerseyAutoConfiguration implements ServletContextAware {
final
ObjectMapper
objectMapper
)
{
final
ObjectMapper
objectMapper
)
{
addJaxbAnnotationIntrospectorIfPresent
(
objectMapper
);
addJaxbAnnotationIntrospectorIfPresent
(
objectMapper
);
return
(
ResourceConfig
config
)
->
{
return
(
ResourceConfig
config
)
->
{
config
.
register
(
JacksonFeature
.
class
);
JerseyAutoConfiguration
.
this
.
config
.
register
(
JacksonFeature
.
class
);
config
.
register
(
new
ObjectMapperContextResolver
(
objectMapper
),
JerseyAutoConfiguration
.
this
.
config
.
register
(
new
ObjectMapperContextResolver
(
objectMapper
),
ContextResolver
.
class
);
ContextResolver
.
class
);
};
};
}
}
...
...
spring-boot-project/spring-boot-parent/src/checkstyle/checkstyle-suppressions.xml
View file @
21d80d87
...
@@ -5,8 +5,7 @@
...
@@ -5,8 +5,7 @@
<suppressions>
<suppressions>
<suppress
files=
"SpringApplicationTests\.java"
checks=
"FinalClass"
/>
<suppress
files=
"SpringApplicationTests\.java"
checks=
"FinalClass"
/>
<suppress
files=
".+Configuration\.java"
checks=
"HideUtilityClassConstructor"
/>
<suppress
files=
".+Configuration\.java"
checks=
"HideUtilityClassConstructor"
/>
<suppress
files=
"LaunchScriptTestApplication\.java"
checks=
"HideUtilityClassConstructor"
/>
<suppress
files=
".+Application\.java"
checks=
"HideUtilityClassConstructor"
/>
<suppress
files=
"DevToolsTestApplication\.java"
checks=
"HideUtilityClassConstructor"
/>
<suppress
files=
"SignalUtils\.java"
checks=
"IllegalImport"
/>
<suppress
files=
"SignalUtils\.java"
checks=
"IllegalImport"
/>
<suppress
files=
"[\\/]src[\\/]test[\\/]java[\\/]cli[\\/]command[\\/]"
checks=
"ImportControl"
/>
<suppress
files=
"[\\/]src[\\/]test[\\/]java[\\/]cli[\\/]command[\\/]"
checks=
"ImportControl"
/>
<suppress
files=
"[\\/]src[\\/]main[\\/]java[\\/]sample[\\/]"
checks=
"ImportControl"
/>
<suppress
files=
"[\\/]src[\\/]main[\\/]java[\\/]sample[\\/]"
checks=
"ImportControl"
/>
...
@@ -23,4 +22,8 @@
...
@@ -23,4 +22,8 @@
<suppress
files=
"LogLevel\.java"
checks=
"JavadocVariable"
/>
<suppress
files=
"LogLevel\.java"
checks=
"JavadocVariable"
/>
<suppress
files=
"HelpMojo\.java"
checks=
".*"
/>
<suppress
files=
"HelpMojo\.java"
checks=
".*"
/>
<suppress
files=
"[\\/]org.springframework.boot.configurationprocessor.json[\\/].*\.java$"
checks=
".*"
/>
<suppress
files=
"[\\/]org.springframework.boot.configurationprocessor.json[\\/].*\.java$"
checks=
".*"
/>
<suppress
files=
"TripType\.java"
checks=
"JavadocVariable"
/>
<suppress
files=
"Rating\.java"
checks=
"JavadocVariable"
/>
<suppress
files=
"Direction\.java"
checks=
"JavadocVariable"
/>
<suppress
files=
"JooqExamples\.java"
checks=
"AvoidStaticImport"
/>
</suppressions>
</suppressions>
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/ZipCompression.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-ant/src/test/java/sample/ant/SampleAntApplicationIT.java
View file @
21d80d87
...
@@ -16,17 +16,18 @@
...
@@ -16,17 +16,18 @@
package
sample
.
ant
;
package
sample
.
ant
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.FileFilter
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.loader.tools.JavaExecutable
;
import
org.springframework.boot.loader.tools.JavaExecutable
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileCopyUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Integration Tests for {@code SampleAntApplication}.
* Integration Tests for {@code SampleAntApplication}.
*
*
...
...
spring-boot-samples/spring-boot-sample-ant/src/test/resources/application.properties
View file @
21d80d87
name
:
Phil
name
:
Phil
\ No newline at end of file
spring-boot-samples/spring-boot-sample-aop/src/main/resources/application.properties
View file @
21d80d87
name
:
Phil
name
:
Phil
\ No newline at end of file
spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java
View file @
21d80d87
...
@@ -59,6 +59,10 @@ public class SampleAtmosphereApplication {
...
@@ -59,6 +59,10 @@ public class SampleAtmosphereApplication {
return
registration
;
return
registration
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
SampleAtmosphereApplication
.
class
,
args
);
}
@Configuration
@Configuration
static
class
MvcConfiguration
implements
WebMvcConfigurer
{
static
class
MvcConfiguration
implements
WebMvcConfigurer
{
...
@@ -79,8 +83,4 @@ public class SampleAtmosphereApplication {
...
@@ -79,8 +83,4 @@ public class SampleAtmosphereApplication {
}
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SampleAtmosphereApplication
.
class
,
args
);
}
}
}
spring-boot-samples/spring-boot-sample-cache/src/main/java/sample/cache/SampleClient.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -53,7 +53,7 @@ class SampleClient {
...
@@ -53,7 +53,7 @@ class SampleClient {
private
final
Random
random
;
private
final
Random
random
;
public
SampleClient
(
CountryRepository
countryService
)
{
SampleClient
(
CountryRepository
countryService
)
{
this
.
countryService
=
countryService
;
this
.
countryService
=
countryService
;
this
.
random
=
new
Random
();
this
.
random
=
new
Random
();
}
}
...
...
spring-boot-samples/spring-boot-sample-custom-layout/src/main/java/sample/layout/SampleLayout.java
View file @
21d80d87
...
@@ -24,6 +24,8 @@ import org.springframework.boot.loader.tools.Layouts;
...
@@ -24,6 +24,8 @@ import org.springframework.boot.loader.tools.Layouts;
import
org.springframework.boot.loader.tools.LoaderClassesWriter
;
import
org.springframework.boot.loader.tools.LoaderClassesWriter
;
/**
/**
* An example layout.
*
* @author Phillip Webb
* @author Phillip Webb
*/
*/
public
class
SampleLayout
extends
Layouts
.
Jar
implements
CustomLoaderLayout
{
public
class
SampleLayout
extends
Layouts
.
Jar
implements
CustomLoaderLayout
{
...
...
spring-boot-samples/spring-boot-sample-data-cassandra/src/main/java/sample/data/cassandra/CustomerRepository.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -24,9 +24,9 @@ import org.springframework.data.repository.CrudRepository;
...
@@ -24,9 +24,9 @@ import org.springframework.data.repository.CrudRepository;
public
interface
CustomerRepository
extends
CrudRepository
<
Customer
,
String
>
{
public
interface
CustomerRepository
extends
CrudRepository
<
Customer
,
String
>
{
@Query
(
"Select * from customer where firstname=?0"
)
@Query
(
"Select * from customer where firstname=?0"
)
public
Customer
findByFirstName
(
String
firstName
);
Customer
findByFirstName
(
String
firstName
);
@Query
(
"Select * from customer where lastname=?0"
)
@Query
(
"Select * from customer where lastname=?0"
)
public
List
<
Customer
>
findByLastName
(
String
lastName
);
List
<
Customer
>
findByLastName
(
String
lastName
);
}
}
spring-boot-samples/spring-boot-sample-data-elasticsearch/src/main/java/sample/data/elasticsearch/CustomerRepository.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,8 +22,8 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
...
@@ -22,8 +22,8 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
public
interface
CustomerRepository
extends
ElasticsearchRepository
<
Customer
,
String
>
{
public
interface
CustomerRepository
extends
ElasticsearchRepository
<
Customer
,
String
>
{
public
Customer
findByFirstName
(
String
firstName
);
Customer
findByFirstName
(
String
firstName
);
public
List
<
Customer
>
findByLastName
(
String
lastName
);
List
<
Customer
>
findByLastName
(
String
lastName
);
}
}
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/CityServiceImpl.java
View file @
21d80d87
...
@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
...
@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
private
final
HotelRepository
hotelRepository
;
private
final
HotelRepository
hotelRepository
;
public
CityServiceImpl
(
CityRepository
cityRepository
,
CityServiceImpl
(
CityRepository
cityRepository
,
HotelRepository
hotelRepository
)
{
HotelRepository
hotelRepository
)
{
this
.
cityRepository
=
cityRepository
;
this
.
cityRepository
=
cityRepository
;
this
.
hotelRepository
=
hotelRepository
;
this
.
hotelRepository
=
hotelRepository
;
}
}
...
...
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java
View file @
21d80d87
...
@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
...
@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
private
final
ReviewRepository
reviewRepository
;
private
final
ReviewRepository
reviewRepository
;
public
HotelServiceImpl
(
HotelRepository
hotelRepository
,
HotelServiceImpl
(
HotelRepository
hotelRepository
,
ReviewRepository
reviewRepository
)
{
ReviewRepository
reviewRepository
)
{
this
.
hotelRepository
=
hotelRepository
;
this
.
hotelRepository
=
hotelRepository
;
this
.
reviewRepository
=
reviewRepository
;
this
.
reviewRepository
=
reviewRepository
;
}
}
...
@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
...
@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
private
final
Map
<
Rating
,
Long
>
ratingCount
;
private
final
Map
<
Rating
,
Long
>
ratingCount
;
public
ReviewsSummaryImpl
(
List
<
RatingCount
>
ratingCounts
)
{
ReviewsSummaryImpl
(
List
<
RatingCount
>
ratingCounts
)
{
this
.
ratingCount
=
new
HashMap
<>();
this
.
ratingCount
=
new
HashMap
<>();
for
(
RatingCount
ratingCount
:
ratingCounts
)
{
for
(
RatingCount
ratingCount
:
ratingCounts
)
{
this
.
ratingCount
.
put
(
ratingCount
.
getRating
(),
ratingCount
.
getCount
());
this
.
ratingCount
.
put
(
ratingCount
.
getRating
(),
ratingCount
.
getCount
());
...
@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
...
@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
@Override
@Override
public
long
getNumberOfReviewsWithRating
(
Rating
rating
)
{
public
long
getNumberOfReviewsWithRating
(
Rating
rating
)
{
Long
count
=
this
.
ratingCount
.
get
(
rating
);
Long
count
=
this
.
ratingCount
.
get
(
rating
);
return
count
==
null
?
0
:
count
;
return
(
count
!=
null
?
count
:
0
)
;
}
}
}
}
...
...
spring-boot-samples/spring-boot-sample-data-jpa/src/test/resources/application-scratch.properties
View file @
21d80d87
spring.datasource.name
=
scratchdb
spring.datasource.name
=
scratchdb
spring.jmx.default-domain
=
jpa.sample
spring.jmx.default-domain
=
jpa.sample
\ No newline at end of file
spring-boot-samples/spring-boot-sample-data-mongodb/src/main/java/sample/data/mongo/Customer.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -24,6 +24,7 @@ public class Customer {
...
@@ -24,6 +24,7 @@ public class Customer {
private
String
id
;
private
String
id
;
private
String
firstName
;
private
String
firstName
;
private
String
lastName
;
private
String
lastName
;
public
Customer
()
{
public
Customer
()
{
...
@@ -36,8 +37,8 @@ public class Customer {
...
@@ -36,8 +37,8 @@ public class Customer {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
String
.
format
(
"Customer[id=%s, firstName='%s', lastName='%s']"
,
id
,
return
String
.
format
(
"Customer[id=%s, firstName='%s', lastName='%s']"
,
this
.
id
,
firstName
,
lastName
);
this
.
firstName
,
this
.
lastName
);
}
}
}
}
spring-boot-samples/spring-boot-sample-data-mongodb/src/main/resources/application.properties
deleted
100644 → 0
View file @
606eb9dd
spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -28,6 +28,7 @@ public class Customer {
...
@@ -28,6 +28,7 @@ public class Customer {
private
Long
id
;
private
Long
id
;
private
String
firstName
;
private
String
firstName
;
private
String
lastName
;
private
String
lastName
;
public
Customer
()
{
public
Customer
()
{
...
...
spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/CustomerRepository.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,8 +22,8 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
...
@@ -22,8 +22,8 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
public
interface
CustomerRepository
extends
Neo4jRepository
<
Customer
,
Long
>
{
public
interface
CustomerRepository
extends
Neo4jRepository
<
Customer
,
Long
>
{
public
Customer
findByFirstName
(
String
firstName
);
Customer
findByFirstName
(
String
firstName
);
public
List
<
Customer
>
findByLastName
(
String
lastName
);
List
<
Customer
>
findByLastName
(
String
lastName
);
}
}
spring-boot-samples/spring-boot-sample-data-neo4j/src/test/java/sample/data/neo4j/SampleNeo4jApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,7 +22,7 @@ import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
...
@@ -22,7 +22,7 @@ import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;
import
org.springframework.boot.test.rule.OutputCapture
;
import
org.springframework.boot.test.rule.OutputCapture
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Tests for {@link SampleNeo4jApplication}.
* Tests for {@link SampleNeo4jApplication}.
...
@@ -45,8 +45,7 @@ public class SampleNeo4jApplicationTests {
...
@@ -45,8 +45,7 @@ public class SampleNeo4jApplicationTests {
}
}
}
}
String
output
=
this
.
outputCapture
.
toString
();
String
output
=
this
.
outputCapture
.
toString
();
assertTrue
(
"Wrong output: "
+
output
,
assertThat
(
output
).
contains
(
"firstName='Alice', lastName='Smith'"
);
output
.
contains
(
"firstName='Alice', lastName='Smith'"
));
}
}
private
boolean
neo4jServerRunning
(
Throwable
ex
)
{
private
boolean
neo4jServerRunning
(
Throwable
ex
)
{
...
...
spring-boot-samples/spring-boot-sample-data-rest/src/main/resources/application.properties
View file @
21d80d87
spring.data.rest.base-path
=
/api
spring.data.rest.base-path
=
/api
\ No newline at end of file
spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/Message.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,8 +16,14 @@
...
@@ -16,8 +16,14 @@
package
sample
.
devtools
;
package
sample
.
devtools
;
public
class
Message
{
public
final
class
Message
{
/**
* Sample message.
*/
public
static
String
MESSAGE
=
"Message"
;
public
static
String
MESSAGE
=
"Message"
;
private
Message
()
{
}
}
}
spring-boot-samples/spring-boot-sample-flyway/src/main/java/sample/flyway/Person.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -23,11 +23,14 @@ import javax.persistence.SequenceGenerator;
...
@@ -23,11 +23,14 @@ import javax.persistence.SequenceGenerator;
@Entity
@Entity
public
class
Person
{
public
class
Person
{
@Id
@Id
@SequenceGenerator
(
name
=
"person_generator"
,
sequenceName
=
"person_sequence"
,
allocationSize
=
1
)
@SequenceGenerator
(
name
=
"person_generator"
,
sequenceName
=
"person_sequence"
,
allocationSize
=
1
)
@GeneratedValue
(
generator
=
"person_generator"
)
@GeneratedValue
(
generator
=
"person_generator"
)
private
Long
id
;
private
Long
id
;
private
String
firstName
;
private
String
firstName
;
private
String
lastName
;
private
String
lastName
;
public
String
getFirstName
()
{
public
String
getFirstName
()
{
...
@@ -51,4 +54,5 @@ public class Person {
...
@@ -51,4 +54,5 @@ public class Person {
return
"Person [firstName="
+
this
.
firstName
+
", lastName="
+
this
.
lastName
return
"Person [firstName="
+
this
.
firstName
+
", lastName="
+
this
.
lastName
+
"]"
;
+
"]"
;
}
}
}
}
spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -119,4 +119,5 @@ public class SampleIntegrationApplicationTests {
...
@@ -119,4 +119,5 @@ public class SampleIntegrationApplicationTests {
}
}
return
candidates
;
return
candidates
;
}
}
}
}
spring-boot-samples/spring-boot-sample-jersey1/src/main/resources/application.properties
deleted
100644 → 0
View file @
606eb9dd
spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/resources/application.properties
View file @
21d80d87
server.port
=
8443
server.port
=
8443
server.ssl.key-store
=
classpath:sample.jks
server.ssl.key-store
=
classpath:sample.jks
server.ssl.key-store-password
=
secret
server.ssl.key-store-password
=
secret
server.ssl.key-password
=
password
server.ssl.key-password
=
password
\ No newline at end of file
spring-boot-samples/spring-boot-sample-jooq/src/main/java/sample/jooq/JooqExamples.java
View file @
21d80d87
...
@@ -76,4 +76,5 @@ public class JooqExamples implements CommandLineRunner {
...
@@ -76,4 +76,5 @@ public class JooqExamples implements CommandLineRunner {
});
});
System
.
out
.
println
(
"jOOQ SQL "
+
list
);
System
.
out
.
println
(
"jOOQ SQL "
+
list
);
}
}
}
}
spring-boot-samples/spring-boot-sample-liquibase/src/test/java/sample/liquibase/SampleLiquibaseApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -68,4 +68,5 @@ public class SampleLiquibaseApplicationTests {
...
@@ -68,4 +68,5 @@ public class SampleLiquibaseApplicationTests {
}
}
return
false
;
return
false
;
}
}
}
}
spring-boot-samples/spring-boot-sample-oauth2-client/src/main/java/sample/oauth2/client/SampleOAuth2ClientApplication.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-oauth2-client/src/test/java/sample/oauth2/client/SampleOAuth2ClientApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-parent-context/src/main/java/sample/parent/SampleParentContextApplication.java
View file @
21d80d87
...
@@ -36,6 +36,11 @@ import org.springframework.integration.file.FileWritingMessageHandler;
...
@@ -36,6 +36,11 @@ import org.springframework.integration.file.FileWritingMessageHandler;
@EnableConfigurationProperties
(
ServiceProperties
.
class
)
@EnableConfigurationProperties
(
ServiceProperties
.
class
)
public
class
SampleParentContextApplication
{
public
class
SampleParentContextApplication
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
SpringApplicationBuilder
(
Parent
.
class
)
.
child
(
SampleParentContextApplication
.
class
).
run
(
args
);
}
@EnableAutoConfiguration
@EnableAutoConfiguration
protected
static
class
Parent
{
protected
static
class
Parent
{
...
@@ -83,9 +88,4 @@ public class SampleParentContextApplication {
...
@@ -83,9 +88,4 @@ public class SampleParentContextApplication {
}
}
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
Parent
.
class
)
.
child
(
SampleParentContextApplication
.
class
).
run
(
args
);
}
}
}
spring-boot-samples/spring-boot-sample-parent-context/src/main/resources/application.properties
View file @
21d80d87
service.greeting
=
Hello
service.greeting
=
Hello
\ No newline at end of file
spring-boot-samples/spring-boot-sample-parent-context/src/test/java/sample/parent/consumer/SampleIntegrationParentApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -99,4 +99,5 @@ public class SampleIntegrationParentApplicationTests {
...
@@ -99,4 +99,5 @@ public class SampleIntegrationParentApplicationTests {
}
}
return
builder
.
toString
();
return
builder
.
toString
();
}
}
}
}
spring-boot-samples/spring-boot-sample-profile/src/main/java/sample/profile/service/MessageService.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,9 +16,6 @@
...
@@ -16,9 +16,6 @@
package
sample
.
profile
.
service
;
package
sample
.
profile
.
service
;
/**
* @author Dave Syer
*/
public
interface
MessageService
{
public
interface
MessageService
{
String
getMessage
();
String
getMessage
();
...
...
spring-boot-samples/spring-boot-sample-property-validation/src/main/resources/application.properties
View file @
21d80d87
sample.host
=
192.168.0.1
sample.host
=
192.168.0.1
sample.port
=
7070
sample.port
=
7070
\ No newline at end of file
spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
View file @
21d80d87
/*
/*
<<<<<<< HEAD:spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2017 the original author or authors.
=======
* Copyright 2012-2018 the original author or authors.
>>>>>>> local15x/1.5.x:spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/CitySearchCriteria.java
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,10 +20,6 @@ import org.springframework.security.access.annotation.Secured;
...
@@ -20,10 +20,6 @@ import org.springframework.security.access.annotation.Secured;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
/**
* @author Dave Syer
*
*/
@Service
@Service
public
class
SampleService
{
public
class
SampleService
{
...
...
spring-boot-samples/spring-boot-sample-secure/src/main/resources/application.properties
View file @
21d80d87
# debug: true
# debug: true
spring.security.user.name
=
user
spring.security.user.name
=
user
spring.security.user.password
=
password
spring.security.user.password
=
password
spring.security.user.roles
=
USER
spring.security.user.roles
=
USER
\ No newline at end of file
spring-boot-samples/spring-boot-sample-secure/src/test/java/sample/secure/SampleSecureApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-secure/src/test/resources/test.properties
deleted
100644 → 0
View file @
606eb9dd
spring-boot-samples/spring-boot-sample-servlet/src/test/java/sample/servlet/SampleServletApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -67,4 +67,5 @@ public class SampleServletApplicationTests {
...
@@ -67,4 +67,5 @@ public class SampleServletApplicationTests {
private
String
getPassword
()
{
private
String
getPassword
()
{
return
"password"
;
return
"password"
;
}
}
}
}
spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleIdentificationNumberNotFoundException.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -25,7 +25,7 @@ import sample.test.domain.VehicleIdentificationNumber;
...
@@ -25,7 +25,7 @@ import sample.test.domain.VehicleIdentificationNumber;
*/
*/
public
class
VehicleIdentificationNumberNotFoundException
extends
RuntimeException
{
public
class
VehicleIdentificationNumberNotFoundException
extends
RuntimeException
{
private
VehicleIdentificationNumber
vehicleIdentificationNumber
;
private
final
VehicleIdentificationNumber
vehicleIdentificationNumber
;
public
VehicleIdentificationNumberNotFoundException
(
VehicleIdentificationNumber
vin
)
{
public
VehicleIdentificationNumberNotFoundException
(
VehicleIdentificationNumber
vin
)
{
this
(
vin
,
null
);
this
(
vin
,
null
);
...
@@ -40,4 +40,5 @@ public class VehicleIdentificationNumberNotFoundException extends RuntimeExcepti
...
@@ -40,4 +40,5 @@ public class VehicleIdentificationNumberNotFoundException extends RuntimeExcepti
public
VehicleIdentificationNumber
getVehicleIdentificationNumber
()
{
public
VehicleIdentificationNumber
getVehicleIdentificationNumber
()
{
return
this
.
vehicleIdentificationNumber
;
return
this
.
vehicleIdentificationNumber
;
}
}
}
}
spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/web/UserNameNotFoundException.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
...
@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
public
class
UserNameNotFoundException
extends
RuntimeException
{
public
class
UserNameNotFoundException
extends
RuntimeException
{
private
String
username
;
private
final
String
username
;
public
UserNameNotFoundException
(
String
username
)
{
public
UserNameNotFoundException
(
String
username
)
{
this
.
username
=
username
;
this
.
username
=
username
;
...
...
spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/resources/application.properties
View file @
21d80d87
spring.mvc.view.prefix
:
/WEB-INF/jsp/
spring.mvc.view.prefix
:
/WEB-INF/jsp/
spring.mvc.view.suffix
:
.jsp
spring.mvc.view.suffix
:
.jsp
application.message
:
Hello Phil
application.message
:
Hello Phil
\ No newline at end of file
spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplication.java
View file @
21d80d87
...
@@ -25,7 +25,7 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
...
@@ -25,7 +25,7 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
/**
/**
* Sample Application to show Tomcat running two connectors
* Sample Application to show Tomcat running two connectors
.
*
*
* @author Brock Mills
* @author Brock Mills
* @author Andy Wilkinson
* @author Andy Wilkinson
...
...
spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/test/java/sample/tomcat/multiconnector/SampleTomcatTwoConnectorsApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-tomcat/src/test/java/sample/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -52,6 +52,13 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
...
@@ -52,6 +52,13 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Autowired
@Autowired
private
TestRestTemplate
restTemplate
;
private
TestRestTemplate
restTemplate
;
@Test
public
void
testHome
()
throws
Exception
{
ResponseEntity
<
String
>
entity
=
this
.
restTemplate
.
getForEntity
(
"/"
,
String
.
class
);
assertThat
(
entity
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
entity
.
getBody
()).
isEqualTo
(
"Hello World"
);
}
@Configuration
@Configuration
@Import
({
ServletWebServerFactoryAutoConfiguration
.
class
,
@Import
({
ServletWebServerFactoryAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
...
@@ -67,11 +74,4 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
...
@@ -67,11 +74,4 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
}
}
@Test
public
void
testHome
()
{
ResponseEntity
<
String
>
entity
=
this
.
restTemplate
.
getForEntity
(
"/"
,
String
.
class
);
assertThat
(
entity
.
getStatusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
entity
.
getBody
()).
isEqualTo
(
"Hello World"
);
}
}
}
spring-boot-samples/spring-boot-sample-traditional/src/main/java/sample/traditional/config/WebConfig.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -55,4 +55,5 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -55,4 +55,5 @@ public class WebConfig implements WebMvcConfigurer {
DefaultServletHandlerConfigurer
configurer
)
{
DefaultServletHandlerConfigurer
configurer
)
{
configurer
.
enable
();
configurer
.
enable
();
}
}
}
}
spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/resources/application.properties
View file @
21d80d87
server.port
=
8443
server.port
=
8443
server.ssl.key-store
=
classpath:sample.jks
server.ssl.key-store
=
classpath:sample.jks
server.ssl.key-store-password
=
secret
server.ssl.key-store-password
=
secret
server.ssl.key-password
=
password
server.ssl.key-password
=
password
\ No newline at end of file
spring-boot-samples/spring-boot-sample-undertow/src/main/resources/application.properties
View file @
21d80d87
...
@@ -2,4 +2,4 @@ server.undertow.accesslog.enabled=true
...
@@ -2,4 +2,4 @@ server.undertow.accesslog.enabled=true
server.undertow.accesslog.dir
=
target/logs
server.undertow.accesslog.dir
=
target/logs
server.undertow.accesslog.pattern
=
combined
server.undertow.accesslog.pattern
=
combined
server.compression.enabled
=
true
server.compression.enabled
=
true
server.compression.min-response-size
=
1
server.compression.min-response-size
=
1
\ No newline at end of file
spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/SampleWarApplication.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,11 +21,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
...
@@ -21,11 +21,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.context.annotation.PropertySource
;
/**
* Sample WAR application
*/
@SpringBootApplication
@SpringBootApplication
@PropertySource
(
value
=
{
"WEB-INF/custom.properties"
}
)
@PropertySource
(
"WEB-INF/custom.properties"
)
public
class
SampleWarApplication
extends
SpringBootServletInitializer
{
public
class
SampleWarApplication
extends
SpringBootServletInitializer
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/application.properties
View file @
21d80d87
application.message
:
Hello, Andy
application.message
:
Hello, Andy
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/Message.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
...
spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/resources/application.properties
View file @
21d80d87
# Allow templates to be reloaded at dev time
# Allow templates to be reloaded at dev time
spring.groovy.template.cache
:
false
spring.groovy.template.cache
:
false
logging.level.org.springframework.web
:
INFO
logging.level.org.springframework.web
:
INFO
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-groovy-templates/src/test/java/sample/groovytemplates/MessageControllerWebTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -82,14 +82,10 @@ public class MessageControllerWebTests {
...
@@ -82,14 +82,10 @@ public class MessageControllerWebTests {
private
final
String
regex
;
private
final
String
regex
;
public
RegexMatcher
(
String
regex
)
{
RegexMatcher
(
String
regex
)
{
this
.
regex
=
regex
;
this
.
regex
=
regex
;
}
}
public
static
org
.
hamcrest
.
Matcher
<
java
.
lang
.
String
>
matches
(
String
regex
)
{
return
new
RegexMatcher
(
regex
);
}
@Override
@Override
public
boolean
matchesSafely
(
String
item
)
{
public
boolean
matchesSafely
(
String
item
)
{
return
Pattern
.
compile
(
this
.
regex
).
matcher
(
item
).
find
();
return
Pattern
.
compile
(
this
.
regex
).
matcher
(
item
).
find
();
...
@@ -106,6 +102,10 @@ public class MessageControllerWebTests {
...
@@ -106,6 +102,10 @@ public class MessageControllerWebTests {
.
appendText
(
this
.
regex
);
.
appendText
(
this
.
regex
);
}
}
public
static
org
.
hamcrest
.
Matcher
<
java
.
lang
.
String
>
matches
(
String
regex
)
{
return
new
RegexMatcher
(
regex
);
}
}
}
}
}
spring-boot-samples/spring-boot-sample-web-jsp/src/main/resources/application.properties
View file @
21d80d87
spring.mvc.view.prefix
:
/WEB-INF/jsp/
spring.mvc.view.prefix
:
/WEB-INF/jsp/
spring.mvc.view.suffix
:
.jsp
spring.mvc.view.suffix
:
.jsp
application.message
:
Hello Phil
application.message
:
Hello Phil
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java
View file @
21d80d87
...
@@ -42,20 +42,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
...
@@ -42,20 +42,6 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableGlobalMethodSecurity
(
securedEnabled
=
true
)
@EnableGlobalMethodSecurity
(
securedEnabled
=
true
)
public
class
SampleMethodSecurityApplication
implements
WebMvcConfigurer
{
public
class
SampleMethodSecurityApplication
implements
WebMvcConfigurer
{
@Controller
protected
static
class
HomeController
{
@GetMapping
(
"/"
)
@Secured
(
"ROLE_ADMIN"
)
public
String
home
(
Map
<
String
,
Object
>
model
)
{
model
.
put
(
"message"
,
"Hello World"
);
model
.
put
(
"title"
,
"Hello Home"
);
model
.
put
(
"date"
,
new
Date
());
return
"home"
;
}
}
@Override
@Override
public
void
addViewControllers
(
ViewControllerRegistry
registry
)
{
public
void
addViewControllers
(
ViewControllerRegistry
registry
)
{
registry
.
addViewController
(
"/login"
).
setViewName
(
"login"
);
registry
.
addViewController
(
"/login"
).
setViewName
(
"login"
);
...
@@ -118,4 +104,18 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer {
...
@@ -118,4 +104,18 @@ public class SampleMethodSecurityApplication implements WebMvcConfigurer {
}
}
@Controller
protected
static
class
HomeController
{
@GetMapping
(
"/"
)
@Secured
(
"ROLE_ADMIN"
)
public
String
home
(
Map
<
String
,
Object
>
model
)
{
model
.
put
(
"message"
,
"Hello World"
);
model
.
put
(
"title"
,
"Hello Home"
);
model
.
put
(
"date"
,
new
Date
());
return
"home"
;
}
}
}
}
spring-boot-samples/spring-boot-sample-web-mustache/src/main/resources/application.properties
View file @
21d80d87
application.message
:
Hello, Andy
application.message
:
Hello, Andy
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/resources/application.properties
View file @
21d80d87
spring.thymeleaf.cache
:
false
spring.thymeleaf.cache
:
false
logging.level.org.springframework.security
:
INFO
logging.level.org.springframework.security
:
INFO
spring.security.user.name
=
user
spring.security.user.name
=
user
spring.security.user.password
=
password
spring.security.user.password
=
password
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/resources/application.properties
View file @
21d80d87
debug
:
true
debug
:
true
spring.thymeleaf.cache
:
false
spring.thymeleaf.cache
:
false
logging.level.org.springframework.security
:
INFO
logging.level.org.springframework.security
:
INFO
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-secure/src/main/resources/application.properties
View file @
21d80d87
...
@@ -2,6 +2,5 @@ spring.thymeleaf.cache: false
...
@@ -2,6 +2,5 @@ spring.thymeleaf.cache: false
# demo only:
# demo only:
logging.level.org.springframework.security
:
INFO
logging.level.org.springframework.security
:
INFO
logging.level.org.springframework.boot.actuate.audit.listener.AuditListener
:
DEBUG
logging.level.org.springframework.boot.actuate.audit.listener.AuditListener
:
DEBUG
spring.security.user.name
=
user
spring.security.user.name
=
user
spring.security.user.password
=
password
spring.security.user.password
=
password
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/InMemoryMessageRepository.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
* @author Dave Syer
*/
public
class
InMemoryMessageRepository
implements
MessageRepository
{
public
class
InMemoryMessageRepository
implements
MessageRepository
{
private
static
AtomicLong
counter
=
new
AtomicLong
();
private
static
AtomicLong
counter
=
new
AtomicLong
();
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/Message.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -20,9 +20,6 @@ import java.util.Calendar;
...
@@ -20,9 +20,6 @@ import java.util.Calendar;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotEmpty
;
/**
* @author Rob Winch
*/
public
class
Message
{
public
class
Message
{
private
Long
id
;
private
Long
id
;
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/MessageRepository.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* Licensed under the Apache License, Version 2.0 (the "License");
* the License. You may obtain a copy of the License at
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* Unless required by applicable law or agreed to in writing, software
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* distributed under the License is distributed on an "AS IS" BASIS,
* specific language governing permissions and limitations under the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/
package
sample
.
web
.
ui
;
package
sample
.
web
.
ui
;
/**
* @author Rob Winch
*/
public
interface
MessageRepository
{
public
interface
MessageRepository
{
Iterable
<
Message
>
findAll
();
Iterable
<
Message
>
findAll
();
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
/**
* @author Rob Winch
* @author Doo-Hwan Kwak
*/
@Controller
@Controller
@RequestMapping
(
"/"
)
@RequestMapping
(
"/"
)
public
class
MessageController
{
public
class
MessageController
{
...
@@ -77,14 +73,14 @@ public class MessageController {
...
@@ -77,14 +73,14 @@ public class MessageController {
throw
new
RuntimeException
(
"Expected exception in controller"
);
throw
new
RuntimeException
(
"Expected exception in controller"
);
}
}
@GetMapping
(
value
=
"delete/{id}"
)
@GetMapping
(
"delete/{id}"
)
public
ModelAndView
delete
(
@PathVariable
(
"id"
)
Long
id
)
{
public
ModelAndView
delete
(
@PathVariable
(
"id"
)
Long
id
)
{
this
.
messageRepository
.
deleteMessage
(
id
);
this
.
messageRepository
.
deleteMessage
(
id
);
Iterable
<
Message
>
messages
=
this
.
messageRepository
.
findAll
();
Iterable
<
Message
>
messages
=
this
.
messageRepository
.
findAll
();
return
new
ModelAndView
(
"messages/list"
,
"messages"
,
messages
);
return
new
ModelAndView
(
"messages/list"
,
"messages"
,
messages
);
}
}
@GetMapping
(
value
=
"modify/{id}"
)
@GetMapping
(
"modify/{id}"
)
public
ModelAndView
modifyForm
(
@PathVariable
(
"id"
)
Message
message
)
{
public
ModelAndView
modifyForm
(
@PathVariable
(
"id"
)
Message
message
)
{
return
new
ModelAndView
(
"messages/form"
,
"message"
,
message
);
return
new
ModelAndView
(
"messages/form"
,
"message"
,
message
);
}
}
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/application.properties
View file @
21d80d87
# Allow Thymeleaf templates to be reloaded at dev time
# Allow Thymeleaf templates to be reloaded at dev time
spring.thymeleaf.cache
:
false
spring.thymeleaf.cache
:
false
server.tomcat.access_log_enabled
:
true
server.tomcat.access_log_enabled
:
true
server.tomcat.basedir
:
target/tomcat
server.tomcat.basedir
:
target/tomcat
\ No newline at end of file
spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/web/ui/MessageControllerWebTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -81,16 +81,13 @@ public class MessageControllerWebTests {
...
@@ -81,16 +81,13 @@ public class MessageControllerWebTests {
}
}
private
static
class
RegexMatcher
extends
TypeSafeMatcher
<
String
>
{
private
static
class
RegexMatcher
extends
TypeSafeMatcher
<
String
>
{
private
final
String
regex
;
private
final
String
regex
;
public
RegexMatcher
(
String
regex
)
{
RegexMatcher
(
String
regex
)
{
this
.
regex
=
regex
;
this
.
regex
=
regex
;
}
}
public
static
org
.
hamcrest
.
Matcher
<
java
.
lang
.
String
>
matches
(
String
regex
)
{
return
new
RegexMatcher
(
regex
);
}
@Override
@Override
public
boolean
matchesSafely
(
String
item
)
{
public
boolean
matchesSafely
(
String
item
)
{
return
Pattern
.
compile
(
this
.
regex
).
matcher
(
item
).
find
();
return
Pattern
.
compile
(
this
.
regex
).
matcher
(
item
).
find
();
...
@@ -106,5 +103,11 @@ public class MessageControllerWebTests {
...
@@ -106,5 +103,11 @@ public class MessageControllerWebTests {
description
.
appendText
(
"a string that matches regex: "
)
description
.
appendText
(
"a string that matches regex: "
)
.
appendText
(
this
.
regex
);
.
appendText
(
this
.
regex
);
}
}
public
static
org
.
hamcrest
.
Matcher
<
java
.
lang
.
String
>
matches
(
String
regex
)
{
return
new
RegexMatcher
(
regex
);
}
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private
final
String
echoFormat
;
private
final
String
echoFormat
;
public
DefaultEchoService
(
String
echoFormat
)
{
public
DefaultEchoService
(
String
echoFormat
)
{
this
.
echoFormat
=
(
echoFormat
!=
null
)
?
echoFormat
:
"%s"
;
this
.
echoFormat
=
(
echoFormat
!=
null
?
echoFormat
:
"%s"
)
;
}
}
@Override
@Override
...
...
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/reverse/ReverseWebSocketEndpoint.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session
.
getBasicRemote
()
session
.
getBasicRemote
()
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Direction.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -18,5 +17,7 @@
...
@@ -18,5 +17,7 @@
package
samples
.
websocket
.
jetty
.
snake
;
package
samples
.
websocket
.
jetty
.
snake
;
public
enum
Direction
{
public
enum
Direction
{
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Location.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -19,11 +18,15 @@ package samples.websocket.jetty.snake;
...
@@ -19,11 +18,15 @@ package samples.websocket.jetty.snake;
public
class
Location
{
public
class
Location
{
/**
* The X location.
*/
public
int
x
;
public
int
x
;
/**
* The Y location.
*/
public
int
y
;
public
int
y
;
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
Location
(
int
x
,
int
y
)
{
public
Location
(
int
x
,
int
y
)
{
this
.
x
=
x
;
this
.
x
=
x
;
...
@@ -33,13 +36,13 @@ public class Location {
...
@@ -33,13 +36,13 @@ public class Location {
public
Location
getAdjacentLocation
(
Direction
direction
)
{
public
Location
getAdjacentLocation
(
Direction
direction
)
{
switch
(
direction
)
{
switch
(
direction
)
{
case
NORTH:
case
NORTH:
return
new
Location
(
this
.
x
,
this
.
y
-
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
-
SnakeUtils
.
GRID_SIZE
);
case
SOUTH:
case
SOUTH:
return
new
Location
(
this
.
x
,
this
.
y
+
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
+
SnakeUtils
.
GRID_SIZE
);
case
EAST:
case
EAST:
return
new
Location
(
this
.
x
+
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
+
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
WEST:
case
WEST:
return
new
Location
(
this
.
x
-
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
-
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
NONE:
case
NONE:
// fall through
// fall through
default
:
default
:
...
@@ -55,16 +58,13 @@ public class Location {
...
@@ -55,16 +58,13 @@ public class Location {
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
return
false
;
}
}
Location
location
=
(
Location
)
o
;
Location
location
=
(
Location
)
o
;
if
(
this
.
x
!=
location
.
x
)
{
if
(
this
.
x
!=
location
.
x
)
{
return
false
;
return
false
;
}
}
if
(
this
.
y
!=
location
.
y
)
{
if
(
this
.
y
!=
location
.
y
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
...
@@ -74,4 +74,5 @@ public class Location {
...
@@ -74,4 +74,5 @@ public class Location {
result
=
31
*
result
+
this
.
y
;
result
=
31
*
result
+
this
.
y
;
return
result
;
return
result
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/Snake.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -157,4 +156,5 @@ public class Snake {
...
@@ -157,4 +156,5 @@ public class Snake {
public
String
getHexColor
()
{
public
String
getHexColor
()
{
return
this
.
hexColor
;
return
this
.
hexColor
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeTimer.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
...
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
/**
/**
* Sets up the timer for the multi-player snake game WebSocket example.
* Sets up the timer for the multi-player snake game WebSocket example.
*/
*/
public
class
SnakeTimer
{
public
final
class
SnakeTimer
{
private
static
final
long
TICK_DELAY
=
100
;
private
static
final
long
TICK_DELAY
=
100
;
...
@@ -43,6 +42,9 @@ public class SnakeTimer {
...
@@ -43,6 +42,9 @@ public class SnakeTimer {
private
static
Timer
gameTimer
=
null
;
private
static
Timer
gameTimer
=
null
;
private
SnakeTimer
()
{
}
public
static
void
addSnake
(
Snake
snake
)
{
public
static
void
addSnake
(
Snake
snake
)
{
synchronized
(
MONITOR
)
{
synchronized
(
MONITOR
)
{
if
(
snakes
.
isEmpty
())
{
if
(
snakes
.
isEmpty
())
{
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer
.
cancel
();
gameTimer
.
cancel
();
}
}
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeUtils.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -20,14 +19,28 @@ package samples.websocket.jetty.snake;
...
@@ -20,14 +19,28 @@ package samples.websocket.jetty.snake;
import
java.awt.Color
;
import
java.awt.Color
;
import
java.util.Random
;
import
java.util.Random
;
public
class
SnakeUtils
{
public
final
class
SnakeUtils
{
/**
* The width of the playfield.
*/
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
/**
* The height of the playfield.
*/
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
/**
* The grid size.
*/
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
SnakeUtils
()
{
}
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
float
hue
=
random
.
nextFloat
();
float
hue
=
random
.
nextFloat
();
// sat between 0.1 and 0.3
// sat between 0.1 and 0.3
...
...
spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/snake/SnakeWebSocketHandler.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
final
int
id
;
private
final
int
id
;
private
Snake
snake
;
private
Snake
snake
;
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
}
public
static
Location
getRandomLocation
()
{
public
static
Location
getRandomLocation
()
{
int
x
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_WIDTH
));
int
x
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_WIDTH
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_HEIGHT
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_HEIGHT
));
return
new
Location
(
x
,
y
);
return
new
Location
(
x
,
y
);
}
}
private
static
int
roundByGridSize
(
int
value
)
{
private
static
int
roundByGridSize
(
int
value
)
{
value
=
value
+
(
GRID_SIZE
/
2
);
value
=
value
+
(
SnakeUtils
.
GRID_SIZE
/
2
);
value
=
value
/
GRID_SIZE
;
value
=
value
/
SnakeUtils
.
GRID_SIZE
;
value
=
value
*
GRID_SIZE
;
value
=
value
*
SnakeUtils
.
GRID_SIZE
;
return
value
;
return
value
;
}
}
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer
.
broadcast
(
SnakeTimer
.
broadcast
(
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-jetty/src/test/java/samples/websocket/jetty/SampleWebSocketsApplicationTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -130,6 +130,7 @@ public class SampleWebSocketsApplicationTests {
...
@@ -130,6 +130,7 @@ public class SampleWebSocketsApplicationTests {
public
GreetingService
greetingService
()
{
public
GreetingService
greetingService
()
{
return
new
SimpleGreetingService
();
return
new
SimpleGreetingService
();
}
}
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private
final
String
echoFormat
;
private
final
String
echoFormat
;
public
DefaultEchoService
(
String
echoFormat
)
{
public
DefaultEchoService
(
String
echoFormat
)
{
this
.
echoFormat
=
(
echoFormat
!=
null
)
?
echoFormat
:
"%s"
;
this
.
echoFormat
=
(
echoFormat
!=
null
?
echoFormat
:
"%s"
)
;
}
}
@Override
@Override
...
...
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/reverse/ReverseWebSocketEndpoint.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session
.
getBasicRemote
()
session
.
getBasicRemote
()
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Direction.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -18,5 +17,7 @@
...
@@ -18,5 +17,7 @@
package
samples
.
websocket
.
tomcat
.
snake
;
package
samples
.
websocket
.
tomcat
.
snake
;
public
enum
Direction
{
public
enum
Direction
{
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Location.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -19,11 +18,15 @@ package samples.websocket.tomcat.snake;
...
@@ -19,11 +18,15 @@ package samples.websocket.tomcat.snake;
public
class
Location
{
public
class
Location
{
/**
* The X location.
*/
public
int
x
;
public
int
x
;
/**
* The Y location.
*/
public
int
y
;
public
int
y
;
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
Location
(
int
x
,
int
y
)
{
public
Location
(
int
x
,
int
y
)
{
this
.
x
=
x
;
this
.
x
=
x
;
...
@@ -33,13 +36,13 @@ public class Location {
...
@@ -33,13 +36,13 @@ public class Location {
public
Location
getAdjacentLocation
(
Direction
direction
)
{
public
Location
getAdjacentLocation
(
Direction
direction
)
{
switch
(
direction
)
{
switch
(
direction
)
{
case
NORTH:
case
NORTH:
return
new
Location
(
this
.
x
,
this
.
y
-
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
-
SnakeUtils
.
GRID_SIZE
);
case
SOUTH:
case
SOUTH:
return
new
Location
(
this
.
x
,
this
.
y
+
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
+
SnakeUtils
.
GRID_SIZE
);
case
EAST:
case
EAST:
return
new
Location
(
this
.
x
+
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
+
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
WEST:
case
WEST:
return
new
Location
(
this
.
x
-
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
-
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
NONE:
case
NONE:
// fall through
// fall through
default
:
default
:
...
@@ -55,16 +58,13 @@ public class Location {
...
@@ -55,16 +58,13 @@ public class Location {
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
return
false
;
}
}
Location
location
=
(
Location
)
o
;
Location
location
=
(
Location
)
o
;
if
(
this
.
x
!=
location
.
x
)
{
if
(
this
.
x
!=
location
.
x
)
{
return
false
;
return
false
;
}
}
if
(
this
.
y
!=
location
.
y
)
{
if
(
this
.
y
!=
location
.
y
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
...
@@ -74,4 +74,5 @@ public class Location {
...
@@ -74,4 +74,5 @@ public class Location {
result
=
31
*
result
+
this
.
y
;
result
=
31
*
result
+
this
.
y
;
return
result
;
return
result
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/Snake.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -157,4 +156,5 @@ public class Snake {
...
@@ -157,4 +156,5 @@ public class Snake {
public
String
getHexColor
()
{
public
String
getHexColor
()
{
return
this
.
hexColor
;
return
this
.
hexColor
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeTimer.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -25,24 +24,27 @@ import java.util.TimerTask;
...
@@ -25,24 +24,27 @@ import java.util.TimerTask;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
org.
apache.juli.logging.Log
;
import
org.
slf4j.Logger
;
import
org.
apache.juli.logging.Log
Factory
;
import
org.
slf4j.Logger
Factory
;
/**
/**
* Sets up the timer for the multi-player snake game WebSocket example.
* Sets up the timer for the multi-player snake game WebSocket example.
*/
*/
public
class
SnakeTimer
{
public
final
class
SnakeTimer
{
private
static
final
long
TICK_DELAY
=
100
;
private
static
final
long
TICK_DELAY
=
100
;
private
static
final
Object
MONITOR
=
new
Object
();
private
static
final
Object
MONITOR
=
new
Object
();
private
static
final
Log
log
=
LogFactory
.
getLog
(
SnakeTimer
.
class
);
private
static
final
Log
ger
log
=
LoggerFactory
.
getLogger
(
SnakeTimer
.
class
);
private
static
final
ConcurrentHashMap
<
Integer
,
Snake
>
snakes
=
new
ConcurrentHashMap
<>();
private
static
final
ConcurrentHashMap
<
Integer
,
Snake
>
snakes
=
new
ConcurrentHashMap
<>();
private
static
Timer
gameTimer
=
null
;
private
static
Timer
gameTimer
=
null
;
private
SnakeTimer
()
{
}
public
static
void
addSnake
(
Snake
snake
)
{
public
static
void
addSnake
(
Snake
snake
)
{
synchronized
(
MONITOR
)
{
synchronized
(
MONITOR
)
{
if
(
snakes
.
isEmpty
())
{
if
(
snakes
.
isEmpty
())
{
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer
.
cancel
();
gameTimer
.
cancel
();
}
}
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeUtils.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -20,14 +19,28 @@ package samples.websocket.tomcat.snake;
...
@@ -20,14 +19,28 @@ package samples.websocket.tomcat.snake;
import
java.awt.Color
;
import
java.awt.Color
;
import
java.util.Random
;
import
java.util.Random
;
public
class
SnakeUtils
{
public
final
class
SnakeUtils
{
/**
* The width of the playfield.
*/
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
/**
* The height of the playfield.
*/
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
/**
* The grid size.
*/
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
SnakeUtils
()
{
}
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
float
hue
=
random
.
nextFloat
();
float
hue
=
random
.
nextFloat
();
// sat between 0.1 and 0.3
// sat between 0.1 and 0.3
...
...
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/snake/SnakeWebSocketHandler.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
final
int
id
;
private
final
int
id
;
private
Snake
snake
;
private
Snake
snake
;
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
}
public
static
Location
getRandomLocation
()
{
public
static
Location
getRandomLocation
()
{
int
x
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_WIDTH
));
int
x
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_WIDTH
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_HEIGHT
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_HEIGHT
));
return
new
Location
(
x
,
y
);
return
new
Location
(
x
,
y
);
}
}
private
static
int
roundByGridSize
(
int
value
)
{
private
static
int
roundByGridSize
(
int
value
)
{
value
=
value
+
(
GRID_SIZE
/
2
);
value
=
value
+
(
SnakeUtils
.
GRID_SIZE
/
2
);
value
=
value
/
GRID_SIZE
;
value
=
value
/
SnakeUtils
.
GRID_SIZE
;
value
=
value
*
GRID_SIZE
;
value
=
value
*
SnakeUtils
.
GRID_SIZE
;
return
value
;
return
value
;
}
}
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer
.
broadcast
(
SnakeTimer
.
broadcast
(
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-tomcat/src/test/java/samples/websocket/tomcat/snake/SnakeTimerTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
...
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
Snake
snake
=
mock
(
Snake
.
class
);
Snake
snake
=
mock
(
Snake
.
class
);
willThrow
(
new
IOException
()).
given
(
snake
).
sendMessage
(
anyString
());
willThrow
(
new
IOException
()).
given
(
snake
).
sendMessage
(
anyString
());
SnakeTimer
.
addSnake
(
snake
);
SnakeTimer
.
addSnake
(
snake
);
SnakeTimer
.
broadcast
(
""
);
SnakeTimer
.
broadcast
(
""
);
assertThat
(
SnakeTimer
.
getSnakes
()).
hasSize
(
0
);
assertThat
(
SnakeTimer
.
getSnakes
()).
hasSize
(
0
);
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
...
@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private
final
String
echoFormat
;
private
final
String
echoFormat
;
public
DefaultEchoService
(
String
echoFormat
)
{
public
DefaultEchoService
(
String
echoFormat
)
{
this
.
echoFormat
=
(
echoFormat
!=
null
)
?
echoFormat
:
"%s"
;
this
.
echoFormat
=
(
echoFormat
!=
null
?
echoFormat
:
"%s"
)
;
}
}
@Override
@Override
...
...
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/reverse/ReverseWebSocketEndpoint.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
...
@@ -30,4 +30,5 @@ public class ReverseWebSocketEndpoint {
session
.
getBasicRemote
()
session
.
getBasicRemote
()
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
.
sendText
(
"Reversed: "
+
new
StringBuilder
(
message
).
reverse
());
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Direction.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -18,5 +17,7 @@
...
@@ -18,5 +17,7 @@
package
samples
.
websocket
.
undertow
.
snake
;
package
samples
.
websocket
.
undertow
.
snake
;
public
enum
Direction
{
public
enum
Direction
{
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
NONE
,
NORTH
,
SOUTH
,
EAST
,
WEST
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Location.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -19,11 +18,15 @@ package samples.websocket.undertow.snake;
...
@@ -19,11 +18,15 @@ package samples.websocket.undertow.snake;
public
class
Location
{
public
class
Location
{
/**
* The X location.
*/
public
int
x
;
public
int
x
;
/**
* The Y location.
*/
public
int
y
;
public
int
y
;
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
Location
(
int
x
,
int
y
)
{
public
Location
(
int
x
,
int
y
)
{
this
.
x
=
x
;
this
.
x
=
x
;
...
@@ -33,13 +36,13 @@ public class Location {
...
@@ -33,13 +36,13 @@ public class Location {
public
Location
getAdjacentLocation
(
Direction
direction
)
{
public
Location
getAdjacentLocation
(
Direction
direction
)
{
switch
(
direction
)
{
switch
(
direction
)
{
case
NORTH:
case
NORTH:
return
new
Location
(
this
.
x
,
this
.
y
-
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
-
SnakeUtils
.
GRID_SIZE
);
case
SOUTH:
case
SOUTH:
return
new
Location
(
this
.
x
,
this
.
y
+
Location
.
GRID_SIZE
);
return
new
Location
(
this
.
x
,
this
.
y
+
SnakeUtils
.
GRID_SIZE
);
case
EAST:
case
EAST:
return
new
Location
(
this
.
x
+
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
+
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
WEST:
case
WEST:
return
new
Location
(
this
.
x
-
Location
.
GRID_SIZE
,
this
.
y
);
return
new
Location
(
this
.
x
-
SnakeUtils
.
GRID_SIZE
,
this
.
y
);
case
NONE:
case
NONE:
// fall through
// fall through
default
:
default
:
...
@@ -55,16 +58,13 @@ public class Location {
...
@@ -55,16 +58,13 @@ public class Location {
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
return
false
;
}
}
Location
location
=
(
Location
)
o
;
Location
location
=
(
Location
)
o
;
if
(
this
.
x
!=
location
.
x
)
{
if
(
this
.
x
!=
location
.
x
)
{
return
false
;
return
false
;
}
}
if
(
this
.
y
!=
location
.
y
)
{
if
(
this
.
y
!=
location
.
y
)
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
...
@@ -74,4 +74,5 @@ public class Location {
...
@@ -74,4 +74,5 @@ public class Location {
result
=
31
*
result
+
this
.
y
;
result
=
31
*
result
+
this
.
y
;
return
result
;
return
result
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/Snake.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -157,4 +156,5 @@ public class Snake {
...
@@ -157,4 +156,5 @@ public class Snake {
public
String
getHexColor
()
{
public
String
getHexColor
()
{
return
this
.
hexColor
;
return
this
.
hexColor
;
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeTimer.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
...
@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
/**
/**
* Sets up the timer for the multi-player snake game WebSocket example.
* Sets up the timer for the multi-player snake game WebSocket example.
*/
*/
public
class
SnakeTimer
{
public
final
class
SnakeTimer
{
private
static
final
long
TICK_DELAY
=
100
;
private
static
final
long
TICK_DELAY
=
100
;
...
@@ -43,6 +42,9 @@ public class SnakeTimer {
...
@@ -43,6 +42,9 @@ public class SnakeTimer {
private
static
Timer
gameTimer
=
null
;
private
static
Timer
gameTimer
=
null
;
private
SnakeTimer
()
{
}
public
static
void
addSnake
(
Snake
snake
)
{
public
static
void
addSnake
(
Snake
snake
)
{
synchronized
(
MONITOR
)
{
synchronized
(
MONITOR
)
{
if
(
snakes
.
isEmpty
())
{
if
(
snakes
.
isEmpty
())
{
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
...
@@ -112,4 +114,5 @@ public class SnakeTimer {
gameTimer
.
cancel
();
gameTimer
.
cancel
();
}
}
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeUtils.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -20,14 +19,28 @@ package samples.websocket.undertow.snake;
...
@@ -20,14 +19,28 @@ package samples.websocket.undertow.snake;
import
java.awt.Color
;
import
java.awt.Color
;
import
java.util.Random
;
import
java.util.Random
;
public
class
SnakeUtils
{
public
final
class
SnakeUtils
{
/**
* The width of the playfield.
*/
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
/**
* The height of the playfield.
*/
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
/**
* The grid size.
*/
public
static
final
int
GRID_SIZE
=
10
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
SnakeUtils
()
{
}
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
float
hue
=
random
.
nextFloat
();
float
hue
=
random
.
nextFloat
();
// sat between 0.1 and 0.3
// sat between 0.1 and 0.3
...
...
spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/snake/SnakeWebSocketHandler.java
View file @
21d80d87
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with
*
* this work for additional information regarding copyright ownership.
* Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0
* you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with
* You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
...
@@ -29,14 +28,12 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
class
SnakeWebSocketHandler
extends
TextWebSocketHandler
{
public
static
final
int
PLAYFIELD_WIDTH
=
640
;
public
static
final
int
PLAYFIELD_HEIGHT
=
480
;
public
static
final
int
GRID_SIZE
=
10
;
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
AtomicInteger
snakeIds
=
new
AtomicInteger
(
0
);
private
static
final
Random
random
=
new
Random
();
private
static
final
Random
random
=
new
Random
();
private
final
int
id
;
private
final
int
id
;
private
Snake
snake
;
private
Snake
snake
;
public
static
String
getRandomHexColor
()
{
public
static
String
getRandomHexColor
()
{
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -50,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
}
}
public
static
Location
getRandomLocation
()
{
public
static
Location
getRandomLocation
()
{
int
x
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_WIDTH
));
int
x
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_WIDTH
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
PLAYFIELD_HEIGHT
));
int
y
=
roundByGridSize
(
random
.
nextInt
(
SnakeUtils
.
PLAYFIELD_HEIGHT
));
return
new
Location
(
x
,
y
);
return
new
Location
(
x
,
y
);
}
}
private
static
int
roundByGridSize
(
int
value
)
{
private
static
int
roundByGridSize
(
int
value
)
{
value
=
value
+
(
GRID_SIZE
/
2
);
value
=
value
+
(
SnakeUtils
.
GRID_SIZE
/
2
);
value
=
value
/
GRID_SIZE
;
value
=
value
/
SnakeUtils
.
GRID_SIZE
;
value
=
value
*
GRID_SIZE
;
value
=
value
*
SnakeUtils
.
GRID_SIZE
;
return
value
;
return
value
;
}
}
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
...
@@ -109,4 +106,5 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
SnakeTimer
.
broadcast
(
SnakeTimer
.
broadcast
(
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
String
.
format
(
"{'type': 'leave', 'id': %d}"
,
Integer
.
valueOf
(
this
.
id
)));
}
}
}
}
spring-boot-samples/spring-boot-sample-websocket-undertow/src/test/java/samples/websocket/undertow/snake/SnakeTimerTests.java
View file @
21d80d87
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
...
@@ -32,8 +32,8 @@ public class SnakeTimerTests {
Snake
snake
=
mock
(
Snake
.
class
);
Snake
snake
=
mock
(
Snake
.
class
);
willThrow
(
new
IOException
()).
given
(
snake
).
sendMessage
(
anyString
());
willThrow
(
new
IOException
()).
given
(
snake
).
sendMessage
(
anyString
());
SnakeTimer
.
addSnake
(
snake
);
SnakeTimer
.
addSnake
(
snake
);
SnakeTimer
.
broadcast
(
""
);
SnakeTimer
.
broadcast
(
""
);
assertThat
(
SnakeTimer
.
getSnakes
()).
hasSize
(
0
);
assertThat
(
SnakeTimer
.
getSnakes
()).
hasSize
(
0
);
}
}
}
}
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