1 | <?xml version="1.0"?>
|
---|
2 |
|
---|
3 | <!--
|
---|
4 | websrv-jax-ws.xsl:
|
---|
5 | XSLT stylesheet that generates virtualbox.java from
|
---|
6 | VirtualBox.xidl. This generated Java code contains
|
---|
7 | a Java wrapper that allows client code to use the
|
---|
8 | webservice in an object-oriented way.
|
---|
9 |
|
---|
10 | Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
21 | Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
22 | additional information or have any questions.
|
---|
23 | -->
|
---|
24 |
|
---|
25 | <xsl:stylesheet
|
---|
26 | version="1.0"
|
---|
27 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
28 | xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
---|
29 | xmlns:exsl="http://exslt.org/common"
|
---|
30 | extension-element-prefixes="exsl">
|
---|
31 |
|
---|
32 | <xsl:output method="text"/>
|
---|
33 |
|
---|
34 | <xsl:strip-space elements="*"/>
|
---|
35 |
|
---|
36 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
37 | global XSLT variables
|
---|
38 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
39 |
|
---|
40 | <xsl:variable name="G_xsltFilename" select="'glue-jaxws.xsl'" />
|
---|
41 | <!-- Keep in sync with VBOX_JAVA_PACKAGE in webservices/Makefile.kmk -->
|
---|
42 | <xsl:variable name="G_virtualBoxPackage" select="concat('org.virtualbox',$G_vboxApiSuffix)" />
|
---|
43 | <xsl:variable name="G_virtualBoxPackage2" select="concat('com.sun.xml.ws.commons.virtualbox',$G_vboxApiSuffix)" />
|
---|
44 | <xsl:variable name="G_virtualBoxWsdl" select="concat(concat('"vboxwebService',$G_vboxApiSuffix), '.wsdl"')" />
|
---|
45 |
|
---|
46 | <xsl:include href="websrv-shared.inc.xsl" />
|
---|
47 |
|
---|
48 | <!-- collect all interfaces with "wsmap='suppress'" in a global variable for
|
---|
49 | quick lookup -->
|
---|
50 | <xsl:variable name="G_setSuppressedInterfaces"
|
---|
51 | select="//interface[@wsmap='suppress']" />
|
---|
52 |
|
---|
53 |
|
---|
54 | <xsl:template name="fileheader">
|
---|
55 | <xsl:param name="name" />
|
---|
56 | <xsl:text>/**
|
---|
57 | * Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
---|
58 | *
|
---|
59 | * This file is part of a free software library; you can redistribute
|
---|
60 | * it and/or modify it under the terms of the GNU Lesser General
|
---|
61 | * Public License version 2.1 as published by the Free Software
|
---|
62 | * Foundation and shipped in the "COPYING.LIB" file with this library.
|
---|
63 | * The library is distributed in the hope that it will be useful,
|
---|
64 | * but WITHOUT ANY WARRANTY of any kind.
|
---|
65 | *
|
---|
66 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if
|
---|
67 | * any license choice other than GPL or LGPL is available it will
|
---|
68 | * apply instead, Sun elects to use only the Lesser General Public
|
---|
69 | * License version 2.1 (LGPLv2) at this time for any software where
|
---|
70 | * a choice of LGPL license versions is made available with the
|
---|
71 | * language indicating that LGPLv2 or any later version may be used,
|
---|
72 | * or where a choice of which version of the LGPL is applied is
|
---|
73 | * otherwise unspecified.
|
---|
74 | *
|
---|
75 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
76 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
77 | * additional information or have any questions.
|
---|
78 | *
|
---|
79 | </xsl:text>
|
---|
80 | <xsl:value-of select="concat(' * ',$name)"/>
|
---|
81 | <xsl:text>
|
---|
82 | *
|
---|
83 | * DO NOT EDIT! This is a generated file.
|
---|
84 | * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
|
---|
85 | * Generator: src/VBox/Main/webservice/glue-jaxws.xsl
|
---|
86 | */
|
---|
87 |
|
---|
88 | </xsl:text>
|
---|
89 | </xsl:template>
|
---|
90 |
|
---|
91 | <xsl:template name="fullClassName">
|
---|
92 | <xsl:param name="name" />
|
---|
93 | <xsl:param name="origname" />
|
---|
94 | <xsl:param name="collPrefix" />
|
---|
95 | <xsl:variable name="coll" select="//collection[@name=$name]" />
|
---|
96 | <xsl:choose>
|
---|
97 | <xsl:when test="//collection[@name=$name]">
|
---|
98 | <!-- for collections and safearrays we return element type -->
|
---|
99 | <xsl:call-template name="fullClassName">
|
---|
100 | <xsl:with-param name="name" select="concat($collPrefix,//collection[@name=$name]/@type)" />
|
---|
101 | <xsl:with-param name="origname" select="//collection[@name=$name]/@type" />
|
---|
102 | <xsl:with-param name="collPrefix" select="$collPrefix" />
|
---|
103 | </xsl:call-template>
|
---|
104 | <!-- <xsl:value-of select="concat('org.virtualbox.', concat($collPrefix,//collection[@name=$name]/@type))" /> -->
|
---|
105 | </xsl:when>
|
---|
106 | <xsl:when test="//enum[@name=$name] or //enum[@name=$origname]">
|
---|
107 | <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
|
---|
108 | </xsl:when>
|
---|
109 | <xsl:when test="$collPrefix and //interface[@name=$origname]/@wsmap='managed'">
|
---|
110 | <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
|
---|
111 | </xsl:when>
|
---|
112 | <xsl:when test="//interface[@name=$name]/@wsmap='struct' or //interface[@name=$origname]/@wsmap='struct'">
|
---|
113 | <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
|
---|
114 | </xsl:when>
|
---|
115 | <xsl:otherwise>
|
---|
116 | <xsl:value-of select="concat($G_virtualBoxPackage2, concat('.', $name))" />
|
---|
117 | </xsl:otherwise>
|
---|
118 | </xsl:choose>
|
---|
119 | </xsl:template>
|
---|
120 |
|
---|
121 | <!--
|
---|
122 | typeIdl2Glue: converts $type into a type as used by the java glue code.
|
---|
123 | For example, for an XIDL IMachineCollection, this will return
|
---|
124 | "List<com.sun.xml.ws.commons.virtualbox.IMachine>".
|
---|
125 | -->
|
---|
126 | <xsl:template name="typeIdl2Glue">
|
---|
127 | <xsl:param name="ifname" />
|
---|
128 | <xsl:param name="method" />
|
---|
129 | <xsl:param name="name" />
|
---|
130 | <xsl:param name="type" />
|
---|
131 | <xsl:param name="safearray" />
|
---|
132 | <xsl:param name="forceelem" />
|
---|
133 |
|
---|
134 | <xsl:variable name="needarray" select="($safearray='yes' or //collection[@name=$type]) and not($forceelem='yes')" />
|
---|
135 |
|
---|
136 | <xsl:if test="$needarray">
|
---|
137 | <xsl:value-of select="'List<'" />
|
---|
138 | </xsl:if>
|
---|
139 |
|
---|
140 | <xsl:choose>
|
---|
141 | <xsl:when test="$type='wstring'">String</xsl:when>
|
---|
142 | <xsl:when test="$type='boolean'">Boolean</xsl:when>
|
---|
143 | <!-- <xsl:when test="$type='double'">double</xsl:when> -->
|
---|
144 | <!-- <xsl:when test="$type='float'">float</xsl:when> -->
|
---|
145 | <!-- <xsl:when test="$type='octet'">byte</xsl:when> -->
|
---|
146 | <!-- <xsl:when test="$type='short'">short</xsl:when> -->
|
---|
147 | <xsl:when test="$type='unsigned short'">Integer</xsl:when>
|
---|
148 | <xsl:when test="$type='long'">Integer</xsl:when>
|
---|
149 | <xsl:when test="$type='long long'">Long</xsl:when>
|
---|
150 | <xsl:when test="$type='unsigned long'">Long</xsl:when>
|
---|
151 | <xsl:when test="$type='unsigned long long'">BigInteger</xsl:when>
|
---|
152 | <xsl:when test="$type='result'">Long</xsl:when>
|
---|
153 | <xsl:when test="$type='uuid'">UUID</xsl:when>
|
---|
154 | <!-- not a standard type: then it better be one of the types defined in the XIDL -->
|
---|
155 | <xsl:when test="$type='$unknown'">IUnknown</xsl:when>
|
---|
156 | <xsl:otherwise>
|
---|
157 | <xsl:call-template name="fullClassName">
|
---|
158 | <xsl:with-param name="name" select="$type" />
|
---|
159 | <xsl:with-param name="collPrefix" select="''"/>
|
---|
160 | </xsl:call-template>
|
---|
161 | </xsl:otherwise>
|
---|
162 | <!-- <xsl:otherwise> -->
|
---|
163 | <!-- <xsl:call-template name="fatalError"> -->
|
---|
164 | <!-- <xsl:with-param name="msg" select="concat('typeIdl2Glue: Type "', $type, '" in arg "', $name, '" of method "', $ifname, '::', $method, '" is not supported.')" /> -->
|
---|
165 | <!-- </xsl:call-template> -->
|
---|
166 | <!-- </xsl:otherwise> -->
|
---|
167 | </xsl:choose>
|
---|
168 |
|
---|
169 | <xsl:if test="$needarray">
|
---|
170 | <xsl:value-of select="'>'" />
|
---|
171 | </xsl:if>
|
---|
172 | </xsl:template>
|
---|
173 |
|
---|
174 | <!--
|
---|
175 | typeIdl2Java: converts $type into a type as used by the JAX-WS backend.
|
---|
176 | For example, for an XIDL IMachineCollection, this will return
|
---|
177 | "ArrayOfIMachine".
|
---|
178 | -->
|
---|
179 | <xsl:template name="typeIdl2Java">
|
---|
180 | <xsl:param name="ifname" />
|
---|
181 | <xsl:param name="method" />
|
---|
182 | <xsl:param name="name" />
|
---|
183 | <xsl:param name="type" />
|
---|
184 | <xsl:param name="safearray" />
|
---|
185 |
|
---|
186 | <xsl:if test="$safearray">
|
---|
187 | <xsl:value-of select="'List<'" />
|
---|
188 | </xsl:if>
|
---|
189 |
|
---|
190 | <xsl:choose>
|
---|
191 | <xsl:when test="$type='wstring'">String</xsl:when>
|
---|
192 | <xsl:when test="$type='boolean'">Boolean</xsl:when>
|
---|
193 | <!-- <xsl:when test="$type='double'">double</xsl:when> -->
|
---|
194 | <!-- <xsl:when test="$type='float'">float</xsl:when> -->
|
---|
195 | <!-- <xsl:when test="$type='octet'">byte</xsl:when> -->
|
---|
196 | <!-- <xsl:when test="$type='short'">short</xsl:when> -->
|
---|
197 | <xsl:when test="$type='unsigned short'">int</xsl:when>
|
---|
198 | <xsl:when test="$type='long'">Integer</xsl:when>
|
---|
199 | <xsl:when test="$type='long long'">Long</xsl:when>
|
---|
200 | <xsl:when test="$type='unsigned long'">Long</xsl:when>
|
---|
201 | <xsl:when test="$type='unsigned long long'">BigInteger</xsl:when>
|
---|
202 | <xsl:when test="$type='result'">Long</xsl:when>
|
---|
203 | <xsl:when test="$type='uuid'">String</xsl:when>
|
---|
204 | <xsl:when test="$type='$unknown'">String</xsl:when>
|
---|
205 | <xsl:when test="//interface[@name=$type]/@wsmap='managed'">String</xsl:when>
|
---|
206 | <xsl:otherwise>
|
---|
207 | <xsl:call-template name="fullClassName">
|
---|
208 | <xsl:with-param name="name" select="$type" />
|
---|
209 | <xsl:with-param name="collPrefix" select="'ArrayOf'"/>
|
---|
210 | </xsl:call-template>
|
---|
211 | </xsl:otherwise>
|
---|
212 | <!-- <xsl:otherwise> -->
|
---|
213 | <!-- <xsl:call-template name="fatalError"> -->
|
---|
214 | <!-- <xsl:with-param name="msg" select="concat('typeIdl2Java: Type "', $type, '" in arg "', $name, '" of method "', $ifname, '::', $method, '" is not supported.')" /> -->
|
---|
215 | <!-- </xsl:call-template> -->
|
---|
216 | <!-- </xsl:otherwise> -->
|
---|
217 | </xsl:choose>
|
---|
218 | <xsl:if test="$safearray">
|
---|
219 | <xsl:value-of select="'>'" />
|
---|
220 | </xsl:if>
|
---|
221 | </xsl:template>
|
---|
222 |
|
---|
223 | <xsl:template name="cookOutParam">
|
---|
224 | <xsl:param name="ifname"/>
|
---|
225 | <xsl:param name="methodname"/>
|
---|
226 | <xsl:param name="value"/>
|
---|
227 | <xsl:param name="idltype"/>
|
---|
228 | <xsl:param name="safearray"/>
|
---|
229 | <xsl:choose>
|
---|
230 | <xsl:when test="$idltype='uuid'">
|
---|
231 | <xsl:choose>
|
---|
232 | <xsl:when test="$safearray">
|
---|
233 | <xsl:value-of select="concat('Helper.uuidWrap(',$value,')')" />
|
---|
234 | </xsl:when>
|
---|
235 | <xsl:otherwise>
|
---|
236 | <xsl:value-of select="concat('UUID.fromString(',$value,')')" />
|
---|
237 | </xsl:otherwise>
|
---|
238 | </xsl:choose>
|
---|
239 | </xsl:when>
|
---|
240 | <xsl:when test="//collection[@name=$idltype]">
|
---|
241 | <xsl:variable name="elemtype">
|
---|
242 | <xsl:call-template name="typeIdl2Glue">
|
---|
243 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
244 | <xsl:with-param name="method" select="$methodname" />
|
---|
245 | <xsl:with-param name="name" select="$value" />
|
---|
246 | <xsl:with-param name="type" select="$idltype" />
|
---|
247 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
248 | </xsl:call-template>
|
---|
249 | </xsl:variable>
|
---|
250 | <xsl:choose>
|
---|
251 | <xsl:when test="contains($elemtype, $G_virtualBoxPackage)">
|
---|
252 | <xsl:value-of select="concat($value,'.getArray()')" />
|
---|
253 | </xsl:when>
|
---|
254 | <xsl:otherwise>
|
---|
255 | <xsl:value-of select="concat('Helper.wrap(', $elemtype, '.class, port, ((',
|
---|
256 | $value,' == null)? null : ',$value,'.getArray()))')" />
|
---|
257 | </xsl:otherwise>
|
---|
258 | </xsl:choose>
|
---|
259 | </xsl:when>
|
---|
260 | <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
|
---|
261 | <xsl:choose>
|
---|
262 | <xsl:when test="//interface[@name=$idltype]/@wsmap='struct' and $safearray='yes'">
|
---|
263 | <xsl:value-of select="concat('/* 2 */', $value)" />
|
---|
264 | </xsl:when>
|
---|
265 | <xsl:when test="//interface[@name=$idltype]/@wsmap='struct'">
|
---|
266 | <xsl:value-of select="$value" />
|
---|
267 | </xsl:when>
|
---|
268 | <xsl:when test="$safearray='yes'">
|
---|
269 | <xsl:variable name="elemtype">
|
---|
270 | <xsl:call-template name="typeIdl2Glue">
|
---|
271 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
272 | <xsl:with-param name="method" select="$methodname" />
|
---|
273 | <xsl:with-param name="name" select="$value" />
|
---|
274 | <xsl:with-param name="type" select="$idltype" />
|
---|
275 | <xsl:with-param name="safearray" select="'no'" />
|
---|
276 | <xsl:with-param name="forceelem" select="'yes'" />
|
---|
277 | </xsl:call-template>
|
---|
278 | </xsl:variable>
|
---|
279 | <xsl:value-of select="concat('Helper.wrap(',$elemtype, '.class, port, ', $value,')')"/>
|
---|
280 | </xsl:when>
|
---|
281 | <xsl:otherwise>
|
---|
282 | <xsl:variable name="gluetype">
|
---|
283 | <xsl:call-template name="typeIdl2Glue">
|
---|
284 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
285 | <xsl:with-param name="method" select="$methodname" />
|
---|
286 | <xsl:with-param name="name" select="$value" />
|
---|
287 | <xsl:with-param name="type" select="$idltype" />
|
---|
288 | <xsl:with-param name="safearray" select="$safearray" />
|
---|
289 | </xsl:call-template>
|
---|
290 | </xsl:variable>
|
---|
291 | <xsl:value-of select="concat('new ', $gluetype, '(', $value,', port)')" />
|
---|
292 | </xsl:otherwise>
|
---|
293 | </xsl:choose>
|
---|
294 | </xsl:when>
|
---|
295 | <xsl:otherwise>
|
---|
296 | <xsl:value-of select="$value"/>
|
---|
297 | </xsl:otherwise>
|
---|
298 | </xsl:choose>
|
---|
299 | </xsl:template>
|
---|
300 |
|
---|
301 | <xsl:template name="emitArgInMethodImpl">
|
---|
302 | <xsl:param name="paramname" select="@name" />
|
---|
303 | <xsl:param name="paramtype" select="@type" />
|
---|
304 | <!-- per-argument special type handling -->
|
---|
305 | <xsl:choose>
|
---|
306 | <xsl:when test="//interface[@name=$paramtype] or $paramtype='$unknown'">
|
---|
307 | <xsl:choose>
|
---|
308 | <xsl:when test="@dir='out'">
|
---|
309 | <xsl:value-of select="concat('tmp', $paramname)" />
|
---|
310 | </xsl:when>
|
---|
311 | <xsl:otherwise>
|
---|
312 | <xsl:choose>
|
---|
313 | <xsl:when test="@safearray='yes'">
|
---|
314 | <xsl:value-of select="concat('Helper.unwrap(',$paramname,')')"/>
|
---|
315 | </xsl:when>
|
---|
316 | <xsl:otherwise>
|
---|
317 | <xsl:value-of select="concat('((', $paramname, ' == null)?null:', $paramname, '.getRef())')" />
|
---|
318 | </xsl:otherwise>
|
---|
319 | </xsl:choose>
|
---|
320 | </xsl:otherwise>
|
---|
321 | </xsl:choose>
|
---|
322 | </xsl:when>
|
---|
323 | <xsl:when test="$paramtype='uuid'">
|
---|
324 | <xsl:value-of select="concat($paramname, '.toString()')" />
|
---|
325 | </xsl:when>
|
---|
326 | <xsl:otherwise>
|
---|
327 | <xsl:value-of select="$paramname" />
|
---|
328 | </xsl:otherwise>
|
---|
329 | </xsl:choose>
|
---|
330 | <xsl:if test="not(position()=last())">
|
---|
331 | <xsl:text>, </xsl:text>
|
---|
332 | </xsl:if>
|
---|
333 | </xsl:template>
|
---|
334 |
|
---|
335 | <xsl:template name="startFile">
|
---|
336 | <xsl:param name="file" />
|
---|
337 |
|
---|
338 | <xsl:value-of select="concat(' // ##### BEGINFILE "', $file, '" ')" />
|
---|
339 | <xsl:call-template name="fileheader">
|
---|
340 | <xsl:with-param name="name" select="$file" />
|
---|
341 | </xsl:call-template>
|
---|
342 | package <xsl:value-of select="$G_virtualBoxPackage2" />;
|
---|
343 |
|
---|
344 | import <xsl:value-of select="$G_virtualBoxPackage" />.VboxPortType;
|
---|
345 | import <xsl:value-of select="$G_virtualBoxPackage" />.VboxService;
|
---|
346 | import <xsl:value-of select="$G_virtualBoxPackage" />.InvalidObjectFaultMsg;
|
---|
347 | import <xsl:value-of select="$G_virtualBoxPackage" />.RuntimeFaultMsg;
|
---|
348 | import javax.xml.ws.WebServiceException;
|
---|
349 | </xsl:template>
|
---|
350 |
|
---|
351 | <xsl:template name="endFile">
|
---|
352 | <xsl:param name="file" />
|
---|
353 | <xsl:value-of select="concat(' // ##### ENDFILE "', $file, '" ')" />
|
---|
354 | </xsl:template>
|
---|
355 |
|
---|
356 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
357 | root match
|
---|
358 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
359 |
|
---|
360 | <xsl:template match="/idl">
|
---|
361 | <xsl:if test="not($G_vboxApiSuffix)">
|
---|
362 | <xsl:call-template name="fatalError">
|
---|
363 | <xsl:with-param name="msg" select="'G_vboxApiSuffix must be given'" />
|
---|
364 | </xsl:call-template>
|
---|
365 | </xsl:if>
|
---|
366 | <xsl:call-template name="startFile">
|
---|
367 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
368 | </xsl:call-template>
|
---|
369 |
|
---|
370 | <xsl:text><![CDATA[
|
---|
371 | public class IUnknown
|
---|
372 | {
|
---|
373 | protected String _this; /* almost final, could only be set in finalizer */
|
---|
374 | protected final VboxPortType port;
|
---|
375 |
|
---|
376 | public IUnknown(String _this, VboxPortType port)
|
---|
377 | {
|
---|
378 | this._this = _this;
|
---|
379 | this.port = port;
|
---|
380 | }
|
---|
381 |
|
---|
382 | public final String getRef()
|
---|
383 | {
|
---|
384 | return _this;
|
---|
385 | }
|
---|
386 |
|
---|
387 | public final VboxPortType getRemoteWSPort()
|
---|
388 | {
|
---|
389 | return port;
|
---|
390 | }
|
---|
391 |
|
---|
392 | public synchronized void releaseRemote() throws WebServiceException
|
---|
393 | {
|
---|
394 | if (_this == null) {
|
---|
395 | return;
|
---|
396 | }
|
---|
397 | try {
|
---|
398 | port.iManagedObjectRefRelease(_this);
|
---|
399 | _this = null;
|
---|
400 | } catch (InvalidObjectFaultMsg e) {
|
---|
401 | throw new WebServiceException(e);
|
---|
402 | } catch (RuntimeFaultMsg e) {
|
---|
403 | throw new WebServiceException(e);
|
---|
404 | }
|
---|
405 | }
|
---|
406 |
|
---|
407 | /*
|
---|
408 | protected void finalize()
|
---|
409 | {
|
---|
410 | try {
|
---|
411 | releaseRemote();
|
---|
412 | } catch (WebServiceException e) {
|
---|
413 | }
|
---|
414 | } */
|
---|
415 |
|
---|
416 | // may need to support some sort of QueryInterface, to make this class useable
|
---|
417 | // not only as common baseclass
|
---|
418 | }
|
---|
419 | ]]></xsl:text>
|
---|
420 |
|
---|
421 | <xsl:call-template name="endFile">
|
---|
422 | <xsl:with-param name="file" select="'IUnknown.java'" />
|
---|
423 | </xsl:call-template>
|
---|
424 |
|
---|
425 | <xsl:call-template name="startFile">
|
---|
426 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
427 | </xsl:call-template>
|
---|
428 |
|
---|
429 | <xsl:text><![CDATA[
|
---|
430 |
|
---|
431 | import java.util.List;
|
---|
432 | import java.util.ArrayList;
|
---|
433 | import java.util.Collections;
|
---|
434 | import java.util.UUID;
|
---|
435 | import java.lang.reflect.Constructor;
|
---|
436 | import java.lang.reflect.InvocationTargetException;
|
---|
437 |
|
---|
438 | class Helper {
|
---|
439 | public static <T> List<T> wrap(Class<T> wrapperClass, VboxPortType pt, List<String> thisPtrs) {
|
---|
440 | try {
|
---|
441 | if(thisPtrs==null) return Collections.emptyList();
|
---|
442 |
|
---|
443 | Constructor<T> c = wrapperClass.getConstructor(String.class, VboxPortType.class);
|
---|
444 | List<T> ret = new ArrayList<T>(thisPtrs.size());
|
---|
445 | for (String thisPtr : thisPtrs) {
|
---|
446 | ret.add(c.newInstance(thisPtr,pt));
|
---|
447 | }
|
---|
448 | return ret;
|
---|
449 | } catch (NoSuchMethodException e) {
|
---|
450 | throw new AssertionError(e);
|
---|
451 | } catch (InstantiationException e) {
|
---|
452 | throw new AssertionError(e);
|
---|
453 | } catch (IllegalAccessException e) {
|
---|
454 | throw new AssertionError(e);
|
---|
455 | } catch (InvocationTargetException e) {
|
---|
456 | throw new AssertionError(e);
|
---|
457 | }
|
---|
458 | }
|
---|
459 |
|
---|
460 | public static List<UUID> uuidWrap(List<String> uuidVals) {
|
---|
461 | List<UUID> ret = new ArrayList<UUID>(uuidVals.size());
|
---|
462 | for (String uuid : uuidVals) {
|
---|
463 | ret.add(UUID.fromString(uuid));
|
---|
464 | }
|
---|
465 | return ret;
|
---|
466 | }
|
---|
467 |
|
---|
468 | public static <T extends IUnknown> List<String> unwrap(List<T> thisPtrs) {
|
---|
469 | if (thisPtrs==null) return Collections.emptyList();
|
---|
470 |
|
---|
471 | List<String> ret = new ArrayList<String>();
|
---|
472 | for (T obj : thisPtrs) {
|
---|
473 | ret.add(obj.getRef());
|
---|
474 | }
|
---|
475 | return ret;
|
---|
476 | }
|
---|
477 | }
|
---|
478 | ]]></xsl:text>
|
---|
479 |
|
---|
480 | <xsl:call-template name="endFile">
|
---|
481 | <xsl:with-param name="file" select="'Helper.java'" />
|
---|
482 | </xsl:call-template>
|
---|
483 |
|
---|
484 | <xsl:call-template name="startFile">
|
---|
485 | <xsl:with-param name="file" select="'IWebsessionManager.java'" />
|
---|
486 | </xsl:call-template>
|
---|
487 |
|
---|
488 |
|
---|
489 | import java.net.URL;
|
---|
490 | import java.math.BigInteger;
|
---|
491 | import java.util.List;
|
---|
492 | import java.util.Map;
|
---|
493 | import java.util.HashMap;
|
---|
494 | import java.util.UUID;
|
---|
495 | import javax.xml.namespace.QName;
|
---|
496 | import javax.xml.ws.BindingProvider;
|
---|
497 | import javax.xml.ws.Holder;
|
---|
498 | import javax.xml.ws.WebServiceException;
|
---|
499 |
|
---|
500 | class PortPool
|
---|
501 | {
|
---|
502 | private final static String wsdlFile = <xsl:value-of select="$G_virtualBoxWsdl" />;
|
---|
503 |
|
---|
504 | <xsl:text><![CDATA[
|
---|
505 | private Map<VboxPortType, Integer> known;
|
---|
506 | private boolean initStarted;
|
---|
507 | private VboxService svc;
|
---|
508 |
|
---|
509 | PortPool(boolean usePreinit)
|
---|
510 | {
|
---|
511 | known = new HashMap<VboxPortType, Integer>();
|
---|
512 |
|
---|
513 | if (usePreinit)
|
---|
514 | {
|
---|
515 | new Thread(new Runnable()
|
---|
516 | {
|
---|
517 | public void run()
|
---|
518 | {
|
---|
519 | // need to sync on something else but 'this'
|
---|
520 | synchronized (known)
|
---|
521 | {
|
---|
522 | initStarted = true;
|
---|
523 | known.notify();
|
---|
524 | }
|
---|
525 |
|
---|
526 | preinit();
|
---|
527 | }
|
---|
528 | }).start();
|
---|
529 |
|
---|
530 | synchronized (known)
|
---|
531 | {
|
---|
532 | while (!initStarted)
|
---|
533 | {
|
---|
534 | try {
|
---|
535 | known.wait();
|
---|
536 | } catch (InterruptedException e) {
|
---|
537 | break;
|
---|
538 | }
|
---|
539 | }
|
---|
540 | }
|
---|
541 | }
|
---|
542 | }
|
---|
543 |
|
---|
544 | private synchronized void preinit()
|
---|
545 | {
|
---|
546 | VboxPortType port = getPort();
|
---|
547 | releasePort(port);
|
---|
548 | }
|
---|
549 |
|
---|
550 | synchronized VboxPortType getPort()
|
---|
551 | {
|
---|
552 | VboxPortType port = null;
|
---|
553 | for (VboxPortType cur: known.keySet())
|
---|
554 | {
|
---|
555 | if (known.get(cur) == 0)
|
---|
556 | {
|
---|
557 | port = cur;
|
---|
558 | break;
|
---|
559 | }
|
---|
560 | }
|
---|
561 |
|
---|
562 | if (port == null)
|
---|
563 | {
|
---|
564 | if (svc == null) {
|
---|
565 | URL wsdl = PortPool.class.getClassLoader().getResource(wsdlFile);
|
---|
566 | if (wsdl == null)
|
---|
567 | throw new LinkageError(wsdlFile+" not found, but it should have been in the jar");
|
---|
568 | svc = new VboxService(wsdl,
|
---|
569 | new QName("http://www.virtualbox.org/Service",
|
---|
570 | "vboxService"));
|
---|
571 | }
|
---|
572 | port = svc.getVboxServicePort();
|
---|
573 | }
|
---|
574 | known.put(port, new Integer(1));
|
---|
575 | return port;
|
---|
576 | }
|
---|
577 |
|
---|
578 | synchronized void releasePort(VboxPortType port)
|
---|
579 | {
|
---|
580 | Integer val = known.get(port);
|
---|
581 | if (val == null || val == 0)
|
---|
582 | {
|
---|
583 | // know you not
|
---|
584 | return;
|
---|
585 | }
|
---|
586 | known.put(port, val - 1);
|
---|
587 | }
|
---|
588 | }
|
---|
589 |
|
---|
590 | public class IWebsessionManager {
|
---|
591 |
|
---|
592 | private static PortPool pool = new PortPool(true);
|
---|
593 | protected VboxPortType port;
|
---|
594 |
|
---|
595 | public IWebsessionManager(URL url)
|
---|
596 | {
|
---|
597 | connect(url);
|
---|
598 | }
|
---|
599 |
|
---|
600 | public IWebsessionManager(String url)
|
---|
601 | {
|
---|
602 | connect(url);
|
---|
603 | }
|
---|
604 |
|
---|
605 | public IWebsessionManager(URL url, Map<String, Object> requestContext, Map<String, Object> responseContext)
|
---|
606 | {
|
---|
607 | connect(url.toExternalForm(), requestContext, responseContext);
|
---|
608 | }
|
---|
609 |
|
---|
610 | public IWebsessionManager(String url, Map<String, Object> requestContext, Map<String, Object> responseContext)
|
---|
611 | {
|
---|
612 | connect(url, requestContext, responseContext);
|
---|
613 | }
|
---|
614 |
|
---|
615 | public void connect(URL url)
|
---|
616 | {
|
---|
617 | connect(url.toExternalForm());
|
---|
618 | }
|
---|
619 |
|
---|
620 | public void connect(String url)
|
---|
621 | {
|
---|
622 | this.port = pool.getPort();
|
---|
623 | ((BindingProvider)port).getRequestContext().
|
---|
624 | put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
---|
625 | }
|
---|
626 |
|
---|
627 | public void connect(String url, Map<String, Object> requestContext, Map<String, Object> responseContext)
|
---|
628 | {
|
---|
629 | this.port = pool.getPort();
|
---|
630 |
|
---|
631 | ((BindingProvider)port).getRequestContext();
|
---|
632 | if (requestContext != null)
|
---|
633 | ((BindingProvider)port).getRequestContext().putAll(requestContext);
|
---|
634 |
|
---|
635 | if (responseContext != null)
|
---|
636 | ((BindingProvider)port).getResponseContext().putAll(responseContext);
|
---|
637 |
|
---|
638 | ((BindingProvider)port).getRequestContext().
|
---|
639 | put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
|
---|
640 | }
|
---|
641 |
|
---|
642 |
|
---|
643 | public void disconnect(IVirtualBox refIVirtualBox)
|
---|
644 | {
|
---|
645 | logoff(refIVirtualBox);
|
---|
646 | pool.releasePort(port);
|
---|
647 | }
|
---|
648 |
|
---|
649 | public void cleanupUnused()
|
---|
650 | {
|
---|
651 | System.gc();
|
---|
652 | Runtime.getRuntime().runFinalization();
|
---|
653 | }
|
---|
654 |
|
---|
655 | /* method IWebsessionManager::logon(
|
---|
656 | [in] wstring username,
|
---|
657 | [in] wstring password,
|
---|
658 | [return] IVirtualBox return)
|
---|
659 | */
|
---|
660 | public IVirtualBox logon(String username, String password) {
|
---|
661 | try {
|
---|
662 | String retVal = port.iWebsessionManagerLogon(username, password);
|
---|
663 | return new IVirtualBox(retVal, port);
|
---|
664 | } catch (InvalidObjectFaultMsg e) {
|
---|
665 | throw new WebServiceException(e);
|
---|
666 | } catch (RuntimeFaultMsg e) {
|
---|
667 | throw new WebServiceException(e);
|
---|
668 | }
|
---|
669 | }
|
---|
670 |
|
---|
671 | /* method IWebsessionManager::getSessionObject(
|
---|
672 | [in] IVirtualBox refIVirtualBox,
|
---|
673 | [return] ISession return)
|
---|
674 | */
|
---|
675 | public ISession getSessionObject(IVirtualBox refIVirtualBox) {
|
---|
676 | try {
|
---|
677 | String retVal = port.iWebsessionManagerGetSessionObject(((refIVirtualBox == null)?null:refIVirtualBox.getRef()));
|
---|
678 | return new ISession(retVal, port);
|
---|
679 | } catch (InvalidObjectFaultMsg e) {
|
---|
680 | throw new WebServiceException(e);
|
---|
681 | } catch (RuntimeFaultMsg e) {
|
---|
682 | throw new WebServiceException(e);
|
---|
683 | }
|
---|
684 | }
|
---|
685 |
|
---|
686 | /* method IWebsessionManager::logoff(
|
---|
687 | [in] IVirtualBox refIVirtualBox)
|
---|
688 | */
|
---|
689 | public void logoff(IVirtualBox refIVirtualBox) {
|
---|
690 | try {
|
---|
691 | port.iWebsessionManagerLogoff(((refIVirtualBox == null)?null:refIVirtualBox.getRef()));
|
---|
692 | } catch (InvalidObjectFaultMsg e) {
|
---|
693 | throw new WebServiceException(e);
|
---|
694 | } catch (RuntimeFaultMsg e) {
|
---|
695 | throw new WebServiceException(e);
|
---|
696 | }
|
---|
697 | }
|
---|
698 | }
|
---|
699 | ]]></xsl:text>
|
---|
700 | <xsl:call-template name="endFile">
|
---|
701 | <xsl:with-param name="file" select="'IWebsessionManager.java'" />
|
---|
702 | </xsl:call-template>
|
---|
703 |
|
---|
704 | <xsl:text>// ######## COLLECTIONS </xsl:text>
|
---|
705 |
|
---|
706 | <xsl:for-each select="//collection">
|
---|
707 | <xsl:variable name="type" select="@type" />
|
---|
708 | <xsl:variable name="arrayoftype" select="concat('ArrayOf', @type)" />
|
---|
709 | <xsl:variable name="filename" select="$arrayoftype" />
|
---|
710 |
|
---|
711 | <xsl:value-of select="concat(' // ##### BEGINFILE "', $filename, '.java" ')" />
|
---|
712 |
|
---|
713 | <xsl:call-template name="startFile">
|
---|
714 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
715 | </xsl:call-template>
|
---|
716 |
|
---|
717 | <xsl:text>import java.util.ArrayList; </xsl:text>
|
---|
718 | <xsl:text>import java.util.List; </xsl:text>
|
---|
719 | <xsl:text>import javax.xml.bind.annotation.XmlAccessType; </xsl:text>
|
---|
720 | <xsl:text>import javax.xml.bind.annotation.XmlAccessorType; </xsl:text>
|
---|
721 | <xsl:text>import javax.xml.bind.annotation.XmlType; </xsl:text>
|
---|
722 |
|
---|
723 | <xsl:text>@XmlAccessorType(XmlAccessType.FIELD) </xsl:text>
|
---|
724 | <xsl:value-of select="concat('@XmlType(name = "', $arrayoftype, '", propOrder = { ')" />
|
---|
725 | <xsl:text> "array" </xsl:text>
|
---|
726 | <xsl:text>}) </xsl:text>
|
---|
727 | <xsl:value-of select="concat('public class ', $arrayoftype, ' { ')" />
|
---|
728 |
|
---|
729 | <xsl:text> protected List<String> array; </xsl:text>
|
---|
730 |
|
---|
731 | <xsl:text> public List<String> getArray() { </xsl:text>
|
---|
732 | <xsl:text> if (array == null) { </xsl:text>
|
---|
733 | <xsl:text> array = new ArrayList<String>(); </xsl:text>
|
---|
734 | <xsl:text> } </xsl:text>
|
---|
735 | <xsl:text> return this.array; </xsl:text>
|
---|
736 | <xsl:text> } </xsl:text>
|
---|
737 | <xsl:text>} </xsl:text>
|
---|
738 | <xsl:call-template name="endFile">
|
---|
739 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
740 | </xsl:call-template>
|
---|
741 |
|
---|
742 | </xsl:for-each>
|
---|
743 |
|
---|
744 | <xsl:text>// ######## ENUMS </xsl:text>
|
---|
745 |
|
---|
746 | <xsl:for-each select="//enum">
|
---|
747 | <xsl:variable name="enumname" select="@name" />
|
---|
748 | <xsl:variable name="filename" select="$enumname" />
|
---|
749 |
|
---|
750 | <xsl:call-template name="startFile">
|
---|
751 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
752 | </xsl:call-template>
|
---|
753 |
|
---|
754 | <xsl:text>import javax.xml.bind.annotation.XmlEnum; </xsl:text>
|
---|
755 | <xsl:text>import javax.xml.bind.annotation.XmlEnumValue; </xsl:text>
|
---|
756 | <xsl:text>import javax.xml.bind.annotation.XmlType; </xsl:text>
|
---|
757 |
|
---|
758 | <xsl:value-of select="concat('@XmlType(name = "', $enumname, '") ')" />
|
---|
759 | <xsl:text>@XmlEnum </xsl:text>
|
---|
760 | <xsl:value-of select="concat('public enum ', $enumname, ' { ')" />
|
---|
761 | <xsl:for-each select="const">
|
---|
762 | <xsl:variable name="enumconst" select="@name" />
|
---|
763 | <xsl:value-of select="concat(' @XmlEnumValue("', $enumconst, '") ')" />
|
---|
764 | <xsl:value-of select="concat(' ', $enumconst, '("', $enumconst, '")')" />
|
---|
765 | <xsl:choose>
|
---|
766 | <xsl:when test="not(position()=last())">
|
---|
767 | <xsl:text>, </xsl:text>
|
---|
768 | </xsl:when>
|
---|
769 | <xsl:otherwise>
|
---|
770 | <xsl:text>; </xsl:text>
|
---|
771 | </xsl:otherwise>
|
---|
772 | </xsl:choose>
|
---|
773 | </xsl:for-each>
|
---|
774 |
|
---|
775 | <xsl:text> </xsl:text>
|
---|
776 | <xsl:text> private final String value; </xsl:text>
|
---|
777 |
|
---|
778 | <xsl:value-of select="concat(' ', $enumname, '(String v) { ')" />
|
---|
779 | <xsl:text> value = v; </xsl:text>
|
---|
780 | <xsl:text> } </xsl:text>
|
---|
781 |
|
---|
782 | <xsl:text> public String value() { </xsl:text>
|
---|
783 | <xsl:text> return value; </xsl:text>
|
---|
784 | <xsl:text> } </xsl:text>
|
---|
785 |
|
---|
786 | <xsl:value-of select="concat(' public static ', $enumname, ' fromValue(String v) { ')" />
|
---|
787 | <xsl:value-of select="concat(' for (', $enumname, ' c: ', $enumname, '. values()) { ')" />
|
---|
788 | <xsl:text> if (c.value.equals(v)) { </xsl:text>
|
---|
789 | <xsl:text> return c; </xsl:text>
|
---|
790 | <xsl:text> } </xsl:text>
|
---|
791 | <xsl:text> } </xsl:text>
|
---|
792 | <xsl:text> throw new IllegalArgumentException(v); </xsl:text>
|
---|
793 | <xsl:text> } </xsl:text>
|
---|
794 |
|
---|
795 | <xsl:text>} </xsl:text>
|
---|
796 |
|
---|
797 | <xsl:call-template name="endFile">
|
---|
798 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
799 | </xsl:call-template>
|
---|
800 |
|
---|
801 | </xsl:for-each>
|
---|
802 |
|
---|
803 | <xsl:text>// ######## INTERFACES </xsl:text>
|
---|
804 |
|
---|
805 | <xsl:for-each select="//interface">
|
---|
806 | <xsl:variable name="ifname" select="@name" />
|
---|
807 | <xsl:variable name="filename" select="$ifname" />
|
---|
808 | <xsl:variable name="wsmap" select="@wsmap" />
|
---|
809 | <xsl:variable name="wscpp" select="@wscpp" />
|
---|
810 |
|
---|
811 | <xsl:if test="not($wsmap='suppress') and not($wsmap='struct') and not ($wsmap='global')">
|
---|
812 | <xsl:call-template name="startFile">
|
---|
813 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
814 | </xsl:call-template>
|
---|
815 |
|
---|
816 | <xsl:text>import java.math.BigInteger; </xsl:text>
|
---|
817 | <xsl:text>import java.util.List; </xsl:text>
|
---|
818 | <xsl:text>import java.util.UUID; </xsl:text>
|
---|
819 | <xsl:text>import javax.xml.ws.Holder; </xsl:text>
|
---|
820 | <xsl:text>import javax.xml.ws.WebServiceException; </xsl:text>
|
---|
821 |
|
---|
822 | <xsl:choose>
|
---|
823 | <xsl:when test="$wsmap='struct'">
|
---|
824 |
|
---|
825 | <xsl:value-of select="concat('public class ', $ifname, ' { ')" />
|
---|
826 |
|
---|
827 | </xsl:when>
|
---|
828 |
|
---|
829 | <xsl:otherwise>
|
---|
830 |
|
---|
831 | <!-- interface (class) constructor -->
|
---|
832 | <xsl:value-of select="concat('public class ', $ifname, ' extends IUnknown { ')" />
|
---|
833 | <xsl:value-of select="concat(' public static ', $ifname, ' cast(IUnknown other) { ')" />
|
---|
834 | <xsl:value-of select="concat(' return new ', $ifname,
|
---|
835 | '(other.getRef(), other.getRemoteWSPort()); } ')"/>
|
---|
836 | <xsl:value-of select="concat(' public ', $ifname, '(String _this, VboxPortType port) { ')" />
|
---|
837 | <xsl:text> super(_this,port); </xsl:text>
|
---|
838 | <xsl:text> } </xsl:text>
|
---|
839 |
|
---|
840 | <!-- attributes -->
|
---|
841 | <xsl:for-each select="attribute">
|
---|
842 | <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
843 | <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
|
---|
844 | <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
|
---|
845 | <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
|
---|
846 |
|
---|
847 | <xsl:choose>
|
---|
848 | <xsl:when test="( $attrtype=($G_setSuppressedInterfaces/@name) )">
|
---|
849 | <xsl:value-of select="concat(' // Skipping attribute ', $attrtype, ' for it is of suppressed type ', $attrtype, ' ')" />
|
---|
850 | </xsl:when>
|
---|
851 | <xsl:otherwise>
|
---|
852 | <xsl:choose>
|
---|
853 | <xsl:when test="@readonly='yes'">
|
---|
854 | <xsl:value-of select="concat(' // read-only attribute ', $ifname, '::', $attrname, ' of type ', $attrtype, ' ')" />
|
---|
855 | </xsl:when>
|
---|
856 | <xsl:otherwise>
|
---|
857 | <xsl:value-of select="concat(' // read/write attribute ', $ifname, '::', $attrname, ' of type ', $attrtype, ' ')" />
|
---|
858 | </xsl:otherwise>
|
---|
859 | </xsl:choose>
|
---|
860 | <!-- emit getter method -->
|
---|
861 | <xsl:variable name="gettername"><xsl:call-template name="makeGetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
862 | <xsl:variable name="jaxwsGetter"><xsl:call-template name="makeJaxwsMethod"><xsl:with-param name="ifname" select="$ifname" /><xsl:with-param name="methodname" select="$gettername" /></xsl:call-template></xsl:variable>
|
---|
863 | <xsl:variable name="gluegettertype">
|
---|
864 | <xsl:call-template name="typeIdl2Glue">
|
---|
865 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
866 | <xsl:with-param name="method" select="$gettername" />
|
---|
867 | <xsl:with-param name="name" select="$attrname" />
|
---|
868 | <xsl:with-param name="type" select="$attrtype" />
|
---|
869 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
870 | </xsl:call-template>
|
---|
871 | </xsl:variable>
|
---|
872 | <xsl:variable name="javagettertype">
|
---|
873 | <xsl:call-template name="typeIdl2Java">
|
---|
874 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
875 | <xsl:with-param name="method" select="$gettername" />
|
---|
876 | <xsl:with-param name="name" select="$attrname" />
|
---|
877 | <xsl:with-param name="type" select="$attrtype" />
|
---|
878 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
879 | </xsl:call-template>
|
---|
880 | </xsl:variable>
|
---|
881 | <xsl:value-of select="concat(' public ', $gluegettertype, ' ', $gettername, '() { ')" />
|
---|
882 | <xsl:text> try { </xsl:text>
|
---|
883 | <xsl:value-of select="concat(' ', $javagettertype, ' retVal = port.', $jaxwsGetter, '(_this); ')" />
|
---|
884 | <xsl:variable name="wrapped">
|
---|
885 | <xsl:call-template name="cookOutParam">
|
---|
886 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
887 | <xsl:with-param name="method" select="$gettername" />
|
---|
888 | <xsl:with-param name="value" select="'retVal'" />
|
---|
889 | <xsl:with-param name="idltype" select="$attrtype" />
|
---|
890 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
891 | </xsl:call-template>
|
---|
892 | </xsl:variable>
|
---|
893 | <xsl:value-of select="concat(' return ', $wrapped, '; ')" />
|
---|
894 | <xsl:text> } catch (InvalidObjectFaultMsg e) { </xsl:text>
|
---|
895 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
896 | <xsl:text> } catch (RuntimeFaultMsg e) { </xsl:text>
|
---|
897 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
898 | <xsl:text> } </xsl:text>
|
---|
899 | <xsl:text> } </xsl:text>
|
---|
900 | <xsl:if test="not(@readonly='yes')">
|
---|
901 | <!-- emit setter -->
|
---|
902 | <xsl:variable name="settername"><xsl:call-template name="makeSetterName"><xsl:with-param name="attrname" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
903 | <xsl:variable name="jaxwsSetter"><xsl:call-template name="makeJaxwsMethod"><xsl:with-param name="ifname" select="$ifname" /><xsl:with-param name="methodname" select="$settername" /></xsl:call-template></xsl:variable>
|
---|
904 | <xsl:variable name="javasettertype">
|
---|
905 | <xsl:call-template name="typeIdl2Java">
|
---|
906 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
907 | <xsl:with-param name="method" select="$settername" />
|
---|
908 | <xsl:with-param name="name" select="$attrname" />
|
---|
909 | <xsl:with-param name="type" select="$attrtype" />
|
---|
910 | </xsl:call-template>
|
---|
911 | </xsl:variable>
|
---|
912 | <xsl:value-of select="concat(' public void ', $settername, '(', $javasettertype, ' value) { ')" />
|
---|
913 | <xsl:text> try { </xsl:text>
|
---|
914 | <xsl:value-of select="concat(' port.', $jaxwsSetter, '(_this, value); ')" />
|
---|
915 | <xsl:text> } catch (InvalidObjectFaultMsg e) { </xsl:text>
|
---|
916 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
917 | <xsl:text> } catch (RuntimeFaultMsg e) { </xsl:text>
|
---|
918 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
919 | <xsl:text> } </xsl:text>
|
---|
920 | <xsl:text> } </xsl:text>
|
---|
921 | </xsl:if>
|
---|
922 | </xsl:otherwise>
|
---|
923 | </xsl:choose>
|
---|
924 | </xsl:for-each> <!-- attribute -->
|
---|
925 |
|
---|
926 | <!-- emit real methods -->
|
---|
927 | <xsl:for-each select="method">
|
---|
928 | <xsl:variable name="methodname"><xsl:value-of select="@name" /></xsl:variable>
|
---|
929 | <xsl:variable name="portArg">
|
---|
930 | <xsl:if test="not($wsmap='global')">
|
---|
931 | <xsl:value-of select="'_this'"/>
|
---|
932 | </xsl:if>
|
---|
933 | </xsl:variable>
|
---|
934 |
|
---|
935 | <!-- method header: return value "int", method name, soap arguments -->
|
---|
936 | <!-- skip this method if it has parameters of a type that has wsmap="suppress" -->
|
---|
937 | <xsl:choose>
|
---|
938 | <xsl:when test="param[@type=($G_setSuppressedInterfaces/@name)]">
|
---|
939 | <xsl:comment><xsl:value-of select="concat('Skipping method ', $methodname, ' for it has parameters with suppressed types')" /></xsl:comment>
|
---|
940 | </xsl:when>
|
---|
941 | <xsl:otherwise>
|
---|
942 | <xsl:variable name="fHasReturnParms" select="param[@dir='return']" />
|
---|
943 | <xsl:variable name="fHasOutParms" select="param[@dir='out']" />
|
---|
944 |
|
---|
945 | <xsl:value-of select="concat(' /* method ', $ifname, '::', $methodname, '(')" />
|
---|
946 | <xsl:for-each select="param">
|
---|
947 | <xsl:value-of select="concat(' [', @dir, '] ', @type, ' ', @name)" />
|
---|
948 | <xsl:if test="@safearray='yes'">
|
---|
949 | <xsl:text>[]</xsl:text>
|
---|
950 | </xsl:if>
|
---|
951 | <xsl:if test="not(position()=last())">
|
---|
952 | <xsl:text>,</xsl:text>
|
---|
953 | </xsl:if>
|
---|
954 | </xsl:for-each>
|
---|
955 | <xsl:text>) */ </xsl:text>
|
---|
956 | <!-- method implementation -->
|
---|
957 | <xsl:variable name="returnidltype" select="param[@dir='return']/@type" />
|
---|
958 | <xsl:variable name="returnidlsafearray" select="param[@dir='return']/@safearray" />
|
---|
959 | <xsl:variable name="returngluetype">
|
---|
960 | <xsl:choose>
|
---|
961 | <xsl:when test="$returnidltype">
|
---|
962 | <xsl:call-template name="typeIdl2Glue">
|
---|
963 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
964 | <xsl:with-param name="method" select="$methodname" />
|
---|
965 | <xsl:with-param name="name" select="@name" />
|
---|
966 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
967 | <xsl:with-param name="safearray" select="param[@dir='return']/@safearray" />
|
---|
968 | </xsl:call-template>
|
---|
969 | </xsl:when>
|
---|
970 | <xsl:otherwise>
|
---|
971 | <xsl:text>void</xsl:text>
|
---|
972 | </xsl:otherwise>
|
---|
973 | </xsl:choose>
|
---|
974 | </xsl:variable>
|
---|
975 | <xsl:value-of select="concat(' public ', $returngluetype, ' ', $methodname, '(')" />
|
---|
976 | <!-- make a set of all parameters with in and out direction -->
|
---|
977 | <xsl:variable name="paramsinout" select="param[@dir='in' or @dir='out']" />
|
---|
978 | <xsl:for-each select="exsl:node-set($paramsinout)">
|
---|
979 | <xsl:variable name="paramgluetype">
|
---|
980 | <xsl:call-template name="typeIdl2Glue">
|
---|
981 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
982 | <xsl:with-param name="method" select="$methodname" />
|
---|
983 | <xsl:with-param name="name" select="@name" />
|
---|
984 | <xsl:with-param name="type" select="@type" />
|
---|
985 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
986 | </xsl:call-template>
|
---|
987 | </xsl:variable>
|
---|
988 | <xsl:choose>
|
---|
989 | <xsl:when test="@dir='out'">
|
---|
990 | <xsl:value-of select="concat('Holder<', $paramgluetype, '> ', @name)" />
|
---|
991 | </xsl:when>
|
---|
992 | <xsl:otherwise>
|
---|
993 | <xsl:value-of select="concat($paramgluetype, ' ', @name)" />
|
---|
994 | </xsl:otherwise>
|
---|
995 | </xsl:choose>
|
---|
996 | <xsl:if test="not(position()=last())">
|
---|
997 | <xsl:text>, </xsl:text>
|
---|
998 | </xsl:if>
|
---|
999 | </xsl:for-each>
|
---|
1000 | <xsl:text>) { </xsl:text>
|
---|
1001 | <xsl:text> try { </xsl:text>
|
---|
1002 | <xsl:if test="param[@dir='out']">
|
---|
1003 | <xsl:for-each select="param[@dir='out']">
|
---|
1004 | <xsl:variable name="paramtype" select="@type" />
|
---|
1005 | <xsl:if test="//interface[@name=$paramtype] or $paramtype='$unknown'">
|
---|
1006 | <xsl:choose>
|
---|
1007 | <xsl:when test="@safearray='yes'">
|
---|
1008 | <xsl:value-of select="concat(' Holder<List<String>> tmp', @name, ' = new Holder<List<String>>(); ')" />
|
---|
1009 | </xsl:when>
|
---|
1010 | <xsl:otherwise>
|
---|
1011 | <xsl:value-of select="concat(' Holder<String> tmp', @name, ' = new Holder<String>(); ')" />
|
---|
1012 | </xsl:otherwise>
|
---|
1013 | </xsl:choose>
|
---|
1014 | </xsl:if>
|
---|
1015 | </xsl:for-each>
|
---|
1016 | </xsl:if>
|
---|
1017 |
|
---|
1018 | <xsl:text> </xsl:text>
|
---|
1019 |
|
---|
1020 | <!-- make the function call: first have a stack variable for the return value, if any -->
|
---|
1021 | <!-- XSLT doesn't allow variable override in inner blocks -->
|
---|
1022 | <xsl:variable name="retValValue">
|
---|
1023 | <xsl:choose>
|
---|
1024 | <xsl:when test="param[@dir='out']">
|
---|
1025 | <xsl:value-of select="'retVal.value'"/>
|
---|
1026 | </xsl:when>
|
---|
1027 | <xsl:otherwise>
|
---|
1028 | <xsl:value-of select="'retVal'"/>
|
---|
1029 | </xsl:otherwise>
|
---|
1030 | </xsl:choose>
|
---|
1031 | </xsl:variable>
|
---|
1032 |
|
---|
1033 | <xsl:if test="$returnidltype">
|
---|
1034 | <xsl:variable name="javarettype">
|
---|
1035 | <xsl:call-template name="typeIdl2Java">
|
---|
1036 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1037 | <xsl:with-param name="method" select="$methodname" />
|
---|
1038 | <xsl:with-param name="name" select="@name" />
|
---|
1039 | <xsl:with-param name="type" select="$returnidltype" />
|
---|
1040 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
1041 | </xsl:call-template>
|
---|
1042 | </xsl:variable>
|
---|
1043 | <xsl:choose>
|
---|
1044 | <xsl:when test="param[@dir='out']">
|
---|
1045 | <!-- create a new object for return value -->
|
---|
1046 | <xsl:value-of select="
|
---|
1047 | concat('Holder<', $javarettype, '>',
|
---|
1048 | ' ', 'retVal = new Holder<', $javarettype,
|
---|
1049 | '>();
 ')"/>
|
---|
1050 | </xsl:when>
|
---|
1051 | <xsl:otherwise>
|
---|
1052 | <xsl:value-of select="$javarettype"/>
|
---|
1053 | <xsl:text> retVal = </xsl:text>
|
---|
1054 | </xsl:otherwise>
|
---|
1055 | </xsl:choose>
|
---|
1056 | </xsl:if>
|
---|
1057 | <!-- function name and arguments -->
|
---|
1058 | <xsl:variable name="jaxwsmethod"><xsl:call-template name="makeJaxwsMethod"><xsl:with-param name="ifname" select="$ifname" /><xsl:with-param name="methodname" select="$methodname" /></xsl:call-template></xsl:variable>
|
---|
1059 | <xsl:value-of select="concat('port.', $jaxwsmethod, '(', $portArg)" />
|
---|
1060 | <xsl:if test="$paramsinout and not($portArg='')">
|
---|
1061 | <xsl:text>, </xsl:text>
|
---|
1062 | </xsl:if>
|
---|
1063 | <!-- jax-ws has an oddity: if both out params and a return value exist, then the return value is moved to the function's argument list... -->
|
---|
1064 | <xsl:choose>
|
---|
1065 | <xsl:when test="param[@dir='out'] and param[@dir='return']">
|
---|
1066 | <xsl:for-each select="param">
|
---|
1067 | <xsl:choose>
|
---|
1068 | <xsl:when test="@dir='return'">
|
---|
1069 | <xsl:text>retVal</xsl:text>
|
---|
1070 | </xsl:when>
|
---|
1071 | <xsl:otherwise>
|
---|
1072 | <xsl:call-template name="emitArgInMethodImpl">
|
---|
1073 | <xsl:with-param name="paramname" select="@name" />
|
---|
1074 | <xsl:with-param name="paramtype" select="@type" />
|
---|
1075 | </xsl:call-template>
|
---|
1076 | </xsl:otherwise>
|
---|
1077 | </xsl:choose>
|
---|
1078 | </xsl:for-each>
|
---|
1079 | </xsl:when>
|
---|
1080 | <xsl:otherwise>
|
---|
1081 | <xsl:for-each select="$paramsinout">
|
---|
1082 | <xsl:call-template name="emitArgInMethodImpl">
|
---|
1083 | <xsl:with-param name="paramname" select="@name" />
|
---|
1084 | <xsl:with-param name="paramtype" select="@type" />
|
---|
1085 | </xsl:call-template>
|
---|
1086 | </xsl:for-each>
|
---|
1087 | </xsl:otherwise>
|
---|
1088 | </xsl:choose>
|
---|
1089 | <xsl:text>); </xsl:text>
|
---|
1090 | <!-- now copy temp out parameters to their actual destination -->
|
---|
1091 | <xsl:for-each select="param[@dir='out']">
|
---|
1092 | <xsl:variable name="paramtype" select="@type" />
|
---|
1093 | <xsl:if test="//interface[@name=$paramtype] or $paramtype='$unknown'">
|
---|
1094 | <xsl:variable name="paramname" select="@name" />
|
---|
1095 | <xsl:variable name="wrapped">
|
---|
1096 | <xsl:call-template name="cookOutParam">
|
---|
1097 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1098 | <xsl:with-param name="method" select="$methodname" />
|
---|
1099 | <xsl:with-param name="value" select="concat('tmp',@name,'.value')" />
|
---|
1100 | <xsl:with-param name="idltype" select="@type" />
|
---|
1101 | <xsl:with-param name="safearray" select="@safearray" />
|
---|
1102 | </xsl:call-template>
|
---|
1103 | </xsl:variable>
|
---|
1104 | <xsl:value-of select="concat(' ',$paramname,'.value = ',
|
---|
1105 | $wrapped,'; ')"/>
|
---|
1106 | </xsl:if>
|
---|
1107 | </xsl:for-each>
|
---|
1108 | <!-- next line with return + glue type -->
|
---|
1109 | <xsl:if test="$returnidltype">
|
---|
1110 | <xsl:variable name="retval">
|
---|
1111 | <xsl:call-template name="cookOutParam">
|
---|
1112 | <xsl:with-param name="ifname" select="$ifname" />
|
---|
1113 | <xsl:with-param name="method" select="$methodname" />
|
---|
1114 | <xsl:with-param name="value" select="$retValValue" />
|
---|
1115 | <xsl:with-param name="idltype" select="$returnidltype" />
|
---|
1116 | <xsl:with-param name="safearray" select="$returnidlsafearray" />
|
---|
1117 | </xsl:call-template>
|
---|
1118 | </xsl:variable>
|
---|
1119 | <xsl:value-of select="concat(' return ', $retval, '; ')"/>
|
---|
1120 | </xsl:if>
|
---|
1121 | <xsl:text> } catch (InvalidObjectFaultMsg e) { </xsl:text>
|
---|
1122 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
1123 | <xsl:text> } catch (RuntimeFaultMsg e) { </xsl:text>
|
---|
1124 | <xsl:text> throw new WebServiceException(e); </xsl:text>
|
---|
1125 | <xsl:text> } </xsl:text>
|
---|
1126 | <xsl:text> } </xsl:text>
|
---|
1127 | </xsl:otherwise>
|
---|
1128 | </xsl:choose>
|
---|
1129 | </xsl:for-each>
|
---|
1130 |
|
---|
1131 | </xsl:otherwise>
|
---|
1132 | </xsl:choose>
|
---|
1133 | <!-- end of class -->
|
---|
1134 | <xsl:text>} </xsl:text>
|
---|
1135 | <xsl:value-of select="concat(' // ##### ENDFILE "', $filename, '.java" ')" />
|
---|
1136 | <xsl:call-template name="endFile">
|
---|
1137 | <xsl:with-param name="file" select="concat($filename, '.java')" />
|
---|
1138 | </xsl:call-template>
|
---|
1139 | </xsl:if>
|
---|
1140 | </xsl:for-each>
|
---|
1141 |
|
---|
1142 | <!-- <xsl:apply-templates /> -->
|
---|
1143 | </xsl:template>
|
---|
1144 |
|
---|
1145 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1146 | if
|
---|
1147 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1148 |
|
---|
1149 | <!--
|
---|
1150 | * ignore all |if|s except those for WSDL target
|
---|
1151 | -->
|
---|
1152 | <xsl:template match="if">
|
---|
1153 | <xsl:if test="@target='wsdl'">
|
---|
1154 | <xsl:apply-templates/>
|
---|
1155 | </xsl:if>
|
---|
1156 | </xsl:template>
|
---|
1157 |
|
---|
1158 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1159 | cpp
|
---|
1160 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1161 |
|
---|
1162 | <xsl:template match="cpp">
|
---|
1163 | <!-- ignore this -->
|
---|
1164 | </xsl:template>
|
---|
1165 |
|
---|
1166 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1167 | library
|
---|
1168 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1169 |
|
---|
1170 | <xsl:template match="library">
|
---|
1171 | <xsl:apply-templates />
|
---|
1172 | </xsl:template>
|
---|
1173 |
|
---|
1174 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1175 | class
|
---|
1176 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1177 |
|
---|
1178 | <xsl:template match="module/class">
|
---|
1179 | <!-- TODO swallow for now -->
|
---|
1180 | </xsl:template>
|
---|
1181 |
|
---|
1182 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1183 | enum
|
---|
1184 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1185 |
|
---|
1186 | <xsl:template match="enum">
|
---|
1187 | </xsl:template>
|
---|
1188 |
|
---|
1189 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1190 | const
|
---|
1191 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1192 |
|
---|
1193 | <!--
|
---|
1194 | <xsl:template match="const">
|
---|
1195 | <xsl:apply-templates />
|
---|
1196 | </xsl:template>
|
---|
1197 | -->
|
---|
1198 |
|
---|
1199 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1200 | desc
|
---|
1201 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1202 |
|
---|
1203 | <xsl:template match="desc">
|
---|
1204 | <!-- TODO swallow for now -->
|
---|
1205 | </xsl:template>
|
---|
1206 |
|
---|
1207 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1208 | note
|
---|
1209 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1210 |
|
---|
1211 | <xsl:template match="note">
|
---|
1212 | <!-- TODO -->
|
---|
1213 | <xsl:apply-templates />
|
---|
1214 | </xsl:template>
|
---|
1215 |
|
---|
1216 | <!-- - - - - - - - - - - - - - - - - - - - - - -
|
---|
1217 | interface
|
---|
1218 | - - - - - - - - - - - - - - - - - - - - - - -->
|
---|
1219 |
|
---|
1220 | <xsl:template match="interface">
|
---|
1221 |
|
---|
1222 | </xsl:template>
|
---|
1223 |
|
---|
1224 |
|
---|
1225 | </xsl:stylesheet>
|
---|