diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index cfc696f01..000000000 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * The MIT License - * Copyright © 2014-2021 Ilkka Seppälä - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83ae..4f15c4db1 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# https://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/crtp/etc/crtp.urm.puml b/crtp/etc/crtp.urm.puml new file mode 100644 index 000000000..02af47ddf --- /dev/null +++ b/crtp/etc/crtp.urm.puml @@ -0,0 +1,2 @@ +@startuml +@enduml \ No newline at end of file diff --git a/health-check/etc/health-check.urm.puml b/health-check/etc/health-check.urm.puml new file mode 100644 index 000000000..ebd0fa967 --- /dev/null +++ b/health-check/etc/health-check.urm.puml @@ -0,0 +1,124 @@ +@startuml +package com.iluwatar.health.check { + class App { + + App() + + main(args : String[]) {static} + } + class AsynchronousHealthChecker { + - HEALTH_CHECK_FAILED_MESSAGE : String {static} + - HEALTH_CHECK_TIMEOUT_MESSAGE : String {static} + - LOGGER : Logger {static} + - healthCheckExecutor : ScheduledExecutorService + + AsynchronousHealthChecker() + - awaitTerminationWithTimeout() : boolean + + performCheck(healthCheck : Supplier, timeoutInSeconds : long) : CompletableFuture + + shutdown() + } + class CpuHealthIndicator { + - ERROR_MESSAGE : String {static} + - HIGH_LOAD_AVERAGE_MESSAGE : String {static} + - HIGH_LOAD_AVERAGE_MESSAGE_WITHOUT_PARAM : String {static} + - HIGH_PROCESS_CPU_LOAD_MESSAGE : String {static} + - HIGH_PROCESS_CPU_LOAD_MESSAGE_WITHOUT_PARAM : String {static} + - HIGH_SYSTEM_CPU_LOAD_MESSAGE : String {static} + - HIGH_SYSTEM_CPU_LOAD_MESSAGE_WITHOUT_PARAM : String {static} + - LOGGER : Logger {static} + - defaultWarningMessage : String + - loadAverageThreshold : double + - osBean : OperatingSystemMXBean + - processCpuLoadThreshold : double + - systemCpuLoadThreshold : double + + CpuHealthIndicator() + + getDefaultWarningMessage() : String + + getLoadAverageThreshold() : double + + getOsBean() : OperatingSystemMXBean + + getProcessCpuLoadThreshold() : double + + getSystemCpuLoadThreshold() : double + + health() : Health + + init() + + setDefaultWarningMessage(defaultWarningMessage : String) + + setLoadAverageThreshold(loadAverageThreshold : double) + + setOsBean(osBean : OperatingSystemMXBean) + + setProcessCpuLoadThreshold(processCpuLoadThreshold : double) + + setSystemCpuLoadThreshold(systemCpuLoadThreshold : double) + } + class CustomHealthIndicator { + - LOGGER : Logger {static} + - cacheManager : CacheManager + - healthCheckRepository : HealthCheckRepository + - healthChecker : AsynchronousHealthChecker + - timeoutInSeconds : long + + CustomHealthIndicator(healthChecker : AsynchronousHealthChecker, cacheManager : CacheManager, healthCheckRepository : HealthCheckRepository) + - check() : Health + + evictHealthCache() + + health() : Health + } + class DatabaseTransactionHealthIndicator { + - LOGGER : Logger {static} + - asynchronousHealthChecker : AsynchronousHealthChecker + - healthCheckRepository : HealthCheckRepository + - retryTemplate : RetryTemplate + - timeoutInSeconds : long + + DatabaseTransactionHealthIndicator(healthCheckRepository : HealthCheckRepository, asynchronousHealthChecker : AsynchronousHealthChecker, retryTemplate : RetryTemplate) + + getAsynchronousHealthChecker() : AsynchronousHealthChecker + + getHealthCheckRepository() : HealthCheckRepository + + getRetryTemplate() : RetryTemplate + + getTimeoutInSeconds() : long + + health() : Health + + setTimeoutInSeconds(timeoutInSeconds : long) + } + class GarbageCollectionHealthIndicator { + - LOGGER : Logger {static} + - memoryUsageThreshold : double + + GarbageCollectionHealthIndicator() + - addMemoryPoolDetails(collectorDetails : Map, memoryPoolMxBeans : List, memoryPoolNamesList : List) + - createCollectorDetails(gcBean : GarbageCollectorMXBean, memoryPoolMxBeans : List) : Map + # getGarbageCollectorMxBeans() : List + # getMemoryPoolMxBeans() : List + + getMemoryUsageThreshold() : double + + health() : Health + + setMemoryUsageThreshold(memoryUsageThreshold : double) + } + class HealthCheck { + - id : Integer + - status : String + + HealthCheck() + # canEqual(other : Object) : boolean + + equals(o : Object) : boolean + + getId() : Integer + + getStatus() : String + + hashCode() : int + + setId(id : Integer) + + setStatus(status : String) + + toString() : String + } + class HealthCheckRepository { + - HEALTH_CHECK_OK : String {static} + - LOGGER : Logger {static} + - entityManager : EntityManager + + HealthCheckRepository() + + checkHealth() : Integer + + performTestTransaction() + } + class MemoryHealthIndicator { + - LOGGER : Logger {static} + - asynchronousHealthChecker : AsynchronousHealthChecker + - memoryThreshold : double + - timeoutInSeconds : long + + MemoryHealthIndicator(asynchronousHealthChecker : AsynchronousHealthChecker) + + checkMemory() : Health + + health() : Health + } + class RetryConfig { + - backOffPeriod : long + - maxAttempts : int + + RetryConfig() + + retryTemplate() : RetryTemplate + } +} +DatabaseTransactionHealthIndicator --> "-asynchronousHealthChecker" AsynchronousHealthChecker +DatabaseTransactionHealthIndicator --> "-healthCheckRepository" HealthCheckRepository +CustomHealthIndicator --> "-healthCheckRepository" HealthCheckRepository +CustomHealthIndicator --> "-healthChecker" AsynchronousHealthChecker +MemoryHealthIndicator --> "-asynchronousHealthChecker" AsynchronousHealthChecker +@enduml \ No newline at end of file diff --git a/log-aggregation/etc/log-aggregation.urm.puml b/log-aggregation/etc/log-aggregation.urm.puml new file mode 100644 index 000000000..1d4551ed0 --- /dev/null +++ b/log-aggregation/etc/log-aggregation.urm.puml @@ -0,0 +1,68 @@ +@startuml +package com.iluwatar.logaggregation { + class App { + + App() + + main(args : String[]) {static} + } + class CentralLogStore { + - LOGGER : Logger {static} + - logs : ConcurrentLinkedQueue + + CentralLogStore() + + displayLogs() + + storeLog(logEntry : LogEntry) + } + class LogAggregator { + - BUFFER_THRESHOLD : int {static} + - LOGGER : Logger {static} + - buffer : ConcurrentLinkedQueue + - centralLogStore : CentralLogStore + - executorService : ExecutorService + - logCount : AtomicInteger + - minLogLevel : LogLevel + + LogAggregator(centralLogStore : CentralLogStore, minLogLevel : LogLevel) + + collectLog(logEntry : LogEntry) + - flushBuffer() + - startBufferFlusher() + + stop() + } + class LogEntry { + - level : LogLevel + - message : String + - serviceName : String + - timestamp : LocalDateTime + + LogEntry(serviceName : String, level : LogLevel, message : String, timestamp : LocalDateTime) + # canEqual(other : Object) : boolean + + equals(o : Object) : boolean + + getLevel() : LogLevel + + getMessage() : String + + getServiceName() : String + + getTimestamp() : LocalDateTime + + hashCode() : int + + setLevel(level : LogLevel) + + setMessage(message : String) + + setServiceName(serviceName : String) + + setTimestamp(timestamp : LocalDateTime) + + toString() : String + } + enum LogLevel { + + DEBUG {static} + + ERROR {static} + + INFO {static} + + valueOf(name : String) : LogLevel {static} + + values() : LogLevel[] {static} + } + class LogProducer { + - LOGGER : Logger {static} + - aggregator : LogAggregator + - serviceName : String + + LogProducer(serviceName : String, aggregator : LogAggregator) + + generateLog(level : LogLevel, message : String) + } +} +LogAggregator --> "-centralLogStore" CentralLogStore +LogEntry --> "-level" LogLevel +CentralLogStore --> "-logs" LogEntry +LogAggregator --> "-buffer" LogEntry +LogAggregator --> "-minLogLevel" LogLevel +LogProducer --> "-aggregator" LogAggregator +@enduml \ No newline at end of file diff --git a/model-view-viewmodel/pom.xml b/model-view-viewmodel/pom.xml index 992b5247e..09e85b558 100644 --- a/model-view-viewmodel/pom.xml +++ b/model-view-viewmodel/pom.xml @@ -32,7 +32,6 @@ com.iluwatar 1.26.0-SNAPSHOT - com.iluwatar model-view-viewmodel 1.26.0-SNAPSHOT diff --git a/optimistic-offline-lock/etc/optimistic-offline-lock.urm.puml b/optimistic-offline-lock/etc/optimistic-offline-lock.urm.puml new file mode 100644 index 000000000..d2e861ad8 --- /dev/null +++ b/optimistic-offline-lock/etc/optimistic-offline-lock.urm.puml @@ -0,0 +1,59 @@ +@startuml +package com.iluwatar.repository { + interface JpaRepository { + + findById(long) : T {abstract} + + getEntityVersionById(long) : int {abstract} + + update(T) : int {abstract} + } +} +package com.iluwatar.api { + interface UpdateService { + + doUpdate(T, long) : T {abstract} + } +} +package com.iluwatar.service { + class CardUpdateService { + - cardJpaRepository : JpaRepository + + CardUpdateService(cardJpaRepository : JpaRepository) + + doUpdate(obj : Card, id : long) : Card + } +} +package com.iluwatar.model { + class Card { + - id : long + - personId : long + - sum : float + - version : int + + Card() + + Card(id : long, personId : long, sum : float, version : int) + + builder() : CardBuilder {static} + # canEqual(other : Object) : boolean + + equals(o : Object) : boolean + + getId() : long + + getPersonId() : long + + getSum() : float + + getVersion() : int + + hashCode() : int + + setId(id : long) + + setPersonId(personId : long) + + setSum(sum : float) + + setVersion(version : int) + + toString() : String + } + class CardBuilder { + - id : long + - personId : long + - sum : float + - version : int + ~ CardBuilder() + + build() : Card + + id(id : long) : CardBuilder + + personId(personId : long) : CardBuilder + + sum(sum : float) : CardBuilder + + toString() : String + + version(version : int) : CardBuilder + } +} +CardUpdateService --> "-cardJpaRepository" JpaRepository +CardUpdateService ..|> UpdateService +@enduml \ No newline at end of file diff --git a/slob/etc/slob.urm.puml b/slob/etc/slob.urm.puml new file mode 100644 index 000000000..3e0c4c2e3 --- /dev/null +++ b/slob/etc/slob.urm.puml @@ -0,0 +1,122 @@ +@startuml +package com.iluwatar.slob.lob { + class Animal { + - animalsEaten : Set + - name : String + - plantsEaten : Set + + Animal() + + Animal(name : String, plantsEaten : Set, animalsEaten : Set) + # canEqual(other : Object) : boolean + + createObjectFromXml(node : Node) + + equals(o : Object) : boolean + + getAnimalsEaten() : Set + + getName() : String + + getPlantsEaten() : Set + + hashCode() : int + # iterateXmlForAnimalAndPlants(childNodes : NodeList, animalsEaten : Set, plantsEaten : Set) {static} + + setAnimalsEaten(animalsEaten : Set) + + setName(name : String) + + setPlantsEaten(plantsEaten : Set) + + toString() : String + + toXmlElement(xmlDoc : Document) : Element + } + class Forest { + - animals : Set + - name : String + - plants : Set + + Forest() + + Forest(name : String, animals : Set, plants : Set) + # canEqual(other : Object) : boolean + + createObjectFromXml(document : Document) + + equals(o : Object) : boolean + + getAnimals() : Set + + getName() : String + + getPlants() : Set + - getXmlDoc() : Document + + hashCode() : int + + setAnimals(animals : Set) + + setName(name : String) + + setPlants(plants : Set) + + toString() : String + + toXmlElement() : Element + } + class Plant { + - name : String + - type : String + + Plant() + + Plant(name : String, type : String) + # canEqual(other : Object) : boolean + + createObjectFromXml(node : Node) + + equals(o : Object) : boolean + + getName() : String + + getType() : String + + hashCode() : int + + setName(name : String) + + setType(type : String) + + toString() : String + + toXmlElement(xmlDoc : Document) : Element + } +} +package com.iluwatar.slob.serializers { + class BlobSerializer { + + TYPE_OF_DATA_FOR_DB : String {static} + + BlobSerializer() + + deSerialize(toDeserialize : Object) : Forest + + serialize(toSerialize : Forest) : Object + } + class ClobSerializer { + + TYPE_OF_DATA_FOR_DB : String {static} + + ClobSerializer() + + deSerialize(toDeserialize : Object) : Forest + - elementToXmlString(node : Element) : String {static} + + serialize(forest : Forest) : Object + } + abstract class LobSerializer { + - databaseService : DatabaseService + # LobSerializer(dataTypeDb : String) + + close() + + deSerialize(Object) : Forest {abstract} + + loadFromDb(id : int, columnName : String) : Object + + persistToDb(id : int, name : String, object : Object) : int + + serialize(Forest) : Object {abstract} + } +} +package com.iluwatar.slob.dbservice { + class DatabaseService { + + BINARY_DATA : String {static} + + CREATE_BINARY_SCHEMA_DDL : String {static} + + CREATE_TEXT_SCHEMA_DDL : String {static} + - DB_URL : String {static} + + DELETE_SCHEMA_SQL : String {static} + - INSERT : String {static} + - LOGGER : Logger {static} + - SELECT : String {static} + - dataSource : DataSource {static} + + dataTypeDb : String + + DatabaseService(dataTypeDb : String) + - createDataSource() : DataSource {static} + + insert(id : int, name : String, data : Object) + + select(id : long, columnsName : String) : Object + + shutDownService() + + startupService() + } +} +package com.iluwatar.slob { + class App { + + CLOB : String {static} + - LOGGER : Logger {static} + + App() + - createForest() : Forest {static} + - createLobSerializer(args : String[]) : LobSerializer {static} + - executeSerializer(forest : Forest, lobSerializer : LobSerializer) {static} + + main(args : String[]) {static} + } +} +Animal --> "-plantsEaten" Plant +LobSerializer --> "-databaseService" DatabaseService +Forest --> "-animals" Animal +Forest --> "-plants" Plant +Animal --> "-animalsEaten" Animal +BlobSerializer --|> LobSerializer +ClobSerializer --|> LobSerializer +@enduml \ No newline at end of file diff --git a/slob/pom.xml b/slob/pom.xml index 5f95d4c1b..a53a6f4c4 100644 --- a/slob/pom.xml +++ b/slob/pom.xml @@ -68,11 +68,6 @@ com.h2database 2.2.220 - - lombok - org.projectlombok - provided - diff --git a/thread-local-storage/etc/thread-local-storage.urm.puml b/thread-local-storage/etc/thread-local-storage.urm.puml new file mode 100644 index 000000000..f6e682a01 --- /dev/null +++ b/thread-local-storage/etc/thread-local-storage.urm.puml @@ -0,0 +1,29 @@ +@startuml +package com.iluwatar { + abstract class AbstractThreadLocalExample { + - RANDOM_THREAD_PARK_END : Integer {static} + - RANDOM_THREAD_PARK_START : Integer {static} + - RND : SecureRandom {static} + + AbstractThreadLocalExample() + - getThreadName() : String + # getter() : Supplier {abstract} + + run() + # setter() : Consumer {abstract} + } + class WithThreadLocal { + - value : ThreadLocal + + WithThreadLocal(value : ThreadLocal) + # getter() : Supplier + + remove() + # setter() : Consumer + } + class WithoutThreadLocal { + - value : Integer + + WithoutThreadLocal(value : Integer) + # getter() : Supplier + # setter() : Consumer + } +} +WithThreadLocal --|> AbstractThreadLocalExample +WithoutThreadLocal --|> AbstractThreadLocalExample +@enduml \ No newline at end of file