KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > Components > ComponentContext


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

26 package org.objectweb.openccm.explorer.Components;
27
28
29 import org.omg.Components.CCMObject;
30 import org.omg.Components.ComponentPortDescription;
31 import org.omg.Components.FacetDescription;
32 import org.omg.Components.ReceptacleDescription;
33 import org.omg.Components.ConsumerDescription;
34 import org.omg.Components.EmitterDescription;
35 import org.omg.Components.PublisherDescription;
36 import org.objectweb.openccm.explorer.CORBA.CORBAContext;
37 import org.objectweb.util.explorer.api.Entry;
38 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry;
39
40 /**
41  * Basic implementation of the Context interface
42  * for managing Components.
43  *
44  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
45  *
46  * @version 0.2
47  */

48 public class ComponentContext
49      extends CORBAContext {
50
51     // ==================================================================
52
//
53
// No Internal state.
54
//
55
// ==================================================================
56

57     // ==================================================================
58
//
59
// No Constructors.
60
//
61
// ==================================================================
62

63     // ==================================================================
64
//
65
// No internal methods.
66
//
67
// ==================================================================
68

69     // ==================================================================
70
//
71
// Public methods for Context interface.
72
//
73
// ==================================================================
74

75     public Entry[] getEntries(Object JavaDoc object) {
76         CCMObject component = (CCMObject)object;
77         
78         ComponentPortDescription cpd = ((CCMObject)component).get_all_ports();
79         java.util.List JavaDoc v = new java.util.Vector JavaDoc();
80
81         Entry[] attributes = super.getEntries(object);
82         for (int i = 0; i < attributes.length; i++)
83             v.add(attributes[i]);
84
85         FacetDescription[] fd = cpd.facets;
86         for (int i = 0; i < fd.length; i++)
87             v.add(new DefaultEntry(fd[i].name, fd[i]));
88
89         ConsumerDescription[] cd = cpd.consumers;
90         for (int i = 0; i < cd.length; i++)
91             v.add(new DefaultEntry(cd[i].name, cd[i]));
92
93         ReceptacleDescription[] rd = cpd.receptacles;
94         for (int i = 0; i < rd.length; i++) {
95             ReceptacleContainer rc = new ReceptacleContainer();
96             rc.setComponent((CCMObject)component);
97             rc.setReceptacle(rd[i]);
98             v.add(new DefaultEntry(rd[i].name, rc));
99         }
100
101         EmitterDescription[] ed = cpd.emitters;
102         for (int i = 0; i < ed.length; i++) {
103             EmitterContainer ec = new EmitterContainer();
104             ec.setComponent((CCMObject)component);
105             ec.setEmitter(ed[i]);
106             v.add(new DefaultEntry(ed[i].name, ec));
107         }
108
109         PublisherDescription[] pd = cpd.publishers;
110         for (int i = 0; i < pd.length; i++) {
111             PublisherContainer pc = new PublisherContainer();
112             pc.setComponent((CCMObject)component);
113             pc.setPublisher(pd[i]);
114             v.add(new DefaultEntry(pd[i].name, pc));
115         }
116
117         return (Entry[]) v.toArray(new Entry[0]);
118     }
119
120 }
121
Popular Tags