the tools used by esup-helpdesk developers: eclipse, omondo eclipseuml plugin, apache ojb jdo

24
Format PDF 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

Upload: doctor

Post on 19-Jan-2016

31 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

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

Format PDF

The tools used by esup-helpdesk developers:

Eclipse,Omondo EclipseUML plugin,

Apache OJB JDO

Pascal Aubry & Alexandre BoisseauIFSIC – University of Rennes 1 – May 2004

http://perso.univ-rennes1.fr/pascal.aubry/presentations/jdo

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

Format PDF

Program.java(runtime logic)

Program.java(runtime logic)

runtime components

Program.classProgram.classjavac

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

A Java program

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

Format PDF

Channel.java(runtime logic)

Channel.java(runtime logic)

runtime components

Channel.classChannel.class

uPortal

IChannel.javaIChannel.java

javac

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

A uPortal channel

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

Format PDF

Channel.java(runtime logic)

Channel.java(runtime logic)

runtime components

Data.classData.class

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

javacdatabaseaccesses

databasemanagement

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

A uPortal channel accessing a database

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

Format PDF

Channel.java(runtime logic)

Channel.java(runtime logic)

runtime components

Data.classData.class

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

javacdatabaseaccesses

databasemanagement

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

Accessing the database through (OJB) JDO

OJB JDOenhancer

databaseobject map

databaseobject map

JDO runtimeJDO runtime

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

Format PDF

runtime components

Channel.java(runtime logic)

Channel.java(runtime logic)

Data.classData.class JDO runtimeJDO runtime

UMLmodel

UMLmodel

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

OJB JDOenhancer

databaseobject map

databaseobject map

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

OmondoeclipseUML

javacdatabaseaccesses

databasemanagement

code generation &reverse engineering

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

Using Omondo EclipseUML plugin

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

Format PDF

runtime components

Channel.java(runtime logic)

Channel.java(runtime logic)

Data.classData.class JDO runtimeJDO runtime

UMLmodel

UMLmodel

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

OJB JDOenhancer

databaseobject map

databaseobject map

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

OmondoeclipseUML

javacdatabaseaccesses

databasemanagement

code generation &reverse engineering

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

Legend:

Using Omondo EclipseUML plugin

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

Format PDF

runtime components

Channel.java(runtime logic)

Channel.java(runtime logic)

Data.classData.class JDO runtimeJDO runtime

UMLmodel

UMLmodel

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

OJB JDOenhancer

databaseobject map

databaseobject map

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

OmondoeclipseUML

javacdatabaseaccesses

databasemanagement

code generation &reverse engineering

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

missing feature

Legend:

database object mapping

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

Format PDF

runtime components

Channel.java(runtime logic)

Channel.java(runtime logic)

Data.classData.class JDO runtimeJDO runtime

UMLmodel

UMLmodel

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

OJB JDOenhancer

databaseobject map

databaseobject map

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

OmondoeclipseUML

javacdatabaseaccesses

databasemanagement

code generation &reverse engineering

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

missing feature

Legend:

database object mapping

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

Format PDF

runtime components

Channel.java(runtime logic)

Channel.java(runtime logic)

Data.classData.class JDO runtimeJDO runtime

UMLmodel

UMLmodel

Data.java(data access)

Data.java(data access)

Channel.classChannel.class

uPortal

database

OJB JDOenhancer

databaseobject map

databaseobject map

IChannel.javaIChannel.java

javacdatabaseaccessconfig

databaseaccessconfig

OmondoeclipseUML

javacdatabaseaccesses

databasemanagement

code generation &reverse engineering

database object mapping

runtimedata

XMLoutput

impl

emen

tatio

n

user-maintained datauser-maintained data

generated datagenerated data

tools and programs

missing feature

Legend:

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

Format PDF

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)

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

Format PDF

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/

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

Format PDF

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

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

Format PDF

A very short example

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

Format PDF

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;}

}

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

Format PDF

The CDoc classpublic 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; }}

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

Format PDF

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>

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

Format PDF

CUser database mapping

Table user :

- id (primary-key)

- displayname

Table user :

- id (primary-key)

- displayname

<field-descriptor name="displayName" column="displayname" jdbc-type="VARCHAR"/>

<field-descriptor name="id" column="id" jdbc-type="VARCHAR"/>

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

Format PDF

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>

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

Format PDF

CDoc database mapping

Table doc :

- id (primary-key)

- date

- sender-id

Table doc :

- id (primary-key)

- date

- sender-id

Table user :

- id (primary-key)

- displayname

Table user :

- id (primary-key)

- displayname<reference-descriptor name="sender" class-ref="CExample.CUser"><foreignkey field-ref="senderId"/>

field-descriptor name="date" column="date" jdbc-type="TIMESTAMP"/>

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

Format PDF

Programming with OJB

// Get an Persistence Manager Factory (PMF)OjbStorePMF f = new OjbStoryPMF();

// Get a Persistence ManagerPersistenceManager manager = f.getPersistenceManager();

// Start a transactionmanager.currentTransaction().begin();

//// Do things... //

// Commit or rollback the transactionmanager.currentTransaction().commit();

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

Format PDF

Example: display all userstry { 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();}}

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

Format PDF

Example: create a user

CUser u = new CUser("mon-id", "NOM prenom");

Transaction tx = manager.currentTransaction();

tx.begin();

// Mark object as persistantmanager.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();}

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

Format PDF

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();