mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
remove unneeded synchronization locks on settings
This commit is contained in:
@@ -3,7 +3,8 @@ package com.commafeed.backend.services;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import javax.ejb.Singleton;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.enterprise.context.ApplicationScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.commons.lang.time.DateUtils;
|
import org.apache.commons.lang.time.DateUtils;
|
||||||
@@ -15,7 +16,7 @@ import com.commafeed.backend.dao.ApplicationSettingsDAO;
|
|||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
@Singleton
|
@ApplicationScoped
|
||||||
public class ApplicationSettingsService {
|
public class ApplicationSettingsService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -23,19 +24,21 @@ public class ApplicationSettingsService {
|
|||||||
|
|
||||||
private ApplicationSettings settings;
|
private ApplicationSettings settings;
|
||||||
|
|
||||||
public void save(ApplicationSettings settings) {
|
@PostConstruct
|
||||||
this.settings = settings;
|
private void init() {
|
||||||
applicationSettingsDAO.saveOrUpdate(settings);
|
settings = Iterables.getFirst(applicationSettingsDAO.findAll(), null);
|
||||||
applyLogLevel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationSettings get() {
|
public ApplicationSettings get() {
|
||||||
if (settings == null) {
|
|
||||||
settings = Iterables.getFirst(applicationSettingsDAO.findAll(), null);
|
|
||||||
}
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(ApplicationSettings settings) {
|
||||||
|
applicationSettingsDAO.saveOrUpdate(settings);
|
||||||
|
this.settings = settings;
|
||||||
|
applyLogLevel();
|
||||||
|
}
|
||||||
|
|
||||||
public Date getUnreadThreshold() {
|
public Date getUnreadThreshold() {
|
||||||
int keepStatusDays = get().getKeepStatusDays();
|
int keepStatusDays = get().getKeepStatusDays();
|
||||||
return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null;
|
return keepStatusDays > 0 ? DateUtils.addDays(new Date(), -1 * keepStatusDays) : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user