public class HeadlessThermostat extends Observable implements Observer
Constructor and Description |
---|
HeadlessThermostat()
Instantiates an
HeadlessThermostat with a ThermostatModel available by the ServiceLoader . |
HeadlessThermostat(ThermostatModel model)
Instantiates a
HeadlessThermostat with a specific ThermostatModel . |
Modifier and Type | Method and Description |
---|---|
void |
addCloudConnector(CloudConnector connector)
Adds a cloud connector for the
HeadlessThermostat . |
void |
addCloudConnectorObserver(Observer observer)
Add an observer to be notified when a
CloudConnector is added, removed or changed. |
boolean |
clientIsLogged()
Checks if a client has been logged.
|
CloudConnector[] |
getCloudConnectors()
Gets the cloud connectors.
|
RestEndpoint[] |
getEndpoints()
Gets the additional endpoints.
|
ThermostatModel |
getModel()
Gets the associated model.
|
int |
getPort()
Gets the server port.
|
void |
removeCloudConnector(CloudConnector connector)
Removes a cloud connector.
|
void |
removeCloudConnectorObserver(Observer observer)
Remove an observer notified when a
CloudConnector is added, removed or changed. |
void |
setEndpoints(RestEndpoint... endpoints)
Sets the additional endpoints.
|
void |
setPort(int port)
Sets the server port.
|
void |
start()
Starts the thermostat server.
|
void |
stop()
Stops the server.
|
void |
update(Observable o,
Object arg)
This method is called whenever the observed object is changed.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
public HeadlessThermostat()
HeadlessThermostat
with a ThermostatModel available by the ServiceLoader
.public HeadlessThermostat(ThermostatModel model)
HeadlessThermostat
with a specific ThermostatModel
.model
- the ThermostatModel
to use.public void addCloudConnector(CloudConnector connector)
HeadlessThermostat
.connector
- the connector to add.public void addCloudConnectorObserver(Observer observer)
CloudConnector
is added, removed or changed.observer
- the observer to be add.public boolean clientIsLogged()
true
if a client has been logged into the Server.public CloudConnector[] getCloudConnectors()
public RestEndpoint[] getEndpoints()
public ThermostatModel getModel()
public int getPort()
public void removeCloudConnector(CloudConnector connector)
connector
- the connector to remove.public void removeCloudConnectorObserver(Observer observer)
CloudConnector
is added, removed or changed.observer
- the observer to be removed.public void setEndpoints(RestEndpoint... endpoints)
endpoints
- the endpoints to set, cannot be null
.public void setPort(int port)
port
- the server port to set.public void start() throws IOException
IOException
- when the server could not be started.public void stop()
public void update(Observable o, Object arg)
Observer
notifyObservers
method to have all the object's
observers notified of the change.