Package akka.weather

Source Code of akka.weather.WeatherServiceImpl

package akka.weather;

import java.util.Random;

import akka.actor.TypedActor;
import akka.dispatch.Future;
import akka.weather.WeatherSensor.WeatherData;

public class WeatherServiceImpl extends TypedActor implements WeatherService {
  private Random random = new Random(System.currentTimeMillis());

  public Future<WeatherData> get() {
    try {
      Thread.sleep(1000); // sensor is slow...
    } catch (InterruptedException e) {
    }
    int temperature = random.nextInt(215) - 80 + 1;
    int humidity = random.nextInt(50) + 10 + 1;
    WeatherData data = new WeatherData(temperature, humidity);
    return future(data);
  }
}
TOP

Related Classes of akka.weather.WeatherServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.