Presentation is loading. Please wait.

Presentation is loading. Please wait.

OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University.

Similar presentations


Presentation on theme: "OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University."— Presentation transcript:

1 OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University

2 OOPSLA Lab2 Contents 7.1 Introduction 7.2 Java ODL 7.3 Java OML 7.4 Java OQL

3 OOPSLA Lab3 7.1 Introduction(1) Language design principles –one principle perceive the binding as a single language for expressing both database and programming operation –several corollaries a single unified type system respect the Java language respect the automatic storage management semantics of Java Language binding –two ways to declare persistence-capable Java classes existing Java classes Java class declaration generated by a preprocessor for ODMG ODL

4 OOPSLA Lab4 7.1 Introduction(2) Use of Java language features –namespace the ODMG Java API will be defined in a vendor-specific package name –implementation extensions provide the full function signature for all the interface methods specified Mapping the ODMG object model into Java –object and literal ODMG object type maps into a Java object type ODMG atomic literal types map into their equivalent Java primitive types no structured literal types in the Java binding –structure the object model definition of a structure maps into a Java class –implementation interface and abstract classes cannot be instantiated

5 OOPSLA Lab5 7.1 Introduction(3) –collection classes the Java binding provides at least one implementation for each of the following collection objects public interface Set extends Collection {….} public interface Bag extends Collection {….} public interface List extends Collection {….} –array the ODMG array collection maps into either the primitive array type, the Java Vector class, or the ODMG VArray class –relationship not yet supported by the Java binding –extents not yet supported by the Java binding –keys not yet supported by the Java binding

6 OOPSLA Lab6 7.1 Introduction(4) –names objects may be named using methods of the Database class defined in the Java OML –exception handling an exception is thrown using the standard Java exception mechanism

7 OOPSLA Lab7 7.2 Java ODL Attribute declaration and types Relationship traversal path declarations –not yet supported in the Java binding Operation declaration –operation declarations in the Java ODL are syntactically identical to method declaration in Java

8 OOPSLA Lab8 7.3 Java OML(1) Object creation, deletion, modification, and reference –object persistence persistence by reachability : a transient Java object that is referenced by a persistent Java object will automatically become persistent –object deletion no notion of explicit deletion of objects –object modification modified persistent Java object will have their updated fields reflected in the object database –object locking support explicit locking using methods on the Transaction object Properties –uses standard Java syntax for accessing attributes and relationships Operation –defined as methods in the Java language

9 OOPSLA Lab9 7.3 Java OML(2) Collection interface –a comforming implementation must provide these collection interface Collection Set Bag List –interface Collection Public interface Collection { // Chapter 2 operations public int size(); // unsigned long cardinality() public boolean isEmpty(); // boolean is_empty() public void add(Object obj); // void insert_element(…) public Object remove(Object obj); // void remove_element(…) public boolean contains(Object obj); // boolean contains_element(…) public Enumeration elements(); // Iterator create_iterator(…) …….. }

10 OOPSLA Lab10 7.3 Java OML(3) Transaction –implemented as object of class Transaction –the creation of new transaction object implicitly associates it with the caller’s thread –class Transaction Public class Transaction { // Create new transaction object and associate it with the caller’s thread Transaction(); // Attaches caller’s thread to this existing Transaction; // any previous transaction detached from thread public void join(); ……… public void begin(); public void commit(); public void abort(); ……. }

11 OOPSLA Lab11 7.3 Java OML(4) Database operations –the predefined type Database represents a database –class Database Public class Database { // Access modes public static final int notOpen = 0; public static final int openReadOnly = 1; ….. // Returns the database the name specified. // Opens database if not already open. public static Database open(String name, int accessMode) throws ODMGException; public void close() throws ODMGException; // Named object binding and lookup public void bind(Object object, String name); public Object lookup(String name) throws ObjectNameNotFoundException; …… }

12 OOPSLA Lab12 7.4 Java OQL(1) Java OQL binding –support the full functionality of the object query language –two ways that use this functionality query method on class Collection queries using on a stand-alone OQLQuery class Collection query method –Collection interface has a query member function Collection query(String predicate) –example SetOfObject mathematicians; mathematicians = Students.query( “exists s in this.takes: s.section_of.name = \”math\” ”);

13 OOPSLA Lab13 7.4 Java OQL(2) OQLQuery class –allows the programmer to create a query –example class OQLQuery{ public OQLQuery(){} public OQLQuery(String query){…} // You can construct or.. public create(String query){….} // assign a query. public bind(Object parameter){…} public Object execute() throws ODMGException {…} } Bag mathematicians; Bag assistedProfs; Double x; OQLQuery query; mathematicians = Students.query(“exist s in this.takes: s.sectionOf.name = \”math” ”); query = new OQLQuery( “select t.assistants.taightBy from t in TA where t.salary > $1 and t in $2”); x = new Double(50000.0); query.bind(x); query.bind(mathematicians); assistedProfs = (Bag) query.executed();


Download ppt "OOPSLA Lab1 Chapter 7 Java Binding Prof. Hyoung-Joo Kim OOPSLA Lab. Dept. of Computer Engineering Seoul National University."

Similar presentations


Ads by Google