use of org.eclipse.kura.data.DataTransportService in project kura by eclipse.
the class GwtStatusServiceImpl method fillFromDataService.
private void fillFromDataService(List<GwtGroupedNVPair> pairs, final String dataServiceRef) throws GwtKuraException {
final Collection<ServiceReference<DataService>> dataServiceReferences = ServiceLocator.getInstance().getServiceReferences(DataService.class, dataServiceRef);
for (ServiceReference<DataService> dataServiceReference : dataServiceReferences) {
final DataService dataService = ServiceLocator.getInstance().getService(dataServiceReference);
try {
if (dataService != null) {
pairs.add(new GwtGroupedNVPair("cloudStatus", "Auto-connect", dataService.isAutoConnectEnabled() ? "ON (Retry Interval is " + Integer.toString(dataService.getRetryInterval()) + "s)" : "OFF"));
}
final String dataTransportRef = (String) dataServiceReference.getProperty(DATA_TRANSPORT_SERVICE_REFERENCE_NAME + ComponentConstants.REFERENCE_TARGET_SUFFIX);
final List<DataTransportService> dataTransportServices = ServiceLocator.getInstance().getServices(DataTransportService.class, dataTransportRef);
for (DataTransportService dataTransportService : dataTransportServices) {
pairs.add(new GwtGroupedNVPair("cloudStatus", "Broker URL", dataTransportService.getBrokerUrl()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Account", dataTransportService.getAccountName()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Username", dataTransportService.getUsername()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Client ID", dataTransportService.getClientId()));
}
} finally {
ServiceLocator.getInstance().ungetService(dataServiceReference);
}
}
}
use of org.eclipse.kura.data.DataTransportService in project kura by eclipse.
the class GwtStatusServiceImpl method getCloudStatus.
private List<GwtGroupedNVPair> getCloudStatus() throws GwtKuraException {
List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
try {
DataService dataService = ServiceLocator.getInstance().getService(DataService.class);
DataTransportService dataTransportService = ServiceLocator.getInstance().getService(DataTransportService.class);
if (dataService != null) {
pairs.add(new GwtGroupedNVPair("cloudStatus", "Connection Status", dataService.isConnected() ? "CONNECTED" : "DISCONNECTED"));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Auto-connect", dataService.isAutoConnectEnabled() ? "ON (Retry Interval is " + Integer.toString(dataService.getRetryInterval()) + "s)" : "OFF"));
}
if (dataTransportService != null) {
pairs.add(new GwtGroupedNVPair("cloudStatus", "Broker URL", dataTransportService.getBrokerUrl()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Account", dataTransportService.getAccountName()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Username", dataTransportService.getUsername()));
pairs.add(new GwtGroupedNVPair("cloudStatus", "Client ID", dataTransportService.getClientId()));
}
} catch (GwtKuraException e) {
s_logger.warn("Get cloud status failed", e);
throw e;
}
return pairs;
}
Aggregations