Compare commits

..

93 Commits

Author SHA1 Message Date
0c48695fa5 Achieved milestone 1.14.0 2016-12-31 10:23:32 +02:00
8d34ccf827 Add link to Proxy presentation. 2016-12-26 20:16:30 +02:00
512a5c0560 Merge branch 'proxy-presentation' 2016-12-26 20:08:41 +02:00
9cf1918425 Add presentation for Proxy pattern. 2016-12-26 20:05:38 +02:00
5e57cd03d1 Add some material for proxy presentation. 2016-12-26 19:43:46 +02:00
ad93184a79 Merge pull request #530 from Valdar-Soft/master
Sonar quality bugfix and minor refactor
2016-12-24 12:36:11 +02:00
95f2c19780 Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.
2016-12-18 16:08:59 +01:00
120033b58b Sonar bug fixes using Yoda condition in equals expression when comparing String literal with String object.
Using try-with-resources if we use Scanner to close the underlying stream is a good practice to handle resources.
Minimal refactor.
2016-12-18 16:04:13 +01:00
c94c8a3e74 Merge pull request #512 from inbravo/master
Module pattern #62
2016-12-01 20:53:12 +02:00
5d8806858b Review comments++ 2016-12-01 16:29:35 +05:30
efc2c887e9 Merge pull request #521 from Amarnath510/master
Issue #450. First commit. Queue Based Load Leveling
2016-11-28 19:04:31 +02:00
1d6d0c54a7 pom.xml Fixed Conflict 2016-11-28 20:33:45 +05:30
1387e2bc96 Fixed all the code changes after review 2016-11-28 20:13:18 +05:30
faa29f8025 Update license headers 2016-11-27 14:34:20 +02:00
89e7f51e99 Merge pull request #519 from iluwatar/presentation
Add hexagonal architecture presentation
2016-11-27 13:50:04 +02:00
cc02ff472b Merge pull request #503 from igeligel/master
Object Mother pattern #498
2016-11-26 20:22:48 +02:00
7d995056ff Update URM Version to 1.4.4 and regenerated all puml files 2016-11-26 12:51:06 +01:00
8574e06966 Proxy pattern: Add missing license header 2016-11-23 22:08:50 +02:00
82d3d7bf1f Proxy pattern: Improve the example 2016-11-23 22:03:26 +02:00
1a75ab8df1 Removed unused imports in tests 2016-11-23 09:00:04 +05:30
92f8501f7d Decorator pattern: Improve the example 2016-11-22 23:08:39 +02:00
b9ac0dc6a3 Fixed PMD issue. 2016-11-23 00:10:30 +05:30
5e7887d9be Reverted pom.xml changes that are done previously. 2016-11-22 12:21:24 +05:30
e8f7187e4b Updated pom.xml with maven-pmd-plugin
Added dependency "maven-pmd-plugin" to the pom file.
2016-11-22 12:06:54 +05:30
d6b5456f98 Updated checkstyle errors. 2016-11-20 23:36:23 +05:30
52a81eb368 Issue #450. Updated pom.xml 2016-11-20 21:55:56 +05:30
12b70cb39c Issue #450. First commit. Queue Based Load Leveling 2016-11-20 16:25:10 +05:30
68ec24c62e Merge pull request #515 from dbryla/master
#502 Added logging framework to repository
2016-11-18 20:47:17 +02:00
3091ff21b0 #502 Reduced amount of information logged 2016-11-17 09:54:10 +01:00
95b651f177 Merge pull request #520 from thomasoss/patch-1
Update App.java
2016-11-15 21:31:34 +02:00
f67d2fd9a9 Review comments++ 2016-11-15 13:01:37 +05:30
4ff8fa3721 Review comments++ 2016-11-15 12:59:05 +05:30
9180bb0fef Update App.java
The relationship between decorator and target (in the code example between Troll und SmartTroll) ist not a composition as described in the code comment lines of class App. It's a aggregation. In a composition both instances canncot live without the other one. But the target (Troll) could live without the decorator (Smart Troll). Changed "composition" to "aggregation" in the comment lines. Code lines are unchanged.
Greetings Thomas
2016-11-14 16:43:58 +01:00
1abf5b11c3 Add presentation link to README.md 2016-11-13 11:37:49 +02:00
22d973c460 Merge branch 'master' into presentation 2016-11-13 11:34:14 +02:00
c850295aab Add new diagram 2016-11-13 11:23:22 +02:00
4c24d99414 Work on Hexagonal Architecture presentation 2016-11-12 22:44:08 +02:00
e1ae1067db Link Hexagonal Architecture pattern to corresponding blog entry 2016-11-06 12:26:03 +02:00
6f3e2985a4 Create presentation template 2016-11-06 12:14:39 +02:00
b37190a214 #502 Introduced logging in new example 2016-11-04 12:19:32 +01:00
0a427710bb Merge branch 'master' of https://github.com/iluwatar/java-design-patterns
* 'master' of https://github.com/iluwatar/java-design-patterns: (27 commits)
  Remove use of coveralls-maven-plugin (sonarqube.com covers this)
  Add SonarQube.com badge
  Fix environment variable
  Add Travis instructions for SonarQube.com analysis
  Adds more criticism to Singleton pattern.
  Event Based Asynchronous pattern: Add missing license header and puml diagram
  Changed config to non-interactive
  Moved config into a separate dir
  Unused import removed.
  End process logic clause has been corrected.
  Caching pattern: Documentation and diagram
  Fixes #437. Adds criticism to Singleton pattern.
  Alter JUnit tests to run in lesser time.
  Updated version snapshot to 1.14.0
  Changes based on review feedback.
  Closes #436. Adds criticism to service locator pattern.
  Caching pattern: Implementation of Cache-Aside pattern
  Caching pattern: Style fix for null check
  Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cache lookup
  Caching pattern: Refactor shutdown hook to use method reference
  ...
2016-11-04 11:51:45 +01:00
e138163c4f #502 Adjusted tests for logger introduction 2016-11-04 11:47:06 +01:00
124fd33da0 Remove use of coveralls-maven-plugin (sonarqube.com covers this) 2016-11-01 21:31:54 +02:00
9433c78d29 Merge pull request #510 from bellingard/patch-1
Add SonarQube.com badge
2016-10-28 20:39:55 +03:00
932700d9b1 Merge pull request #506 from dzmitryh/master
Cosmetic fixes in async-method-invocation
2016-10-28 19:13:17 +03:00
27d6d500bc #502 Reverted changes in composite example, due to nature of this example using logger isn't good idea 2016-10-28 09:35:59 +02:00
ea7752c5e1 checkstyle errors removed
checkstyle errors removed
2016-10-27 18:30:07 +05:30
7ba6cb43fd App
App
2016-10-27 16:00:01 +05:30
1ace4c05d6 App++
App++
2016-10-27 15:59:51 +05:30
7015e95ac3 SecondCut++
SecondCut++
2016-10-27 15:55:08 +05:30
2a77ac29e9 FirstCut++
FirstCut++
2016-10-26 16:59:36 +05:30
6aed26e61e Fix pom.xml
Deleted </modules> tag because i added it one time more than neccessary
2016-10-24 15:43:52 +02:00
74ac79b01e Fix pom.xml 2016-10-24 15:33:25 +02:00
750fa4f954 Merge Changes of the master repository 2016-10-24 15:32:32 +02:00
20295316c2 add entry to parent pom.xml #498 2016-10-24 15:30:17 +02:00
56b0884258 Change name of variables in test #498 2016-10-24 15:28:27 +02:00
0438811489 #502 Replaced usages of System.out with logger. 2016-10-23 19:59:03 +02:00
1c02785927 Add SonarQube.com badge 2016-10-23 14:35:45 +02:00
19cb715d20 Fix environment variable 2016-10-19 23:08:51 +03:00
ffdaf2ec47 Add Travis instructions for SonarQube.com analysis 2016-10-19 22:25:37 +03:00
a37a29e12b Merge pull request #500 from dmitraver/master
Adds criticism to a Service Locator and Singleton patterns.
2016-10-18 21:01:58 +03:00
b66e8ecef9 Adds more criticism to Singleton pattern. 2016-10-18 14:18:47 +02:00
99677867c6 Event Based Asynchronous pattern: Add missing license header and puml diagram 2016-10-18 07:51:37 +03:00
0f7b44c3b1 Merge pull request #483 from waisuan/master
Issue #469: Event-based Asynchronous pattern
2016-10-18 07:43:01 +03:00
70318123fe Changed config to non-interactive 2016-10-17 22:22:06 +01:00
986c529eb6 Moved config into a separate dir 2016-10-17 21:29:03 +01:00
64bdab46b9 Merge pull request #495 from christofferh/feat/cache-aside
Caching pattern: Cache-Aside
2016-10-17 22:49:16 +03:00
37b930c3b7 Unused import removed. 2016-10-15 14:29:32 +03:00
85060784a7 End process logic clause has been corrected. 2016-10-15 14:27:15 +03:00
f114b5b957 Caching pattern: Documentation and diagram 2016-10-09 12:43:43 +02:00
863ea75381 Add PlantUML file for the UML diagram #498 2016-10-06 20:12:43 +02:00
3a9d1684fd Initial commit of the object mother #498
Add a simple king and queen classes which implement the behaviour of the
royalty interface. Also wrote the object mother of royalty objects which
is final so you can just call the static methods in it to create objects
with a specific state to use them fast in tests. The tests are already
created for testing the behaviour and the type of the objects which are
created by the object mother.
I also created the UML diagrams via object aid and updated the readme.
2016-10-04 22:33:06 +02:00
eea8785a22 Fixes #437. Adds criticism to Singleton pattern. 2016-10-04 14:34:01 +02:00
8f1758c28f Alter JUnit tests to run in lesser time. 2016-10-03 21:46:16 +01:00
622376e0fa Updated version snapshot to 1.14.0 2016-10-03 21:16:23 +01:00
5eacf522a2 Merge remote-tracking branch 'upstream/master' 2016-10-03 21:05:31 +01:00
12544caa75 Changes based on review feedback. 2016-10-03 21:05:11 +01:00
9512f3ec70 Closes #436. Adds criticism to service locator pattern. 2016-10-03 21:59:36 +02:00
4ca205c03c Set version number for next development iteration 2016-09-30 19:40:28 +03:00
b31edda3cf Caching pattern: Implementation of Cache-Aside pattern 2016-09-22 20:41:26 +02:00
e3355d76d1 Caching pattern: Style fix for null check 2016-09-22 20:36:02 +02:00
865f788612 Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cache lookup 2016-09-22 20:35:44 +02:00
6ed842e58b Caching pattern: Refactor shutdown hook to use method reference 2016-09-22 20:34:46 +02:00
69cab15d75 Merge remote-tracking branch 'upstream/master' 2016-09-19 21:50:54 +01:00
371b262a51 Changes based on latest code review 2016-09-19 21:50:23 +01:00
dbd605e378 Changes based on latest code review 2016-09-19 21:50:04 +01:00
f2159515bc Merge remote-tracking branch 'upstream/master' 2016-09-11 20:33:51 +01:00
9a90f2de1f Changes based on code review 2016-09-11 18:45:51 +01:00
fce30db803 Updating fork branch 2016-09-11 16:24:16 +01:00
233f1e69f9 Removed PUBLIC modifiers from IEvent 2016-09-03 11:32:31 +01:00
f11597136f Fixed Checkstyle errors. 2016-09-03 11:32:29 +01:00
e1836fee2f Updated parent POM to include new pattern (Event-asynchronous) 2016-09-03 11:32:28 +01:00
2d99061902 Issue #469: Implementation of Event-based Asynchronous pattern 2016-09-03 11:32:25 +01:00
1138 changed files with 9794 additions and 5682 deletions

30
.gitignore vendored
View File

@ -1,19 +1,19 @@
target
.metadata
.settings
.classpath
.project
*.class
# Package Files #
*.jar
*.war
*.ear
.idea
*.iml
*.swp
target
.metadata
.settings
.classpath
.project
*.class
# Package Files #
*.jar
*.war
*.ear
.idea
*.iml
*.swp
datanucleus.log
/bin/
/bin/
/bin/
data-mapper/src/main/resources/log4j.xml
*.log
data-mapper/src/main/resources/log4j.xml

View File

@ -6,6 +6,7 @@ env:
global:
- GH_REF: github.com/iluwatar/java-design-patterns.git
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="
before_install:
- export DISPLAY=:99.0
@ -16,7 +17,7 @@ install:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
after_success:
- mvn clean test jacoco:report coveralls:report
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
- bash update-ghpages.sh
# use latest java version available instead of travis default

View File

@ -5,9 +5,9 @@
# Design patterns implemented in Java
[![Build status](https://travis-ci.org/iluwatar/java-design-patterns.svg?branch=master)](https://travis-ci.org/iluwatar/java-design-patterns)
[![Coverage Status](https://coveralls.io/repos/iluwatar/java-design-patterns/badge.svg?branch=master)](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Quality Gate](https://sonarqube.com/api/badges/gate?key=com.iluwatar%3Ajava-design-patterns)](https://sonarqube.com/dashboard/index/com.iluwatar%3Ajava-design-patterns)
# Introduction

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,33 +1,29 @@
@startuml
package com.iluwatar.abstractdocument.domain {
class Part {
+ Part(properties : Map<String, Object>)
}
interface HasPrice {
+ PROPERTY : String {static}
+ getPrice() : Optional<Number>
}
interface HasParts {
+ PROPERTY : String {static}
+ getParts() : Stream<Part>
}
class Car {
+ Car(properties : Map<String, Object>)
}
interface HasType {
+ PROPERTY : String {static}
+ getType() : Optional<String>
}
interface HasModel {
+ PROPERTY : String {static}
+ getModel() : Optional<String>
}
interface HasParts {
+ PROPERTY : String {static}
+ getParts() : Stream<Part>
}
interface HasPrice {
+ PROPERTY : String {static}
+ getPrice() : Optional<Number>
}
interface HasType {
+ PROPERTY : String {static}
+ getType() : Optional<String>
}
class Part {
+ Part(properties : Map<String, Object>)
}
}
package com.iluwatar.abstractdocument {
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class AbstractDocument {
- properties : Map<String, Object>
# AbstractDocument(properties : Map<String, Object>)
@ -36,24 +32,28 @@ package com.iluwatar.abstractdocument {
+ put(key : String, value : Object)
+ toString() : String
}
class App {
- LOGGER : Logger {static}
+ App()
+ main(args : String[]) {static}
}
interface Document {
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
+ get(String) : Object {abstract}
+ put(String, Object) {abstract}
}
}
AbstractDocument --+ Map
Part ..|> HasType
Part ..|> HasModel
Part ..|> HasPrice
Part --|> AbstractDocument
AbstractDocument ..|> Document
HasPrice --|> Document
HasParts --|> Document
Car ..|> HasModel
Car ..|> HasPrice
Car ..|> HasParts
Car --|> AbstractDocument
HasType --|> Document
HasModel --|> Document
HasParts --|> Document
HasPrice --|> Document
HasType --|> Document
Part ..|> HasType
Part ..|> HasModel
Part ..|> HasPrice
Part --|> AbstractDocument
@enduml

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -27,6 +27,8 @@ import com.iluwatar.abstractdocument.domain.HasModel;
import com.iluwatar.abstractdocument.domain.HasParts;
import com.iluwatar.abstractdocument.domain.HasPrice;
import com.iluwatar.abstractdocument.domain.HasType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
@ -44,11 +46,13 @@ import java.util.Map;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Executes the App
*/
public App() {
System.out.println("Constructing parts and car");
LOGGER.info("Constructing parts and car");
Map<String, Object> carProperties = new HashMap<>();
carProperties.put(HasModel.PROPERTY, "300SL");
@ -68,12 +72,11 @@ public class App {
Car car = new Car(carProperties);
System.out.println("Here is our car:");
System.out.println("-> model: " + car.getModel().get());
System.out.println("-> price: " + car.getPrice().get());
System.out.println("-> parts: ");
car.getParts().forEach(p -> System.out
.println("\t" + p.getType().get() + "/" + p.getModel().get() + "/" + p.getPrice().get()));
LOGGER.info("Here is our car:");
LOGGER.info("-> model: {}", car.getModel().get());
LOGGER.info("-> price: {}", car.getPrice().get());
LOGGER.info("-> parts: ");
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
}
/**

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,7 @@
@startuml
package com.iluwatar.abstractfactory {
class App {
- LOGGER : Logger {static}
- army : Army
- castle : Castle
- king : King
@ -17,58 +18,58 @@ package com.iluwatar.abstractfactory {
- setCastle(castle : Castle)
- setKing(king : King)
}
class OrcKingdomFactory {
+ OrcKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
interface Army {
+ getDescription() : String {abstract}
}
interface Castle {
+ getDescription() : String {abstract}
}
class ElfArmy {
~ DESCRIPTION : String {static}
+ ElfArmy()
+ getDescription() : String
}
class ElfCastle {
~ DESCRIPTION : String {static}
+ ElfCastle()
+ getDescription() : String
}
class ElfKing {
~ DESCRIPTION : String {static}
+ ElfKing()
+ getDescription() : String
}
class ElfKingdomFactory {
+ ElfKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
}
interface King {
+ getDescription() : String {abstract}
}
interface KingdomFactory {
+ createArmy() : Army {abstract}
+ createCastle() : Castle {abstract}
+ createKing() : King {abstract}
}
class OrcArmy {
~ DESCRIPTION : String {static}
+ OrcArmy()
+ getDescription() : String
}
class OrcCastle {
~ DESCRIPTION : String {static}
+ OrcCastle()
+ getDescription() : String
}
interface KingdomFactory {
+ createArmy() : Army {abstract}
+ createCastle() : Castle {abstract}
+ createKing() : King {abstract}
}
class ElfKing {
~ DESCRIPTION : String {static}
+ ElfKing()
+ getDescription() : String
}
class ElfArmy {
~ DESCRIPTION : String {static}
+ ElfArmy()
+ getDescription() : String
}
interface Castle {
+ getDescription() : String {abstract}
}
interface Army {
+ getDescription() : String {abstract}
}
class OrcKing {
~ DESCRIPTION : String {static}
+ OrcKing()
+ getDescription() : String
}
class OrcArmy {
~ DESCRIPTION : String {static}
+ OrcArmy()
+ getDescription() : String
}
interface King {
+ getDescription() : String {abstract}
}
class ElfKingdomFactory {
+ ElfKingdomFactory()
class OrcKingdomFactory {
+ OrcKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
@ -77,12 +78,12 @@ package com.iluwatar.abstractfactory {
App --> "-castle" Castle
App --> "-king" King
App --> "-army" Army
OrcKingdomFactory ..|> KingdomFactory
ElfCastle ..|> Castle
OrcCastle ..|> Castle
ElfKing ..|> King
ElfArmy ..|> Army
OrcKing ..|> King
OrcArmy ..|> Army
ElfCastle ..|> Castle
ElfKing ..|> King
ElfKingdomFactory ..|> KingdomFactory
OrcArmy ..|> Army
OrcCastle ..|> Castle
OrcKing ..|> King
OrcKingdomFactory ..|> KingdomFactory
@enduml

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -22,6 +22,9 @@
*/
package com.iluwatar.abstractfactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme
@ -39,6 +42,8 @@ package com.iluwatar.abstractfactory;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private King king;
private Castle castle;
private Army army;
@ -98,17 +103,17 @@ public class App {
App app = new App();
System.out.println("Elf Kingdom");
LOGGER.info("Elf Kingdom");
app.createKingdom(new ElfKingdomFactory());
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
System.out.println("\nOrc Kingdom");
LOGGER.info("Orc Kingdom");
app.createKingdom(new OrcKingdomFactory());
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
}

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,18 +1,19 @@
@startuml
package com.iluwatar.adapter {
interface BattleShip {
+ fire() {abstract}
+ move() {abstract}
class App {
+ App()
+ main(args : String[]) {static}
}
class BattleFishingBoat {
- LOGGER : Logger {static}
- boat : FishingBoat
+ BattleFishingBoat()
+ fire()
+ move()
}
class App {
+ App()
+ main(args : String[]) {static}
interface BattleShip {
+ fire() {abstract}
+ move() {abstract}
}
class Captain {
- battleship : BattleShip
@ -23,6 +24,7 @@ package com.iluwatar.adapter {
+ setBattleship(battleship : BattleShip)
}
class FishingBoat {
- LOGGER : Logger {static}
+ FishingBoat()
+ fish()
+ sail()

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -22,6 +22,9 @@
*/
package com.iluwatar.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link BattleShip}
@ -33,6 +36,8 @@ package com.iluwatar.adapter;
*/
public class BattleFishingBoat implements BattleShip {
private static final Logger LOGGER = LoggerFactory.getLogger(BattleFishingBoat.class);
private FishingBoat boat;
public BattleFishingBoat() {
@ -41,7 +46,7 @@ public class BattleFishingBoat implements BattleShip {
@Override
public void fire() {
System.out.println("fire!");
LOGGER.info("fire!");
}
@Override

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -22,6 +22,9 @@
*/
package com.iluwatar.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Device class (adaptee in the pattern). We want to reuse this class
@ -29,12 +32,14 @@ package com.iluwatar.adapter;
*/
public class FishingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
public void sail() {
System.out.println("The Boat is moving to that place");
LOGGER.info("The Boat is moving to that place");
}
public void fish() {
System.out.println("fishing ...");
LOGGER.info("fishing ...");
}
}

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -27,6 +27,8 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
@ -37,6 +39,8 @@ import java.io.IOException;
@Component
public class ProductInformationClientImpl implements ProductInformationClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
@Override
public String getProductTitle() {
String response = null;
@ -46,7 +50,7 @@ public class ProductInformationClientImpl implements ProductInformationClient {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("Exception caught.", e);
}
return response;
}

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -27,6 +27,8 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
@ -37,6 +39,8 @@ import java.io.IOException;
@Component
public class ProductInventoryClientImpl implements ProductInventoryClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
@Override
public int getProductInventories() {
String response = "0";
@ -46,7 +50,7 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("Exception caught.", e);
}
return Integer.parseInt(response);
}

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,16 +1,15 @@
@startuml
package com.iluwatar.aggregator.microservices {
class ProductInventoryClientImpl {
+ ProductInventoryClientImpl()
+ getProductInventories() : int
class Aggregator {
- informationClient : ProductInformationClient
- inventoryClient : ProductInventoryClient
+ Aggregator()
+ getProduct() : Product
}
class App {
+ App()
+ main(args : String[]) {static}
}
interface ProductInventoryClient {
+ getProductInventories() : int {abstract}
}
class Product {
- productInventories : int
- title : String
@ -20,22 +19,25 @@ package com.iluwatar.aggregator.microservices {
+ setProductInventories(productInventories : int)
+ setTitle(title : String)
}
class Aggregator {
- informationClient : ProductInformationClient
- inventoryClient : ProductInventoryClient
+ Aggregator()
+ getProduct() : Product
}
class ProductInformationClientImpl {
+ ProductInformationClientImpl()
+ getProductTitle() : String
}
interface ProductInformationClient {
+ getProductTitle() : String {abstract}
}
class ProductInformationClientImpl {
- LOGGER : Logger {static}
+ ProductInformationClientImpl()
+ getProductTitle() : String
}
interface ProductInventoryClient {
+ getProductInventories() : int {abstract}
}
class ProductInventoryClientImpl {
- LOGGER : Logger {static}
+ ProductInventoryClientImpl()
+ getProductInventories() : int
}
}
Aggregator --> "-inventoryClient" ProductInventoryClient
Aggregator --> "-informationClient" ProductInformationClient
ProductInventoryClientImpl ..|> ProductInventoryClient
Aggregator --> "-inventoryClient" ProductInventoryClient
ProductInformationClientImpl ..|> ProductInformationClient
ProductInventoryClientImpl ..|> ProductInventoryClient
@enduml

View File

@ -1,12 +1,12 @@
@startuml
package com.iluwatar.inventory.microservice {
class InventoryController {
+ InventoryController()
+ getProductInventories() : int
}
class InventoryApplication {
+ InventoryApplication()
+ main(args : String[]) {static}
}
class InventoryController {
+ InventoryController()
+ getProductInventories() : int
}
}
@enduml

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway-service</artifactId>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,12 +1,27 @@
@startuml
package com.iluwatar.api.gateway {
class ApiGateway {
- imageClient : ImageClient
- priceClient : PriceClient
+ ApiGateway()
+ getProductDesktop() : DesktopProduct
+ getProductMobile() : MobileProduct
}
class App {
+ App()
+ main(args : String[]) {static}
}
class PriceClientImpl {
+ PriceClientImpl()
class DesktopProduct {
- imagePath : String
- price : String
+ DesktopProduct()
+ getImagePath() : String
+ getPrice() : String
+ setImagePath(imagePath : String)
+ setPrice(price : String)
}
interface ImageClient {
+ getImagePath() : String {abstract}
}
class ImageClientImpl {
+ ImageClientImpl()
@ -18,31 +33,16 @@ package com.iluwatar.api.gateway {
+ getPrice() : String
+ setPrice(price : String)
}
interface ImageClient {
+ getImagePath() : String {abstract}
}
class ApiGateway {
- imageClient : ImageClient
- priceClient : PriceClient
+ ApiGateway()
+ getProductDesktop() : DesktopProduct
+ getProductMobile() : MobileProduct
}
class DesktopProduct {
- imagePath : String
- price : String
+ DesktopProduct()
+ getImagePath() : String
+ getPrice() : String
+ setImagePath(imagePath : String)
+ setPrice(price : String)
}
interface PriceClient {
+ getPrice() : String {abstract}
}
class PriceClientImpl {
+ PriceClientImpl()
+ getPrice() : String
}
}
ApiGateway --> "-imageClient" ImageClient
ApiGateway --> "-priceClient" PriceClient
PriceClientImpl ..|> PriceClient
ImageClientImpl ..|> ImageClient
PriceClientImpl ..|> PriceClient
@enduml

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway</artifactId>

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
#
# The MIT License
# Copyright (c) 2014 Ilkka Seppälä
# Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,22 +1,26 @@
@startuml
package com.iluwatar.async.method.invocation {
class App {
- LOGGER : Logger {static}
+ App()
- callback(name : String) : AsyncCallback<T> {static}
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
- log(msg : String) {static}
+ main(args : String[]) {static}
}
interface AsyncResult<T> {
+ await() {abstract}
+ getValue() : T {abstract}
+ isCompleted() : boolean {abstract}
interface AsyncCallback<T> {
+ onComplete(T, Optional<Exception>) {abstract}
}
interface AsyncExecutor {
+ endProcess(AsyncResult<T>) : T {abstract}
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
+ startProcess(Callable<T>, AsyncCallback<T>) : AsyncResult<T> {abstract}
}
interface AsyncResult<T> {
+ await() {abstract}
+ getValue() : T {abstract}
+ isCompleted() : boolean {abstract}
}
class ThreadAsyncExecutor {
- idx : AtomicInteger
+ ThreadAsyncExecutor()
@ -24,9 +28,6 @@ package com.iluwatar.async.method.invocation {
+ startProcess(task : Callable<T>) : AsyncResult<T>
+ startProcess(task : Callable<T>, callback : AsyncCallback<T>) : AsyncResult<T>
}
interface AsyncCallback<T> {
+ onComplete(T, Optional<Exception>) {abstract}
}
-class CompletableResult<T> {
~ COMPLETED : int {static}
~ FAILED : int {static}

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 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
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.14.0</version>
</parent>
<artifactId>async-method-invocation</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -22,6 +22,9 @@
*/
package com.iluwatar.async.method.invocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
/**
@ -54,6 +57,8 @@ import java.util.concurrent.Callable;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point
*/
@ -120,6 +125,6 @@ public class App {
}
private static void log(String msg) {
System.out.println(String.format("[%1$-10s] - %2$s", Thread.currentThread().getName(), msg));
LOGGER.info(msg);
}
}

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -57,12 +57,10 @@ public class ThreadAsyncExecutor implements AsyncExecutor {
@Override
public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException {
if (asyncResult.isCompleted()) {
return asyncResult.getValue();
} else {
if (!asyncResult.isCompleted()) {
asyncResult.await();
return asyncResult.getValue();
}
return asyncResult.getValue();
}
/**

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 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
@ -31,7 +31,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import static org.junit.Assert.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.internal.verification.VerificationModeFactory.times;

View File

@ -1,72 +1,9 @@
@startuml
package com.iluwatar.bridge {
class FlyingMagicWeapon {
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
+ fly()
+ getImp() : FlyingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
class Stormbringer {
+ Stormbringer()
+ eatSoulImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
abstract class FlyingMagicWeaponImpl {
+ FlyingMagicWeaponImpl()
+ flyImp() {abstract}
}
class SoulEatingMagicWeapon {
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
+ eatSoul()
+ getImp() : SoulEatingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
abstract class MagicWeaponImpl {
+ MagicWeaponImpl()
+ swingImp() {abstract}
+ unwieldImp() {abstract}
+ wieldImp() {abstract}
}
abstract class SoulEatingMagicWeaponImpl {
+ SoulEatingMagicWeaponImpl()
+ eatSoulImp() {abstract}
}
class Excalibur {
+ Excalibur()
+ blindImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
class Mjollnir {
+ Mjollnir()
+ flyImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
class App {
+ App()
+ main(args : String[]) {static}
}
abstract class MagicWeapon {
# imp : MagicWeaponImpl
+ MagicWeapon(imp : MagicWeaponImpl)
+ getImp() : MagicWeaponImpl
+ swing() {abstract}
+ unwield() {abstract}
+ wield() {abstract}
}
abstract class BlindingMagicWeaponImpl {
+ BlindingMagicWeaponImpl()
+ blindImp() {abstract}
}
class BlindingMagicWeapon {
+ BlindingMagicWeapon(imp : BlindingMagicWeaponImpl)
+ blind()
@ -75,15 +12,81 @@ package com.iluwatar.bridge {
+ unwield()
+ wield()
}
abstract class BlindingMagicWeaponImpl {
+ BlindingMagicWeaponImpl()
+ blindImp() {abstract}
}
class Excalibur {
- LOGGER : Logger {static}
+ Excalibur()
+ blindImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
class FlyingMagicWeapon {
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
+ fly()
+ getImp() : FlyingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
abstract class FlyingMagicWeaponImpl {
+ FlyingMagicWeaponImpl()
+ flyImp() {abstract}
}
abstract class MagicWeapon {
# imp : MagicWeaponImpl
+ MagicWeapon(imp : MagicWeaponImpl)
+ getImp() : MagicWeaponImpl
+ swing() {abstract}
+ unwield() {abstract}
+ wield() {abstract}
}
abstract class MagicWeaponImpl {
+ MagicWeaponImpl()
+ swingImp() {abstract}
+ unwieldImp() {abstract}
+ wieldImp() {abstract}
}
class Mjollnir {
- LOGGER : Logger {static}
+ Mjollnir()
+ flyImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
class SoulEatingMagicWeapon {
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
+ eatSoul()
+ getImp() : SoulEatingMagicWeaponImpl
+ swing()
+ unwield()
+ wield()
}
abstract class SoulEatingMagicWeaponImpl {
+ SoulEatingMagicWeaponImpl()
+ eatSoulImp() {abstract}
}
class Stormbringer {
- LOGGER : Logger {static}
+ Stormbringer()
+ eatSoulImp()
+ swingImp()
+ unwieldImp()
+ wieldImp()
}
}
MagicWeapon --> "-imp" MagicWeaponImpl
BlindingMagicWeapon --|> MagicWeapon
BlindingMagicWeaponImpl --|> MagicWeaponImpl
Excalibur --|> BlindingMagicWeaponImpl
FlyingMagicWeapon --|> MagicWeapon
Stormbringer --|> SoulEatingMagicWeaponImpl
FlyingMagicWeaponImpl --|> MagicWeaponImpl
Mjollnir --|> FlyingMagicWeaponImpl
SoulEatingMagicWeapon --|> MagicWeapon
SoulEatingMagicWeaponImpl --|> MagicWeaponImpl
Excalibur --|> BlindingMagicWeaponImpl
Mjollnir --|> FlyingMagicWeaponImpl
BlindingMagicWeaponImpl --|> MagicWeaponImpl
BlindingMagicWeapon --|> MagicWeapon
Stormbringer --|> SoulEatingMagicWeaponImpl
@enduml

Some files were not shown because too many files have changed in this diff Show More