[Ejtools-cvs] libraries/common/src/main/org/ejtools/beans/beancontext package.html,NONE,1.1 CustomBe
Brought to you by:
letiemble
Update of /cvsroot/ejtools/libraries/common/src/main/org/ejtools/beans/beancontext In directory sc8-pr-cvs1:/tmp/cvs-serv18971/common/src/main/org/ejtools/beans/beancontext Modified Files: CustomBeanContextServiceProvider.java CustomBeanContextServicesSupport.java Added Files: package.html Log Message: Add more javadocs. Add package.html files. --- NEW FILE: package.html --- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!-- EJTools, the Enterprise Java Tools Distributable under LGPL license. See terms of license at www.gnu.org. $Revision: 1.1 $ --> <html> <head/> <body> Provides classes that extends the JavaBeans BeanContext specifications. It includes recursive service discovery and template classes for commonly use functionnalities. </body> </html> Index: CustomBeanContextServiceProvider.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/beans/beancontext/CustomBeanContextServiceProvider.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CustomBeanContextServiceProvider.java 15 Sep 2003 22:23:45 -0000 1.9 --- CustomBeanContextServiceProvider.java 13 Dec 2003 21:27:49 -0000 1.10 *************** *** 1,60 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.beans.beancontext; ! ! import java.beans.beancontext.BeanContextServiceProvider; ! import java.beans.beancontext.BeanContextServices; ! ! import org.apache.log4j.Logger; ! ! /** ! * Super class that aggregates the Service support role, and the service provider role. ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public abstract class CustomBeanContextServiceProvider extends CustomBeanContextServicesSupport implements BeanContextServiceProvider ! { ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(CustomBeanContextServiceProvider.class); ! ! ! /** ! * Returns the Service classes provided. ! * ! * @return The array of service provided ! */ ! protected abstract Class[] getServiceClass(); ! ! ! /** Registers every service into the parent bean context */ ! protected void initializeBeanContextResources() ! { ! super.initializeBeanContextResources(); ! ! Class[] services = this.getServiceClass(); ! for (int i = 0; i < services.length; i++) ! { ! ((BeanContextServices) this.getBeanContext()).addService(services[i], this); ! logger.debug("Service " + services[i] + " added"); ! } ! } ! ! ! /** Registers every service into the parent bean context */ ! protected void releaseBeanContextResources() ! { ! Class[] services = this.getServiceClass(); ! for (int i = 0; i < services.length; i++) ! { ! ((BeanContextServices) this.getBeanContext()).revokeService(services[i], this, true); ! logger.debug("Service " + services[i] + " revoked"); ! } ! ! super.releaseBeanContextResources(); ! } ! } --- 1,60 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.beans.beancontext; ! ! import java.beans.beancontext.BeanContextServiceProvider; ! import java.beans.beancontext.BeanContextServices; ! ! import org.apache.log4j.Logger; ! ! /** ! * Super class that aggregates the Service support role, and the service provider role. ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public abstract class CustomBeanContextServiceProvider extends CustomBeanContextServicesSupport implements BeanContextServiceProvider ! { ! /** Description of the Field */ ! private static Logger logger = Logger.getLogger(CustomBeanContextServiceProvider.class); ! ! ! /** ! * Returns the Service classes provided. ! * ! * @return The array of service provided ! */ ! protected abstract Class[] getServiceClass(); ! ! ! /** Registers every service into the parent bean context */ ! protected void initializeBeanContextResources() ! { ! super.initializeBeanContextResources(); ! ! Class[] services = this.getServiceClass(); ! for (int i = 0; i < services.length; i++) ! { ! ((BeanContextServices) this.getBeanContext()).addService(services[i], this); ! logger.debug("Service " + services[i] + " added"); ! } ! } ! ! ! /** Registers every service into the parent bean context */ ! protected void releaseBeanContextResources() ! { ! Class[] services = this.getServiceClass(); ! for (int i = 0; i < services.length; i++) ! { ! ((BeanContextServices) this.getBeanContext()).revokeService(services[i], this, true); ! logger.debug("Service " + services[i] + " revoked"); ! } ! ! super.releaseBeanContextResources(); ! } ! } Index: CustomBeanContextServicesSupport.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/main/org/ejtools/beans/beancontext/CustomBeanContextServicesSupport.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CustomBeanContextServicesSupport.java 15 Sep 2003 22:23:45 -0000 1.8 --- CustomBeanContextServicesSupport.java 13 Dec 2003 21:27:49 -0000 1.9 *************** *** 1,102 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.beans.beancontext; ! ! import java.beans.beancontext.BeanContext; ! import java.beans.beancontext.BeanContextChild; ! import java.beans.beancontext.BeanContextServiceRevokedListener; ! import java.beans.beancontext.BeanContextServices; ! import java.beans.beancontext.BeanContextServicesSupport; ! import java.util.Iterator; ! import java.util.TooManyListenersException; ! ! import org.ejtools.util.state.Storable; ! import org.ejtools.util.state.StoreVisitor; ! ! /** ! * Enhancement of the {@link BeanContextServicesSupport} to provide an implementation ! * for the <code>clear</code> method, and a recursive search for a particular service. ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public abstract class CustomBeanContextServicesSupport extends BeanContextServicesSupport implements Storable ! { ! /** ! * Description of the Method ! * ! * @param visitor Description of the Parameter ! */ ! public void accept(StoreVisitor visitor) ! { ! visitor.persist(this); ! } ! ! ! /** Implementation of the <code>clear</code> method */ ! public void clear() ! { ! Iterator iterator; ! ! // Recursively clear the content ! iterator = this.iterator(); ! while (iterator.hasNext()) ! { ! Object o = iterator.next(); ! if (o instanceof BeanContext) ! { ! ((BeanContext) o).clear(); ! } ! } ! ! // Remove all elements ! iterator = this.iterator(); ! while (iterator.hasNext()) ! { ! iterator.next(); ! iterator.remove(); ! } ! } ! ! ! /** ! * Gets the BeanContext service recursivly if necessary. ! * ! * @param child Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @param bcsrl Description of Parameter ! * @return The value ! * @exception TooManyListenersException Description of Exception ! * Object,BeanContextServiceRevokedListener) ! */ ! public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) ! throws TooManyListenersException ! { ! Object service = super.getService(child, requestor, serviceClass, serviceSelector, bcsrl); ! ! // If the service requested is not provided by this BeanContext, try the parent ! if (service == null) ! { ! BeanContextServices bcs = null; ! ! try ! { ! bcs = (BeanContextServices) this.getBeanContext(); ! } ! catch (ClassCastException cce) ! { ! return null; ! } ! ! return bcs.getService(this, requestor, serviceClass, serviceSelector, bcsrl); ! } ! ! return service; ! } ! } --- 1,102 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.beans.beancontext; ! ! import java.beans.beancontext.BeanContext; ! import java.beans.beancontext.BeanContextChild; ! import java.beans.beancontext.BeanContextServiceRevokedListener; ! import java.beans.beancontext.BeanContextServices; ! import java.beans.beancontext.BeanContextServicesSupport; ! import java.util.Iterator; ! import java.util.TooManyListenersException; ! ! import org.ejtools.util.state.Storable; ! import org.ejtools.util.state.StoreVisitor; ! ! /** ! * Enhancement of the {@link BeanContextServicesSupport} to provide an implementation ! * for the <code>clear</code> method, and a recursive search for a particular service. ! * ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public abstract class CustomBeanContextServicesSupport extends BeanContextServicesSupport implements Storable ! { ! /** ! * Description of the Method ! * ! * @param visitor Description of the Parameter ! */ ! public void accept(StoreVisitor visitor) ! { ! visitor.persist(this); ! } ! ! ! /** Implementation of the <code>clear</code> method */ ! public void clear() ! { ! Iterator iterator; ! ! // Recursively clear the content ! iterator = this.iterator(); ! while (iterator.hasNext()) ! { ! Object o = iterator.next(); ! if (o instanceof BeanContext) ! { ! ((BeanContext) o).clear(); ! } ! } ! ! // Remove all elements ! iterator = this.iterator(); ! while (iterator.hasNext()) ! { ! iterator.next(); ! iterator.remove(); ! } ! } ! ! ! /** ! * Gets the BeanContext service recursivly if necessary. ! * ! * @param child Description of Parameter ! * @param requestor Description of Parameter ! * @param serviceClass Description of Parameter ! * @param serviceSelector Description of Parameter ! * @param bcsrl Description of Parameter ! * @return The value ! * @exception TooManyListenersException Description of Exception ! * Object,BeanContextServiceRevokedListener) ! */ ! public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) ! throws TooManyListenersException ! { ! Object service = super.getService(child, requestor, serviceClass, serviceSelector, bcsrl); ! ! // If the service requested is not provided by this BeanContext, try the parent ! if (service == null) ! { ! BeanContextServices bcs = null; ! ! try ! { ! bcs = (BeanContextServices) this.getBeanContext(); ! } ! catch (ClassCastException cce) ! { ! return null; ! } ! ! return bcs.getService(this, requestor, serviceClass, serviceSelector, bcsrl); ! } ! ! return service; ! } ! } |