Presentation is loading. Please wait.

Presentation is loading. Please wait.

SaxStore: a n aspect oriented persistence library for Java based on SAX events Riccardo Solmi University of Bologna May 2001.

Similar presentations


Presentation on theme: "SaxStore: a n aspect oriented persistence library for Java based on SAX events Riccardo Solmi University of Bologna May 2001."— Presentation transcript:

1 SaxStore: a n aspect oriented persistence library for Java based on SAX events Riccardo Solmi University of Bologna May 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 SaxStore Runtime Application objects XSLT compiler XSLT compiler XML serializer XSLT compiler XSLT compiler XML parser XML Stylesheet 1.0 to 1.1 Stylesheet 1.1 to 1.2 Stylesheet 1.2 to 1.1 Stylesheet 1.1 to 1.0 Compression Integrity signature Given XML Schema

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

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

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 automanual

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


Download ppt "SaxStore: a n aspect oriented persistence library for Java based on SAX events Riccardo Solmi University of Bologna May 2001."

Similar presentations


Ads by Google