KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > adl > legacy > FractalLegacyComponentBuilder


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.legacy;
26
27 import org.objectweb.fractal.adl.components.FractalComponentBuilder;
28 import org.objectweb.fractal.api.Component;
29 import org.objectweb.fractal.api.NoSuchInterfaceException;
30 import org.objectweb.fractal.api.control.ContentController;
31 import org.objectweb.fractal.util.Fractal;
32
33 /**
34  * Component builder for legacy component. Adds the
35  * {@link LegacyComponentBuilder#stopComponent(Object, Object) stopComponent }
36  * method and the
37  * {@link org.objectweb.fractal.adl.components.ComponentBuilder#addComponent(Object, Object, String, Object) addComponent }
38  * method check if the sub component is not already in the super component (in
39  * case of legacy component)
40  */

41 public class FractalLegacyComponentBuilder extends FractalComponentBuilder
42     implements
43       LegacyComponentBuilder
44 {
45
46   /**
47    * @see LegacyComponentBuilder#stopComponent(Object, Object)
48    */

49   public void stopComponent(Object JavaDoc component, Object JavaDoc context) throws Exception JavaDoc
50   {
51     /*
52      * try { Fractal.getLifeCycleController((Component) component).stopFc(); }
53      * catch (NoSuchInterfaceException ignored) { } catch (NullPointerException
54      * ignored) { }
55      */

56   }
57
58   /**
59    * @see org.objectweb.fractal.adl.components.ComponentBuilder#addComponent(Object,
60    * Object, String, Object)
61    */

62   public void addComponent(Object JavaDoc superComponent, Object JavaDoc subComponent,
63       String JavaDoc name, Object JavaDoc context) throws Exception JavaDoc
64   {
65     ContentController cc = Fractal
66         .getContentController((Component) superComponent);
67     Component subComponents[] = cc.getFcSubComponents();
68     for (int i = 0; i < subComponents.length; i++)
69     {
70       if (subComponents[i] == subComponent)
71       {
72         // subComponent already a sub component of superComponent.
73
return;
74       }
75     }
76     cc.addFcSubComponent((Component) subComponent);
77     try
78     {
79       Fractal.getNameController((Component) subComponent).setFcName(name);
80     }
81     catch (NoSuchInterfaceException ignored)
82     {
83     }
84   }
85 }
Popular Tags