KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > adl > AbstractDelagatingChecker


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.adl;
26
27 import org.objectweb.fractal.adl.ADLException;
28 import org.objectweb.fractal.api.NoSuchInterfaceException;
29 import org.objectweb.fractal.api.control.BindingController;
30 import org.objectweb.fractal.api.control.IllegalBindingException;
31 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
32
33 /**
34  * Abstract Checker component using delegation. The
35  * {@link Checker#check(Object, Object) check }method first call the client
36  * interface (if bound) then call the {@link #doChek(Object, Object) }method.
37  */

38 public abstract class AbstractDelagatingChecker
39     implements
40       Checker,
41       BindingController
42 {
43
44   /** The name of the optionnal client interface used for delegation */
45   public static final String JavaDoc CHECKER_OPT_ITF_NAME = "client-checker";
46
47   protected Checker optChekerItf;
48
49   /**
50    * @see org.objectweb.dream.adl.Checker#check(java.lang.Object,
51    * java.lang.Object)
52    */

53   public void check(Object JavaDoc legacyComponent, Object JavaDoc node) throws ADLException
54   {
55     if (optChekerItf != null)
56     {
57       optChekerItf.check(legacyComponent, node);
58     }
59     doChek(legacyComponent, node);
60   }
61
62   protected abstract void doChek(Object JavaDoc legacyComponent, Object JavaDoc node)
63       throws ADLException;
64
65   /**
66    * @see org.objectweb.fractal.api.control.BindingController#listFc()
67    */

68   public String JavaDoc[] listFc()
69   {
70     return new String JavaDoc[]{CHECKER_OPT_ITF_NAME};
71   }
72
73   /**
74    * @see org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
75    */

76   public Object JavaDoc lookupFc(String JavaDoc clientItfName) throws NoSuchInterfaceException
77   {
78     if (CHECKER_OPT_ITF_NAME.equals(clientItfName))
79     {
80       return optChekerItf;
81     }
82     return null;
83   }
84
85   /**
86    * @see org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
87    * java.lang.Object)
88    */

89   public void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
90       throws NoSuchInterfaceException, IllegalBindingException,
91       IllegalLifeCycleException
92   {
93     if (CHECKER_OPT_ITF_NAME.equals(clientItfName))
94     {
95       optChekerItf = (Checker) serverItf;
96     }
97   }
98
99   /**
100    * @see org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
101    */

102   public void unbindFc(String JavaDoc clientItfName) throws NoSuchInterfaceException,
103       IllegalBindingException, IllegalLifeCycleException
104   {
105     if (CHECKER_OPT_ITF_NAME.equals(clientItfName))
106     {
107       optChekerItf = null;
108     }
109   }
110
111 }
Popular Tags