added play-framework project (#678)
* made changes to java reflection * removed redundant method makeSound in Animal abstract class * added project for play-framework article
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
334e1b3f83
commit
0835118e85
@@ -0,0 +1,26 @@
|
||||
package services;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.inject.*;
|
||||
|
||||
/**
|
||||
* This class is a concrete implementation of the {@link Counter} trait.
|
||||
* It is configured for Guice dependency injection in the {@link Module}
|
||||
* class.
|
||||
*
|
||||
* This class has a {@link Singleton} annotation because we need to make
|
||||
* sure we only use one counter per application. Without this
|
||||
* annotation we would get a new instance every time a {@link Counter} is
|
||||
* injected.
|
||||
*/
|
||||
@Singleton
|
||||
public class AtomicCounter implements Counter {
|
||||
|
||||
private final AtomicInteger atomicCounter = new AtomicInteger();
|
||||
|
||||
@Override
|
||||
public int nextCount() {
|
||||
return atomicCounter.getAndIncrement();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user