Compare commits

..

270 Commits

Author SHA1 Message Date
d793160bce Reach milestone 1.16.0 2017-06-30 20:31:31 +03:00
b65b89baaf Merge pull request #593 from Harshrajsinh/hotfix/readme-update
Refactored Function<Integer,T> to IntFunction<T>
2017-06-14 22:48:33 +03:00
edea7d2220 Refactored Function<Integer,T> to IntFunction<T>. 2017-06-14 11:58:05 -07:00
bf8bc4df4b Merge pull request #589 from Harshrajsinh/hotfix/readme-update
Refactored the Functional Interface to the Specialized Primitive Functional Interface
2017-06-14 20:19:44 +03:00
d13635533a Merge pull request #588 from prafful1/master
Few additions in readme
2017-06-14 20:14:09 +03:00
37cd4cbb3b Merge pull request #585 from fluency03/master
add RxJava to Real world examples of observer
2017-06-14 20:12:32 +03:00
3d29755842 Add license headers 2017-06-11 19:37:52 +03:00
5b47d48fc2 Merge pull request #573 from SrdjanPaunovic/extension-objects
#541 Extension objects pattern
2017-06-11 19:26:47 +03:00
73934e25e5 Refactored the Functional Interface to the Specialized Functional
Interface.
2017-06-09 17:17:56 -07:00
41d487d32a Few additions in readme
Adding Consequences and General usage of Adapter Pattern section to the Readme doc.
2017-06-07 20:22:15 +05:30
a0916aab6c Update README.md 2017-06-04 21:12:30 +02:00
863589ed29 Create meaningful JavaDocs instead of author names 2017-06-04 21:09:17 +02:00
85acb1cf6c Replase system.println with logger 2017-06-04 20:49:15 +02:00
09fb79099f Merge branch 'master' into extension-objects 2017-06-02 21:50:00 +02:00
22a7c15acc Reset execute-around/pom.xml from master 2017-06-02 21:42:59 +02:00
0182b840af add RxJava to Real world examples of observer 2017-05-30 13:22:52 +02:00
f87249e03b Add missing license headers 2017-05-29 21:53:05 +03:00
dd0ca2d16e Merge pull request #572 from 4lexis/master
#567 Marker Interface pull request
2017-05-29 21:41:27 +03:00
f2e35ec03d #567 fix version and javadoc 2017-05-23 01:38:02 +02:00
ae1d9cf7a8 Add missing license headers 2017-05-21 09:19:29 +03:00
1bbc597671 Merge pull request #575 from prafful1/master
Few additions in README
2017-05-21 09:11:00 +03:00
4d6467e435 Merge pull request #569 from kapinuss/master
Adding Setter Dependency Injection as a second subtype of DI
2017-05-21 09:02:18 +03:00
17039dc5e9 Update AdvancedSorceressTest.java 2017-05-18 20:27:16 +03:00
30dcbee2cc Update AdvancedSorceress.java 2017-05-18 20:26:47 +03:00
08901f3c26 Update AdvancedSorceress.java 2017-05-18 20:23:05 +03:00
c746004f73 Update AdvancedSorceress.java 2017-05-18 19:13:45 +03:00
09aa44ddcb Update App.java 2017-05-18 19:13:09 +03:00
992e76ac61 Merge pull request #566 from qpi/master
Event Queue pattern
2017-05-16 21:59:50 +03:00
167a43f72e updated model.png 2017-05-15 11:04:41 +02:00
fe1e45bd69 some fixes 2017-05-15 10:40:12 +02:00
4b32fb65da Merge pull request #571 from ytian90/master
Fix Block 3 Case in Feature Toggle Design Pattern
2017-05-15 08:13:28 +03:00
0546223bba quick fix 2017-05-11 21:44:07 +02:00
857902ab95 compatibility fix
When the system is not capable to play the sound, do not throw
exception, just log it. For example on Linux there are several issues to
play sound and there are no workarounds for that :(
2017-05-11 21:41:25 +02:00
0b57edd211 Merge pull request #568 from brandon-d-mckay/patch-1
Fix incorrect URL
2017-05-09 23:10:31 +03:00
fb26d42b51 Few additions in README
Added few more points in applicability and also some use cases and consequences.
2017-05-07 13:28:54 +05:30
6857486f27 #541 Create README.md file 2017-05-04 12:33:25 +02:00
1abd96a9c8 #567 checkstyle fix 2017-05-03 22:09:47 +02:00
08c4202852 #541 fix checkstyle errors 2017-05-03 22:08:04 +02:00
6ecf994258 #567 pom.xml align fix 2017-05-03 21:42:15 +02:00
0687a3f9f8 #541 pom.xml fix align 2017-05-03 21:40:54 +02:00
64337dff06 merge fix 2017-05-03 21:07:49 +02:00
34b09c75ec #567 added .gitignore 2017-05-03 20:51:51 +02:00
66c6f30c1c #567 Updated pom.xml 2017-05-03 20:34:27 +02:00
e413b116ac Merge branch 'master' of https://github.com/4lexis/java-design-patterns 2017-05-03 19:57:57 +02:00
6e0b3e37ea updated pom.xml 2017-05-03 19:57:14 +02:00
be3f4dce50 Update Picture 2017-05-03 19:49:25 +02:00
6d87f63ed5 Added README.md 2017-05-03 19:48:29 +02:00
c92a8daeda Class diagram & fix relation between units 2017-05-03 17:59:54 +02:00
20062faae6 All without Readme and pumlid 2017-05-03 17:50:35 +02:00
678524704c Test done 2017-05-03 13:21:13 +02:00
2b229d8ea1 Update AdvancedSorceressTest.java 2017-05-02 20:38:08 +03:00
03aa99c55f Update AdvancedSorceressTest.java 2017-05-02 20:18:05 +03:00
20a4c054a7 Merge branch 'master' of github.com:ytian90/java-design-patterns 2017-04-30 00:20:48 -07:00
3ed6cc19d2 fix Block 3 case 2017-04-30 00:19:50 -07:00
87a9387e62 Merge pull request #1 from iluwatar/master
Rebase
2017-04-29 16:03:26 -07:00
8530d01e10 code implemented 2017-04-29 16:35:57 +02:00
a34e7be9c2 check commit 2017-04-28 19:35:19 +02:00
ee3744cb0a added travis supported sound files 2017-04-28 13:47:56 +02:00
2830a407ba some fixes for testing in event queue 2017-04-28 12:19:57 +02:00
ccfb6709c7 Add files via upload 2017-04-28 13:00:01 +03:00
a1c5131304 Add files via upload 2017-04-28 12:59:09 +03:00
44401988d1 pom.xml fixes 2017-04-28 11:32:35 +02:00
6e8eaf7593 adding some test cases for the event queue 2017-04-28 10:38:40 +02:00
645e91ed23 first version of pattern without Tests 2017-04-27 13:58:58 +02:00
9e7e8a64f6 Fix incorrect URL 2017-04-26 04:22:44 -04:00
152b2762c3 read.me and the diagram is added 2017-04-22 17:16:38 +02:00
82b9f4fea7 Merge pull request #544 from kemitix/data-bus
[WIP] Data Bus
2017-04-22 15:17:31 +03:00
ff8d854a8d #467 data-bus: README.md: clean up 2017-04-16 06:51:10 +01:00
31f4b15e86 Merge pull request #565 from kapinuss/patch-1
Update ObjectPool.java
2017-04-16 08:17:56 +03:00
cd54cf5512 Merge pull request #563 from sunilmogadati/SonarQubeBlockerBugs
#507 SonarQube blocker severity bugs
2017-04-16 08:13:26 +03:00
798aee47b3 Update ObjectPool.java 2017-04-12 18:59:43 +03:00
dce767c1c5 first commit 2017-04-06 23:48:15 +02:00
60ebcc56f8 #507 SonarQube blocker severity bugs 2017-04-01 20:55:47 -06:00
2643dfa0b8 #467 data-bus: App: add notes about this implementation of the patter 2017-04-01 19:33:54 +01:00
c96ebcb197 #467 data-bus: App: add description of the pattern 2017-04-01 19:26:41 +01:00
b72d545349 #467 data-bus: members: StatusMemberTest: added 2017-04-01 19:17:09 +01:00
311bb79870 #467 data-bus: members: StatusMember: records start and stop times 2017-04-01 19:16:55 +01:00
f495a88e91 #467 data-bus: members: MessageCollectorMemberTest: added 2017-04-01 19:05:19 +01:00
8b0c14cae0 Counter doesn't count anything. Added ability to collect the messages
from the MessageData that it receives.
2017-04-01 19:05:09 +01:00
b7a6a018e0 #467 data-bus: DataBusTest: added 2017-04-01 18:36:04 +01:00
46e0fa4825 #467 data-bus: pom.xml: add mockito dependency 2017-04-01 18:35:40 +01:00
86009f2261 #467 data-bus: add missing javadoc 2017-04-01 18:12:56 +01:00
146f367188 #467 data-bus: remove lombok 2017-04-01 18:12:32 +01:00
bc4d029a87 #467 data-bus: pom.xml: remove surefire plugin 2017-04-01 18:04:44 +01:00
960eee3d43 #467 update version 2017-04-01 18:04:16 +01:00
30315e788f Merge remote-tracking branch 'upstream/master' into data-bus
* upstream/master: (67 commits)
  Set version for next development iteration
  Reached milestone 1.15.0
  #539 Checkstyle fix
  #539 More Checkstyle fixes
  #539 Checkstyle fixes
  #497 Add missing puml and license headers
  #77 Add missing license header
  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
  Removed AvoidStarImport Rule Added JavaDocType Rule
  Update App.java
  Update App.java
  Update after changes from review. Additional improvements.
  Pom.xml files fixed.
  #66 Balking Pattern
  fixed pmd violation
  fixed checkstyle violations
  diagrams added
  comments, tests and description
  changed parent POM version #69
  apply changes from review #69
  ...

# Conflicts:
#	pom.xml
2017-04-01 18:03:02 +01:00
073d06c0ae Set version for next development iteration 2017-04-01 17:15:59 +03:00
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
6b795e52c3 #467 data-bus: README.md: updated for data-bus 2017-03-05 19:43:57 +00:00
b5bdf2d7d7 #467 data-bus: etc: add urm diagrams 2017-03-05 19:43:26 +00:00
3fd6887975 #467 data-bus: implement pattern 2017-03-05 18:55:34 +00:00
eecffb0ea5 #467 data-bus: add stub 2017-03-03 19:58:03 +00: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
b31edda3cf Caching pattern: Implementation of Cache-Aside pattern 2016-09-22 20:41:26 +02:00
e3355d76d1 Caching pattern: Style fix for null check 2016-09-22 20:36:02 +02:00
865f788612 Caching pattern: Refactor LRU cache to avoid NPE and unnecessary cache lookup 2016-09-22 20:35:44 +02:00
6ed842e58b Caching pattern: Refactor shutdown hook to use method reference 2016-09-22 20:34:46 +02:00
69cab15d75 Merge remote-tracking branch 'upstream/master' 2016-09-19 21:50:54 +01:00
371b262a51 Changes based on latest code review 2016-09-19 21:50:23 +01:00
dbd605e378 Changes based on latest code review 2016-09-19 21:50:04 +01:00
f2159515bc Merge remote-tracking branch 'upstream/master' 2016-09-11 20:33:51 +01:00
9a90f2de1f Changes based on code review 2016-09-11 18:45:51 +01:00
fce30db803 Updating fork branch 2016-09-11 16:24:16 +01:00
233f1e69f9 Removed PUBLIC modifiers from IEvent 2016-09-03 11:32:31 +01:00
f11597136f Fixed Checkstyle errors. 2016-09-03 11:32:29 +01:00
e1836fee2f Updated parent POM to include new pattern (Event-asynchronous) 2016-09-03 11:32:28 +01:00
2d99061902 Issue #469: Implementation of Event-based Asynchronous pattern 2016-09-03 11:32:25 +01:00
1283 changed files with 16245 additions and 6037 deletions

30
.gitignore vendored
View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<artifactId>abstract-document</artifactId>
<dependencies>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,22 @@ Use the Abstract Factory pattern when
* 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
* the lifetime of the dependency is conceptually shorter than the lifetime of the consumer.
* you need a run-time value to construct a particular dependency
* you want to decide which product to call from a family at runtime.
* you need to supply one or more parameters only known at run-time before you can resolve a dependency.
## Use Cases:
* Selecting to call the appropriate implementation of FileSystemAcmeService or DatabaseAcmeService or NetworkAcmeService at runtime.
* Unit test case writing becomes much easier
## Consequences:
* Dependency injection in java hides the service class dependencies that can lead to runtime errors that would have been caught at compile time.
## Real world examples

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<artifactId>abstract-factory</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,6 +22,9 @@
*/
package com.iluwatar.abstractfactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme
@ -39,6 +42,8 @@ package com.iluwatar.abstractfactory;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private King king;
private Castle castle;
private Army army;
@ -98,17 +103,17 @@ public class App {
App app = new App();
System.out.println("Elf Kingdom");
LOGGER.info("Elf Kingdom");
app.createKingdom(new ElfKingdomFactory());
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
System.out.println("\nOrc Kingdom");
LOGGER.info("Orc Kingdom");
app.createKingdom(new OrcKingdomFactory());
System.out.println(app.getArmy().getDescription());
System.out.println(app.getCastle().getDescription());
System.out.println(app.getKing().getDescription());
LOGGER.info(app.getArmy().getDescription());
LOGGER.info(app.getCastle().getDescription());
LOGGER.info(app.getKing().getDescription());
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,9 @@ incompatible interfaces.
![alt text](./etc/adapter.png "Adapter")
## General usage of Adapter Pattern:
+ Wrappers used to adopt 3rd parties libraries and frameworks - most of the applications using third party libraries use adapters as a middle layer between the application and the 3rd party library to decouple the application from the library. If another library has to be used only an adapter for the new library is required without having to change the application code.
## Applicability
Use the Adapter pattern when
@ -28,6 +31,19 @@ Use the Adapter pattern when
* 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.
## Consequences:
Class and object adapters have different trade-offs. A class adapter
* adapts Adaptee to Target by committing to a concrete Adaptee class. As a consequence, a class adapter wont work when we want to adapt a class and all its subclasses.
* lets Adapter override some of Adaptees behavior, since Adapter is a subclass of Adaptee.
* introduces only one object, and no additional pointer indirection is needed to get to the adaptee.
An object adapter
* lets a single Adapter work with many Adaptees—that is, the Adaptee itself and all of its subclasses (if any). The Adapter can also add functionality to all Adaptees at once.
* makes it harder to override Adaptee behavior. It will require subclassing Adaptee and making Adapter refer to the subclass rather than the Adaptee itself.
## Real world examples
* [java.util.Arrays#asList()](http://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#asList%28T...%29)

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<artifactId>adapter</artifactId>
<dependencies>

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,6 +22,9 @@
*/
package com.iluwatar.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link BattleShip}
@ -33,6 +36,8 @@ package com.iluwatar.adapter;
*/
public class BattleFishingBoat implements BattleShip {
private static final Logger LOGGER = LoggerFactory.getLogger(BattleFishingBoat.class);
private FishingBoat boat;
public BattleFishingBoat() {
@ -41,7 +46,7 @@ public class BattleFishingBoat implements BattleShip {
@Override
public void fire() {
System.out.println("fire!");
LOGGER.info("fire!");
}
@Override

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,6 +22,9 @@
*/
package com.iluwatar.adapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Device class (adaptee in the pattern). We want to reuse this class
@ -29,12 +32,14 @@ package com.iluwatar.adapter;
*/
public class FishingBoat {
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
public void sail() {
System.out.println("The Boat is moving to that place");
LOGGER.info("The Boat is moving to that place");
}
public void fish() {
System.out.println("fishing ...");
LOGGER.info("fishing ...");
}
}

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,6 +25,9 @@ package com.iluwatar.aggregator.microservices;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Spring Boot EntryPoint Class
*/
@SpringBootApplication
public class App {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,15 +22,18 @@
*/
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;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
/**
* Test Aggregation of domain objects
*/
public class AggregatorTest {
@InjectMocks
@ -64,4 +67,4 @@ public class AggregatorTest {
assertEquals(inventories, testProduct.getProductInventories());
}
}
}

View File

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

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,6 +25,9 @@ package com.iluwatar.information.microservice;
import org.junit.Assert;
import org.junit.Test;
/**
* Test for Information Rest Controller
*/
public class InformationControllerTest {
@Test
@ -36,4 +39,4 @@ public class InformationControllerTest {
Assert.assertEquals("The Product Title.", title);
}
}
}

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>aggregator-microservices</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,10 @@ 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();
@ -35,4 +37,4 @@ public class InventoryControllerTest {
Assert.assertEquals(5, numberOfInventories);
}
}
}

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aggregator-microservices</artifactId>

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway-service</artifactId>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -35,7 +35,7 @@ import java.io.IOException;
* An adapter to communicate with the Image microservice
*/
@Component
public class ImageClientImpl implements ImageClient{
public class ImageClientImpl implements ImageClient {
/**
* Makes a simple HTTP Get request to the Image microservice
* @return The path to the image

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -35,7 +35,7 @@ import java.io.IOException;
* An adapter to communicate with the Price microservice
*/
@Component
public class PriceClientImpl implements PriceClient{
public class PriceClientImpl implements PriceClient {
/**
* Makes a simple HTTP Get request to the Price microservice
* @return The price of the product

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,15 +22,18 @@
*/
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;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
/**
* Test API Gateway Pattern
*/
public class ApiGatewayTest {
@InjectMocks

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,6 +25,9 @@ package com.iluwatar.image.microservice;
import org.junit.Assert;
import org.junit.Test;
/**
* Test for Image Rest Controller
*/
public class ImageControllerTest {
@Test
public void testGetImagePath() {

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-gateway</artifactId>

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<artifactId>api-gateway</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,6 +25,10 @@ package com.iluwatar.price.microservice;
import org.junit.Assert;
import org.junit.Test;
/**
* Test for Price Rest Controller
*/
public class PriceControllerTest {
@Test
public void testgetPrice() {

View File

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

View File

@ -2,7 +2,7 @@
<!--
The MIT License
Copyright (c) 2014 Ilkka Seppälä
Copyright (c) 2014-2016 Ilkka Seppälä
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -29,7 +29,7 @@
<parent>
<groupId>com.iluwatar</groupId>
<artifactId>java-design-patterns</artifactId>
<version>1.13.0</version>
<version>1.16.0</version>
</parent>
<artifactId>async-method-invocation</artifactId>
<dependencies>

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,6 +22,9 @@
*/
package com.iluwatar.async.method.invocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
/**
@ -54,6 +57,8 @@ import java.util.concurrent.Callable;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point
*/
@ -120,6 +125,6 @@ public class App {
}
private static void log(String msg) {
System.out.println(String.format("[%1$-10s] - %2$s", Thread.currentThread().getName(), msg));
LOGGER.info(msg);
}
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,8 +25,8 @@ package com.iluwatar.async.method.invocation;
import java.util.concurrent.ExecutionException;
/**
*
* AsyncResult interface
* @param <T> parameter returned when getValue is invoked
*/
public interface AsyncResult<T> {

View File

@ -1,6 +1,6 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
* Copyright (c) 2014-2016 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -57,12 +57,10 @@ public class ThreadAsyncExecutor implements AsyncExecutor {
@Override
public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException {
if (asyncResult.isCompleted()) {
return asyncResult.getValue();
} else {
if (!asyncResult.isCompleted()) {
asyncResult.await();
return asyncResult.getValue();
}
return asyncResult.getValue();
}
/**

View File

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

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