forked from iluwatar/java-design-patterns
-
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.
Resolves checkstyle errors for converter, cqrs (iluwatar#1063)
* Reduces checkstyle errors in converter * Reduces checkstyle errors in cqrs
- Loading branch information
1 parent
2f49648
commit 4f9ee01
Showing
16 changed files
with
129 additions
and
127 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
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
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 |
---|---|---|
|
@@ -23,12 +23,6 @@ | |
|
||
package com.iluwatar.cqrs.app; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.iluwatar.cqrs.commandes.CommandServiceImpl; | ||
import com.iluwatar.cqrs.commandes.ICommandService; | ||
import com.iluwatar.cqrs.constants.AppConstants; | ||
|
@@ -37,59 +31,63 @@ | |
import com.iluwatar.cqrs.queries.IQueryService; | ||
import com.iluwatar.cqrs.queries.QueryServiceImpl; | ||
import com.iluwatar.cqrs.util.HibernateUtil; | ||
import java.math.BigInteger; | ||
import java.util.List; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* CQRS : Command Query Responsibility Segregation. A pattern used to separate query services from commands or writes | ||
* services. The pattern is very simple but it has many consequences. For example, it can be used to tackle down a | ||
* complex domain, or to use other architectures that were hard to implement with the classical way. | ||
* | ||
* This implementation is an example of managing books and authors in a library. The persistence of books and authors is | ||
* done according to the CQRS architecture. A command side that deals with a data model to persist(insert,update,delete) | ||
* objects to a database. And a query side that uses native queries to get data from the database and return objects as | ||
* DTOs (Data transfer Objects). | ||
* CQRS : Command Query Responsibility Segregation. A pattern used to separate query services from | ||
* commands or writes services. The pattern is very simple but it has many consequences. For | ||
* example, it can be used to tackle down a complex domain, or to use other architectures that were | ||
* hard to implement with the classical way. | ||
* | ||
* <p>This implementation is an example of managing books and authors in a library. The persistence | ||
* of books and authors is done according to the CQRS architecture. A command side that deals with a | ||
* data model to persist(insert,update,delete) objects to a database. And a query side that uses | ||
* native queries to get data from the database and return objects as DTOs (Data transfer Objects). | ||
*/ | ||
public class App { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class); | ||
|
||
/** | ||
* Program entry point | ||
* | ||
* @param args | ||
* command line args | ||
* Program entry point. | ||
* | ||
* @param args command line args | ||
*/ | ||
public static void main(String[] args) { | ||
ICommandService commands = new CommandServiceImpl(); | ||
|
||
// Create Authors and Books using CommandService | ||
commands.authorCreated(AppConstants.E_EVANS, "Eric Evans", "eEvans@email.com"); | ||
commands.authorCreated(AppConstants.E_EVANS, "Eric Evans", "evans@email.com"); | ||
commands.authorCreated(AppConstants.J_BLOCH, "Joshua Bloch", "[email protected]"); | ||
commands.authorCreated(AppConstants.M_FOWLER, "Martin Fowler", "[email protected]"); | ||
|
||
commands.bookAddedToAuthor("Domain-Driven Design", 60.08, AppConstants.E_EVANS); | ||
commands.bookAddedToAuthor("Effective Java", 40.54, AppConstants.J_BLOCH); | ||
commands.bookAddedToAuthor("Java Puzzlers", 39.99, AppConstants.J_BLOCH); | ||
commands.bookAddedToAuthor("Java Concurrency in Practice", 29.40, AppConstants.J_BLOCH); | ||
commands.bookAddedToAuthor("Patterns of Enterprise Application Architecture", 54.01, AppConstants.M_FOWLER); | ||
commands.bookAddedToAuthor("Patterns of Enterprise" | ||
+ " Application Architecture", 54.01, AppConstants.M_FOWLER); | ||
commands.bookAddedToAuthor("Domain Specific Languages", 48.89, AppConstants.M_FOWLER); | ||
commands.authorNameUpdated(AppConstants.E_EVANS, "Eric J. Evans"); | ||
|
||
IQueryService queries = new QueryServiceImpl(); | ||
|
||
// Query the database using QueryService | ||
Author nullAuthor = queries.getAuthorByUsername("username"); | ||
Author eEvans = queries.getAuthorByUsername(AppConstants.E_EVANS); | ||
BigInteger jBlochBooksCount = queries.getAuthorBooksCount(AppConstants.J_BLOCH); | ||
Author evans = queries.getAuthorByUsername(AppConstants.E_EVANS); | ||
BigInteger blochBooksCount = queries.getAuthorBooksCount(AppConstants.J_BLOCH); | ||
BigInteger authorsCount = queries.getAuthorsCount(); | ||
Book dddBook = queries.getBook("Domain-Driven Design"); | ||
List<Book> jBlochBooks = queries.getAuthorBooks(AppConstants.J_BLOCH); | ||
List<Book> blochBooks = queries.getAuthorBooks(AppConstants.J_BLOCH); | ||
|
||
LOGGER.info("Author username : {}", nullAuthor); | ||
LOGGER.info("Author eEvans : {}", eEvans); | ||
LOGGER.info("jBloch number of books : {}", jBlochBooksCount); | ||
LOGGER.info("Author evans : {}", evans); | ||
LOGGER.info("jBloch number of books : {}", blochBooksCount); | ||
LOGGER.info("Number of authors : {}", authorsCount); | ||
LOGGER.info("DDD book : {}", dddBook); | ||
LOGGER.info("jBloch books : {}", jBlochBooks); | ||
LOGGER.info("jBloch books : {}", blochBooks); | ||
|
||
HibernateUtil.getSessionFactory().close(); | ||
} | ||
|
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
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
Oops, something went wrong.