/** * Copyright (C) 2006-2008 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. * * This file is autogenerated by glue-jaxws.xsl, DO NOT EDIT! */ String Boolean Integer Integer Long Long BigInteger Long UUID IUnknown String Boolean int Integer Long Long BigInteger Long String String String , List wrap(Class wrapperClass, VboxPortType pt, List thisPtrs) { try { if(thisPtrs==null) return Collections.emptyList(); Constructor c = wrapperClass.getConstructor(String.class, VboxPortType.class); List ret = new ArrayList(thisPtrs.size()); for (String thisPtr : thisPtrs) { ret.add(c.newInstance(thisPtr,pt)); } return ret; } catch (NoSuchMethodException e) { throw new AssertionError(e); } catch (InstantiationException e) { throw new AssertionError(e); } catch (IllegalAccessException e) { throw new AssertionError(e); } catch (InvocationTargetException e) { throw new AssertionError(e); } } public static List uuidWrap(List uuidVals) { List ret = new ArrayList(uuidVals.size()); for (String uuid : uuidVals) { ret.add(UUID.fromString(uuid)); } return ret; } public static List unwrap(List thisPtrs) { if (thisPtrs==null) return Collections.emptyList(); List ret = new ArrayList(); for (T obj : thisPtrs) { ret.add(obj.getRef()); } return ret; } } // ##### ENDFILE "Helper.java" // ##### BEGINFILE "IWebsessionManager.java" /** * Copyright (C) 2006-2008 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. * * This file is autogenerated by glue-jaxws.xsl, DO NOT EDIT! */ package com.sun.xml.ws.commons.virtualbox; import java.net.URL; import java.math.BigInteger; import java.util.List; import java.util.Map; import java.util.HashMap; import java.util.UUID; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceException; import com.sun.xml.ws.commons.virtualbox.IUnknown; import org.virtualbox.service.InvalidObjectFaultMsg; import org.virtualbox.service.RuntimeFaultMsg; import org.virtualbox.service.VboxService; import org.virtualbox.service.VboxPortType; class PortPool { private Map known; private boolean initStarted; private VboxService svc; PortPool(boolean usePreinit) { known = new HashMap(); if (usePreinit) { new Thread(new Runnable() { public void run() { // need to sync on something else but 'this' synchronized (known) { initStarted = true; known.notify(); } preinit(); } }).start(); synchronized (known) { while (!initStarted) { try { known.wait(); } catch (InterruptedException e) { break; } } } } } private synchronized void preinit() { VboxPortType port = getPort(); releasePort(port); } synchronized VboxPortType getPort() { VboxPortType port = null; for (VboxPortType cur: known.keySet()) { if (known.get(cur) == 0) { port = cur; break; } } if (port == null) { if (svc == null) { URL wsdl = PortPool.class.getClassLoader().getResource("vboxwebService.wsdl"); if (wsdl == null) throw new LinkageError("vboxwebService.wsdl not found, but it should have been in the jar"); svc = new VboxService(wsdl, new QName("http://www.virtualbox.org/Service", "vboxService")); } port = svc.getVboxServicePort(); } known.put(port, new Integer(1)); return port; } synchronized void releasePort(VboxPortType port) { Integer val = known.get(port); if (val == null || val == 0) { // know you not return; } known.put(port, val - 1); } } public class IWebsessionManager { private static PortPool pool = new PortPool(true); protected VboxPortType port; public IWebsessionManager(URL url) { connect(url); } public IWebsessionManager(String url) { connect(url); } public IWebsessionManager(URL url, Map requestContext, Map responseContext) { connect(url.toExternalForm(), requestContext, responseContext); } public IWebsessionManager(String url, Map requestContext, Map responseContext) { connect(url, requestContext, responseContext); } public void connect(URL url) { connect(url.toExternalForm()); } public void connect(String url) { this.port = pool.getPort(); ((BindingProvider)port).getRequestContext(). put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); } public void connect(String url, Map requestContext, Map responseContext) { this.port = pool.getPort(); ((BindingProvider)port).getRequestContext(); if (requestContext != null) ((BindingProvider)port).getRequestContext().putAll(requestContext); if (responseContext != null) ((BindingProvider)port).getResponseContext().putAll(responseContext); ((BindingProvider)port).getRequestContext(). put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); } public void disconnect(com.sun.xml.ws.commons.virtualbox.IVirtualBox refIVirtualBox) { logoff(refIVirtualBox); pool.releasePort(port); } public void cleanupUnused() { System.gc(); Runtime.getRuntime().runFinalization(); } /* method IWebsessionManager::logon( [in] wstring username, [in] wstring password, [return] IVirtualBox return) */ public com.sun.xml.ws.commons.virtualbox.IVirtualBox logon(String username, String password) { try { String retVal = port.iWebsessionManagerLogon(username, password); return new com.sun.xml.ws.commons.virtualbox.IVirtualBox(retVal, port); } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } /* method IWebsessionManager::getSessionObject( [in] IVirtualBox refIVirtualBox, [return] ISession return) */ public com.sun.xml.ws.commons.virtualbox.ISession getSessionObject(com.sun.xml.ws.commons.virtualbox.IVirtualBox refIVirtualBox) { try { String retVal = port.iWebsessionManagerGetSessionObject(((refIVirtualBox == null)?null:refIVirtualBox.getRef())); return new com.sun.xml.ws.commons.virtualbox.ISession(retVal, port); } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } /* method IWebsessionManager::logoff( [in] IVirtualBox refIVirtualBox) */ public void logoff(com.sun.xml.ws.commons.virtualbox.IVirtualBox refIVirtualBox) { try { port.iWebsessionManagerLogoff(((refIVirtualBox == null)?null:refIVirtualBox.getRef())); } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } } // ##### ENDFILE "IWebsessionManager.java" ]]> // ######## COLLECTIONS package com.sun.xml.ws.commons.virtualbox; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) "array" }) protected List<String> array; public List<String> getArray() { if (array == null) { array = new ArrayList<String>(); } return this.array; } } // ######## ENUMS package com.sun.xml.ws.commons.virtualbox; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; @XmlEnum , ; private final String value; value = v; } public String value() { return value; } if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } } // ######## INTERFACES package com.sun.xml.ws.commons.virtualbox; import java.math.BigInteger; import java.util.List; import java.util.UUID; import javax.xml.ws.Holder; import javax.xml.ws.WebServiceException; import com.sun.xml.ws.commons.virtualbox.IUnknown; import org.virtualbox.service.InvalidObjectFaultMsg; import org.virtualbox.service.RuntimeFaultMsg; import org.virtualbox.service.VboxService; import org.virtualbox.service.VboxPortType; super(_this,port); } try { } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } try { } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } [] , ) */ void , ) { try { retVal = , retVal ); } catch (InvalidObjectFaultMsg e) { throw new WebServiceException(e); } catch (RuntimeFaultMsg e) { throw new WebServiceException(e); } } }