KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > ir > gui > remoteobject > RemoteObject


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.ir.gui.remoteobject;
22
23
24
25 import org.jacorb.ir.gui.typesystem.*;
26
27 import org.jacorb.ir.gui.typesystem.remote.*;
28
29 import org.omg.CORBA.*;
30
31 /**
32
33  * This class was generated by a SmartGuide.
34
35  *
36
37  */

38
39 public class RemoteObject
40
41     extends ObjectRepresentant implements AbstractContainer
42
43 {
44
45
46
47
48
49     /**
50
51      * This method was created by a SmartGuide.
52
53      * @param counterPart java.lang.Object
54
55      */

56
57     protected RemoteObject (org.omg.CORBA.Object JavaDoc counterPart,
58
59                             TypeSystemNode type, String JavaDoc name)
60
61     {
62
63     super(counterPart,type,name);
64
65     
66
67 }
68
69     /**
70
71      * Für alle Attributes erzeuge ObjectRepresentants und gebe sie zurück
72
73      * @return ModelParticipant[]
74
75      */

76
77     public ModelParticipant[] contents() {
78
79     if (counterPart!=null) {
80
81             IRAttribute[] allFields = (IRAttribute[])((Interface)this.typeSystemNode).getAllFields();
82
83             ObjectRepresentant[] result = new ObjectRepresentant[allFields.length];
84
85             for (int i=0; i<allFields.length; i++) {
86
87                 Request request = ((org.omg.CORBA.Object JavaDoc)counterPart)._request("_get_"+allFields[i].getName());
88
89                 IRNode associatedNode = (IRNode)allFields[i].getAssociatedTypeSystemNode();
90
91                 request.set_return_type(associatedNode.getTypeCode()); // was ist mit Alias-Typen?
92

93                 try {
94
95                     request.invoke();
96
97                 }
98
99                 catch (Exception JavaDoc e) {
100
101                     e.printStackTrace();
102
103                 }
104
105                 Any any = request.return_value();
106
107                 if (any!=null) {
108
109                     result[i] = ObjectRepresentantFactory.create(
110
111                                                                  ObjectRepresentantFactory.objectFromAny(any),
112
113                                                                  allFields[i].getAssociatedTypeSystemNode(),
114
115                                                                  allFields[i]);
116
117                 }
118
119                 else {
120
121                     result[i] = ObjectRepresentantFactory.create(null, allFields[i].getAssociatedTypeSystemNode(),allFields[i]);
122
123                 }
124
125             }
126
127             return result;
128
129     } // if (counterPart!=null)
130

131     else {
132
133             return new ModelParticipant[0];
134
135     }
136
137     }
138
139     /**
140
141      * This method was created by a SmartGuide.
142
143      * @return java.lang.Object
144
145      * @param op org.jacorb.ir;.gui.typesystem.remote.IROperation
146
147      * @param params java.lang.String[]
148
149      */

150
151     public java.lang.Object JavaDoc invokeOperation(IROperation op, String JavaDoc[] params) {
152
153     ModelParticipant[] irParams = op.contents();
154
155     Request request = ((org.omg.CORBA.Object JavaDoc)counterPart)._request(op.getName());
156
157     IRNode associatedNode = (IRNode)op.getAssociatedTypeSystemNode();
158
159     request.set_return_type(associatedNode.getTypeCode()); // was ist mit Alias-Typen?
160

161     for (int i=0; i<irParams.length; i++) {
162
163             IRParameter irParam = (IRParameter)irParams[i];
164
165             switch (irParam.getMode().value()) {
166
167             case ParameterMode._PARAM_IN:
168
169                 ObjectRepresentantFactory.insertFromString(request.add_in_arg(),params[i],irParam.getTypeCode().kind());
170
171                 break;
172
173             case ParameterMode._PARAM_OUT:
174
175                 ObjectRepresentantFactory.insertFromString(request.add_out_arg(),params[i],irParam.getTypeCode().kind());
176
177                 break;
178
179             case ParameterMode._PARAM_INOUT:
180
181                 ObjectRepresentantFactory.insertFromString(request.add_inout_arg(),params[i],irParam.getTypeCode().kind());
182
183                 break;
184
185             }
186
187     }
188
189     request.invoke();
190
191     Any any = request.return_value();
192
193     if (any!=null) {
194
195             return ObjectRepresentantFactory.objectFromAny(any);
196
197     }
198
199     return null;
200
201     }
202
203 }
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
Popular Tags