ztex
Class ZtexContext

java.lang.Object
  extended by ztex.ZtexContext

public class ZtexContext
extends java.lang.Object

This class manages an USB context. Because libusb_get_device_list does not return an up to date device list at least on some implementations a new context must be created every time the bus is (re)discovered, i.e. every time re-numeration occurs. This class creates a new USB context, initializes it and deinitializes it as soon it is not used anymore. Used is tracked using a reference counter. Reference counter of a new instance is 1.


Constructor Summary
ZtexContext()
          Constructs an new USB context and initializes it.
 
Method Summary
 org.usb4java.Context context()
          Returns the USB context.
protected  void finalize()
           
 ZtexContext ref()
          Increases the reference count.
 void unref()
          Decreases the reference count and deinitializes the context if reference counter reaches 0.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZtexContext

public ZtexContext()
            throws UsbException
Constructs an new USB context and initializes it.

Throws:
UsbException
Method Detail

context

public final org.usb4java.Context context()
Returns the USB context.

Returns:
the USB context.

ref

public ZtexContext ref()
                throws UsbException
Increases the reference count.

Returns:
the USB context.
Throws:
UsbException

unref

public void unref()
Decreases the reference count and deinitializes the context if reference counter reaches 0.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable