diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0503c92..9322149 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,20 +9,20 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v5 with: - java-version: '17' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' - name: Gradle Wrapper Validation - uses: gradle/actions/wrapper-validation@v4 + uses: gradle/actions/wrapper-validation@v5 - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@v5 - - name: Run tests + - name: Test run: ./gradlew test - - name: Build project + - name: Build run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b33b18c..6f8e6ea 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,8 +1,3 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - name: Publish to Reposilite on: @@ -17,22 +12,22 @@ jobs: - uses: actions/checkout@v5 - name: Set version - run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/*/} | sed 's/^v//')" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF#refs/*/} | sed "s/^v//")" >> $GITHUB_ENV - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v5 with: - java-version: '17' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' - name: Gradle Wrapper Validation - uses: gradle/actions/wrapper-validation@v4 + uses: gradle/actions/wrapper-validation@v5 - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@v5 - - name: Publish Build - run: ./gradlew clean publish -Pversion=${{ env.RELEASE_VERSION }} + - name: Publish + run: ./gradlew clean build publish -Pversion=${{ env.RELEASE_VERSION }} env: REPOSILITE_USERNAME: ${{ secrets.REPOSILITE_USERNAME }} REPOSILITE_PASSWORD: ${{ secrets.REPOSILITE_PASSWORD }} \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 614e01a..0000000 --- a/build.gradle +++ /dev/null @@ -1,60 +0,0 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin - -plugins { - id 'org.springframework.boot' version '3.5.5' apply false - id 'io.spring.dependency-management' version '1.1.7' - id 'java' - id 'maven-publish' - id 'java-library' - id 'com.github.ben-manes.versions' version '0.52.0' -} - -group = 'no.fintlabs' - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - } -} - -publishing { - repositories { - mavenLocal() - } -} - -repositories { - mavenLocal() - maven { - url "https://repo.fintlabs.no/releases" - } - mavenCentral() -} - -dependencyManagement { - imports { - mavenBom SpringBootPlugin.BOM_COORDINATES - } -} - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-actuator' - - compileOnly 'org.projectlombok:lombok' - runtimeOnly 'io.micrometer:micrometer-registry-prometheus' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - annotationProcessor 'org.projectlombok:lombok' - - - implementation 'org.ehcache:ehcache:3.11.1' - - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'cglib:cglib-nodep:3.3.0' - testRuntimeOnly 'org.junit.platform:junit-platform-launcher' -} - -test { - useJUnitPlatform() -} - -apply from: 'https://raw.githubusercontent.com/FINTLabs/fint-buildscripts/master/reposilite.ga.gradle' \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9776edf --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,76 @@ +import org.springframework.boot.gradle.plugin.SpringBootPlugin + +plugins { + id("org.springframework.boot") version "3.5.7" apply false + id("io.spring.dependency-management") version "1.1.7" + id("java-library") + id("maven-publish") + id("com.github.ben-manes.versions") version "0.53.0" +} + +group = "no.novari" + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + withSourcesJar() +} + +publishing { + repositories { + mavenLocal() + } +} + +repositories { + mavenLocal() + maven { + url = uri("https://repo.fintlabs.no/releases") + } + mavenCentral() +} + +dependencyManagement { + imports { + mavenBom(SpringBootPlugin.BOM_COORDINATES) + } +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter-actuator") + + compileOnly("org.projectlombok:lombok") + runtimeOnly("io.micrometer:micrometer-registry-prometheus") + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") + annotationProcessor("org.projectlombok:lombok") + + implementation("org.ehcache:ehcache:3.11.1") + + testImplementation("org.springframework.boot:spring-boot-starter-test") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +tasks.test { + useJUnitPlatform() +} + +publishing { + repositories { + maven { + url = uri("https://repo.fintlabs.no/releases") + credentials { + username = System.getenv("REPOSILITE_USERNAME") + password = System.getenv("REPOSILITE_PASSWORD") + } + authentication { + create("basic") + } + } + } + publications { + create("maven") { + from(components["java"]) + } + } +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3ae1e2f..2e11132 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,18 +200,28 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..5eed7ee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,32 +59,34 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index ffc22d4..786bd4e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'fint-flyt-cache' +rootProject.name = 'flyt-cache' diff --git a/src/main/java/no/fintlabs/cache/FintCacheConfiguration.java b/src/main/java/no/fintlabs/cache/FintCacheConfiguration.java deleted file mode 100644 index e7382ca..0000000 --- a/src/main/java/no/fintlabs/cache/FintCacheConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package no.fintlabs.cache; - -import no.fintlabs.cache.ehcache.FintEhCacheManager; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.time.Duration; -import java.time.temporal.ChronoUnit; - -@Configuration -public class FintCacheConfiguration { - - @Value("#{T(java.lang.Long).valueOf('${fint.cache.defaultCacheEntryTimeToLiveMillis}')}") - Long defaultCacheEntryTimeToLiveMillis; - - @Value("#{T(java.lang.Long).valueOf('${fint.cache.defaultCacheHeapSize}')}") - Long defaultCacheHeapSize; - - @Bean - public FintCacheManager fintCacheManager() { - return new FintEhCacheManager( - FintCacheOptions.builder() - .timeToLive(Duration.of(this.defaultCacheEntryTimeToLiveMillis, ChronoUnit.MILLIS)) - .heapSize(this.defaultCacheHeapSize) - .build() - ); - } -} diff --git a/src/main/java/no/fintlabs/cache/FintCache.java b/src/main/java/no/novari/cache/FintCache.java similarity index 93% rename from src/main/java/no/fintlabs/cache/FintCache.java rename to src/main/java/no/novari/cache/FintCache.java index 731d55c..1f619eb 100644 --- a/src/main/java/no/fintlabs/cache/FintCache.java +++ b/src/main/java/no/novari/cache/FintCache.java @@ -1,6 +1,6 @@ -package no.fintlabs.cache; +package no.novari.cache; -import no.fintlabs.cache.exceptions.NoSuchCacheEntryException; +import no.novari.cache.exceptions.NoSuchCacheEntryException; import java.util.*; import java.util.stream.Collectors; diff --git a/src/main/java/no/novari/cache/FintCacheConfiguration.java b/src/main/java/no/novari/cache/FintCacheConfiguration.java new file mode 100644 index 0000000..fea7238 --- /dev/null +++ b/src/main/java/no/novari/cache/FintCacheConfiguration.java @@ -0,0 +1,28 @@ +package no.novari.cache; + +import no.novari.cache.ehcache.FintEhCacheManager; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Bean; + +import java.time.Duration; + +@AutoConfiguration +public class FintCacheConfiguration { + + @Value("${novari.cache.defaultCacheEntryTimeToLive:6d}") + Duration defaultCacheEntryTimeToLive; + + @Value("${novari.cache.defaultCacheHeapSize:1000000}") + Long defaultCacheHeapSize; + + @Bean + public FintCacheManager fintCacheManager() { + return new FintEhCacheManager( + FintCacheOptions.builder() + .timeToLive(this.defaultCacheEntryTimeToLive) + .heapSize(this.defaultCacheHeapSize) + .build() + ); + } +} diff --git a/src/main/java/no/fintlabs/cache/FintCacheEvent.java b/src/main/java/no/novari/cache/FintCacheEvent.java similarity index 95% rename from src/main/java/no/fintlabs/cache/FintCacheEvent.java rename to src/main/java/no/novari/cache/FintCacheEvent.java index 7f01929..cc66944 100644 --- a/src/main/java/no/fintlabs/cache/FintCacheEvent.java +++ b/src/main/java/no/novari/cache/FintCacheEvent.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache; +package no.novari.cache; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; diff --git a/src/main/java/no/fintlabs/cache/FintCacheEventListener.java b/src/main/java/no/novari/cache/FintCacheEventListener.java similarity index 78% rename from src/main/java/no/fintlabs/cache/FintCacheEventListener.java rename to src/main/java/no/novari/cache/FintCacheEventListener.java index 8918614..ad7d411 100644 --- a/src/main/java/no/fintlabs/cache/FintCacheEventListener.java +++ b/src/main/java/no/novari/cache/FintCacheEventListener.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache; +package no.novari.cache; public interface FintCacheEventListener { diff --git a/src/main/java/no/fintlabs/cache/FintCacheInfo.java b/src/main/java/no/novari/cache/FintCacheInfo.java similarity index 90% rename from src/main/java/no/fintlabs/cache/FintCacheInfo.java rename to src/main/java/no/novari/cache/FintCacheInfo.java index 09ae2b9..f34cdcd 100644 --- a/src/main/java/no/fintlabs/cache/FintCacheInfo.java +++ b/src/main/java/no/novari/cache/FintCacheInfo.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache; +package no.novari.cache; import lombok.Builder; import lombok.EqualsAndHashCode; diff --git a/src/main/java/no/fintlabs/cache/FintCacheManager.java b/src/main/java/no/novari/cache/FintCacheManager.java similarity index 93% rename from src/main/java/no/fintlabs/cache/FintCacheManager.java rename to src/main/java/no/novari/cache/FintCacheManager.java index 8bc2404..f178f24 100644 --- a/src/main/java/no/fintlabs/cache/FintCacheManager.java +++ b/src/main/java/no/novari/cache/FintCacheManager.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache; +package no.novari.cache; public interface FintCacheManager { diff --git a/src/main/java/no/fintlabs/cache/FintCacheOptions.java b/src/main/java/no/novari/cache/FintCacheOptions.java similarity index 86% rename from src/main/java/no/fintlabs/cache/FintCacheOptions.java rename to src/main/java/no/novari/cache/FintCacheOptions.java index 162a0f5..e540c37 100644 --- a/src/main/java/no/fintlabs/cache/FintCacheOptions.java +++ b/src/main/java/no/novari/cache/FintCacheOptions.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache; +package no.novari.cache; import lombok.Builder; diff --git a/src/main/java/no/fintlabs/cache/ehcache/FintEhCache.java b/src/main/java/no/novari/cache/ehcache/FintEhCache.java similarity index 95% rename from src/main/java/no/fintlabs/cache/ehcache/FintEhCache.java rename to src/main/java/no/novari/cache/ehcache/FintEhCache.java index 127869f..a6d4b6f 100644 --- a/src/main/java/no/fintlabs/cache/ehcache/FintEhCache.java +++ b/src/main/java/no/novari/cache/ehcache/FintEhCache.java @@ -1,8 +1,8 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; import lombok.Getter; -import no.fintlabs.cache.FintCache; -import no.fintlabs.cache.FintCacheEventListener; +import no.novari.cache.FintCache; +import no.novari.cache.FintCacheEventListener; import org.ehcache.Cache; import org.ehcache.event.EventFiring; import org.ehcache.event.EventOrdering; diff --git a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventListener.java b/src/main/java/no/novari/cache/ehcache/FintEhCacheEventListener.java similarity index 89% rename from src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventListener.java rename to src/main/java/no/novari/cache/ehcache/FintEhCacheEventListener.java index 793d0fa..964b609 100644 --- a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventListener.java +++ b/src/main/java/no/novari/cache/ehcache/FintEhCacheEventListener.java @@ -1,7 +1,7 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; -import no.fintlabs.cache.FintCacheEvent; -import no.fintlabs.cache.FintCacheEventListener; +import no.novari.cache.FintCacheEvent; +import no.novari.cache.FintCacheEventListener; import org.ehcache.event.CacheEvent; import org.ehcache.event.CacheEventListener; import org.ehcache.event.EventType; diff --git a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventLogger.java b/src/main/java/no/novari/cache/ehcache/FintEhCacheEventLogger.java similarity index 94% rename from src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventLogger.java rename to src/main/java/no/novari/cache/ehcache/FintEhCacheEventLogger.java index e0e02e8..0d92730 100644 --- a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheEventLogger.java +++ b/src/main/java/no/novari/cache/ehcache/FintEhCacheEventLogger.java @@ -1,7 +1,7 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; import lombok.extern.slf4j.Slf4j; -import no.fintlabs.cache.FintCacheEvent; +import no.novari.cache.FintCacheEvent; @Slf4j public class FintEhCacheEventLogger extends FintEhCacheEventListener { diff --git a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheManager.java b/src/main/java/no/novari/cache/ehcache/FintEhCacheManager.java similarity index 65% rename from src/main/java/no/fintlabs/cache/ehcache/FintEhCacheManager.java rename to src/main/java/no/novari/cache/ehcache/FintEhCacheManager.java index 28f69ca..f655ccb 100644 --- a/src/main/java/no/fintlabs/cache/ehcache/FintEhCacheManager.java +++ b/src/main/java/no/novari/cache/ehcache/FintEhCacheManager.java @@ -1,17 +1,17 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; -import no.fintlabs.cache.FintCacheManager; -import no.fintlabs.cache.FintCacheOptions; -import no.fintlabs.cache.exceptions.NoSuchCacheException; +import no.novari.cache.FintCacheManager; +import no.novari.cache.FintCacheOptions; +import no.novari.cache.exceptions.NoSuchCacheException; import org.ehcache.CacheManager; import org.ehcache.config.CacheConfiguration; import org.ehcache.config.builders.CacheConfigurationBuilder; import org.ehcache.config.builders.CacheManagerBuilder; +import org.ehcache.config.builders.ExpiryPolicyBuilder; import org.ehcache.config.builders.ResourcePoolsBuilder; -import org.ehcache.expiry.Expirations; +import java.time.Duration; import java.util.Optional; -import java.util.concurrent.TimeUnit; public class FintEhCacheManager implements FintCacheManager { @@ -29,21 +29,20 @@ public FintEhCache createCache(String alias, Class keyClass, Cla public FintEhCache createCache(String alias, Class keyClass, Class valueClass, FintCacheOptions cacheOptions) { CacheConfiguration cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder( - keyClass, - valueClass, - ResourcePoolsBuilder.heap( - cacheOptions.heapSize != null - ? cacheOptions.heapSize - : this.defaultCacheOptions.heapSize - ).build() - ).withExpiry( - Expirations.timeToLiveExpiration(org.ehcache.expiry.Duration.of( - cacheOptions.timeToLive != null - ? cacheOptions.timeToLive.toMillis() - : this.defaultCacheOptions.timeToLive.toMillis(), - TimeUnit.MILLISECONDS - )) - ).build(); + keyClass, + valueClass, + ResourcePoolsBuilder.heap( + cacheOptions.heapSize != null + ? cacheOptions.heapSize + : this.defaultCacheOptions.heapSize + ).build() + ) + .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofMillis( + cacheOptions.timeToLive != null + ? cacheOptions.timeToLive.toMillis() + : this.defaultCacheOptions.timeToLive.toMillis() + )) + ).build(); FintEhCache cache = new FintEhCache<>( alias, diff --git a/src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheEntryException.java b/src/main/java/no/novari/cache/exceptions/NoSuchCacheEntryException.java similarity index 83% rename from src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheEntryException.java rename to src/main/java/no/novari/cache/exceptions/NoSuchCacheEntryException.java index b378500..3cbba05 100644 --- a/src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheEntryException.java +++ b/src/main/java/no/novari/cache/exceptions/NoSuchCacheEntryException.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache.exceptions; +package no.novari.cache.exceptions; public class NoSuchCacheEntryException extends RuntimeException { diff --git a/src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheException.java b/src/main/java/no/novari/cache/exceptions/NoSuchCacheException.java similarity index 82% rename from src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheException.java rename to src/main/java/no/novari/cache/exceptions/NoSuchCacheException.java index 38c4b23..24af436 100644 --- a/src/main/java/no/fintlabs/cache/exceptions/NoSuchCacheException.java +++ b/src/main/java/no/novari/cache/exceptions/NoSuchCacheException.java @@ -1,4 +1,4 @@ -package no.fintlabs.cache.exceptions; +package no.novari.cache.exceptions; public class NoSuchCacheException extends RuntimeException { diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..595f40d --- /dev/null +++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +no.novari.cache.FintCacheConfiguration \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml deleted file mode 100644 index 9152773..0000000 --- a/src/main/resources/application.yaml +++ /dev/null @@ -1,4 +0,0 @@ -fint: - cache: - defaultCacheEntryTimeToLiveMillis: 518400000 - defaultCacheHeapSize: 1000000 \ No newline at end of file diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt deleted file mode 100644 index 11ff356..0000000 --- a/src/main/resources/banner.txt +++ /dev/null @@ -1,22 +0,0 @@ - - :: Spring Boot${spring-boot.formatted-version} :: - -${Ansi.RED} FFFFFFFFFFFFFFFFFFFFFFIIIIIIIIIINNNNNNNN NNNNNNNNTTTTTTTTTTTTTTTTTTTTTTT -${Ansi.RED} F::::::::::::::::::::FI::::::::IN:::::::N N::::::NT:::::::::::::::::::::T -${Ansi.RED} F::::::::::::::::::::FI::::::::IN::::::::N N::::::NT:::::::::::::::::::::T -${Ansi.RED} FF::::::FFFFFFFFF::::FII::::::IIN:::::::::N N::::::NT:::::TT:::::::TT:::::T -${Ansi.RED} F:::::F FFFFFF I::::I N::::::::::N N::::::NTTTTTT T:::::T TTTTTT -${Ansi.RED} F:::::F I::::I N:::::::::::N N::::::N T:::::T -${Ansi.RED} F::::::FFFFFFFFFF I::::I N:::::::N::::N N::::::N T:::::T -${Ansi.RED} F:::::::::::::::F I::::I N::::::N N::::N N::::::N T:::::T -${Ansi.RED} F:::::::::::::::F I::::I N::::::N N::::N:::::::N T:::::T -${Ansi.RED} F::::::FFFFFFFFFF I::::I N::::::N N:::::::::::N T:::::T -${Ansi.RED} F:::::F I::::I N::::::N N::::::::::N T:::::T -${Ansi.RED} F:::::F I::::I N::::::N N:::::::::N T:::::T -${Ansi.RED} FF:::::::FF II::::::IIN::::::N N::::::::N TT:::::::TT -${Ansi.RED} F::::::::FF I::::::::IN::::::N N:::::::N T:::::::::T -${Ansi.RED} F::::::::FF I::::::::IN::::::N N::::::N T:::::::::T -${Ansi.RED} FFFFFFFFFFF IIIIIIIIIINNNNNNNN NNNNNNN TTTTTTTTTTT - -${Ansi.GREEN} Greetings from FINTLabs! ${Ansi.DEFAULT} - diff --git a/src/test/java/no/fintlabs/cache/FintCacheManagerTest.java b/src/test/java/no/novari/cache/FintCacheManagerTest.java similarity index 96% rename from src/test/java/no/fintlabs/cache/FintCacheManagerTest.java rename to src/test/java/no/novari/cache/FintCacheManagerTest.java index 69a0c39..9e43f52 100644 --- a/src/test/java/no/fintlabs/cache/FintCacheManagerTest.java +++ b/src/test/java/no/novari/cache/FintCacheManagerTest.java @@ -1,6 +1,6 @@ -package no.fintlabs.cache; +package no.novari.cache; -import no.fintlabs.cache.exceptions.NoSuchCacheException; +import no.novari.cache.exceptions.NoSuchCacheException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/no/fintlabs/cache/FintCacheTest.java b/src/test/java/no/novari/cache/FintCacheTest.java similarity index 96% rename from src/test/java/no/fintlabs/cache/FintCacheTest.java rename to src/test/java/no/novari/cache/FintCacheTest.java index ada3e70..65ef43d 100644 --- a/src/test/java/no/fintlabs/cache/FintCacheTest.java +++ b/src/test/java/no/novari/cache/FintCacheTest.java @@ -1,6 +1,6 @@ -package no.fintlabs.cache; +package no.novari.cache; -import no.fintlabs.cache.exceptions.NoSuchCacheEntryException; +import no.novari.cache.exceptions.NoSuchCacheEntryException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -261,7 +261,7 @@ void shouldNotifyEventListenerWhenEntryIsCreated() throws InterruptedException { observer.countDownLatch.await(); assertEquals(1, observer.emittedEvents.size()); - assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.CREATED, "testKey", null, 1), observer.emittedEvents.get(0)); + assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.CREATED, "testKey", null, 1), observer.emittedEvents.getFirst()); } @Test @@ -275,7 +275,7 @@ void shouldNotifyEventListenerWhenEntryIsUpdated() throws InterruptedException { observer.countDownLatch.await(); assertEquals(1, observer.emittedEvents.size()); - assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.UPDATED, "testKey", 1, 2), observer.emittedEvents.get(0)); + assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.UPDATED, "testKey", 1, 2), observer.emittedEvents.getFirst()); } @Test @@ -289,7 +289,7 @@ void shouldNotifyEventListenerWhenEntryIsRemoved() throws InterruptedException { observer.countDownLatch.await(); assertEquals(1, observer.emittedEvents.size()); - assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.REMOVED, "testKey", 1, null), observer.emittedEvents.get(0)); + assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.REMOVED, "testKey", 1, null), observer.emittedEvents.getFirst()); } @Test @@ -311,7 +311,7 @@ void shouldNotifyEventListenerWhenEntryIsExpired() throws InterruptedException { assertTrue(awaitResult); assertTrue(getResult.isEmpty()); assertEquals(1, observer.emittedEvents.size()); - assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.EXPIRED, "testKey", 1, null), observer.emittedEvents.get(0)); + assertEquals(new FintCacheEvent<>(FintCacheEvent.EventType.EXPIRED, "testKey", 1, null), observer.emittedEvents.getFirst()); } @Test diff --git a/src/test/java/no/fintlabs/cache/ehcache/FintEhCacheManagerTest.java b/src/test/java/no/novari/cache/ehcache/FintEhCacheManagerTest.java similarity index 79% rename from src/test/java/no/fintlabs/cache/ehcache/FintEhCacheManagerTest.java rename to src/test/java/no/novari/cache/ehcache/FintEhCacheManagerTest.java index ed22601..092f2f7 100644 --- a/src/test/java/no/fintlabs/cache/ehcache/FintEhCacheManagerTest.java +++ b/src/test/java/no/novari/cache/ehcache/FintEhCacheManagerTest.java @@ -1,8 +1,8 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; -import no.fintlabs.cache.FintCacheManager; -import no.fintlabs.cache.FintCacheManagerTest; -import no.fintlabs.cache.FintCacheOptions; +import no.novari.cache.FintCacheManager; +import no.novari.cache.FintCacheManagerTest; +import no.novari.cache.FintCacheOptions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertInstanceOf; diff --git a/src/test/java/no/fintlabs/cache/ehcache/FintEhCacheTest.java b/src/test/java/no/novari/cache/ehcache/FintEhCacheTest.java similarity index 93% rename from src/test/java/no/fintlabs/cache/ehcache/FintEhCacheTest.java rename to src/test/java/no/novari/cache/ehcache/FintEhCacheTest.java index f576b02..3238589 100644 --- a/src/test/java/no/fintlabs/cache/ehcache/FintEhCacheTest.java +++ b/src/test/java/no/novari/cache/ehcache/FintEhCacheTest.java @@ -1,6 +1,6 @@ -package no.fintlabs.cache.ehcache; +package no.novari.cache.ehcache; -import no.fintlabs.cache.*; +import no.novari.cache.*; import java.util.function.Consumer; class FintEhCacheTest extends FintCacheTest {