NOTE: The downloaded code repository will include much of the implementation for this module. You can simply use it as is, or can create your own. If you're using the sample code, you can ignore this requirement; however, please do review the content to ensure your current implementation aligns with the functionality referenced below.
Review the README
Please see README.md for further information on, and use of, this content.
License for embedded documentation and source codes: PIOT-DOC-LIC
Estimated effort may vary greatly
The estimated level of effort for this exercise shown in the 'Estimate' section below is a very rough approximation. The actual level of effort may vary greatly depending on your development and test environment, experience with the requisite technologies, and many other factors.
Actions
NOTE: The implementation examples depicted here are only one way to implement the requirements listed. Your own implementation may vary of course.
Create a new Java package in the programmingtheiot\gda source folder named app and navigate to that folder.
Import the java.util.logging logging framework. You can import all, or just Level and Logger.
Create a package-scoped constructor that accepts a single parameter as follows: public GatewayDeviceApp(String[] args)
Add the public stopApp(int code) method, and log an info message indicating the app was stopped. Include a try / catch block to handle the stop code. On exception, log an error message along with the stack trace. Outside of the try / catch block, and as the last line of code, log an informational message with the code included.
Add the public startApp() method, and log an info message indicating the app was started. Include a try / catch block to handle the start code. On exception, log an error message along with the stack trace, then call stopApp(-1).
Add the private initConfig(String fileName) method, and log an info message indicating the method was called. It will mostly remain empty for now.
Add the private parseArgs(String[] args) method, and log an info message indicating the method was called. For now, the args can be ignored. Before the method exits, call initConfig(null).
Update the constructor to include a call to parseArgs(args).
Add the public static void main(String[] args) method to enable running as an application. It will create an instance of GatewayDeviceApp, call startApp(), wait 65 seconds, then call stopApp(0), as follows:
Description
GatewayDeviceApp
.Review the README
Estimated effort may vary greatly
Actions
NOTE: The implementation examples depicted here are only one way to implement the requirements listed. Your own implementation may vary of course.
programmingtheiot\gda
source folder namedapp
and navigate to that folder.java.util.logging
logging framework. You can import all, or justLevel
andLogger
.public GatewayDeviceApp(String[] args)
stopApp(int code)
method, and log an info message indicating the app was stopped. Include atry / catch
block to handle the stop code. On exception, log an error message along with the stack trace. Outside of thetry / catch
block, and as the last line of code, log an informational message with thecode
included.startApp()
method, and log an info message indicating the app was started. Include atry / catch
block to handle the start code. On exception, log an error message along with the stack trace, then callstopApp(-1)
.initConfig(String fileName)
method, and log an info message indicating the method was called. It will mostly remain empty for now.parseArgs(String[] args)
method, and log an info message indicating the method was called. For now, the args can be ignored. Before the method exits, callinitConfig(null)
.parseArgs(args)
.Add the
public static void main(String[] args)
method to enable running as an application. It will create an instance ofGatewayDeviceApp
, callstartApp()
, wait 65 seconds, then callstopApp(0)
, as follows:Estimate
Tests