Previous Topic

Next Topic

Book Contents

Book Index

Using Device Classes as Functional Items (deprecated)

A guide on using Device Classes as Functional Items

Non-Parameterized Device Classes access

When using the non-parameterized Device Class access, a compile warning will occur.

private ServiceTracker<MultiLevelControl, MultiLevelControl> track;

...

this.track = new ServiceTracker<MultiLevelControl, MultiLevelControl>(context, MultiLevelControl.class, null);

...

final MultiLevelControl tmc = this.track.getService();

// compile warning, MultiLevelControl is a raw type and should be parametrized.

Parameterized Device Classes access

Parameterized Device Classes access is possible with precautions:

Functional Items Interface

The Functional Item interface information is available with a cast. MultiLevelControl does not extend the Functional Item interface, but the service implementation does.

final MultiLevelControl<Temperature> tmc = this.track.getService();

FunctionalItem fi = (FunctionalItem) tmc;

System.out.println("Functional item UID '" + fi.getUID() + "'");

System.out.println("Functional item name '" + fi.getName() + "'");