KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > beans > beancontext > CustomBeanContextServiceProvider


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.BeanContextServiceProvider JavaDoc;
10 import java.beans.beancontext.BeanContextServices JavaDoc;
11
12 import org.apache.log4j.Logger;
13
14 /**
15  * Super class that aggregates the Service support role, and the service provider role.
16  *
17  * @author Laurent Etiemble
18  * @version $Revision: 1.10 $
19  */

20 public abstract class CustomBeanContextServiceProvider extends CustomBeanContextServicesSupport implements BeanContextServiceProvider JavaDoc
21 {
22    /** Description of the Field */
23    private static Logger logger = Logger.getLogger(CustomBeanContextServiceProvider.class);
24
25
26    /**
27     * Returns the Service classes provided.
28     *
29     * @return The array of service provided
30     */

31    protected abstract Class JavaDoc[] getServiceClass();
32
33
34    /** Registers every service into the parent bean context */
35    protected void initializeBeanContextResources()
36    {
37       super.initializeBeanContextResources();
38
39       Class JavaDoc[] services = this.getServiceClass();
40       for (int i = 0; i < services.length; i++)
41       {
42          ((BeanContextServices JavaDoc) this.getBeanContext()).addService(services[i], this);
43          logger.debug("Service " + services[i] + " added");
44       }
45    }
46
47
48    /** Registers every service into the parent bean context */
49    protected void releaseBeanContextResources()
50    {
51       Class JavaDoc[] services = this.getServiceClass();
52       for (int i = 0; i < services.length; i++)
53       {
54          ((BeanContextServices JavaDoc) this.getBeanContext()).revokeService(services[i], this, true);
55          logger.debug("Service " + services[i] + " revoked");
56       }
57
58       super.releaseBeanContextResources();
59    }
60 }
61
Popular Tags