Skip to content

Commit 4805efa

Browse files
GuanHua.WangGuanHua.Wang
GuanHua.Wang
authored and
GuanHua.Wang
committed
Merge remote-tracking branch 'iluwatar/master'
2 parents e01c852 + cca4760 commit 4805efa

File tree

1,705 files changed

+86308
-8664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,705 files changed

+86308
-8664
lines changed

.gitignore

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
target
2-
.metadata
3-
.settings
4-
.classpath
5-
.project
6-
*.class
7-
# Package Files #
8-
*.jar
9-
*.war
10-
*.ear
1+
target
2+
.metadata
3+
.settings
4+
.classpath
5+
.project
6+
*.class
7+
# Package Files #
8+
*.jar
9+
*.war
10+
*.ear
11+
.idea
12+
*.iml
13+
*.swp
14+
datanucleus.log
15+
/bin/
16+
/bin/
17+
/bin/
18+
*.log
19+
data-mapper/src/main/resources/log4j.xml

.travis.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
language: java
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
5+
env:
6+
global:
7+
- GH_REF: github.com/iluwatar/java-design-patterns.git
8+
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
9+
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="
10+
11+
before_install:
12+
- export DISPLAY=:99.0
13+
- sh -e /etc/init.d/xvfb start
14+
15+
# default install command is just "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V"
16+
install:
17+
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
18+
19+
after_success:
20+
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN
21+
- bash update-ghpages.sh
22+
23+
# use latest java version available instead of travis default
24+
addons:
25+
apt:
26+
packages:
27+
- oracle-java8-installer
28+
29+
notifications:
30+
email:
31+
- iluwatar@gmail.com
32+
webhooks:
33+
urls:
34+
- https://webhooks.gitter.im/e/3319623945358a093a6f
35+
on_success: change # options: [always|never|change] default: always
36+
on_failure: always # options: [always|never|change] default: always
37+
on_start: never # options: [always|never|change] default: always
38+
39+
sudo: false # route the build to the container-based infrastructure for a faster build

CODE_COVERAGE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Code Coverage Report generation
2+
3+
To generate the code coverage report, execute the following command:
4+
> mvn clean verify
5+
6+
This will generate code coverage report in each of the modules. In order to view the same, open the following file in your browser.
7+
> target/site/jacoco/index.html
8+
9+
Please note that the above folder is created under each of the modules. For example:
10+
* adapter/target/site/jacoco/index.html
11+
* busniess-delegate/target/site/jacoco/index.html
12+
13+

CONTRIBUTING.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This is great you have something to contribute!
2+
3+
Before going any further please read the [wiki](https://github.com/iluwatar/java-design-patterns/wiki)
4+
with conventions and rules we used for this project.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Ilkka Seppälä
3+
Copyright (c) 2014-2016 Ilkka Seppälä
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 29 additions & 371 deletions
Large diffs are not rendered by default.

_scripts/postPumlsToServer.firstrun.output

Lines changed: 190 additions & 0 deletions
Large diffs are not rendered by default.

_scripts/postPumlsToServer.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#
2+
# The MIT License
3+
# Copyright (c) 2014-2016 Ilkka Seppälä
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
#
23+
24+
import requests, glob, re, os
25+
26+
# taken from here: http://stackoverflow.com/a/13641746
27+
def replace(file, pattern, subst):
28+
# Read contents from file as a single string
29+
file_handle = open(file, 'r')
30+
file_string = file_handle.read()
31+
file_handle.close()
32+
33+
# Use RE package to allow for replacement (also allowing for (multiline) REGEX)
34+
file_string = (re.sub(pattern, subst, file_string))
35+
36+
# Write contents to file.
37+
# Using mode 'w' truncates the file.
38+
file_handle = open(file, 'w')
39+
file_handle.write(file_string)
40+
file_handle.close()
41+
42+
# list of all puml files
43+
fileList = glob.glob('*/etc/*.puml')
44+
for puml in fileList:
45+
pathSplit = puml.split("/")
46+
# parent folder
47+
parent = pathSplit[0]
48+
# individual artifact/project name
49+
artifact = pathSplit[2].replace(".urm.puml", "")
50+
print "parent: " + parent + "; artifact: " + artifact
51+
52+
# do a POST to the official plantuml hosting site with a little trick "!includeurl" and raw github content
53+
data = {
54+
'text': "!includeurl https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/" + puml
55+
}
56+
r = requests.post('http://plantuml.com/plantuml/uml', data=data)
57+
pumlId = r.url.replace("http://plantuml.com/plantuml/uml/", "")
58+
59+
# the only thing needed to get a png/svg/ascii from the server back
60+
print "Puml Server ID: " + pumlId
61+
62+
# add the id so jekyll/liquid can use it
63+
if (parent == artifact):
64+
replace("./" + parent + "/README.md", "categories:", "pumlid: {}\\ncategories:".format(pumlId))
65+
else:
66+
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)
67+

abstract-document/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
layout: pattern
3+
title: Abstract Document
4+
folder: abstract-document
5+
permalink: /patterns/abstract-document/
6+
pumlid: PSjB3eCm34NHhPG599vtDyQn85L-ifzX-p3lxEf8Twj3MXGDQvyJMFubChxpKN767gucSq07iinEjSNDOACVNvoAUZr6MWoe3QVE_WRnxZ0Mf38b-hkIGlurX_MyehS7
7+
categories: Structural
8+
tags:
9+
- Java
10+
- Difficulty-Intermediate
11+
---
12+
13+
## Intent
14+
Achieve flexibility of untyped languages and keep the type-safety
15+
16+
![alt text](./etc/abstract-document-base.png "Abstract Document Base")
17+
18+
![alt text](./etc/abstract-document.png "Abstract Document Traits and Domain")
19+
20+
21+
## Applicability
22+
Use the Abstract Document Pattern when
23+
24+
* there is a need to add new properties on the fly
25+
* you want a flexible way to organize domain in tree like structure
26+
* you want more loosely coupled system
27+
28+
29+
## Credits
30+
31+
* [Wikipedia: Abstract Document Pattern](https://en.wikipedia.org/wiki/Abstract_Document_Pattern)
32+
* [Martin Fowler: Dealing with properties](http://martinfowler.com/apsupp/properties.pdf)
14.6 KB
Loading
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
5+
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="249" y="405"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="true" private="true" static="true"/>
11+
</display>
12+
</interface>
13+
<class id="2" language="java" name="com.iluwatar.abstractdocument.AbstractDocument" project="design-patterns"
14+
file="/design-patterns/src/com/iluwatar/abstractdocument/AbstractDocument.java" binary="false" corner="BOTTOM_RIGHT">
15+
<position height="-1" width="-1" x="250" y="237"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
19+
<operations public="true" package="true" protected="true" private="true" static="true"/>
20+
</display>
21+
</class>
22+
<class id="3" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
23+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
24+
<position height="-1" width="-1" x="108" y="75"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</class>
31+
<class id="4" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
32+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
33+
<position height="-1" width="-1" x="400" y="76"/>
34+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
35+
sort-features="false" accessors="true" visibility="true">
36+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
37+
<operations public="true" package="true" protected="true" private="true" static="true"/>
38+
</display>
39+
</class>
40+
<generalization id="5">
41+
<end type="SOURCE" refId="4"/>
42+
<end type="TARGET" refId="2"/>
43+
</generalization>
44+
<realization id="6">
45+
<end type="SOURCE" refId="2"/>
46+
<end type="TARGET" refId="1"/>
47+
</realization>
48+
<generalization id="7">
49+
<end type="SOURCE" refId="3"/>
50+
<end type="TARGET" refId="2"/>
51+
</generalization>
52+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
53+
sort-features="false" accessors="true" visibility="true">
54+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
55+
<operations public="true" package="true" protected="true" private="true" static="true"/>
56+
</classifier-display>
57+
<association-display labels="true" multiplicity="true"/>
58+
</class-diagram>
16.3 KB
Loading
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.9" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<interface id="1" language="java" name="com.iluwatar.abstractdocument.Document" project="design-patterns"
5+
file="/design-patterns/src/com/iluwatar/abstractdocument/Document.java" binary="false" corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="341" y="376"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10+
<operations public="true" package="true" protected="true" private="true" static="true"/>
11+
</display>
12+
</interface>
13+
<interface id="2" language="java" name="com.iluwatar.abstractdocument.domain.HasModel" project="design-patterns"
14+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasModel.java" binary="false" corner="BOTTOM_RIGHT">
15+
<position height="81" width="173" x="41" y="194"/>
16+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
17+
sort-features="false" accessors="true" visibility="true">
18+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
19+
<operations public="true" package="true" protected="true" private="true" static="true"/>
20+
</display>
21+
</interface>
22+
<interface id="3" language="java" name="com.iluwatar.abstractdocument.domain.HasPrice" project="design-patterns"
23+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasPrice.java" binary="false" corner="BOTTOM_RIGHT">
24+
<position height="81" width="175" x="254" y="194"/>
25+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
26+
sort-features="false" accessors="true" visibility="true">
27+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
28+
<operations public="true" package="true" protected="true" private="true" static="true"/>
29+
</display>
30+
</interface>
31+
<interface id="4" language="java" name="com.iluwatar.abstractdocument.domain.HasParts" project="design-patterns"
32+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/HasParts.java" binary="false" corner="BOTTOM_RIGHT">
33+
<position height="81" width="173" x="469" y="194"/>
34+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
35+
sort-features="false" accessors="true" visibility="true">
36+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
37+
<operations public="true" package="true" protected="true" private="true" static="true"/>
38+
</display>
39+
</interface>
40+
<class id="5" language="java" name="com.iluwatar.abstractdocument.domain.Car" project="design-patterns"
41+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Car.java" binary="false" corner="BOTTOM_RIGHT">
42+
<position height="99" width="173" x="254" y="37"/>
43+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
44+
sort-features="false" accessors="true" visibility="true">
45+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
46+
<operations public="true" package="true" protected="true" private="true" static="true"/>
47+
</display>
48+
</class>
49+
<class id="6" language="java" name="com.iluwatar.abstractdocument.domain.Part" project="design-patterns"
50+
file="/design-patterns/src/com/iluwatar/abstractdocument/domain/Part.java" binary="false" corner="BOTTOM_RIGHT">
51+
<position height="99" width="173" x="41" y="37"/>
52+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
53+
sort-features="false" accessors="true" visibility="true">
54+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
55+
<operations public="true" package="true" protected="true" private="true" static="true"/>
56+
</display>
57+
</class>
58+
<realization id="7">
59+
<end type="SOURCE" refId="5"/>
60+
<end type="TARGET" refId="2"/>
61+
</realization>
62+
<realization id="8">
63+
<end type="SOURCE" refId="6"/>
64+
<end type="TARGET" refId="2"/>
65+
</realization>
66+
<generalization id="9">
67+
<end type="SOURCE" refId="2"/>
68+
<end type="TARGET" refId="1"/>
69+
</generalization>
70+
<realization id="10">
71+
<end type="SOURCE" refId="5"/>
72+
<end type="TARGET" refId="3"/>
73+
</realization>
74+
<realization id="11">
75+
<end type="SOURCE" refId="5"/>
76+
<end type="TARGET" refId="4"/>
77+
</realization>
78+
<generalization id="12">
79+
<end type="SOURCE" refId="3"/>
80+
<end type="TARGET" refId="1"/>
81+
</generalization>
82+
<generalization id="13">
83+
<end type="SOURCE" refId="4"/>
84+
<end type="TARGET" refId="1"/>
85+
</generalization>
86+
<realization id="14">
87+
<end type="SOURCE" refId="6"/>
88+
<end type="TARGET" refId="3"/>
89+
</realization>
90+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
91+
sort-features="false" accessors="true" visibility="true">
92+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
93+
<operations public="true" package="true" protected="true" private="true" static="true"/>
94+
</classifier-display>
95+
<association-display labels="true" multiplicity="true"/>
96+
</class-diagram>

0 commit comments

Comments
 (0)