Skip to content

Commit

Permalink
Merge pull request #20 from lucasponce/jshaughn/api
Browse files Browse the repository at this point in the history
Fix for recursive dependency between Definitions & Alerts services
  • Loading branch information
jshaughn committed Mar 3, 2015
2 parents 7676c0c + 6f20b6a commit 5e975a0
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class DbDefinitionsServiceImpl implements DefinitionsService {
private final String DS_NAME;
private DataSource ds;
private AlertsService alertsService;
private boolean initialized = false;

public DbDefinitionsServiceImpl() {
DS_NAME = System.getProperty("org.hawkular.alerts.engine.datasource", "java:jboss/datasources/HawkularDS");
Expand Down Expand Up @@ -119,6 +120,7 @@ public void init() {
}
String folder = data + "/" + INIT_FOLDER;
initFiles(folder);
initialized = true;
} catch (Throwable t) {
System.out.println(" !!!!!!!!!!!! " + t);
t.printStackTrace();
Expand Down Expand Up @@ -873,7 +875,7 @@ public Collection<Condition> setConditions(String triggerId, Trigger.Mode trigge
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(triggerId);
}

Expand Down Expand Up @@ -911,7 +913,7 @@ public Dampening addDampening(Dampening dampening) throws Exception {
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(dampening.getTriggerId());
}

Expand Down Expand Up @@ -1320,7 +1322,7 @@ public void removeDampening(String dampeningId) throws Exception {
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(dampening.getTriggerId());
}
}
Expand Down Expand Up @@ -1418,7 +1420,7 @@ public void removeTrigger(String triggerId) throws Exception {
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(triggerId);
}
}
Expand Down Expand Up @@ -1451,7 +1453,7 @@ public Dampening updateDampening(Dampening dampening) throws Exception {
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(dampening.getTriggerId());
}

Expand Down Expand Up @@ -1550,7 +1552,7 @@ public Trigger updateTrigger(Trigger trigger) throws Exception {
close(c, s);
}

if (null != alertsService) {
if (initialized && null != alertsService) {
alertsService.reloadTrigger(trigger.getId());
}

Expand Down

0 comments on commit 5e975a0

Please sign in to comment.