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


org.apache.derby.iapi.services.daemon.Serviceable

All known Subclasses:   org.apache.derby.impl.store.raw.log.LogToFile,  org.apache.derby.impl.store.raw.data.ReclaimSpace,  org.apache.derbyTesting.unitTests.services.T_Serviceable,  org.apache.derby.impl.store.access.btree.BTreePostCommit,  org.apache.derby.impl.store.access.heap.HeapPostCommit,  org.apache.derby.impl.services.cache.Clock,
Serviceable
public interface Serviceable (Code)
To use a DaemonService, one implements the Serviceable interface. Only one DaemonService will call this at any given time. However, if this Serviceable object subscribes to or enqueues to the DeamonService multiple times, then multiple DaemonService threads may call this Serviceable object at the same time. The Serviceable object must decide what synchronization it needs to provide depending on what work it needs to do. The Serviceable interface does not provide a way to pass a work object to identify what work needs to be done, it is assumed that the Serviceable object knows that. If a Serviceable object has different work for the DaemonService to do, it must somehow encapsulate or identify the different work by an intermediary object which implements the Serviceable interface and which can an identify the different work and pass it along to the object that can deal with them.


Field Summary
public static  intDONE
    
public static  intREQUEUE
    


Method Summary
public  intperformWork(ContextManager context)
     Do whatever it is that you want the daemon to do for you.
public  booleanserviceASAP()
     If this work should be done as soon as possible, then return true.
public  booleanserviceImmediately()
     If this work should be done immediately on the user thread then return true.

Field Detail
DONE
public static int DONE(Code)
return status for performWork - only meaningful for enqueued client



REQUEUE
public static int REQUEUE(Code)





Method Detail
performWork
public int performWork(ContextManager context) throws StandardException(Code)
Do whatever it is that you want the daemon to do for you. There may be multiple daemon objects on different thread calling performWork at the same time. The DaemonService will always call performWork with a context manager set up. the DaemonService will clean up the context if an exception is thrown. However, it is up to performWork to manage its own transaction. If you start a transaction in performWork, you must commit or abort it at the end. You may leave the transaction open so that other serviceable may use the transaction and context without starting a new one. On the same token, there may already be an opened transaction on the context. Serviceable performWork should always check the state of the context before use. A Serviceable object should be well behaved while it is performing the daemon work, i.e., it should not take too many resources or hog the CPU for too long or deadlock with anyone else.
Parameters:
  context - the contextManager set up by the DaemonService. Theremay or may not be the necessary context on it, depending on which otherServiceable object it has done work for. the return status is only significant if the Serviceable clientwas enqueued instead of subscribed. For subscribed client, the returnstatus is ignored. For enqueue client, it returns DONE or REQUEUE. Ifa REQUEUEd is returned, it would be desirable if this should not beserviceASAP, although no harm is done if this still maintains that thisshould be serviced ASAP ...
exception:
  StandardException - Standard cloudscape exception policy

MT - depends on the work. Be wary of multiple DaemonService threadcalling at the same time if you subscribe or enqueue multiple times.




serviceASAP
public boolean serviceASAP()(Code)
If this work should be done as soon as possible, then return true. If it doesn't make any difference if it is done sooner rather than later, then return false. The difference is whether or not the daemon service will be notified to work on this when this work is enqueued or subscribed, in case the serviceable work is put together but not sent to the daemon service directly, like in post commit processing

MT - MT safe




serviceImmediately
public boolean serviceImmediately()(Code)
If this work should be done immediately on the user thread then return true. If it doesn't make any difference if this work is done on a the user thread immediately or if it is performed by another thread asynchronously later, then return false.



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