Presentation is loading. Please wait.

Presentation is loading. Please wait.

Similar presentations


Presentation on theme: ""— Presentation transcript:

1

2 Speedo presentation - 2 Plan Speedo: the project view JDO Model  By the example  The API Speedo: the implementation  Architecture  The generator (enhancer)

3 Speedo: The project view

4 Speedo presentation - 4 Speedo, What is it ? Implementation of the JDO 2.0 specification http//www.objectweb.org open source community built on top of:  Jorm: mapping of objects into a persistent support  Medor: query framework  Perseus: persistence framework Use Fractal, Julia, ASM, Monolog, MX4J Leader: France Telecom R&D Project responsible: S.Chassande-Barrioz

5 Speedo presentation - 5 Speedo in Objectweb SpeedoEJB CMP2 Cache (Perseus) Concurrency (Perseus) Transaction (JCA) Mapping (JORM) RDBODBLDAP Query (MEDOR) Container File Frame- work Data support Application = { Components }

6 Speedo presentation - 6 Speedo: features (1/2) JDO 2.0  Query aggregate  Detach/attach mechanism Byte code enhancement (ASM) Data support: relational databases only Support legacy database Various concurrency management:  By Speedo itself: Optimistic, pessimistic or Mutex  Delegated to the database  Granularity: Collection | element L2 Cache (persistent objects)  replacement policy: LRU | MRU | FIFO | …  Configuration per classes

7 Speedo presentation - 7 Speedo: Features (2/2) Lazy loading by default but fetch group (JDO2) Data prefetching on query and collection loading  Avoid useless I/O  increase the performance Fractal  component architecture  JMX Component pooling  Avoid the creation of java objects  Avoid the creation and the fractal component binding Jorm/Medor advantages  Legacy support  Other than relationnal data base  Futur: Distribution / federation

8 Speedo presentation - 8 Speedo: tools EclipseJDO Eclipse plugin for speedo.properties PONEI: Eclipse plugin for nagivate and edit JDO persistent model  For JDO developer Speedo documentation as Eclipse Plugin Ant task for enhancement step HTTP console for administration/monitoring

9 Speedo presentation - 9 Work plan 3Q2005:  Several inheritance mappings (horizontal & vertical)  JDO 2: features – Standard mapping in.jdo/.orm – Interface 3Q2005:  Support EJB 3.0 API / JOnAS CMP3 2006:  Distributed concurrency: Perseus on JGroups  Distributed cache: – Perseus, Oscache,Tangosol, gigaspaces

10 The JDO Model

11 Speedo presentation - 11 JDO: What is it ? SUN specification Persistence of java objects JDO Data source Persistent object

12 Speedo presentation - 12 JDO: the principles (1/4) Persistent descriptor =.jdo file  Which classes are persistent ?  Which fields are persistent ?  Vendor extension for the mapping

13 Speedo presentation - 13 JDO: the principles (2/4) Explicit persistence management  makePersistent(Object o)  deletePersistent(Object o)  getObjectById(Object oid)  … Implicit persistence A a1 = …; //a persistent object B b1 = … ; // a non persistent object a1.setMyB(b1); //Now the ‘b1’ instance is persistent

14 Speedo presentation - 14 JDO: the principles (3/4) User transaction demarcation  Begin  Commit | rollback queries built by a programatic way

15 Speedo presentation - 15 JDO: the principles (4/4) PersistenceManagerFactory  Represents a data source  Provides PersistenceManager instance PersistenceManager  Helper to manage the persistence of objects makePersistent, deletePersistent, …  Linked to one PMF  Linked to one transaction

16 Speedo presentation - 16 JDO: Example (1/4) public class Toto { PersistenceManagerFactory pmf; public void initJDO(String fileName) { Properties p = new Properties(); p.load(new FileInputStream(fileName)); pmf = JDOHelper.getPersistenceManagerFactory(p); } Load properties of JDO driver from a properties file (speedo.properties) Use JDO tool to instanciate/find a PersistenceManagerFactory with properties.

17 Speedo presentation - 17 JDO: Example (2/4) public class Department { String name; Map emps = new HashMap(); public Employee createEmployee(String en) { PersistenceManager pm = pmf.getPersistenceManager(); pm.currentTransaction().begin(); Employee e = new Employee() e.name = en; e.dept = this; emps.put(en, e); pm.makePersistent(e); pm.currentTransaction().commit(); pm.close(); } Fetch PM Transaction begin Make persistent the new Employee transaction commit release the pm

18 Speedo presentation - 18 JDO: Example (3/4) public Employee removeEmployee(String en) { Employee e = emps.get(en); if (e == null) return null; PersistenceManager pm = pmf.getPersistenceManager(); pm.currentTransaction().begin(); pm.deletePersistent(e); pm.currentTransaction().commit(); pm.close(); } Fetch PM Transaction begin Remove the Employee transaction commit release the pm

19 Speedo presentation - 19 JDO: Example (4/4) public Collection getPoorEmployee(int salary) { PersistenceManager pm = pmf.getPersistenceManager(); pm.currentTransaction().begin(); Query query = pm.newQuery(Employee.class); query.declareParameters("Float s"); query.setFilter("(salary < s)"); Collection col = new ArrayList( (Collection) query.execute(new Float(1500.0))); pm.currentTransaction().commit(); pm.close(); return col; } new query over the Employee class declare a parameter declare the filter Execute the query with the parameter

20 Speedo: The implementation

21 Speedo presentation - 21 The Speedo component Persistence Manager Factory Persistence Manager Pool PersistenceManagerFactory PoolResource ProxyManager Speedo = One fractal composite component

22 Speedo presentation - 22 Speedo lauching Two ways:  Use the Speedo component (fractal environnement)  Use the org.objectweb.speedo.Speedo class – to launch julia, – to instanciate the component Speedo Application Interface PersistenceManagerFactory Simple classThe component

23 Speedo presentation - 23 PersistenceManagerFactory : the component PMF = one data source = one mapper Pool of PersistenceManager instance Persistence Manager Factory Mapper PooMatchFactory PersistenceManagerFactory ProxyManagerSwitch Pool PMapper PMS Pool

24 Speedo presentation - 24 The PersistenceManager component Transaction ProxyMan ager ProxyManagerSwitch SpeedoTransactional PersistenceManager SpeedoQueryManager CacheManager Pool ProxyManager PoolMatchFactory Pool QueryManager SpeedoTransaction QueryManager CacheManager PersistenceManagerFactory ProxyManager Switch TransactionalPersistence Manager

25 Speedo presentation - 25 Pool / Fractal component Why pooling some fractal components  Remove the cost of the components creation and binding  PersistenceManager / Transaction

26 Speedo presentation - 26 The Speedo container My Container definition: code added to the application using services in order to add semantic. Speedo uses several technics:  Code generation (Velocity)  Byte code injection (ASM)  Classes merging (ASM)  One class

27 Speedo presentation - 27 The Speedo enhancer: overview XXXPBinding XXX XXXProxy XXX Byte code injection 1/ 2/ Jorm Generation XXXPBinding 3/ Speedo Generation XXXProxy 4/ Merging extends XXX

28 Speedo presentation - 28 The persistent object Persistent class (SpeedoProxy) without any field State (SpeedoAccessor) contains persistent fields Aims:  concurrency policies  Unique instance per OID (less java object creation)


Download ppt ""

Similar presentations


Ads by Google