Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.tapestry.bean
Class BeanProvider  view BeanProvider download BeanProvider.java

java.lang.Object
  extended byorg.apache.tapestry.bean.BeanProvider
All Implemented Interfaces:
java.util.EventListener, org.apache.tapestry.IBeanProvider, org.apache.tapestry.event.PageDetachListener, org.apache.tapestry.event.PageRenderListener

public class BeanProvider
extends java.lang.Object
implements org.apache.tapestry.IBeanProvider, org.apache.tapestry.event.PageDetachListener, org.apache.tapestry.event.PageRenderListener

Basic implementation of the org.apache.tapestry.IBeanProvider interface.

Since:
1.0.4

Field Summary
static com.cortexeb.tools.clover.d __CLOVER_42_0
           
private  java.util.Set _beanNames
          Set of bean names provided by this provider.
private  java.util.Map _beans
          Map of beans, keyed on name.
private  org.apache.tapestry.IComponent _component
          The component for which beans are being created and tracked.
private  boolean _registeredForDetach
          Indicates whether this instance has been registered with its page as a PageDetachListener.
private  boolean _registeredForRender
          Indicates whether this instance has been registered as a render listener with the page.
private  org.apache.hivemind.ClassResolver _resolver
          Used for instantiating classes.
private static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
BeanProvider(org.apache.tapestry.IComponent component)
           
 
Method Summary
 boolean canProvideBean(java.lang.String name)
          Returns true if the provider can provide the named bean.
 java.lang.Object getBean(java.lang.String name)
          Returns the JavaBean with the specified name.
 java.util.Collection getBeanNames()
          Returns a collection of the names of any beans which may be provided.
 org.apache.hivemind.ClassResolver getClassResolver()
          Returns a resource resolver.
 org.apache.tapestry.IComponent getComponent()
          Returns the org.apache.tapestry.IComponent (which may be a org.apache.tapestry.IPage) for which this bean provider is providing beans.
private  java.lang.Object instantiateBean(java.lang.String beanName, org.apache.tapestry.spec.IBeanSpecification spec)
           
 void pageBeginRender(org.apache.tapestry.event.PageEvent event)
          Invoked before just before the page renders a response.
 void pageDetached(org.apache.tapestry.event.PageEvent event)
          Removes all beans with the REQUEST lifecycle.
 void pageEndRender(org.apache.tapestry.event.PageEvent event)
          Invoked after a successful render of the page.
private  void removeBeans(org.apache.tapestry.spec.BeanLifecycle lifecycle)
          Removes any beans with the specified lifecycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__CLOVER_42_0

public static com.cortexeb.tools.clover.d __CLOVER_42_0

LOG

private static final org.apache.commons.logging.Log LOG

_registeredForDetach

private boolean _registeredForDetach
Indicates whether this instance has been registered with its page as a PageDetachListener. Registration only occurs the first time a bean with lifecycle REQUEST is instantiated.


_registeredForRender

private boolean _registeredForRender
Indicates whether this instance has been registered as a render listener with the page.


_component

private org.apache.tapestry.IComponent _component
The component for which beans are being created and tracked.


_resolver

private org.apache.hivemind.ClassResolver _resolver
Used for instantiating classes.


_beans

private java.util.Map _beans
Map of beans, keyed on name.


_beanNames

private java.util.Set _beanNames
Set of bean names provided by this provider.

Since:
2.2
Constructor Detail

BeanProvider

public BeanProvider(org.apache.tapestry.IComponent component)
Method Detail

getBeanNames

public java.util.Collection getBeanNames()
Description copied from interface: org.apache.tapestry.IBeanProvider
Returns a collection of the names of any beans which may be provided.

Specified by:
getBeanNames in interface org.apache.tapestry.IBeanProvider
Since:
1.0.6

getComponent

public org.apache.tapestry.IComponent getComponent()
Description copied from interface: org.apache.tapestry.IBeanProvider
Returns the org.apache.tapestry.IComponent (which may be a org.apache.tapestry.IPage) for which this bean provider is providing beans.

Specified by:
getComponent in interface org.apache.tapestry.IBeanProvider
Since:
1.0.5

getBean

public java.lang.Object getBean(java.lang.String name)
Description copied from interface: org.apache.tapestry.IBeanProvider
Returns the JavaBean with the specified name. The bean is created as needed.

Specified by:
getBean in interface org.apache.tapestry.IBeanProvider

instantiateBean

private java.lang.Object instantiateBean(java.lang.String beanName,
                                         org.apache.tapestry.spec.IBeanSpecification spec)

pageDetached

public void pageDetached(org.apache.tapestry.event.PageEvent event)
Removes all beans with the REQUEST lifecycle. Beans with the PAGE lifecycle stick around, and beans with no lifecycle were never stored in the first place.

Specified by:
pageDetached in interface org.apache.tapestry.event.PageDetachListener

removeBeans

private void removeBeans(org.apache.tapestry.spec.BeanLifecycle lifecycle)
Removes any beans with the specified lifecycle.

Since:
2.2

getClassResolver

public org.apache.hivemind.ClassResolver getClassResolver()
Description copied from interface: org.apache.tapestry.IBeanProvider
Returns a resource resolver.

Specified by:
getClassResolver in interface org.apache.tapestry.IBeanProvider
Since:
1.0.8

pageBeginRender

public void pageBeginRender(org.apache.tapestry.event.PageEvent event)
Description copied from interface: org.apache.tapestry.event.PageRenderListener
Invoked before just before the page renders a response. This provides listeners with a last chance to initialize themselves for the render. This initialization can include modifying peristent page properties.

Specified by:
pageBeginRender in interface org.apache.tapestry.event.PageRenderListener
Since:
2.2

pageEndRender

public void pageEndRender(org.apache.tapestry.event.PageEvent event)
Description copied from interface: org.apache.tapestry.event.PageRenderListener
Invoked after a successful render of the page. Allows objects to release any resources they needed during the the render.

Specified by:
pageEndRender in interface org.apache.tapestry.event.PageRenderListener
Since:
2.2

canProvideBean

public boolean canProvideBean(java.lang.String name)
Description copied from interface: org.apache.tapestry.IBeanProvider
Returns true if the provider can provide the named bean.

Specified by:
canProvideBean in interface org.apache.tapestry.IBeanProvider
Since:
2.2