Java Doc for ResourceContext.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » controls » api » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.controls.api.context 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.beehive.controls.api.context.ResourceContext

All known Subclasses:   org.apache.beehive.controls.runtime.bean.ResourceContextImpl,
ResourceContext
public interface ResourceContext (Code)
The ResourceContext interface defines a basic contextual service for coordinating the resource utilization of a control implementation within a resource scope defined external to the control. This contextual service that provides assistance to a Control in managing any external resources (connections, sesssions, etc) that may be relatively expensive to obtain and/or can only be held for a relatively short duration.

A ResourceContext implementation may be provided by an external container of Controls, such as a servlet engine or EJB container, that coordinates the resource lifecycle of controls with the activities of the external container. For example, the resource scope for a ResourceContext provider associated with the web tier might enable control resources to be used for the duration of a single http request; for the EJB tier it might mean for the lifetime of the current EJB invocation or active transaction.

A control implementation participates in this resource management contract by declaring a ResourceContext instance annotated with the @Context annotation, the standard service provider model of the Control runtime will associate the control instance with a ResourceControl provider implementation that is associated with the current execution context. This is demonstrated by the following code excerpt from a ControlImplementation class:


 @org.apache.beehive.controls.api.bean.ControlImplementation
 public class MyControlImpl
 {
 ...
 // Declare need for resource mgmt support via the ResourceContext service
 @org.apache.beehive.controls.api.context.Context
 ResourceContext resourceContext;
 ...
 

Once the control has been associated with a ResourceContext provider, the provider will deliver events to the Control Implementation instance according to the following basic contract:

  • the ResourceContext provider notifies a control implementation when it should acquire its resources using the onAcquire event.
  • the ResourceContext provider notifies a control implementation when it should release its resources using the onRelease event.

The following code fragment shows how to receive resource events from within a Control implementation:


 import org.apache.beehive.controls.api.events.EventHandler;
 ...
 @EventHandler(field="resourceContext",
 eventSet=ResourceContext.ResourceEvents.class,
 eventName="onAcquire")
 public void onAcquire() 
 { 
 // code to obtain connections/sessions/...
 }
 @EventHandler(field="resourceContext", 
 eventSet=ResourceContext.ResourceEvents.class,
 eventName="onRelease")
 public void onRelease() 
 { 
 // code to release connections/sessions/...
 }
 

The onAcquire resource event is guaranteed to be delivered once before any operation declared on a public or extension interface associated with the control. This event will be delivered once, and only once, within a particular resource scope associated with the ResourceContext. If a control needs to utilize its resources in another context (such as in response to a PropertyChange notification), the ResourceContext also provides support for manually acquiring and releasing resources.
See Also:   org.apache.beehive.controls.api.context.ResourceContext.ResourceEvents
See Also:   org.apache.beehive.controls.api.context.Context
See Also:   org.apache.beehive.controls.api.events.EventHandler


Inner Class :public interface ResourceEvents



Method Summary
public  voidacquire()
     The acquire method allows a Control implementation to manually request acquisition. This is useful in contexts where the control needs access to associated resources from outside the scope of an operation.
public  voidaddResourceEventsListener(ResourceEvents resourceListener)
     Registers a listener that implements the ResourceEvents interface for the ResourceContext.
public  booleanhasResources()
     The hasResources method returns true if the control has currently acquired resources, false otherwise.
public  voidrelease()
     The release method allows a Control implement to manually release resources immediately, instead of waiting until the end of the current resource scope.
public  voidremoveResourceEventsListener(ResourceEvents resourceListener)
     Unregisters a listener that implements the ResourceEvents interface for the ResourceContext.



Method Detail
acquire
public void acquire()(Code)
The acquire method allows a Control implementation to manually request acquisition. This is useful in contexts where the control needs access to associated resources from outside the scope of an operation. If invoked when the control has not currently acquired resources, the onAcquire event will be delivered to the control and it will be registered in the current resource scope as holding resources. If the control has previously acquired resources in the current resource scope, then calling acquire() will have no effect.



addResourceEventsListener
public void addResourceEventsListener(ResourceEvents resourceListener)(Code)
Registers a listener that implements the ResourceEvents interface for the ResourceContext.



hasResources
public boolean hasResources()(Code)
The hasResources method returns true if the control has currently acquired resources, false otherwise.



release
public void release()(Code)
The release method allows a Control implement to manually release resources immediately, instead of waiting until the end of the current resource scope. If invoked when the control has currently acquired resources, the onRelease event will be delivered immediately and the control will no longer be in the list of controls holding resources in the current resource scope. If the control has not previously acquired resources, then calling release() will have no effect.



removeResourceEventsListener
public void removeResourceEventsListener(ResourceEvents resourceListener)(Code)
Unregisters a listener that implements the ResourceEvents interface for the ResourceContext.



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