~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Main/webservice/glue-jaxws.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
      <xsl:when test="$collPrefix and //interface[@name=$origname]/@wsmap='managed'">
112
112
         <xsl:value-of select="concat($G_virtualBoxPackage, concat('.', $name))" />
113
113
      </xsl:when>
114
 
     <xsl:when test="//interface[@name=$name]/@wsmap='struct' or //interface[@name=$origname]/@wsmap='struct'">
115
 
       <xsl:value-of select="concat($G_virtualBoxPackage,  concat('.', $name))" />
116
 
     </xsl:when>
117
114
     <xsl:when test="//interface[@name=$name]">
118
115
       <xsl:value-of select="concat($G_virtualBoxPackage2,  concat('.', $name))" />
119
116
     </xsl:when>
177
174
  <xsl:param name="name" />
178
175
  <xsl:param name="type" />
179
176
  <xsl:param name="safearray" />
180
 
 
181
 
  <xsl:if test="$safearray">
 
177
  <xsl:param name="forceelem" />
 
178
 
 
179
  <xsl:variable name="needarray" select="($safearray='yes') and not($forceelem='yes')" />
 
180
 
 
181
  <xsl:if test="$needarray">
182
182
    <xsl:value-of select="'List&lt;'" />
183
183
  </xsl:if>
184
184
 
190
190
      <xsl:value-of select="$javatypefield" />
191
191
    </xsl:when>
192
192
    <xsl:when test="$type='$unknown'">String</xsl:when>
 
193
    <xsl:when test="//interface[@name=$type]/@wsmap='struct'">
 
194
      <xsl:value-of select="concat($G_virtualBoxPackage, '.', $type)" />
 
195
    </xsl:when>
193
196
    <xsl:when test="//interface[@name=$type]/@wsmap='managed'">String</xsl:when>
194
197
    <xsl:otherwise>
195
198
      <xsl:call-template name="fullClassName">
198
201
      </xsl:call-template>
199
202
    </xsl:otherwise>
200
203
  </xsl:choose>
201
 
  <xsl:if test="$safearray">
 
204
  <xsl:if test="$needarray">
202
205
    <xsl:value-of select="'&gt;'" />
203
206
  </xsl:if>
204
207
</xsl:template>
209
212
  <xsl:param name="value"/>
210
213
  <xsl:param name="idltype"/>
211
214
  <xsl:param name="safearray"/>
 
215
  <xsl:variable name="isstruct"
 
216
                select="//interface[@name=$idltype]/@wsmap='struct'" />
212
217
  <xsl:choose>
213
218
    <xsl:when test="//collection[@name=$idltype]">
214
219
      <xsl:variable name="elemtype">
232
237
    </xsl:when>
233
238
    <xsl:when test="//interface[@name=$idltype] or $idltype='$unknown'">
234
239
      <xsl:choose>
235
 
        <xsl:when test="//interface[@name=$idltype]/@wsmap='struct' and $safearray='yes'">
236
 
          <xsl:value-of select="concat('/* 2 */', $value)" />
237
 
        </xsl:when>
238
 
        <xsl:when test="//interface[@name=$idltype]/@wsmap='struct'">
239
 
          <xsl:value-of select="$value" />
240
 
        </xsl:when>
241
240
        <xsl:when test="$safearray='yes'">
242
241
          <xsl:variable name="elemtype">
243
242
            <xsl:call-template name="typeIdl2Glue">
249
248
              <xsl:with-param name="forceelem" select="'yes'" />
250
249
            </xsl:call-template>
251
250
          </xsl:variable>
252
 
          <xsl:value-of select="concat('Helper.wrap(',$elemtype, '.class, port, ', $value,')')"/>
 
251
          <xsl:choose>
 
252
            <xsl:when test="$isstruct">
 
253
              <xsl:variable name="javagettertype">
 
254
                <xsl:call-template name="typeIdl2Java">
 
255
                  <xsl:with-param name="method" select="$methodname" />
 
256
                  <xsl:with-param name="name" select="$value" />
 
257
                  <xsl:with-param name="type" select="$idltype" />
 
258
                  <xsl:with-param name="safearray" select="$safearray" />
 
259
                  <xsl:with-param name="forceelem" select="'yes'" />
 
260
                </xsl:call-template>
 
261
              </xsl:variable>
 
262
              <xsl:value-of select="concat('Helper.wrap2(',$elemtype, '.class, ', $javagettertype, '.class, port, ', $value,')')"/>
 
263
            </xsl:when>
 
264
            <xsl:otherwise>
 
265
              <xsl:value-of select="concat('Helper.wrap(',$elemtype, '.class, port, ', $value,')')"/>
 
266
            </xsl:otherwise>
 
267
          </xsl:choose>
253
268
        </xsl:when>
254
269
        <xsl:otherwise>
255
270
           <xsl:variable name="gluetype">
261
276
               <xsl:with-param name="safearray" select="$safearray" />
262
277
             </xsl:call-template>
263
278
           </xsl:variable>
264
 
           <!-- if the MOR string is empty, that means NULL, so return NULL instead of an object then -->
265
 
           <xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value,', port) : null')" />
 
279
           <xsl:choose>
 
280
             <xsl:when test="$isstruct">
 
281
               <xsl:value-of select="concat('(', $value, ' != null) ? new ', $gluetype, '(', $value,', port) : null')" />
 
282
             </xsl:when>
 
283
              <xsl:otherwise>
 
284
                <!-- if the MOR string is empty, that means NULL, so return NULL instead of an object then -->
 
285
                <xsl:value-of select="concat('(', $value, '.length() > 0) ? new ', $gluetype, '(', $value,', port) : null')" />
 
286
              </xsl:otherwise>
 
287
           </xsl:choose>
266
288
        </xsl:otherwise>
267
289
      </xsl:choose>
268
290
    </xsl:when>
272
294
  </xsl:choose>
273
295
</xsl:template>
274
296
 
 
297
<xsl:template name="genStructWrapper">
 
298
  <xsl:param name="ifname" select="@name" />
 
299
 
 
300
  <xsl:value-of select="concat('    private ', $G_virtualBoxPackage,'.',$ifname, ' real;&#10;')"/>
 
301
  <xsl:value-of select="'    private VboxPortType port;&#10;&#10;'"/>
 
302
 
 
303
   <xsl:value-of select="concat('    public ', $ifname, '(', $G_virtualBoxPackage,'.',$ifname,' real, VboxPortType port) {&#10;      this.real = real; &#10;      this.port = port;  &#10;    }&#10;')"/>
 
304
  <xsl:for-each select="attribute">
 
305
    <xsl:variable name="attrname"><xsl:value-of select="@name" /></xsl:variable>
 
306
    <xsl:variable name="attrtype"><xsl:value-of select="@type" /></xsl:variable>
 
307
    <xsl:variable name="attrreadonly"><xsl:value-of select="@readonly" /></xsl:variable>
 
308
    <xsl:variable name="attrsafearray"><xsl:value-of select="@safearray" /></xsl:variable>
 
309
     <xsl:choose>
 
310
       <xsl:when test="$attrreadonly='yes'">
 
311
         <xsl:value-of select="concat('&#10;    // read-only attribute ', $ifname, '::', $attrname, ' of type ', $attrtype, '&#10;')" />
 
312
 
 
313
       </xsl:when>
 
314
       <xsl:otherwise>
 
315
         <xsl:value-of select="concat('&#10;    // read/write attribute ', $ifname, '::', $attrname, ' of type ', $attrtype, '&#10;')" />
 
316
       </xsl:otherwise>
 
317
     </xsl:choose>
 
318
 
 
319
     <!-- emit getter method -->
 
320
     <xsl:variable name="gettername">
 
321
       <xsl:choose>
 
322
         <!-- Stupid, but boolean getters called isFoo(), not getFoo() -->
 
323
         <xsl:when test="$attrtype = 'boolean'">
 
324
           <xsl:variable name="capsname">
 
325
             <xsl:call-template name="capitalize">
 
326
               <xsl:with-param name="str" select="$attrname" />
 
327
             </xsl:call-template>
 
328
           </xsl:variable>
 
329
           <xsl:value-of select="concat('is', $capsname)" />
 
330
         </xsl:when>
 
331
         <xsl:otherwise>
 
332
           <xsl:call-template name="makeGetterName">
 
333
             <xsl:with-param name="attrname" select="$attrname" />
 
334
           </xsl:call-template>
 
335
         </xsl:otherwise>
 
336
       </xsl:choose>
 
337
     </xsl:variable>
 
338
     <xsl:variable name="gluegettertype">
 
339
       <xsl:call-template name="typeIdl2Glue">
 
340
         <xsl:with-param name="ifname" select="$ifname" />
 
341
         <xsl:with-param name="method" select="$gettername" />
 
342
         <xsl:with-param name="name" select="$attrname" />
 
343
         <xsl:with-param name="type" select="$attrtype" />
 
344
         <xsl:with-param name="safearray" select="@safearray" />
 
345
       </xsl:call-template>
 
346
     </xsl:variable>
 
347
     <xsl:variable name="javagettertype">
 
348
       <xsl:call-template name="typeIdl2Java">
 
349
         <xsl:with-param name="ifname" select="$ifname" />
 
350
         <xsl:with-param name="method" select="$gettername" />
 
351
         <xsl:with-param name="name" select="$attrname" />
 
352
         <xsl:with-param name="type" select="$attrtype" />
 
353
         <xsl:with-param name="safearray" select="@safearray" />
 
354
       </xsl:call-template>
 
355
     </xsl:variable>
 
356
     <xsl:value-of select="concat('    public ', $gluegettertype, ' ', $gettername, '() {&#10;')" />
 
357
     <xsl:value-of select="concat('            ', $javagettertype, ' retVal = real.', $gettername, '();&#10;')" />
 
358
     <xsl:variable name="wrapped">
 
359
       <xsl:call-template name="cookOutParam">
 
360
         <xsl:with-param name="ifname" select="$ifname" />
 
361
         <xsl:with-param name="method" select="$gettername" />
 
362
         <xsl:with-param name="value" select="'retVal'" />
 
363
         <xsl:with-param name="idltype" select="$attrtype" />
 
364
         <xsl:with-param name="safearray" select="@safearray" />
 
365
       </xsl:call-template>
 
366
     </xsl:variable>
 
367
     <xsl:value-of select="concat('            return ', $wrapped, ';&#10;')" />
 
368
     <xsl:text>    }&#10;</xsl:text>
 
369
 
 
370
  </xsl:for-each>
 
371
 
 
372
</xsl:template>
 
373
 
 
374
 
275
375
<xsl:template name="emitArgInMethodImpl">
276
376
  <xsl:param name="paramname" select="@name" />
277
377
  <xsl:param name="paramtype" select="@type" />
402
502
import java.util.List;
403
503
import java.util.ArrayList;
404
504
import java.util.Collections;
405
 
import java.util.UUID;
406
505
import java.lang.reflect.Constructor;
407
506
import java.lang.reflect.InvocationTargetException;
408
507
 
428
527
        }
429
528
    }
430
529
 
 
530
    public static <T1, T2> List<T1> wrap2(Class<T1> wrapperClass1, Class<T2> wrapperClass2, VboxPortType pt, List<T2> thisPtrs) {
 
531
        try {
 
532
            if(thisPtrs==null)  return Collections.emptyList();
 
533
 
 
534
            Constructor<T1> c = wrapperClass1.getConstructor(wrapperClass2, VboxPortType.class);
 
535
            List<T1> ret = new ArrayList<T1>(thisPtrs.size());
 
536
            for (T2 thisPtr : thisPtrs) {
 
537
                ret.add(c.newInstance(thisPtr,pt));
 
538
            }
 
539
            return ret;
 
540
        } catch (NoSuchMethodException e) {
 
541
            throw new AssertionError(e);
 
542
        } catch (InstantiationException e) {
 
543
            throw new AssertionError(e);
 
544
        } catch (IllegalAccessException e) {
 
545
            throw new AssertionError(e);
 
546
        } catch (InvocationTargetException e) {
 
547
            throw new AssertionError(e);
 
548
        }
 
549
    }
 
550
 
431
551
    public static <T extends IUnknown> List<String> unwrap(List<T> thisPtrs) {
432
552
        if (thisPtrs==null)  return Collections.emptyList();
433
553
 
454
574
import java.util.List;
455
575
import java.util.Map;
456
576
import java.util.HashMap;
457
 
import java.util.UUID;
458
577
import javax.xml.namespace.QName;
459
578
import javax.xml.ws.BindingProvider;
460
579
import javax.xml.ws.Holder;
547
666
 
548
667
    synchronized void releasePort(VboxPortType port)
549
668
    {
550
 
        Integer val =  known.get(port);
 
669
        Integer val = known.get(port);
551
670
        if (val == null || val == 0)
552
671
        {
553
672
            // know you not
554
673
            return;
555
674
        }
 
675
 
556
676
        int v = val;
557
677
        int ttl = v & 0xffff;
558
678
        // decrement TTL, and throw away port if used too much times
601
721
    public void connect(String url)
602
722
    {
603
723
        this.port = pool.getPort();
604
 
        try {
 
724
 
 
725
         try {
605
726
          ((BindingProvider)port).getRequestContext().
606
 
                put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
607
 
        }  catch (Throwable t) {
 
727
                 put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
 
728
         }  catch (Throwable t) {
608
729
             if (this.port != null)
609
730
                pool.releasePort(this.port);
610
731
             // we have to throw smth derived from RuntimeException
611
732
             throw new WebServiceException(t);
612
 
        }
 
733
          }
613
734
    }
614
735
 
615
736
    public void connect(String url, Map<String, Object> requestContext, Map<String, Object> responseContext)
617
738
         this.port = pool.getPort();
618
739
 
619
740
         try {
620
 
            ((BindingProvider)port).getRequestContext();
621
 
            if (requestContext != null)
 
741
           ((BindingProvider)port).getRequestContext();
 
742
           if (requestContext != null)
622
743
               ((BindingProvider)port).getRequestContext().putAll(requestContext);
623
744
 
624
 
            if (responseContext != null)
 
745
           if (responseContext != null)
625
746
               ((BindingProvider)port).getResponseContext().putAll(responseContext);
626
747
 
627
 
            ((BindingProvider)port).getRequestContext().
 
748
           ((BindingProvider)port).getRequestContext().
628
749
                put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
629
 
         } catch (Throwable t) {
 
750
          } catch (Throwable t) {
630
751
             if (this.port != null)
631
752
                pool.releasePort(port);
632
753
             // we have to throw smth derived from RuntimeException
809
930
    <xsl:variable name="wsmap" select="@wsmap" />
810
931
    <xsl:variable name="wscpp" select="@wscpp" />
811
932
 
812
 
    <xsl:if test="not($wsmap='suppress') and not($wsmap='struct') and not ($wsmap='global')">
 
933
    <xsl:if test="not($wsmap='suppress') and not ($wsmap='global')">
813
934
      <xsl:call-template name="startFile">
814
935
        <xsl:with-param name="file" select="concat($filename, '.java')" />
815
936
      </xsl:call-template>
816
937
 
817
938
      <xsl:text>import java.math.BigInteger;&#10;</xsl:text>
818
939
      <xsl:text>import java.util.List;&#10;</xsl:text>
819
 
      <xsl:text>import java.util.UUID;&#10;</xsl:text>
820
940
      <xsl:text>import javax.xml.ws.Holder;&#10;</xsl:text>
821
941
      <xsl:text>import javax.xml.ws.WebServiceException;&#10;</xsl:text>
822
942
 
823
943
      <xsl:choose>
824
944
        <xsl:when test="$wsmap='struct'">
825
 
 
826
945
          <xsl:value-of select="concat('public class ', $ifname, ' {&#10;&#10;')" />
827
 
 
 
946
           <xsl:call-template name="genStructWrapper">
 
947
             <xsl:with-param name="name" select="$ifname" />
 
948
           </xsl:call-template>
828
949
        </xsl:when>
829
950
 
830
951
        <xsl:otherwise>
831
 
 
832
952
          <xsl:variable name="extends" select="//interface[@name=$ifname]/@extends" />
833
953
          <xsl:choose>
834
954
            <xsl:when test="($extends = '$unknown') or ($extends = '$dispatched') or ($extends = '$errorinfo')">