forked from springframeworkguru/spring5-jokes-app-v2
-
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.
Create Joke Service. Closes springframeworkguru#2
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/main/java/vmd/springframework/vmdjokesappv2/services/JokeService.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 vmd.springframework.vmdjokesappv2.services; | ||
|
||
public interface JokeService { | ||
String getJoke(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/vmd/springframework/vmdjokesappv2/services/JokeServiceImpl.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,21 @@ | ||
package vmd.springframework.vmdjokesappv2.services; | ||
|
||
import guru.springframework.norris.chuck.ChuckNorrisQuotes; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class JokeServiceImpl implements JokeService { | ||
|
||
private final ChuckNorrisQuotes chuckNorrisQuotes; | ||
|
||
// Hard-wired. Not DI. | ||
|
||
public JokeServiceImpl() { | ||
this.chuckNorrisQuotes = new ChuckNorrisQuotes(); | ||
} | ||
|
||
@Override | ||
public String getJoke() { | ||
return chuckNorrisQuotes.getRandomQuote(); | ||
} | ||
} |