Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  /*
   *  Copyright (C) 2010-2011 Oracle Corporation
   *
   *  This file is part of the VirtualBox SDK, as available from
   *  http://www.virtualbox.org.  This library is free software; you can
   *  redistribute it and/or modify it under the terms of the GNU Lesser General
   *  Public License as published by the Free Software Foundation, in version 2.1
   *  as it comes in the "COPYING.LIB" file of the VirtualBox SDK distribution.
  *  This library is distributed in the hope that it will be useful, but WITHOUT
  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
  *  License for more details.
  *
  * IEventSource.java
  *
  * DO NOT EDIT! This is a generated file.
  * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
  * Generator: src/VBox/Main/glue/glue-java.xsl
  */
 
 package org.virtualbox_4_2;
 
 import javax.xml.ws.*;
 import java.util.List;

Event source. Generally, any object which could generate events can be an event source, or aggregate one. To simplify using one-way protocols such as webservices running on top of HTTP(S), an event source can work with listeners in either active or passive mode. In active mode it is up to the IEventSource implementation to call IEventListener.handleEvent(org.virtualbox_4_2.IEvent), in passive mode the event source keeps track of pending events for each listener and returns available events on demand. See IEvent for an introduction to VirtualBox event handling. Interface ID: {9B6E1AEE-35F3-4F4D-B5BB-ED0ECEFD8538}
 
 public class IEventSource extends IUnknown {
 
     public IEventSource(String wrappedVboxPortType port) {
           super(wrappedport);
     }
     public static IEventSource queryInterface(IUnknown obj) {
        return obj == null ?  null : new IEventSource(obj.getWrapped(), obj.getRemoteWSPort());
     }
Creates a new listener object, useful for passive mode.
 
       try {
         String     retVal;
         retVal = .iEventSourceCreateListener();
         return (retVal.length() > 0) ? new org.virtualbox_4_2.IEventListener(retVal) : null;
      } catch (InvalidObjectFaultMsg e) {
           throw new VBoxException(ee.getMessage());
      } catch (RuntimeFaultMsg e) {
           throw new VBoxException(ee.getMessage());
      }
     }
Creates an aggregator event source, collecting events from multiple sources. This way a single listener can listen for events coming from multiple sources, using a single blocking getEvent(org.virtualbox_4_2.IEventListener,java.lang.Integer) on the returned aggregator.

Parameters:
subordinates Subordinate event source this one aggregatres.
Returns:
Event source aggregating passed sources.
 
       try {
         String     retVal;
         retVal = .iEventSourceCreateAggregator(, Helper.unwrap(subordinates));
         return (retVal.length() > 0) ? new org.virtualbox_4_2.IEventSource(retVal) : null;
      } catch (InvalidObjectFaultMsg e) {
           throw new VBoxException(ee.getMessage());
      } catch (RuntimeFaultMsg e) {
           throw new VBoxException(ee.getMessage());
      }
     }
Register an event listener.

Parameters:
listener Listener to register.
interesting Event types listener is interested in. One can use wildcards like - VBoxEventType.Any to specify wildcards, matching more than one event.
active Which mode this listener is operating in. In active mode, IEventListener.handleEvent(org.virtualbox_4_2.IEvent) is called directly. In passive mode, an internal event queue is created for this this IEventListener. For each event coming in, it is added to queues for all interested registered passive listeners. It is then up to the external code to call the listener's IEventListener.handleEvent(org.virtualbox_4_2.IEvent) method. When done with an event, the external code must call eventProcessed(org.virtualbox_4_2.IEventListener,org.virtualbox_4_2.IEvent). NOTE: To avoid system overload, the VirtualBox server process checks if passive event listeners call getEvent(org.virtualbox_4_2.IEventListener,java.lang.Integer) frequently enough. In the current implementation, if more than 500 pending events are detected for a passive event listener, it is forcefully unregistered by the system, and further getEvent(org.virtualbox_4_2.IEventListener,java.lang.Integer) calls will return VBOX_E_OBJECT_NOT_FOUND.
    public void registerListener(org.virtualbox_4_2.IEventListener listenerList<org.virtualbox_4_2.VBoxEventTypeinterestingBoolean active) {
      try {
        .iEventSourceRegisterListener(, ((listener == null) ? null :listener.getWrapped()), Helper.convertEnums(org.virtualbox_4_2.VBoxEventType.class,org.virtualbox_4_2.jaxws.VBoxEventType.class,interesting), active);
     } catch (InvalidObjectFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     } catch (RuntimeFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     }
    }
Unregister an event listener. If listener is passive, and some waitable events are still in queue they are marked as processed automatically.

Parameters:
listener Listener to unregister.
    public void unregisterListener(org.virtualbox_4_2.IEventListener listener) {
      try {
        .iEventSourceUnregisterListener(, ((listener == null) ? null :listener.getWrapped()));
     } catch (InvalidObjectFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     } catch (RuntimeFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     }
    }
Fire an event for this source.

Parameters:
event Event to deliver.
timeout Maximum time to wait for event processing (if event is waitable), in ms; 0 = no wait, -1 = indefinite wait.
Returns:
true if an event was delivered to all targets, or is non-waitable.
    public Boolean fireEvent(org.virtualbox_4_2.IEvent eventInteger timeout) {
      try {
        Boolean     retVal;
        retVal = .iEventSourceFireEvent(, ((event == null) ? null :event.getWrapped()), timeout);
        return retVal;
     } catch (InvalidObjectFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     } catch (RuntimeFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     }
    }
Get events from this peer's event queue (for passive mode). Calling this method regularly is required for passive event listeners to avoid system overload; see registerListener(org.virtualbox_4_2.IEventListener,java.util.List,java.lang.Boolean) for details.

Parameters:
listener Which listener to get data for.
timeout Maximum time to wait for events, in ms; 0 = no wait, -1 = indefinite wait.
Returns:
Event retrieved, or null if none available. Expected result codes:
@link ::VBOX_E_OBJECT_NOT_FOUND VBOX_E_OBJECT_NOT_FOUND Listener is not registered, or autounregistered.
    public org.virtualbox_4_2.IEvent getEvent(org.virtualbox_4_2.IEventListener listenerInteger timeout) {
      try {
        String     retVal;
        retVal = .iEventSourceGetEvent(, ((listener == null) ? null :listener.getWrapped()), timeout);
        return (retVal.length() > 0) ? new org.virtualbox_4_2.IEvent(retVal) : null;
     } catch (InvalidObjectFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     } catch (RuntimeFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     }
    }
Must be called for waitable events after a particular listener finished its event processing. When all listeners of a particular event have called this method, the system will then call IEvent.setProcessed().

Parameters:
listener Which listener processed event.
event Which event.
    public void eventProcessed(org.virtualbox_4_2.IEventListener listenerorg.virtualbox_4_2.IEvent event) {
      try {
        .iEventSourceEventProcessed(, ((listener == null) ? null :listener.getWrapped()), ((event == null) ? null :event.getWrapped()));
     } catch (InvalidObjectFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     } catch (RuntimeFaultMsg e) {
          throw new VBoxException(ee.getMessage());
     }
    }
New to GrepCode? Check out our FAQ X