|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CustomBeanContextServicesSupport.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* EJTools, the Enterprise Java Tools
|
|
| 3 |
*
|
|
| 4 |
* Distributable under LGPL license.
|
|
| 5 |
* See terms of license at www.gnu.org.
|
|
| 6 |
*/
|
|
| 7 |
package org.ejtools.beans.beancontext;
|
|
| 8 |
|
|
| 9 |
import java.beans.beancontext.BeanContext;
|
|
| 10 |
import java.beans.beancontext.BeanContextChild;
|
|
| 11 |
import java.beans.beancontext.BeanContextServiceRevokedListener;
|
|
| 12 |
import java.beans.beancontext.BeanContextServices;
|
|
| 13 |
import java.beans.beancontext.BeanContextServicesSupport;
|
|
| 14 |
import java.util.Iterator;
|
|
| 15 |
import java.util.TooManyListenersException;
|
|
| 16 |
|
|
| 17 |
import org.ejtools.util.state.Storable;
|
|
| 18 |
import org.ejtools.util.state.StoreVisitor;
|
|
| 19 |
|
|
| 20 |
/**
|
|
| 21 |
* Enhancement of the {@link BeanContextServicesSupport} to provide an implementation
|
|
| 22 |
* for the <code>clear</code> method, and a recursive search for a particular service.
|
|
| 23 |
*
|
|
| 24 |
* @author Laurent Etiemble
|
|
| 25 |
* @version $Revision: 1.9 $
|
|
| 26 |
*/
|
|
| 27 |
public abstract class CustomBeanContextServicesSupport extends BeanContextServicesSupport implements Storable |
|
| 28 |
{
|
|
| 29 |
/**
|
|
| 30 |
* Description of the Method
|
|
| 31 |
*
|
|
| 32 |
* @param visitor Description of the Parameter
|
|
| 33 |
*/
|
|
| 34 | 0 |
public void accept(StoreVisitor visitor) |
| 35 |
{
|
|
| 36 | 0 |
visitor.persist(this);
|
| 37 |
} |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
/** Implementation of the <code>clear</code> method */
|
|
| 41 | 0 |
public void clear() |
| 42 |
{
|
|
| 43 | 0 |
Iterator iterator; |
| 44 |
|
|
| 45 |
// Recursively clear the content
|
|
| 46 | 0 |
iterator = this.iterator();
|
| 47 | 0 |
while (iterator.hasNext())
|
| 48 |
{
|
|
| 49 | 0 |
Object o = iterator.next(); |
| 50 | 0 |
if (o instanceof BeanContext) |
| 51 |
{
|
|
| 52 | 0 |
((BeanContext) o).clear(); |
| 53 |
} |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
// Remove all elements
|
|
| 57 | 0 |
iterator = this.iterator();
|
| 58 | 0 |
while (iterator.hasNext())
|
| 59 |
{
|
|
| 60 | 0 |
iterator.next(); |
| 61 | 0 |
iterator.remove(); |
| 62 |
} |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
|
|
| 66 |
/**
|
|
| 67 |
* Gets the BeanContext service recursivly if necessary.
|
|
| 68 |
*
|
|
| 69 |
* @param child Description of Parameter
|
|
| 70 |
* @param requestor Description of Parameter
|
|
| 71 |
* @param serviceClass Description of Parameter
|
|
| 72 |
* @param serviceSelector Description of Parameter
|
|
| 73 |
* @param bcsrl Description of Parameter
|
|
| 74 |
* @return The value
|
|
| 75 |
* @exception TooManyListenersException Description of Exception
|
|
| 76 |
* Object,BeanContextServiceRevokedListener)
|
|
| 77 |
*/
|
|
| 78 | 0 |
public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
|
| 79 |
throws TooManyListenersException
|
|
| 80 |
{
|
|
| 81 | 0 |
Object service = super.getService(child, requestor, serviceClass, serviceSelector, bcsrl);
|
| 82 |
|
|
| 83 |
// If the service requested is not provided by this BeanContext, try the parent
|
|
| 84 | 0 |
if (service == null) |
| 85 |
{
|
|
| 86 | 0 |
BeanContextServices bcs = null;
|
| 87 |
|
|
| 88 | 0 |
try
|
| 89 |
{
|
|
| 90 | 0 |
bcs = (BeanContextServices) this.getBeanContext();
|
| 91 |
} |
|
| 92 |
catch (ClassCastException cce)
|
|
| 93 |
{
|
|
| 94 | 0 |
return null; |
| 95 |
} |
|
| 96 |
|
|
| 97 | 0 |
return bcs.getService(this, requestor, serviceClass, serviceSelector, bcsrl); |
| 98 |
} |
|
| 99 |
|
|
| 100 | 0 |
return service;
|
| 101 |
} |
|
| 102 |
} |
|
| 103 |
|
|
||||||||||