KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > control > binding > BasicBindingControllerMixin


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
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: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.julia.control.binding;
25
26 import org.objectweb.fractal.api.NoSuchInterfaceException;
27 import org.objectweb.fractal.api.control.BindingController;
28 import org.objectweb.fractal.api.control.IllegalBindingException;
29 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
30
31 import java.util.HashMap JavaDoc;
32 import java.util.Map JavaDoc;
33
34 /**
35  * Provides a basic implementation of the {@link BindingController} interface.
36  * This mixin uses a map to store the bindings of the component.
37  * <br>
38  * <br>
39  * <b>Requirements</b>
40  * <ul>
41  * <li>none.</li>
42  * </ul>
43  */

44
45 public abstract class BasicBindingControllerMixin implements BindingController {
46
47   // -------------------------------------------------------------------------
48
// Private constructor
49
// -------------------------------------------------------------------------
50

51   private BasicBindingControllerMixin () {
52   }
53
54   // -------------------------------------------------------------------------
55
// Fields and methods added and overriden by the mixin class
56
// -------------------------------------------------------------------------
57

58   /**
59    * The bindings of the component to which this controller object belongs.
60    * This map associates to each client interface name the server interface to
61    * which it is bound. If a client interface is not bound, its name is not
62    * associated to <tt>null</tt>, but to the {@link #fcBindings} map itself.
63    * This way the {@link #listFc listFc} method returns the names of all the
64    * client interfaces of the component, and not only the names of the
65    * interfaces that are bound.
66    */

67
68   public Map JavaDoc fcBindings;
69
70   public String JavaDoc[] listFc () {
71     if (fcBindings == null) {
72       return new String JavaDoc[0];
73     }
74     return (String JavaDoc[])fcBindings.keySet().toArray(new String JavaDoc[fcBindings.size()]);
75   }
76
77   public Object JavaDoc lookupFc (final String JavaDoc clientItfName)
78     throws NoSuchInterfaceException
79   {
80     if (fcBindings == null) {
81       return null;
82     }
83     Object JavaDoc serverItf = fcBindings.get(clientItfName);
84     return serverItf == fcBindings ? null : serverItf;
85   }
86
87   public void bindFc (final String JavaDoc clientItfName, final Object JavaDoc serverItf) throws
88     NoSuchInterfaceException,
89     IllegalBindingException,
90     IllegalLifeCycleException
91   {
92     if (fcBindings == null) {
93       fcBindings = new HashMap JavaDoc();
94     }
95     fcBindings.put(clientItfName, serverItf);
96   }
97
98   public void unbindFc (final String JavaDoc clientItfName) throws
99     NoSuchInterfaceException,
100     IllegalBindingException,
101     IllegalLifeCycleException
102   {
103     if (fcBindings != null) {
104       fcBindings.put(clientItfName, fcBindings);
105     }
106   }
107
108   // -------------------------------------------------------------------------
109
// Fields and methods required by the mixin class in the base class
110
// -------------------------------------------------------------------------
111

112 }
113
Popular Tags