Compare commits
93 Commits
Author | SHA1 | Date | |
---|---|---|---|
0c48695fa5 | |||
8d34ccf827 | |||
512a5c0560 | |||
9cf1918425 | |||
5e57cd03d1 | |||
ad93184a79 | |||
95f2c19780 | |||
120033b58b | |||
c94c8a3e74 | |||
5d8806858b | |||
efc2c887e9 | |||
1d6d0c54a7 | |||
1387e2bc96 | |||
faa29f8025 | |||
89e7f51e99 | |||
cc02ff472b | |||
7d995056ff | |||
8574e06966 | |||
82d3d7bf1f | |||
1a75ab8df1 | |||
92f8501f7d | |||
b9ac0dc6a3 | |||
5e7887d9be | |||
e8f7187e4b | |||
d6b5456f98 | |||
52a81eb368 | |||
12b70cb39c | |||
68ec24c62e | |||
3091ff21b0 | |||
95b651f177 | |||
f67d2fd9a9 | |||
4ff8fa3721 | |||
9180bb0fef | |||
1abf5b11c3 | |||
22d973c460 | |||
c850295aab | |||
4c24d99414 | |||
e1ae1067db | |||
6f3e2985a4 | |||
b37190a214 | |||
0a427710bb | |||
e138163c4f | |||
124fd33da0 | |||
9433c78d29 | |||
932700d9b1 | |||
27d6d500bc | |||
ea7752c5e1 | |||
7ba6cb43fd | |||
1ace4c05d6 | |||
7015e95ac3 | |||
2a77ac29e9 | |||
6aed26e61e | |||
74ac79b01e | |||
750fa4f954 | |||
20295316c2 | |||
56b0884258 | |||
0438811489 | |||
1c02785927 | |||
19cb715d20 | |||
ffdaf2ec47 | |||
a37a29e12b | |||
b66e8ecef9 | |||
99677867c6 | |||
0f7b44c3b1 | |||
70318123fe | |||
986c529eb6 | |||
64bdab46b9 | |||
37b930c3b7 | |||
85060784a7 | |||
f114b5b957 | |||
863ea75381 | |||
3a9d1684fd | |||
eea8785a22 | |||
8f1758c28f | |||
622376e0fa | |||
5eacf522a2 | |||
12544caa75 | |||
9512f3ec70 | |||
4ca205c03c | |||
b31edda3cf | |||
e3355d76d1 | |||
865f788612 | |||
6ed842e58b | |||
69cab15d75 | |||
371b262a51 | |||
dbd605e378 | |||
f2159515bc | |||
9a90f2de1f | |||
fce30db803 | |||
233f1e69f9 | |||
f11597136f | |||
e1836fee2f | |||
2d99061902 |
.gitignore.travis.ymlREADME.md
_scripts
abstract-document
abstract-factory
adapter
aggregator-microservices
aggregator-service
etc
information-microservice
inventory-microservice
pom.xmlapi-gateway
api-gateway-service
etc
image-microservice
pom.xmlprice-microservice
async-method-invocation
bridge
builder
business-delegate
caching
callback
chain
checkstyle-suppressions.xmlcheckstyle.xmlcommand
composite
dao
data-mapper
decorator
delegation
dependency-injection
double-checked-locking
double-dispatch
event-aggregator
event-asynchronous
event-driven-architecture
exclude-pmd.propertiesexecute-around
facade
factory-kit
factory-method
feature-toggle
etc
pom.xmlsrc
main
java
com
iluwatar
featuretoggle
test
java
com
iluwatar
featuretoggle
pattern
propertiesversion
tieredversion
user
fluentinterface
etc
pom.xmlsrc
main
java
com
iluwatar
fluentinterface
app
fluentiterable
test
java
com
iluwatar
fluentinterface
app
fluentiterable
flux
flyweight
front-controller
half-sync-half-async
hexagonal
README.md
etc
pom.xmlsrc
main
java
com
iluwatar
hexagonal
App.java
administration
banking
database
domain
LotteryAdministration.javaLotteryConstants.javaLotteryNumbers.javaLotteryService.javaLotteryTicket.javaLotteryTicketCheckResult.javaLotteryTicketId.javaLotteryUtils.javaPlayerDetails.java
eventlog
module
mongo
sampledata
service
test
java
com
iluwatar
hexagonal
intercepting-filter
interpreter
iterator
layers
lazy-loading
mediator
memento
message-channel
model-view-controller
model-view-presenter
module
monad
monostate
multiton
mute-idiom
mutex
naked-objects
null-object
object-mother
object-pool
observer
page-object
poison-pill
pom.xmlprivate-class-data
producer-consumer
promise
property
prototype
proxy
publish-subscribe
queue-load-leveling
reactor
reader-writer-lock
repository
resource-acquisition-is-initialization
etc
pom.xmlsrc
main
java
com
iluwatar
resource
acquisition
is
initialization
test
java
com
iluwatar
resource
acquisition
is
initialization
semaphore
servant
service-layer
bin
etc
pom.xmlsrc
main
java
com
iluwatar
resources
test
java
com
iluwatar
servicelayer
app
common
magic
spell
spellbook
wizard
service-locator
singleton
specification
state
step-builder
strategy
template-method
thread-pool
tolerant-reader
twin
update-ghpages.shvalue-object
visitor
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,5 +15,5 @@ datanucleus.log
|
|||||||
/bin/
|
/bin/
|
||||||
/bin/
|
/bin/
|
||||||
/bin/
|
/bin/
|
||||||
|
*.log
|
||||||
data-mapper/src/main/resources/log4j.xml
|
data-mapper/src/main/resources/log4j.xml
|
@ -6,6 +6,7 @@ env:
|
|||||||
global:
|
global:
|
||||||
- GH_REF: github.com/iluwatar/java-design-patterns.git
|
- GH_REF: github.com/iluwatar/java-design-patterns.git
|
||||||
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
|
- secure: LxTDuNS/rBWIvKkaEqr79ImZAe48mCdoYCF41coxNXgNoippo4GIBArknqtv+XvdkiuRZ1yGyj6pn8GU33c/yn+krddTUkVCwTbVatbalW5jhQjDbHYym/JcxaK9ZS/3JTeGcWrBgiPqHEEDhCf26vPZsXoMSeVCEORVKTp1BSg=
|
||||||
|
- secure: "eoWlW9GyTJY04P8K3pxayXwU9/hmptQg/LfirispQkV9YvmziCfSzXnatnBhNfud98sCzY8BScXnb+OWLTnjLKpId4rtEqb0aJ40Jc32cUKzgzFAUn7cNcDAbUIfyPAGVqyQqfj/11wYSADwWMMOPlW97ExUtoyiH2WenXuRHso="
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export DISPLAY=:99.0
|
- export DISPLAY=:99.0
|
||||||
@ -16,7 +17,7 @@ install:
|
|||||||
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
|
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -e
|
||||||
|
|
||||||
after_success:
|
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
|
- bash update-ghpages.sh
|
||||||
|
|
||||||
# use latest java version available instead of travis default
|
# use latest java version available instead of travis default
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
# Design patterns implemented in Java
|
# Design patterns implemented in Java
|
||||||
|
|
||||||
[](https://travis-ci.org/iluwatar/java-design-patterns)
|
[](https://travis-ci.org/iluwatar/java-design-patterns)
|
||||||
[](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master)
|
|
||||||
[](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
|
[](https://raw.githubusercontent.com/iluwatar/java-design-patterns/master/LICENSE.md)
|
||||||
[](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
[](https://sonarqube.com/dashboard/index/com.iluwatar%3Ajava-design-patterns)
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,33 +1,29 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.abstractdocument.domain {
|
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 {
|
class Car {
|
||||||
+ Car(properties : Map<String, Object>)
|
+ Car(properties : Map<String, Object>)
|
||||||
}
|
}
|
||||||
interface HasType {
|
|
||||||
+ PROPERTY : String {static}
|
|
||||||
+ getType() : Optional<String>
|
|
||||||
}
|
|
||||||
interface HasModel {
|
interface HasModel {
|
||||||
+ PROPERTY : String {static}
|
+ PROPERTY : String {static}
|
||||||
+ getModel() : Optional<String>
|
+ 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 {
|
package com.iluwatar.abstractdocument {
|
||||||
class App {
|
|
||||||
+ App()
|
|
||||||
+ main(args : String[]) {static}
|
|
||||||
}
|
|
||||||
abstract class AbstractDocument {
|
abstract class AbstractDocument {
|
||||||
- properties : Map<String, Object>
|
- properties : Map<String, Object>
|
||||||
# AbstractDocument(properties : Map<String, Object>)
|
# AbstractDocument(properties : Map<String, Object>)
|
||||||
@ -36,24 +32,28 @@ package com.iluwatar.abstractdocument {
|
|||||||
+ put(key : String, value : Object)
|
+ put(key : String, value : Object)
|
||||||
+ toString() : String
|
+ toString() : String
|
||||||
}
|
}
|
||||||
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ App()
|
||||||
|
+ main(args : String[]) {static}
|
||||||
|
}
|
||||||
interface Document {
|
interface Document {
|
||||||
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
|
+ children(String, Function<Map<String, Object>, T>) : Stream<T> {abstract}
|
||||||
+ get(String) : Object {abstract}
|
+ get(String) : Object {abstract}
|
||||||
+ put(String, Object) {abstract}
|
+ put(String, Object) {abstract}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AbstractDocument --+ Map
|
|
||||||
Part ..|> HasType
|
|
||||||
Part ..|> HasModel
|
|
||||||
Part ..|> HasPrice
|
|
||||||
Part --|> AbstractDocument
|
|
||||||
AbstractDocument ..|> Document
|
AbstractDocument ..|> Document
|
||||||
HasPrice --|> Document
|
|
||||||
HasParts --|> Document
|
|
||||||
Car ..|> HasModel
|
Car ..|> HasModel
|
||||||
Car ..|> HasPrice
|
Car ..|> HasPrice
|
||||||
Car ..|> HasParts
|
Car ..|> HasParts
|
||||||
Car --|> AbstractDocument
|
Car --|> AbstractDocument
|
||||||
HasType --|> Document
|
|
||||||
HasModel --|> Document
|
HasModel --|> Document
|
||||||
|
HasParts --|> Document
|
||||||
|
HasPrice --|> Document
|
||||||
|
HasType --|> Document
|
||||||
|
Part ..|> HasType
|
||||||
|
Part ..|> HasModel
|
||||||
|
Part ..|> HasPrice
|
||||||
|
Part --|> AbstractDocument
|
||||||
@enduml
|
@enduml
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>abstract-document</artifactId>
|
<artifactId>abstract-document</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* 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.HasParts;
|
||||||
import com.iluwatar.abstractdocument.domain.HasPrice;
|
import com.iluwatar.abstractdocument.domain.HasPrice;
|
||||||
import com.iluwatar.abstractdocument.domain.HasType;
|
import com.iluwatar.abstractdocument.domain.HasType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -44,11 +46,13 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the App
|
* Executes the App
|
||||||
*/
|
*/
|
||||||
public App() {
|
public App() {
|
||||||
System.out.println("Constructing parts and car");
|
LOGGER.info("Constructing parts and car");
|
||||||
|
|
||||||
Map<String, Object> carProperties = new HashMap<>();
|
Map<String, Object> carProperties = new HashMap<>();
|
||||||
carProperties.put(HasModel.PROPERTY, "300SL");
|
carProperties.put(HasModel.PROPERTY, "300SL");
|
||||||
@ -68,12 +72,11 @@ public class App {
|
|||||||
|
|
||||||
Car car = new Car(carProperties);
|
Car car = new Car(carProperties);
|
||||||
|
|
||||||
System.out.println("Here is our car:");
|
LOGGER.info("Here is our car:");
|
||||||
System.out.println("-> model: " + car.getModel().get());
|
LOGGER.info("-> model: {}", car.getModel().get());
|
||||||
System.out.println("-> price: " + car.getPrice().get());
|
LOGGER.info("-> price: {}", car.getPrice().get());
|
||||||
System.out.println("-> parts: ");
|
LOGGER.info("-> parts: ");
|
||||||
car.getParts().forEach(p -> System.out
|
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
|
||||||
.println("\t" + p.getType().get() + "/" + p.getModel().get() + "/" + p.getPrice().get()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p>
|
* <p>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.abstractfactory {
|
package com.iluwatar.abstractfactory {
|
||||||
class App {
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
- army : Army
|
- army : Army
|
||||||
- castle : Castle
|
- castle : Castle
|
||||||
- king : King
|
- king : King
|
||||||
@ -17,58 +18,58 @@ package com.iluwatar.abstractfactory {
|
|||||||
- setCastle(castle : Castle)
|
- setCastle(castle : Castle)
|
||||||
- setKing(king : King)
|
- setKing(king : King)
|
||||||
}
|
}
|
||||||
class OrcKingdomFactory {
|
interface Army {
|
||||||
+ OrcKingdomFactory()
|
+ getDescription() : String {abstract}
|
||||||
+ createArmy() : Army
|
}
|
||||||
+ createCastle() : Castle
|
interface Castle {
|
||||||
+ createKing() : King
|
+ getDescription() : String {abstract}
|
||||||
|
}
|
||||||
|
class ElfArmy {
|
||||||
|
~ DESCRIPTION : String {static}
|
||||||
|
+ ElfArmy()
|
||||||
|
+ getDescription() : String
|
||||||
}
|
}
|
||||||
class ElfCastle {
|
class ElfCastle {
|
||||||
~ DESCRIPTION : String {static}
|
~ DESCRIPTION : String {static}
|
||||||
+ ElfCastle()
|
+ ElfCastle()
|
||||||
+ getDescription() : String
|
+ 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 {
|
class OrcCastle {
|
||||||
~ DESCRIPTION : String {static}
|
~ DESCRIPTION : String {static}
|
||||||
+ OrcCastle()
|
+ OrcCastle()
|
||||||
+ getDescription() : String
|
+ 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 {
|
class OrcKing {
|
||||||
~ DESCRIPTION : String {static}
|
~ DESCRIPTION : String {static}
|
||||||
+ OrcKing()
|
+ OrcKing()
|
||||||
+ getDescription() : String
|
+ getDescription() : String
|
||||||
}
|
}
|
||||||
class OrcArmy {
|
class OrcKingdomFactory {
|
||||||
~ DESCRIPTION : String {static}
|
+ OrcKingdomFactory()
|
||||||
+ OrcArmy()
|
|
||||||
+ getDescription() : String
|
|
||||||
}
|
|
||||||
interface King {
|
|
||||||
+ getDescription() : String {abstract}
|
|
||||||
}
|
|
||||||
class ElfKingdomFactory {
|
|
||||||
+ ElfKingdomFactory()
|
|
||||||
+ createArmy() : Army
|
+ createArmy() : Army
|
||||||
+ createCastle() : Castle
|
+ createCastle() : Castle
|
||||||
+ createKing() : King
|
+ createKing() : King
|
||||||
@ -77,12 +78,12 @@ package com.iluwatar.abstractfactory {
|
|||||||
App --> "-castle" Castle
|
App --> "-castle" Castle
|
||||||
App --> "-king" King
|
App --> "-king" King
|
||||||
App --> "-army" Army
|
App --> "-army" Army
|
||||||
OrcKingdomFactory ..|> KingdomFactory
|
|
||||||
ElfCastle ..|> Castle
|
|
||||||
OrcCastle ..|> Castle
|
|
||||||
ElfKing ..|> King
|
|
||||||
ElfArmy ..|> Army
|
ElfArmy ..|> Army
|
||||||
OrcKing ..|> King
|
ElfCastle ..|> Castle
|
||||||
OrcArmy ..|> Army
|
ElfKing ..|> King
|
||||||
ElfKingdomFactory ..|> KingdomFactory
|
ElfKingdomFactory ..|> KingdomFactory
|
||||||
|
OrcArmy ..|> Army
|
||||||
|
OrcCastle ..|> Castle
|
||||||
|
OrcKing ..|> King
|
||||||
|
OrcKingdomFactory ..|> KingdomFactory
|
||||||
@enduml
|
@enduml
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>abstract-factory</artifactId>
|
<artifactId>abstract-factory</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.abstractfactory;
|
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
|
* 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 {
|
public class App {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
private King king;
|
private King king;
|
||||||
private Castle castle;
|
private Castle castle;
|
||||||
private Army army;
|
private Army army;
|
||||||
@ -98,17 +103,17 @@ public class App {
|
|||||||
|
|
||||||
App app = new App();
|
App app = new App();
|
||||||
|
|
||||||
System.out.println("Elf Kingdom");
|
LOGGER.info("Elf Kingdom");
|
||||||
app.createKingdom(new ElfKingdomFactory());
|
app.createKingdom(new ElfKingdomFactory());
|
||||||
System.out.println(app.getArmy().getDescription());
|
LOGGER.info(app.getArmy().getDescription());
|
||||||
System.out.println(app.getCastle().getDescription());
|
LOGGER.info(app.getCastle().getDescription());
|
||||||
System.out.println(app.getKing().getDescription());
|
LOGGER.info(app.getKing().getDescription());
|
||||||
|
|
||||||
System.out.println("\nOrc Kingdom");
|
LOGGER.info("Orc Kingdom");
|
||||||
app.createKingdom(new OrcKingdomFactory());
|
app.createKingdom(new OrcKingdomFactory());
|
||||||
System.out.println(app.getArmy().getDescription());
|
LOGGER.info(app.getArmy().getDescription());
|
||||||
System.out.println(app.getCastle().getDescription());
|
LOGGER.info(app.getCastle().getDescription());
|
||||||
System.out.println(app.getKing().getDescription());
|
LOGGER.info(app.getKing().getDescription());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.adapter {
|
package com.iluwatar.adapter {
|
||||||
interface BattleShip {
|
class App {
|
||||||
+ fire() {abstract}
|
+ App()
|
||||||
+ move() {abstract}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
class BattleFishingBoat {
|
class BattleFishingBoat {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
- boat : FishingBoat
|
- boat : FishingBoat
|
||||||
+ BattleFishingBoat()
|
+ BattleFishingBoat()
|
||||||
+ fire()
|
+ fire()
|
||||||
+ move()
|
+ move()
|
||||||
}
|
}
|
||||||
class App {
|
interface BattleShip {
|
||||||
+ App()
|
+ fire() {abstract}
|
||||||
+ main(args : String[]) {static}
|
+ move() {abstract}
|
||||||
}
|
}
|
||||||
class Captain {
|
class Captain {
|
||||||
- battleship : BattleShip
|
- battleship : BattleShip
|
||||||
@ -23,6 +24,7 @@ package com.iluwatar.adapter {
|
|||||||
+ setBattleship(battleship : BattleShip)
|
+ setBattleship(battleship : BattleShip)
|
||||||
}
|
}
|
||||||
class FishingBoat {
|
class FishingBoat {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
+ FishingBoat()
|
+ FishingBoat()
|
||||||
+ fish()
|
+ fish()
|
||||||
+ sail()
|
+ sail()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>adapter</artifactId>
|
<artifactId>adapter</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.adapter;
|
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}
|
* 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 {
|
public class BattleFishingBoat implements BattleShip {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(BattleFishingBoat.class);
|
||||||
|
|
||||||
private FishingBoat boat;
|
private FishingBoat boat;
|
||||||
|
|
||||||
public BattleFishingBoat() {
|
public BattleFishingBoat() {
|
||||||
@ -41,7 +46,7 @@ public class BattleFishingBoat implements BattleShip {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fire() {
|
public void fire() {
|
||||||
System.out.println("fire!");
|
LOGGER.info("fire!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.adapter;
|
package com.iluwatar.adapter;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Device class (adaptee in the pattern). We want to reuse this class
|
* Device class (adaptee in the pattern). We want to reuse this class
|
||||||
@ -29,12 +32,14 @@ package com.iluwatar.adapter;
|
|||||||
*/
|
*/
|
||||||
public class FishingBoat {
|
public class FishingBoat {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
|
||||||
|
|
||||||
public void sail() {
|
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() {
|
public void fish() {
|
||||||
System.out.println("fishing ...");
|
LOGGER.info("fishing ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* 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.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -37,6 +39,8 @@ import java.io.IOException;
|
|||||||
@Component
|
@Component
|
||||||
public class ProductInformationClientImpl implements ProductInformationClient {
|
public class ProductInformationClientImpl implements ProductInformationClient {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProductTitle() {
|
public String getProductTitle() {
|
||||||
String response = null;
|
String response = null;
|
||||||
@ -46,7 +50,7 @@ public class ProductInformationClientImpl implements ProductInformationClient {
|
|||||||
response = EntityUtils.toString(httpResponse.getEntity());
|
response = EntityUtils.toString(httpResponse.getEntity());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Exception caught.", e);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* 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.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -37,6 +39,8 @@ import java.io.IOException;
|
|||||||
@Component
|
@Component
|
||||||
public class ProductInventoryClientImpl implements ProductInventoryClient {
|
public class ProductInventoryClientImpl implements ProductInventoryClient {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getProductInventories() {
|
public int getProductInventories() {
|
||||||
String response = "0";
|
String response = "0";
|
||||||
@ -46,7 +50,7 @@ public class ProductInventoryClientImpl implements ProductInventoryClient {
|
|||||||
response = EntityUtils.toString(httpResponse.getEntity());
|
response = EntityUtils.toString(httpResponse.getEntity());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("Exception caught.", e);
|
||||||
}
|
}
|
||||||
return Integer.parseInt(response);
|
return Integer.parseInt(response);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.aggregator.microservices {
|
package com.iluwatar.aggregator.microservices {
|
||||||
class ProductInventoryClientImpl {
|
class Aggregator {
|
||||||
+ ProductInventoryClientImpl()
|
- informationClient : ProductInformationClient
|
||||||
+ getProductInventories() : int
|
- inventoryClient : ProductInventoryClient
|
||||||
|
+ Aggregator()
|
||||||
|
+ getProduct() : Product
|
||||||
}
|
}
|
||||||
class App {
|
class App {
|
||||||
+ App()
|
+ App()
|
||||||
+ main(args : String[]) {static}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
interface ProductInventoryClient {
|
|
||||||
+ getProductInventories() : int {abstract}
|
|
||||||
}
|
|
||||||
class Product {
|
class Product {
|
||||||
- productInventories : int
|
- productInventories : int
|
||||||
- title : String
|
- title : String
|
||||||
@ -20,22 +19,25 @@ package com.iluwatar.aggregator.microservices {
|
|||||||
+ setProductInventories(productInventories : int)
|
+ setProductInventories(productInventories : int)
|
||||||
+ setTitle(title : String)
|
+ setTitle(title : String)
|
||||||
}
|
}
|
||||||
class Aggregator {
|
|
||||||
- informationClient : ProductInformationClient
|
|
||||||
- inventoryClient : ProductInventoryClient
|
|
||||||
+ Aggregator()
|
|
||||||
+ getProduct() : Product
|
|
||||||
}
|
|
||||||
class ProductInformationClientImpl {
|
|
||||||
+ ProductInformationClientImpl()
|
|
||||||
+ getProductTitle() : String
|
|
||||||
}
|
|
||||||
interface ProductInformationClient {
|
interface ProductInformationClient {
|
||||||
+ getProductTitle() : String {abstract}
|
+ 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
|
Aggregator --> "-informationClient" ProductInformationClient
|
||||||
ProductInventoryClientImpl ..|> ProductInventoryClient
|
Aggregator --> "-inventoryClient" ProductInventoryClient
|
||||||
ProductInformationClientImpl ..|> ProductInformationClient
|
ProductInformationClientImpl ..|> ProductInformationClient
|
||||||
|
ProductInventoryClientImpl ..|> ProductInventoryClient
|
||||||
@enduml
|
@enduml
|
@ -1,12 +1,12 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.inventory.microservice {
|
package com.iluwatar.inventory.microservice {
|
||||||
class InventoryController {
|
|
||||||
+ InventoryController()
|
|
||||||
+ getProductInventories() : int
|
|
||||||
}
|
|
||||||
class InventoryApplication {
|
class InventoryApplication {
|
||||||
+ InventoryApplication()
|
+ InventoryApplication()
|
||||||
+ main(args : String[]) {static}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
|
class InventoryController {
|
||||||
|
+ InventoryController()
|
||||||
|
+ getProductInventories() : int
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@enduml
|
@enduml
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright (c) 2014 Ilkka Seppälä
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||||
* <p/>
|
* <p/>
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>aggregator-microservices</artifactId>
|
<artifactId>aggregator-microservices</artifactId>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>api-gateway-service</artifactId>
|
<artifactId>api-gateway-service</artifactId>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,12 +1,27 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.api.gateway {
|
package com.iluwatar.api.gateway {
|
||||||
|
class ApiGateway {
|
||||||
|
- imageClient : ImageClient
|
||||||
|
- priceClient : PriceClient
|
||||||
|
+ ApiGateway()
|
||||||
|
+ getProductDesktop() : DesktopProduct
|
||||||
|
+ getProductMobile() : MobileProduct
|
||||||
|
}
|
||||||
class App {
|
class App {
|
||||||
+ App()
|
+ App()
|
||||||
+ main(args : String[]) {static}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
class PriceClientImpl {
|
class DesktopProduct {
|
||||||
+ PriceClientImpl()
|
- imagePath : String
|
||||||
|
- price : String
|
||||||
|
+ DesktopProduct()
|
||||||
|
+ getImagePath() : String
|
||||||
+ getPrice() : String
|
+ getPrice() : String
|
||||||
|
+ setImagePath(imagePath : String)
|
||||||
|
+ setPrice(price : String)
|
||||||
|
}
|
||||||
|
interface ImageClient {
|
||||||
|
+ getImagePath() : String {abstract}
|
||||||
}
|
}
|
||||||
class ImageClientImpl {
|
class ImageClientImpl {
|
||||||
+ ImageClientImpl()
|
+ ImageClientImpl()
|
||||||
@ -18,31 +33,16 @@ package com.iluwatar.api.gateway {
|
|||||||
+ getPrice() : String
|
+ getPrice() : String
|
||||||
+ setPrice(price : 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 {
|
interface PriceClient {
|
||||||
+ getPrice() : String {abstract}
|
+ getPrice() : String {abstract}
|
||||||
}
|
}
|
||||||
|
class PriceClientImpl {
|
||||||
|
+ PriceClientImpl()
|
||||||
|
+ getPrice() : String
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ApiGateway --> "-imageClient" ImageClient
|
ApiGateway --> "-imageClient" ImageClient
|
||||||
ApiGateway --> "-priceClient" PriceClient
|
ApiGateway --> "-priceClient" PriceClient
|
||||||
PriceClientImpl ..|> PriceClient
|
|
||||||
ImageClientImpl ..|> ImageClient
|
ImageClientImpl ..|> ImageClient
|
||||||
|
PriceClientImpl ..|> PriceClient
|
||||||
@enduml
|
@enduml
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
2
api-gateway/image-microservice/src/main/java/com/iluwatar/image/microservice/ImageApplication.java
2
api-gateway/image-microservice/src/main/java/com/iluwatar/image/microservice/ImageApplication.java
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>api-gateway</artifactId>
|
<artifactId>api-gateway</artifactId>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
2
api-gateway/price-microservice/src/main/java/com/iluwatar/price/microservice/PriceApplication.java
2
api-gateway/price-microservice/src/main/java/com/iluwatar/price/microservice/PriceApplication.java
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# The MIT License
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.async.method.invocation {
|
package com.iluwatar.async.method.invocation {
|
||||||
class App {
|
class App {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
+ App()
|
+ App()
|
||||||
- callback(name : String) : AsyncCallback<T> {static}
|
- callback(name : String) : AsyncCallback<T> {static}
|
||||||
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
|
- lazyval(value : T, delayMillis : long) : Callable<T> {static}
|
||||||
- log(msg : String) {static}
|
- log(msg : String) {static}
|
||||||
+ main(args : String[]) {static}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
interface AsyncResult<T> {
|
interface AsyncCallback<T> {
|
||||||
+ await() {abstract}
|
+ onComplete(T, Optional<Exception>) {abstract}
|
||||||
+ getValue() : T {abstract}
|
|
||||||
+ isCompleted() : boolean {abstract}
|
|
||||||
}
|
}
|
||||||
interface AsyncExecutor {
|
interface AsyncExecutor {
|
||||||
+ endProcess(AsyncResult<T>) : T {abstract}
|
+ endProcess(AsyncResult<T>) : T {abstract}
|
||||||
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
|
+ startProcess(Callable<T>) : AsyncResult<T> {abstract}
|
||||||
+ startProcess(Callable<T>, AsyncCallback<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 {
|
class ThreadAsyncExecutor {
|
||||||
- idx : AtomicInteger
|
- idx : AtomicInteger
|
||||||
+ ThreadAsyncExecutor()
|
+ ThreadAsyncExecutor()
|
||||||
@ -24,9 +28,6 @@ package com.iluwatar.async.method.invocation {
|
|||||||
+ startProcess(task : Callable<T>) : AsyncResult<T>
|
+ startProcess(task : Callable<T>) : AsyncResult<T>
|
||||||
+ startProcess(task : Callable<T>, callback : AsyncCallback<T>) : AsyncResult<T>
|
+ startProcess(task : Callable<T>, callback : AsyncCallback<T>) : AsyncResult<T>
|
||||||
}
|
}
|
||||||
interface AsyncCallback<T> {
|
|
||||||
+ onComplete(T, Optional<Exception>) {abstract}
|
|
||||||
}
|
|
||||||
-class CompletableResult<T> {
|
-class CompletableResult<T> {
|
||||||
~ COMPLETED : int {static}
|
~ COMPLETED : int {static}
|
||||||
~ FAILED : int {static}
|
~ FAILED : int {static}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
The MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.iluwatar</groupId>
|
<groupId>com.iluwatar</groupId>
|
||||||
<artifactId>java-design-patterns</artifactId>
|
<artifactId>java-design-patterns</artifactId>
|
||||||
<version>1.13.0</version>
|
<version>1.14.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>async-method-invocation</artifactId>
|
<artifactId>async-method-invocation</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.iluwatar.async.method.invocation;
|
package com.iluwatar.async.method.invocation;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +57,8 @@ import java.util.concurrent.Callable;
|
|||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Program entry point
|
* Program entry point
|
||||||
*/
|
*/
|
||||||
@ -120,6 +125,6 @@ public class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void log(String msg) {
|
private static void log(String msg) {
|
||||||
System.out.println(String.format("[%1$-10s] - %2$s", Thread.currentThread().getName(), msg));
|
LOGGER.info(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
8
async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java
8
async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/ThreadAsyncExecutor.java
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -57,12 +57,10 @@ public class ThreadAsyncExecutor implements AsyncExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException {
|
public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException {
|
||||||
if (asyncResult.isCompleted()) {
|
if (!asyncResult.isCompleted()) {
|
||||||
return asyncResult.getValue();
|
|
||||||
} else {
|
|
||||||
asyncResult.await();
|
asyncResult.await();
|
||||||
return asyncResult.getValue();
|
|
||||||
}
|
}
|
||||||
|
return asyncResult.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* The MIT License
|
* 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
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -31,7 +31,6 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.internal.verification.VerificationModeFactory.times;
|
import static org.mockito.internal.verification.VerificationModeFactory.times;
|
||||||
|
|
||||||
|
@ -1,72 +1,9 @@
|
|||||||
@startuml
|
@startuml
|
||||||
package com.iluwatar.bridge {
|
package com.iluwatar.bridge {
|
||||||
class FlyingMagicWeapon {
|
|
||||||
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
|
|
||||||
+ fly()
|
|
||||||
+ getImp() : FlyingMagicWeaponImpl
|
|
||||||
+ swing()
|
|
||||||
+ unwield()
|
|
||||||
+ wield()
|
|
||||||
}
|
|
||||||
class Stormbringer {
|
|
||||||
+ Stormbringer()
|
|
||||||
+ eatSoulImp()
|
|
||||||
+ swingImp()
|
|
||||||
+ unwieldImp()
|
|
||||||
+ wieldImp()
|
|
||||||
}
|
|
||||||
abstract class FlyingMagicWeaponImpl {
|
|
||||||
+ FlyingMagicWeaponImpl()
|
|
||||||
+ flyImp() {abstract}
|
|
||||||
}
|
|
||||||
class SoulEatingMagicWeapon {
|
|
||||||
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
|
|
||||||
+ eatSoul()
|
|
||||||
+ getImp() : SoulEatingMagicWeaponImpl
|
|
||||||
+ swing()
|
|
||||||
+ unwield()
|
|
||||||
+ wield()
|
|
||||||
}
|
|
||||||
abstract class MagicWeaponImpl {
|
|
||||||
+ MagicWeaponImpl()
|
|
||||||
+ swingImp() {abstract}
|
|
||||||
+ unwieldImp() {abstract}
|
|
||||||
+ wieldImp() {abstract}
|
|
||||||
}
|
|
||||||
abstract class SoulEatingMagicWeaponImpl {
|
|
||||||
+ SoulEatingMagicWeaponImpl()
|
|
||||||
+ eatSoulImp() {abstract}
|
|
||||||
}
|
|
||||||
class Excalibur {
|
|
||||||
+ Excalibur()
|
|
||||||
+ blindImp()
|
|
||||||
+ swingImp()
|
|
||||||
+ unwieldImp()
|
|
||||||
+ wieldImp()
|
|
||||||
}
|
|
||||||
class Mjollnir {
|
|
||||||
+ Mjollnir()
|
|
||||||
+ flyImp()
|
|
||||||
+ swingImp()
|
|
||||||
+ unwieldImp()
|
|
||||||
+ wieldImp()
|
|
||||||
}
|
|
||||||
class App {
|
class App {
|
||||||
+ App()
|
+ App()
|
||||||
+ main(args : String[]) {static}
|
+ main(args : String[]) {static}
|
||||||
}
|
}
|
||||||
abstract class MagicWeapon {
|
|
||||||
# imp : MagicWeaponImpl
|
|
||||||
+ MagicWeapon(imp : MagicWeaponImpl)
|
|
||||||
+ getImp() : MagicWeaponImpl
|
|
||||||
+ swing() {abstract}
|
|
||||||
+ unwield() {abstract}
|
|
||||||
+ wield() {abstract}
|
|
||||||
}
|
|
||||||
abstract class BlindingMagicWeaponImpl {
|
|
||||||
+ BlindingMagicWeaponImpl()
|
|
||||||
+ blindImp() {abstract}
|
|
||||||
}
|
|
||||||
class BlindingMagicWeapon {
|
class BlindingMagicWeapon {
|
||||||
+ BlindingMagicWeapon(imp : BlindingMagicWeaponImpl)
|
+ BlindingMagicWeapon(imp : BlindingMagicWeaponImpl)
|
||||||
+ blind()
|
+ blind()
|
||||||
@ -75,15 +12,81 @@ package com.iluwatar.bridge {
|
|||||||
+ unwield()
|
+ unwield()
|
||||||
+ wield()
|
+ wield()
|
||||||
}
|
}
|
||||||
|
abstract class BlindingMagicWeaponImpl {
|
||||||
|
+ BlindingMagicWeaponImpl()
|
||||||
|
+ blindImp() {abstract}
|
||||||
|
}
|
||||||
|
class Excalibur {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Excalibur()
|
||||||
|
+ blindImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
|
class FlyingMagicWeapon {
|
||||||
|
+ FlyingMagicWeapon(imp : FlyingMagicWeaponImpl)
|
||||||
|
+ fly()
|
||||||
|
+ getImp() : FlyingMagicWeaponImpl
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
abstract class FlyingMagicWeaponImpl {
|
||||||
|
+ FlyingMagicWeaponImpl()
|
||||||
|
+ flyImp() {abstract}
|
||||||
|
}
|
||||||
|
abstract class MagicWeapon {
|
||||||
|
# imp : MagicWeaponImpl
|
||||||
|
+ MagicWeapon(imp : MagicWeaponImpl)
|
||||||
|
+ getImp() : MagicWeaponImpl
|
||||||
|
+ swing() {abstract}
|
||||||
|
+ unwield() {abstract}
|
||||||
|
+ wield() {abstract}
|
||||||
|
}
|
||||||
|
abstract class MagicWeaponImpl {
|
||||||
|
+ MagicWeaponImpl()
|
||||||
|
+ swingImp() {abstract}
|
||||||
|
+ unwieldImp() {abstract}
|
||||||
|
+ wieldImp() {abstract}
|
||||||
|
}
|
||||||
|
class Mjollnir {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Mjollnir()
|
||||||
|
+ flyImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
|
class SoulEatingMagicWeapon {
|
||||||
|
+ SoulEatingMagicWeapon(imp : SoulEatingMagicWeaponImpl)
|
||||||
|
+ eatSoul()
|
||||||
|
+ getImp() : SoulEatingMagicWeaponImpl
|
||||||
|
+ swing()
|
||||||
|
+ unwield()
|
||||||
|
+ wield()
|
||||||
|
}
|
||||||
|
abstract class SoulEatingMagicWeaponImpl {
|
||||||
|
+ SoulEatingMagicWeaponImpl()
|
||||||
|
+ eatSoulImp() {abstract}
|
||||||
|
}
|
||||||
|
class Stormbringer {
|
||||||
|
- LOGGER : Logger {static}
|
||||||
|
+ Stormbringer()
|
||||||
|
+ eatSoulImp()
|
||||||
|
+ swingImp()
|
||||||
|
+ unwieldImp()
|
||||||
|
+ wieldImp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MagicWeapon --> "-imp" MagicWeaponImpl
|
MagicWeapon --> "-imp" MagicWeaponImpl
|
||||||
|
BlindingMagicWeapon --|> MagicWeapon
|
||||||
|
BlindingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
|
Excalibur --|> BlindingMagicWeaponImpl
|
||||||
FlyingMagicWeapon --|> MagicWeapon
|
FlyingMagicWeapon --|> MagicWeapon
|
||||||
Stormbringer --|> SoulEatingMagicWeaponImpl
|
|
||||||
FlyingMagicWeaponImpl --|> MagicWeaponImpl
|
FlyingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
|
Mjollnir --|> FlyingMagicWeaponImpl
|
||||||
SoulEatingMagicWeapon --|> MagicWeapon
|
SoulEatingMagicWeapon --|> MagicWeapon
|
||||||
SoulEatingMagicWeaponImpl --|> MagicWeaponImpl
|
SoulEatingMagicWeaponImpl --|> MagicWeaponImpl
|
||||||
Excalibur --|> BlindingMagicWeaponImpl
|
Stormbringer --|> SoulEatingMagicWeaponImpl
|
||||||
Mjollnir --|> FlyingMagicWeaponImpl
|
|
||||||
BlindingMagicWeaponImpl --|> MagicWeaponImpl
|
|
||||||
BlindingMagicWeapon --|> MagicWeapon
|
|
||||||
@enduml
|
@enduml
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user