Java Doc for Lockable.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » services » locks » 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 DBMS » db derby 10.2 » org.apache.derby.iapi.services.locks 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.derby.iapi.services.locks.Lockable

All known Subclasses:   org.apache.derby.iapi.store.raw.ContainerKey,  org.apache.derby.impl.store.raw.data.BasePage,  org.apache.derby.impl.store.raw.data.BaseContainer,  org.apache.derbyTesting.unitTests.services.T_L2,  org.apache.derbyTesting.unitTests.services.T_L1,  org.apache.derby.iapi.services.locks.ShExLockable,
Lockable
public interface Lockable (Code)
Any object that needs to be locked must implement Lockable. This allows a generic lock manager that can have locking policies defined on a per-object basis. A request to lock the object takes a qualifier, this qualifier may be used the object to implement a complex locking policy, e.g. traditional database shared, update and exclusive locks.

The lock manager uses this ordered protocol to determine if a lock request on a Lockable L with qualifier Q1 in compatiblity space CS1 can be granted:

  1. If no locks are held on L in any compatability space then the request is granted.
  2. If L.requestCompatible(Q1) returns true then the lock is granted.
  3. Otherwise the request is granted if the following expression evaluates to true for every other lock { CSn, Qn} held on L
    •     ( ( CSn == CS1 ) && L.lockerAlwaysCompatible() ) 
    •  || (L.reqestCompatible(Q1, Qn)) 

If the request is granted then a call is made to L.lockEvent(CS1, Q1) .
When the lock is released a call is made to L.unlockEvent(CS1, Q1) .

The lock manager uses equals() and hashCode() to identify unique Lockables.
If the class implementing Lockable requires that each instance of class correspond to a different locked object then the equals() method must test equality via the reference equality test (==), this is the default behaviour for equality.
If the class implementing Lockable require that each instance of the class that has the same value (as defined by the class) corresponds to a locked object then its equals() method must reflect that, e.g. by testing equality of its fields. In this case the first Lockable to be locked will be kept by lock manager as the key for the lock. Thus even after the first caller unlocks the obejct, its reference will still be kept by the lock manager. Thus Lockable's that per value equality must be designed so that they are never re-used for different lockable concepts.
In either case the equals() method must accept a reference to an object of a different type.
As per standard hashtable rules the value returned by hashCode() must be in sync with the equals() method.
MT - Mutable - : single thread required, synchronization is provided by the lock manager. If the class implementing Lockable uses value equality then it must have an immutable identity.





Method Summary
public  booleanlockAttributes(int flag, Hashtable attributes)
     If this lockable object wants to participate in a diagnostic virtual lock table, then put any relavent attributes of this lock into the attributes list (the attribute must be an immutable object).
public  voidlockEvent(Latch lockInfo)
     Note the fact the object is locked.
public  booleanlockerAlwaysCompatible()
     Returns true if any lock request on a Lockable L in a compatibility space CS1 is compatible with any other lock held on L in CS1.
public  booleanrequestCompatible(Object requestedQualifier, Object grantedQualifier)
     Return true if the requested qualifier is compatible with the already granted qualifier.
public  voidunlockEvent(Latch lockInfo)
     Note that the object has been unlocked

Must only be called by the lock manager.




Method Detail
lockAttributes
public boolean lockAttributes(int flag, Hashtable attributes)(Code)
If this lockable object wants to participate in a diagnostic virtual lock table, then put any relavent attributes of this lock into the attributes list (the attribute must be an immutable object). The list of attributes of interest to the virtual lock table can be found in VirtualLockTable. The toString method will be called by the VirtualTable on the attribute value for display.


Parameters:
  flag - use the bits in this int to decide if the user isinterested in this kind of lockable object. The bits are defined inVirtualLockTable. For instance, the user may only askfor TABLE_AND_ROWLOCK and if this is not a table or row lock, thendon't paritipate.
Parameters:
  attributes - if this decides to participate, put all relaventattributes into the Hashtable. The complete list of interestingattributes is listed in VirtualLockTable.The following attributes must be present for all participatinglockables:VirtualLockTable.LOCKNAME,VirtualLockTable.LOCKTYPE,either VirtualLockTable.CONTAINERID or VirtualLockTable.CONGLOMID,

MT - this routine must be MP safe, caller will not be single threadingthe lock manager.

true if this object has diagnostic information to add to thevirtual lock table. If this object either does not want to participatein the diagnostic virtual lock table or none of the attributesrequested are attributes of this lock, returns false.
See Also:   VirtualLockTable




lockEvent
public void lockEvent(Latch lockInfo)(Code)
Note the fact the object is locked. Performs required actions to ensure that unlockEvent() work correctly. This method does not actually perform any locking of the object, the locking mechanism is provided by the lock manager.

If the class supports multiple lockers of the object then this method will be called once per locker, each with their own qualifier.

Must only be called by the lock manager. Synchronization will be handled by the lock manager.




lockerAlwaysCompatible
public boolean lockerAlwaysCompatible()(Code)
Returns true if any lock request on a Lockable L in a compatibility space CS1 is compatible with any other lock held on L in CS1.



requestCompatible
public boolean requestCompatible(Object requestedQualifier, Object grantedQualifier)(Code)
Return true if the requested qualifier is compatible with the already granted qualifier.



unlockEvent
public void unlockEvent(Latch lockInfo)(Code)
Note that the object has been unlocked

Must only be called by the lock manager. Synchronization will be handled by the lock manager.




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