13. RpcSportsServiceImpl
public class RpcSportsServiceImpl extends AutoinjectingRemoteServiceServlet
implements
RpcSportsService {
@Autowired
private SportsService sportsService;
public Sport findSportById(Long sportId) {
return sportsService.findSportById(sportId);
}
// getters and setters of sportsService
}
20. UpdateSportCounter
@Controller
@RequestMapping("/cron/updateSportCounter")
public class UpdateSportCounter {
@Autowired
private SportsService sportsService;
@RequestMapping(method = RequestMethod.GET)
public void execute(HttpServletResponse response) throws IOException {
for (SportOutput sportOut : sportsService.findAllSports()){
final Long id = sportOut.getId();
final int counter = sportsService.getCountPlayersBySport(id);
UpdateCounterSportTaskQueue.updateCounterSportTask(id, counter);
}
response.getWriter().write("Scheduled all taskqueues.");
}
}
21. UpdateCounterSportTaskQueue
public class UpdateCounterSportTaskQueue {
public static void updateCounterSportTask(final Long id, final int counter) {
TaskOptions taskOptions =
TaskOptions.Builder.withUrl(
"/api/task/updateCounterSport");
taskOptions.param("id", String.valueOf(id));
taskOptions.param("counter", String.valueOf(counter));
QueueFactory.getDefaultQueue().add(taskOptions);
}
}
22. UpdateCounterSportWorker
@Controller
@RequestMapping("/task/updateCounterSport")
public class UpdateCounterSportWorker {
@Autowired
private SportDao sportDao;
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(HttpStatus.ACCEPTED)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void execute(@RequestParam long id, @RequestParam int counter) {
Sport sport = sportDao.findById(id);
sport.setCounter(counter);
sport.setUpdatedDate(new Date());
sportDao.save(sport);
}
}
23. Version Control - GIT
Decentralization
Distributed Version Control Systems take advantage of the peer-to-peer
approach. Clients can communicate between each other and maintain their
own local branches without having to go through a Central
Server/Repository. Then synchronization takes place between the peers who
decide which changesets to exchange.
24. GIT + Dropbox
I think that git on dropbox is great. I use it all of the time. I have multiple
computers (two at home and one elsewhere) that I use dropbox as a central
bare repo. Since I don't want to host it on a public service and I don't have
access to a server that I can always ssh to, Dropbox takes care of this by
syncing (very quickly) in the background.
Setup is something like this:
http://stackoverflow.com/questions/1960799/using-gitdropbox-together-effectively