Skip to content
This repository was archived by the owner on Mar 5, 2018. It is now read-only.

Commit 30315e7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into data-bus
* upstream/master: (67 commits) Set version for next development iteration Reached milestone 1.15.0 iluwatar#539 Checkstyle fix iluwatar#539 More Checkstyle fixes iluwatar#539 Checkstyle fixes iluwatar#497 Add missing puml and license headers iluwatar#77 Add missing license header Work on iluwatar#190: urm/puml updates * added pumlid where it was missing and possible * removed pumlid where it generated a bad image * regenerated some incorrect puml's * added 'left to right direction' puml prefix to some diagrams to improve the automatic layouting Removed AvoidStarImport Rule Added JavaDocType Rule Update App.java Update App.java Update after changes from review. Additional improvements. Pom.xml files fixed. iluwatar#66 Balking Pattern fixed pmd violation fixed checkstyle violations diagrams added comments, tests and description changed parent POM version iluwatar#69 apply changes from review iluwatar#69 ... # Conflicts: # pom.xml
2 parents 6b795e5 + 073d06c commit 30315e7

File tree

258 files changed

+3078
-442
lines changed

Some content is hidden

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

258 files changed

+3078
-442
lines changed

abstract-document/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>java-design-patterns</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<artifactId>abstract-document</artifactId>
3535
<dependencies>

abstract-factory/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<groupId>com.iluwatar</groupId>
3131
<artifactId>java-design-patterns</artifactId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<artifactId>abstract-factory</artifactId>
3535
<dependencies>

abstract-factory/src/test/java/com/iluwatar/abstractfactory/AbstractFactoryTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import org.junit.Before;
2929
import org.junit.Test;
3030

31+
/**
32+
* Test for abstract factory
33+
*/
3134
public class AbstractFactoryTest {
3235

3336
private App app = new App();

adapter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<groupId>com.iluwatar</groupId>
3131
<artifactId>java-design-patterns</artifactId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<artifactId>adapter</artifactId>
3535
<dependencies>

aggregator-microservices/aggregator-service/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>aggregator-microservices</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535

aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/App.java

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.springframework.boot.SpringApplication;
2626
import org.springframework.boot.autoconfigure.SpringBootApplication;
2727

28+
/**
29+
* Spring Boot EntryPoint Class
30+
*/
2831
@SpringBootApplication
2932
public class App {
3033

aggregator-microservices/aggregator-service/src/test/java/com/iluwatar/aggregator/microservices/AggregatorTest.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
*/
2323
package com.iluwatar.aggregator.microservices;
2424

25+
import static org.junit.Assert.assertEquals;
26+
import static org.mockito.Mockito.when;
27+
2528
import org.junit.Before;
2629
import org.junit.Test;
2730
import org.mockito.InjectMocks;
2831
import org.mockito.Mock;
2932
import org.mockito.MockitoAnnotations;
3033

31-
import static org.junit.Assert.assertEquals;
32-
import static org.mockito.Mockito.when;
33-
34+
/**
35+
* Test Aggregation of domain objects
36+
*/
3437
public class AggregatorTest {
3538

3639
@InjectMocks
@@ -64,4 +67,4 @@ public void testGetProduct() {
6467
assertEquals(inventories, testProduct.getProductInventories());
6568
}
6669

67-
}
70+
}

aggregator-microservices/information-microservice/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>aggregator-microservices</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535

aggregator-microservices/information-microservice/src/main/java/com/iluwatar/information/microservice/InformationController.java

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import org.springframework.web.bind.annotation.RequestMethod;
2727
import org.springframework.web.bind.annotation.RestController;
2828

29+
/**
30+
* Controller providing endpoints to retrieve information about products
31+
*/
2932
@RestController
3033
public class InformationController {
3134

aggregator-microservices/information-microservice/src/test/java/com/iluwatar/information/microservice/InformationControllerTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.junit.Assert;
2626
import org.junit.Test;
2727

28+
/**
29+
* Test for Information Rest Controller
30+
*/
2831
public class InformationControllerTest {
2932

3033
@Test
@@ -36,4 +39,4 @@ public void shouldGetProductTitle() {
3639
Assert.assertEquals("The Product Title.", title);
3740
}
3841

39-
}
42+
}

aggregator-microservices/inventory-microservice/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>aggregator-microservices</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535

aggregator-microservices/inventory-microservice/src/main/java/com/iluwatar/inventory/microservice/InventoryController.java

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
import org.springframework.web.bind.annotation.RequestMethod;
2727
import org.springframework.web.bind.annotation.RestController;
2828

29+
/**
30+
* Controller providing endpoints to retrieve product inventories
31+
*/
2932
@RestController
3033
public class InventoryController {
3134

aggregator-microservices/inventory-microservice/src/test/java/com/iluwatar/inventory/microservice/InventoryControllerTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
import org.junit.Assert;
2626
import org.junit.Test;
2727

28+
/**
29+
* Test Inventory Rest Controller
30+
*/
2831
public class InventoryControllerTest {
29-
3032
@Test
3133
public void testGetProductInventories() throws Exception {
3234
InventoryController inventoryController = new InventoryController();
@@ -35,4 +37,4 @@ public void testGetProductInventories() throws Exception {
3537

3638
Assert.assertEquals(5, numberOfInventories);
3739
}
38-
}
40+
}

aggregator-microservices/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>java-design-patterns</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535
<artifactId>aggregator-microservices</artifactId>

api-gateway/api-gateway-service/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>api-gateway</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535
<artifactId>api-gateway-service</artifactId>

api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/ImageClientImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* An adapter to communicate with the Image microservice
3636
*/
3737
@Component
38-
public class ImageClientImpl implements ImageClient{
38+
public class ImageClientImpl implements ImageClient {
3939
/**
4040
* Makes a simple HTTP Get request to the Image microservice
4141
* @return The path to the image

api-gateway/api-gateway-service/src/main/java/com/iluwatar/api/gateway/PriceClientImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* An adapter to communicate with the Price microservice
3636
*/
3737
@Component
38-
public class PriceClientImpl implements PriceClient{
38+
public class PriceClientImpl implements PriceClient {
3939
/**
4040
* Makes a simple HTTP Get request to the Price microservice
4141
* @return The price of the product

api-gateway/api-gateway-service/src/test/java/com/iluwatar/api/gateway/ApiGatewayTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
*/
2323
package com.iluwatar.api.gateway;
2424

25+
import static org.junit.Assert.assertEquals;
26+
import static org.mockito.Mockito.when;
27+
2528
import org.junit.Before;
2629
import org.junit.Test;
2730
import org.mockito.InjectMocks;
2831
import org.mockito.Mock;
2932
import org.mockito.MockitoAnnotations;
3033

31-
import static org.junit.Assert.assertEquals;
32-
import static org.mockito.Mockito.when;
33-
34+
/**
35+
* Test API Gateway Pattern
36+
*/
3437
public class ApiGatewayTest {
3538

3639
@InjectMocks

api-gateway/image-microservice/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>api-gateway</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434

3535
<modelVersion>4.0.0</modelVersion>

api-gateway/image-microservice/src/test/java/com/iluwatar/image/microservice/ImageControllerTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.junit.Assert;
2626
import org.junit.Test;
2727

28+
/**
29+
* Test for Image Rest Controller
30+
*/
2831
public class ImageControllerTest {
2932
@Test
3033
public void testGetImagePath() {

api-gateway/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>java-design-patterns</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<modelVersion>4.0.0</modelVersion>
3535
<artifactId>api-gateway</artifactId>

api-gateway/price-microservice/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>api-gateway</artifactId>
3131
<groupId>com.iluwatar</groupId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434

3535
<modelVersion>4.0.0</modelVersion>

api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
import org.junit.Assert;
2626
import org.junit.Test;
2727

28+
29+
/**
30+
* Test for Price Rest Controller
31+
*/
2832
public class PriceControllerTest {
2933
@Test
3034
public void testgetPrice() {

async-method-invocation/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<groupId>com.iluwatar</groupId>
3131
<artifactId>java-design-patterns</artifactId>
32-
<version>1.15.0-SNAPSHOT</version>
32+
<version>1.16.0-SNAPSHOT</version>
3333
</parent>
3434
<artifactId>async-method-invocation</artifactId>
3535
<dependencies>

async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/AsyncResult.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import java.util.concurrent.ExecutionException;
2626

2727
/**
28-
*
2928
* AsyncResult interface
29+
* @param <T> parameter returned when getValue is invoked
3030
*/
3131
public interface AsyncResult<T> {
3232

balking/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
layout: pattern
3+
title: Balking
4+
folder: balking
5+
permalink: /patterns/balking/
6+
categories: Concurrency
7+
tags:
8+
- Java
9+
- Difficulty-Beginner
10+
---
11+
12+
## Intent
13+
Balking Pattern is used to prevent an object from executing certain code if it is an
14+
incomplete or inappropriate state
15+
16+
![alt text](./etc/balking.png "Balking")
17+
18+
## Applicability
19+
Use the Balking pattern when
20+
21+
*you want to invoke an action on an object only when it is in a particular state
22+
*objects are generally only in a state that is prone to balking temporarily
23+
but for an unknown amount of time
24+
25+
## Related patterns
26+
* Guarded Suspendion Pattern
27+
* Double Checked Locking Pattern

balking/etc/balking.png

20.9 KB
Loading

balking/etc/balking.ucls

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.13" icons="true" automaticImage="PNG" always-add-relationships="false"
3+
generalizations="true" realizations="true" associations="true" dependencies="false" nesting-relationships="true"
4+
router="FAN">
5+
<class id="1" language="java" name="com.iluwatar.balking.App" project="balking"
6+
file="/balking/src/main/java/com/iluwatar/balking/App.java" binary="false" corner="BOTTOM_RIGHT">
7+
<position height="113" width="114" x="135" y="103"/>
8+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
9+
sort-features="false" accessors="true" visibility="true">
10+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
11+
<operations public="true" package="true" protected="true" private="true" static="true"/>
12+
</display>
13+
</class>
14+
<class id="2" language="java" name="com.iluwatar.balking.WashingMachine" project="balking"
15+
file="/balking/src/main/java/com/iluwatar/balking/WashingMachine.java" binary="false" corner="BOTTOM_RIGHT">
16+
<position height="149" width="268" x="289" y="103"/>
17+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
18+
sort-features="false" accessors="true" visibility="true">
19+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
20+
<operations public="true" package="true" protected="true" private="true" static="true"/>
21+
</display>
22+
</class>
23+
<enumeration id="3" language="java" name="com.iluwatar.balking.WashingMachineState" project="balking"
24+
file="/balking/src/main/java/com/iluwatar/balking/WashingMachineState.java" binary="false" corner="BOTTOM_RIGHT">
25+
<position height="113" width="192" x="289" y="292"/>
26+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
27+
sort-features="false" accessors="true" visibility="true">
28+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
29+
<operations public="true" package="true" protected="true" private="true" static="true"/>
30+
</display>
31+
</enumeration>
32+
<association id="4">
33+
<end type="SOURCE" refId="2" navigable="false">
34+
<attribute id="5" name="washingMachineState"/>
35+
<multiplicity id="6" minimum="0" maximum="1"/>
36+
</end>
37+
<end type="TARGET" refId="3" navigable="true"/>
38+
<display labels="true" multiplicity="true"/>
39+
</association>
40+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
41+
sort-features="false" accessors="true" visibility="true">
42+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
43+
<operations public="true" package="true" protected="true" private="true" static="true"/>
44+
</classifier-display>
45+
<association-display labels="true" multiplicity="true"/>
46+
</class-diagram>

balking/etc/balking.urm.puml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@startuml
2+
package com.iluwatar.balking {
3+
class App {
4+
- LOGGER : Logger {static}
5+
+ App()
6+
+ main(args : String[]) {static}
7+
}
8+
class WashingMachine {
9+
- LOGGER : Logger {static}
10+
- washingMachineState : WashingMachineState
11+
+ WashingMachine()
12+
+ endOfWashing()
13+
+ getWashingMachineState() : WashingMachineState
14+
+ wash()
15+
}
16+
enum WashingMachineState {
17+
+ ENABLED {static}
18+
+ WASHING {static}
19+
+ valueOf(name : String) : WashingMachineState {static}
20+
+ values() : WashingMachineState[] {static}
21+
}
22+
}
23+
WashingMachine --> "-washingMachineState" WashingMachineState
24+
@enduml

0 commit comments

Comments
 (0)