Use an atomic integer as an intance evariable within service classes that are injected into controllers. Scaling is limited by memory required for each thread to run operation, and how many requests are processed per second (cpu speend and time to perform operations on atomic integer?)
@Service
public MyService{
AtomciInteger count = new AtomicIntger(0);
public int add() {
return count.incrementAndGet();
}
// accessed via ajax loop (and controller), if value changes update display
public int getCount() {
return count.get();
}
}
The service class will access via controller, the controller will be available as restful webserivce, accessed via ajax calls. How may siumulateous users/requests could it handle ?
The only alternative I can think of is to use a hibernate entity and store the integer value as a field. Letting hibernate handle the threading issues where a sessionfactory will be injected into dao, and the dao injected into service classes – scaling issues ? My spring classes are all singletons.