Skip to content

Commit

Permalink
Merge pull request #2 from mpbalmeida/1.x-releases
Browse files Browse the repository at this point in the history
Release v1.0.2
  • Loading branch information
mpbalmeida authored May 22, 2019
2 parents 40388b9 + e438efb commit 4d91af7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ This project was built using:

Since `1.0.1` you do not need to provide a thymeleaf version in your project.

```
```xml
<dependency>
<groupId>br.com.faroltech.vraptor</groupId>
<artifactId>vraptor-thymeleaf</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
```

Expand Down
16 changes: 13 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.faroltech.vraptor</groupId>
<artifactId>vraptor-thymeleaf</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>

<licenses>
<license>
Expand Down Expand Up @@ -86,6 +86,16 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down Expand Up @@ -115,7 +125,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -129,7 +139,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ThymeleafPageResult extends DefaultPageResult {
/**
* @deprecated CDI eyes only
*/
@Deprecated
protected ThymeleafPageResult() {
super(null, null, null, null, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.thymeleaf.exceptions.TemplateProcessingException;
import org.thymeleaf.messageresolver.StandardMessageResolver;
import org.thymeleaf.templateresource.ITemplateResource;
import org.thymeleaf.util.StringUtils;

public class CustomMessageResolver extends StandardMessageResolver {

private static final Logger logger = LoggerFactory.getLogger(CustomMessageResolver.class);

private static final String PROPERTIES_FILE_EXTENSION = ".properties";

Expand All @@ -24,24 +28,20 @@ protected Map<String, String> resolveMessagesForTemplate(String template, ITempl
List<String> computeMessageResourceNamesFromBase = computeMessageResourceNamesFromBase("messages", locale);
File file = createFileProperties(computeMessageResourceNamesFromBase);
if (file != null) {
FileInputStream fis = null;
try {
try(FileInputStream fis = new FileInputStream(file)) {
Properties properties = new Properties();
fis = new FileInputStream(file);
properties.load(fis);
setDefaultMessages(properties);
} catch (Throwable t) {

} finally {
try { fis.close(); } catch (Exception e) {}
} catch (Exception t) {
logger.error("Failed to resolve messages for template", t);
}
}
return super.resolveMessagesForTemplate(template, templateResource, locale);
}

private File createFileProperties(List<String> computeMessageResourceNamesFromBase) {
ClassLoader classLoader = getClass().getClassLoader();
File file = null;
File file;
for (String string : computeMessageResourceNamesFromBase) {
URL resource = classLoader.getResource(string);
if (resource != null) {
Expand All @@ -57,7 +57,7 @@ private File createFileProperties(List<String> computeMessageResourceNamesFromBa
private static List<String> computeMessageResourceNamesFromBase(
final String resourceBaseName, final Locale locale) {

final List<String> resourceNames = new ArrayList<String>(5);
final List<String> resourceNames = new ArrayList<>(5);

if (StringUtils.isEmptyOrWhitespace(locale.getLanguage())) {
throw new TemplateProcessingException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
@Specializes
public class ThymeleafPathResolver extends DefaultPathResolver {

private static final String ENCODING = "UTF-8";
private static final Long CACHE_TIME = 3600000L;

/**
* @deprecated CDI eyes only
*/
@Deprecated
protected ThymeleafPathResolver() {
this(null);
}
Expand All @@ -38,11 +42,11 @@ protected TemplateMode getTemplateMode() {
}

protected Long getCache() {
return 3600000L;
return CACHE_TIME;
}

protected String getCharacterEncoding() {
return "UTF-8";
return ENCODING;
}

}

0 comments on commit 4d91af7

Please sign in to comment.