1 / 36

eSciDoc Persistence Layer

eSciDoc Persistence Layer. Architecture. Overview. General eSciDoc architecture Business Layer Excursion Persistence Layer Transformation to the module/dependency structure. Overview. 1. General eSciDoc architecture. Web Application. Spring Framework. Transport Layer.

ted
Download Presentation

eSciDoc Persistence Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. eSciDoc Persistence Layer Architecture

  2. Overview • General eSciDoc architecture • Business Layer Excursion • Persistence Layer • Transformation to the module/dependency structure

  3. Overview

  4. 1. General eSciDoc architecture Web Application Spring Framework TransportLayer CommunicationLayer Business LogicLayer PersistenceLayer CXF GZIP Interceptor FastInfoSetInterceptor XOP Interceptor REST EndpointSpec. REST EndpointImpl. Security Interceptor Transaction Interceptor Service Spec. Service Impl. Repository Spec. FEDORA Repository Impl. HTTPTransport FEDORA SOAP EndpointSpec. SOAP EndpointImpl. Hibernate RMDBRepository Impl. RMDB JMSTransport JAXB JSON map DomainObjects map PersistentObjects TransferObjects implements depends

  5. 1.1 Focus Web Application Spring Framework CommunicationLayer Business LogicLayer PersistenceLayer Service Spec. Service Impl. Repository Spec. Repository Impl. EndpointSpec. EndpointImpl. Data Maintenance System CL-Mapping PL-Mapping TransferObjects DomainObjects PersistentObjects implements depends

  6. 1.2 Mapping • CL- & PL-Mappings are part of each layer • Only the layer knows, which peaces of the business data belongs to the objects of the layer • Example: Hibernate • The Hibernate Layer defines the data structure to be used to persist the data (tables, indexes, etc.) • Hibernate Model A: Use one table to store Items and Container • Hibernate Model B: Use two different tables to store Items in one table and Containers in the other table • Example: Fedora • Fedora uses FOXML to persist the data • Example: Communication Layer (CXF) • Defines Transport-Objects which are marshalled to XML, JSON etc. • Because of the different data structures each concrete layer instance implements, it is the layers responsibility, to map the business domain objects to its own data model • The business logic is completely independent of anything that happens outside of its own borders

  7. 2. Business Layer • A little excursion for later reference Business Logic Layer Service Spec. Persistence Spec. Service Impl. updateContainer() updateItem() updateMdRecords() updateMdRecord() MdRecord MdRecords Item Container … Domain Objects Uses Domain Object Possible Interface/Call Internal call to sub-method

  8. 2. Implementation structure • Structured, centralized and reusable code • Sub-resource methods reused by the service-methods handling the main resources • Avoid conceptual flaws on implementation of new features, bug fixes and so on (protect the developer by design) • Service methods implement the eSciDoc logic like • Update a resource: What happens, if the resource from the client equals the currently persisted resource and what happens if not? • Service methods use the Domain Objects as data holders, which only implement logic, that belongs to their semantic like • getObjid() : extracts the objid from the xlink:href • getVersionNumber() : extracts the version number from getObjid() • Thanks to this concept, sub-resource methods can be reused and offered as services to the communication layer as well

  9. 2. Flow example updateItem(item, null) updateItem(arg0) arg1 = retrieveItem() arg0.hasMdRecords() & arg1.hasMdRecords() updateMdRecords(arg0.getMdRecords(), arg1.getMdRecords()) CL PL updateMdRecords(mdRecords, null) updateMdRecords(arg0, arg1) arg1 == null ? arg1 = retrieveMdRecords() arg0.hasMdRecord(name) & arg1.hasMdRecord(name) updateMdRecord(arg0.getMdRecord(name), arg1.getMdRecord(name)) updateMdRecord(mdRecord, null) updateMdRecord(arg0, arg1) arg1 == null ? arg1 = retrieveMdRecord() arg0 != arg1 ? persistMdRecord()

  10. 2. Loss ofinformation • Providing central methods for reusability will cause a loss of information • eSciDoc interfaces are structured to support different resource types per interface • The centrally provided methods however do not differ between these resources, when handling sub-resources • The persistence layer may still need the information about the type of the resource • If the Hibernate Model B is being used • Or if the data is stored in different ways into the FOXML, depending on the resource type • Therefore we have to support the ResourceType for these methods, not matter if we need the type or not • Support future expandability and plug-in ability for the persistence layer • Signature example: updateMdRecord(MdRecord, MdRecord, ResourceType) • Support an extra package/module for the static sub-resource handlers for better understanding of the structure

  11. 3. Persistence Layer Goals • Currentgoalfor SCAPE: UseHadoopas a persistencelayer • Plug-in ability • In theory eSciDoc could get released without an already implemented persistence layer • How the customer can plug-in an own implementation of the persistence layer is not part of this presentation (How to do this in Tomcat, JBoss etc.) • Black box for the business layer • Exceptionhandling • Mapping ofthebusinessdomainobjectstoitsownobjects

  12. 3. Persistence Layer as a Black Box • Exception handling • Exceptionsthrown in thepersistencelayercannotbehandled in detailbythebusinesslayer • The businesslayerdoes not know, whatkindofpersistencelayerisbeingused • Plug-in supportofferscustomerstoimplementtheirownpersistencelayer, we do not evenknowanythingabouttheirimplementations • The businesslayermaydefine an abstractPersistenceException, which will betherepresentativeof all exceptionsthrown in thepersistencelayer • Ifwehavesomecode in thecurrentbusinesslayer, handling such persistencelayerexceptions, wehavetoanalyzethiscodeand find a bettersolutionfortheideaofthiscode • ResourceNotFoundException Return null instead of throwing an exception in the persistence layer and throw a ResourceNotFoundException in the business layer because it is the business logic decision and design to throw an exception, if a resource was not found

  13. 3. Exceptionhandling – Flow example (ResourceNotFoundException) retrieveItem() Communication Layer Business Layer Persistence Layer Retrieve Item Retrieve Item Retrieve Item Loaddata returnexception XML Throw 404 exception Return null 404 exception OR emptyresult OR anything alike DelegatePersistenceException throwPersistenceException Error-likeexception IO) returnresource XML Return Item Return resource Resourcefound

  14. 3. Exceptionhandling - Outcome • Avoid conceptual flaws on implementation • Non persistencelayerexceptionsshould not beavailableforthepersistencelayer • Adjust eSciDoc modulehierarchy • Adjustthepersistencelayerinterfacestodescribetheexpectedbehaviorofthebusinesslayer • Implementthemappingbetweenbusinessdomainobjectsandpersistencelayerobjectsasalreadydescribed

  15. 3. Plug-in ability • Nowwecanaddanykindofpersistencelayerimplementationtothebusinesslayerbymakingthemconfigurable in Spring Business LogicLayer Hibernate Model A Hibernate Model B Fedora … Repository Spec. Repository Impl. Repository Spec. Repository Impl. Repository Spec. Repository Impl. Service Spec. Service Impl. PL-Mapping PL-Mapping PL-Mapping PersistentObjects PersistentObjects PersistentObjects DomainObjects Data Maintenance System Data Maintenance System Data Maintenance System implements depends

  16. 3. Plug-in ability • But wait… • Thereissomethingverywrongwiththisarchitecture!

  17. 3. Plug-in ability • EachPersistencelayerdefinesitsownspecification. Business LogicLayer Hibernate Model A Hibernate Model B Fedora … Repository Spec. Repository Impl. Repository Spec. Repository Impl. Repository Spec. Repository Impl. Service Spec. Service Impl. PL-Mapping PL-Mapping PL-Mapping PersistentObjects PersistentObjects PersistentObjects DomainObjects Data Maintenance System Data Maintenance System Data Maintenance System implements depends

  18. 3. PersistenceSpecification • If the specification is part of the persistence layer, the business logic has to implement a switch in order to select and work with the current persistence layer • The businesslogichastoimplementspecialcode, whichdealswitheachpersistencelayerspecification • The businesslogiclayerdepends onthepersistencelayer • The businesslogiclayercannotspecifiytheexpectedbehaviorofthepersistencelayer (forexample: theexceptionhandling) • The persistencelayerspecificationexpectsthe persistent objects in itssignaturesandbecauseofthatthebusinesslogichastoperformthemappingfromitsdomainobjectstothe persistent objects, no matter whatkindofpersistencelayerweareusing • The persistencelayerisno real black box • A lotofuglycode will bewritten • All thisconflictswiththeideatosupporttheplug-in abilityandtoachieve an easy extensiontouseHadoopforexample

  19. 3. Correctedarchitecture Web Application Spring Framework CommunicationLayer Business LogicLayer PersistenceLayer Service Spec. Service Impl. Repository Spec. Repository Impl. EndpointSpec. EndpointImpl. Data Maintenance System CL-Mapping PL-Mapping TransferObjects DomainObjects PersistentObjects implements depends

  20. 3. Outcome • The businesslogiclayerdefinesthepersistencespecification • Usesitsdomainobjects in thesignatures • Predefinestheexpectedbehavior (Exceptionhandling etc.) • UsesthePersistenceException in thesignatures • Eachpersistenceimplementationimplementsthisonespecificationandperformsitsownmappingfromdomainobjectstoitsown persistent objects • The persistencelayerbecomes a real black box • The businesslogiclayercaneasilyworkwithanypersistencelayerimplementationwithouttheneedtoimplementspecialcodeforanypersistencelayerimplementation • The persistencelayerispluggablelikethecommunicationlayer

  21. 4. eSciDoc Modules> Communication Layer dataobjects-spec utilities woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl aa geronimo-servlet 3.0 spec common spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies Mapping context-rest-impl om Communication Layer Business Logic Layer BL dataobjects (domainobjects) Business logicspec.

  22. 4. eSciDoc Modules> Communication Layer dataobjects-spec utilities woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl aa geronimo-servlet 3.0 spec common spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies Mapping context-rest-impl om Beforewecontinue, wehaveto clean thisup.

  23. 4. eSciDoc Modules> Communication Layer • Dependenciesareresolvedtransitively. • „aspects“ & „policies“ shouldbeincluded in eachrootmoduleonly • Business logicmodulescannotbeused in thecommunicationlayerandviseversa. • Onlythebusinesslogicspecificationshouldbeused in module „context-rest-impl“ dataobjects-spec utilities woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl aa geronimo-servlet 3.0 spec common ? spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies Mapping context-rest-impl om

  24. 4. eSciDoc Modules> Communication Layer (Discussion) • dataobjects-impldepends on aa • Reasonunknown • Dependenciesutilitiesandcommon • Reusability • Not allowedbetweenlayers • Create a utilitymodule outside ofthelayers • Dependencytoom • Reasonunknown

  25. 4. eSciDoc Modules> Communication Layer (Cleanup) dataobjects-spec utilities woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl aa geronimo-servlet 3.0 spec common ? spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies om Mapping context-rest-impl Communication Layer Business Logic Layer BL dataobjects (domainobjects) Business logicspec.

  26. 4. eSciDoc Modules> Communication Layer (Final) dataobjects-spec woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl geronimo-servlet 3.0 spec spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies Mapping context-rest-impl Communication Layer Business Logic Layer BL dataobjects (domainobjects) Business logicspec.

  27. 4. eSciDoc Modules> Communication Layer (Final) dataobjects Noneedtodifferbetweenspec. & impl. forobjects Usewoodstoxastheparserimpl. for JAXB dataobjects-spec woodstox-core-asl CXF frontend-jaxrs Transports (HTTP, Jetty, JMS) dataobjects-impl geronimo-servlet 3.0 spec spring aspects jax-rsframework aspects FastInfoSet context-rest-spec policies implement General servletspec. (Also worksforJBoss) Mapping context-rest-impl See architecture on page 19 ? Communication Layer international standard that specifies a binary encoding format for the XML Information Set (for JMS?) call Business Logic Layer BL dataobjects (domainobjects) Business logicspec.

  28. 4. eSciDoc Modules> Business logiclayer BL dataobjects (domainobjects) Persistencelayerspec. Business logicspec. call implement aa See page 19 common Sub-resourcehandler aspects policies See page 7 - 14 Business logicImpl. Optional (Shouldbereplacedwith an HTTP connectionorusing CXF in termsofclusteringabilitieslater) Other dependencies (no eSciDoc modules)

  29. 4. eSciDoc Modules> Business logiclayer (Discussion) • dataobjects-specisrequiredfor SRU classesforexample but should not bepartofthislayer (RequestType, ResponseType, etc.) • Create dataobjects (domainobjects)moduleforbusinesslayer, wherethedomainobjectsarebeingimplementedandexternalobjectsaregeneratedfrom XSD schemafiles • Code aboutmappingbetween String & DateTimeshould not occur in thislayer (DateTimeJaxbConverterfromthe Communication Layer) • Put such utilityclasses in an utilitymodule, whichcanbereused on anylayerandis not partofanylayer • RenameDateTimeJaxbConvertertoDateTimeConverter (forexample)

  30. 4. eSciDoc Modules> Persistencelayer BL dataobjects (domainobjects) Persistencelayerspec. Business Logic Layer implement Persistent Layer PL dataobjects Mapping aspects policies PersistencelayerImpl. Other dependencies (no eSciDoc modules)

  31. 4. eSciDoc Modules> Persistencelayer (Discussion) • Nothing

  32. 4. Project Structure & Dependencies Utilities eSciDoc BL Project Domain Objects BL Impl. eSciDoc CL CXF Project eSciDoc PL Fedora Project BL Spec PL Spec

  33. 4. Project Structure & Dependencies • Advantages • The borders of the layers are clear • Protects the developer to spuriously add wrong dependencies • Maybe add some kind of Maven plug-in, which evaluates the allowed eSciDoc module dependencies • If a new persistence or communication layer is being implemented, a new project for this new layer can be created • Avoids adding a bunch of new modules to the current project for the new layer implementation(s) • The Utilities module has to be completely independent from any layer • If that is not possible, because you may need objects from one layer, it has to be part of this layer and cannot be reused in another layer!

  34. Addendum • Why do the CL, BL and PL layers looks so differently? • Let us look at this using another perspective and some examples BL BL Spec PL Spec call implement Request Request CL CXF REST CL Axis SOAP GUI PL Fedora PL Hibernate PL Hadoop “Plug-in” Incoming Outgoing

More Related