80 likes | 412 Views
Service Oriented Architecture using Spring Framework . Ryan Kirkendall Xiaofeng Qi. Goals of SOA. Promote loosely coupled services with clear areas of functionality Utilize Spring provided classes to reduce redundant code (DAOs) Services are “black boxes” to client code
E N D
Service Oriented Architecture using Spring Framework Ryan Kirkendall Xiaofeng Qi
Goals of SOA • Promote loosely coupled services with clear areas of functionality • Utilize Spring provided classes to reduce redundant code (DAOs) • Services are “black boxes” to client code • Can be replaced/refactored without impacting client code • Results in code that is: • Cleaner • More reliable • More flexible • More understandable
Components of a service • Service interface (client code programs against this) • Service implementation • DAO (Data Access Object) interface • DAO Implementation • POJO (plain old java object) goes between the layers of the application.
Guidelines • Anything can talk to a service (POJO, DAO, other services) • Only a given service may talk to it’s DAO(s) • Services and DAOs are accessed by their interface • Requires a factory for constructing these objects (Spring framework) • Services throw unchecked exceptions
Diagram – client code/service/dao interaction OJB Services (Interfaces, Implementations) (POJO) NOTE: POJOS (Model Beans) are always the same there is no bean translation between layers Stolen graphic from: http://www.onjava.com/lpt/a/4744
Close Up Service Layer Service Implementation POJO DAO Implementation Client Code (Struts, Other Services, POJOs) POJO Service Interface DAO Interface POJO POJO Client Code retrieves Service Implementation from Spring and communicates with Implementation using the Service Interface Spring “injects” DAO into service Implementation. Service communicates with DAO using the DAO interface NOTE: POJOS (Model Beans) are always the same there is no bean translation between layers Code Examples
Close Up Struts Layer ActionForm 2. Struts gives ActionForm to Action Action 3. Action gets Model Bean from ActionForm and send it to service layer POJO 5. Action Returns Action Form with embedded Model Bean POJO POJO 4. Service Returns Model Bean ActionForm Service(s) POJO 1. Set Model Bean directly from JSP using “.” notation to drill down to bean through ActionForm JSP JSP 6. JSP Renders Module bean NOTE: POJOS (Model Beans) are always the same there is no bean translation between layers Code Examples
On to the code URLs about SOA http://www.onjava.com/lpt/a/4744 http://www-106.ibm.com/developerworks/webservices/library/ws-migratesoa/ http://www.javaworld.com/javaworld/jw-10-2004/jw-1004-soa.html