Download presentation
Presentation is loading. Please wait.
1
www.objectweb.org http://speedo.objectweb.org speedo@objectweb.org
2
www.objectweb.org Speedo presentation - 2 Plan Speedo: the project view JDO Model By the example The API Speedo: the implementation Architecture The generator (enhancer)
3
www.objectweb.org Speedo: The project view http://speedo.objectweb.org speedo@objectweb.org
4
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org The JDO Model http://java.sun.com/products/jdo/
11
www.objectweb.org Speedo presentation - 11 JDO: What is it ? SUN specification Persistence of java objects JDO Data source Persistent object
12
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org Speedo presentation - 14 JDO: the principles (3/4) User transaction demarcation Begin Commit | rollback queries built by a programatic way
15
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org Speedo: The implementation http://speedo.objectweb.org speedo@objectweb.org
21
www.objectweb.org Speedo presentation - 21 The Speedo component Persistence Manager Factory Persistence Manager Pool PersistenceManagerFactory PoolResource ProxyManager Speedo = One fractal composite component
22
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org Speedo presentation - 25 Pool / Fractal component Why pooling some fractal components Remove the cost of the components creation and binding PersistenceManager / Transaction
26
www.objectweb.org 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
www.objectweb.org 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
www.objectweb.org 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)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.