V1_0.java [src/java/m/example/logging] Revision: Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package m.example.logging;
import csip.ModelDataService;
import javax.ws.rs.Path;
import csip.annotations.*;
/**
* Fahrenheit conversion.
*
* @author od
*/
@Name("logging")
@Description("Example of an simple service that logs")
@Path("m/logging/1.0")
public class V1_0 extends ModelDataService {
double temp;
// 1) parse the service input
@Override
protected void preProcess() throws Exception {
temp = parameter().getDouble("temp");
LOG.info("Got input temp: " + temp);
}
// 2) convert the temperature
protected void doProcess() throws Exception {
temp = temp * (9 / 5) + 32;
LOG.info("computed temp: " + temp);
}
// 3) provide the temperature as a result.
@Override
protected void postProcess() throws Exception {
LOG.info("put result " + temp);
results().put("temp", temp, "F");
}
}