Skip to content

Commit

Permalink
[systeminfo] Rename Systeminfo* to SystemInfo* (openhab#16823)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Falkenstern <alexander.falkenstern@gmail.com>
  • Loading branch information
falkena committed May 31, 2024
1 parent 86a8a07 commit c836561
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 151 deletions.
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.systeminfo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>org.openhab.binding.systeminfo</artifactId>

<name>openHAB Add-ons :: Bundles :: Systeminfo Binding</name>
<name>openHAB Add-ons :: Bundles :: SystemInfo Binding</name>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link SysteminfoBindingConstants} class defines common constants, which are
* The {@link SystemInfoBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Svilen Valkanov - Initial contribution
* @author Mark Herwege - Add dynamic creation of extra channels
* @author Mark Herwege - Processor frequency channels
*/
@NonNullByDefault
public class SysteminfoBindingConstants {
public class SystemInfoBindingConstants {

public static final String BINDING_ID = "systeminfo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*/
package org.openhab.binding.systeminfo.internal;

import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*;
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler;
import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface;
import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler;
import org.openhab.binding.systeminfo.internal.model.SystemInfoInterface;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
Expand All @@ -27,19 +27,19 @@
import org.osgi.service.component.annotations.Reference;

/**
* The {@link SysteminfoHandlerFactory} is responsible for creating things and thing
* The {@link SystemInfoHandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Svilen Valkanov - Initial contribution
* @author Lyubomir Papazov - Pass systeminfo service to the SysteminfoHandler constructor
* @author Lyubomir Papazov - Pass systeminfo service to the SystemInfoHandler constructor
* @author Wouter Born - Add null annotations
* @author Mark Herwege - Add dynamic creation of extra channels
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.systeminfo")
public class SysteminfoHandlerFactory extends BaseThingHandlerFactory {
private @NonNullByDefault({}) SysteminfoInterface systeminfo;
private @NonNullByDefault({}) SysteminfoThingTypeProvider thingTypeProvider;
public class SystemInfoHandlerFactory extends BaseThingHandlerFactory {
private @NonNullByDefault({}) SystemInfoInterface systeminfo;
private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider;

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
Expand All @@ -58,26 +58,26 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
thingTypeProvider.storeChannelsConfig(thing); // Save the current channels configs, will be restored
// after thing type change.
}
return new SysteminfoHandler(thing, thingTypeProvider, systeminfo);
return new SystemInfoHandler(thing, thingTypeProvider, systeminfo);
}
return null;
}

@Reference
public void bindSystemInfo(SysteminfoInterface systeminfo) {
public void bindSystemInfo(SystemInfoInterface systeminfo) {
this.systeminfo = systeminfo;
}

public void unbindSystemInfo(SysteminfoInterface systeminfo) {
public void unbindSystemInfo(SystemInfoInterface systeminfo) {
this.systeminfo = null;
}

@Reference
public void setSysteminfoThingTypeProvider(SysteminfoThingTypeProvider thingTypeProvider) {
public void setSystemInfoThingTypeProvider(SystemInfoThingTypeProvider thingTypeProvider) {
this.thingTypeProvider = thingTypeProvider;
}

public void unsetSysteminfoThingTypeProvider(SysteminfoThingTypeProvider thingTypeProvider) {
public void unsetSystemInfoThingTypeProvider(SystemInfoThingTypeProvider thingTypeProvider) {
this.thingTypeProvider = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.binding.systeminfo.internal;

import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*;
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;

import java.net.URI;
import java.util.Collections;
Expand Down Expand Up @@ -51,17 +51,17 @@

/**
* Extended channels can be auto discovered and added to newly created groups in the
* {@link org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler}. The
* thing needs to be updated to add the groups. The `SysteminfoThingTypeProvider` OSGi service gives access to the
* {@link org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler}. The
* thing needs to be updated to add the groups. The `SystemInfoThingTypeProvider` OSGi service gives access to the
* `ThingTypeRegistry` and serves the updated `ThingType`.
*
* @author Mark Herwege - Initial contribution
*
*/
@NonNullByDefault
@Component(service = { SysteminfoThingTypeProvider.class, ThingTypeProvider.class })
public class SysteminfoThingTypeProvider extends AbstractStorageBasedTypeProvider {
private final Logger logger = LoggerFactory.getLogger(SysteminfoThingTypeProvider.class);
@Component(service = { SystemInfoThingTypeProvider.class, ThingTypeProvider.class })
public class SystemInfoThingTypeProvider extends AbstractStorageBasedTypeProvider {
private final Logger logger = LoggerFactory.getLogger(SystemInfoThingTypeProvider.class);

private final ThingTypeRegistry thingTypeRegistry;
private final ChannelGroupTypeRegistry channelGroupTypeRegistry;
Expand All @@ -70,7 +70,7 @@ public class SysteminfoThingTypeProvider extends AbstractStorageBasedTypeProvide
private final Map<ThingUID, Map<String, Configuration>> thingChannelsConfig = new HashMap<>();

@Activate
public SysteminfoThingTypeProvider(@Reference ThingTypeRegistry thingTypeRegistry,
public SystemInfoThingTypeProvider(@Reference ThingTypeRegistry thingTypeRegistry,
@Reference ChannelGroupTypeRegistry channelGroupTypeRegistry,
@Reference ChannelTypeRegistry channelTypeRegistry, @Reference StorageService storageService) {
super(storageService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
*/
package org.openhab.binding.systeminfo.internal.discovery;

import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.THING_TYPE_COMPUTER;
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.THING_TYPE_COMPUTER;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
Expand All @@ -31,27 +30,27 @@
import org.slf4j.LoggerFactory;

/**
* Discovery service implementation for the Systeminfo binding. It creates {@link DiscoveryResult} with
* Discovery service implementation for the SystemInfo binding. It creates {@link DiscoveryResult} with
* {@link #DEFAULT_THING_LABEL}. The discovered Thing will have id - the hostname or {@link #DEFAULT_THING_ID}'
*
* @author Svilen Valkanov - Initial contribution
* @author Wouter Born - Add null annotations
*/
@NonNullByDefault
@Component(service = DiscoveryService.class, configurationPid = "discovery.systeminfo")
public class SysteminfoDiscoveryService extends AbstractDiscoveryService {
public class SystemInfoDiscoveryService extends AbstractDiscoveryService {
public static final String DEFAULT_THING_ID = "unknown";
public static final String DEFAULT_THING_LABEL = "Local computer";

private final Logger logger = LoggerFactory.getLogger(SysteminfoDiscoveryService.class);
private final Logger logger = LoggerFactory.getLogger(SystemInfoDiscoveryService.class);

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER);

private static final int DISCOVERY_TIME_SECONDS = 30;
private static final String THING_UID_VALID_CHARS = "A-Za-z0-9_-";
private static final String HOST_NAME_SEPERATOR = "_";

public SysteminfoDiscoveryService() {
public SystemInfoDiscoveryService() {
super(SUPPORTED_THING_TYPES_UIDS, DISCOVERY_TIME_SECONDS);
}

Expand All @@ -74,8 +73,7 @@ protected void startScan() {
DEFAULT_THING_ID);
}

ThingTypeUID computerType = SysteminfoBindingConstants.THING_TYPE_COMPUTER;
ThingUID computer = new ThingUID(computerType, hostname);
ThingUID computer = new ThingUID(THING_TYPE_COMPUTER, hostname);
thingDiscovered(DiscoveryResultBuilder.create(computer).withLabel(DEFAULT_THING_LABEL).build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.binding.systeminfo.internal.handler;

import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*;
import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*;

import java.math.BigDecimal;
import java.util.ArrayList;
Expand All @@ -27,9 +27,9 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.systeminfo.internal.SysteminfoThingTypeProvider;
import org.openhab.binding.systeminfo.internal.SystemInfoThingTypeProvider;
import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException;
import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface;
import org.openhab.binding.systeminfo.internal.model.SystemInfoInterface;
import org.openhab.core.cache.ExpiringCache;
import org.openhab.core.cache.ExpiringCacheMap;
import org.openhab.core.config.core.Configuration;
Expand All @@ -55,7 +55,7 @@
import org.slf4j.LoggerFactory;

/**
* The {@link SysteminfoHandler} is responsible for providing real time information about the system
* The {@link SystemInfoHandler} is responsible for providing real time information about the system
* (CPU, Memory, Storage, Display and others).
*
* @author Svilen Valkanov - Initial contribution
Expand All @@ -65,7 +65,7 @@
* @author Mark Herwege - Processor frequency channels
*/
@NonNullByDefault
public class SysteminfoHandler extends BaseThingHandler {
public class SystemInfoHandler extends BaseThingHandler {
/**
* Refresh interval for {@link #highPriorityChannels} in seconds.
*/
Expand Down Expand Up @@ -109,9 +109,9 @@ public class SysteminfoHandler extends BaseThingHandler {
*/
public final String idExtString;

public final SysteminfoThingTypeProvider thingTypeProvider;
public final SystemInfoThingTypeProvider thingTypeProvider;

private SysteminfoInterface systeminfo;
private SystemInfoInterface systeminfo;

private @Nullable ScheduledFuture<?> highPriorityTasks;
private @Nullable ScheduledFuture<?> mediumPriorityTasks;
Expand All @@ -128,10 +128,10 @@ public class SysteminfoHandler extends BaseThingHandler {
private ExpiringCacheMap<Integer, @Nullable DecimalType> processLoadCache = new ExpiringCacheMap<>(
MIN_PROCESS_LOAD_REFRESH_INTERVAL_MS);

private final Logger logger = LoggerFactory.getLogger(SysteminfoHandler.class);
private final Logger logger = LoggerFactory.getLogger(SystemInfoHandler.class);

public SysteminfoHandler(Thing thing, SysteminfoThingTypeProvider thingTypeProvider,
SysteminfoInterface systeminfo) {
public SystemInfoHandler(Thing thing, SystemInfoThingTypeProvider thingTypeProvider,
SystemInfoInterface systeminfo) {
super(thing);
this.thingTypeProvider = thingTypeProvider;
this.systeminfo = systeminfo;
Expand All @@ -145,7 +145,7 @@ public void initialize() {
thing.getThingTypeUID().getId());
restoreChannelsConfig(); // After a thing type change, previous channel configs will have been stored, and will
// be restored here.
if (instantiateSysteminfoLibrary() && isConfigurationValid() && updateProperties()) {
if (instantiateSystemInfoLibrary() && isConfigurationValid() && updateProperties()) {
if (!addDynamicChannels()) { // If there are new channel groups, the thing will get recreated with a new
// thing type and this handler will be disposed. Therefore do not do anything
// further here.
Expand All @@ -165,13 +165,13 @@ public void handleRemoval() {
super.handleRemoval();
}

private boolean instantiateSysteminfoLibrary() {
private boolean instantiateSystemInfoLibrary() {
try {
systeminfo.initializeSysteminfo();
logger.debug("Systeminfo implementation is instantiated!");
systeminfo.initializeSystemInfo();
logger.debug("SystemInfo implementation is instantiated!");
return true;
} catch (Exception e) {
logger.warn("Cannot instantiate Systeminfo object!", e);
logger.warn("Cannot instantiate SystemInfo object!", e);
return false;
}
}
Expand Down Expand Up @@ -428,9 +428,9 @@ public Set<ChannelUID> getLowPriorityChannels() {
}

/**
* This method gets the information for specific channel through the {@link SysteminfoInterface}. It uses the
* channel ID to call the correct method from the {@link SysteminfoInterface} with deviceIndex parameter (in case of
* multiple devices, for reference see {@link #getDeviceIndex(String)}})
* This method gets the information for specific channel through the {@link SystemInfoInterface}. It uses the
* channel ID to call the correct method from the {@link SystemInfoInterface} with deviceIndex parameter (in case of
* multiple devices, for reference see {@link SystemInfoHandler#getDeviceIndex(ChannelUID)}})
*
* @param channelUID the UID of the channel
* @return State object or null, if there is no information for the device with this index
Expand Down Expand Up @@ -662,7 +662,7 @@ private State getInfoForChannel(ChannelUID channelUID) {
* first will have deviceIndex=0, the second deviceIndex=1 ant etc).
* When no device index is specified, default value of 0 (first device in the list) is returned.
*
* @param channelID the ID of the channel
* @param channelUID the ID of the channel
* @return natural number (number >=0)
*/
private int getDeviceIndex(ChannelUID channelUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
import oshi.util.EdidUtil;

/**
* This implementation of {@link SysteminfoInterface} is using the open source library OSHI to provide system
* This implementation of {@link SystemInfoInterface} is using the open source library OSHI to provide system
* information. OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java.
*
* @author Svilen Valkanov - Initial contribution
* @author Lyubomir Papazov - Move the initialization logic that could potentially take long time to the
* initializeSysteminfo method
* initializeSystemInfo method
* @author Christoph Weitkamp - Update to OSHI 3.13.0 - Replaced deprecated method
* CentralProcessor#getSystemSerialNumber()
* @author Wouter Born - Update to OSHI 4.0.0 and add null annotations
Expand All @@ -68,10 +68,10 @@
* @see <a href="https://github.com/oshi/oshi">OSHI GitHub repository</a>
*/
@NonNullByDefault
@Component(service = SysteminfoInterface.class)
public class OSHISysteminfo implements SysteminfoInterface {
@Component(service = SystemInfoInterface.class)
public class OSHISystemInfo implements SystemInfoInterface {

private final Logger logger = LoggerFactory.getLogger(OSHISysteminfo.class);
private final Logger logger = LoggerFactory.getLogger(OSHISystemInfo.class);

private @NonNullByDefault({}) HardwareAbstractionLayer hal;

Expand Down Expand Up @@ -101,13 +101,13 @@ public class OSHISysteminfo implements SysteminfoInterface {
* Some of the methods used in this constructor execute native code and require execute permissions
*
*/
public OSHISysteminfo() {
logger.debug("OSHISysteminfo service is created");
public OSHISystemInfo() {
logger.debug("OSHISystemInfo service is created");
}

@Override
public void initializeSysteminfo() {
logger.debug("OSHISysteminfo service starts initializing");
public void initializeSystemInfo() {
logger.debug("OSHISystemInfo service starts initializing");

SystemInfo systemInfo = new SystemInfo();
hal = systemInfo.getHardware();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.openhab.core.library.types.StringType;

/**
* {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information.
* {@link SystemInfoInterface} defines the methods needed to provide this binding with the required system information.
*
* @author Svilen Valkanov - Initial contribution
* @author Wouter Born - Add null annotations
Expand All @@ -35,12 +35,12 @@
* @author Mark Herwege - Processor frequency channels
*/
@NonNullByDefault
public interface SysteminfoInterface {
public interface SystemInfoInterface {

/**
* Initialize logic for the Systeminfo implementation
* Initialize logic for the SystemInfo implementation
*/
void initializeSysteminfo();
void initializeSystemInfo();

// Operating system info
/**
Expand Down
2 changes: 1 addition & 1 deletion itests/org.openhab.binding.systeminfo.tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>org.openhab.binding.systeminfo.tests</artifactId>

<name>openHAB Add-ons :: Integration Tests :: Systeminfo Binding Tests</name>
<name>openHAB Add-ons :: Integration Tests :: SystemInfo Binding Tests</name>

<dependencies>
<dependency>
Expand Down
Loading

0 comments on commit c836561

Please sign in to comment.