官术网_书友最值得收藏!

Implementing the domain-store pattern

This is a very long pattern. To implement and facilitate this implementation, we will save all the data on HashMap. This is an important step, because the focus of this subsection is to demonstrate how to implement domain-store patterns. To facilitate our understanding, we will look at the same scenario covered in the Implementing the data-access object pattern subsection. Here, we have the transfer object, called Employee, and we will also read and write data on the data source. However, persistence will be oriented by object state and will have an intelligence in its logic.. In this implementation, we have the following classes, interfaces, and annotations:

  • PersistenceManagerFactory: This works as a factory pattern and is responsible for creating instances of the PersistenceManager class. PersistenceManagerFactory is a singleton and has only one instance on the entire application.
  • PersistenceManager: This manages the persistence and queries the data. This data is an object model that works as a Unit of Work. 
  • Persistence: This is an annotation used as the qualify of CDI. This qualify is used to define a method of PersistenceManagerFactory, which is responsible for creating a PersistenceManager instance.
  • EmployeeStoreManager: This works as a Data-Access Object (DAO), interacting with the data source and encapsulating all the data source complexity. DAO is responsible for reading and writing employee data on the data source.
  • StageManager: This is an interface used to create all the StageManager implementations.
  • EmployeeStageManager: This coordinates the read and writes operations of data according to its states and rules.
  • TransactionFactory: This works as a factory pattern and is responsible for creating Transaction instances. TransactionFactory is a singleton and has only one instance in the entire application.
  • Transaction: This is used to create transaction-oriented policies. This class controls the life cycle of transactions and defines the transaction limits.
  • Transaction (annotation): Annotation used as the qualify of CDI. This qualify is used to define a method of TransactionFactory that is responsible for creating a Transaction instance.

To implement this pattern, we will begin with the PesistenceManagerFactory class, which is a factory of PersistenceManager.

主站蜘蛛池模板: 西和县| 藁城市| 天台县| 华蓥市| 隆回县| 会同县| 肥西县| 淮安市| 类乌齐县| 清镇市| 宁波市| 青铜峡市| 芒康县| 肃宁县| 乐陵市| 乡城县| 赤城县| 府谷县| 清苑县| 和龙市| 新野县| 沁阳市| 唐河县| 承德市| 玛沁县| 堆龙德庆县| 玉门市| 磴口县| 旬阳县| 防城港市| 陇川县| 石城县| 亚东县| 枣阳市| 久治县| 鹤壁市| 行唐县| 安阳市| 喀什市| 淮北市| 中江县|