KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > model > BasicServerInterface


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 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: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.model;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 /**
30  * Basic implementation of the {@link ServerInterface}
31  * interface.
32  */

33
34 public class BasicServerInterface extends BasicInterface
35   implements ServerInterface
36 {
37
38   /**
39    * The list of the {@link Binding} objects that refer to this server
40    * interface.
41    */

42
43   private List JavaDoc bindings;
44
45   /**
46    * Constructs a new external server interface.
47    *
48    * @param owner the component that will own this interface.
49    */

50
51   BasicServerInterface (final BasicComponent owner) {
52     super(owner);
53     complementaryItf = new BasicClientInterface(this);
54     bindings = new ArrayList JavaDoc();
55   }
56
57   /**
58    * Constructs a new internal server interface.
59    *
60    * @param externalItf the complementary interface of this interface.
61    */

62
63   BasicServerInterface (final ClientInterface externalItf) {
64     super(externalItf);
65     bindings = new ArrayList JavaDoc();
66   }
67
68   /**
69    * Constructs a new slave, collection server interface.
70    *
71    * @param rootCollectionItf a master collection server interface.
72    */

73
74   BasicServerInterface (final ServerInterface rootCollectionItf, final String JavaDoc suffix) {
75     super(rootCollectionItf, 0);
76     if (suffix != null) {
77       this.name = suffix;
78     }
79     complementaryItf = new BasicClientInterface(this);
80     bindings = new ArrayList JavaDoc();
81     ((BasicInterface)rootCollectionItf).addSlaveCollectionInterface(this);
82   }
83
84   public List JavaDoc getBindings () {
85     return bindings;
86   }
87
88   /**
89    * Adds the given binding to the list of bindings that refer to this
90    * interface.
91    *
92    * @param binding a new binding that refer to this interface.
93    */

94
95   void addBinding (final Binding binding) {
96     for (int i = 0; i < bindings.size(); ++i) {
97       Binding b = (Binding)bindings.get(i);
98       if (b.getClientInterface() == binding.getClientInterface() && b.getServerInterface() == binding.getServerInterface()) {
99         return;
100       }
101     }
102     bindings.add(binding);
103   }
104
105   /**
106    * Removes the given binding from the list of bindings that refer to this
107    * interface.
108    *
109    * @param binding a binding that refer to this interface.
110    */

111
112   void removeBinding (final Binding binding) {
113     bindings.remove(binding);
114   }
115 }
116
Popular Tags