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