├── .mvn ├── jvm.config ├── maven.config ├── wrapper │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── extensions.xml └── settings.xml ├── .gitattributes ├── renovate.json ├── NOTICE ├── .gitignore ├── LICENSE_HEADER ├── format.xml ├── src ├── main │ └── java │ │ └── org │ │ └── mybatis │ │ └── caches │ │ └── ehcache │ │ ├── package-info.java │ │ ├── LoggingEhcache.java │ │ ├── EhcacheCache.java │ │ ├── EhBlockingCache.java │ │ ├── DummyReadWriteLock.java │ │ └── AbstractEhcacheCache.java ├── site │ ├── site.xml │ └── xdoc │ │ └── index.xml.vm └── test │ └── java │ └── org │ └── mybatis │ └── caches │ └── ehcache │ ├── EhcacheTest.java │ └── EhBlockingCacheTest.java ├── .github └── workflows │ ├── sonatype.yaml │ ├── ci.yaml │ ├── site.yaml │ ├── codeql.yaml │ ├── sonar.yaml │ └── coveralls.yaml ├── README.md ├── pom.xml ├── mvnw.cmd ├── LICENSE └── mvnw /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 2 | -Daether.connector.smartChecksums=false 3 | --no-transfer-progress 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | MyBatis-EHCACHE cache 2 | Copyright 2010-2024 3 | 4 | This product includes software developed by 5 | The MyBatis Team (http://mybatis.org/). 6 | 7 | This product includes software developed by 8 | Terracotta (http://ehcache.org/) 9 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionType=source 2 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip 3 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar 4 | wrapperVersion=3.3.4 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /*.iml 2 | /*.ipr 3 | /*.iws 4 | /.classpath 5 | /.idea 6 | /.project 7 | /.settings 8 | /ibderby 9 | /nb* 10 | /release.properties 11 | /target 12 | /test.db.lck 13 | /test.db.log 14 | /test.db.properties 15 | /test.db.script 16 | /test.db.tmp 17 | /src/docbkx 18 | velocity.log 19 | /bin 20 | .mvn/wrapper/maven-wrapper.jar 21 | .DS_Store 22 | *.releaseBackup 23 | -------------------------------------------------------------------------------- /LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | Copyright ${license.git.copyrightYears} the original author or authors. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /format.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains Ehcache support for MyBatis Cache. 18 | */ 19 | package org.mybatis.caches.ehcache; 20 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | fr.jcgay.maven 22 | maven-profiler 23 | 3.3 24 | 25 | 26 | -------------------------------------------------------------------------------- /.github/workflows/sonatype.yaml: -------------------------------------------------------------------------------- 1 | name: Sonatype 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | permissions: read-all 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | build: 16 | if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 30 19 | steps: 20 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 21 | - name: Setup Java 22 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 23 | with: 24 | cache: maven 25 | distribution: temurin 26 | java-version: 25 27 | - name: Deploy to Sonatype 28 | run: ./mvnw deploy --batch-mode --no-transfer-progress --settings ./.mvn/settings.xml --show-version -Dlicense.skip=true -DskipTests 29 | env: 30 | CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} 31 | CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} 32 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/LoggingEhcache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | /** 19 | * {@code LoggingCache} Kept for compatibility. 20 | * 21 | * @author Simone Tripodi 22 | * 23 | * @deprecated Not needed with MyBatis 3.2.x 24 | */ 25 | @Deprecated 26 | public final class LoggingEhcache extends EhcacheCache { 27 | 28 | public LoggingEhcache(String id) { 29 | super(id); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: [workflow_dispatch, push, pull_request] 4 | 5 | permissions: read-all 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | test: 13 | runs-on: ${{ matrix.os }} 14 | timeout-minutes: 30 15 | strategy: 16 | matrix: 17 | cache: [maven] 18 | distribution: [temurin] 19 | java: [21, 25, 26-ea] 20 | os: [macos-latest, ubuntu-latest, windows-latest] 21 | fail-fast: false 22 | max-parallel: 6 23 | name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} 24 | 25 | steps: 26 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 27 | - name: Setup Java ${{ matrix.java }} ${{ matrix.distribution }} 28 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 29 | with: 30 | cache: ${{ matrix.cache }} 31 | distribution: ${{ matrix.distribution }} 32 | java-version: ${{ matrix.java }} 33 | - name: Test with Maven 34 | run: ./mvnw test --batch-mode --no-transfer-progress --show-version -D"license.skip=true" 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MyBatis Ehcache Extension 2 | ========================= 3 | 4 | [![Java CI](https://github.com/mybatis/ehcache-cache/actions/workflows/ci.yaml/badge.svg)](https://github.com/mybatis/ehcache-cache/actions/workflows/ci.yaml) 5 | [![Coverage Status](https://coveralls.io/repos/mybatis/ehcache-cache/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/ehcache-cache?branch=master) 6 | [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.caches/mybatis-ehcache/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.caches/mybatis-ehcache) 7 | [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis.caches/mybatis-ehcache.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/caches/mybatis-ehcache/) 8 | [![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) 9 | 10 | ![mybatis-logo](https://mybatis.org/images/mybatis-logo.png) 11 | 12 | MyBatis-Ehcache extension Ehcache support for MyBatis Cache. 13 | 14 | Essentials 15 | ---------- 16 | 17 | * [See the docs](https://mybatis.org/ehcache-cache/) 18 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/EhcacheCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | public class EhcacheCache extends AbstractEhcacheCache { 19 | 20 | /** 21 | * Instantiates a new ehcache cache. 22 | * 23 | * @param id 24 | * the id 25 | */ 26 | public EhcacheCache(String id) { 27 | super(id); 28 | if (!CACHE_MANAGER.cacheExists(id)) { 29 | CACHE_MANAGER.addCache(id); 30 | } 31 | this.cache = CACHE_MANAGER.getEhcache(id); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /.github/workflows/site.yaml: -------------------------------------------------------------------------------- 1 | name: Site 2 | 3 | on: 4 | push: 5 | branches: 6 | - site 7 | 8 | permissions: 9 | contents: write 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | build: 17 | if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') 18 | runs-on: ubuntu-latest 19 | timeout-minutes: 60 20 | steps: 21 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 22 | - name: Setup Java 23 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 24 | with: 25 | cache: maven 26 | distribution: temurin 27 | java-version: 25 28 | - name: Build site 29 | run: ./mvnw site site:stage --batch-mode --no-transfer-progress --settings ./.mvn/settings.xml --show-version -Dlicense.skip=true -DskipTests 30 | env: 31 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | NVD_API_KEY: ${{ secrets.NVD_API_KEY }} 33 | - name: Deploy Site to gh-pages 34 | uses: JamesIves/github-pages-deploy-action@9d877eea73427180ae43cf98e8914934fe157a1a # v4 35 | with: 36 | branch: gh-pages 37 | folder: target/staging 38 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yaml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | schedule: 9 | - cron: '43 10 * * 2' 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | analyze: 17 | name: Analyze 18 | runs-on: 'ubuntu-latest' 19 | timeout-minutes: 30 20 | permissions: 21 | actions: read 22 | contents: read 23 | security-events: write 24 | 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 28 | 29 | - name: Setup Java 30 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 31 | with: 32 | cache: maven 33 | distribution: 'temurin' 34 | java-version: 25 35 | 36 | - name: Initialize CodeQL 37 | uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 38 | with: 39 | queries: +security-and-quality 40 | 41 | - name: Autobuild 42 | uses: github/codeql-action/autobuild@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 43 | 44 | - name: Perform CodeQL Analysis 45 | uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4 46 | -------------------------------------------------------------------------------- /.github/workflows/sonar.yaml: -------------------------------------------------------------------------------- 1 | name: SonarCloud 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | permissions: read-all 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | env: 15 | SONAR_ORGANIZATION: mybatis 16 | SONAR_PROJECT_KEY: ehcache-cache 17 | 18 | jobs: 19 | build: 20 | if: github.repository_owner == 'mybatis' 21 | runs-on: ubuntu-latest 22 | timeout-minutes: 30 23 | steps: 24 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 25 | with: 26 | # Disabling shallow clone is recommended for improving relevancy of reporting 27 | fetch-depth: 0 28 | - name: Setup Java 29 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 30 | with: 31 | cache: maven 32 | distribution: temurin 33 | java-version: 25 34 | - name: Set SONAR_SCANNER_JAVA_OPTS 35 | run: echo "SONAR_SCANNER_JAVA_OPTS=-Xmx512m" >> ${GITHUB_ENV} 36 | - name: Analyze with SonarCloud 37 | run: ./mvnw verify jacoco:report sonar:sonar --batch-mode --no-transfer-progress --show-version -Dlicense.skip=true -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=${{ env.SONAR_ORGANIZATION }} -Dsonar.projectKey=${{ env.SONAR_ORGANIZATION }}_${{ env.SONAR_PROJECT_KEY }} -Dsonar.scanner.skipJreProvisioning=true -Dsonar.token=${{ env.SONAR_TOKEN }} 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 41 | -------------------------------------------------------------------------------- /.github/workflows/coveralls.yaml: -------------------------------------------------------------------------------- 1 | name: Coveralls 2 | 3 | on: [push, pull_request] 4 | 5 | permissions: read-all 6 | 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.ref }} 9 | cancel-in-progress: true 10 | 11 | jobs: 12 | coveralls: 13 | if: github.repository_owner == 'mybatis' 14 | runs-on: ubuntu-latest 15 | timeout-minutes: 30 16 | steps: 17 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 18 | - name: Setup Java 19 | uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5 20 | with: 21 | cache: maven 22 | distribution: temurin 23 | java-version: 25 24 | - name: Run the build 25 | run: ./mvnw test --batch-mode --no-transfer-progress --quiet --show-version -Dlicense.skip=true 26 | - name: Report Coverage to Coveralls for Pull Requests 27 | if: github.event_name == 'pull_request' 28 | run: ./mvnw generate-sources jacoco:report coveralls:report --batch-mode --no-transfer-progress -DpullRequest=${{ env.PR_NUMBER }} -DrepoToken=${{ env.GITHUB_TOKEN }} -DserviceName=github 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | PR_NUMBER: ${{ github.event.number }} 32 | - name: Report Coverage to Coveralls for General Push 33 | if: github.event_name == 'push' 34 | run: ./mvnw generate-sources jacoco:report coveralls:report --batch-mode --no-transfer-progress -DrepoToken=${{ env.GITHUB_TOKEN }} -DserviceName=github 35 | env: 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 37 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/EhBlockingCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | import net.sf.ehcache.Ehcache; 19 | import net.sf.ehcache.Element; 20 | import net.sf.ehcache.constructs.blocking.BlockingCache; 21 | 22 | /** 23 | * The Class EhBlockingCache. 24 | * 25 | * @author Iwao AVE! 26 | */ 27 | public class EhBlockingCache extends AbstractEhcacheCache { 28 | 29 | /** 30 | * Instantiates a new eh blocking cache. 31 | * 32 | * @param id 33 | * the id 34 | */ 35 | public EhBlockingCache(final String id) { 36 | super(id); 37 | if (!CACHE_MANAGER.cacheExists(id)) { 38 | CACHE_MANAGER.addCache(this.id); 39 | Ehcache ehcache = CACHE_MANAGER.getEhcache(this.id); 40 | BlockingCache blockingCache = new BlockingCache(ehcache); 41 | CACHE_MANAGER.replaceCacheWithDecoratedCache(ehcache, blockingCache); 42 | } 43 | this.cache = CACHE_MANAGER.getEhcache(id); 44 | } 45 | 46 | @Override 47 | public Object removeObject(Object key) { 48 | // this method is called during a rollback just to 49 | // release any previous lock 50 | cache.put(new Element(key, null)); 51 | return null; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /.mvn/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 21 | 22 | 23 | 24 | 25 | central 26 | ${env.CI_DEPLOY_USERNAME} 27 | ${env.CI_DEPLOY_PASSWORD} 28 | 29 | 30 | 31 | 32 | gh-pages-scm 33 | 34 | branch 35 | gh-pages 36 | 37 | 38 | 39 | 40 | 41 | github 42 | ${env.GITHUB_TOKEN} 43 | 44 | 45 | 46 | 47 | nvd 48 | ${env.NVD_API_KEY} 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/DummyReadWriteLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | import java.util.concurrent.TimeUnit; 19 | import java.util.concurrent.locks.Condition; 20 | import java.util.concurrent.locks.Lock; 21 | import java.util.concurrent.locks.ReadWriteLock; 22 | 23 | /** 24 | * The Class DummyReadWriteLock. 25 | * 26 | * @author Iwao AVE! 27 | */ 28 | class DummyReadWriteLock implements ReadWriteLock { 29 | 30 | /** The lock. */ 31 | private Lock lock = new DummyLock(); 32 | 33 | @Override 34 | public Lock readLock() { 35 | return lock; 36 | } 37 | 38 | @Override 39 | public Lock writeLock() { 40 | return lock; 41 | } 42 | 43 | /** 44 | * The Class DummyLock. 45 | */ 46 | static class DummyLock implements Lock { 47 | 48 | @Override 49 | public void lock() { 50 | // Not implemented 51 | } 52 | 53 | @Override 54 | public void lockInterruptibly() throws InterruptedException { 55 | // Not implemented 56 | } 57 | 58 | @Override 59 | public boolean tryLock() { 60 | return true; 61 | } 62 | 63 | @Override 64 | public boolean tryLock(long paramLong, TimeUnit paramTimeUnit) throws InterruptedException { 65 | return true; 66 | } 67 | 68 | @Override 69 | public void unlock() { 70 | // Not implemented 71 | } 72 | 73 | @Override 74 | public Condition newCondition() { 75 | return null; 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * https://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.net.Authenticator; 23 | import java.net.PasswordAuthentication; 24 | import java.net.URI; 25 | import java.net.URL; 26 | import java.nio.file.Files; 27 | import java.nio.file.Path; 28 | import java.nio.file.StandardCopyOption; 29 | import java.util.concurrent.ThreadLocalRandom; 30 | 31 | public final class MavenWrapperDownloader { 32 | private static final String WRAPPER_VERSION = "3.3.4"; 33 | 34 | private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE")); 35 | 36 | public static void main(String[] args) { 37 | log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION); 38 | 39 | if (args.length != 2) { 40 | System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing"); 41 | System.exit(1); 42 | } 43 | 44 | try { 45 | log(" - Downloader started"); 46 | final URL wrapperUrl = URI.create(args[0]).toURL(); 47 | final Path baseDir = Path.of(".").toAbsolutePath().normalize(); 48 | final Path wrapperJarPath = baseDir.resolve(args[1]).normalize(); 49 | if (!wrapperJarPath.startsWith(baseDir)) { 50 | throw new IOException("Invalid path: outside of allowed directory"); 51 | } 52 | downloadFileFromURL(wrapperUrl, wrapperJarPath); 53 | log("Done"); 54 | } catch (IOException e) { 55 | System.err.println("- Error downloading: " + e.getMessage()); 56 | if (VERBOSE) { 57 | e.printStackTrace(); 58 | } 59 | System.exit(1); 60 | } 61 | } 62 | 63 | private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath) 64 | throws IOException { 65 | log(" - Downloading to: " + wrapperJarPath); 66 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 67 | final String username = System.getenv("MVNW_USERNAME"); 68 | final char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 69 | Authenticator.setDefault(new Authenticator() { 70 | @Override 71 | protected PasswordAuthentication getPasswordAuthentication() { 72 | return new PasswordAuthentication(username, password); 73 | } 74 | }); 75 | } 76 | Path temp = wrapperJarPath 77 | .getParent() 78 | .resolve(wrapperJarPath.getFileName() + "." 79 | + Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp"); 80 | try (InputStream inStream = wrapperUrl.openStream()) { 81 | Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING); 82 | Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING); 83 | } finally { 84 | Files.deleteIfExists(temp); 85 | } 86 | log(" - Downloader complete"); 87 | } 88 | 89 | private static void log(String msg) { 90 | if (VERBOSE) { 91 | System.out.println(msg); 92 | } 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.mybatis 25 | mybatis-parent 26 | 51 27 | 28 | 29 | 30 | org.mybatis.caches 31 | mybatis-ehcache 32 | 1.3.2-SNAPSHOT 33 | 34 | mybatis-ehcache 35 | Ehcache support for MyBatis Cache 36 | https://www.mybatis.org/ehcache-cache/ 37 | 38 | 39 | scm:git:ssh://git@github.com/mybatis/ehcache-cache.git 40 | scm:git:ssh://git@github.com/mybatis/ehcache-cache.git 41 | HEAD 42 | http://github.com/mybatis/ehcache-cache/ 43 | 44 | 45 | GitHub Issue Management 46 | https://github.com/mybatis/ehcache-cache/issues 47 | 48 | 49 | GitHub Actions 50 | https://github.com/mybatis/ehcache-cache/actions 51 | 52 | 53 | 54 | gh-pages-scm 55 | Mybatis GitHub Pages 56 | scm:git:ssh://git@github.com/mybatis/ehcache-cache.git 57 | 58 | 59 | 60 | 61 | 62 | 11 63 | 11 64 | 65 | 1.2.0 66 | org.mybatis.caches.ehcache.* 67 | Cache 68 | org.mybatis.caches.ehcache 69 | 70 | 71 | 1763919261 72 | 73 | 74 | 2.0.17 75 | 76 | 77 | 78 | 79 | org.mybatis 80 | mybatis 81 | 3.5.19 82 | provided 83 | 84 | 85 | 86 | net.sf.ehcache 87 | ehcache 88 | 2.10.9.2 89 | compile 90 | 91 | 92 | 93 | org.junit.jupiter 94 | junit-jupiter-engine 95 | 6.0.1 96 | test 97 | 98 | 99 | 100 | org.slf4j 101 | slf4j-api 102 | ${slf4j.version} 103 | compile 104 | 105 | 106 | org.slf4j 107 | slf4j-simple 108 | ${slf4j.version} 109 | test 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/site/xdoc/index.xml.vm: -------------------------------------------------------------------------------- 1 | 2 | 19 | 22 | 23 | 24 | MyBatis Ehcache | Reference Documentation 25 | Simone Tripodi 26 | 27 | 28 | 29 |
30 | 31 |

Ehcache is a widely used java distributed cache for general purpose caching, 32 | Java EE and light-weight containers.

33 |

The Ehcache integration is built on top of the ehcache and comes without any Ehcache 3rd party applications. 34 | Please refer to official Ehcache documentation if you need plugins.

35 |

To use Ehcache in your application download the zip bundle, 36 | decompress it and add the jars to the classpath.

37 |

If you are using Maven then simply add to your pom.xml the following dependency:

38 | 39 | 40 | ... 41 | 42 | org.mybatis.caches 43 | mybatis-ehcache 44 | ${project.version} 45 | 46 | ... 47 | ]]> 48 | 49 |

then, just configure a cache element in your mapper XML files as follows:

50 | 51 | 52 | 53 | ... 54 | ]]> 55 | 56 |

You can also provide values for parameters that can be modified dynamically at runtime:

57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | ... 67 | ]]> 68 | 69 |

You may need to use a blocking cache. See the details here. 70 | This is how it is configured:

71 | 72 | 73 | 74 | ... 75 | ]]> 76 | 77 |

Users that need to configure Ehcache through XML configuration file, have to put in the classpath the /ehcache.xml resource. 78 | Please refer to the official Ehcache documentation to know more details.

79 | 80 |

If the /ehcache.xml resource is not found or something goes wrong while loading it, the default configuration will be used.

81 |
82 | 83 | 84 |
85 | -------------------------------------------------------------------------------- /src/test/java/org/mybatis/caches/ehcache/EhcacheTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; 21 | import static org.junit.jupiter.api.Assertions.assertNull; 22 | import static org.junit.jupiter.api.Assertions.assertThrows; 23 | 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | 27 | class EhcacheTest { 28 | 29 | private static final String DEFAULT_ID = "EHCACHE"; 30 | 31 | // CacheManager holds any settings between tests 32 | private AbstractEhcacheCache cache; 33 | 34 | @BeforeEach 35 | void newCache() { 36 | cache = new EhcacheCache(DEFAULT_ID); 37 | } 38 | 39 | @Test 40 | void shouldDemonstrateHowAllObjectsAreKept() { 41 | for (int i = 0; i < 100000; i++) { 42 | cache.putObject(i, i); 43 | assertEquals(i, cache.getObject(i)); 44 | } 45 | assertEquals(100000, cache.getSize()); 46 | } 47 | 48 | @Test 49 | void shouldDemonstrateCopiesAreEqual() { 50 | for (int i = 0; i < 1000; i++) { 51 | cache.putObject(i, i); 52 | assertEquals(i, cache.getObject(i)); 53 | } 54 | } 55 | 56 | @Test 57 | void shouldRemoveItemOnDemand() { 58 | cache.putObject(0, 0); 59 | assertNotNull(cache.getObject(0)); 60 | cache.removeObject(0); 61 | assertNull(cache.getObject(0)); 62 | } 63 | 64 | @Test 65 | void shouldFlushAllItemsOnDemand() { 66 | for (int i = 0; i < 5; i++) { 67 | cache.putObject(i, i); 68 | } 69 | assertNotNull(cache.getObject(0)); 70 | assertNotNull(cache.getObject(4)); 71 | cache.clear(); 72 | assertNull(cache.getObject(0)); 73 | assertNull(cache.getObject(4)); 74 | } 75 | 76 | @Test 77 | void shouldChangeTimeToLive() throws Exception { 78 | cache.putObject("test", "test"); 79 | Thread.sleep(1200); 80 | assertEquals("test", cache.getObject("test")); 81 | cache.setTimeToLiveSeconds(1); 82 | Thread.sleep(1200); 83 | assertNull(cache.getObject("test")); 84 | this.resetCache(); 85 | } 86 | 87 | @Test 88 | void shouldChangeTimeToIdle() throws Exception { 89 | cache.putObject("test", "test"); 90 | Thread.sleep(1200); 91 | assertEquals("test", cache.getObject("test")); 92 | cache.setTimeToIdleSeconds(1); 93 | Thread.sleep(1200); 94 | assertNull(cache.getObject("test")); 95 | this.resetCache(); 96 | } 97 | 98 | @Test 99 | void shouldTestEvictionPolicy() throws Exception { 100 | cache.clear(); 101 | cache.setMemoryStoreEvictionPolicy("FIFO"); 102 | cache.setMaxEntriesLocalHeap(1); 103 | cache.setMaxEntriesLocalDisk(1); 104 | cache.putObject("eviction", "eviction"); 105 | cache.putObject("eviction2", "eviction2"); 106 | cache.putObject("eviction3", "eviction3"); 107 | Thread.sleep(1200); 108 | assertEquals(1, cache.getSize()); 109 | this.resetCache(); 110 | } 111 | 112 | @Test 113 | void shouldNotCreateCache() { 114 | assertThrows(IllegalArgumentException.class, () -> { 115 | cache = new EhcacheCache(null); 116 | }); 117 | } 118 | 119 | @Test 120 | void shouldVerifyCacheId() { 121 | assertEquals("EHCACHE", cache.getId()); 122 | } 123 | 124 | @Test 125 | void shouldVerifyToString() { 126 | assertEquals("EHCache {EHCACHE}", cache.toString()); 127 | } 128 | 129 | @Test 130 | void equalsAndHashCodeSymmetricTest() { 131 | // equals and hashCode check name field value 132 | AbstractEhcacheCache x = new EhcacheCache("EHCACHE"); 133 | AbstractEhcacheCache y = new EhcacheCache("EHCACHE"); 134 | assertEquals(x, y); 135 | assertEquals(y, x); 136 | assertEquals(x.hashCode(), y.hashCode()); 137 | // dummy tests to cover edge cases 138 | assertNotEquals(x, new String()); 139 | assertNotNull(x); 140 | assertEquals(x, x); 141 | } 142 | 143 | // CacheManager holds reference to settings, reset this for other tests 144 | private void resetCache() { 145 | cache.setTimeToLiveSeconds(120); 146 | cache.setTimeToIdleSeconds(120); 147 | cache.setMemoryStoreEvictionPolicy("LRU"); 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/test/java/org/mybatis/caches/ehcache/EhBlockingCacheTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 20 | import static org.junit.jupiter.api.Assertions.assertNotNull; 21 | import static org.junit.jupiter.api.Assertions.assertNull; 22 | import static org.junit.jupiter.api.Assertions.assertThrows; 23 | 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | 27 | class EhBlockingCacheTest { 28 | 29 | private static final String DEFAULT_ID = "EHBLOCKINGCACHE"; 30 | 31 | // CacheManager holds any settings between tests 32 | private AbstractEhcacheCache cache; 33 | 34 | @BeforeEach 35 | void newCache() { 36 | cache = new EhBlockingCache(DEFAULT_ID); 37 | } 38 | 39 | @Test 40 | void shouldDemonstrateHowAllObjectsAreKept() { 41 | for (int i = 0; i < 100000; i++) { 42 | cache.putObject(i, i); 43 | assertEquals(i, cache.getObject(i)); 44 | } 45 | assertEquals(100000, cache.getSize()); 46 | } 47 | 48 | @Test 49 | void shouldDemonstrateCopiesAreEqual() { 50 | for (int i = 0; i < 1000; i++) { 51 | cache.putObject(i, i); 52 | assertEquals(i, cache.getObject(i)); 53 | } 54 | } 55 | 56 | @Test 57 | void shouldRemoveItemOnDemand() { 58 | cache.putObject(0, 0); 59 | assertNotNull(cache.getObject(0)); 60 | cache.removeObject(0); 61 | assertNull(cache.getObject(0)); 62 | } 63 | 64 | @Test 65 | void shouldFlushAllItemsOnDemand() { 66 | for (int i = 0; i < 5; i++) { 67 | cache.putObject(i, i); 68 | } 69 | assertNotNull(cache.getObject(0)); 70 | assertNotNull(cache.getObject(4)); 71 | cache.clear(); 72 | assertNull(cache.getObject(0)); 73 | assertNull(cache.getObject(4)); 74 | } 75 | 76 | @Test 77 | void shouldChangeTimeToLive() throws Exception { 78 | cache.putObject("test", "test"); 79 | Thread.sleep(1200); 80 | assertEquals("test", cache.getObject("test")); 81 | cache.setTimeToLiveSeconds(1); 82 | Thread.sleep(1200); 83 | assertNull(cache.getObject("test")); 84 | this.resetCache(); 85 | } 86 | 87 | @Test 88 | void shouldChangeTimeToIdle() throws Exception { 89 | cache.putObject("test", "test"); 90 | Thread.sleep(1200); 91 | assertEquals("test", cache.getObject("test")); 92 | cache.setTimeToIdleSeconds(1); 93 | Thread.sleep(1200); 94 | assertNull(cache.getObject("test")); 95 | this.resetCache(); 96 | } 97 | 98 | @Test 99 | void shouldTestEvictionPolicy() throws Exception { 100 | cache.clear(); 101 | cache.setMemoryStoreEvictionPolicy("FIFO"); 102 | cache.setMaxEntriesLocalHeap(1); 103 | cache.setMaxEntriesLocalDisk(1); 104 | cache.putObject("eviction", "eviction"); 105 | cache.putObject("eviction2", "eviction2"); 106 | cache.putObject("eviction3", "eviction3"); 107 | Thread.sleep(1200); 108 | assertEquals(1, cache.getSize()); 109 | this.resetCache(); 110 | } 111 | 112 | @Test 113 | void shouldNotCreateCache() { 114 | assertThrows(IllegalArgumentException.class, () -> { 115 | cache = new EhBlockingCache(null); 116 | }); 117 | } 118 | 119 | @Test 120 | void shouldVerifyCacheId() { 121 | assertEquals(DEFAULT_ID, cache.getId()); 122 | } 123 | 124 | @Test 125 | void shouldVerifyToString() { 126 | assertEquals("EHCache {EHBLOCKINGCACHE}", cache.toString()); 127 | } 128 | 129 | @Test 130 | void equalsAndHashCodeSymmetricTest() { 131 | // equals and hashCode check name field value 132 | AbstractEhcacheCache x = new EhBlockingCache(DEFAULT_ID); 133 | AbstractEhcacheCache y = new EhBlockingCache(DEFAULT_ID); 134 | assertEquals(x, y); 135 | assertEquals(y, x); 136 | assertEquals(x.hashCode(), y.hashCode()); 137 | // dummy tests to cover edge cases 138 | assertNotEquals(x, new String()); 139 | assertNotNull(x); 140 | assertEquals(x, x); 141 | } 142 | 143 | // CacheManager holds reference to settings, reset this for other tests 144 | private void resetCache() { 145 | cache.setTimeToLiveSeconds(120); 146 | cache.setTimeToIdleSeconds(120); 147 | cache.setMemoryStoreEvictionPolicy("LRU"); 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/org/mybatis/caches/ehcache/AbstractEhcacheCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.mybatis.caches.ehcache; 17 | 18 | import java.util.concurrent.locks.ReadWriteLock; 19 | 20 | import net.sf.ehcache.CacheManager; 21 | import net.sf.ehcache.Ehcache; 22 | import net.sf.ehcache.Element; 23 | 24 | import org.apache.ibatis.cache.Cache; 25 | 26 | /** 27 | * Cache adapter for Ehcache. 28 | * 29 | * @author Simone Tripodi 30 | */ 31 | public abstract class AbstractEhcacheCache implements Cache { 32 | 33 | /** 34 | * The cache manager reference. 35 | */ 36 | protected static CacheManager CACHE_MANAGER = CacheManager.create(); 37 | 38 | /** 39 | * The cache id (namespace). 40 | */ 41 | protected final String id; 42 | 43 | /** 44 | * The cache instance. 45 | */ 46 | protected Ehcache cache; 47 | 48 | /** 49 | * Instantiates a new abstract ehcache cache. 50 | * 51 | * @param id 52 | * the chache id (namespace) 53 | */ 54 | public AbstractEhcacheCache(final String id) { 55 | if (id == null) { 56 | throw new IllegalArgumentException("Cache instances require an ID"); 57 | } 58 | this.id = id; 59 | } 60 | 61 | /** 62 | * {@inheritDoc} 63 | */ 64 | @Override 65 | public void clear() { 66 | cache.removeAll(); 67 | } 68 | 69 | /** 70 | * {@inheritDoc} 71 | */ 72 | @Override 73 | public String getId() { 74 | return id; 75 | } 76 | 77 | /** 78 | * {@inheritDoc} 79 | */ 80 | @Override 81 | public Object getObject(Object key) { 82 | Element cachedElement = cache.get(key); 83 | if (cachedElement == null) { 84 | return null; 85 | } 86 | return cachedElement.getObjectValue(); 87 | } 88 | 89 | /** 90 | * {@inheritDoc} 91 | */ 92 | @Override 93 | public int getSize() { 94 | return cache.getSize(); 95 | } 96 | 97 | /** 98 | * {@inheritDoc} 99 | */ 100 | @Override 101 | public void putObject(Object key, Object value) { 102 | cache.put(new Element(key, value)); 103 | } 104 | 105 | /** 106 | * {@inheritDoc} 107 | */ 108 | @Override 109 | public Object removeObject(Object key) { 110 | Object obj = getObject(key); 111 | cache.remove(key); 112 | return obj; 113 | } 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | public void unlock(Object key) { 119 | } 120 | 121 | /** 122 | * {@inheritDoc} 123 | */ 124 | @Override 125 | public boolean equals(Object obj) { 126 | if (this == obj) { 127 | return true; 128 | } 129 | if (obj == null) { 130 | return false; 131 | } 132 | if (!(obj instanceof Cache)) { 133 | return false; 134 | } 135 | 136 | Cache otherCache = (Cache) obj; 137 | return id.equals(otherCache.getId()); 138 | } 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | @Override 144 | public int hashCode() { 145 | return id.hashCode(); 146 | } 147 | 148 | @Override 149 | public ReadWriteLock getReadWriteLock() { 150 | return null; 151 | } 152 | 153 | /** 154 | * {@inheritDoc} 155 | */ 156 | @Override 157 | public String toString() { 158 | return "EHCache {" + id + "}"; 159 | } 160 | 161 | // DYNAMIC PROPERTIES 162 | 163 | /** 164 | * Sets the time to idle for an element before it expires. Is only used if the element is not eternal. 165 | * 166 | * @param timeToIdleSeconds 167 | * the default amount of time to live for an element from its last accessed or modified date 168 | */ 169 | public void setTimeToIdleSeconds(long timeToIdleSeconds) { 170 | cache.getCacheConfiguration().setTimeToIdleSeconds(timeToIdleSeconds); 171 | } 172 | 173 | /** 174 | * Sets the time to idle for an element before it expires. Is only used if the element is not eternal. 175 | * 176 | * @param timeToLiveSeconds 177 | * the default amount of time to live for an element from its creation date 178 | */ 179 | public void setTimeToLiveSeconds(long timeToLiveSeconds) { 180 | cache.getCacheConfiguration().setTimeToLiveSeconds(timeToLiveSeconds); 181 | } 182 | 183 | /** 184 | * Sets the maximum objects to be held in memory (0 = no limit). 185 | * 186 | * @param maxEntriesLocalHeap 187 | * The maximum number of elements in heap, before they are evicted (0 == no limit) 188 | */ 189 | public void setMaxEntriesLocalHeap(long maxEntriesLocalHeap) { 190 | cache.getCacheConfiguration().setMaxEntriesLocalHeap(maxEntriesLocalHeap); 191 | } 192 | 193 | /** 194 | * Sets the maximum number elements on Disk. 0 means unlimited. 195 | * 196 | * @param maxEntriesLocalDisk 197 | * the maximum number of Elements to allow on the disk. 0 means unlimited. 198 | */ 199 | public void setMaxEntriesLocalDisk(long maxEntriesLocalDisk) { 200 | cache.getCacheConfiguration().setMaxEntriesLocalDisk(maxEntriesLocalDisk); 201 | } 202 | 203 | /** 204 | * Sets the eviction policy. An invalid argument will set it to null. 205 | * 206 | * @param memoryStoreEvictionPolicy 207 | * a String representation of the policy. One of "LRU", "LFU" or "FIFO". 208 | */ 209 | public void setMemoryStoreEvictionPolicy(String memoryStoreEvictionPolicy) { 210 | cache.getCacheConfiguration().setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy); 211 | } 212 | 213 | } 214 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.3.4 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. >&2 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. >&2 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. >&2 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. >&2 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | 121 | @REM Maven main class is here to fix maven 4.0.0-beta-5 through 4.0.0-rc-4 122 | set MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling 123 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 124 | 125 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" 126 | 127 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 128 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 129 | ) 130 | 131 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 132 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 133 | if exist %WRAPPER_JAR% ( 134 | if "%MVNW_VERBOSE%" == "true" ( 135 | echo Found %WRAPPER_JAR% 136 | ) 137 | ) else ( 138 | if not "%MVNW_REPOURL%" == "" ( 139 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" 140 | ) 141 | if "%MVNW_VERBOSE%" == "true" ( 142 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 143 | echo Downloading from: %WRAPPER_URL% 144 | ) 145 | 146 | powershell -Command "&{"^ 147 | "$webclient = new-object System.Net.WebClient;"^ 148 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 149 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 150 | "}"^ 151 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 152 | "}" 153 | if "%MVNW_VERBOSE%" == "true" ( 154 | echo Finished downloading %WRAPPER_JAR% 155 | ) 156 | ) 157 | @REM End of extension 158 | 159 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 160 | SET WRAPPER_SHA_256_SUM="" 161 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 162 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 163 | ) 164 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 165 | powershell -Command "&{"^ 166 | "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ 167 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 168 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 169 | " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 170 | " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 171 | " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 172 | " exit 1;"^ 173 | "}"^ 174 | "}" 175 | if ERRORLEVEL 1 goto error 176 | ) 177 | 178 | @REM Provide a "standardized" way to retrieve the CLI args that will 179 | @REM work with both Windows and non-Windows executions. 180 | set MAVEN_CMD_LINE_ARGS=%* 181 | 182 | %MAVEN_JAVA_EXE% ^ 183 | %JVM_CONFIG_MAVEN_PROPS% ^ 184 | %MAVEN_OPTS% ^ 185 | %MAVEN_DEBUG_OPTS% ^ 186 | -classpath %WRAPPER_JAR% ^ 187 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 188 | "-Dmaven.mainClass=%MAVEN_MAIN_CLASS%" ^ 189 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 190 | if ERRORLEVEL 1 goto error 191 | goto end 192 | 193 | :error 194 | set ERROR_CODE=1 195 | 196 | :end 197 | @endlocal & set ERROR_CODE=%ERROR_CODE% 198 | 199 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 200 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 201 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 202 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 203 | :skipRcPost 204 | 205 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 206 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 207 | 208 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 209 | 210 | cmd /C exit /B %ERROR_CODE% 211 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | https://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.4 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ]; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ]; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ]; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ]; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false 54 | darwin=false 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true ;; 59 | Darwin*) 60 | darwin=true 61 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 62 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 63 | if [ -z "$JAVA_HOME" ]; then 64 | if [ -x "/usr/libexec/java_home" ]; then 65 | JAVA_HOME="$(/usr/libexec/java_home)" 66 | export JAVA_HOME 67 | else 68 | JAVA_HOME="/Library/Java/Home" 69 | export JAVA_HOME 70 | fi 71 | fi 72 | ;; 73 | esac 74 | 75 | if [ -z "$JAVA_HOME" ]; then 76 | if [ -r /etc/gentoo-release ]; then 77 | JAVA_HOME=$(java-config --jre-home) 78 | fi 79 | fi 80 | 81 | # For Cygwin, ensure paths are in UNIX format before anything is touched 82 | if $cygwin; then 83 | [ -n "$JAVA_HOME" ] \ 84 | && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 85 | [ -n "$CLASSPATH" ] \ 86 | && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 87 | fi 88 | 89 | # For Mingw, ensure paths are in UNIX format before anything is touched 90 | if $mingw; then 91 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ 92 | && JAVA_HOME="$( 93 | cd "$JAVA_HOME" || ( 94 | echo "cannot cd into $JAVA_HOME." >&2 95 | exit 1 96 | ) 97 | pwd 98 | )" 99 | fi 100 | 101 | if [ -z "$JAVA_HOME" ]; then 102 | javaExecutable="$(which javac)" 103 | if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then 104 | # readlink(1) is not available as standard on Solaris 10. 105 | readLink=$(which readlink) 106 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 107 | if $darwin; then 108 | javaHome="$(dirname "$javaExecutable")" 109 | javaExecutable="$(cd "$javaHome" && pwd -P)/javac" 110 | else 111 | javaExecutable="$(readlink -f "$javaExecutable")" 112 | fi 113 | javaHome="$(dirname "$javaExecutable")" 114 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 115 | JAVA_HOME="$javaHome" 116 | export JAVA_HOME 117 | fi 118 | fi 119 | fi 120 | 121 | if [ -z "$JAVACMD" ]; then 122 | if [ -n "$JAVA_HOME" ]; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD="$JAVA_HOME/jre/sh/java" 126 | else 127 | JAVACMD="$JAVA_HOME/bin/java" 128 | fi 129 | else 130 | JAVACMD="$( 131 | \unset -f command 2>/dev/null 132 | \command -v java 133 | )" 134 | fi 135 | fi 136 | 137 | if [ ! -x "$JAVACMD" ]; then 138 | echo "Error: JAVA_HOME is not defined correctly." >&2 139 | echo " We cannot execute $JAVACMD" >&2 140 | exit 1 141 | fi 142 | 143 | if [ -z "$JAVA_HOME" ]; then 144 | echo "Warning: JAVA_HOME environment variable is not set." >&2 145 | fi 146 | 147 | # traverses directory structure from process work directory to filesystem root 148 | # first directory with .mvn subdirectory is considered project base directory 149 | find_maven_basedir() { 150 | if [ -z "$1" ]; then 151 | echo "Path not specified to find_maven_basedir" >&2 152 | return 1 153 | fi 154 | 155 | basedir="$1" 156 | wdir="$1" 157 | while [ "$wdir" != '/' ]; do 158 | if [ -d "$wdir"/.mvn ]; then 159 | basedir=$wdir 160 | break 161 | fi 162 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 163 | if [ -d "${wdir}" ]; then 164 | wdir=$( 165 | cd "$wdir/.." || exit 1 166 | pwd 167 | ) 168 | fi 169 | # end of workaround 170 | done 171 | printf '%s' "$( 172 | cd "$basedir" || exit 1 173 | pwd 174 | )" 175 | } 176 | 177 | # concatenates all lines of a file 178 | concat_lines() { 179 | if [ -f "$1" ]; then 180 | # Remove \r in case we run on Windows within Git Bash 181 | # and check out the repository with auto CRLF management 182 | # enabled. Otherwise, we may read lines that are delimited with 183 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 184 | # splitting rules. 185 | tr -s '\r\n' ' ' <"$1" 186 | fi 187 | } 188 | 189 | log() { 190 | if [ "$MVNW_VERBOSE" = true ]; then 191 | printf '%s\n' "$1" 192 | fi 193 | } 194 | 195 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 196 | if [ -z "$BASE_DIR" ]; then 197 | exit 1 198 | fi 199 | 200 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 201 | export MAVEN_PROJECTBASEDIR 202 | log "$MAVEN_PROJECTBASEDIR" 203 | 204 | trim() { 205 | # MWRAPPER-139: 206 | # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. 207 | # Needed for removing poorly interpreted newline sequences when running in more 208 | # exotic environments such as mingw bash on Windows. 209 | printf "%s" "${1}" | tr -d '[:space:]' 210 | } 211 | 212 | ########################################################################################## 213 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 214 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 215 | ########################################################################################## 216 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 217 | if [ -r "$wrapperJarPath" ]; then 218 | log "Found $wrapperJarPath" 219 | else 220 | log "Couldn't find $wrapperJarPath, downloading it ..." 221 | 222 | if [ -n "$MVNW_REPOURL" ]; then 223 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" 224 | else 225 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar" 226 | fi 227 | while IFS="=" read -r key value; do 228 | case "$key" in wrapperUrl) 229 | wrapperUrl=$(trim "${value-}") 230 | break 231 | ;; 232 | esac 233 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 234 | log "Downloading from: $wrapperUrl" 235 | 236 | if $cygwin; then 237 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 238 | fi 239 | 240 | if command -v wget >/dev/null; then 241 | log "Found wget ... using wget" 242 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 243 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 244 | wget ${QUIET:+"$QUIET"} "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 245 | else 246 | wget ${QUIET:+"$QUIET"} --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 247 | fi 248 | elif command -v curl >/dev/null; then 249 | log "Found curl ... using curl" 250 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 251 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 252 | curl ${QUIET:+"$QUIET"} -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 253 | else 254 | curl ${QUIET:+"$QUIET"} --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 255 | fi 256 | else 257 | log "Falling back to using Java to download" 258 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 259 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 260 | # For Cygwin, switch paths to Windows format before running javac 261 | if $cygwin; then 262 | javaSource=$(cygpath --path --windows "$javaSource") 263 | javaClass=$(cygpath --path --windows "$javaClass") 264 | fi 265 | if [ -e "$javaSource" ]; then 266 | if [ ! -e "$javaClass" ]; then 267 | log " - Compiling MavenWrapperDownloader.java ..." 268 | ("$JAVA_HOME/bin/javac" "$javaSource") 269 | fi 270 | if [ -e "$javaClass" ]; then 271 | log " - Running MavenWrapperDownloader.java ..." 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 282 | wrapperSha256Sum="" 283 | while IFS="=" read -r key value; do 284 | case "$key" in wrapperSha256Sum) 285 | wrapperSha256Sum=$(trim "${value-}") 286 | break 287 | ;; 288 | esac 289 | done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 290 | if [ -n "$wrapperSha256Sum" ]; then 291 | wrapperSha256Result=false 292 | if command -v sha256sum >/dev/null; then 293 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c - >/dev/null 2>&1; then 294 | wrapperSha256Result=true 295 | fi 296 | elif command -v shasum >/dev/null; then 297 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then 298 | wrapperSha256Result=true 299 | fi 300 | else 301 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 302 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 303 | exit 1 304 | fi 305 | if [ $wrapperSha256Result = false ]; then 306 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 307 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 308 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 309 | exit 1 310 | fi 311 | fi 312 | 313 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 314 | 315 | # For Cygwin, switch paths to Windows format before running java 316 | if $cygwin; then 317 | [ -n "$JAVA_HOME" ] \ 318 | && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 319 | [ -n "$CLASSPATH" ] \ 320 | && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 321 | [ -n "$MAVEN_PROJECTBASEDIR" ] \ 322 | && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 323 | fi 324 | 325 | # Provide a "standardized" way to retrieve the CLI args that will 326 | # work with both Windows and non-Windows executions. 327 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 328 | export MAVEN_CMD_LINE_ARGS 329 | 330 | # Maven main class is here to fix maven 4.0.0-beta-5 through 4.0.0-rc-4 331 | MAVEN_MAIN_CLASS=org.apache.maven.cling.MavenCling 332 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 333 | 334 | # shellcheck disable=SC2086 # safe args 335 | exec "$JAVACMD" \ 336 | $MAVEN_OPTS \ 337 | $MAVEN_DEBUG_OPTS \ 338 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 339 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 340 | "-Dmaven.mainClass=${MAVEN_MAIN_CLASS}" \ 341 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 342 | --------------------------------------------------------------------------------