forked from jknack/handlebars.java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
142 changed files
with
4,173 additions
and
2,059 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: maven | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "09:00" | ||
open-pull-requests-limit: 10 | ||
ignore: | ||
- dependency-name: org.springframework:spring-test | ||
versions: | ||
- ">= 5.a, < 6" | ||
- dependency-name: com.google.javascript:closure-compiler | ||
versions: | ||
- v20210106 | ||
- v20210202 | ||
- v20210302 | ||
- dependency-name: org.eclipse.jetty:jetty-servlet | ||
versions: | ||
- 11.0.0 | ||
- 11.0.1 | ||
- dependency-name: org.eclipse.jetty:jetty-webapp | ||
versions: | ||
- 11.0.0 | ||
- 11.0.1 | ||
- dependency-name: org.eclipse.jetty:jetty-server | ||
versions: | ||
- 11.0.0 | ||
- 11.0.1 | ||
- dependency-name: org.yaml:snakeyaml | ||
versions: | ||
- "1.27" | ||
- dependency-name: org.apache.commons:commons-lang3 | ||
versions: | ||
- "3.11" | ||
- dependency-name: org.apache.felix:maven-bundle-plugin | ||
versions: | ||
- 5.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
java_version: [1.8, 11, 15, 17] | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
- name: Mustache Specs | ||
run: | | ||
git submodule update --init --recursive | ||
- name: Set up JDK ${{ matrix.java_version }} | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.java_version }} | ||
- name: Install | ||
run: mvn clean install -DskipTests --batch-mode --no-transfer-progress | ||
env: | ||
BUILD_PORT: 0 | ||
BUILD_SECURE_PORT: 0 | ||
- name: Build | ||
run: mvn clean package --batch-mode --no-transfer-progress | ||
env: | ||
BUILD_PORT: 0 | ||
BUILD_SECURE_PORT: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ dependency-reduced-pom.xml | |
*.versionsBackup | ||
pom.xml.versionsBackup | ||
|
||
jacoco.exec | ||
jacoco.exec | ||
|
||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Java 15/17 Migration | ||
|
||
- Replace pegdown with something else | ||
- Upgrade spring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>com.github.jknack</groupId> | ||
<artifactId>handlebars.java</artifactId> | ||
<version>4.3.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.github.jknack</groupId> | ||
<artifactId>handlebars-caffeine</artifactId> | ||
|
||
<name>Handlebars Caffeine Cache</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.jknack</groupId> | ||
<artifactId>handlebars</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.github.ben-manes.caffeine</groupId> | ||
<artifactId>caffeine</artifactId> | ||
<version>2.9.2</version> | ||
</dependency> | ||
|
||
<!-- Servlet API --> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>com.github.jknack</groupId> | ||
<artifactId>handlebars</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
<classifier>tests</classifier> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-runtime</artifactId> | ||
<version>4.9.2</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.abego.treelayout</groupId> | ||
<artifactId>org.abego.treelayout.core</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-text</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
88 changes: 88 additions & 0 deletions
88
...bars-caffeine/src/main/java/com/github/jknack/handlebars/cache/CaffeineTemplateCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright (c) 2012-2015 Edgar Espina | ||
* | ||
* This file is part of Handlebars.java. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* 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 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* 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 com.github.jknack.handlebars.cache; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Function; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import com.github.jknack.handlebars.Handlebars; | ||
import com.github.jknack.handlebars.Parser; | ||
import com.github.jknack.handlebars.Template; | ||
import com.github.jknack.handlebars.io.TemplateSource; | ||
|
||
/** | ||
* Caffeine template cache for handlebars. | ||
* | ||
* @author edgar | ||
* @since 4.3.0 | ||
*/ | ||
public class CaffeineTemplateCache implements TemplateCache { | ||
|
||
/** | ||
* Internal cache. | ||
*/ | ||
private final Cache<TemplateSource, Template> cache; | ||
|
||
/** | ||
* Creates a new template cache. | ||
* | ||
* @param cache Cache. | ||
*/ | ||
public CaffeineTemplateCache(final Cache<TemplateSource, Template> cache) { | ||
this.cache = requireNonNull(cache, "The cache is required."); | ||
} | ||
|
||
@Override public void clear() { | ||
cache.invalidateAll(); | ||
} | ||
|
||
@Override public void evict(final TemplateSource source) { | ||
cache.invalidate(source); | ||
} | ||
|
||
@Override public Template get(final TemplateSource source, final Parser parser) { | ||
return cache.get(source, parseTemplate(parser)); | ||
} | ||
|
||
/** | ||
* This method does nothing on Caffeine. Better option is to use a loading cache with a | ||
* eviction policy of your choice. | ||
* | ||
* Don't use this method. | ||
* | ||
* @param reload Ignored. | ||
* @return This template cache. | ||
*/ | ||
@Override public TemplateCache setReload(final boolean reload) { | ||
// NOOP | ||
return this; | ||
} | ||
|
||
private Function<? super TemplateSource, ? extends Template> parseTemplate(final Parser parser) { | ||
return source -> { | ||
try { | ||
return parser.parse(source); | ||
} catch (IOException ex) { | ||
throw Handlebars.Utils.propagate(ex); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.