The DeviceAdmin service can be used to obtain information about all protocol adapters currently available in the OSGi runtime. Information for each specific protocol adapter is provided in the form of a com.prosyst.mbs.services.da.AdapterInfo object.
DeviceAdmin.PROPERTY_ADAPTER_INFOS
The DeviceAdmin has functional property DeviceAdmin.PROPERTY_ADAPTER_INFOS which type is Set of AdapterInfo. The following example use a getter method for DeviceAdmin.PROPERTY_ADAPTER_INFOS property to print information about all available protocol adapters. In our example there is only one available protocol adapter – "DA Demo". For this reason you should have the Device Access Protocol Adapter Demo installed and started.
private DeviceAdmin deviceAdmin;
public DeviceAdmin addingService(ServiceReference<DeviceAdmin> reference) {
deviceAdmin = bc.getService(reference);
printAdapterInfos();
return deviceAdmin;
}
private static void printAdapterInfos() {
Set<AdapterInfo> adapterInfos = deviceAdmin.getAdapterInfos();
for (AdapterInfo adapterInfo : adapterInfos) {
System.out.println("Adapter Name : " + adapterInfo.getName());
System.out.println("Adapter Version : " + adapterInfo.getVersion());
System.out.println("Supported Operations : " + adapterInfo.getOperations());
System.out.println("Supported Remove Arguments : " + adapterInfo.getRemoveArguments());
}
}
The result after executing the example is:
Adapter Name : DA DEMO
Adapter Version : 1.0.0
Supported Operations : [CREATE. REMOVE ]
Supported Remove Arguments : []
DeviceAdmin.OPERATION_GET_ADAPTER_INFO
The DeviceAdmin has an operation DeviceAdmin.OPERATION_GET_ADAPTER_INFO which returns information for specific protocol adapter. The following example shows the information about "DA Demo" protocol adapter.
private DeviceAdmin deviceAdmin;
public DeviceAdmin addingService(ServiceReference<DeviceAdmin> reference) {
deviceAdmin = bc.getService(reference);
printAdapterInfo();
return deviceAdmin;
}
private static void printAdapterInfo() {
AdapterInfo adapterInfo = deviceAdmin.getAdapterInfo("DA Demo");
System.out.println("Adapter Name : " + adapterInfo.getName());
System.out.println("Adapter Version : " + adapterInfo.getVersion());
System.out.println("Suported Operations : " + adapterInfo.getOperations());
System.out.println("Supported Remove Arguments : " + adapterInfo.getRemoveArguments());
}
The result after executing the example is same as of the previous example:
Adapter Name : DA DEMO
Adapter Version : 1.0.0
Supported Operations : [CREATE. REMOVE ]
Supported Remove Arguments : []
AdapterOperation
The method of AdapterInfo.getOperation() returns the supported operations. The AdapterOperation (com.prosyst.mbs.services.da.AdapterOperation) provides detail information for the operations of the specific protocol adapter. The possible values for the protocol adapter operations are:
Operation |
Description |
|---|---|
AdapterOperation.CREATE |
This operation is used for creation of a new |
AdapterOperation.REMOVE |
This operation is used for remove an existing |
AdapterOperation.CANCEL_REMOVE |
This operation is used for cancel removing an existing |
RemoveArgument
The method of AdapterInfo.getRemoveArguments() returns the supported removal arguments. The RemoveArgument (com.prosyst.mbs.services.da.RemoveArgument) provides arguments for the removing of a specified device. The possible values for the removal arguments are:
Remove argument |
Description |
|---|---|
RemoveArgument.FORCE |
This removal argument defines that the |
RemoveArgument.POSTPONE |
This removal argument define that the |
RemoveArgument.FORCE_RESET |
This removal argument defines that the |
RemoveArgument.POSTPONE_RESET |
This removal argument defines that the |
These are the constants that are defined on the API level. They are related to the implementation of the protocol adapter which is on the SPI level. To see how to implement a protocol adapter click here.