Executor humidity #104
|
@ -1,5 +1,6 @@
|
|||
package ch.unisg.executorbase.executor.domain;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -88,6 +89,6 @@ public abstract class ExecutorBase {
|
|||
* Implementation of the actual execution method of an executor
|
||||
* @return the execution result
|
||||
**/
|
||||
protected abstract String execution(String input);
|
||||
protected abstract String execution(String input) throws ConnectorException, IOException, ConnectorException;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>executor-miro</artifactId>
|
||||
<artifactId>executor-humidity</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -15,9 +15,9 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<version>2.5.5</version>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>5.3.10</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -26,6 +26,11 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.californium</groupId>
|
||||
<artifactId>californium-core</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
package ch.unisg.executorhumidity.executor.adapter.out;
|
||||
|
||||
import ch.unisg.executorhumidity.executor.application.port.out.GetHumidityPort;
|
||||
import org.eclipse.californium.core.CoapClient;
|
||||
import org.eclipse.californium.elements.exception.ConnectorException;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@Component
|
||||
@Primary
|
||||
public class GetHumidityAdapter implements GetHumidityPort {
|
||||
|
||||
@Override
|
||||
public boolean getHumidity(String key) {
|
||||
public String getHumidity() {
|
||||
|
||||
CoapClient client1 = new CoapClient("coap://130.82.171.10:5683/humidity")
|
||||
CoapClient client1 = new CoapClient("coap://130.82.171.10:5683/humidity");
|
||||
|
||||
String result = null;
|
||||
try {
|
||||
result = client1.get().getResponseText();
|
||||
} catch (ConnectorException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package ch.unisg.executorhumidity.executor.application.port.out;
|
||||
|
||||
import org.eclipse.californium.elements.exception.ConnectorException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface GetHumidityPort {
|
||||
boolean getHumidity(String key);
|
||||
String getHumidity();
|
||||
}
|
||||
|
|
|
@ -2,11 +2,17 @@ package ch.unisg.executorhumidity.executor.domain;
|
|||
|
||||
import ch.unisg.executorbase.executor.domain.ExecutorBase;
|
||||
import ch.unisg.executorbase.executor.domain.ExecutorType;
|
||||
import ch.unisg.executorhumidity.executor.adapter.out.GetHumidityAdapter;
|
||||
import ch.unisg.executorhumidity.executor.application.port.out.GetHumidityPort;
|
||||
import org.eclipse.californium.elements.exception.ConnectorException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Executor extends ExecutorBase{
|
||||
|
||||
private static final Executor executor = new Exec(ExecutorType.HUMIDITY);
|
||||
private static final Executor executor = new Executor(ExecutorType.HUMIDITY);
|
||||
// TODO: Add the necessary ports
|
||||
private final GetHumidityPort getHumidityPort = new GetHumidityAdapter();
|
||||
|
||||
|
||||
private Executor(ExecutorType executorType) {super(executorType);}
|
||||
|
@ -18,5 +24,9 @@ public class Executor extends ExecutorBase{
|
|||
protected
|
||||
String execution(String input) {
|
||||
//TODO: Fill
|
||||
|
||||
String result = getHumidityPort.getHumidity();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,36 @@
|
|||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.unisg</groupId>
|
||||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.unisg</groupId>
|
||||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.unisg</groupId>
|
||||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.unisg</groupId>
|
||||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.unisg</groupId>
|
||||
<artifactId>executor-base</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
Loading…
Reference in New Issue
Block a user