Driver

Syntax

public interface Driver

Description

A Driver service should be registered by each driver wishing to attach to device services provided by other drivers. For each newly discovered Device, the device manager enters a bidding phase. The Driver whose match(ServiceReference) method bids the highest for a particular device will be instructed by the device manager to attach to the device.

See Also: Device

Member Summary
Methods
public Stringattach(ServiceReference)
 Attach this driver to the device represented by the given ServiceReference.
public intmatch(ServiceReference)
 Check whether this driver can be attached to the device represented by the given ServiceReference, and return a value indicating how well this driver can support the given device, or Device.MATCH_NONE if it cannot support the given device at all.

Methods

attach(ServiceReference)
public java.lang.String attach(ServiceReference reference)
            throws java.lang.Exception

Attach this driver to the device represented by the given ServiceReference.

A return value of null indicates that this driver has successfully attached to the given device. If this driver is unable to attach to the given device, but knows of a more suitable driver, it must return the ID of that driver. This allows for the implementation of referring drivers whose only purpose is to refer to other drivers capable of handling a given device.

After having attached to the device, this driver is expected to register the device as a new service exposing driver-specific functionality.

This method is called by the device manager.

Parameters:

reference— the ServiceReference of the device to attach to

Returns: null if this driver has successfully attached to the given device, or the ID of a more suitable driver

Throws:

java.lang.Exception— the driver cannot attach to the given device and does not know of a more suitable driver

match(ServiceReference)
public int match(ServiceReference reference)
            throws java.lang.Exception

Check whether this driver can be attached to the device represented by the given ServiceReference, and return a value indicating how well this driver can support the given device, or Device.MATCH_NONE if it cannot support the given device at all.

The value returned must be one of the possible match values defined in the Device subinterface corresponding to the given device.

In order to make its decision, this driver may simply examine the properties associated with the given device or may get the referenced service object (representing the actual physical device) to talk to it, as long as it ungets the service and returns the physical device to a normal state before this method returns.

A driver should always return the same match code whenever it is presented with the same device.

The match function is called by the device manager during the matching process.

Parameters:

reference— the ServiceReference of the device to match

Returns: value indicating how well this driver can support the given device, or Device.MATCH_NONE if it cannot support the device at all

Throws:

java.lang.Exception— the driver cannot examine the device

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.237.201