annotate a class ApplicationCache with:
@javax.enterprise.context.ApplicationScoped
@javax.ejb.Singleton
@javax.ejb.ConcurrencyManagement(ConcurrencyManagementType.BEAN)
initialize it with a method annotated with
@javax.annotation.PostConstruct
public void startup()
provide a scheduled method:
@javax.ejb.Schedule(dayOfWeek = "1-5", hour = "*", minute = "*/30", persistent = false)
public void refreshCache()
Wherever you want to invoke a service method on the above class, you acquire a reference with
@javax.inject.Inject
private ApplicationCache applicationCache;
=================
If you need a logger:
@javax.inject.Inject
private org.slf4j.Logger logger;
=================
if you need a thread-safe collection:
private final List
private final Map
===================
No comments:
Post a Comment