Alternative video format (mpg)
Let us create a PlanetService to expose the sayHello method to clients. We lookup the Planet from its name using the built in findByKey repository operation. In Sculptor model file this looks like this:
Service PlanetService {
String sayHello(String planetName) throws PlanetNotFoundException;
}
Entity Planet {
gap
scaffold
String name key
Long population min="0"
Long diameter min="0" nullable
-Set<@Moon> moons opposite planet
Repository PlanetRepository {
findByKey;
}
}
All hand written java code we need to add is for testing and two trivial lines in PlanetServiceImpl:
public String sayHello(ServiceContext ctx, String planetName)
throws PlanetNotFoundException {
Planet planet = getPlanetRepository().findByKey(planetName);
return planet.greeting();
}
No comments:
Post a Comment