-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoteProjectManagerRepoImpl.java
70 lines (56 loc) · 2.47 KB
/
RemoteProjectManagerRepoImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package edu.tamu.app.model.repo.impl;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import edu.tamu.app.cache.service.ScheduledCache;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.model.repo.custom.RemoteProjectManagerRepoCustom;
import edu.tamu.app.service.registry.ManagementBeanRegistry;
import edu.tamu.weaver.data.model.repo.impl.AbstractWeaverRepoImpl;
public class RemoteProjectManagerRepoImpl extends AbstractWeaverRepoImpl<RemoteProjectManager, RemoteProjectManagerRepo> implements RemoteProjectManagerRepoCustom {
private static final Logger logger = LoggerFactory.getLogger(RemoteProjectManagerRepoImpl.class);
@Autowired
private RemoteProjectManagerRepo remoteProjectManagerRepo;
@Autowired
private ManagementBeanRegistry managementBeanRegistry;
@Autowired
private List<ScheduledCache<?, ?>> scheduledCaches;
@Override
public RemoteProjectManager create(RemoteProjectManager remoteProjectManager) {
remoteProjectManager = super.create(remoteProjectManager);
managementBeanRegistry.register(remoteProjectManager);
updateCache();
return remoteProjectManager;
}
@Override
public RemoteProjectManager update(RemoteProjectManager remoteProjectManager) {
RemoteProjectManager existingRemoteProductManager = remoteProjectManagerRepo.getById(remoteProjectManager.getId());
managementBeanRegistry.unregister(existingRemoteProductManager);
remoteProjectManager = super.update(remoteProjectManager);
managementBeanRegistry.register(remoteProjectManager);
updateCache();
return remoteProjectManager;
}
@Override
public void delete(RemoteProjectManager remoteProjectManager) {
managementBeanRegistry.unregister(remoteProjectManager);
super.delete(remoteProjectManager);
updateCache();
}
@Override
protected String getChannel() {
return "/channel/remote-project-manager";
}
private void updateCache() {
CompletableFuture.runAsync(() -> {
for (ScheduledCache<?, ?> sceduledCache : scheduledCaches) {
sceduledCache.schedule();
}
}).thenRun(() -> {
logger.info("Finished asynchronous cache update and brodcast");
});
}
}