1 / 24

The tools used by esup-helpdesk developers: Eclipse, Omondo EclipseUML plugin, Apache OJB JDO

SIGILUM. UNIVERSITATIS. REDONENSIS. UNIVERSITE DE RENNES 1. The tools used by esup-helpdesk developers: Eclipse, Omondo EclipseUML plugin, Apache OJB JDO. Pascal Aubry & Alexandre Boisseau IFSIC – University of Rennes 1 – May 2004 http://perso.univ-rennes1.fr/pascal.aubry/presentations/jdo.

doctor
Download Presentation

The tools used by esup-helpdesk developers: Eclipse, Omondo EclipseUML plugin, Apache OJB JDO

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. SIGILUM UNIVERSITATIS REDONENSIS UNIVERSITE DE RENNES 1 The tools used by esup-helpdesk developers:Eclipse,Omondo EclipseUML plugin,Apache OJB JDO Pascal Aubry & Alexandre Boisseau IFSIC – University of Rennes 1 – May 2004 http://perso.univ-rennes1.fr/pascal.aubry/presentations/jdo

  2. A Java program Program.java (runtime logic) runtime components Program.class javac Legend: user-maintained data tools and programs generated data

  3. A uPortal channel Channel.java (runtime logic) implementation IChannel.java runtime components Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs generated data

  4. A uPortal channel accessing a database database databasemanagement Data.java (data access) Channel.java (runtime logic) implementation IChannel.java runtime components Data.class javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs generated data

  5. Accessing the database through (OJB) JDO database databasemanagement databaseobject map Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs generated data

  6. Using Omondo EclipseUML plugin database UML model OmondoeclipseUML databasemanagement databaseobject map code generation & reverse engineering Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs generated data

  7. Using Omondo EclipseUML plugin database UML model OmondoeclipseUML databasemanagement databaseobject map code generation & reverse engineering Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs generated data

  8. database UML model OmondoeclipseUML databasemanagement database object mapping databaseobject map code generation & reverse engineering Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs missing feature generated data

  9. database UML model OmondoeclipseUML databasemanagement database object mapping databaseobject map code generation & reverse engineering Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs missing feature generated data

  10. database UML model OmondoeclipseUML databasemanagement database object mapping databaseobject map code generation & reverse engineering Data.java (data access) Channel.java (runtime logic) implementation OJB JDO enhancer IChannel.java runtime components Data.class JDO runtime javac databaseaccesses databaseaccessconfig Channel.class javac runtimedata XMLoutput Legend: uPortal user-maintained data tools and programs missing feature generated data

  11. JDO principles • Database abstraction • Uses JDBC • JDBC abstracts the database manager • JDO abstracts the data:no SQL code is written at all! • Persistence management • Perform changes on objects • the changes are automatically reflected on the data (in the database)

  12. JDO specifications • http://java.sun.com/products/jdo/index.jsp • http://www.theserverside.com/articles/article.tss?l=JDO • http://www.onjava.com/pub/a/onjava/excerpt/JDO_chap3/

  13. JDO implementations • Commercial • Kodo JDO (SolarMetric/Versant) • the most feature complete, easy to use implementation. • JDO Genie • pretty feature complete, but bad reputation. • JCredo • Open-source • OJB (Apache, open source) • JDO support is added through a plugin. A native JDO implementation will come with JDO 2.0. • TJDO (dead), XORM (not followed) • Castor JDO • Last release in march 2004. Middle product • JOnAS (ObjectWeb) • JOnAS is a J2ee specification which include JDO implementation. • Hibernate JDO (Hibernate) • seems to be a good product • JBoss announced an open-source JDO implementation in JBoss. • http://www.theserverside.com/discussions/thread.tss?thread_id=21825

  14. A very short example

  15. The CUser class public class CUser { private String id; private String displayName; public CUser(String id, String displayName) { this.id = id; this.displayName = displayName; } public String getId() { return id; } public String getDisplayName() { return displayName; } }

  16. The CDoc class public class CDoc { private long id; private java.sql.Timestamp date; private CUser sender; private String senderId; public CDoc(String description, CUser sender) {// id is automatically set by OJB-JDO. this.date = new java.sql.Timestamp( new Date().getTime()); this.sender = sender; this.senderId = sender.getId(); } public long getId() { return id; } public Timestamp getDate() { return date; } public CUser getSender() { return sender; } }

  17. CUser database mapping <class-descriptor class="CExample.CUser" table="user"> <field-descriptor name="id" column="id" jdbc-type="VARCHAR" primarykey="true" /> <field-descriptor name="displayName" column="displayName" jdbc-type="VARCHAR"/></class-descriptor>

  18. CUser database mapping <field-descriptor name="id" column="id" jdbc-type="VARCHAR"/> • Table user : • id (primary-key) • displayname <field-descriptor name="displayName" column="displayname" jdbc-type="VARCHAR"/>

  19. CDoc database mapping <class-descriptor class="CExample.CDoc" table="doc"> <field-descriptor name="id" column="id" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/> <field-descriptor name="date" column="date“ jdbc-type="TIMESTAMP"/> <field-descriptor name="senderId" column="sender" jdbc-type="VARCHAR"/> <reference-descriptor name="sender" class-ref="CExample.CUser"> <foreignkey field-ref="senderId"/> </reference-descriptor> </class-descriptor>

  20. CDoc database mapping field-descriptor name="date"column="date"jdbc-type="TIMESTAMP"/> • Table doc : • id (primary-key) • date • sender-id • Table user : • id (primary-key) • displayname <reference-descriptor name="sender" class-ref="CExample.CUser"><foreignkeyfield-ref="senderId"/>

  21. Programming with OJB // Get an Persistence Manager Factory (PMF) OjbStorePMF f = new OjbStoryPMF();// Get a Persistence ManagerPersistenceManager manager = f.getPersistenceManager(); // Start a transaction manager.currentTransaction().begin(); //// Do things... // // Commit or rollback the transactionmanager.currentTransaction().commit();

  22. Example: display all users try { manager.currentTransaction().begin(); Query query = manager.newQuery(CUser.class); Collection allUsers = (Collection) query.execute(); Iterator iter = allUsers.iterator(); while (iter.hasNext()) { u = (CUser) iter.next(); System.out.println("id=" + u.getId() + ", displayName=" + u.getDisplayName()); i++; } manager.currentTransaction().commit(); } catch (Throwable t) { t.printStackTrace(); } finally { manager.close();} }

  23. Example: create a user CUser u = new CUser("mon-id", "NOM prenom"); Transaction tx = manager.currentTransaction(); tx.begin(); // Mark object as persistant manager.makePersistent(u); try{ // Commit the transaction, object mark persistent is stored. tx.commit(); } catch(OjbStoreFatalInternalException ex){ System.out.println("User already exists!"); } finally { manager.close(); }

  24. Example: delete a user Transaction tx = manager.currentTransaction(); tx.begin(); Query query = manager.newQuery(CUser.class, "displayName == \"Toto\""); Collection result = (Collection) query.execute(); if (result.size() == 0) { System.out.println("No user found!"); } else if (result.size() > 1) { System.out.println("Several users match!"); } else { CUser u = (CUser) result.iterator().next(); manager.deletePersistent(u); } tx.commit();

More Related