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
decee8d8
Commit
decee8d8
authored
Apr 30, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish templates code
parent
1d5cddc1
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
43 additions
and
33 deletions
+43
-33
FreeMarkerAutoConfiguration.java
...autoconfigure/freemarker/FreeMarkerAutoConfiguration.java
+2
-1
FreeMarkerTemplateAvailabilityProvider.java
...re/freemarker/FreeMarkerTemplateAvailabilityProvider.java
+9
-8
ThymeleafTemplateAvailabilityProvider.java
...gure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java
+2
-2
ErrorMvcAutoConfiguration.java
...ork/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
+1
-1
JspTemplateAvailabilityProvider.java
...ot/autoconfigure/web/JspTemplateAvailabilityProvider.java
+7
-0
FreeMarkerAutoConfigurationTests.java
...onfigure/freemarker/FreeMarkerAutoConfigurationTests.java
+3
-3
FreeMarkerTemplateAvailabilityProviderTests.java
...eemarker/FreeMarkerTemplateAvailabilityProviderTests.java
+1
-1
ThymeleafTemplateAvailabilityProviderTests.java
...thymeleaf/ThymeleafTemplateAvailabilityProviderTests.java
+1
-1
SampleController.java
...uator/src/main/java/sample/actuator/SampleController.java
+7
-8
SampleDataGemFireApplication.java
...ava/sample/data/gemfire/SampleDataGemFireApplication.java
+1
-2
TemplateAvailabilityProvider.java
...pringframework/boot/web/TemplateAvailabilityProvider.java
+9
-6
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java
View file @
decee8d8
...
@@ -46,6 +46,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
...
@@ -46,6 +46,7 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
* {@link EnableAutoConfiguration Auto-configuration} for FreeMarker.
* {@link EnableAutoConfiguration Auto-configuration} for FreeMarker.
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
* @since 1.1.0
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
freemarker
.
template
.
Configuration
.
class
)
@ConditionalOnClass
(
freemarker
.
template
.
Configuration
.
class
)
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProvider.java
View file @
decee8d8
...
@@ -22,11 +22,11 @@ import org.springframework.core.io.ResourceLoader;
...
@@ -22,11 +22,11 @@ import org.springframework.core.io.ResourceLoader;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
/**
/**
* {@link TemplateAvailabilityProvider} that provides availability information
* {@link TemplateAvailabilityProvider} that provides availability information
for
*
for
FreeMarker view templates
* FreeMarker view templates
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*
*
@since 1.1.0
*/
*/
public
class
FreeMarkerTemplateAvailabilityProvider
implements
public
class
FreeMarkerTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
TemplateAvailabilityProvider
{
...
@@ -34,15 +34,16 @@ public class FreeMarkerTemplateAvailabilityProvider implements
...
@@ -34,15 +34,16 @@ public class FreeMarkerTemplateAvailabilityProvider implements
@Override
@Override
public
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
public
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
)
{
if
(
ClassUtils
.
isPresent
(
"freemarker.template.Configuration"
,
if
(
ClassUtils
.
isPresent
(
"freemarker.template.Configuration"
,
classLoader
))
{
classLoader
))
{
String
loaderPath
=
environment
.
getProperty
(
String
loaderPath
=
environment
.
getProperty
(
"spring.freemarker.templateLoaderPath"
,
"spring.freemarker.templateLoaderPath"
,
FreeMarkerAutoConfiguration
.
DEFAULT_TEMPLATE_LOADER_PATH
);
FreeMarkerAutoConfiguration
.
DEFAULT_TEMPLATE_LOADER_PATH
);
String
prefix
=
environment
.
getProperty
(
"spring.freemarker.prefix"
,
String
prefix
=
environment
.
getProperty
(
"spring.freemarker.prefix"
,
FreeMarkerAutoConfiguration
.
DEFAULT_PREFIX
);
FreeMarkerAutoConfiguration
.
DEFAULT_PREFIX
);
String
suffix
=
environment
.
getProperty
(
"spring.freemarker.suffix"
,
String
suffix
=
environment
.
getProperty
(
"spring.freemarker.suffix"
,
FreeMarkerAutoConfiguration
.
DEFAULT_SUFFIX
);
FreeMarkerAutoConfiguration
.
DEFAULT_SUFFIX
);
return
resourceLoader
.
getResource
(
loaderPath
+
prefix
+
view
+
suffix
).
exists
();
return
resourceLoader
.
getResource
(
loaderPath
+
prefix
+
view
+
suffix
)
.
exists
();
}
}
return
false
;
return
false
;
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProvider.java
View file @
decee8d8
...
@@ -26,7 +26,7 @@ import org.springframework.util.ClassUtils;
...
@@ -26,7 +26,7 @@ import org.springframework.util.ClassUtils;
* Thymeleaf view templates
* Thymeleaf view templates
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*
*
@since 1.1.0
*/
*/
public
class
ThymeleafTemplateAvailabilityProvider
implements
public
class
ThymeleafTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
TemplateAvailabilityProvider
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
View file @
decee8d8
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/JspTemplateAvailabilityProvider.java
View file @
decee8d8
...
@@ -21,6 +21,13 @@ import org.springframework.core.env.Environment;
...
@@ -21,6 +21,13 @@ import org.springframework.core.env.Environment;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ClassUtils
;
/**
* {@link TemplateAvailabilityProvider} that provides availability information for JSP
* view templates
*
* @author Andy Wilkinson
* @since 1.1.0
*/
public
class
JspTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
public
class
JspTemplateAvailabilityProvider
implements
TemplateAvailabilityProvider
{
@Override
@Override
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java
View file @
decee8d8
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerTemplateAvailabilityProviderTests.java
View file @
decee8d8
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafTemplateAvailabilityProviderTests.java
View file @
decee8d8
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java
View file @
decee8d8
...
@@ -37,18 +37,18 @@ public class SampleController {
...
@@ -37,18 +37,18 @@ public class SampleController {
@Autowired
@Autowired
private
HelloWorldService
helloWorldService
;
private
HelloWorldService
helloWorldService
;
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
@ResponseBody
public
Map
<
String
,
String
>
hello
()
{
public
Map
<
String
,
String
>
hello
()
{
return
Collections
.
singletonMap
(
"message"
,
return
Collections
.
singletonMap
(
"message"
,
this
.
helloWorldService
.
getHelloMessage
());
this
.
helloWorldService
.
getHelloMessage
());
}
}
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ResponseBody
public
Map
<
String
,
Object
>
olleh
(
@Validated
Message
message
)
{
public
Map
<
String
,
Object
>
olleh
(
@Validated
Message
message
)
{
Map
<
String
,
Object
>
model
=
new
LinkedHashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
model
=
new
LinkedHashMap
<
String
,
Object
>();
model
.
put
(
"message"
,
message
.
getValue
());
model
.
put
(
"message"
,
message
.
getValue
());
model
.
put
(
"title"
,
"Hello Home"
);
model
.
put
(
"title"
,
"Hello Home"
);
model
.
put
(
"date"
,
new
Date
());
model
.
put
(
"date"
,
new
Date
());
return
model
;
return
model
;
...
@@ -62,11 +62,11 @@ public class SampleController {
...
@@ -62,11 +62,11 @@ public class SampleController {
protected
static
class
Message
{
protected
static
class
Message
{
@NotBlank
(
message
=
"Message value cannot be empty"
)
@NotBlank
(
message
=
"Message value cannot be empty"
)
private
String
value
;
private
String
value
;
public
String
getValue
()
{
public
String
getValue
()
{
return
value
;
return
this
.
value
;
}
}
public
void
setValue
(
String
value
)
{
public
void
setValue
(
String
value
)
{
...
@@ -74,5 +74,4 @@ public class SampleController {
...
@@ -74,5 +74,4 @@ public class SampleController {
}
}
}
}
}
}
spring-boot-samples/spring-boot-sample-data-gemfire/src/main/java/sample/data/gemfire/SampleDataGemFireApplication.java
View file @
decee8d8
...
@@ -28,9 +28,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
...
@@ -28,9 +28,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* The GemstoneAppConfiguration class for allowing Spring Boot to pickup additional
* The GemstoneAppConfiguration class for allowing Spring Boot to pickup additional
* application Spring configuration meta-data for GemFire, which must be specified in
* application Spring configuration meta-data for GemFire, which must be specified in
* Spring Data GemFire's XML namespace.
* Spring Data GemFire's XML namespace.
*
<p/>
*
* @author John Blum
* @author John Blum
* @since 1.1.0
*/
*/
@Configuration
@Configuration
@ImportResource
(
"/spring-data-gemfire-cache.xml"
)
@ImportResource
(
"/spring-data-gemfire-cache.xml"
)
...
...
spring-boot/src/main/java/org/springframework/boot/web/TemplateAvailabilityProvider.java
View file @
decee8d8
...
@@ -20,17 +20,20 @@ import org.springframework.core.env.Environment;
...
@@ -20,17 +20,20 @@ import org.springframework.core.env.Environment;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
/**
/**
*
A {@code TemplateAvailabilityProvider} indicates the availability of view templates for
*
Indicates the availability of view templates for a particular templating engine such as
*
a particular templating engine such as
FreeMarker or Thymeleaf
* FreeMarker or Thymeleaf
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*
*
@since 1.1.0
*/
*/
public
interface
TemplateAvailabilityProvider
{
public
interface
TemplateAvailabilityProvider
{
/**
/**
* Returns {@code true} if a template is available for the given {@code view},
* Returns {@code true} if a template is available for the given {@code view}.
* otherwise {@code false} is returned.
* @param view the view name
* @param environment the environment
* @param classLoader the class loader
* @param resourceLoader the resource loader
*/
*/
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
boolean
isTemplateAvailable
(
String
view
,
Environment
environment
,
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
);
ClassLoader
classLoader
,
ResourceLoader
resourceLoader
);
...
...
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