Interface Driver
-
public interface DriverADriverservice object must be registered by each Driver bundle wishing to attach to Device services provided by other drivers. For each newly discoveredDeviceobject, the device manager enters a bidding phase. TheDriverobject whosematch(ServiceReference)method bids the highest for a particularDeviceobject will be instructed by the device manager to attach to theDeviceobject.- See Also:
Device,DriverLocator
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Stringattach(org.osgi.framework.ServiceReference<?> reference)Attaches this Driver service to the Device service represented by the givenServiceReferenceobject.intmatch(org.osgi.framework.ServiceReference<?> reference)Checks whether this Driver service can be attached to the Device service.
-
-
-
Method Detail
-
match
int match(org.osgi.framework.ServiceReference<?> reference) throws java.lang.Exception
Checks whether this Driver service can be attached to the Device service. The Device service is represented by the givenServiceReferenceand returns a value indicating how well this driver can support the given Device service, orDevice.MATCH_NONEif it cannot support the given Device service at all.The return value must be one of the possible match values defined in the device category definition for the given Device service, or
Device.MATCH_NONEif the category of the Device service is not recognized.In order to make its decision, this Driver service may examine the properties associated with the given Device service, 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 service must always return the same match code whenever it is presented with the same Device service.
The match function is called by the device manager during the matching process.
- Parameters:
reference- theServiceReferenceobject of the device to match- Returns:
- value indicating how well this driver can support the given
Device service, or
Device.MATCH_NONEif it cannot support the Device service at all - Throws:
java.lang.Exception- if this Driver service cannot examine the Device service
-
attach
java.lang.String attach(org.osgi.framework.ServiceReference<?> reference) throws java.lang.ExceptionAttaches this Driver service to the Device service represented by the givenServiceReferenceobject.A return value of
nullindicates that this Driver service has successfully attached to the given Device service. If this Driver service is unable to attach to the given Device service, but knows of a more suitable Driver service, it must return theDRIVER_IDof that Driver service. This allows for the implementation of referring drivers whose only purpose is to refer to other drivers capable of handling a given Device service.After having attached to the Device service, this driver may register the underlying device as a new service exposing driver-specific functionality.
This method is called by the device manager.
- Parameters:
reference- theServiceReferenceobject of the device to attach to- Returns:
nullif this Driver service has successfully attached to the given Device service, or theDRIVER_IDof a more suitable driver- Throws:
java.lang.Exception- if the driver cannot attach to the given device and does not know of a more suitable driver
-
-