1 / 20

SaxStore: a n aspect oriented persistence library for Java based on SAX events

SaxStore: a n aspect oriented persistence library for Java based on SAX events. Riccardo Solmi University of Bologna May 2001. Summary. SaxStore: features and usage scenarios Choice of a perspective XML representation Accessing XML data Accessing application objects

minnie
Télécharger la présentation

SaxStore: a n aspect oriented persistence library for Java based on SAX events

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. SaxStore: an aspect orientedpersistence library for Javabased on SAX events Riccardo Solmi University of BolognaMay 2001

  2. Summary • SaxStore: features and usage scenarios • Choice of a perspective • XML representation • Accessing XML data • Accessing application objects • SaxStore persistence management

  3. Features • SaxStore provides a mechanism to map arbitrary Java objects into a stream of SAX events and backward. • SAX events can be serialized to an XML stream and saved to disk or transmitted across a network. • XSLT transformations (translets) can be used to support versioning, stylesheet application and conformance to a given XML Schema.

  4. Long-term persistence scenario Runtime Application objects Stylesheet 1.0 to 1.1 Stylesheet 1.1 to 1.2 Stylesheet 1.2 to 1.1 Stylesheet 1.1 to 1.0 XML parser XSLT compiler XSLT compiler SaxStore XSLT compiler XSLT compiler XML serializer XML • Compression • Integrity signature • Given XML Schema

  5. Representation scenario Runtime Application objects Stylesheet for XSLFO representation XSLFO representation SaxStore XSLT compiler • Dynamic form filling • XSLFO, XHTML, SVG, …

  6. Data exchange scenario Runtime Application objects Runtime Application objects Stylesheet transformation to a given XML Schema Stylesheet transformation from a given XML Schema Schema instance SaxStore XSLT compiler XSLT compiler SaxStore • Given XML Schema • Sun XMLB is better (may be)

  7. Persistence • To preserve something of the current execution state between successive program runnings. • To store a (runtime) graph of objects to a non volatile memory and to reconstruct an equivalent graph of objects.

  8. Requirements • Exchangable and neutral data format(i.e. XML) • Almost automatic but customizable • Large graphs of objects • Versioning • Performance

  9. Goals • Powerful and easy to use as Java Serialization API • Support short-term & long-term persistence • Data exchange between running applications • Document format for successive executions • Decouple producers and consumers • Support distributed applications

  10. Persistence and Java • Java has not yet a standard persistence library • Java Serialization API provides only short term persistence and was introduced to support RMI. • SUN is working only on projects that doesn’t satisfy my requirements.

  11. Runtime and persistent representations • Both runtime and persistent representations should be user defined. • Runtime. To implement efficiently application algorithms • Persistent. To support interoperability of applications and loosly coupled distributed systems

  12. Choice of a perspective • An (almost) automatic transformation between two unconstrained and unrelated forms is not possible! • Two alternative points of view are suitable: • Java side: • XML side: My classes XML My XML custumizable manual My classes Java classes My XML manual auto

  13. Data Binding: focus on XML side • Data Binding (JSR-031) – Bind Java objects to an XML document. Compiles an XML Schema to Java classes with specific accessor and mutator methods that affect the underlying XML document. • Writing the XML Schema from application classes (or even from scratch) is expansive. • Writing the code, in application classes, that store/retrive data to/from the graph of generated classes is not trivial. • Generated classes requires additional memory

  14. SaxStore: focus on Java side • In many applications the format of XML representation doesn’t matter. • Versioning support is the major requirement. • An easy to understand XML representation is enough. • Customization is required only for a very small number of classes.

  15. SaxStore XML representation • Is an XML-Schema instance. • Objects are mapped to elements • Objects have an id attribute with a unique value and a xsi:type attribute with the runtime type. • Fields are mapped to nested elements with the same name (because attributes are not referenceable) • Objects already mapped are represented by an element with an idref attribute.

  16. Accessing XML data • Callbacks(SAX) – Is an event-driven model; the parsing of an XML document trigger callback methods. • Trees (DOM) – The parsing of an XML document create a tree structure manageable with a set of standard methods. SaxStore is based on SAX2 events.

  17. Accessing application objects • Reflection • State exposition • Field level accessor and mutator methods • Object level persistence methods • Aspect

  18. Persistence vs encapsulation • Reflection violates encapsulation and performs poorly. • Field level state exposition make encapsulation useless. • Object level state exposition alone is a weak solution and requires excessive work. • Aspects preserve encapsulation while retaining instance methods performance.

  19. SaxStore persistence management • User defined • XmlSerializable interface (source required) • Custom aspect or single classes • XmlSerializer interface or adapter class • Singletons • Part objects • Automatic • AspectWriter preprocessor (source required) • Reflective XmlSerializer

  20. Future works • Produce an XML-Schema • Support XML-Schema constraints • Generation of persistence code based on reverse engineering of classes that uses Java serialization API • Integration with distributed API

More Related