Java Doc for Pooled.java in  » Inversion-of-Control » PicoContainer » org » picocontainer » gems » behaviors » 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 » Inversion of Control » PicoContainer » org.picocontainer.gems.behaviors 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.picocontainer.behaviors.AbstractBehavior
      org.picocontainer.gems.behaviors.Pooled

Pooled
final public class Pooled extends AbstractBehavior implements Behavior(Code)
ComponentAdapter implementation that pools components.

The implementation utilizes a delegated ComponentAdapter to create the instances of the pool. The pool can be configured to grow unlimited or to a maximum size. If a component is requested from this adapter, the implementation returns an availailabe instance from the pool or will create a new one, if the maximum pool size is not reached yet. If none is available, the implementation can wait a defined time for a returned object before it throws a PoolException .

This implementation uses the Pool toy from the ProxyToys project. This ensures, that any component, that is out of scope will be automatically returned to the pool by the garbage collector. Additionally will every component instance also implement com.thoughtworks.proxy.toys.pool.Poolable , that can be used to return the instance manually. After returning an instance it should not be used in client code anymore.

Before a returning object is added to the available instances of the pool again, it should be reinitialized to a normalized state. By providing a proper Resetter implementation this can be done automatically. If the object cannot be reused anymore it can also be dropped and the pool may request a new instance.

The pool supports components with a lifecycle. If the delegated ComponentAdapter implements a LifecycleStrategy , any component retrieved form the pool will be started before and stopped again, when it returns back into the pool. Also if a component cannot be resetted it will automatically be disposed. If the container of the pool is disposed, that any returning object is also disposed and will not return to the pool anymore. Note, that current implementation cannot dispose pooled objects.


author:
   Jörg Schaible
author:
   Aslak Hellesøy

Inner Class :public static interface Context
Inner Class :public static class DefaultContext implements Context
Inner Class :final static class LifecycleResetter implements Resetter,Serializable
Inner Class :public static class PoolException extends PicoCompositionException

Field Summary
final public static  intBLOCK_ON_WAIT
     BLOCK_ON_WAIT forces the pool to wait until an object of the pool is returning in case none is immediately available.
final public static  intDEFAULT_MAX_SIZE
     DEFAULT_MAX_SIZE is the default size of the pool.
final public static  ResetterDEFAULT_RESETTER
     DEFAULT_RESETTER is a NoOperationResetter that is used by default.
final public static  intFAIL_ON_WAIT
     FAIL_ON_WAIT forces the pool to fail none is immediately available.
final public static  intUNLIMITED_SIZE
     UNLIMITED_SIZE is the value to set the maximum size of the pool to unlimited ( Integer.MAX_VALUE in fact).

Constructor Summary
public  Pooled(ComponentAdapter delegate, Context context)
     Construct a Pooled.
protected  Pooled()
     Construct an empty ComponentAdapter, used for serialization with reflection only.

Method Summary
public  voiddispose(PicoContainer container)
     Dispose of the container will dispose all returning objects.
public  ObjectgetComponentInstance(PicoContainer container)
    

As long as the maximum size of the pool is not reached and the pool is exhausted, the implementation will request its delegate for a new instance, that will be managed by the pool.

public  StringgetDescriptor()
    
public  intsize()
     Retrieve the current size of the pool.
public  voidstart(PicoContainer container)
     Start of the container ensures that at least one pooled component has been started.
public  voidstop(PicoContainer container)
     Stop of the container has no effect for the pool.

Field Detail
BLOCK_ON_WAIT
final public static int BLOCK_ON_WAIT(Code)
BLOCK_ON_WAIT forces the pool to wait until an object of the pool is returning in case none is immediately available.



DEFAULT_MAX_SIZE
final public static int DEFAULT_MAX_SIZE(Code)
DEFAULT_MAX_SIZE is the default size of the pool.



DEFAULT_RESETTER
final public static Resetter DEFAULT_RESETTER(Code)
DEFAULT_RESETTER is a NoOperationResetter that is used by default.



FAIL_ON_WAIT
final public static int FAIL_ON_WAIT(Code)
FAIL_ON_WAIT forces the pool to fail none is immediately available.



UNLIMITED_SIZE
final public static int UNLIMITED_SIZE(Code)
UNLIMITED_SIZE is the value to set the maximum size of the pool to unlimited ( Integer.MAX_VALUE in fact).




Constructor Detail
Pooled
public Pooled(ComponentAdapter delegate, Context context)(Code)
Construct a Pooled. Remember, that the implementation will request new components from the delegate as long as no component instance is available in the pool and the maximum pool size is not reached. Therefore the delegate may not return the same component instance twice. Ensure, that the used ComponentAdapter does not cache.
Parameters:
  delegate - the delegated ComponentAdapter
Parameters:
  context - the Context of the pool
throws:
  IllegalArgumentException - if the maximum pool size or the serialization mode isinvalid



Pooled
protected Pooled()(Code)
Construct an empty ComponentAdapter, used for serialization with reflection only.




Method Detail
dispose
public void dispose(PicoContainer container)(Code)
Dispose of the container will dispose all returning objects. They will not be added to the pool anymore. Applies only if the delegated ComponentAdapter supports a lifecylce by implementing LifecycleStrategy .
throws:
  IllegalStateException - if pool was already disposed



getComponentInstance
public Object getComponentInstance(PicoContainer container)(Code)

As long as the maximum size of the pool is not reached and the pool is exhausted, the implementation will request its delegate for a new instance, that will be managed by the pool. Only if the maximum size of the pool is reached, the implementation may wait (depends on the initializing Context ) for a returning object.


throws:
  PoolException - if the pool is exhausted or waiting for a returning object timed out orwas interrupted



getDescriptor
public String getDescriptor()(Code)



size
public int size()(Code)
Retrieve the current size of the pool. The returned value reflects the number of all managed components. the number of components.



start
public void start(PicoContainer container)(Code)
Start of the container ensures that at least one pooled component has been started. Applies only if the delegated ComponentAdapter supports a lifecylce by implementing LifecycleStrategy .
throws:
  IllegalStateException - if pool was already disposed



stop
public void stop(PicoContainer container)(Code)
Stop of the container has no effect for the pool. Applies only if the delegated ComponentAdapter supports a lifecylce by implementing org.picocontainer.LifecycleStrategy .
throws:
  IllegalStateException - if pool was already disposed



Fields inherited from org.picocontainer.behaviors.AbstractBehavior
final protected ComponentAdapter<T> delegate(Code)(Java Doc)

Methods inherited from org.picocontainer.behaviors.AbstractBehavior
public void accept(PicoVisitor visitor)(Code)(Java Doc)
public void changeMonitor(ComponentMonitor monitor)(Code)(Java Doc)
public boolean componentHasLifecycle()(Code)(Java Doc)
public ComponentMonitor currentMonitor()(Code)(Java Doc)
public void dispose(PicoContainer container)(Code)(Java Doc)
public void dispose(Object component)(Code)(Java Doc)
final public U findAdapterOfType(Class<U> componentAdapterType)(Code)(Java Doc)
public Class<T> getComponentImplementation()(Code)(Java Doc)
public T getComponentInstance(PicoContainer container) throws PicoCompositionException(Code)(Java Doc)
public Object getComponentKey()(Code)(Java Doc)
final public ComponentAdapter<T> getDelegate()(Code)(Java Doc)
public boolean hasLifecycle(Class type)(Code)(Java Doc)
public void start(PicoContainer container)(Code)(Java Doc)
public void start(Object component)(Code)(Java Doc)
public void stop(PicoContainer container)(Code)(Java Doc)
public void stop(Object component)(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public void verify(PicoContainer container) throws PicoCompositionException(Code)(Java Doc)

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.