-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/antelopesystems/crud-fram…
…ework � Conflicts: � crud-framework-core/src/main/java/com/antelopesystem/crudframework/crud/annotation/CachedBy.kt
- Loading branch information
Showing
49 changed files
with
847 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: maven | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
ignore: | ||
- dependency-name: mysql:mysql-connector-java | ||
versions: | ||
- "> 5.1.18" | ||
- dependency-name: org.apache.commons:commons-lang3 | ||
versions: | ||
- ">= 3.11.a, < 3.12" | ||
- dependency-name: org.aspectj:aspectjweaver | ||
versions: | ||
- "> 1.8.13" | ||
- dependency-name: org.hibernate:hibernate-core | ||
versions: | ||
- "> 5.2.17.Final" | ||
- dependency-name: org.hibernate.validator:hibernate-validator | ||
versions: | ||
- "> 6.1.0.Final" | ||
- dependency-name: org.jetbrains.dokka:dokka-maven-plugin | ||
versions: | ||
- "> 1.4.20, < 1.5" | ||
- dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen | ||
versions: | ||
- "> 1.3.20" | ||
- dependency-name: org.jetbrains.kotlin:kotlin-maven-noarg | ||
versions: | ||
- "> 1.3.20" | ||
- dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin | ||
versions: | ||
- "> 1.3.20" | ||
- dependency-name: org.jetbrains.kotlin:kotlin-reflect | ||
versions: | ||
- "> 1.3.20" | ||
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8 | ||
versions: | ||
- "> 1.3.20" | ||
- dependency-name: org.springframework.boot:spring-boot-starter-parent | ||
versions: | ||
- "> 2.0.8.RELEASE" | ||
- dependency-name: org.testcontainers:mysql | ||
versions: | ||
- "> 1.10.6" | ||
- dependency-name: org.antlr:antlr4-runtime | ||
versions: | ||
- 4.9.2 | ||
- dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-core | ||
versions: | ||
- 1.4.2-native-mt | ||
- 1.4.3-native-mt | ||
- dependency-name: org.jetbrains.dokka:dokka-maven-plugin | ||
versions: | ||
- 1.4.20-dev-65 | ||
- dependency-name: org.apache.commons:commons-lang3 | ||
versions: | ||
- "3.10" | ||
- dependency-name: net.sf.ehcache:ehcache | ||
versions: | ||
- 2.10.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ork-core/src/main/java/com/antelopesystem/crudframework/crud/cache/CacheManagerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.antelopesystem.crudframework.crud.cache | ||
|
||
/** | ||
* Used to retrieve and create caches | ||
*/ | ||
interface CacheManagerAdapter { | ||
/** | ||
* Get a cache by its name | ||
*/ | ||
fun getCache(name: String): CrudCache? | ||
|
||
/** | ||
* Create a cache with the given name and options | ||
* Not all options are supported by all vendors | ||
* Whether or not the cache exists or not and how to handle that is passed on to the vendor | ||
*/ | ||
fun createCache(name: String, options: CrudCacheOptions): CrudCache | ||
} |
14 changes: 6 additions & 8 deletions
14
...crudframework/utils/utils/CacheUtils.java → .../crudframework/crud/cache/CacheUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
crud-framework-core/src/main/java/com/antelopesystem/crudframework/crud/cache/CrudCache.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.antelopesystem.crudframework.crud.cache | ||
|
||
/** | ||
* Internal cache abstraction | ||
*/ | ||
interface CrudCache { | ||
fun get(key: Any): Any? | ||
fun put(key: Any, value: Any?) | ||
fun remove(key: Any) | ||
fun removeAll() | ||
fun unwrap() : Any | ||
} |
11 changes: 11 additions & 0 deletions
11
...mework-core/src/main/java/com/antelopesystem/crudframework/crud/cache/CrudCacheOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.antelopesystem.crudframework.crud.cache | ||
|
||
/** | ||
* Options available when creating a cache | ||
* Not all options are supported by all vendors | ||
*/ | ||
data class CrudCacheOptions( | ||
val timeToLiveSeconds: Long? = null, | ||
val timeToIdleSeconds: Long? = null, | ||
val maxEntries: Long? = null | ||
) |
28 changes: 28 additions & 0 deletions
28
.../main/java/com/antelopesystem/crudframework/crud/cache/adapter/ehcache/CrudEhCacheImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.antelopesystem.crudframework.crud.cache.adapter.ehcache | ||
|
||
import com.antelopesystem.crudframework.crud.cache.CrudCache | ||
import net.sf.ehcache.Ehcache | ||
import net.sf.ehcache.Element | ||
|
||
class CrudEhCacheImpl(private val vendorCache: Ehcache) : CrudCache { | ||
override fun get(key: Any): Any? { | ||
return vendorCache.get(key)?.objectValue | ||
} | ||
|
||
override fun put(key: Any, value: Any?) { | ||
val element = Element(key, value) | ||
vendorCache.put(element) | ||
} | ||
|
||
override fun remove(key: Any) { | ||
vendorCache.remove(key) | ||
} | ||
|
||
override fun removeAll() { | ||
vendorCache.removeAll() | ||
} | ||
|
||
override fun unwrap(): Any { | ||
return vendorCache | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...java/com/antelopesystem/crudframework/crud/cache/adapter/ehcache/EhCacheManagerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.antelopesystem.crudframework.crud.cache.adapter.ehcache | ||
|
||
import com.antelopesystem.crudframework.crud.cache.CacheManagerAdapter | ||
import com.antelopesystem.crudframework.crud.cache.CrudCache | ||
import com.antelopesystem.crudframework.crud.cache.CrudCacheOptions | ||
import com.antelopesystem.crudframework.crud.cache.adapter.inmemory.InMemoryCacheManagerAdapter | ||
import net.sf.ehcache.Cache | ||
import net.sf.ehcache.CacheManager | ||
import net.sf.ehcache.config.CacheConfiguration | ||
import org.slf4j.LoggerFactory | ||
|
||
class EhCacheManagerAdapter( | ||
private val cacheManager: CacheManager | ||
) : CacheManagerAdapter { | ||
override fun getCache(name: String) : CrudCache? { | ||
return CrudEhCacheImpl(cacheManager.getCache(name)) | ||
} | ||
|
||
override fun createCache(name: String, options: CrudCacheOptions): CrudCache { | ||
log.debug("Attempting to create cache with name [ $name ] and options [ $options ]") | ||
val configuration = CacheConfiguration(name, 0) | ||
val (timeToLiveSeconds, timeToIdleSeconds, maxEntries) = options | ||
if(timeToLiveSeconds != null) { | ||
configuration.timeToLiveSeconds = timeToLiveSeconds | ||
} | ||
|
||
if(timeToIdleSeconds != null) { | ||
configuration.timeToIdleSeconds = timeToIdleSeconds | ||
} | ||
|
||
if(maxEntries != null) { | ||
configuration.maxEntriesInCache = maxEntries | ||
} | ||
|
||
val vendorCache = cacheManager.addCacheIfAbsent(Cache(configuration)) | ||
log.debug("Created cache with [ $name ] and options [ $options ]") | ||
return CrudEhCacheImpl(vendorCache) | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(EhCacheManagerAdapter::class.java) | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
...m/antelopesystem/crudframework/crud/cache/adapter/inmemory/InMemoryCacheManagerAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.antelopesystem.crudframework.crud.cache.adapter.inmemory | ||
|
||
import com.antelopesystem.crudframework.crud.cache.CacheManagerAdapter | ||
import com.antelopesystem.crudframework.crud.cache.CrudCache | ||
import com.antelopesystem.crudframework.crud.cache.CrudCacheOptions | ||
import org.slf4j.LoggerFactory | ||
|
||
class InMemoryCacheManagerAdapter : CacheManagerAdapter { | ||
private val caches = mutableMapOf<String, CrudCache>() | ||
override fun getCache(name: String) : CrudCache? { | ||
log.debug("Attempting to find cache with name [ $name ]") | ||
val cache = caches[name] | ||
if(cache != null) { | ||
log.debug("Found cache with $name") | ||
} else { | ||
log.debug("Did not find cache with $name") | ||
} | ||
|
||
return cache | ||
} | ||
|
||
override fun createCache(name: String, options: CrudCacheOptions): CrudCache { | ||
log.debug("Attempting to create or return cache with name [ $name ]") | ||
return caches.computeIfAbsent(name) { | ||
log.debug("Cache with name [ $name ] did not exist, creating") | ||
InMemoryCrudCache() | ||
} | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(InMemoryCacheManagerAdapter::class.java) | ||
} | ||
} | ||
|
||
|
||
|
Oops, something went wrong.