Merged from master
This commit is contained in:
commit
0bf2a2fb5d
116
README.md
116
README.md
@ -6,26 +6,23 @@
|
||||
|
||||
[](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
 [](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master) <a href="https://scan.coverity.com/projects/5634">
|
||||
[](https://travis-ci.org/iluwatar/java-design-patterns) [](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master) <a href="https://scan.coverity.com/projects/5634">
|
||||
<img alt="Coverity Scan Build Status"
|
||||
src="https://scan.coverity.com/projects/5634/badge.svg"/>
|
||||
</a>
|
||||
|
||||
|
||||
#### Browse and view all of the patterns on our Website: [iluwatar.github.io/java-design-patterns/](https://iluwatar.github.io/java-design-patterns/)
|
||||
|
||||
<a name="top"/>
|
||||
|
||||
# <a name="toc">Table of Contents</a>
|
||||
- <a href="#introduction">Introduction</a>
|
||||
- <a href="#contribute">How to contribute</a>
|
||||
- <a href="#faq">Frequently Asked Questions</a>
|
||||
- <a href="#how-to-contribute">How to contribute</a>
|
||||
- <a href="#versioning">Versioning</a>
|
||||
- <a href="#credits">Credits</a>
|
||||
- <a href="#license">License</a>
|
||||
|
||||
|
||||
## <a name="introduction">Introduction</a>
|
||||
# <a name="introduction">Introduction</a> [↑](#top)
|
||||
|
||||
Design patterns are formalized best practices that the programmer can use to
|
||||
solve common problems when designing an application or system.
|
||||
@ -38,6 +35,11 @@ problems, and it also improves code readability for coders and architects who
|
||||
are familiar with the patterns.
|
||||
|
||||
|
||||
# <a name="contribute">How to contribute</a> [↑](#top)
|
||||
|
||||
If you are willing to contribute to the project you will find the relevant information in our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki).
|
||||
|
||||
|
||||
# <a name="faq">Frequently asked questions</a> [↑](#top)
|
||||
|
||||
**<a id="Q1">Q: What is the difference between State and Strategy patterns?</a>**
|
||||
@ -97,98 +99,6 @@ blocked waiting for available object from the pool. This is not the case with
|
||||
Flyweight.
|
||||
|
||||
|
||||
|
||||
# <a name="how-to-contribute">How to contribute</a> [↑](#top)
|
||||
|
||||
**To work on a new pattern** you need to do the following steps:
|
||||
|
||||
1. If there is no issue for the new pattern yet, raise new issue. Comment on
|
||||
the issue that you are working on it so that others don't start work on the
|
||||
same thing.
|
||||
2. Fork the repository.
|
||||
3. Create a new folder for the pattern. The rough structure of the new folder would be as follows:
|
||||
* etc (every resource related to the pattern, like diagrams)
|
||||
* src (the source code of the pattern)
|
||||
* index.md (the description of the pattern)
|
||||
* pom.xml (the maven pom.xml)
|
||||
4. Implement the code changes in your fork. Remember to add sufficient comments
|
||||
documenting the implementation. Reference the issue id e.g. #52 in your
|
||||
commit messages.
|
||||
5. Format the code according to [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
|
||||
* [Eclipse configuration](https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml)
|
||||
* [IntelliJ configuration](https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml)
|
||||
6. Create a simple class diagram from your example code and put it inside of the etc folder.
|
||||
7. Add description of the pattern in index.md and link to the class diagram.
|
||||
(Attention, all internal links must be relative to the pattern subdirectory, else the links dont link properly on the website)
|
||||
8. Create a pull request.
|
||||
|
||||
**Structure of the index.md file**
|
||||
|
||||
```markdown
|
||||
--- # this is so called 'Yaml Front Matter', read up on it here: http://jekyllrb.com/docs/frontmatter/
|
||||
layout: pattern # layout must allways be pattern
|
||||
title: Best Pattern Ever # the properly formatted title
|
||||
folder: best-pattern-ever # the folder name in which this pattern lies
|
||||
permalink: /patterns/best-pattern-ever/ # the permalink to the pattern, to keep this uniform please stick to /patterns/FOLDER/
|
||||
|
||||
# both categories and tags are Yaml Lists
|
||||
# you can either just pick one or write a list with '-'s
|
||||
# usable categories and tags are listed here: https://github.com/iluwatar/java-design-patterns/blob/gh-pages/_config.yml
|
||||
categories: creational # categories of the pattern
|
||||
tags: # tags of the pattern
|
||||
- best
|
||||
- ever
|
||||
- awesome
|
||||
---
|
||||
|
||||
**Intent:** Makes your code awesome
|
||||
|
||||

|
||||
|
||||
**Applicability:** Use the Best Pattern Ever pattern when
|
||||
|
||||
* you want to be the best
|
||||
* you need to ...
|
||||
|
||||
**Real world examples:**
|
||||
|
||||
* [Nowhere](http://no.where.com)
|
||||
```
|
||||
|
||||
**To add a new category or tag** you need to edit the _config.yml file of the gh-pages branch.
|
||||
In there you should find 2 yaml lists with the respective names 'category-list' and 'tag-list'
|
||||
|
||||
**To work on one of the non-pattern issues** you need to do the following steps:
|
||||
|
||||
1. Check that the issue has "help wanted" badge
|
||||
2. Comment on the issue that you are working on it
|
||||
3. Fork the repository.
|
||||
4. Implement the code changes in your fork. Remember to add sufficient comments
|
||||
documenting the implementation. Reference the issue id e.g. #52 in your
|
||||
commit messages.
|
||||
5. Create a pull request.
|
||||
|
||||
**For creating/editing UML diagrams** you need [ObjectAid UML Explorer for Eclipse](http://www.objectaid.com/home).
|
||||
|
||||
**For inspiration** check out the following sources:
|
||||
|
||||
* there is a good list of design patterns at [Wikipedia](http://en.wikipedia.org/wiki/Software_design_pattern)
|
||||
* Martin Fowler's [Catalog of Patterns of Enterprise Application Architecture](http://martinfowler.com/eaaCatalog/)
|
||||
* [pattern language for microservices](http://microservices.io/patterns/index.html)
|
||||
* Microsoft's [Cloud Design Patterns](http://download.microsoft.com/download/B/B/6/BB69622C-AB5D-4D5F-9A12-B81B952C1169/CloudDesignPatternsBook-PDF.pdf)
|
||||
|
||||
**Links to patterns applied in real world applications** are welcome. The links
|
||||
should be added to the corresponding section of the `index.md`.
|
||||
|
||||
|
||||
# <a name="versioning">Versioning</a> [↑](#top)
|
||||
|
||||
Java-design-patterns project uses [semantic versioning](http://semver.org/)
|
||||
scheme. However, version numbers in this project do not signify binary releases
|
||||
(since we don't make any) but rather milestones achieved on the roadmap. In
|
||||
other words, version numbers are used only for project planning sake.
|
||||
|
||||
|
||||
# <a name="credits">Credits</a> [↑](#top)
|
||||
|
||||
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)
|
||||
@ -196,21 +106,11 @@ other words, version numbers are used only for project planning sake.
|
||||
* [Java Generics and Collections](http://www.amazon.com/Java-Generics-Collections-Maurice-Naftalin/dp/0596527756/)
|
||||
* [Let's Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
|
||||
* [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
|
||||
* [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
|
||||
* [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm)
|
||||
* [Presentation Tier Patterns](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
|
||||
* [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
|
||||
* [Martin Fowler - Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html)
|
||||
* [Martin Fowler - Specifications](http://martinfowler.com/apsupp/spec.pdf)
|
||||
* [Martin Fowler - Tolerant Reader](http://martinfowler.com/bliki/TolerantReader.html)
|
||||
* [Trygve Reenskaug - Model-view-controller](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)
|
||||
* [Flux - Application architecture for building user interfaces](http://facebook.github.io/flux/)
|
||||
* [Richard Pawson - Naked Objects](http://downloads.nakedobjects.net/resources/Pawson%20thesis.pdf)
|
||||
* [Patterns of Enterprise Application Architecture](http://www.amazon.com/Patterns-Enterprise-Application-Architecture-Martin/dp/0321127420)
|
||||
* [Spring Data](http://www.amazon.com/Spring-Data-Mark-Pollack/dp/1449323952/ref=sr_1_1)
|
||||
* [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
|
||||
* [Marco Castigliego - Step Builder](http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html)
|
||||
* [Douglas C. Schmidt and Charles D. Cranor - Half Sync/Half Async](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
|
||||
* [Pattern Oriented Software Architecture Vol I-V](http://www.amazon.com/Pattern-Oriented-Software-Architecture-Volume-Patterns/dp/0471958697)
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>abstract-factory</artifactId>
|
||||
<dependencies>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.iluwatar.abstractfactory;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The essence of the Abstract Factory pattern is a factory interface
|
||||
@ -12,26 +13,61 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
createKingdom(new ElfKingdomFactory());
|
||||
createKingdom(new OrcKingdomFactory());
|
||||
}
|
||||
private King king;
|
||||
private Castle castle;
|
||||
private Army army;
|
||||
|
||||
/**
|
||||
* Creates kingdom
|
||||
* @param factory
|
||||
*/
|
||||
public static void createKingdom(KingdomFactory factory) {
|
||||
King king = factory.createKing();
|
||||
Castle castle = factory.createCastle();
|
||||
Army army = factory.createArmy();
|
||||
System.out.println("The kingdom was created.");
|
||||
System.out.println(king);
|
||||
System.out.println(castle);
|
||||
System.out.println(army);
|
||||
public void createKingdom(final KingdomFactory factory) {
|
||||
setKing(factory.createKing());
|
||||
setCastle(factory.createCastle());
|
||||
setArmy(factory.createArmy());
|
||||
}
|
||||
|
||||
ElfKingdomFactory getElfKingdomFactory() {
|
||||
return new ElfKingdomFactory();
|
||||
}
|
||||
|
||||
OrcKingdomFactory getOrcKingdomFactory() {
|
||||
return new OrcKingdomFactory();
|
||||
}
|
||||
|
||||
King getKing(final KingdomFactory factory) {
|
||||
return factory.createKing();
|
||||
}
|
||||
|
||||
Castle getCastle(final KingdomFactory factory) {
|
||||
return factory.createCastle();
|
||||
}
|
||||
|
||||
Army getArmy(final KingdomFactory factory) {
|
||||
return factory.createArmy();
|
||||
}
|
||||
|
||||
public King getKing() {
|
||||
return king;
|
||||
}
|
||||
|
||||
private void setKing(final King king) {
|
||||
this.king = king;
|
||||
}
|
||||
|
||||
public Castle getCastle() {
|
||||
return castle;
|
||||
}
|
||||
|
||||
private void setCastle(final Castle castle) {
|
||||
this.castle = castle;
|
||||
}
|
||||
|
||||
public Army getArmy() {
|
||||
return army;
|
||||
}
|
||||
|
||||
private void setArmy(final Army army) {
|
||||
this.army = army;
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public interface Army {
|
||||
|
||||
String getDescription();
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public interface Castle {
|
||||
|
||||
String getDescription();
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class ElfArmy implements Army {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Elven Army!";
|
||||
}
|
||||
static final String DESCRIPTION = "This is the Elven Army!";
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class ElfCastle implements Castle {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Elven castle!";
|
||||
}
|
||||
static final String DESCRIPTION = "This is the Elven castle!";
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class ElfKing implements King {
|
||||
|
||||
static final String DESCRIPTION = "This is the Elven king!";
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Elven king!";
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public interface King {
|
||||
|
||||
String getDescription();
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class OrcArmy implements Army {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Orcish Army!";
|
||||
}
|
||||
static final String DESCRIPTION = "This is the Orc Army!";
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class OrcCastle implements Castle {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Orcish castle!";
|
||||
}
|
||||
static final String DESCRIPTION = "This is the Orc castle!";
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ package com.iluwatar.abstractfactory;
|
||||
*/
|
||||
public class OrcKing implements King {
|
||||
|
||||
static final String DESCRIPTION = "This is the Orc king!";
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "This is the Orc king!";
|
||||
public String getDescription() {
|
||||
return DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,77 @@
|
||||
package com.iluwatar.abstractfactory;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.abstractfactory.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
private App app = new App();;
|
||||
private KingdomFactory elfFactory;
|
||||
private KingdomFactory orcFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
elfFactory = app.getElfKingdomFactory();
|
||||
orcFactory = app.getOrcKingdomFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
public void king() {
|
||||
final King elfKing = app.getKing(elfFactory);
|
||||
assertTrue(elfKing instanceof ElfKing);
|
||||
assertEquals(ElfKing.DESCRIPTION, elfKing.getDescription());
|
||||
final King orcKing = app.getKing(orcFactory);
|
||||
assertTrue(orcKing instanceof OrcKing);
|
||||
assertEquals(OrcKing.DESCRIPTION, orcKing.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castle() {
|
||||
final Castle elfCastle = app.getCastle(elfFactory);
|
||||
assertTrue(elfCastle instanceof ElfCastle);
|
||||
assertEquals(ElfCastle.DESCRIPTION, elfCastle.getDescription());
|
||||
final Castle orcCastle = app.getCastle(orcFactory);
|
||||
assertTrue(orcCastle instanceof OrcCastle);
|
||||
assertEquals(OrcCastle.DESCRIPTION, orcCastle.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void army() {
|
||||
final Army elfArmy = app.getArmy(elfFactory);
|
||||
assertTrue(elfArmy instanceof ElfArmy);
|
||||
assertEquals(ElfArmy.DESCRIPTION, elfArmy.getDescription());
|
||||
final Army orcArmy = app.getArmy(orcFactory);
|
||||
assertTrue(orcArmy instanceof OrcArmy);
|
||||
assertEquals(OrcArmy.DESCRIPTION, orcArmy.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createElfKingdom() {
|
||||
app.createKingdom(elfFactory);
|
||||
final King king = app.getKing();
|
||||
final Castle castle = app.getCastle();
|
||||
final Army army = app.getArmy();
|
||||
assertTrue(king instanceof ElfKing);
|
||||
assertEquals(ElfKing.DESCRIPTION, king.getDescription());
|
||||
assertTrue(castle instanceof ElfCastle);
|
||||
assertEquals(ElfCastle.DESCRIPTION, castle.getDescription());
|
||||
assertTrue(army instanceof ElfArmy);
|
||||
assertEquals(ElfArmy.DESCRIPTION, army.getDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrcKingdom() {
|
||||
app.createKingdom(orcFactory);
|
||||
final King king = app.getKing();
|
||||
final Castle castle = app.getCastle();
|
||||
final Army army = app.getArmy();
|
||||
assertTrue(king instanceof OrcKing);
|
||||
assertEquals(OrcKing.DESCRIPTION, king.getDescription());
|
||||
assertTrue(castle instanceof OrcCastle);
|
||||
assertEquals(OrcCastle.DESCRIPTION, castle.getDescription());
|
||||
assertTrue(army instanceof OrcArmy);
|
||||
assertEquals(OrcArmy.DESCRIPTION, army.getDescription());
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>adapter</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>async-method-invocation</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>bridge</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>builder</artifactId>
|
||||
<dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>business-delegate</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>callback</artifactId>
|
||||
<dependencies>
|
||||
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
layout: pattern
|
||||
title: Chain of responsibility
|
||||
folder: chain-of-responsibility
|
||||
permalink: /patterns/chain-of-responsibility/
|
||||
folder: chain
|
||||
permalink: /patterns/chain/
|
||||
categories: Behavioral
|
||||
tags: Java
|
||||
---
|
||||
@ -11,7 +11,7 @@ tags: Java
|
||||
more than one object a chance to handle the request. Chain the receiving
|
||||
objects and pass the request along the chain until an object handles it.
|
||||
|
||||

|
||||

|
||||
|
||||
**Applicability:** Use Chain of Responsibility when
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>chain</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>command</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>composite</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>dao</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>decorator</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>dependency-injection</artifactId>
|
||||
<dependencies>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>double-checked-locking</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>double-dispatch</artifactId>
|
||||
<dependencies>
|
||||
|
@ -23,3 +23,7 @@ allowing clients to register with just the aggregator.
|
||||
with them all, you can centralize the registration logic to the Event
|
||||
Aggregator. As well as simplifying registration, a Event Aggregator also
|
||||
simplifies the memory management issues in using observers.
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>event-aggregator</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>execute-around</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>facade</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>factory-method</artifactId>
|
||||
<dependencies>
|
||||
|
@ -17,3 +17,7 @@ logic, which updates all of the views that are affected.
|
||||
**Applicability:** Use the Flux pattern when
|
||||
|
||||
* you want to focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Flux - Application architecture for building user interfaces](http://facebook.github.io/flux/)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>flux</artifactId>
|
||||
<dependencies>
|
||||
|
@ -15,6 +15,7 @@ efficiently.
|
||||
**Applicability:** The Flyweight pattern's effectiveness depends heavily on how
|
||||
and where it's used. Apply the Flyweight pattern when all of the following are
|
||||
true
|
||||
|
||||
* an application uses a large number of objects
|
||||
* storage costs are high because of the sheer quantity of objects
|
||||
* most object state can be made extrinsic
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>flyweight</artifactId>
|
||||
<dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>front-controller</artifactId>
|
||||
<dependencies>
|
||||
|
@ -26,3 +26,7 @@ degrading execution efficiency.
|
||||
* [BSD Unix networking subsystem](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
|
||||
* [Real Time CORBA](http://www.omg.org/news/meetings/workshops/presentations/realtime2001/4-3_Pyarali_thread-pool.pdf)
|
||||
* [Android AsyncTask framework](http://developer.android.com/reference/android/os/AsyncTask.html)
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Douglas C. Schmidt and Charles D. Cranor - Half Sync/Half Async](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>half-sync-half-async</artifactId>
|
||||
<dependencies>
|
||||
|
@ -17,3 +17,7 @@ post-processing to requests from a client to a target
|
||||
* a system uses pre-processing or post-processing requests
|
||||
* a system should do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers
|
||||
* you want a modular approach to configuring pre-processing and post-processing schemes
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>intercepting-filter</artifactId>
|
||||
<dependencies>
|
||||
|
@ -16,5 +16,6 @@ language.
|
||||
**Applicability:** Use the Interpreter pattern when there is a language to
|
||||
interpret, and you can represent statements in the language as abstract syntax
|
||||
trees. The Interpreter pattern works best when
|
||||
|
||||
* the grammar is simple. For complex grammars, the class hierarchy for the grammar becomes large and unmanageable. Tools such as parser generators are a better alternative in such cases. They can interpret expressions without building abstract syntax trees, which can save space and possibly time
|
||||
* efficiency is not a critical concern. The most efficient interpreters are usually not implemented by interpreting parse trees directly but by first translating them into another form. For example, regular expressions are often transformed into state machines. But even then, the translator can be implemented by the Interpreter pattern, so the pattern is still applicable
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>interpreter</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>iterator</artifactId>
|
||||
<dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<groupId>com.iluwatar.layers</groupId>
|
||||
<artifactId>layers</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>lazy-loading</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>mediator</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>memento</artifactId>
|
||||
<dependencies>
|
||||
|
1
message-channel/.gitignore
vendored
Normal file
1
message-channel/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target/
|
BIN
message-channel/etc/message-channel.png
Normal file
BIN
message-channel/etc/message-channel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
320
message-channel/etc/message-channel.ucls
Normal file
320
message-channel/etc/message-channel.ucls
Normal file
@ -0,0 +1,320 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
|
||||
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
|
||||
<class id="1" language="java" name="org.apache.camel.builder.RouteBuilder" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="920" y="458"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="2" language="java" name="org.apache.camel.CamelContext" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="674" y="458"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<class id="3" language="java" name="org.apache.camel.model.RouteDefinition" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="673" y="48"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="4" language="java" name="org.apache.camel.model.ProcessorDefinition" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="673" y="-96"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="5" language="java" name="org.apache.camel.model.OptionalIdentifiedDefinition" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="248" y="-96"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="6" language="java" name="org.apache.camel.NamedNode" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="249" y="0"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="7" language="java" name="org.apache.camel.model.Block" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="464" y="13"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="8" language="java" name="org.apache.camel.RoutesBuilder" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="920" y="590"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<class id="9" language="java" name="org.apache.camel.builder.BuilderSupport" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="920" y="297"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="10" language="java" name="org.apache.camel.SuspendableService" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="267" y="458"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="11" language="java" name="org.apache.camel.Service" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="267" y="297"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="12" language="java" name="org.apache.camel.RuntimeConfiguration" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="674" y="590"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<class id="13" language="java" name="org.apache.camel.impl.DefaultCamelContext" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="673" y="167"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="14" language="java" name="org.apache.camel.support.ServiceSupport" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="265" y="91"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="15" language="java" name="org.apache.camel.StatefulService" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="5" y="188"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="16" language="java" name="org.apache.camel.ShutdownableService" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="265" y="188"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<interface id="17" language="java" name="org.apache.camel.model.ModelCamelContext" project="message-channel"
|
||||
file="C:/Users/ilkka/.m2/repository/org/apache/camel/camel-core/2.15.3/camel-core-2.15.3.jar" binary="true"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="674" y="297"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</display>
|
||||
</interface>
|
||||
<generalization id="18">
|
||||
<end type="SOURCE" refId="4"/>
|
||||
<end type="TARGET" refId="5"/>
|
||||
</generalization>
|
||||
<generalization id="19">
|
||||
<end type="SOURCE" refId="2"/>
|
||||
<end type="TARGET" refId="10"/>
|
||||
</generalization>
|
||||
<realization id="20">
|
||||
<end type="SOURCE" refId="1"/>
|
||||
<end type="TARGET" refId="8"/>
|
||||
</realization>
|
||||
<association id="21">
|
||||
<end type="SOURCE" refId="9" navigable="false">
|
||||
<attribute id="22" name="context">
|
||||
<position height="0" width="0" x="-583" y="-276"/>
|
||||
</attribute>
|
||||
<multiplicity id="23" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="-583" y="-276"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="17" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="24">
|
||||
<end type="SOURCE" refId="4" navigable="false">
|
||||
<attribute id="25" name="blocks">
|
||||
<position height="0" width="0" x="145" y="-462"/>
|
||||
</attribute>
|
||||
<multiplicity id="26" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="145" y="-462"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="27">
|
||||
<end type="SOURCE" refId="13" navigable="false">
|
||||
<attribute id="28" name="servicesToClose">
|
||||
<position height="0" width="0" x="-409" y="37"/>
|
||||
</attribute>
|
||||
<multiplicity id="29" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="-409" y="37"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="11" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<realization id="30">
|
||||
<end type="SOURCE" refId="13"/>
|
||||
<end type="TARGET" refId="17"/>
|
||||
</realization>
|
||||
<realization id="31">
|
||||
<end type="SOURCE" refId="14"/>
|
||||
<end type="TARGET" refId="15"/>
|
||||
</realization>
|
||||
<generalization id="32">
|
||||
<end type="SOURCE" refId="17"/>
|
||||
<end type="TARGET" refId="2"/>
|
||||
</generalization>
|
||||
<generalization id="33">
|
||||
<end type="SOURCE" refId="15"/>
|
||||
<end type="TARGET" refId="10"/>
|
||||
</generalization>
|
||||
<generalization id="34">
|
||||
<end type="SOURCE" refId="1"/>
|
||||
<end type="TARGET" refId="9"/>
|
||||
</generalization>
|
||||
<generalization id="35">
|
||||
<end type="SOURCE" refId="3"/>
|
||||
<end type="TARGET" refId="4"/>
|
||||
</generalization>
|
||||
<generalization id="36">
|
||||
<end type="SOURCE" refId="16"/>
|
||||
<end type="TARGET" refId="11"/>
|
||||
</generalization>
|
||||
<generalization id="37">
|
||||
<end type="SOURCE" refId="15"/>
|
||||
<end type="TARGET" refId="16"/>
|
||||
</generalization>
|
||||
<generalization id="38">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="11"/>
|
||||
</generalization>
|
||||
<realization id="39">
|
||||
<end type="SOURCE" refId="4"/>
|
||||
<end type="TARGET" refId="7"/>
|
||||
</realization>
|
||||
<association id="40">
|
||||
<end type="SOURCE" refId="4" navigable="false">
|
||||
<attribute id="41" name="parent">
|
||||
<position height="0" width="0" x="329" y="-461"/>
|
||||
</attribute>
|
||||
<multiplicity id="42" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="329" y="-461"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="4" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<realization id="43">
|
||||
<end type="SOURCE" refId="5"/>
|
||||
<end type="TARGET" refId="6"/>
|
||||
</realization>
|
||||
<generalization id="44">
|
||||
<end type="SOURCE" refId="2"/>
|
||||
<end type="TARGET" refId="12"/>
|
||||
</generalization>
|
||||
<generalization id="45">
|
||||
<end type="SOURCE" refId="13"/>
|
||||
<end type="TARGET" refId="14"/>
|
||||
</generalization>
|
||||
<association id="46">
|
||||
<end type="SOURCE" refId="3" navigable="false">
|
||||
<attribute id="47" name="outputs">
|
||||
<position height="0" width="0" x="329" y="-461"/>
|
||||
</attribute>
|
||||
<multiplicity id="48" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="329" y="-461"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="4" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="49">
|
||||
<end type="SOURCE" refId="13" navigable="false">
|
||||
<attribute id="50" name="routeDefinitions">
|
||||
<position height="0" width="0" x="291" y="-218"/>
|
||||
</attribute>
|
||||
<multiplicity id="51" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="291" y="-218"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<realization id="52">
|
||||
<end type="SOURCE" refId="13"/>
|
||||
<end type="TARGET" refId="10"/>
|
||||
</realization>
|
||||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="true"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="true"/>
|
||||
</classifier-display>
|
||||
<association-display labels="true" multiplicity="true"/>
|
||||
</class-diagram>
|
21
message-channel/index.md
Normal file
21
message-channel/index.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
layout: pattern
|
||||
title: Message Channel
|
||||
folder: message-channel
|
||||
permalink: /patterns/message-channel/
|
||||
categories: Integration
|
||||
tags: Java
|
||||
---
|
||||
|
||||
**Intent:** When two applications communicate using a messaging system they do it by using logical addresses
|
||||
of the system, so called Message Channels.
|
||||
|
||||

|
||||
|
||||
**Applicability:** Use the Message Channel pattern when
|
||||
|
||||
* two or more applications need to communicate using a messaging system
|
||||
|
||||
**Real world examples:**
|
||||
|
||||
* [akka-camel](http://doc.akka.io/docs/akka/snapshot/scala/camel.html)
|
27
message-channel/pom.xml
Normal file
27
message-channel/pom.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>message-channel</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-stream</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,53 @@
|
||||
package com.iluwatar.message.channel;
|
||||
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.apache.camel.impl.DefaultCamelContext;
|
||||
|
||||
/**
|
||||
*
|
||||
* When two applications communicate with each other using a messaging system
|
||||
* they first need to establish a communication channel that will carry the
|
||||
* data. Message Channel decouples Message producers and consumers.
|
||||
* <p>
|
||||
* The sending application doesn't necessarily know what particular application
|
||||
* will end up retrieving it, but it can be assured that the application that
|
||||
* retrieves the information is interested in that information. This is because
|
||||
* the messaging system has different Message Channels for different types of
|
||||
* information the applications want to communicate. When an application sends
|
||||
* information, it doesn't randomly add the information to any channel available;
|
||||
* it adds it to a channel whose specific purpose is to communicate that sort of
|
||||
* information. Likewise, an application that wants to receive particular information
|
||||
* doesn't pull info off some random channel; it selects what channel to get information
|
||||
* from based on what type of information it wants.
|
||||
* <p>
|
||||
* In this example we use Apache Camel to establish two different Message Channels. The first
|
||||
* one reads from standard input and delivers messages to Direct endpoint. The second Message
|
||||
* Channel is established from the Direct component to console output. No actual messages are sent,
|
||||
* only the established routes are printed to standard output.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
CamelContext context = new DefaultCamelContext();
|
||||
|
||||
context.addRoutes(new RouteBuilder() {
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("stream:in").to("direct:greetings");
|
||||
from("direct:greetings").to("stream:out");
|
||||
}
|
||||
});
|
||||
|
||||
context.start();
|
||||
context.getRoutes().stream().forEach((r) -> System.out.println(r));
|
||||
context.stop();
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.iluwatar.message.channel;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
@ -17,3 +17,7 @@ display.
|
||||
**Applicability:** Use the Model-View-Controller pattern when
|
||||
|
||||
* you want to clearly separate the domain data from its user interface representation
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Trygve Reenskaug - Model-view-controller](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>model-view-controller</artifactId>
|
||||
<dependencies>
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* In this second example the model-view relationship is different. This time we use the Observer pattern to notify
|
||||
* the {@link GiantView} each time the {@link GiantModel} is changed. This way the {@link GiantController} responsibilities
|
||||
* are narrowed and it only needs to modify the {@link GiantModel} according to the user input.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main( String[] args ) {
|
||||
// create model, view and controller
|
||||
GiantModel giant = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
GiantView view = new GiantView();
|
||||
GiantController controller = new GiantController(giant, view);
|
||||
// initial display
|
||||
controller.updateView();
|
||||
// controller receives some interactions that affect the giant
|
||||
// model modifications trigger the view rendering automatically
|
||||
controller.setHealth(Health.WOUNDED);
|
||||
controller.setNourishment(Nourishment.HUNGRY);
|
||||
controller.setFatigue(Fatigue.TIRED);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* Fatigue enumeration
|
||||
*
|
||||
*/
|
||||
public enum Fatigue {
|
||||
|
||||
ALERT("alert"), TIRED("tired"), SLEEPING("sleeping");
|
||||
|
||||
private String title;
|
||||
|
||||
Fatigue(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantController updates the giant model.
|
||||
*
|
||||
*/
|
||||
public class GiantController {
|
||||
|
||||
private GiantModel giant;
|
||||
private GiantView view;
|
||||
|
||||
public GiantController(GiantModel giant, GiantView view) {
|
||||
this.giant = giant;
|
||||
this.view = view;
|
||||
this.giant.registerObserver(this.view);
|
||||
}
|
||||
|
||||
public Health getHealth() {
|
||||
return giant.getHealth();
|
||||
}
|
||||
|
||||
public void setHealth(Health health) {
|
||||
this.giant.setHealth(health);
|
||||
}
|
||||
|
||||
public Fatigue getFatigue() {
|
||||
return giant.getFatigue();
|
||||
}
|
||||
|
||||
public void setFatigue(Fatigue fatigue) {
|
||||
this.giant.setFatigue(fatigue);
|
||||
}
|
||||
|
||||
public Nourishment getNourishment() {
|
||||
return giant.getNourishment();
|
||||
}
|
||||
|
||||
public void setNourishment(Nourishment nourishment) {
|
||||
this.giant.setNourishment(nourishment);
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
this.view.displayGiant(giant);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantModel contains the giant data.
|
||||
*
|
||||
*/
|
||||
public class GiantModel {
|
||||
|
||||
private Health health;
|
||||
private Fatigue fatigue;
|
||||
private Nourishment nourishment;
|
||||
private List<GiantModelObserver> observers = new ArrayList<>();
|
||||
|
||||
GiantModel(Health health, Fatigue fatigue, Nourishment nourishment) {
|
||||
this.health = health;
|
||||
this.fatigue = fatigue;
|
||||
this.nourishment = nourishment;
|
||||
}
|
||||
|
||||
public Health getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
public void setHealth(Health health) {
|
||||
this.health = health;
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
public Fatigue getFatigue() {
|
||||
return fatigue;
|
||||
}
|
||||
|
||||
public void setFatigue(Fatigue fatigue) {
|
||||
this.fatigue = fatigue;
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
public Nourishment getNourishment() {
|
||||
return nourishment;
|
||||
}
|
||||
|
||||
public void setNourishment(Nourishment nourishment) {
|
||||
this.nourishment = nourishment;
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("The giant looks %s, %s and %s.", health, fatigue, nourishment);
|
||||
}
|
||||
|
||||
public void registerObserver(GiantModelObserver observer) {
|
||||
observers.add(observer);
|
||||
}
|
||||
|
||||
private void notifyObservers() {
|
||||
observers.stream().forEach((GiantModelObserver o) -> o.modelChanged(this));
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantModelObserver is the interface for delivering update notifications.
|
||||
*
|
||||
*/
|
||||
public interface GiantModelObserver {
|
||||
|
||||
void modelChanged(GiantModel model);
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* GiantView displays the giant
|
||||
*
|
||||
*/
|
||||
public class GiantView implements GiantModelObserver {
|
||||
|
||||
public void displayGiant(GiantModel giant) {
|
||||
System.out.println(giant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modelChanged(GiantModel model) {
|
||||
displayGiant(model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* Health enumeration
|
||||
*
|
||||
*/
|
||||
public enum Health {
|
||||
|
||||
HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead");
|
||||
|
||||
private String title;
|
||||
|
||||
Health(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
/**
|
||||
*
|
||||
* Nourishment enumeration
|
||||
*
|
||||
*/
|
||||
public enum Nourishment {
|
||||
|
||||
SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving");
|
||||
|
||||
private String title;
|
||||
|
||||
Nourishment(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.iluwatar.model.view.controller.with.observer;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.model.view.controller.with.observer.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
@ -14,5 +14,6 @@ developers to build and test user interfaces.
|
||||
|
||||
**Applicability:** Use the Model-View-Presenter in any of the following
|
||||
situations
|
||||
|
||||
* when you want to improve the "Separation of Concerns" principle in presentation logic
|
||||
* when a user interface development and testing is necessary.
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>model-view-presenter</artifactId>
|
||||
<name>model-view-presenter</name>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>multiton</artifactId>
|
||||
<dependencies>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>naked-objects</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects-dom</artifactId>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>naked-objects</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects-fixture</artifactId>
|
||||
|
@ -22,3 +22,7 @@ everything else is autogenerated by the framework.
|
||||
**Real world examples:**
|
||||
|
||||
* [Apache Isis](https://isis.apache.org/)
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Richard Pawson - Naked Objects](http://downloads.nakedobjects.net/resources/Pawson%20thesis.pdf)
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>naked-objects</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects-integtests</artifactId>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects</artifactId>
|
||||
@ -350,17 +350,17 @@
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>naked-objects-dom</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>naked-objects-fixture</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>naked-objects-webapp</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>naked-objects</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects-webapp</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>null-object</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>object-pool</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>observer</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>poison-pill</artifactId>
|
||||
<dependencies>
|
||||
|
18
pom.xml
18
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
@ -17,6 +17,7 @@
|
||||
<coveralls.version>3.1.0</coveralls.version>
|
||||
<jacoco.version>0.7.2.201409121644</jacoco.version>
|
||||
<commons-dbcp.version>1.4</commons-dbcp.version>
|
||||
<camel.version>2.15.3</camel.version>
|
||||
</properties>
|
||||
<modules>
|
||||
<module>abstract-factory</module>
|
||||
@ -71,10 +72,11 @@
|
||||
<module>front-controller</module>
|
||||
<module>repository</module>
|
||||
<module>async-method-invocation</module>
|
||||
<module>business-delegate</module>
|
||||
<module>half-sync-half-async</module>
|
||||
<module>business-delegate</module>
|
||||
<module>half-sync-half-async</module>
|
||||
<module>step-builder</module>
|
||||
<module>layers</module>
|
||||
<module>message-channel</module>
|
||||
<module>reactor</module>
|
||||
</modules>
|
||||
|
||||
@ -105,6 +107,16 @@
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<version>${commons-dbcp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-stream</artifactId>
|
||||
<version>${camel.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>private-class-data</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>property</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>prototype</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>proxy</artifactId>
|
||||
<dependencies>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>repository</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>resource-acquisition-is-initialization</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>servant</artifactId>
|
||||
<dependencies>
|
||||
|
@ -20,3 +20,7 @@ its business logic. The Service Layer fulfills this role.
|
||||
|
||||
* you want to encapsulate domain logic under API
|
||||
* you need to implement multiple interfaces with common logic and data
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Martin Fowler - Service Layer](http://martinfowler.com/eaaCatalog/serviceLayer.html)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>service-layer</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>service-locator</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>singleton</artifactId>
|
||||
<dependencies>
|
||||
|
@ -18,3 +18,7 @@ order
|
||||
|
||||
* you need to select a subset of objects based on some criteria, and to refresh the selection at various times
|
||||
* you need to check that only suitable objects are used for a certain role (validation)
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Martin Fowler - Specifications](http://martinfowler.com/apsupp/spec.pdf)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>specification</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>state</artifactId>
|
||||
<dependencies>
|
||||
|
@ -13,3 +13,7 @@ The user experience will be much more improved by the fact that he will only see
|
||||

|
||||
|
||||
**Applicability:** Use the Step Builder pattern when the algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled the construction process must allow different representations for the object that's constructed when in the process of constructing the order is important.
|
||||
|
||||
**Credits:**
|
||||
|
||||
* [Marco Castigliego - Step Builder](http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html)
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>step-builder</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>strategy</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>template-method</artifactId>
|
||||
<dependencies>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>java-design-patterns</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
</parent>
|
||||
<artifactId>thread-pool</artifactId>
|
||||
<dependencies>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user