made changes to executor-humidity
This commit is contained in:
parent
c87a732e2a
commit
aaffb0371e
|
@ -1,5 +1,6 @@
|
||||||
package ch.unisg.executorbase.executor.domain;
|
package ch.unisg.executorbase.executor.domain;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@ -88,6 +89,6 @@ public abstract class ExecutorBase {
|
||||||
* Implementation of the actual execution method of an executor
|
* Implementation of the actual execution method of an executor
|
||||||
* @return the execution result
|
* @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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>executor-miro</artifactId>
|
<artifactId>executor-humidity</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -15,9 +15,9 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
<version>2.5.5</version>
|
<version>5.3.10</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -26,6 +26,11 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.californium</groupId>
|
||||||
|
<artifactId>californium-core</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -1,17 +1,32 @@
|
||||||
package ch.unisg.executorhumidity.executor.adapter.out;
|
package ch.unisg.executorhumidity.executor.adapter.out;
|
||||||
|
|
||||||
import ch.unisg.executorhumidity.executor.application.port.out.GetHumidityPort;
|
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.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Primary
|
@Primary
|
||||||
public class GetHumidityAdapter implements GetHumidityPort {
|
public class GetHumidityAdapter implements GetHumidityPort {
|
||||||
|
|
||||||
@Override
|
@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;
|
package ch.unisg.executorhumidity.executor.application.port.out;
|
||||||
|
|
||||||
|
import org.eclipse.californium.elements.exception.ConnectorException;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface GetHumidityPort {
|
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.ExecutorBase;
|
||||||
import ch.unisg.executorbase.executor.domain.ExecutorType;
|
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{
|
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
|
// TODO: Add the necessary ports
|
||||||
|
private final GetHumidityPort getHumidityPort = new GetHumidityAdapter();
|
||||||
|
|
||||||
|
|
||||||
private Executor(ExecutorType executorType) {super(executorType);}
|
private Executor(ExecutorType executorType) {super(executorType);}
|
||||||
|
@ -18,5 +24,9 @@ public class Executor extends ExecutorBase{
|
||||||
protected
|
protected
|
||||||
String execution(String input) {
|
String execution(String input) {
|
||||||
//TODO: Fill
|
//TODO: Fill
|
||||||
|
|
||||||
|
String result = getHumidityPort.getHumidity();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,37 @@
|
||||||
<artifactId>executor-base</artifactId>
|
<artifactId>executor-base</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<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>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user