KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
28
29 import org.objectweb.fractal.adl.ADLException;
30 import org.objectweb.fractal.adl.Factory;
31 import org.objectweb.fractal.api.Component;
32 import org.objectweb.fractal.api.NoSuchInterfaceException;
33 import org.objectweb.fractal.api.control.BindingController;
34 import org.objectweb.fractal.api.control.IllegalBindingException;
35 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
36
37 /**
38  * Implementation of the {@link Reconfiguration }interface.
39  */

40 public class ReconfigurationImpl implements Reconfiguration, BindingController
41 {
42
43   Factory factoryItf;
44
45   /**
46    * @see org.objectweb.dream.adl.Reconfiguration#addComponents(org.objectweb.fractal.api.Component,
47    * java.lang.String, java.util.Map)
48    */

49   public void addComponents(Component composite, String JavaDoc reconfADL, Map JavaDoc context)
50       throws ADLException
51   {
52     context.put("legacy:./", composite);
53     factoryItf.newComponent(reconfADL, context);
54   }
55
56   /**
57    * @see org.objectweb.fractal.api.control.BindingController#listFc()
58    */

59   public String JavaDoc[] listFc()
60   {
61     return new String JavaDoc[]{"factory"};
62   }
63
64   /**
65    * @see org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
66    */

67   public Object JavaDoc lookupFc(String JavaDoc clientItfName) throws NoSuchInterfaceException
68   {
69     if ("factory".equals(clientItfName))
70     {
71       return factoryItf;
72     }
73     return null;
74   }
75
76   /**
77    * @see org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
78    * java.lang.Object)
79    */

80   public void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
81       throws NoSuchInterfaceException, IllegalBindingException,
82       IllegalLifeCycleException
83   {
84     if ("factory".equals(clientItfName))
85     {
86       factoryItf = (Factory) serverItf;
87     }
88   }
89
90   /**
91    * @see org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
92    */

93   public void unbindFc(String JavaDoc clientItfName) throws NoSuchInterfaceException,
94       IllegalBindingException, IllegalLifeCycleException
95   {
96     if ("factory".equals(clientItfName))
97     {
98       factoryItf = null;
99     }
100   }
101
102 }
Popular Tags