KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > generator > cif_idl > lib > HomeExecutorMapping


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): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.corba.generator.cif_idl.lib;
28
29 // Package dependencies.
30
import org.objectweb.openccm.ast.api.Declaration;
31 import org.objectweb.openccm.ast.api.HomeExecutorDecl;
32 import org.objectweb.openccm.ast.api.ModuleDecl;
33 import org.objectweb.openccm.ast.api.InterfaceDecl;
34 import org.objectweb.openccm.ast.api.InterfaceList;
35 import org.objectweb.openccm.ast.api.NativeDecl;
36 import org.objectweb.openccm.ast.api.OperationDecl;
37 import org.objectweb.openccm.ast.utils.api.CompositionInfo;
38 import org.objectweb.corba.generator.cif_idl.api.ExecutorMapping;
39
40
41 /**
42  * This class generates CIF IDL for an OMG CIDL Home Executor.
43  *
44  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
45  *
46  * @version 0.1
47  */

48
49 public class HomeExecutorMapping
50   implements org.objectweb.corba.generator.cif_idl.api.HomeExecutorMapping
51 {
52     // ==================================================================
53
//
54
// Internal state.
55
//
56
// ==================================================================
57

58     /** The home executor to map. */
59     private HomeExecutorDecl home_exec_;
60
61     /** The Home Executor CIF interface mapping. */
62     private InterfaceDecl cif_mapping_;
63
64     // ==================================================================
65
//
66
// Constructors.
67
//
68
// ==================================================================
69

70     /**
71      * The default constructor.
72      *
73      * @param home_exec - The home executor to map.
74      */

75     public HomeExecutorMapping(HomeExecutorDecl home_exec)
76     {
77         // Init internal states
78
home_exec_ = home_exec;
79         cif_mapping_ = null;
80     }
81
82     // ==================================================================
83
//
84
// Internal methods.
85
//
86
// ==================================================================
87

88     // ==================================================================
89
//
90
// Public methods for org.objectweb.openccm.generator.cif_idl.api.HomeExecutorMapping
91
//
92
// ==================================================================
93

94     /**
95      * Declare CIF interfaces into Interface Repository.
96      *
97      * @param module - The module to declare CIF mapping in.
98      * @param comp - An abstract view of the binding composition.
99      */

100     public void
101     declareCIF(ModuleDecl module,
102                CompositionInfo comp)
103     {
104         InterfaceDecl itf = null;
105         Declaration[] decls = null;
106         InterfaceList list = null;
107         NativeDecl ast = null,
108                    ash = null;
109         ExecutorMapping exec_mapping = null;
110
111         /** Create the home executor interface **/
112         itf = module.declareLocalInterface( "CIF_" + home_exec_.getName() );
113         // Feed inherited interface list
114
list = itf.getInheritedInterfaceList();
115           // the CIF_SegmentBase interface
116
list.add( home_exec_.getHomeType().getLocalMapping() );
117         itf.create();
118         cif_mapping_ = itf;
119
120         /** Create operations for component persistence if needed **/
121         if (home_exec_.getAbstractStorageHomeBinding() != null)
122         {
123             OperationDecl op = null;
124
125             ash = home_exec_.getAbstractStorageHomeBinding().getMapping();
126             ast = home_exec_.getAbstractStorageHomeBinding().getAbstractStorageType().getMapping();
127
128             op = itf.startOperation("get_state");
129             op.setType(ash);
130             op.create();
131         }
132
133         /** Create operations for home persistence if needed **/
134         if (home_exec_.getHomePersistence() != null)
135         {
136             NativeDecl home_ast = null,
137                        home_ash = null;
138             OperationDecl op = null;
139
140             home_ash = home_exec_.getHomePersistence().getMapping();
141             home_ast = home_exec_.getHomePersistence().getAbstractStorageType().getMapping();
142
143             op = itf.startOperation("get_home_executor_state");
144             op.setType(home_ast);
145             op.create();
146             // Create an operation to get home_ast ?
147
}
148
149         // Generate operations if needed
150

151         // Call mapping for component executor
152
exec_mapping = new org.objectweb.corba.generator.cif_idl.lib.ExecutorMapping( comp.getComponentExecutor() );
153         exec_mapping.declareCIF(comp, module, ast);
154     }
155
156     /**
157      * Declare CIF interfaces into Interface Repository.
158      */

159     public InterfaceDecl
160     getCIFMapping()
161     {
162         return cif_mapping_;
163     }
164
165     // ==================================================================
166
//
167
// Public methods.
168
//
169
// ==================================================================
170

171 }
172
Popular Tags