Java Magazine, May/June 2018
ORACLE COM JAVAMAGAZINE MAY JUNE 2018 54 design patterns Value objects typically implement equals and hashCode to ensure that identical instances are recognized as such You probably noticed that the model implementation is not completely immutable This is because of the requirement in the current JPA specification to define no argument constructors with at least protected visibility Some mapping frameworks such as Hibernate make it possible to further restrict the visibility by defining private no argument constructors This step however is not fully compliant with the JPA standard and leads to nonportable applications Services Services are responsible for performing domain business logic that is not naturally part of an entity or value object They are entry points of the business use cases that manage and orchestrate domain entities and they hold together the separate steps of the business process In a Java EE world services are implemented as managed beans either Contexts and Dependency Injection CDI beans or EJB beans Services that serve as the entry point for business use cases sometimes called boundaries are usually implemented as EJB beans They already comprise often required cross cutting concerns such as transactions The InstrumentCraftShop service represents the use case boundary for creating new music instruments @ Stateless public class InstrumentCraftShop @ Inject InstrumentMaker instrumentMaker @ PersistenceContext EntityManager entityManager public ElectricGuitar craftInstrument ElectricGuitar instrument instrumentMaker build
You must have JavaScript enabled to view digital editions.