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


java.lang.Object
   org.apache.derby.impl.services.daemon.BasicDaemon

BasicDaemon
public class BasicDaemon implements DaemonService,Runnable(Code)
A BasicDaemon is a background worker thread which does asynchronous I/O and general clean up. It should not be used as a general worker thread for parallel execution. One cannot count on the order of request or count on when the daemon will wake up, even with serviceNow requests. Request are not persistent and not recoverable, they are all lost when the system crashes or is shutdown. System shutdown, even orderly ones, do not wait for daemons to finish its work or empty its queue. Furthermore, any Serviceable subscriptions, including onDemandOnly, must tolerate spurious services. The BasicDaemon will setup a context manager with no context on it. The Serviceable object's performWork must provide useful context on the context manager to do its work. The BasicDaemon will wrap performWork call with try / catch block and will use the ContextManager's error handling to clean up any error. The BasicDaemon will guarentee serviceNow request will not be lost as long as the jbms does not crash - however, if N serviceNow requests are made by the same client, it may only be serviced once, not N times. Many Serviceable object will subscribe to the same BasicDaemon. Their performWork method should be well behaved - in other words, it should not take too long or hog too many resources or deadlock with anyone else. And it cannot (should not) error out. The BasicDaemon implementation manages the DaemonService's data structure, handles subscriptions and enqueues requests, and determine the service schedule for its Serviceable objects. The BasicDaemon keeps an array (Vector) of Serviceable subscriptions it also keeps 2 queues for clients that uses it for one time service - the 1st queue is for a serviceNow enqueue request, the 2nd queue is for non serviceNow enqueue request. This BasicDaemon services its clients in the following order: 1. any subscribed client that have made a serviceNow request that has not been fulfilled 2. serviceable clients on the 1st queue 3. all subscribed clients that are not onDemandOnly 4. serviceable clients 2nd queue


Field Summary
final protected  ContextManagercontextMgr
    
final protected  ContextServicecontextService
    

Constructor Summary
public  BasicDaemon(ContextService contextService)
    

Method Summary
public synchronized  voidclear()
     Get rid of all queued up Serviceable tasks.
public  booleanenqueue(Serviceable newClient, boolean serviceNow)
    
protected  ServiceRecordnextAssignment(boolean urgent)
    
public  voidpause()
    
public  voidresume()
    
public  voidrun()
    
protected  voidserviceClient(ServiceRecord clientRecord)
    
public  voidserviceNow(int clientNumber)
    
public  voidstop()
     Finish what we are doing and at the next convenient moment, get rid of the thread and make the daemon object goes away if possible.
public  intsubscribe(Serviceable newClient, boolean onDemandOnly)
    
public  voidunsubscribe(int clientNumber)
     Removes a client from the list of subscribed clients.
public  voidwaitUntilQueueIsEmpty()
    
protected synchronized  voidwakeUp()
    

Field Detail
contextMgr
final protected ContextManager contextMgr(Code)



contextService
final protected ContextService contextService(Code)




Constructor Detail
BasicDaemon
public BasicDaemon(ContextService contextService)(Code)
make a BasicDaemon




Method Detail
clear
public synchronized void clear()(Code)
Get rid of all queued up Serviceable tasks.



enqueue
public boolean enqueue(Serviceable newClient, boolean serviceNow)(Code)



nextAssignment
protected ServiceRecord nextAssignment(boolean urgent)(Code)



pause
public void pause()(Code)



resume
public void resume()(Code)



run
public void run()(Code)



serviceClient
protected void serviceClient(ServiceRecord clientRecord)(Code)



serviceNow
public void serviceNow(int clientNumber)(Code)



stop
public void stop()(Code)
Finish what we are doing and at the next convenient moment, get rid of the thread and make the daemon object goes away if possible. remember we are calling from another thread



subscribe
public int subscribe(Serviceable newClient, boolean onDemandOnly)(Code)



unsubscribe
public void unsubscribe(int clientNumber)(Code)
Removes a client from the list of subscribed clients. The call does not wait for the daemon to finish the work it is currently performing. Therefore, the client must tolerate that its performWork() method could be invoked even after the call to unsubscribe() has returned (but not more than once).
Parameters:
  clientNumber - client identifier



waitUntilQueueIsEmpty
public void waitUntilQueueIsEmpty()(Code)



wakeUp
protected synchronized void wakeUp()(Code)



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.