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


org.apache.derby.iapi.services.context.Context

All known Subclasses:   org.apache.derby.iapi.services.context.ContextImpl,
Context
public interface Context (Code)
Contexts are created and used to manage the execution environment. They provide a convenient location for storing globals organized by the module using the globals.

A basic context implementation is provided as an abstract class; this implementation satisfies the interface and should in general be used as the supertype of all context types. Otherwise, context classes must satisfy the semantics of the interface through their own distinct implementations.

Contexts assist in cleanup when errors are caught in the outer block.

Use of context cleanup is preferred over using try/catch blocks throughout the code.

Use of context pushing and popping is preferred over using many instance or local variables, even when try/catch is present. when the instance or local variables would be holding resources.

Usually Context's have a reference based equality, ie. they do not provide an implementation of equals(). Contexts may implement a value based equality but this usually means there is only one instance of the Context on the stack, This is because the popContext(Context) will remove the most recently pushed Context that matches via the equals method, not by a reference check. Implementing equals is useful for Contexts used in notifyAllThreads() that is not aimed at a single thread.





Method Summary
public  voidcleanupOnError(Throwable error)
     Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action.
public  ContextManagergetContextManager()
     Returns the context manager that has stored this context in its stack.
public  StringgetIdName()
     Returns the current id name associated with this context.
public  booleanisLastHandler(int severity)
     Return whether or not this context is the "last" handler for a the specified severity level.
public  voidpopMe()
     Pop myself of the context stack.
public  voidpushMe()
     Push myself onto my context stack.



Method Detail
cleanupOnError
public void cleanupOnError(Throwable error) throws StandardException(Code)
Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action. They will be told what the error is, so that they can react appropriately. Most of the time, the contexts will react by either doing nothing or by removing themselves from the context manager. If there are no other references to the context, removing itself from the manager equates to freeing it.
On an exception that is session severity or greater the Context must push itself off the stack. This is to ensure that after a session has been closed there are no Contexts on the stack that potentially hold references to objects, thus delaying their garbage collection.

Contexts must release all their resources before removing themselves from their context manager.

The context manager will "unwind" the contexts during cleanup in the reverse order they were placed on its global stack.

If error is an instance of StandardException then an implementation of this method may throw a new exception if and only if the new exception is an instance of StandardException that is more severe than the original error or the new exception is a not an instance of StandardException (e.g java.lang.NullPointerException).
exception:
  StandardException - thrown if cleanup goes awry




getContextManager
public ContextManager getContextManager()(Code)
Returns the context manager that has stored this context in its stack.



getIdName
public String getIdName()(Code)
Returns the current id name associated with this context. Contexts are placed into stacks by id, in a context manager. Null if the context is not assigned to an id. Contexts known by context managers are always assigned to an id.

A default Id name should be defined in each specific context interface as a static final field with the name CONTEXT_ID. For example, see org.apache.derby.iapi.sql.compile.CompilerContext.CONTEXT_ID.
See Also:   org.apache.derby.iapi.sql.compile.CompilerContext




isLastHandler
public boolean isLastHandler(int severity)(Code)
Return whether or not this context is the "last" handler for a the specified severity level. Previously, the context manager would march through all of the contexts in cleanupOnError() and call each of their cleanupOnError() methods. That did not work with server side JDBC, especially for a StatementException, because outer contexts could get cleaned up incorrectly. This functionality is specific to the Language system. Any non-language system contexts should return ExceptionSeverity.NOT_APPLICABLE_SEVERITY. NOTE: Both the LanguageConnectionContext and the JDBC Connection Context are interested in session level errors because they both have clean up to do. This method allows both of them to return false so that all such handlers under them can do their clean up.



popMe
public void popMe()(Code)
Pop myself of the context stack.



pushMe
public void pushMe()(Code)
Push myself onto my context stack.



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