-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e690be9
commit 219f075
Showing
8 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
random.service=CHEAP |
19 changes: 17 additions & 2 deletions
19
lottery-module/src/com/example/lottery/application/LotteryApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.random.service; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface QoS { | ||
QualityLevel value(); | ||
} |
5 changes: 5 additions & 0 deletions
5
random-module/src/com/example/random/service/QualityLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.example.random.service; | ||
|
||
public enum QualityLevel { | ||
FAST, SECURE, CHEAP | ||
} |
17 changes: 17 additions & 0 deletions
17
random-module/src/com/example/random/service/business/CheapRandomNumberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.random.service.business; | ||
|
||
import com.example.random.service.QoS; | ||
import com.example.random.service.QualityLevel; | ||
import com.example.random.service.RandomNumberService; | ||
|
||
@QoS(QualityLevel.CHEAP) | ||
public class CheapRandomNumberService implements RandomNumberService { | ||
private static int counter = 0; | ||
@Override | ||
public int generate(int min, int max) { | ||
System.err.println("CheapRandomNumberService::generate"); | ||
counter++; | ||
return min + (counter % (max-min+1) ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import com.example.random.service.RandomNumberService; | ||
import com.example.random.service.business.CheapRandomNumberService; | ||
import com.example.random.service.business.FastRandomNumberService; | ||
import com.example.random.service.business.SecureRandomNumberService; | ||
|
||
module com.example.random { | ||
exports com.example.random.service; | ||
provides RandomNumberService with FastRandomNumberService,SecureRandomNumberService; | ||
provides RandomNumberService with FastRandomNumberService,SecureRandomNumberService,CheapRandomNumberService; | ||
} |