Java Doc for ObjectCacheTwoLevelImpl.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » cache » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.broker.cache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl

ObjectCacheTwoLevelImpl
public class ObjectCacheTwoLevelImpl implements ObjectCacheInternal,PBStateListener(Code)
A two-level ObjectCache implementation with a session- and an application cache. The application cache could be specified by the property applicationCache.

The first level is a transactional session cache which cache objects till org.apache.ojb.broker.PersistenceBroker.close or if a PB-tx is running till org.apache.ojb.broker.PersistenceBroker.abortTransaction or org.apache.ojb.broker.PersistenceBroker.commitTransaction . On commit all objects written to database will be pushed to the application cache.

The session cache act as a temporary storage for all read/store operations of persistent objects and only on commit or close of the used PB instance the buffered objects of type ObjectCacheTwoLevelImpl.TYPE_WRITE will be written to the application cache. Except objects of type ObjectCacheTwoLevelImpl.TYPE_NEW_MATERIALIZED these objects will be immediatly pushed to application cache.

The application cache

Property Key Property Values
applicationCache Specifies the ObjectCache implementation used as application cache (second level cache). By default ObjectCacheDefaultImpl was used. It's recommended to use a shared cache implementation (all used PB instances should access the same pool of objects - e.g. by using a static Map in cache implementation).
copyStrategy Specifies the implementation class of the ObjectCacheTwoLevelImpl.CopyStrategy interface, which was used to copy objects on read and write to application cache. If not specified a default implementation based was used ( ObjectCacheTwoLevelImpl.CopyStrategyImpl make field-descriptor based copies of the cached objects).
forceProxies If true on materialization of cached objects, all referenced objects will be represented by proxy objects (independent from the proxy settings in reference- or collection-descriptor).
Note: To use this feature all persistence capable objects have to be interface based or the ProxyFactory and IndirectionHandler implementation classes supporting dynamic proxy enhancement for all classes (see OJB.properties file).


version:
   $Id: ObjectCacheTwoLevelImpl.java,v 1.1.2.16 2005/12/21 22:24:15 tomdz Exp $


Inner Class :final static class CacheEntry extends SoftReference implements Serializable
Inner Class :public interface CopyStrategy
Inner Class :public static class CopyStrategyImpl implements CopyStrategy

Field Summary
final public static  StringAPPLICATION_CACHE_PROP
    
final public static  StringCOPY_STRATEGY_PROP
    
final public static  StringFORCE_PROXIES
    

Constructor Summary
public  ObjectCacheTwoLevelImpl(PersistenceBroker broker, Properties prop)
    

Method Summary
public  voidafterBegin(PBStateEvent event)
    
public  voidafterCommit(PBStateEvent event)
     After committing the transaction push the object from session cache ( 1st level cache) to the application cache (2d level cache).
public  voidafterOpen(PBStateEvent event)
    
public  voidafterRollback(PBStateEvent event)
    
public  voidbeforeBegin(PBStateEvent event)
    
public  voidbeforeClose(PBStateEvent event)
    
public  voidbeforeCommit(PBStateEvent event)
    
public  voidbeforeRollback(PBStateEvent event)
    
public  voidcache(Identity oid, Object obj)
     Put the specified object to session cache.
public  booleancacheIfNew(Identity oid, Object obj)
    
public  voidclear()
     Clear session cache and application cache.
public  voiddoInternalCache(Identity oid, Object obj, int type)
     Cache the given object.
public  ObjectCacheInternalgetApplicationCache()
     Returns the application cache that this 2-level cache uses.
public  PersistenceBrokerImplgetBroker()
     Returns the org.apache.ojb.broker.PersistenceBroker instance associated with this cache instance.
public  Objectlookup(Identity oid)
     Lookup corresponding object from session cache or if not found from the underlying real ObjectCache - Return null if no object was found.
public  voidmaterializeFullObject(Object target)
     This cache implementation cache only "flat" objects (persistent objects without any references), so when ObjectCacheTwoLevelImpl.lookup(org.apache.ojb.broker.Identity) a cache object it needs full materialization (assign all referenced objects) before the cache returns the object.
public  voidremove(Identity oid)
     Remove the corresponding object from session AND application cache.
public  voidresetSessionCache()
     Discard all session cached objects and reset the state of this class for further usage.

Field Detail
APPLICATION_CACHE_PROP
final public static String APPLICATION_CACHE_PROP(Code)



COPY_STRATEGY_PROP
final public static String COPY_STRATEGY_PROP(Code)



FORCE_PROXIES
final public static String FORCE_PROXIES(Code)




Constructor Detail
ObjectCacheTwoLevelImpl
public ObjectCacheTwoLevelImpl(PersistenceBroker broker, Properties prop)(Code)




Method Detail
afterBegin
public void afterBegin(PBStateEvent event)(Code)



afterCommit
public void afterCommit(PBStateEvent event)(Code)
After committing the transaction push the object from session cache ( 1st level cache) to the application cache (2d level cache). Finally, clear the session cache.



afterOpen
public void afterOpen(PBStateEvent event)(Code)



afterRollback
public void afterRollback(PBStateEvent event)(Code)



beforeBegin
public void beforeBegin(PBStateEvent event)(Code)



beforeClose
public void beforeClose(PBStateEvent event)(Code)
Before closing the PersistenceBroker ensure that the session cache is cleared



beforeCommit
public void beforeCommit(PBStateEvent event)(Code)



beforeRollback
public void beforeRollback(PBStateEvent event)(Code)
Before rollbacking clear the session cache (first level cache)



cache
public void cache(Identity oid, Object obj)(Code)
Put the specified object to session cache.



cacheIfNew
public boolean cacheIfNew(Identity oid, Object obj)(Code)



clear
public void clear()(Code)
Clear session cache and application cache.



doInternalCache
public void doInternalCache(Identity oid, Object obj, int type)(Code)
Cache the given object. Creates a org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl.CacheEntry and put it to session cache. If the specified object to cache is of type ObjectCacheTwoLevelImpl.TYPE_NEW_MATERIALIZED it will be immediately pushed to the application cache.



getApplicationCache
public ObjectCacheInternal getApplicationCache()(Code)
Returns the application cache that this 2-level cache uses. The application cache



getBroker
public PersistenceBrokerImpl getBroker()(Code)
Returns the org.apache.ojb.broker.PersistenceBroker instance associated with this cache instance.



lookup
public Object lookup(Identity oid)(Code)
Lookup corresponding object from session cache or if not found from the underlying real ObjectCache - Return null if no object was found.



materializeFullObject
public void materializeFullObject(Object target)(Code)
This cache implementation cache only "flat" objects (persistent objects without any references), so when ObjectCacheTwoLevelImpl.lookup(org.apache.ojb.broker.Identity) a cache object it needs full materialization (assign all referenced objects) before the cache returns the object. The materialization of the referenced objects based on the auto-XXX settings specified in the metadata mapping.
Override this method if needed in conjunction with a user-defined org.apache.ojb.broker.cache.ObjectCacheTwoLevelImpl.CopyStrategy .
Parameters:
  target - The "flat" object for full materialization



remove
public void remove(Identity oid)(Code)
Remove the corresponding object from session AND application cache.



resetSessionCache
public void resetSessionCache()(Code)
Discard all session cached objects and reset the state of this class for further usage.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.