Compare commits

..

571 Commits

Author SHA1 Message Date
8fea969912 Reached milestone 1.15.0 2017-04-01 17:14:02 +03:00
139876f96a #539 Checkstyle fix 2017-04-01 15:51:01 +03:00
f3c4640d12 #539 More Checkstyle fixes 2017-04-01 15:43:36 +03:00
c1c4411957 #539 Checkstyle fixes 2017-04-01 15:34:13 +03:00
3f272bf291 Merge pull request #548 from muditporwal/master
Checkstyle improvements #539 : Added JavaDocType Rule
2017-04-01 14:45:52 +03:00
2921448f8b #497 Add missing puml and license headers 2017-04-01 14:25:13 +03:00
952c207a62 Merge pull request #546 from Crossy147/converter
Converter
2017-04-01 14:17:37 +03:00
6ba4d7be98 #77 Add missing license header 2017-04-01 12:39:06 +03:00
854101bb49 Merge pull request #529 from thomasoss/master
Thread Local Storage issue #77
2017-04-01 12:29:03 +03:00
a5ab5c7d8e Merge branch 'master' into converter 2017-03-26 23:50:08 +02:00
286d6c3a4c Merge pull request #536 from Rzeposlaw/master
#66 Balking Pattern
2017-03-26 15:00:21 +03:00
c2a7b902a9 Work on #190: urm/puml updates
* added pumlid where it was missing and possible
* removed pumlid where it generated a bad image
* regenerated some incorrect puml's
* added 'left to right direction' puml prefix to some diagrams to improve the automatic layouting
2017-03-25 22:07:10 +01:00
09585c3874 Removed AvoidStarImport Rule
Added JavaDocType Rule
2017-03-22 01:16:02 +08:00
f84c4c1611 Update App.java
Correction of correction ;-)
2017-03-18 10:02:37 +01:00
2c2d874ac8 Update App.java
Correction of error detected by maven-pmd-plugin.
2017-03-18 10:00:13 +01:00
72a0765ec6 Merge branch 'master' into converter 2017-03-16 12:27:05 +01:00
cca4d5a670 Update after changes from review. Additional improvements. 2017-03-13 01:33:14 +01:00
bb4a1bdc05 Pom.xml files fixed. 2017-03-13 01:16:26 +01:00
1aed5905d7 #66 Balking Pattern 2017-03-13 01:15:39 +01:00
175e9f58c1 Merge pull request #537 from robertt240/master
guarded suspension pattern #69
2017-03-12 10:36:27 +02:00
77a534385c fixed pmd violation 2017-03-11 13:35:55 +01:00
2ed7acbc31 fixed checkstyle violations 2017-03-11 13:02:29 +01:00
3a243eee6e diagrams added 2017-03-11 12:47:58 +01:00
8632bafcd7 comments, tests and description 2017-03-11 12:24:48 +01:00
449aed1a53 changed parent POM version #69 2017-03-11 12:02:04 +01:00
a20abae21c apply changes from review #69 2017-03-11 11:50:19 +01:00
7423f47daa further POM rearragments #69 2017-03-11 11:50:19 +01:00
f09578c091 further POM rearragments #69 2017-03-11 11:50:19 +01:00
29715028d1 fix in POM formatting #69 2017-03-11 11:50:19 +01:00
e5034c6ae9 guarded suspension pattern #69 2017-03-11 11:50:19 +01:00
a09866d35b another readme fix 2017-03-11 11:50:19 +01:00
1824b4138b readme fix 2017-03-11 11:50:19 +01:00
764ff4bf53 Initial commit of guarded suspension design pattern 2017-03-11 11:50:19 +01:00
e8b634c33e java docs added 2017-03-10 20:59:24 +01:00
8871f788d2 #497 Converter pattern implementation 2017-03-10 20:08:58 +01:00
e9c54011e9 Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2017-03-08 16:50:04 +01:00
fd7107694a Update pom.xml
Changed
    <version>1.14.0-SNAPSHOT</version>
to
    <version>1.15.0-SNAPSHOT</version>
2017-02-18 15:16:15 +01:00
cca4760f69 #190 Rename package for Queue-Based Load Leveling pattern 2017-02-12 00:33:30 +02:00
a1ff55b462 #190 Regenerate puml files 2017-02-11 21:46:56 +02:00
ddac9dc6cb Add files via upload
Changed the classname part "runnable" to "callable"
2017-01-29 12:34:13 +01:00
2bbf84233e Delete DateFormatRunnableTestMultiThread.java 2017-01-29 12:32:44 +01:00
82f8460243 Delete DateFormatRunnableTestIncorrectDateFormat.java 2017-01-29 12:32:32 +01:00
59ea20745f Delete DateFormatRunnableTest.java 2017-01-29 12:32:21 +01:00
3d3dd58501 Update pom.xml
removed errors caused by copy code from master
2017-01-29 12:08:11 +01:00
3324e1bc43 Update pom.xml
added  <module>tls</module>
2017-01-29 12:01:32 +01:00
6202f3ab44 Add files via upload 2017-01-29 11:42:16 +01:00
453862cfc2 Delete AppTest.java 2017-01-29 11:41:46 +01:00
a8e2c157de Add files via upload
Test reworked completely. AppTest seperated.
2017-01-29 11:41:13 +01:00
080965fb17 Delete DateFormatUglyRunnable.java 2017-01-29 11:38:49 +01:00
7200329a6b Add files via upload
Rework replaces previous version completely. Using ExecutorService. Use of result object instead of static variables. Ugly example is left out.
2017-01-29 11:38:20 +01:00
f170aaa42b Delete DateFormatRunnable.java 2017-01-29 11:34:12 +01:00
c598748549 Delete AppUgly.java 2017-01-29 11:33:59 +01:00
ed11c4c4f9 Delete App.java 2017-01-29 11:33:40 +01:00
283f198ba8 Delete empty 2017-01-29 11:32:26 +01:00
15913d6382 Add files via upload
new uml diagramm after changes to the java classes
2017-01-29 11:31:06 +01:00
65e047974c Create empty 2017-01-29 11:29:19 +01:00
c529e35791 Delete tls.urm.puml 2017-01-29 11:28:27 +01:00
3342851005 Delete tls.ucls 2017-01-29 11:28:17 +01:00
c167f87ce5 Delete tls.png 2017-01-29 11:27:46 +01:00
e8fc3427c6 Update README.md
no change of content. Improved text
2017-01-29 11:23:33 +01:00
26b79a5382 Update README.md
Some additonal description, deleted wrong pumlid
2017-01-29 11:16:45 +01:00
9ec0935a1c Merge pull request #532 from leogtzr/master
Adding initialization-on-demand idiom and noninstantiable class instead of interface constant idiom
2017-01-23 08:21:07 +02:00
c6d0d28557 Reverting initialization on demand holder idiom. 2017-01-22 11:06:57 -07:00
e26215578c Changing code to use interfaces instead of implementations. 2017-01-21 15:49:29 -07:00
d6fc28e120 Changing code to use interfaces instead of implementations. 2017-01-21 15:47:54 -07:00
115a85301c #525 Add link to proxy blog 2017-01-21 13:37:16 +02:00
29c5b80f19 #525 Add link to Queue-Based Load Leveling blog 2017-01-21 12:56:42 +02:00
0c8bb1c22e Set version for next development iteration 2016-12-31 10:24:26 +02:00
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
6292690250 Changing constant interface pattern with a Noninstantiable class 2016-12-24 14:49:41 -07:00
ad93184a79 Merge pull request #530 from Valdar-Soft/master
Sonar quality bugfix and minor refactor
2016-12-24 12:36:11 +02:00
20b1c2bd49 Adding initialization on demand holder idiom. 2016-12-24 00:49:46 -07: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
e210e4ed62 Add files via upload 2016-12-16 11:17:27 +01:00
fb98da86c4 Add files via upload 2016-12-16 11:12:43 +01:00
c8b3c773c7 Add files via upload 2016-12-16 09:43:16 +01:00
61b1356976 Delete emptyfile 2016-12-16 09:42:46 +01:00
487f9ddc80 Add files via upload 2016-12-16 09:42:08 +01:00
9b7ce556e3 Create emptyfile 2016-12-16 09:35:19 +01:00
e17cf27e5a upload pom.xml 2016-12-15 18:33:52 +01:00
937a1e269d delete empty file 2016-12-15 18:32:13 +01:00
803a97237c delete empty file 2016-12-15 18:31:53 +01:00
e64f7faa3f upload junit test 2016-12-15 18:31:20 +01:00
15d660b117 empty file to create folder 2016-12-15 18:30:22 +01:00
544f7fb6d1 delete empty file 2016-12-15 18:28:02 +01:00
c4eb198a8d Upload code files 2016-12-15 18:27:28 +01:00
7067d1ae56 Create test 2016-12-15 18:24:03 +01:00
d80edd1ed3 Create test 2016-12-15 18:08:12 +01:00
aeefc11f25 Merge pull request #1 from iluwatar/master
Update my local repository
2016-12-14 08:52:22 +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
c5e6dcc11b Reached milestone 1.13.0 2016-09-30 19:38: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
6026eedd51 UML generation: Mark the urm-maven-plugin execution to be ignored in Eclipse and recreate all .puml files 2016-09-18 17:51:09 +03:00
b030cd4eba Hexagonal pattern: Introduce lottery utils class 2016-09-17 09:20:33 +03:00
6aa58e8ae6 Hexagonal pattern: Remove unnecessary factories 2016-09-17 09:07:06 +03:00
914d1353a1 Hexagonal pattern: Update test application description 2016-09-15 21:56:15 +03:00
df32a7b893 Hexagonal pattern: Introduced lottery events port with two adapters 2016-09-15 21:45:09 +03:00
c4c5e78e50 Hexagonal pattern: Improve error handling in console lottery 2016-09-14 22:18:42 +03:00
3cf2b34d2a Hexagonal pattern: Improve connection properties handling 2016-09-14 22:01:41 +03:00
27e8cb7f2d Hexagonal pattern: Add separate class for Mongo connection properties 2016-09-14 19:25:26 +03:00
e685512ed5 Hexagonal pattern: Added Mongo based banking adapter and bound it in Guice production module 2016-09-11 23:19:02 +03:00
f2159515bc Merge remote-tracking branch 'upstream/master' 2016-09-11 20:33:51 +01:00
59e6a0af85 Hexagonal pattern: Ignore Mongo repository test 2016-09-11 22:16:50 +03:00
9a90f2de1f Changes based on code review 2016-09-11 18:45:51 +01:00
626c56730c Hexagonal pattern: Added Mongo based ticket repository and set production configuration to use that 2016-09-11 20:02:34 +03:00
fce30db803 Updating fork branch 2016-09-11 16:24:16 +01:00
a85463470e Hexagonal pattern: Add mongo driver dependency 2016-09-11 13:53:00 +03:00
4410419914 Hexagonal pattern: Simplified lottery ticket ids 2016-09-11 10:34:12 +03:00
e17d72bca8 Hexagonal pattern: Added console interfaces for players and administration. 2016-09-10 14:28:05 +03:00
121ed3cca8 Hexagonal pattern: Move lottery administration and service to the core. Introduce console interfaces for players and administartors. 2016-09-10 07:56:37 +03:00
adc6019c7e Hexagonal pattern: Remove interfaces with only one implementation 2016-09-10 07:14:24 +03:00
0f2807b9cf Hexagonal pattern: More descriptive class names 2016-09-09 21:36:17 +03:00
1b10ddbb73 Hexagonal pattern: Use Guice dependency injection 2016-09-06 22:39:39 +03:00
348e577e8e Hexagonal pattern: Add Guice dependency 2016-09-06 21:39:08 +03:00
22821ba8cc Move Guice to parent pom dependency management section 2016-09-06 21:35:36 +03:00
4493341ba6 add documentation to 'use latest java 8' change 2016-09-04 11:00:24 +02:00
3cb872807e Hexagonal pattern: remove unnecessary repository usage from a unit test 2016-09-04 10:33:26 +03:00
ab68129829 Hexagonal pattern: move business logic to core 2016-09-03 22:02:08 +03:00
e57a0948ef Merge pull request #490 from iluwatar/DocumentUsages
#211 Document GoF usages from Java API
2016-09-03 14:14:13 +03: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
ff23e90c4f Add puml for Promise pattern 2016-09-03 08:43:35 +03:00
fa52a7f77e Run build with latest java 8 release 2016-09-03 00:19:50 +02:00
165d1f1298 Turn Error Tracing on when installing
Travis currently errors and i cant reproduce locally, so this might help finding the culprit
2016-09-02 23:54:52 +02:00
be2c7fdb2b Update URM version: 1.4.0 -> 1.4.1, fixes #492 2016-09-02 23:15:38 +02:00
90c636abd3 Add missing license headers 2016-09-02 21:28:45 +03:00
678a06e7f8 Merge pull request #470 from iluwatar/Promise
Implements #403 Promise pattern
2016-09-02 20:47:21 +03:00
e425c2ef2f Add webhook for travis build failures to gitter
Only the core group (private) gitter room
2016-08-31 13:15:44 +02:00
5c1a4f1caf Added example that mocking frameworks use proxy pattern 2016-08-31 16:12:13 +05:30
58dce1bd89 Work on #190: Commit initial pumlId's added by the script 2016-08-30 15:10:34 +02:00
9dd1503e6f Work on #190: add postPumlsToServer.py python script
Used to initially post all pumls to the plantuml hosting while preserving the pumlId's
2016-08-30 15:07:49 +02:00
09037b0251 Rename index.md to README.md
to conform to our standards, every other file is named README.md
2016-08-30 14:06:14 +02:00
36fe249960 Work on #190: Add first batch of automagically generated puml files 2016-08-30 13:29:12 +02:00
e73867f9a1 Work on #190: Add automagic puml generation in pom.xml's 2016-08-30 13:24:53 +02:00
59cf100302 #403, updated javadocs 2016-08-29 12:04:24 +05:30
ad11ea46b1 Work on #403, javadocs updated 2016-08-29 11:55:30 +05:30
5796e1967f Work on #403, updated diagram and finishing touches 2016-08-29 11:50:33 +05:30
483c61a82a Some refactoring, added javadocs 2016-08-29 00:16:36 +05:30
6575b3ae99 Merge pull request #491 from alexsomai/patch-1
Minor code changes
2016-08-29 00:00:44 +05:30
095adda7e9 Change access level to private 2016-08-26 12:54:20 +03:00
f16ae08bdf Remove extra space 2016-08-26 12:46:30 +03:00
95cf9fe367 Work on #403, made example readable and moved methods into utility 2016-08-22 18:43:29 +05:30
28647cdf48 #211, consistent use of real world examples section in all readme files. 2016-08-20 20:57:48 +05:30
fdcf546112 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into DocumentUsages 2016-08-20 20:50:30 +05:30
a0c77c32b5 #211 added further examples for structural and behavioral patterns 2016-08-20 20:49:28 +05:30
eb75773891 Added FAQ on Memento pattern
Difference between java Serialization and Memento pattern added
2016-08-20 19:44:48 +05:30
c79df708b1 #211 added real world examples from Java api for creational patterns 2016-08-20 13:17:53 +05:30
56100927a9 Addendum #481
Change page-index for faq.md
2016-08-15 12:33:24 +02:00
7e77216919 remove link, resolves #479
to avoid confusion, the link is removed.
For more information on why this is done please look at the referenced issue
2016-08-15 11:53:39 +02:00
b16d7fc970 Configure Travis notification email 2016-08-14 23:00:27 +03:00
0b36a3153d Fix checkstyle error 2016-08-14 22:42:59 +03:00
7c2f5da926 Add final keyword 2016-08-13 18:28:53 +03:00
ffbc5f2f29 Reorganize LotteryNumbers for easier inclusion in the blog 2016-08-13 17:08:57 +03:00
d50139e13e Merge pull request #478 from iluwatar/DocumentDoubleCheckIdiom
Documented singleton double check idiom
2016-08-05 18:45:00 +03:00
d484e7f731 Documented singleton double check idiom, explaining the dynamics that happen on each step for better understanding. Did this due to a PR #475 2016-08-05 14:38:25 +05:30
76970633b8 Work on #403, incorporate review changes 2016-08-04 18:10:50 +05:30
55028a49dc Merge pull request #476 from sumityadav6541/master
removed extra "is" from javadoc comments
2016-08-04 17:47:37 +05:30
94c3a2caf3 removed extra "is" from the javadoc of InitializingOnDemandHolderIdiom class 2016-08-03 15:02:46 +05:30
547d798528 Merge pull request #1 from iluwatar/master
merging changes into fork from origin
2016-08-03 14:57:07 +05:30
e7be94d2e4 Merge branch 'Promise' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-29 13:12:33 +05:30
383e4a3a0b Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-29 13:01:51 +05:30
3001fa4a30 Merge pull request #471 from Crossy147/issue-#459
#459 added known alias for monostate pattern
2016-07-27 15:46:17 +03:00
5fcef89384 #459 added known aliast for monostate pattern 2016-07-26 20:33:43 +02:00
40ac552542 Work on #403, added README 2016-07-24 01:45:49 +05:30
09ba5ca656 Work on #403, added class diagrams and javadocs 2016-07-22 18:34:05 +05:30
eb560f5f54 Work on #403, removed checkstyle violations 2016-07-22 16:53:01 +05:30
2b945ca27f Work on #403, removed dependency on async method invocation module, added more tests 2016-07-22 16:47:52 +05:30
4bd1f14cfb Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into Promise 2016-07-22 12:52:54 +05:30
bc94d0fc26 Fix link 2016-07-21 20:21:36 +03:00
102341443d Work on #403, added application class and test cases. 2016-07-21 19:13:42 +05:30
8124fd0771 Adjust pattern categories and tags 2016-07-21 09:27:48 +03:00
ea7503414e Work on #403, added basic implementation of promise pattern 2016-07-20 19:58:20 +05:30
d4c2f0392d Merge pull request #464 from pnowy/#463-chain-of-responsibility
#463 Added javax.servlet.Filter to real world examples intercepting filter
2016-07-18 09:22:34 +03:00
f7b7f15ec8 #463 Added javax.servlet.Filter to real world examples of intercepting filter 2016-07-17 21:24:12 +02:00
0fbbd8dc81 #463 Added javax.servlet.Filter to real world examples of chain 2016-07-17 16:05:07 +02:00
9f0320aeaf Add some tags to Page Object 2016-07-13 00:02:20 +03:00
fe1d760c7f Fix license headers 2016-07-12 19:52:56 +03:00
b46d2deeb0 Merge pull request #434 from colinbut/master
#229 Page Object Pattern
2016-07-12 19:47:48 +03:00
f182e87ee1 fixed app launch 2016-07-10 20:51:52 +01:00
85f432fb54 exclude library class from jacoco code coverage 2016-07-09 22:24:17 +01:00
7be98fa829 added missing licence headers to 2 files 2016-07-09 22:20:13 +01:00
ff8037ee0b Add aliases for Specification pattern 2016-07-07 08:46:56 +03:00
849df50394 Fix formatting 2016-07-04 22:22:37 +03:00
f806c5b712 Add known uses to Factory Method 2016-07-04 21:52:39 +03:00
ef2ada4fdf syncing fork 2016-07-03 21:47:07 +01:00
5d58a1b333 syncing fork 2016-07-03 21:46:38 +01:00
4a069ee93a new class diagrams 2016-07-03 21:36:03 +01:00
88321890c7 remove old class diagram 2016-07-03 21:12:48 +01:00
b1e40d9c92 Feedback changes - final and refactored code 2016-07-03 21:12:09 +01:00
5c26f46174 Set version number for next development iteration 2016-06-30 18:15:26 +03:00
7a118e4209 Reached milestone 1.12.0 2016-06-30 18:14:41 +03:00
4eac37c6b5 Feedback changes - removed file 2016-06-28 22:04:39 +01:00
c212ee5cb1 Feedback changes - fix dependency in pom 2016-06-28 22:03:57 +01:00
8efaf44170 Feedback changes - sort out dependency 2016-06-28 22:02:03 +01:00
27e4e9afee Feedback changes - restructed project structure 2016-06-28 21:53:55 +01:00
35c0942803 syncing fork 2016-06-27 20:54:45 +01:00
e7bd3cade2 Update link for Naked Objects paper 2016-06-26 20:23:05 +03:00
f2e1982264 Merge pull request #435 from protopapa/aggregator-microservices
implementation of microservices architectural pattern #296
2016-06-26 17:32:42 +03:00
27bbbd8335 fix bug 2016-06-26 14:57:27 +02:00
6677d1091d implementation of microservices architectural pattern #296 2016-06-23 22:54:44 +02:00
0282d6663f README 2016-06-18 21:08:15 +01:00
c8f04d2f0d added Class Diagram 2016-06-18 19:20:29 +01:00
53fc8b749a Page Object pattern implementation 2016-06-18 15:40:03 +01:00
f57b94ab47 Merge pull request #433 from qza/master
Abstract Document
2016-06-07 22:32:00 +03:00
34431d71b4 Merge pull request #431 from VarunVats9/master
Renamed HeroBuilder to Builder
2016-06-05 09:20:54 +03:00
qza
afdeba4f9a #355 finalize example 2016-06-04 20:06:32 +02:00
qza
c229ec23b3 #355 clean up 2016-06-02 07:41:32 +02:00
qza
f3110de130 #355 handle case when there are no child elements for the given key 2016-06-02 07:32:48 +02:00
qza
43f90ead48 #355 abstract document test 2016-06-02 07:29:37 +02:00
qza
a372f05e41 #355 override toString to log properties 2016-06-02 07:27:35 +02:00
qza
32b647323c #355 class diagrams 2016-06-01 22:21:31 +02:00
qza
913411773f #355 document, abstract base, traits and example domain 2016-06-01 22:20:55 +02:00
qza
c1187ae0d7 #355 init abstract-document module 2016-05-31 20:12:27 +02:00
509de9782d renamed HeroBuilder to Builder 2016-05-29 20:05:54 +05:30
f6649a4fed Markdown fix 2016-05-22 09:33:50 +03:00
9de2cbe73e Merge pull request #421 from iluwatar/hexagonal
Implements #86 Hexagonal Architecture
2016-05-21 22:19:16 +03:00
75ed1b1a96 Review fixes 2016-05-21 21:48:25 +03:00
2ed3748c9b Improve Singleton holder example 2016-05-07 11:38:55 +03:00
0ad9937881 Merge pull request #427 from surgeforward/297
#297 Create API Gateway pattern
2016-05-06 10:14:31 +03:00
f234a6875c #297 Update class diagram to reflect new location of files 2016-05-03 17:41:37 -05:00
dd2385312b #297 Add new dependencies to java-design-patterns/pom.xml and reference them from api-gateway submodule pom.xml files 2016-05-03 17:37:33 -05:00
8653eb87bc #297 Move API Gateway code into a new submodule: api-gateway-service. Change api-gateway packaging type to "pom". Update price-microservice and image-microservice to be true submodules of api-gateway 2016-05-03 17:17:36 -05:00
a6036e5787 #297 Update category and tags in README 2016-05-03 16:29:20 -05:00
5abd20f9e1 #297 Update license headers 2016-05-03 16:28:20 -05:00
b115c61873 #297 Fix error in README 2016-04-24 16:05:38 -05:00
b92318ae36 #297 Increase version number 2016-04-24 16:00:53 -05:00
28d259a55c #297 Create README.md 2016-04-24 16:00:39 -05:00
9a9df80080 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into 297
Conflicts:
	pom.xml
2016-04-24 15:30:35 -05:00
a54cea777f #297 Create class diagrams for API Gateway, Price microservice, and Image microservice 2016-04-24 15:24:33 -05:00
71e3443e0e Fix permalink to represent its current dir
Otherwise the picture cant be found, as the jekyll build process will put this file in a 'dm' directory and the other stuff like resources in a 'data-mapper' directory (because resources dont have permalink specified they are served static)
2016-04-24 12:58:38 +02:00
bf7b682549 Add License Shield 2016-04-24 12:25:05 +02:00
5b72510c1c Merge pull request #417 from inbravo/master
Data Mapper #34
2016-04-24 00:02:48 +03:00
49ca63087c Merge branch 'master' into hexagonal
# Conflicts:
#	pom.xml
2016-04-20 22:32:22 +03:00
af1db79aa7 version++ 2016-04-20 07:23:12 +05:30
59e9d027d4 version++ 2016-04-19 12:45:12 +05:30
018a4e52a2 build error fix++ 2016-04-19 12:23:52 +05:30
93b0b3730e build error fix++ 2016-04-19 11:59:27 +05:30
d5f7cb4e2c build check style error-- 2016-04-19 11:49:35 +05:30
8fa774d420 mvn build file++ 2016-04-19 11:35:13 +05:30
28c2714862 review comments++
review comments++
2016-04-19 11:25:42 +05:30
534fb67eb0 Merge pull request #397 from gwildor28/master
Lock Pattern #71: Added mutex and semaphore modules to demonstrate locks
2016-04-18 21:12:29 +03:00
32736fc90c uml diagram++ 2016-04-18 17:05:18 +05:30
8529d6e34b First review changes++
First review changes++
2016-04-18 13:14:20 +05:30
a2843297d8 JUnit tests 2016-04-17 14:46:52 +01:00
886ad7e8f0 Fix some markdown errors 2016-04-16 08:52:16 +03:00
6f89315aa9 Fix minor display error on web site 2016-04-15 08:41:15 +03:00
cf0570a5ed Fix display error 2016-04-15 08:38:08 +03:00
8e69ebce9f Fix display error 2016-04-15 08:21:29 +03:00
439e286f00 Fix minor display error 2016-04-15 08:13:51 +03:00
e821abdb1b updated version to fix pom 2016-04-14 17:44:18 +01:00
685d093cff added relative paths to pom in mutex/semaphore 2016-04-14 17:33:52 +01:00
ca8be7c43e pom update 2016-04-13 19:26:31 +01:00
3f9a756657 pom update 2016-04-13 19:25:02 +01:00
1fd15d535b Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2016-04-13 18:51:55 +01:00
b72214da2f Fix H2 database path problem 2016-04-12 23:04:37 +03:00
a7dfe7681e Add alias names 2016-04-11 23:17:27 +03:00
cfda338617 Fix version number 2016-04-10 22:03:24 +03:00
e546d5dacc Add general description for the example code 2016-04-10 21:50:02 +03:00
c2f4194c07 Add alias name for the pattern 2016-04-10 21:49:40 +03:00
ccc1ec921a Add readme and class diagram 2016-04-10 21:22:40 +03:00
9b3aa785ed Add missing license headers 2016-04-09 17:21:27 +03:00
0fe8eec610 Fix merge conflict 2016-04-09 17:17:29 +03:00
68725bf3cc Merge branch 'master' into hexagonal 2016-04-09 17:16:07 +03:00
5de9c7e6b4 Lots of improvements to the example 2016-04-09 16:53:34 +03:00
48803d4c7d Add example lottery run 2016-04-09 16:01:47 +03:00
b94a705161 Add constants for win sum and prize payer's bank account 2016-04-09 15:14:12 +03:00
335737d7dd Add alias for Multiton 2016-04-06 20:37:02 +03:00
06e0a15400 Applicability++ 2016-04-06 13:18:42 +05:30
c53dcf1274 Intent++ 2016-04-06 13:14:10 +05:30
822ab8d9fd Second type mapper is updated to use java.util.vector
Second type mapper is updated to use java.util.vector
2016-04-04 16:35:22 +05:30
59b6b817f4 Test/Doc added
Test/Doc added
2016-04-04 15:31:43 +05:30
eb72493f13 JDBC removed... 2016-04-04 12:33:43 +05:30
deb15e2733 JDBC removed... 2016-04-04 12:24:15 +05:30
d631585fa8 Test commit for #255
ignore the minor documentation change.
This is to test our build chain with travis!
2016-04-03 20:04:56 +02:00
4ebb64c092 #297 Create unit test for PriceController 2016-04-02 18:33:50 -05:00
e80583fad7 #297 Create unit test for ImageController 2016-04-02 18:31:58 -05:00
665256ecc0 #297 Create Spring Boot-backed API Gateway that aggregates calls to the Image and Price microservices 2016-04-02 18:25:13 -05:00
01737bc643 #297 Create Spring Boot-backed Price microservice with an endpoint to retrieve a price 2016-04-02 18:19:42 -05:00
0c6d3f2c3a #297 Create Spring Boot-backed Image microservice with an endpoint to retrieve an image path 2016-04-02 18:19:21 -05:00
398eb11b11 Set version for the next development iteration 2016-04-02 19:55:04 +03:00
1f27dbbf5b Set version for milestone 1.11.0 2016-04-02 19:51:03 +03:00
187658cce9 Merge remote-tracking branch 'iluwatar/master' 2016-03-29 14:19:01 +01:00
e2af78f417 Update According to Review Comments #397
Resubmit of updates
2016-03-29 13:42:54 +01:00
474f2658ee Merge remote-tracking branch 'refs/remotes/iluwatar/master' 2016-03-29 13:36:56 +01:00
28a5a43a47 basic implementation ++
basic implementation ++
2016-03-29 16:36:00 +05:30
d20145c05d Merge pull request #407 from iluwatar/refactor-dao
Solves #404 Refactor dao
2016-03-28 19:44:07 +03:00
464ae1690b Updated pom 2016-03-28 11:59:29 +05:30
ddbc61b140 Incorporated review changes - 1) Created sql file for central schema 2)
Changed getById return type to Optional
2016-03-28 11:55:22 +05:30
f32a3892a3 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into refactor-dao 2016-03-28 11:06:25 +05:30
6608a8de38 Utilize notifications and banking 2016-03-27 23:35:51 +03:00
28d3cb2aa2 Add notifications implementation 2016-03-26 22:01:31 +02:00
11c0654103 Add banking implementation 2016-03-26 21:47:25 +02:00
f620123cee Organize packages 2016-03-26 21:22:49 +02:00
d406f0f9c6 Merge pull request #412 from slawiko/patch-1
Override annotation added
2016-03-26 21:03:34 +02:00
ac468bb7e7 Added high level lottery test 2016-03-26 15:54:40 +02:00
0c56d800c5 Override annotation added
I think this is a typo
2016-03-26 15:22:33 +03:00
4bb7ddaec1 Work on admin tests 2016-03-26 12:42:23 +02:00
39a1c1e956 Implement admin interface 2016-03-26 12:28:51 +02:00
656b599687 Refactor to test utils 2016-03-26 12:28:31 +02:00
9074a9ca05 Merge branch 'saifulazad-patch-1' 2016-03-26 15:54:38 +05:30
b14aff17b6 Updated failing test cases 2016-03-26 15:54:10 +05:30
20c1e2ea80 Merge branch 'patch-1' of https://github.com/saifulazad/java-design-patterns into saifulazad-patch-1 2016-03-26 15:50:25 +05:30
100a72a5e2 Merge pull request #402 from iluwatar/mute-idiom
Implements Mute idiom
2016-03-26 11:07:46 +02:00
8d6bc522cd Simplify lottery ticket submit 2016-03-26 11:03:40 +02:00
a395316a80 Added readme 2016-03-26 13:54:03 +05:30
80875a9ac8 Removed dependency on Mockito from pom 2016-03-26 12:36:50 +05:30
4d820b12ff Changes after review. Added README 2016-03-26 12:33:02 +05:30
e543ee0a9c Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into mute-idiom 2016-03-26 12:11:09 +05:30
2f5a2be27a Fix missing table error 2016-03-25 22:00:08 +02:00
e549af25dd Severe is not appropriate.
"Sever" is most Appropriate
2016-03-25 22:50:17 +06:00
6e4b269939 Update according to review comments #397
- Added descriptions
- Added junit tests
- Added javadoc
- Added index.md
- Added class diagrams
2016-03-24 18:13:37 +00:00
3f7ead5ca5 Work on #404, updated class diagram and javadoc. Passed checkstyle checks 2016-03-23 13:13:19 +05:30
266b658ab5 Refactor interfaces 2016-03-22 22:45:25 +02:00
d2f620a5e6 Added tests for lottery ticket repository 2016-03-22 21:27:13 +02:00
aebd857931 Merge pull request #406 from slawiko/slawiko-patch-1
File renaming (index.md to README.md)
2016-03-22 12:22:35 +01:00
fa077c8be9 Work on #404, javadocs and test cases for DB and in memory dao. 2016-03-21 17:55:29 +05:30
8b147c4dd9 Add mock database for lottery tickets 2016-03-20 20:56:04 +02:00
fde33999b7 Added interface for lottery administrators 2016-03-20 14:38:24 +02:00
e8671e1d6e Add interface for lottery event notifications 2016-03-20 14:33:41 +02:00
15d2b9dcca Added interface to lottery service provider's bank account 2016-03-20 14:26:43 +02:00
95e6a67056 Added interface for accessing lottery tickets in database 2016-03-20 14:09:44 +02:00
2785f6915b Add lottery ticket check result 2016-03-20 11:10:06 +02:00
bd1b65276e all index.md files renamed to README.md for more compatibility with github 2016-03-20 11:50:21 +03:00
804ffc3ea7 Added lottery service interface 2016-03-20 10:49:31 +02:00
035b14fef8 Added lottery ticket and unit tests 2016-03-19 21:57:57 +02:00
81718eb8ae Added player details and unit tests 2016-03-19 21:08:55 +02:00
cd3a5d48d8 Work on lottery numbers unit tests 2016-03-19 20:37:36 +02:00
b0f96adeb1 Added class for lottery numbers and unit tests for it 2016-03-19 18:13:30 +02:00
448d855809 implemented and added test cases for DB dao. Added dependency of Hierarchical junit runner in parent pom 2016-03-18 16:39:45 +05:30
f6a20c7693 Refactoring changes to DAO pattern. Renamed default dao implementation to InMemory and refined interface 2016-03-16 18:47:07 +05:30
e5217bbde8 Work on #385, added missing license template 2016-03-16 12:48:53 +05:30
40e5c8d587 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into mute-idiom 2016-03-16 12:41:15 +05:30
c78dd2667a Work on #385, added documentation and class diagram. Made refactoring changes to pass checkstyle and PMD checks 2016-03-16 12:40:46 +05:30
7aff77ab27 Used mockito to replicate SQLException while closing connection to show use of loggedMute 2016-03-15 18:44:59 +05:30
528d179efe Add missing license headers 2016-03-13 17:29:09 +02:00
06546ae3cf Fix license headers 2016-03-13 17:23:31 +02:00
2ed089900d Initial commit for Hexagonal Architecture pattern 2016-03-13 17:23:15 +02:00
984bf552ce Merge pull request #390 from DevFactory/release/private-methods-that-don't-access-instance-data-should-be-static-fix-1
squid:S2325 - private methods that don't access instance data should …
2016-03-09 18:33:17 +02:00
414cdfa332 Merge pull request #398 from legka/master
Event driven architecture refactored.
2016-03-09 10:49:08 +05:30
afb897300b Event driven architecture refactored.
1. Renamed Message to Event and Event to AbstractEvent
2. Generified Event and Handler
3. Updated EventDispatcher to make unsafe configuration impossible
4. Updated UML diagram accordingly
2016-03-08 00:56:08 -08:00
3ed3bc1fa5 Added mutex and semaphore modules to demonstrate locks
Added two modules to demonstrate locks.

Mutex demonstrates a simple mutual exclusion lock. Semaphore
demonstrates a semaphore for controlling access to a pool of resources.

The main class of both programs is App.java.
2016-03-07 19:40:50 +00:00
adb94044ff Work on #385, created project and provided two mute methods 2016-03-01 17:28:28 +05:30
35d6a54831 Merge pull request #391 from DevFactory/release/Useless-parentheses-around-expressions-should-be-removed-to-prevent-any-misunderstanding-fix-1
squid:UselessParenthesesCheck - Useless parentheses around expression…
2016-02-29 17:53:13 +05:30
f135ef6ec8 Merge pull request #389 from DevFactory/release/Declarations-should-use-Java-collection-interfaces-such-as-List-rather-than-specific-implementation-classes-such-as-LinkedList-fix-1
squid:S1319 - Declarations should use Java collection interfaces such…
2016-02-29 07:42:04 +02:00
046e131119 squid:UselessParenthesesCheck - Useless parentheses around expressions should be removed to prevent any misunderstanding 2016-02-23 20:57:55 +02:00
e4c34b1e22 squid:S1319 - Declarations should use Java collection interfaces such as List rather than specific implementation classes such as LinkedList 2016-02-23 12:32:23 +02:00
3791a80978 squid:S2325 - private methods that don't access instance data should be static 2016-02-22 19:15:51 +02:00
ab19c47415 Merge pull request #388 from Crossy147/monad-pattern
Monad pattern
2016-02-21 20:36:05 +02:00
9f086ba72c Merge pull request #382 from Crossy147/master
issue #333 Factory-kit
2016-02-21 19:56:53 +02:00
cfd83b5753 issue #333 review changes 2016-02-21 12:54:40 +01:00
81e8d354a9 issue #335 review changes 2016-02-21 12:10:08 +01:00
c580b61df3 Merge pull request #380 from DevFactory/release/Type-parameter-names-should-comply-with-a-naming-convention-fix-1
squid:S00119 - Type parameter names should comply with a naming conve…
2016-02-20 19:35:53 +02:00
9714fe075a Merge pull request #387 from DevFactory/release/Constructors-should-only-call-non-overridable-methods-fix-1
squid:S1699 - Constructors should only call non-overridable methods
2016-02-20 19:25:48 +02:00
bbd769b208 Merge pull request #386 from amitbhoraniya/master
Dao Pattern : Create object with reference to Interface
2016-02-20 18:34:47 +02:00
d3689b2040 squid:S00119 - Type parameter names should comply with a naming convention 2016-02-20 18:19:44 +02:00
ea81ef71ab Merge pull request #377 from iluwatar/FactoryMethodChanges
Factory and Abstract Factory changes
2016-02-20 17:49:14 +02:00
80ff7bb217 issue #335 brace typo 2016-02-20 15:01:45 +01:00
64f1fe8979 issue #335 typos fixed 2016-02-20 14:55:37 +01:00
f47b9283c3 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into monad-pattern 2016-02-19 19:10:43 +01:00
72e08365b8 issue #335 documentation improvements 2016-02-19 19:08:35 +01:00
3e526cb5da issue #335 Monad pattern introduced 2016-02-19 17:56:09 +01:00
50310aaeaf squid:S1699 - Constructors should only call non-overridable methods 2016-02-19 11:02:49 +02:00
b70614efef Creating object with reference to Interface
In Dao pattern DaoImpl object is created with reference to dao interface.
2016-02-19 00:10:55 +05:30
dfef28e93e Merge pull request #384 from DevFactory/release/Redundant-Field-Initializer-fix-1
pmd:RedundantFieldInitializer - Redundant-Field-Initializer
2016-02-18 12:39:06 +05:30
0003c6cb00 pmd:RedundantFieldInitializer - Redundant-Field-Initializer 2016-02-18 08:40:19 +02:00
6ab9b36d59 issue #333 javadocs changes 2016-02-17 19:35:10 +01:00
2fa705ab59 issue #333 snapshot version fixed 2016-02-16 00:05:28 +01:00
8fabc861b3 pom.xml minor 2016-02-15 21:57:26 +01:00
53fdaba6c4 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns 2016-02-15 21:48:07 +01:00
8b625a8d3c issue #333 minor revert 2016-02-15 20:54:55 +01:00
022ab28e20 issue #333 diagrams and index added 2016-02-15 20:37:16 +01:00
f1122f78e3 Added real life application to Command pattern 2016-02-15 18:21:34 +05:30
cd077fa490 Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into FactoryMethodChanges 2016-02-12 15:49:35 +05:30
823dc6395f Merge pull request #376 from DevFactory/release/Classes-without-public-constructors-should-be-final-fix-1
squid:S2974 - Classes without public constructors should be final
2016-02-12 15:44:31 +05:30
221b71781a Resolved checkstyle audit error 2016-02-11 12:29:35 +05:30
b5d4445d63 Made example App a bit easier to understand 2016-02-10 17:53:32 +05:30
f64ba22c64 1) Removed warning from test case. 2) Made implementation of App more understandable. 2016-02-10 17:38:15 +05:30
632174b6dc squid:S2974 - Classes without public constructors should be final 2016-02-09 17:19:31 +02:00
57be8aa522 Merge pull request #375 from DevFactory/release/The-members-of-an-interface-declaration-or-class-should-appear-in-a-pre-defined-order-fix-1
squid:S1213 - The members of an interface declaration or class should…
2016-02-08 20:40:16 +02:00
3cbb88e09c #297 Create unit tests for Gateway API pattern 2016-02-07 17:05:45 -06:00
88c3b04eb3 #297 Create API Gateway pattern 2016-02-07 17:05:33 -06:00
9c5745763d squid:S1213 - The members of an interface declaration or class should appear in a pre-defined order 2016-02-06 01:10:56 +02:00
1655f30845 Merge pull request #372 from DevFactory/release/Methods-should-not-be-empty-fix-1
squid:S1186 - Methods should not be empty
2016-02-05 21:07:57 +02:00
769a6206f2 Merge pull request #370 from fluxw42/license_date_2016
Update license year from 2014 to range '2014-2016'
2016-02-05 21:07:02 +02:00
9b6517453f Merge pull request #362 from JuhoKang/master
Value object pattern #349
2016-02-05 21:04:21 +02:00
df4a40fc13 squid:S1186 - Methods should not be empty 2016-02-03 21:51:40 +02:00
83533543e6 format code 2016-02-03 23:38:13 +09:00
f71e186959 Fixed descriptions in code. 2016-02-03 23:33:40 +09:00
db2140ecc9 updated child and parent pom 2016-02-03 23:02:27 +09:00
049841298e deleted the change in parent pom 2016-02-03 22:59:15 +09:00
1e5cbe1f76 Merge remote-tracking branch 'upstream/master' 2016-02-03 22:49:59 +09:00
53cc97e9d0 Update license year from 2014 to range '2014-2016' 2016-02-03 07:15:19 +01:00
33224dd7d7 Prepare for next development iteration 2016-02-02 22:14:20 +02:00
4f56f7b097 Achieved milestone 1.10.0 2016-02-02 22:11:38 +02:00
e25cbad811 Merge pull request #367 from mikulucky/master
Feature Toogle PR
2016-02-02 22:02:15 +02:00
6caea8557b added missing space, 'cause website didnt display correctly 2016-02-02 17:31:12 +01:00
d8378915a1 pom.xml change to fit upstream 2016-02-02 08:02:38 +09:00
0e7fae21c3 Edit pom.xml 2016-02-02 07:48:43 +09:00
3ef464986c Merge remote-tracking branch 'upstream/master', fixed f-c index properly 2016-02-02 07:35:06 +09:00
e05592b522 Merge pull request #365 from DevFactory/release/Append-Character-With-Char-fix-1
pmd:AppendCharacterWithChar - Append Character With Char
2016-02-01 22:28:34 +02:00
f08af14555 Merge pull request #364 from DevFactory/release/The-diamond-operator-should-be-used-fix-1
squid:S2293 - The diamond operator should be used
2016-02-01 22:26:43 +02:00
c7f4311706 #354 Clean up 2016-02-01 18:57:05 +00:00
37da470178 #354 Finish Readme 2016-02-01 18:45:54 +00:00
7adefc89ba pmd:AppendCharacterWithChar - Append Character With Char 2016-02-01 04:20:52 +02:00
b27d6dff66 Merge branch 'master' of github.com:mikulucky/java-design-patterns
terns
Update
2016-01-31 23:28:28 +00:00
bf5ba44260 #354 add App.java 2016-01-31 23:24:35 +00:00
8603333e5d #354 Adding Class Diagram 2016-01-31 14:10:34 +00:00
7cc93de672 #354 Merged Remote Master and resolved conflicts 2016-01-31 13:58:00 +00:00
c2e750aca1 #354 finished method javadocs 2016-01-31 13:46:34 +00:00
59c32d3937 Add tests that run the examples 2016-01-31 12:09:09 +02:00
dc4f07eb81 Merge pull request #360 from mikulucky/MIT-Source
Pull Request for adding License Plugin and Generate #358
2016-01-30 15:10:42 +02:00
d24a12a9b2 Merge pull request #359 from DevFactory/release/Local-Variables-should-not-be-declared-and-then-immediately-returned-or-thrown-fix-1
squid:S1488 - Local Variables should not be declared and then immedia…
2016-01-30 14:42:05 +02:00
62b2f8e9a4 Merge pull request #357 from DevFactory/release/Consecutive-Appends-Should-Reuse-fix-1
pmd:ConsecutiveAppendsShouldReuse - Consecutive Appends Should Reuse
2016-01-30 14:37:18 +02:00
409ff027b8 squid:S2293 - The diamond operator should be used 2016-01-29 07:33:34 +02:00
98326a1e5e #354 Start Adding Java docs 2016-01-28 21:14:40 +00:00
d3eb8a2ef2 Added comments in the code. modified index.md 2016-01-29 00:53:27 +09:00
083065ba93 Added index.md
Added index.md with explanation which seems a little bit short of detail.
Fixed the directory of the files.
2016-01-28 23:33:46 +09:00
cca40a543a Added Code 2016-01-28 22:39:50 +09:00
3d95696078 #358 Added license to all files using plugin 2016-01-27 22:20:42 +00:00
321f5d6c5a Merge branch 'master' of https://github.com/iluwatar/java-design-patterns into MIT-Source 2016-01-27 22:15:15 +00:00
7b61395bc1 #358 Add Plugin for Auto License 2016-01-27 22:14:28 +00:00
ab2aad3226 Work on #226, moved pattern specific references to respective patterns. And removed credits section from Home page. 2016-01-27 12:55:59 +05:30
4e40cc3888 squid:S1488 - Local Variables should not be declared and then immediately returned or thrown 2016-01-27 02:45:39 +02:00
77e14f0069 #354 Add tests for Properties 2016-01-26 23:38:28 +00:00
4a49f82f23 #354 add general boolean method to services for feature status. Change user.toString 2016-01-26 21:18:47 +00:00
ba1d3a0fbf #354 Added Configuration Based Example of Feature Toggle 2016-01-26 21:08:28 +00:00
d627b7af6b #354 Moved Tests to the correct area 2016-01-26 20:24:43 +00:00
91b2379fd0 #354 Fixed CheckStyle Issues 2016-01-26 19:20:28 +00:00
32f9cf3ab1 #354 Some clean up and show the difference between paid and free a bit more. 2016-01-26 18:58:35 +00:00
a1ede8980f #354 Added WelcomeMessage Service and Tests for tier example of featureToggle 2016-01-26 18:49:25 +00:00
72733acfc6 #354 added usergroup for version of feature toggle 2016-01-26 18:41:08 +00:00
d00bfae5ee pmd:ConsecutiveAppendsShouldReuse - Consecutive Appends Should Reuse 2016-01-26 19:58:45 +02:00
0b834128b9 #354 Add Blank index.md 2016-01-25 21:29:05 +00:00
89e0e3e73e #354 Remove generated copyright banner 2016-01-25 21:16:35 +00:00
d7526fc7c0 #354 Add maven model for feature toggle design pattern 2016-01-25 21:14:24 +00:00
cf10bd1d05 #354 Add maven model for feature toggle design pattern 2016-01-25 21:11:26 +00:00
5ad99be224 #354 Add maven model for feature toggle design pattern 2016-01-25 21:10:58 +00:00
64b89ecb59 Create project for value-object pattern 2016-01-23 10:06:57 +09:00
1a55f3a420 Work on #353: More descriptive Tags
* Added the full name for Apache Camel, including the trademark symbol for clarity among other things named "Camel" and to indicate that this is a 3rd party software
2016-01-19 21:28:54 +01:00
10bbf988ea issue #333 factory kit pattern introduced 2016-01-17 13:47:44 +01:00
bd82387fc1 Merge pull request #345 from azhuzhu/master
Fix the wrong uml .png name in decorator
2016-01-14 19:47:09 +02:00
3398badd30 Merge pull request #344 from hoswey/master
fix issue #343 ReaderWriterLock unit tests fail on CI
2016-01-14 19:42:46 +02:00
033dce8387 Fix the wrong uml .png name in decorator 2016-01-15 00:56:46 +08:00
e95cfe9292 fix issue #343 ReaderWriterLock unit tests fail on CI 2016-01-13 09:35:31 +08:00
150c4e0d5d Ignore rest of ReaderWriterLock tests with intermittent failures 2016-01-12 21:16:39 +02:00
c8db19efe2 Ignore another test with intermittent failures until fixed 2016-01-12 21:08:10 +02:00
2fec4f891b Ignore test with intermittent failures until fixed 2016-01-12 20:57:36 +02:00
adf131b784 Merge pull request #326 from hoswey/master
implements the #75 reader writer lock
2016-01-12 20:15:22 +02:00
77d45c35e0 implements the #75 reader writer lock, fix the problem of review 2016-01-10 21:23:52 +08:00
2f84369003 Merge remote-tracking branch 'upstream/master' 2016-01-09 22:26:18 +08:00
83f1ac7489 Update dependencies 2016-01-07 21:41:45 +02:00
03e187743c Merge pull request #340 from tomroy/master
Decorator pattern: SmartTroll should be SmartHostile #264
2016-01-06 19:44:26 +02:00
bd83fa28bb Correct method name and cleanup etc folder #264 2016-01-07 00:34:33 +08:00
30ca1ea1fb Decorator pattern: SmartTroll should be SmartHostile #264 2016-01-04 23:07:33 +08:00
4c5f9ae44c Merge pull request #339 from fluxw42/issue-238
Use headings instead of bold text in index.md #238

Script used to do it: https://gist.github.com/fluxw42/464820d08e3b567fda48
2016-01-04 02:15:37 +01:00
3d642cdad7 Use headings instead of bold text in index.md #238 2016-01-03 21:14:30 +01:00
b6beffec2e Merge pull request #299 from genericmethod/master
#113 Event-driven Architecture
2016-01-03 14:50:46 +02:00
1987bdb962 Merge pull request #1 from mikulucky/master
Class Diagram for EDA
2016-01-03 12:20:35 +00:00
bea1a0d6d9 Revert "Revert "Add class diagram for #113 and to be included in PR #299""
This reverts commit 0f75a0e239.
2016-01-03 00:55:04 +00:00
d6719729b9 Revert "Revert "Merge remote-tracking branch 'origin/master'""
This reverts commit 03f0a2112b.
2016-01-03 00:54:49 +00:00
03f0a2112b Revert "Merge remote-tracking branch 'origin/master'"
This reverts commit 248ea5191a, reversing
changes made to 02bd15db90.
2016-01-03 00:52:56 +00:00
0f75a0e239 Revert "Add class diagram for #113 and to be included in PR #299"
This reverts commit 0c062d3f55.
2016-01-03 00:52:24 +00:00
0c062d3f55 Add class diagram for #113 and to be included in PR #299 2016-01-03 00:01:43 +00:00
248ea5191a Merge remote-tracking branch 'origin/master' 2016-01-02 23:59:47 +00:00
39b183d569 Merge pull request #2 from genericmethod/master
Pull
2016-01-02 23:58:43 +00:00
02bd15db90 Merge remote-tracking branch 'iluwatar/master' 2016-01-02 18:39:58 +00:00
317a599c3b Merge pull request #337 from mikulucky/master
Provide a simple example for Callback Pattern using Lambdas
2016-01-02 19:04:43 +02:00
7176b86146 #113 Event Driven Architecture
bumped up version to 1.10
2016-01-02 14:05:36 +01:00
2ea9bfef19 #113 Event Driven Architecture
Fixed PMD errors
2016-01-02 14:04:07 +01:00
40042ae392 Merge remote-tracking branch 'iluwatar/master'
# Conflicts:
#	pom.xml
2016-01-02 11:48:01 +01:00
e25ef1b0f8 Check Style fixes #334 2016-01-02 00:54:26 +00:00
ca4a4ec07b Created a Lambdas example for the callback pattern, using the same output of the traditional version. Have also added another unit test for issue #334 2016-01-01 23:41:56 +00:00
e0e51324db Set version number for next development iteration 2016-01-01 20:39:20 +02:00
3731d26f6d implants the #75 reader writer lock 2015-12-26 14:17:24 +08:00
898f3a428c #113 Event Driven Architecture
Fixed a typo in index.md
2015-12-02 01:43:34 +01:00
0b46a9985d #113 Event Driven Architecture
Updated index.md with eda uses
2015-12-02 01:39:20 +01:00
2aa20b7445 #113 Event Driven Architecture
Adds various changes including :
- Fixes to Javadoc
2015-12-01 23:33:26 +01:00
cfb0fafc7d #113 Event Driven Architecture
Adds various changes including :
- Fixes to Javadoc
- Test refactoring and improvements
- Refactored EventDispatcher to be immutable
- Removed DynamicRouter interface since it not needed
- Renamed Channel to a more appropriate name - Handler
2015-12-01 23:30:01 +01:00
9e857d7dd6 #113 Event Driven Architecture
Fixed javadoc
2015-11-28 19:05:23 +01:00
d9a1d1cef9 #113 Event Driven Architecture
Adds unit test to assert and verify pattern event get type behaviour.
Also added unit test comments.
2015-11-28 17:58:32 +01:00
3ad36020aa #113 Event Driven Architecture
Adds unit test to assert and verify pattern behaviour
2015-11-28 17:25:15 +01:00
e1c0731f7e #113 Event Driven Architecture
Adds more Javadoc and fixes checkstyle issues.
2015-11-28 15:03:22 +01:00
b8b94b697a #113 Event Driven Architecture
Adds more Javadoc
2015-11-28 13:12:16 +01:00
fc70a706c6 #113 Event Driven Architecture
Adds module to the root pom.xml
Fixes indentation
2015-11-28 10:57:00 +01:00
321e9d4191 #113 Event Driven Architecture
- added class diagram
- added more comments
2015-11-23 11:20:20 +01:00
b4aeca3aa0 #113 Event Driven Architecture
- removed unused imports
2015-11-23 00:04:44 +01:00
3ef0921f20 #113 Event Driven Architecture
- refactored and moved around some classes
2015-11-23 00:02:58 +01:00
eb396217d0 #113 Event Driven Architecture
- initial commit includes a simple and advanced example of Event-driven architecture
2015-11-22 19:40:07 +01:00
1341 changed files with 49481 additions and 4071 deletions

33
.gitignore vendored
View File

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

View File

@ -6,13 +6,34 @@ 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
- sh -e /etc/init.d/xvfb start
# default install command is just "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
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
sudo: false
# use latest java version available instead of travis default
addons:
apt:
packages:
- oracle-java8-installer
notifications:
email:
- iluwatar@gmail.com
webhooks:
urls:
- https://webhooks.gitter.im/e/3319623945358a093a6f
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
sudo: false # route the build to the container-based infrastructure for a faster build

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
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

@ -5,8 +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
@ -23,7 +24,7 @@ are familiar with the patterns.
# Getting started
Before you dive into the material, you should be familiar with various
[Programming/Software Design Principles](http://webpro.github.io/programming-principles/).
Programming/Software Design Principles.
All designs should be as simple as possible. You should start with KISS, YAGNI,
and Do The Simplest Thing That Could Possibly Work principles. Complexity and
@ -41,18 +42,6 @@ patterns by any of the following approaches
If you are willing to contribute to the project you will find the relevant information in our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki). We will help you and answer your questions in the [Gitter chatroom](https://gitter.im/iluwatar/java-design-patterns).
# Credits
* [Effective Java (2nd Edition)](http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683)
* [Java Generics and Collections](http://www.amazon.com/Java-Generics-Collections-Maurice-Naftalin/dp/0596527756/)
* [Let's Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
* [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
* [Presentation Tier Patterns](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
* [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
* [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
* [Spring Data](http://www.amazon.com/Spring-Data-Mark-Pollack/dp/1449323952/ref=sr_1_1)
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
# License
This project is licensed under the terms of the MIT license.

View File

@ -0,0 +1,190 @@
parent: half-sync-half-async; artifact: half-sync-half-async
Puml Server ID: RScv3SCm3030LU819FRPXg5fIm552tnYPFiyjRi3RkbAaYkdoQr5JBy369vrxz7oaSv6XmPhL3e6TCaJ0msU-CAoilTToyG8DdKOw5z0GzcAlvNAN_WZSD1brBHHPmxv0000
parent: abstract-document; artifact: abstract-document
Puml Server ID: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
parent: tolerant-reader; artifact: tolerant-reader
Puml Server ID: NSZ14SCm20NHLf829ExfXaYChGn26lZ4xSVdtFRjSrZJx9AkZnFOyI9olkenSEOxGxmjWnXgMvE6viLWfmz_kNI9SLZP38XRqEIuWx1Kd0t5XVjjGVj_DNtMdLD_
parent: event-driven-architecture; artifact: event-driven-architecture
Puml Server ID: TOhH3SCW30LNQGS0_tSRnrZ15H1adfFromBzkfFktZQaHT7mzgh0N1yYvoUVXXf7B7Mv1dGWozN9MZmCTlhopQdeidEaoO3wMDHvRI6zzvwAssPYbsfGGRYIGlxN7DxpZDv-
parent: publish-subscribe; artifact: publish-subscribe
Puml Server ID: PSZB3SCm203GLTe1RExT1XCKKs5YyMdMR--zFRsd66aTNAwFcRdZ1U1uzrDorgXWfykIBJjT2qJhnaI7Dtwm7HnoMjkOoMu12-C7s3LKOhQe4UGo63ZfVtlvwhkMVW40
parent: facade; artifact: facade
Puml Server ID: BSP15eCm20N0gxG7CEoz3ILKqvTW7dpq-hhehERTJ7fMJU-l7PYn4ZbVPMlOyvEXBeT13KMEGQtdnM2d7v-yL8sssJ8PKBUWmV64lYnSbHJoRqaVPUReDm00
parent: service-locator; artifact: service-locator
Puml Server ID: NSjB3iCm203HgxG7iDdtDeIWX0fZYqzo_MRTtUX9ynOZhPtBzNLchlW0EDxza3nhgs2dQScMdUO0qRenqU6B5xQTGmvh2pFPBM1WF07FSmbnqqcOqu6J_gsNZxvgw0y0
parent: dao; artifact: dao
Puml Server ID: 5SR14OKW30N0LhG0oVrt4o6ZE12Ov4NR_thQNQlc5aN2sd82qtz4naywAixOmyNoK8WYvT6fjdWOR7JnpLiHhuTkam4nTUhiRwZm847-J64zpUZj3m00
parent: model-view-presenter; artifact: model-view-presenter
Puml Server ID: ROlR3SGW3C1MkGu0-RzjKeXQJWcWFChwPO3xispvQBrmL0hbp-q-xGkWkFBL_8upZBICxjGzbo7GE1OwAlpmmLJ9sjNJH7VIRY1e6q169KvFevMcakrtI_BoD-HGoJE4Nm00
parent: observer; artifact: observer
Puml Server ID: FSkn4OGm30NHLg00hFow4KO3PcpP8tr1-pYwx6smQz5Suv2mkbp0y1-HyPlEWYlsSB7S5Q98kJSgDLu66ztyy7Q8brEtmO2OEZNs2Uhxl9u9GVv72cjfHAiV
parent: intercepting-filter; artifact: intercepting-filter
Puml Server ID: RSfB3i8m303Hgy014k-vZN5DQkIuaJ_q-fGzkz7JtCL8Q-DolUsPAnu0ZcSVadizAzZfi6JBJiS4qJenqU6D7smRXmnh2pFPBM1YN05o_KwyKcoqb-ZFEEcVz_BPLqtz0W00
parent: factory-method; artifact: factory-method
Puml Server ID: NSZB3G8n30N0Lg20n7UwCOxPP9MVx6TMT0zdRgEvjoazYeRrMmMsFuYChtmqr7Y6gycQq8aiQr3hSJ7OwEGtfwBUZfas0shJQR3_G2yMBFkaeQYha4B-AeUDl6FqBm00
parent: private-class-data; artifact: private-class-data
Puml Server ID: RShR3SCm243HLTe1RFwx3S4eeSB4uf6itmpGlwkZ-nOZhS7b-ZeoLtm07E--InwrLR3JQScMdSu9edLZeiCNBso3GtPh2pFPBM1YF07BvSBaHeeHRJm_SD8VxkMphvhw0m00
parent: async-method-invocation; artifact: async-method-invocation
Puml Server ID: TSdB3SCW303GLTe1mFTkunWhk0A3_4dKxTi5UdlIUuhIoCPfuz4Zjhy03EzwIlGyqjbeQR16fJL1HjuOQF362qjZbrFBnWWsTPZeFm3wHwbCZhvQ4RqMOSXIuA1_LzDctJd75m00
parent: execute-around; artifact: execute-around
Puml Server ID: NSZ14G8n20NGLhI0XBlT865suoGa0n_NylNixSsxTvEHJTF7xGHsF8YShtfqdFdCK9TbK4ELDQcFl1ZizE8tbwRH3okR0NKBcXm_a7vK4bhOLreZXVnLJPzrvnnV
parent: monostate; artifact: monostate
Puml Server ID: HSV14OGm20NGLjO23FVj1YEZsGaa0nzjVxrvUszfLdlkaju_9p3ZI-HybwFXp2r3l0w364eTIgtdpM2d7r-yxXBji7Ko86v1ol60TDW8C8G4zLr9rp9J-ny0
parent: thread-pool; artifact: thread-pool
Puml Server ID: JSV14SCW30J0Lk82GFzq8uF6a1624IUx_UIPt-xHhMXK2TTN0zP-4pa_-UfeSSOMBzCWXbpceAxnCDZfmpUdAhjVbXO3uhPfyFw1q5oufZMdag3yFuUFl6Be5m00
parent: delegation; artifact: delegation
Puml Server ID: JSV14GCX20NGLf82LkxfXbN69OFeu2VRVdBCxRsdUhLiac6F2rZxHHHybwwuyimjKQT37ANEGMfvCpZepHy-ccpjVYm697pJuFq3DJ7f39rEWlhNaZ7Aoc5V
parent: chain; artifact: chain
Puml Server ID: 9SR13SCm20NGLTe1OkxTXX0KKzd4Wa-pVYlrdTxJN4OTMZ4U7LZv8Wg-ssdejLTgoELGHvDhaesw6HpqvWzlXwQTlYq6D3nfSlv2qjcS5F9VgvXjrHnV
parent: resource-acquisition-is-initialization; artifact: resource-acquisition-is-initialization
Puml Server ID: ZShR3S8m343HLUW0YV_PnhXMQvGumOzMOdhA1lqxkhgBABLSEQqzzeZfJm33isuIUxxIsMXei4QbqK5QdXXeyCO3oyekcvQ94MpgqD4lWB6FDEA2z4bn2HbQn8leHMponNy13hgvrhHUP_Rs0m00
parent: fluentinterface; artifact: fluentinterface
Puml Server ID: NOj93eCm302_KXv0VEzlN6F0bMCYB_3zvjpRQ3IpY97MnkNwEZD7l04SdtP8dlMfOAVBaYqRNHr4wy54Xo_Uk6uSSjWwC9FT0Zh61DYrPY_pyXs9WPF-NIllRLJN7m00
parent: service-layer; artifact: service-layer
Puml Server ID: LOl93SCm3C1MQGUmzUysgY8aAcJ5q96WszVV_aW2V8gHriRb-ZWoPxm07E--Inxrhc2dqv8jEvq3HEl6H8SFNjWs3jcjJSnaju21iG3MSmbnK_mkuwJ_qij7dpNq1m00
parent: visitor; artifact: visitor
Puml Server ID: DSR14OGm20NGLhG0mtsxmSWeJa8oyD7sTo_xJczLgoqFIM_B1Spu43c_vLHSkMU8rs4GGwcZaxPy6UnqyyFR8Q6dRPC1SGlg7B_Gew4OJeBwVqdlPMPlNm00
parent: double-dispatch; artifact: double-dispatch
Puml Server ID: NSbB3iCW303HgpG70Ezx6yTOWSeOv4zp_MRTtUZDCPGa6wV9gqTiVmCOtlKQqVDCPwEbmHgLreGXUMEWmGU_M1hxkBHiZ61JXud-1BILft1fmvz37JZetshQh3kd_000
parent: monad; artifact: monad
Puml Server ID: 9SR13SCm20NGLPe1OkxTXjWeSMMm1Pza_LRgExsjMntP97syBc35cyZvAMV7bKU6U9q6CPGwbVh8Xy5E7xvvRnBzj7qn86v1ol4BwJHk9AZ_bNGjAtLy0G00
parent: front-controller; artifact: front-controller
Puml Server ID: PSlB3OGm303HLfO24j-t6nCC13bEvC_IFk6yjz6JPgbIE3OAvS_fFkmBe7Zde_ePQnXfwU8adajlK3bkT5Iuy8Tf8wk7f87kf6BGq6R0hlD8xwQTUG9v-SCSslA8nWy0
parent: strategy; artifact: strategy
Puml Server ID: FSV13OCm30NGLM00udktCS4AGOaJsTz5tRwSkBstLiqj3WbhombC_n0PtwbKdB67Y-MX44NAerDjSJFOwE8lRuTuBRfD1iJKgRC_88SnfFn8aD-ai9vczFO7
parent: command; artifact: command
Puml Server ID: DSgn4OCm30NGLM00h3xR25i7vYpXaxx2-g59zugtTgiZcwIFvGHcV8YSdt9qdBbdYDVR88PIRwK-yc6mqyLVtff4FsoR38XRa7Aye3SgMoD1_RkaQvcfumS0
parent: abstract-factory; artifact: abstract-factory
Puml Server ID: PSZB3OD034NHLa81Czwd6sCC39gVxEUWT1_ssLmTtQLqgR5fM7sTmFGtaV6TZu8prd0r6HtQaMKqAZLk1XjT_E6qgPUZfyc0MdTgx0-8LuUn8ErFXdr98NypXxKyezKV
parent: flux; artifact: flux
Puml Server ID: 7SP14eCm20NGg-W13FlU1YFLE0GpyAazVZk-rPkRLSrDqdKwW14l8kUxx0r7hXdYzJA8eTIhKzEy6UnqyeUNJQBjjWm6n2seS_n3Ryql2UgJajxBoAu_
parent: event-aggregator; artifact: event-aggregator
Puml Server ID: PSf13iCW30NHgxG70Ezx6uTOX0eCih-JwvTzTwEdUJSjFKu9wwyBMFuXCdvoRRZY21ShKo6ANEQWrkDXiD6NRqwdUAkQ5WDYwZJOTv3SUqzSgqbbp0qeVvZ3Hbun-Wy0
parent: singleton; artifact: singleton
Puml Server ID: HSV14SCm20J0Lk82BFxf1ikCh0n26ZZizfDVVhjRjwfvIhg-Bc35cyZvAQtZoYD3l4w364gTWxhcms2d3z-ydnAzsRuO4BUWmV43HRUcWcaagF-Lz55M3lq2
parent: null-object; artifact: null-object
Puml Server ID: JSV14SCm20J0Lk829Fxf1cF6bWSX3JhYzfDdVhjRSx4yDCDU5p3NcoZugMV3bNik3HaETLGPdPhbm-2WcpzS3btjz38PqF15dTSFv6bMndwhW1Jo_vhHwynkNm00
parent: multiton; artifact: multiton
Puml Server ID: FST14i8m20NGg-W16lRUXgPCYnD81Zxs-hfozzvJlOywf68yBc3bYoZuRgVYghrIea-7E5gVHZhgPd3Gcp-y7P9w-hOOaF0au_o1h0OKqqdG_saLrbRP-080
parent: composite; artifact: composite
Puml Server ID: HSf13eCm30NHgy01YFUzZGaM62LEP7-NwvTTT_EaMTLgoqFIst81Cpv4payv5LVk6U9r6CHGwkYaBHy6EztyvUsGqDEsoO2u1NMED-WTvmY5aA3-LT9xcTdR3m00
parent: api-gateway; artifact: image-microservice
Puml Server ID: 3Sp13SCm2030LTe1RFxTXX3aK1biOOZLxPlVlUujHZrFJk-lAsAk3u3ZhatYoYCNEmqBjgWq5AJdna27BzvOJbxIh4oCOBS5Yki1u9JIC7ZZ3pW8HB5nKI4VJtSBSKtNEbFx7m00
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/image-microservice.urm.puml'
pumlid: 3Sp13SCm2030LTe1RFxTXX3aK1biOOZLxPlVlUujHZrFJk-lAsAk3u3ZhatYoYCNEmqBjgWq5AJdna27BzvOJbxIh4oCOBS5Yki1u9JIC7ZZ3pW8HB5nKI4VJtSBSKtNEbFx7m00
parent: api-gateway; artifact: api-gateway-service
Puml Server ID: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/api-gateway-service.urm.puml'
pumlid: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
parent: api-gateway; artifact: price-microservice
Puml Server ID: 3Sn13iGW243HgqmFeEpdDfGIoqJK8DJqzkFklyq_f56DYyFgvtOVymjWk78Hl-ECoKQzEJVFr1Mana97Wny-c2wUKbeQwCxM9YZE7O13Ka7dXI-m4mmJugH2rlVksSXXcaTe_GC0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'api-gateway/etc/price-microservice.urm.puml'
pumlid: 3Sn13iGW243HgqmFeEpdDfGIoqJK8DJqzkFklyq_f56DYyFgvtOVymjWk78Hl-ECoKQzEJVFr1Mana97Wny-c2wUKbeQwCxM9YZE7O13Ka7dXI-m4mmJugH2rlVksSXXcaTe_GC0
parent: object-pool; artifact: object-pool
Puml Server ID: JSV94SCm2030Lk829Fxf1cF6bWU1XYDkFtdcjxiD9Qc3o-LrPQvu0pW-_HnvrLx1JgR9cfrimf1wCD7XnW-sWsESsXPcicl0nFW1RB-PiYqp0KxwVo-VVTMKBm00
parent: adapter; artifact: adapter
Puml Server ID: DSR14S8m30J0Lg20M7-wEMnDOiPMFDA9j0yyUEtUkzMHJTF7xI1NF4GSLzaxZtncgDVJgCPIpobzv0N2vOKtjgRHTziMI7KBcOXl10thfxB-Nz9dMJd71m00
parent: hexagonal; artifact: hexagonal
Puml Server ID: HSTB4W8X30N0g-W1XkozpPD90LO8L3wEnzUTk-xxq2fvSfhSUiJs1v7XAcr4psSwMrqQh57gcZGaBmICNdZZEDb7qsCZWasT9lm7wln1MmeXZlfVIPjbvvGl
parent: value-object; artifact: value-object
Puml Server ID: LSZ13SCm20NGLTe1RExTXX2KECBOmfza_VRQszDxDnVBNJFiTG9pVOY2dteqdBdbqf3XK4ULqQbPFWmEklZcikjgXvV9W8Olwhn-e9ijjOpjKW4fv2zgHgypktq1
parent: twin; artifact: twin
Puml Server ID: 7SR13OCm30NGLUW0n7UsCS42eyH4zdUpFbNVwNtKQij3qjjo0ICs8kTPJiMLUuPuVGnYAFNff2qdWvrk_l9wIEXfws10t88wno-4gKQ2-az9xsLaRoy0
parent: semaphore; artifact: semaphore
Puml Server ID: HSV14SCm20J0Lk82BFxf1ikCfOn06ZZizfDVVhjRjphobFJnQi2ADv7pKwwEbaU6U9q6CPGwbVh8Xy5E7xvvFoNwPVjYGDo2bEC72b5URRgGeFvNqhMirF45
parent: message-channel; artifact: message-channel
Puml Server ID: NSZB3SCm203GLTe1RExTXX1akm9YyMdMRy-zFRtdCf8wkLmUCtF72y3nxcFbhAE2dIvBjknqAIof6nCTtlZ1TdAiOMrZ9hi5ACOFe1o1WnjDD6C1Jlg_NgvzbyeN
parent: poison-pill; artifact: poison-pill
Puml Server ID: JSZ14SCm20NHLf82BExfXiYCJGOX3NpYzkDZRllsgTwjTgcmnmciV145N-rGdFMkbEZJ8OxMvo2rkXWSzE4lRxka7huj1YGyQN3UGMjgpdkh6Gdwlrl5QAk6_G00
parent: aggregator-microservices; artifact: aggregator-service
Puml Server ID: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/aggregator-service.urm.puml'
pumlid: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
parent: aggregator-microservices; artifact: information-microservice
Puml Server ID: LSnB3i8m303Hgy016k-vZN5DQXGxaJ_jzUcMtKXFcgSOZTgvV3oEp1Kl0CUhTScZtXNiD2tPij5Ka54N9ZfyySHjvv1ksy9CTWjGZ3i0UtVkcDCt5V9vFquX3k0a4FjCLqoPzgUjNDig7Jy0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/information-microservice.urm.puml'
pumlid: LSnB3i8m303Hgy016k-vZN5DQXGxaJ_jzUcMtKXFcgSOZTgvV3oEp1Kl0CUhTScZtXNiD2tPij5Ka54N9ZfyySHjvv1ksy9CTWjGZ3i0UtVkcDCt5V9vFquX3k0a4FjCLqoPzgUjNDig7Jy0
parent: aggregator-microservices; artifact: inventory-microservice
Puml Server ID: LSpB3G8n303HLg20ZUzqOxnMrYXn8d-oedjovJRIIEyfIYrFJckFAsBw2y3mBbNYodSw6mqDrYWqEaZB6mCDFhZmEDcbwZ4nWaqTEleEm5gDAyQmemlPsCOIOWSE0j6riM7VlrVIUfdPsmy0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'aggregator-microservices/etc/inventory-microservice.urm.puml'
pumlid: LSpB3G8n303HLg20ZUzqOxnMrYXn8d-oedjovJRIIEyfIYrFJckFAsBw2y3mBbNYodSw6mqDrYWqEaZB6mCDFhZmEDcbwZ4nWaqTEleEm5gDAyQmemlPsCOIOWSE0j6riM7VlrVIUfdPsmy0
parent: bridge; artifact: bridge
Puml Server ID: BSR14SCm20J0Lf82BFxf1akCJ4R26ZZYzkE7zxLljJgoIVfu7S2A3v7pLRhYo3r3l9u6CPHwJjAH5uETllpZhKbejsqn86v1a-CExQwj2mdgqv8-oyev_W00
parent: servant; artifact: servant
Puml Server ID: DSkn4O0m20NGLNG0G-ys63cDbv0SV7HzRUnUy-QYkSOkONKwWU4haV6JZe8pjd2nt1MYIBatAZKU1XjTVFEoYvT3by60c3erzW_qdPiL9CY_KrXB8rfz0G00
parent: lazy-loading; artifact: lazy-loading
Puml Server ID: LSXB3W8X303Gg-W1e7jlqu66gIc5zED4JwzRTo_lpjeaEwN9xOpO_W0mlEhWEFD89sjBWpHgMnDOyi90WoU-i7Ho7besHf2fmqJ_0GG_xo8BE-i0YlONDMtMdLE-
parent: flyweight; artifact: flyweight
Puml Server ID: HSV94S8m3030Lg20M7-w4OvYAoCh7Xtnq3ty-Eq-MQlaJcdow17JNm26gpIEdkzqidffa4Qfrm2MN1XeSEADsqxEJRU94MJgCD1_W4C-YxZr08hwNqaRPUQGBm00
parent: mutex; artifact: mutex
Puml Server ID: 9SR13OCm30NGLSe0n7UsCS62LB69x6zWV2hrdTxKhFRS9Br_3c34GkHybxtXo3L3l9u6CPHwAhMUDuETldpnl4cqtUR1WBW5ASSlf0bvI53_A-bQHcf_0G00
parent: mediator; artifact: mediator
Puml Server ID: FSV14SCm20J0Lk82BFxf1akCJKOW3JhizfDNVhkRUktP9AE_Bc2kDr7mKqx5bKSkYJeSuYXr66dFXy517xvvRxBqz7qo8E6BZDSFPDAKCO84zP-IOMMczIy0
parent: page-object; artifact: page-object
Puml Server ID: JSV14OGW30NGLjO28FVj9iOCua1Wme-sxnxtzjvMJLeS6ju-9p3NbyZvoQNYZ3sMkWo36hACJhN5ms2dYszEXwvQB4q6r6rHv_K3JIwQndwfW1Jo_npUyupUNW00
parent: factory-kit; artifact: factory-kit
Puml Server ID: JST15i8m20N0g-W14lRU1YcsQ4BooCS-RwzBTpDNSscvQKQx7C1SDwBWi-w68--vD6Gur55bTBAM9uE3dlpcikcotSjaGCCNTLu_q8C58pxbPI25_Bzcz3gpjoy0
parent: property; artifact: property
Puml Server ID: FSV13OCm30NGLTe1YEziumOBKYMEPN-3s9wUUdlltRJst2Izlmx0OYLolihUSEGdGxnEXIXAdODQpul1Jby-UTaasgwBCI2kGOFZ1pAV9ewR1FMVaZwAvUWF
parent: dependency-injection; artifact: dependency-injection
Puml Server ID: RSdB3SCW303GLPe1mFTkunWhSGG6-PEesxS3zFQajubIpyPf_NL6B7y363xra3XpJsUZgS4QbUO0wVbWeC65DvR6BeUMXH5iwZ3GVu36YxMnqgU8NamXKu63_aPD6tNbw5y0
parent: layers; artifact: layers
Puml Server ID: BSR13OCm30NGLSe0n7UsCS62L8w9x6yGszD3t-bDpQhc9kdwEO0H2v7pNVQ68zSCyNeQn53gsQbftWns-lB5yoRHTfi70-8Mr3b-8UL7F4XG_otflOpi-W80
parent: producer-consumer; artifact: producer-consumer
Puml Server ID: PSjB3iCW303HgxG70Ezx6zTO2HKso9_a-c7VtUX9y-vA8nkdZTSPiVm3O7ZNeyUPttGscXgiKMaAz94t1XhyyCBIsFkXPM44cpe8-WvODbiIMzcdfspXe7-jQL9NodW0
parent: builder; artifact: builder
Puml Server ID: DSR94O0m2030LhG0mzzkC64KXs26GzlNZw_TcRLADagJwOWOlW8OFcNdE79B9wkN1ccKUdLWoGS33KwySMdalEioC89C7Jhw5zYIfNrIrFybhPUHNLu0
parent: specification; artifact: specification
Puml Server ID: LSX14i8m20NGg-W16lRU1YcsE0d9mCTUNxVkthoxkVJQjQBVJc3bWoZuQeVXh6UbXao7EfhCGTRhOd3Gcp-yxPfs-BOOqF2amVa3vLAnbmd3ffD2_gTLZBPgz2y0
parent: state; artifact: state
Puml Server ID: 9SRH3O0m20N0LNG0ox_RO2LQqz867hg-9jxNpKLpZLt2wdG2mrSYuoST1MTiuMAvAqIHSczKQZmCDhhuvcKNBuSkWm4nTMhiNyZ141BaVocifH6jlW00
parent: reader-writer-lock; artifact: reader-writer-lock
Puml Server ID: RSZB4S8m303HLg00MtUw4R8cCP5bZpwuVL80jttxx4gIZTFaSKOiVm4OxdhqEFETpaPJWpKgpG5TScEWmGU_M1fxFxGiZ61JXu5-1nXZOolR-gqYaoxWe3-xfeswSiWF
parent: interpreter; artifact: interpreter
Puml Server ID: JSf13eCm30NHgz034E-vZGaM62Kcih_BzQ6xxjv8yr6hBJT9RzC1Z5Y8dE-oAuvSCyJhPH13gLSdRNapsEdaBy-RXEus3mR4BQXpl21zVnykFmlgVvVqNaRszW00
parent: template-method; artifact: template-method
Puml Server ID: NSZ13SCW30NGLPe1mFTkuu0Lg6n0vZjPlpttzlIEFef6bN1zDM3jDv7paw-E5cTiyJ87P22NQTGr7WOxVVZcL6NtQwJ5WFZOPBn_88WjPKWoGPkL1EN_ShZb5QPV
parent: feature-toggle; artifact: feature-toggle
Puml Server ID: NSZ14G8X30NGLhG0oDrk8XjPd12OvCTjNy_UthpxiAPvIBhUJc37WyZvgdtWp6U6U5i6CTIs9WtDYy5ER_vmEIH6jx8P4BUWoV43lOIHBWMhTnKIjB-gwRFkdFe5
parent: business-delegate; artifact: business-delegate
Puml Server ID: POl13SCm3CHMQGU8zUysgYCuBcJ5a4x9-l6_Fu84tzsgvYxf-Zg06HyYvxkqZYE_6UBrD8YXr7DGrxmPxFJZYxTTeZVR9WFY5ZGu5j2wkad4wYgD8IIe_xQaZp9pw0C0
parent: naked-objects; artifact: naked-objects-integtests
Puml Server ID: LSmn4iCW30NHgoG70FMvZGmQ6ni48tt5ru_RT3kls7VJqgDAM7yTmF8FaV6TzuOZjd2nCXMYo6KEQZrk1XkT_ELKnTkkQJ4Wfaw3_GbIlgIckPrIu2Ge_vBQyziX3izX8wyO_GS0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-integtests.urm.puml'
pumlid: LSmn4iCW30NHgoG70FMvZGmQ6ni48tt5ru_RT3kls7VJqgDAM7yTmF8FaV6TzuOZjd2nCXMYo6KEQZrk1XkT_ELKnTkkQJ4Wfaw3_GbIlgIckPrIu2Ge_vBQyziX3izX8wyO_GS0
parent: naked-objects; artifact: naked-objects-dom
Puml Server ID: LSZ94SCW3030Lf82G7zt8mkDZOC4eyDkF_dcjxFlhZIoSTfudH7BDm33fnuzpjpJsMXgi4QbAT17FXXeSE6DfR7tGyl223Pr4FGVGF73hSpzOWe73lgVqgRKDAahPNm1
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-dom.urm.puml'
pumlid: LSZ94SCW3030Lf82G7zt8mkDZOC4eyDkF_dcjxFlhZIoSTfudH7BDm33fnuzpjpJsMXgi4QbAT17FXXeSE6DfR7tGyl223Pr4FGVGF73hSpzOWe73lgVqgRKDAahPNm1
parent: naked-objects; artifact: naked-objects-fixture
Puml Server ID: LSX15i8W30N0g-W187jlaq9igH1uoO_r-BfrDs_kJKkFAc7zTW3B7qJ6LzuRZjZ2nSfKY2ANEQZrk1XiTFARKnLlkwR5W9Ww3VOVIFabDStjb08dGVcVz6mVX4aE6td5w5y0
I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file 'naked-objects/etc/naked-objects-fixture.urm.puml'
pumlid: LSX15i8W30N0g-W187jlaq9igH1uoO_r-BfrDs_kJKkFAc7zTW3B7qJ6LzuRZjZ2nSfKY2ANEQZrk1XiTFARKnLlkwR5W9Ww3VOVIFabDStjb08dGVcVz6mVX4aE6td5w5y0
parent: model-view-controller; artifact: model-view-controller
Puml Server ID: ROl13SCm201NQGUm-NSRQgE42h258Lw_wR-_qvtkoTOaEwNBuuoOwmNWkEl1SUOx5taR5cHHsr1WoOs13X-yi7HQV5YP645k2nJN3Q2ZavIBQPVVwqFajXJjVwdfMcUgV040
parent: proxy; artifact: proxy
Puml Server ID: 9SR13OCm30NGLM00udktCS62eCI9x6yesrEfx_Jcehd69c5rEe3X7oBZE-q5HwpXOhahH95oRrHgt0msEldYPHClkow30J5rQko_qB3-VKYG_qjXBOrezGK0
parent: memento; artifact: memento
Puml Server ID: DSgn4OCm30NGLM00h3xR2AC3SvRiaxx2-g59zugtDgiz3qdlomNC-10vF-Lik7BF4A_388PIXrBh-J3OwUOlRuT4EssR38XRa7Ay81Lz_o11_RkaQvcf_GS0
parent: decorator; artifact: decorator
Puml Server ID: HSV14SCm20J0Lk82BFxf1YF6LaP26ZZizfDVVhjRC-bPDRs_Bc35cyZvAMV3bKU6kao36ehCGQtdms2d3z-yLursshuOKBUWmV43LPNfZEcaaFzA-YWhH_y2
parent: data-mapper; artifact: data-mapper
Puml Server ID: JShB3OGm303HLg20nFVjnYGM1CN6ycTfVtFSsnjfzY5jPgUqkLqHwXy0mxUU8wuyqidQ8q4IjJqCO-QBWGOtVh5qyd5AKOmW4mT6Nu2-ZiAekapH_hkcSTNa-GC0
parent: caching; artifact: caching
Puml Server ID: DSRB4OKm2030LhG0m_rrWyWaE0bc-6ZxpujxsbMKUXwSrfSMCVq7OFYKAj5oJsUZIuCr2bq3fEU3WGOdthWTx59rcnZ1fWu3_GqGKXEjm47VIzeeCqV_0m00
parent: reactor; artifact: reactor
Puml Server ID: DSR14OGm20NGLjO23FVj1f7Hx2Ga0nzjVxtuJc-f9YrtJM-V4vZn9NA-or5nvfQXBiEWXYAZKsrvCzZfnnUlkqOzR9qCg5jGvtX2hYmOJWfvNz9xcTdR7m00
parent: iterator; artifact: iterator
Puml Server ID: FSV13OGm30NHLg00uljsOu85HeaJsTzB-yjfBwCtgrfjUKXwMovWneV8-IcduiezGxmEWnXA7PsqvSDWfvk_l1qIUjes6H2teCxnWlGDOpW9wdzAUYypU_i1
parent: callback; artifact: callback
Puml Server ID: FSVB4S8m30N0Lg20M7UwUL4qYOciUFGXxSE9s-wp6sjjKgwF8tF6YyXnjxtdKMk5E5-MOjdu6jIrRYIStlXWsIJwRij4fhW53SGFn51TmIT9yZ-jVBHPGxy0
parent: repository; artifact: repository
Puml Server ID: JSV13OCm30NGLM00udktCS42eyI9xE-YRjyUUtjlLQij3qblomNCU14vF-LKNBbdYDTX44EfevEsV1ZiTFERjqD2Jzic0-8Mr3b-89SvGZ7yGuBwrvBUoypUlW00
parent: mute-idiom; artifact: mute-idiom
Puml Server ID: JSf13iCm20NHgxG7iDdtDjH62PKX5luarq-MtSsJvgtUHdR96AyTcEj357pLJR7dDvT4EnpYgEqmqf4NWuD-V7BfidJpCXcGy4N6wmcoX1Jj-lo2ziUQONMcZHi0
parent: prototype; artifact: prototype
Puml Server ID: HSV13OCm30NGLM00udktCS62eCInxE-YRj_UUdjlRLfx7fBUbmkmU14vF-Lik7BF4AzJ8OfIvw3Mys6mqyrltWw9Tkfc38XhqE3uWSmd9Zuc9AZ_bVHHB4V_0W00
parent: step-builder; artifact: step-builder
Puml Server ID: LOZ93SCm3C1MQGQmzUysYYqaAcJ5q96i7t_x8KXkh4soKvfypeZfNm33fnuSP-xfPEtI88tQhW4i-M2WmGzlB9sS3oqJ8yZKOQ0lWOLPzcJfAoZQtwXfeyuSyW80
parent: double-checked-locking; artifact: double-checked-locking
Puml Server ID: TSdH4SCW203GLTe1bFzkGv1J6qGFeLc_MI1_x-wzkv94uJ1vDVUrFm26LwxTMnonsMYgitgcEQ1BNEXeyCKVfiAxLqqBtTbqmy1z0ygCGpXHOpgv99bqTgt0JW-LmqPUCUGF

View File

@ -0,0 +1,67 @@
#
# The MIT License
# 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
# 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 requests, glob, re, os
# taken from here: http://stackoverflow.com/a/13641746
def replace(file, pattern, subst):
# Read contents from file as a single string
file_handle = open(file, 'r')
file_string = file_handle.read()
file_handle.close()
# Use RE package to allow for replacement (also allowing for (multiline) REGEX)
file_string = (re.sub(pattern, subst, file_string))
# Write contents to file.
# Using mode 'w' truncates the file.
file_handle = open(file, 'w')
file_handle.write(file_string)
file_handle.close()
# list of all puml files
fileList = glob.glob('*/etc/*.puml')
for puml in fileList:
pathSplit = puml.split("/")
# parent folder
parent = pathSplit[0]
# individual artifact/project name
artifact = pathSplit[2].replace(".urm.puml", "")
print "parent: " + parent + "; artifact: " + artifact
# do a POST to the official plantuml hosting site with a little trick "!includeurl" and raw github content
data = {
'text': "!includeurl https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/" + puml
}
r = requests.post('http://plantuml.com/plantuml/uml', data=data)
pumlId = r.url.replace("http://plantuml.com/plantuml/uml/", "")
# the only thing needed to get a png/svg/ascii from the server back
print "Puml Server ID: " + pumlId
# add the id so jekyll/liquid can use it
if (parent == artifact):
replace("./" + parent + "/README.md", "categories:", "pumlid: {}\\ncategories:".format(pumlId))
else:
print "I dont want to program this, just add the following lines to the README.md file that corresponds to this puml file '" + puml + "'\npumlid: {}".format(pumlId)

View File

@ -0,0 +1,32 @@
---
layout: pattern
title: Abstract Document
folder: abstract-document
permalink: /patterns/abstract-document/
pumlid: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
categories: Structural
tags:
- Java
- Difficulty-Intermediate
---
## Intent
Achieve flexibility of untyped languages and keep the type-safety
![alt text](./etc/abstract-document-base.png "Abstract Document Base")
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")
## Applicability
Use the Abstract Document Pattern when
* there is a need to add new properties on the fly
* you want a flexible way to organize domain in tree like structure
* you want more loosely coupled system
## Credits
* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="249" y="405"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="2" language="java" name="com.iluwatar.abstractdocument.AbstractDocument" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/AbstractDocument.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="250" y="237"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="108" y="75"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="4" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="400" y="76"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<generalization id="5">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="2"/>
</generalization>
<realization id="6">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="1"/>
</realization>
<generalization id="7">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="2"/>
</generalization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="341" y="376"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="2" language="java" name="com.iluwatar.abstractdocument.domain.HasModel" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasModel.java" binary="false" corner="BOTTOM_RIGHT">
<position height="81" width="173" x="41" y="194"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="3" language="java" name="com.iluwatar.abstractdocument.domain.HasPrice" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasPrice.java" binary="false" corner="BOTTOM_RIGHT">
<position height="81" width="175" x="254" y="194"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="4" language="java" name="com.iluwatar.abstractdocument.domain.HasParts" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasParts.java" binary="false" corner="BOTTOM_RIGHT">
<position height="81" width="173" x="469" y="194"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="5" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="173" x="254" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="6" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="173" x="41" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<realization id="7">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="2"/>
</realization>
<realization id="8">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="2"/>
</realization>
<generalization id="9">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="1"/>
</generalization>
<realization id="10">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="3"/>
</realization>
<realization id="11">
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="4"/>
</realization>
<generalization id="12">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</generalization>
<generalization id="13">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="1"/>
</generalization>
<realization id="14">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="3"/>
</realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

View File

@ -0,0 +1,59 @@
@startuml
package com.iluwatar.abstractdocument.domain {
class Car {
+ Car(properties : Map<String, Object>)
}
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 {
abstract class AbstractDocument {
- properties : Map<String, Object>
# AbstractDocument(properties : Map<String, Object>)
+ children(key : String, constructor : Function<Map<String, Object>, T>) : Stream<T>
+ get(key : String) : Object
+ 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 ..|> Document
Car ..|> HasModel
Car ..|> HasPrice
Car ..|> HasParts
Car --|> AbstractDocument
HasModel --|> Document
HasParts --|> Document
HasPrice --|> Document
HasType --|> Document
Part ..|> HasType
Part ..|> HasModel
Part ..|> HasPrice
Part --|> AbstractDocument
@enduml

42
abstract-document/pom.xml Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,72 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Abstract implementation of Document interface
*/
public abstract class AbstractDocument implements Document {
private final Map<String, Object> properties;
protected AbstractDocument(Map<String, Object> properties) {
Objects.requireNonNull(properties, "properties map is required");
this.properties = properties;
}
@Override
public Void put(String key, Object value) {
properties.put(key, value);
return null;
}
@Override
public Object get(String key) {
return properties.get(key);
}
@Override
public <T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor) {
Optional<List<Map<String, Object>>> any = Stream.of(get(key)).filter(el -> el != null)
.map(el -> (List<Map<String, Object>>) el).findAny();
return any.isPresent() ? any.get().stream().map(constructor) : Stream.empty();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getName()).append("[");
properties.entrySet()
.forEach(e -> builder.append("[").append(e.getKey()).append(" : ").append(e.getValue()).append("]"));
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,91 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import com.iluwatar.abstractdocument.domain.Car;
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;
import java.util.Map;
/**
* The Abstract Document pattern enables handling additional, non-static
* properties. This pattern uses concept of traits to enable type safety and
* separate properties of different classes into set of interfaces.
* <p>
* <p>
* In Abstract Document pattern,({@link AbstractDocument}) fully implements
* {@link Document}) interface. Traits are then defined to enable access to
* properties in usual, static way.
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Executes the App
*/
public App() {
LOGGER.info("Constructing parts and car");
Map<String, Object> carProperties = new HashMap<>();
carProperties.put(HasModel.PROPERTY, "300SL");
carProperties.put(HasPrice.PROPERTY, 10000L);
Map<String, Object> wheelProperties = new HashMap<>();
wheelProperties.put(HasType.PROPERTY, "wheel");
wheelProperties.put(HasModel.PROPERTY, "15C");
wheelProperties.put(HasPrice.PROPERTY, 100L);
Map<String, Object> doorProperties = new HashMap<>();
doorProperties.put(HasType.PROPERTY, "door");
doorProperties.put(HasModel.PROPERTY, "Lambo");
doorProperties.put(HasPrice.PROPERTY, 300L);
carProperties.put(HasParts.PROPERTY, Arrays.asList(wheelProperties, doorProperties));
Car car = new Car(carProperties);
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()));
}
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
new App();
}
}

View File

@ -0,0 +1,59 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Stream;
/**
* Document interface
*/
public interface Document {
/**
* Puts the value related to the key
*
* @param key element key
* @param value element value
* @return Void
*/
Void put(String key, Object value);
/**
* Gets the value for the key
*
* @param key element key
* @return value or null
*/
Object get(String key);
/**
* Gets the stream of child documents
*
* @param key element key
* @param constructor constructor of child class
* @return child documents
*/
<T> Stream<T> children(String key, Function<Map<String, Object>, T> constructor);
}

View File

@ -0,0 +1,38 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import java.util.Map;
import com.iluwatar.abstractdocument.AbstractDocument;
/**
* Car entity
*/
public class Car extends AbstractDocument implements HasModel, HasPrice, HasParts {
public Car(Map<String, Object> properties) {
super(properties);
}
}

View File

@ -0,0 +1,40 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import java.util.Optional;
import com.iluwatar.abstractdocument.Document;
/**
* HasModel trait for static access to 'model' property
*/
public interface HasModel extends Document {
String PROPERTY = "model";
default Optional<String> getModel() {
return Optional.ofNullable((String) get(PROPERTY));
}
}

View File

@ -0,0 +1,40 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import java.util.stream.Stream;
import com.iluwatar.abstractdocument.Document;
/**
* HasParts trait for static access to 'parts' property
*/
public interface HasParts extends Document {
String PROPERTY = "parts";
default Stream<Part> getParts() {
return children(PROPERTY, Part::new);
}
}

View File

@ -0,0 +1,40 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import java.util.Optional;
import com.iluwatar.abstractdocument.Document;
/**
* HasPrice trait for static access to 'price' property
*/
public interface HasPrice extends Document {
String PROPERTY = "price";
default Optional<Number> getPrice() {
return Optional.ofNullable((Number) get(PROPERTY));
}
}

View File

@ -0,0 +1,40 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import com.iluwatar.abstractdocument.Document;
import java.util.Optional;
/**
* HasType trait for static access to 'type' property
*/
public interface HasType extends Document {
String PROPERTY = "type";
default Optional<String> getType() {
return Optional.ofNullable((String) get(PROPERTY));
}
}

View File

@ -0,0 +1,38 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument.domain;
import java.util.Map;
import com.iluwatar.abstractdocument.AbstractDocument;
/**
* Part entity
*/
public class Part extends AbstractDocument implements HasType, HasModel, HasPrice {
public Part(Map<String, Object> properties) {
super(properties);
}
}

View File

@ -0,0 +1,88 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
/**
* AbstractDocument test class
*/
public class AbstractDocumentTest {
private static final String KEY = "key";
private static final String VALUE = "value";
private class DocumentImplementation extends AbstractDocument {
DocumentImplementation(Map<String, Object> properties) {
super(properties);
}
}
private DocumentImplementation document = new DocumentImplementation(new HashMap<>());
@Test
public void shouldPutAndGetValue() {
document.put(KEY, VALUE);
assertEquals(VALUE, document.get(KEY));
}
@Test
public void shouldRetrieveChildren() {
Map<String, Object> child1 = new HashMap<>();
Map<String, Object> child2 = new HashMap<>();
List<Map<String, Object>> children = Arrays.asList(child1, child2);
document.put(KEY, children);
Stream<DocumentImplementation> childrenStream = document.children(KEY, DocumentImplementation::new);
assertNotNull(children);
assertEquals(2, childrenStream.count());
}
@Test
public void shouldRetrieveEmptyStreamForNonExistingChildren() {
Stream<DocumentImplementation> children = document.children(KEY, DocumentImplementation::new);
assertNotNull(children);
assertEquals(0, children.count());
}
@Test
public void shouldIncludePropsInToString() {
Map<String, Object> props = new HashMap<>();
props.put(KEY, VALUE);
DocumentImplementation document = new DocumentImplementation(props);
assertNotNull(document.toString().contains(KEY));
assertNotNull(document.toString().contains(VALUE));
}
}

View File

@ -0,0 +1,37 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import org.junit.Test;
/**
* Simple App test
*/
public class AppTest {
@Test
public void shouldExecuteAppWithoutException() {
App.main(null);
}
}

View File

@ -0,0 +1,77 @@
/**
* The MIT License
* 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
* 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:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* 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.
*/
package com.iluwatar.abstractdocument;
import com.iluwatar.abstractdocument.domain.Car;
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 com.iluwatar.abstractdocument.domain.Part;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.TestCase.assertEquals;
/**
* Test for Part and Car
*/
public class DomainTest {
private static final String TEST_PART_TYPE = "test-part-type";
private static final String TEST_PART_MODEL = "test-part-model";
private static final long TEST_PART_PRICE = 0L;
private static final String TEST_CAR_MODEL = "test-car-model";
private static final long TEST_CAR_PRICE = 1L;
@Test
public void shouldConstructPart() {
Map<String, Object> partProperties = new HashMap<>();
partProperties.put(HasType.PROPERTY, TEST_PART_TYPE);
partProperties.put(HasModel.PROPERTY, TEST_PART_MODEL);
partProperties.put(HasPrice.PROPERTY, TEST_PART_PRICE);
Part part = new Part(partProperties);
assertEquals(TEST_PART_TYPE, part.getType().get());
assertEquals(TEST_PART_MODEL, part.getModel().get());
assertEquals(TEST_PART_PRICE, part.getPrice().get());
}
@Test
public void shouldConstructCar() {
Map<String, Object> carProperties = new HashMap<>();
carProperties.put(HasModel.PROPERTY, TEST_CAR_MODEL);
carProperties.put(HasPrice.PROPERTY, TEST_CAR_PRICE);
carProperties.put(HasParts.PROPERTY, Arrays.asList(new HashMap<>(), new HashMap<>()));
Car car = new Car(carProperties);
assertEquals(TEST_CAR_MODEL, car.getModel().get());
assertEquals(TEST_CAR_PRICE, car.getPrice().get());
assertEquals(2, car.getParts().count());
}
}

View File

@ -3,31 +3,37 @@ layout: pattern
title: Abstract Factory
folder: abstract-factory
permalink: /patterns/abstract-factory/
pumlid: PSZB3OD034NHLa81Czwd6sCC39gVxEUWT1_ssLmTtQLqgR5fM7sTmFGtaV6TZu8prd0r6HtQaMKqAZLk1XjT_E6qgPUZfyc0MdTgx0-8LuUn8ErFXdr98NypXxKyezKV
categories: Creational
tags:
tags:
- Java
- Gang Of Four
- Difficulty-Intermediate
---
**Also known as:** Kit
## Also known as
Kit
**Intent:** Provide an interface for creating families of related or dependent
## Intent
Provide an interface for creating families of related or dependent
objects without specifying their concrete classes.
![alt text](./etc/abstract-factory_1.png "Abstract Factory")
**Applicability:** Use the Abstract Factory pattern when
## Applicability
Use the Abstract Factory pattern when
* a system should be independent of how its products are created, composed and represented
* a system should be configured with one of multiple families of products
* a family of related product objects is designed to be used together, and you need to enforce this constraint
* you want to provide a class library of products, and you want to reveal just their interfaces, not their implementations
**Real world examples:**
## Real world examples
* [javax.xml.parsers.DocumentBuilderFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html)
* [javax.xml.transform.TransformerFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)
* [javax.xml.xpath.XPathFactory](http://docs.oracle.com/javase/8/docs/api/javax/xml/xpath/XPathFactory.html#newInstance--)
**Credits**
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)

View File

@ -0,0 +1,89 @@
@startuml
package com.iluwatar.abstractfactory {
class App {
- LOGGER : Logger {static}
- army : Army
- castle : Castle
- king : King
+ App()
+ createKingdom(factory : KingdomFactory)
+ getArmy() : Army
~ getArmy(factory : KingdomFactory) : Army
+ getCastle() : Castle
~ getCastle(factory : KingdomFactory) : Castle
+ getKing() : King
~ getKing(factory : KingdomFactory) : King
+ main(args : String[]) {static}
- setArmy(army : Army)
- setCastle(castle : Castle)
- setKing(king : 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
}
class OrcKing {
~ DESCRIPTION : String {static}
+ OrcKing()
+ getDescription() : String
}
class OrcKingdomFactory {
+ OrcKingdomFactory()
+ createArmy() : Army
+ createCastle() : Castle
+ createKing() : King
}
}
App --> "-castle" Castle
App --> "-king" King
App --> "-army" Army
ElfArmy ..|> Army
ElfCastle ..|> Castle
ElfKing ..|> King
ElfKingdomFactory ..|> KingdomFactory
OrcArmy ..|> Army
OrcCastle ..|> Castle
OrcKing ..|> King
OrcKingdomFactory ..|> KingdomFactory
@enduml

View File

@ -1,11 +1,35 @@
<?xml version="1.0"?>
<!--
The MIT License
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
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.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.9.0</version>
<version>1.15.0</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>

View File

@ -1,5 +1,30 @@
/**
* The MIT License
* 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
* 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.
*/
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
@ -17,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;
@ -30,14 +57,6 @@ public class App {
setArmy(factory.createArmy());
}
ElfKingdomFactory getElfKingdomFactory() {
return new ElfKingdomFactory();
}
OrcKingdomFactory getOrcKingdomFactory() {
return new OrcKingdomFactory();
}
King getKing(final KingdomFactory factory) {
return factory.createKing();
}
@ -84,21 +103,17 @@ public class App {
App app = new App();
System.out.println("Elf Kingdom");
KingdomFactory elfKingdomFactory;
elfKingdomFactory = app.getElfKingdomFactory();
app.createKingdom(elfKingdomFactory);
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info("Elf Kingdom");
app.createKingdom(new ElfKingdomFactory());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
System.out.println("\nOrc Kingdom");
KingdomFactory orcKingdomFactory;
orcKingdomFactory = app.getOrcKingdomFactory();
app.createKingdom(orcKingdomFactory);
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info("Orc Kingdom");
app.createKingdom(new OrcKingdomFactory());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
}

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
/**

View File

@ -0,0 +1,103 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
/**
* Test for abstract factory
*/
public class AbstractFactoryTest {
private App app = new App();
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;
@Before
public void setUp() {
elfFactory = new ElfKingdomFactory();
orcFactory = new OrcKingdomFactory();
}
@Test
public void king() {
final King elfKing = app.getKing(elfFactory);
assertTrue(elfKing instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
final King orcKing = app.getKing(orcFactory);
assertTrue(orcKing instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
}
@Test
public void castle() {
final Castle elfCastle = app.getCastle(elfFactory);
assertTrue(elfCastle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
final Castle orcCastle = app.getCastle(orcFactory);
assertTrue(orcCastle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
}
@Test
public void army() {
final Army elfArmy = app.getArmy(elfFactory);
assertTrue(elfArmy instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
final Army orcArmy = app.getArmy(orcFactory);
assertTrue(orcArmy instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
}
@Test
public void createElfKingdom() {
app.createKingdom(elfFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, army.getDescription());
}
@Test
public void createOrcKingdom() {
app.createKingdom(orcFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, army.getDescription());
}
}

View File

@ -1,78 +1,38 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.abstractfactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
/**
* Tests that Abstract Factory example runs without errors.
*/
public class AppTest {
private App app = new App();
private KingdomFactory elfFactory;
private KingdomFactory orcFactory;
@Before
public void setUp() {
elfFactory = app.getElfKingdomFactory();
orcFactory = app.getOrcKingdomFactory();
}
@Test
public void king() {
final King elfKing = app.getKing(elfFactory);
assertTrue(elfKing instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
final King orcKing = app.getKing(orcFactory);
assertTrue(orcKing instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
}
@Test
public void castle() {
final Castle elfCastle = app.getCastle(elfFactory);
assertTrue(elfCastle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
final Castle orcCastle = app.getCastle(orcFactory);
assertTrue(orcCastle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
}
@Test
public void army() {
final Army elfArmy = app.getArmy(elfFactory);
assertTrue(elfArmy instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
final Army orcArmy = app.getArmy(orcFactory);
assertTrue(orcArmy instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
}
@Test
public void createElfKingdom() {
app.createKingdom(elfFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof ElfKing);
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof ElfCastle);
assertEquals(ElfCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof ElfArmy);
assertEquals(ElfArmy.DESCRIPTION, army.getDescription());
}
@Test
public void createOrcKingdom() {
app.createKingdom(orcFactory);
final King king = app.getKing();
final Castle castle = app.getCastle();
final Army army = app.getArmy();
assertTrue(king instanceof OrcKing);
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
assertTrue(castle instanceof OrcCastle);
assertEquals(OrcCastle.DESCRIPTION, castle.getDescription());
assertTrue(army instanceof OrcArmy);
assertEquals(OrcArmy.DESCRIPTION, army.getDescription());
public void test() throws IOException {
String[] args = {};
App.main(args);
}
}

View File

@ -3,6 +3,7 @@ layout: pattern
title: Adapter
folder: adapter
permalink: /patterns/adapter/
pumlid: DSR14S8m30J0Lg20M7-wEMnDOiPMFDA9j0yyUEtUkzMHJTF7xI1NF4GSLzaxZtncgDVJgCPIpobzv0N2vOKtjgRHTziMI7KBcOXl10thfxB-Nz9dMJd71m00
categories: Structural
tags:
- Java
@ -10,24 +11,32 @@ tags:
- Difficulty-Beginner
---
**Also known as:** Wrapper
## Also known as
Wrapper
**Intent:** Convert the interface of a class into another interface the clients
## Intent
Convert the interface of a class into another interface the clients
expect. Adapter lets classes work together that couldn't otherwise because of
incompatible interfaces.
![alt text](./etc/adapter.png "Adapter")
**Applicability:** Use the Adapter pattern when
## Applicability
Use the Adapter pattern when
* you want to use an existing class, and its interface does not match the one you need
* you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces
* you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class.
**Real world examples:**
## Real world examples
* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)
* [java.util.Collections#list()](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#list-java.util.Enumeration-)
* [java.util.Collections#enumeration()](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#enumeration-java.util.Collection-)
* [javax.xml.bind.annotation.adapters.XMLAdapter](http://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html#marshal-BoundType-)
**Credits**
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)

View File

@ -0,0 +1,37 @@
@startuml
package com.iluwatar.adapter {
class App {
+ App()
+ main(args : String[]) {static}
}
class BattleFishingBoat {
- LOGGER : Logger {static}
- boat : FishingBoat
+ BattleFishingBoat()
+ fire()
+ move()
}
interface BattleShip {
+ fire() {abstract}
+ move() {abstract}
}
class Captain {
- battleship : BattleShip
+ Captain()
+ Captain(battleship : BattleShip)
+ fire()
+ move()
+ setBattleship(battleship : BattleShip)
}
class FishingBoat {
- LOGGER : Logger {static}
+ FishingBoat()
+ fish()
+ sail()
}
}
BattleFishingBoat --> "-boat" FishingBoat
Captain --> "-battleship" BattleShip
BattleFishingBoat ..|> BattleShip
Captain ..|> BattleShip
@enduml

View File

@ -1,11 +1,35 @@
<?xml version="1.0"?>
<!--
The MIT License
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
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.
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.9.0</version>
<version>1.15.0</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
/**

View File

@ -1,5 +1,30 @@
/**
* The MIT License
* 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
* 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.
*/
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}
@ -11,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() {
@ -19,7 +46,7 @@ public class BattleFishingBoat implements BattleShip {
@Override
public void fire() {
System.out.println("fire!");
LOGGER.info("fire!");
}
@Override

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
/**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
/**

View File

@ -1,5 +1,30 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Device class (adaptee in the pattern). We want to reuse this class
@ -7,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,3 +1,25 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
import org.junit.Before;

View File

@ -0,0 +1,38 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.adapter;
import org.junit.Test;
import java.io.IOException;
/**
* Tests that Adapter example runs without errors.
*/
public class AppTest {
@Test
public void test() throws IOException {
String[] args = {};
App.main(args);
}
}

View File

@ -0,0 +1,30 @@
---
layout: pattern
title: Aggregator Microservices
folder: aggregator-microservices
permalink: /patterns/aggregator-microservices/
pumlid: JOov3SCm301NIGQGs7iRXYPa1g8ayB7NjuiKwGvtmBrbKC-Tq_hhY5Y-0HXUjKaS-Kbdepc2HrIQ2jBpma23BvvOTdPfeooCO1iEYlu0O6l63MDQKI6Rp-CKOWSE-ey_NzEqhjH-0m00
categories: Architectural
tags:
- Java
- Spring
---
## Intent
The user makes a single call to the Aggregator, and the aggregator then calls each relevant microservice and collects
the data, apply business logic to it, and further publish is as a REST Endpoint.
More variations of the aggregator are:
- Proxy Microservice Design Pattern: A different microservice is called upon the business need.
- Chained Microservice Design Pattern: In this case each microservice is dependent/ chained to a series
of other microservices.
![alt text](./etc/aggregator-microservice.png "Aggregator Microservice")
## Applicability
Use the Aggregator Microservices pattern when you need a unified API for various microservices, regardless the client device.
## Credits
* [Microservice Design Patterns](http://blog.arungupta.me/microservice-design-patterns/)

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-service</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,58 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* The aggregator aggregates calls on various micro-services, collects
* data and further publishes them under a REST endpoint.
*/
@RestController
public class Aggregator {
@Resource
private ProductInformationClient informationClient;
@Resource
private ProductInventoryClient inventoryClient;
/**
* Retrieves product data.
*
* @return a Product.
*/
@RequestMapping("/product")
public Product getProduct() {
Product product = new Product();
product.setTitle(informationClient.getProductTitle());
product.setProductInventories(inventoryClient.getProductInventories());
return product;
}
}

View File

@ -0,0 +1,42 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Spring Boot EntryPoint Class
*/
@SpringBootApplication
public class App {
/**
* Program entry point
*
* @param args command line args
*/
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}

View File

@ -0,0 +1,57 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
/**
* Encapsulates all the data for a Product that clients will request.
*/
public class Product {
/**
* The title of the product.
*/
private String title;
/**
* The inventories of the product.
*/
private int productInventories;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getProductInventories() {
return productInventories;
}
public void setProductInventories(int productInventories) {
this.productInventories = productInventories;
}
}

View File

@ -0,0 +1,32 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
/**
* Interface for the Information micro-service.
*/
public interface ProductInformationClient {
String getProductTitle();
}

View File

@ -0,0 +1,57 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
import org.apache.http.client.methods.CloseableHttpResponse;
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;
/**
* An adapter to communicate with information micro-service.
*/
@Component
public class ProductInformationClientImpl implements ProductInformationClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
@Override
public String getProductTitle() {
String response = null;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:51515/information");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
}
return response;
}
}

View File

@ -0,0 +1,31 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
/**
* Interface to Inventory micro-service.
*/
public interface ProductInventoryClient {
int getProductInventories();
}

View File

@ -0,0 +1,57 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
import org.apache.http.client.methods.CloseableHttpResponse;
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;
/**
* An adapter to communicate with inventory micro-service.
*/
@Component
public class ProductInventoryClientImpl implements ProductInventoryClient {
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
@Override
public int getProductInventories() {
String response = "0";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:51516/inventories");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
LOGGER.error("Exception caught.", e);
}
return Integer.parseInt(response);
}
}

View File

@ -0,0 +1,24 @@
#
# The MIT License
# 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
# 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.
#
server.port=50004

View File

@ -0,0 +1,70 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.aggregator.microservices;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/**
* Test Aggregation of domain objects
*/
public class AggregatorTest {
@InjectMocks
private Aggregator aggregator;
@Mock
private ProductInformationClient informationClient;
@Mock
private ProductInventoryClient inventoryClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
/**
* Tests getting the data for a desktop client
*/
@Test
public void testGetProduct() {
String title = "The Product Title.";
int inventories = 5;
when(informationClient.getProductTitle()).thenReturn(title);
when(inventoryClient.getProductInventories()).thenReturn(inventories);
Product testProduct = aggregator.getProduct();
assertEquals(title, testProduct.getTitle());
assertEquals(inventories, testProduct.getProductInventories());
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -0,0 +1,43 @@
@startuml
package com.iluwatar.aggregator.microservices {
class Aggregator {
- informationClient : ProductInformationClient
- inventoryClient : ProductInventoryClient
+ Aggregator()
+ getProduct() : Product
}
class App {
+ App()
+ main(args : String[]) {static}
}
class Product {
- productInventories : int
- title : String
+ Product()
+ getProductInventories() : int
+ getTitle() : String
+ setProductInventories(productInventories : int)
+ setTitle(title : 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 --> "-informationClient" ProductInformationClient
Aggregator --> "-inventoryClient" ProductInventoryClient
ProductInformationClientImpl ..|> ProductInformationClient
ProductInventoryClientImpl ..|> ProductInventoryClient
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.information.microservice {
class InformationApplication {
+ InformationApplication()
+ main(args : String[]) {static}
}
class InformationController {
+ InformationController()
+ getProductTitle() : String
}
}
@enduml

View File

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

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>information-microservice</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,37 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.information.microservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Inventory Application starts container (Spring Boot) and exposes the Inventory micro-service.
*/
@SpringBootApplication
public class InformationApplication {
public static void main(String[] args) {
SpringApplication.run(InformationApplication.class, args);
}
}

View File

@ -0,0 +1,44 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.information.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller providing endpoints to retrieve information about products
*/
@RestController
public class InformationController {
/**
* Endpoint to retrieve a product's informations.
*
* @return product inventory.
*/
@RequestMapping(value = "/information", method = RequestMethod.GET)
public String getProductTitle() {
return "The Product Title.";
}
}

View File

@ -0,0 +1,24 @@
#
# The MIT License
# 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
# 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.
#
server.port=51515

View File

@ -0,0 +1,42 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.information.microservice;
import org.junit.Assert;
import org.junit.Test;
/**
* Test for Information Rest Controller
*/
public class InformationControllerTest {
@Test
public void shouldGetProductTitle() {
InformationController infoController = new InformationController();
String title = infoController.getProductTitle();
Assert.assertEquals("The Product Title.", title);
}
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>inventory-microservice</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,38 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.inventory.microservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Inventory Application starts container (Spring Boot) and exposes the Inventory micro-service.
*/
@SpringBootApplication
public class InventoryApplication {
public static void main(String[] args) {
SpringApplication.run(InventoryApplication.class, args);
}
}

View File

@ -0,0 +1,45 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.inventory.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Controller providing endpoints to retrieve product inventories
*/
@RestController
public class InventoryController {
/**
* Endpoint to retrieve a product's inventories.
*
* @return product inventory.
*/
@RequestMapping(value = "/inventories", method = RequestMethod.GET)
public int getProductInventories() {
return 5;
}
}

View File

@ -0,0 +1,24 @@
#
# The MIT License
# 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
# 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.
#
server.port=51516

View File

@ -0,0 +1,40 @@
/**
* The MIT License
* 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
* 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:
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p/>
* 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.
*/
package com.iluwatar.inventory.microservice;
import org.junit.Assert;
import org.junit.Test;
/**
* Test Inventory Rest Controller
*/
public class InventoryControllerTest {
@Test
public void testGetProductInventories() throws Exception {
InventoryController inventoryController = new InventoryController();
int numberOfInventories = inventoryController.getProductInventories();
Assert.assertEquals(5, numberOfInventories);
}
}

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>com.github.markusmo3.urm</groupId>
<artifactId>urm-maven-plugin</artifactId>
<version>${urm.version}</version>
<configuration combine.self="override">
<outputDirectory>${project.basedir}/../etc</outputDirectory>
<packages>
<param>com.iluwatar</param>
</packages>
<skipForProjects>
<!-- skip for parent project -->
<param>aggregator-microservices</param>
</skipForProjects>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>information-microservice</module>
<module>aggregator-service</module>
<module>inventory-microservice</module>
</modules>
</project>

31
api-gateway/README.md Normal file
View File

@ -0,0 +1,31 @@
---
layout: pattern
title: API Gateway
folder: api-gateway
permalink: /patterns/api-gateway/
pumlid: JSox3SCm303HLP819FRUXg49cO542_nOyFPncUvUSszHwhbpMdyT4TCt0CDLcyIHdtGsEZLOez8vG7ek33JuueLbPvUcPM84cpeCz2S0fvI6mGjluA1_b-Tt2N5D6tNcw3y0
categories: Architectural
tags:
- Java
- Difficulty-Intermediate
- Spring
---
## Intent
Aggregate calls to microservices in a single location: the API Gateway. The user makes a single
call to the API Gateway, and the API Gateway then calls each relevant microservice.
![alt text](./etc/api-gateway.png "API Gateway")
## Applicability
Use the API Gateway pattern when
* you're also using the Microservices pattern and need a single point of aggregation for your
microservice calls
## Credits
* [microservices.io - API Gateway](http://microservices.io/patterns/apigateway.html)
* [NGINX - Building Microservices: Using an API Gateway](https://www.nginx.com/blog/building-microservices-using-an-api-gateway/)

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway-service</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,64 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* The ApiGateway aggregates calls to microservices based on the needs of the individual clients.
*/
@RestController
public class ApiGateway {
@Resource
private ImageClient imageClient;
@Resource
private PriceClient priceClient;
/**
* Retrieves product information that desktop clients need
* @return Product information for clients on a desktop
*/
@RequestMapping("/desktop")
public DesktopProduct getProductDesktop() {
DesktopProduct desktopProduct = new DesktopProduct();
desktopProduct.setImagePath(imageClient.getImagePath());
desktopProduct.setPrice(priceClient.getPrice());
return desktopProduct;
}
/**
* Retrieves product information that mobile clients need
* @return Product information for clients on a mobile device
*/
@RequestMapping("/mobile")
public MobileProduct getProductMobile() {
MobileProduct mobileProduct = new MobileProduct();
mobileProduct.setPrice(priceClient.getPrice());
return mobileProduct;
}
}

View File

@ -0,0 +1,66 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* With the Microservices pattern, a client may need data from multiple different microservices.
* If the client called each microservice directly, that could contribute to longer load times,
* since the client would have to make a network request for each microservice called. Moreover,
* having the client call each microservice directly ties the client to that microservice - if the
* internal implementations of the microservices change (for example, if two microservices are
* combined sometime in the future) or if the location (host and port) of a microservice changes,
* then every client that makes use of those microservices must be updated.
*
* <p>
* The intent of the API Gateway pattern is to alleviate some of these issues. In the API Gateway
* pattern, an additional entity (the API Gateway) is placed between the client and the
* microservices. The job of the API Gateway is to aggregate the calls to the microservices.
* Rather than the client calling each microservice individually, the client calls the API Gateway
* a single time. The API Gateway then calls each of the microservices that the client needs.
*
* <p>
* This implementation shows what the API Gateway pattern could look like for an e-commerce site.
* The {@link ApiGateway} makes calls to the Image and Price microservices using the
* {@link ImageClientImpl} and {@link PriceClientImpl} respectively. Customers viewing the site on a
* desktop device can see both price information and an image of a product, so the {@link ApiGateway}
* calls both of the microservices and aggregates the data in the {@link DesktopProduct} model.
* However, mobile users only see price information; they do not see a product image. For mobile
* users, the {@link ApiGateway} only retrieves price information, which it uses to populate the
* {@link MobileProduct}.
*/
@SpringBootApplication
public class App {
/**
* Program entry point
*
* @param args
* command line args
*/
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}

View File

@ -0,0 +1,54 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
/**
* Encapsulates all of the information that a desktop client needs to display a product.
*/
public class DesktopProduct {
/**
* The price of the product
*/
private String price;
/**
* The path to the image of the product
*/
private String imagePath;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
}

View File

@ -0,0 +1,30 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
/**
* An interface used to communicate with the Image microservice
*/
public interface ImageClient {
String getImagePath();
}

View File

@ -0,0 +1,56 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
import org.apache.http.client.methods.CloseableHttpResponse;
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.springframework.stereotype.Component;
import java.io.IOException;
/**
* An adapter to communicate with the Image microservice
*/
@Component
public class ImageClientImpl implements ImageClient {
/**
* Makes a simple HTTP Get request to the Image microservice
* @return The path to the image
*/
@Override
public String getImagePath() {
String response = null;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:50005/image-path");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
}

View File

@ -0,0 +1,41 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
/**
* Encapsulates all of the information that mobile client needs to display a product.
*/
public class MobileProduct {
/**
* The price of the product
*/
private String price;
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
}

View File

@ -0,0 +1,30 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
/**
* An interface used to communicate with the Price microservice
*/
public interface PriceClient {
String getPrice();
}

View File

@ -0,0 +1,56 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
import org.apache.http.client.methods.CloseableHttpResponse;
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.springframework.stereotype.Component;
import java.io.IOException;
/**
* An adapter to communicate with the Price microservice
*/
@Component
public class PriceClientImpl implements PriceClient {
/**
* Makes a simple HTTP Get request to the Price microservice
* @return The price of the product
*/
@Override
public String getPrice() {
String response = null;
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:50006/price");
try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) {
response = EntityUtils.toString(httpResponse.getEntity());
}
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
}

View File

@ -0,0 +1,24 @@
#
# The MIT License
# 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
# 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.
#
server.port=50004

View File

@ -0,0 +1,81 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.api.gateway;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/**
* Test API Gateway Pattern
*/
public class ApiGatewayTest {
@InjectMocks
private ApiGateway apiGateway;
@Mock
private ImageClient imageClient;
@Mock
private PriceClient priceClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
/**
* Tests getting the data for a desktop client
*/
@Test
public void testGetProductDesktop() {
String imagePath = "/product-image.png";
String price = "20";
when(imageClient.getImagePath()).thenReturn(imagePath);
when(priceClient.getPrice()).thenReturn(price);
DesktopProduct desktopProduct = apiGateway.getProductDesktop();
assertEquals(price, desktopProduct.getPrice());
assertEquals(imagePath, desktopProduct.getImagePath());
}
/**
* Tests getting the data for a mobile client
*/
@Test
public void testGetProductMobile() {
String price = "20";
when(priceClient.getPrice()).thenReturn(price);
MobileProduct mobileProduct = apiGateway.getProductMobile();
assertEquals(price, mobileProduct.getPrice());
}
}

View File

@ -0,0 +1,48 @@
@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 DesktopProduct {
- imagePath : String
- price : String
+ DesktopProduct()
+ getImagePath() : String
+ getPrice() : String
+ setImagePath(imagePath : String)
+ setPrice(price : String)
}
interface ImageClient {
+ getImagePath() : String {abstract}
}
class ImageClientImpl {
+ ImageClientImpl()
+ getImagePath() : String
}
class MobileProduct {
- price : String
+ MobileProduct()
+ getPrice() : String
+ setPrice(price : String)
}
interface PriceClient {
+ getPrice() : String {abstract}
}
class PriceClientImpl {
+ PriceClientImpl()
+ getPrice() : String
}
}
ApiGateway --> "-imageClient" ImageClient
ApiGateway --> "-priceClient" PriceClient
ImageClientImpl ..|> ImageClient
PriceClientImpl ..|> PriceClient
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<class id="1" language="java" name="com.iluwatar.api.gateway.ApiGateway" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ApiGateway.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="125" y="87"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="2" language="java" name="com.iluwatar.api.gateway.DesktopProduct" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/DesktopProduct.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="388" y="109"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="3" language="java" name="com.iluwatar.api.gateway.ImageClient" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClient.java" binary="false" corner="BOTTOM_RIGHT">
<position height="81" width="129" x="13" y="197"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="4" language="java" name="com.iluwatar.api.gateway.ImageClientImpl" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="129" x="13" y="325"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="com.iluwatar.api.gateway.MobileProduct" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/MobileProduct.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="376" y="293"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="6" language="java" name="com.iluwatar.api.gateway.PriceClient" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClient.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="222" y="231"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="7" language="java" name="com.iluwatar.api.gateway.PriceClientImpl" project="api-gateway"
file="/api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="223" y="374"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<association id="8">
<end type="SOURCE" refId="1" navigable="false">
<attribute id="9" name="imageClient"/>
<multiplicity id="10" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="11">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="3"/>
</realization>
<association id="12">
<end type="SOURCE" refId="1" navigable="false">
<attribute id="13" name="priceClient"/>
<multiplicity id="14" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="6" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="15">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="6"/>
</realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.image.microservice {
class ImageApplication {
+ ImageApplication()
+ main(args : String[]) {static}
}
class ImageController {
+ ImageController()
+ getImagePath() : String
}
}
@enduml

View File

@ -0,0 +1,12 @@
@startuml
package com.iluwatar.price.microservice {
class PriceApplication {
+ PriceApplication()
+ main(args : String[]) {static}
}
class PriceController {
+ PriceController()
+ getPrice() : String
}
}
@enduml

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<class id="1" language="java" name="com.iluwatar.image.microservice.ImageController" project="image-microservice"
file="/image-microservice/src/main/java/com/iluwatar/image/microservice/ImageController.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="87" y="61"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License
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
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.15.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-microservice</artifactId>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,43 @@
/**
* The MIT License
* 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
* 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.
*/
package com.iluwatar.image.microservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* ImageApplication starts up Spring Boot, exposing endpoints for the Image microservice through
* the {@link ImageController}.
*/
@SpringBootApplication
public class ImageApplication {
/**
* Microservice entry point
* @param args
* command line args
*/
public static void main(String[] args) {
SpringApplication.run(ImageApplication.class, args);
}
}

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