Skip to content

Commit

Permalink
Create Joke Service. Closes springframeworkguru#2
Browse files Browse the repository at this point in the history
  • Loading branch information
vmdemo committed Jul 4, 2022
1 parent 518cbc9 commit 44a24d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package vmd.springframework.vmdjokesappv2.services;

public interface JokeService {
String getJoke();
}
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();
}
}

0 comments on commit 44a24d8

Please sign in to comment.