Improving code
This commit is contained in:
parent
721e69034b
commit
604856b4d2
|
@ -103,29 +103,23 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
||||||
Set<String> startTokens = applicationContext.configuration().startTokens();
|
Set<String> startTokens = applicationContext.configuration().startTokens();
|
||||||
|
|
||||||
Set<UUID> startContextsUUID = new HashSet<>();
|
Set<UUID> startContextsUUID = new HashSet<>();
|
||||||
ContextCache contextCache = ContextCache.getInstance();
|
|
||||||
for (String token : startTokens) {
|
for (String token : startTokens) {
|
||||||
|
UUID contextUUID = ContextUtility.getContextUUID(token);
|
||||||
if (create) {
|
if (create) {
|
||||||
ContextUtility.setContextFromToken(token);
|
ContextUtility.setContextFromToken(token);
|
||||||
eServiceManager = new EServiceManager(applicationContext);
|
eServiceManager = new EServiceManager(applicationContext);
|
||||||
eServiceManager.createEService();
|
eServiceManager.createEService();
|
||||||
// applicationContext.properties()
|
|
||||||
// .add(new Property(Constants.ESERVICE_MANAGER_PROPERTY, eServiceManager));
|
|
||||||
create = false;
|
create = false;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
UUID contextUUID = ContextUtility.getContextUUID(token);
|
|
||||||
eServiceManager.addToContext(contextUUID);
|
eServiceManager.addToContext(contextUUID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
UUID uuid = UUID.fromString(applicationContext.id());
|
UUID uuid = UUID.fromString(applicationContext.id());
|
||||||
logger.error("Unable to add {} with UUID {} to current context ({})", EService.NAME, uuid,
|
logger.error("Unable to add {} with UUID {} to current context ({})", EService.NAME, uuid,
|
||||||
ContextUtility.getContextName(token), e);
|
ContextUtility.getContextName(token), e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String contextFullName = ContextUtility.getContextName(token);
|
|
||||||
UUID contextUUID = contextCache.getUUIDByFullName(contextFullName);
|
|
||||||
startContextsUUID.add(contextUUID);
|
startContextsUUID.add(contextUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,28 +103,23 @@ public class HostingNodeHandler extends ContainerHandler {
|
||||||
List<String> startTokens = containerContext.configuration().startTokens();
|
List<String> startTokens = containerContext.configuration().startTokens();
|
||||||
|
|
||||||
Set<UUID> startContextsUUID = new HashSet<>();
|
Set<UUID> startContextsUUID = new HashSet<>();
|
||||||
ContextCache contextCache = ContextCache.getInstance();
|
|
||||||
for (String token : startTokens) {
|
for (String token : startTokens) {
|
||||||
|
UUID contextUUID = ContextUtility.getContextUUID(token);
|
||||||
if (create) {
|
if (create) {
|
||||||
ContextUtility.setContextFromToken(token);
|
ContextUtility.setContextFromToken(token);
|
||||||
hostingNodeManager = new HostingNodeManager(containerContext);
|
hostingNodeManager = new HostingNodeManager(containerContext);
|
||||||
hostingNodeManager.createHostingNode();
|
hostingNodeManager.createHostingNode();
|
||||||
// containerContext.properties()
|
|
||||||
// .add(new Property(Constants.HOSTING_NODE_MANAGER_PROPERTY, hostingNodeManager));
|
|
||||||
create = false;
|
create = false;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
UUID contextUUID = ContextUtility.getContextUUID(token);
|
|
||||||
hostingNodeManager.addToContext(contextUUID);
|
hostingNodeManager.addToContext(contextUUID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
UUID uuid = UUID.fromString(containerContext.id());
|
UUID uuid = UUID.fromString(containerContext.id());
|
||||||
logger.error("Unable to add {} with UUID {} to current context ({})", HostingNode.NAME, uuid,
|
logger.error("Unable to add {} with UUID {} to current context ({})", HostingNode.NAME, uuid,
|
||||||
ContextUtility.getContextName(token), e);
|
ContextUtility.getContextName(token), e);
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String contextFullName = ContextUtility.getContextName(token);
|
|
||||||
UUID contextUUID = contextCache.getUUIDByFullName(contextFullName);
|
|
||||||
startContextsUUID.add(contextUUID);
|
startContextsUUID.add(contextUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue