Skip to content

Commit

Permalink
Add spring properties bean for properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankbregulla1111 committed Mar 28, 2017
1 parent 317ff2c commit ff2b8e5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ When spring profiles "local" or "prod" are active, esi-includes will be resolved

# 3. Release Notes

## Version 0.0.4
* Add spring properties bean for property `esiinclude-thymeleaf-dialect.prefixForRelativePath`
so that you get syntax highlighting and code completion in your application*.yml files in your IDE.

This property may now also be written "`prefix-for-relative-path`"


## Version 0.0.3
* Add javadoc
* Rename variables and httpClient to Fetch
Expand Down
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'signing'
apply plugin: 'com.github.ben-manes.versions'

group = 'de.otto'
version = '0.0.3'
version = '0.0.4'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

archivesBaseName = 'esi-include-thymeleaf3-dialect'
Expand All @@ -31,18 +31,22 @@ ext.libraries = [
]

dependencies {
ext.springBootVersion = '1.4.2.RELEASE'
compileOnly libraries.thymeleaf3
compileOnly group: 'com.ning', name: 'async-http-client', version: '1.9.33'

compile group: 'org.springframework', name: 'spring-context', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.3.4.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: springBootVersion
testCompile group: 'junit', name: 'junit', version: '4.11'

testCompile libraries.thymeleaf3
testCompile "org.mockito:mockito-core:1.10.19"
testCompile "org.hamcrest:hamcrest-core:1.3"
testCompile "org.hamcrest:hamcrest-library:1.3"

compileOnly "org.springframework.boot:spring-boot-configuration-processor:" + springBootVersion

}

// for gradle plugins
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/de/otto/esidialect/EsiDialectConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import de.otto.esidialect.thymeleaf3.EsiDialect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand All @@ -32,6 +32,7 @@
* </p>
*/
@Configuration
@EnableConfigurationProperties(EsiDialectProperties.class)
@Profile({"local", "prod"})
public class EsiDialectConfiguration {

Expand Down Expand Up @@ -63,8 +64,8 @@ public Fetch fetch() {
@Bean
@ConditionalOnClass(AbstractElementTagProcessor.class)
@ConditionalOnMissingBean(EsiDialect.class)
public EsiDialect conditionalEsiDialect(Fetch fetch, @Value("${esiinclude-thymeleaf-dialect.prefixForRelativePath:}") String prefixForRelativePath) {
return new EsiDialect(fetch, prefixForRelativePath);
public EsiDialect conditionalEsiDialect(Fetch fetch, EsiDialectProperties properties) {
return new EsiDialect(fetch, properties.getPrefixForRelativePath());
}

}
21 changes: 21 additions & 0 deletions src/main/java/de/otto/esidialect/EsiDialectProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.otto.esidialect;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "esiinclude-thymeleaf-dialect")
public class EsiDialectProperties {

private String prefixForRelativePath;

/**
* Optional prefix for relative esi:include paths
* @return prefix for relative esi:include paths or null if not set
*/
public String getPrefixForRelativePath() {
return prefixForRelativePath;
}

public void setPrefixForRelativePath(String prefixForRelativePath) {
this.prefixForRelativePath = prefixForRelativePath;
}
}

0 comments on commit ff2b8e5

Please sign in to comment.