Fixed handlers
This commit is contained in:
parent
8e35e18b58
commit
625ed37d88
|
@ -111,8 +111,7 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
||||||
|
|
||||||
applicationContext.events().subscribe(new Object() {
|
applicationContext.events().subscribe(new Object() {
|
||||||
|
|
||||||
// @Observes({ activation, stop, failure })
|
@Observes({ activation, stop, failure })
|
||||||
@Observes({ activation })
|
|
||||||
void onChanged(ApplicationLifecycle lc) {
|
void onChanged(ApplicationLifecycle lc) {
|
||||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||||
String previousToken = SecurityTokenProvider.instance.get();
|
String previousToken = SecurityTokenProvider.instance.get();
|
||||||
|
@ -129,9 +128,9 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
||||||
ContextUtility.setContextFromToken(previousToken);
|
ContextUtility.setContextFromToken(previousToken);
|
||||||
Thread.currentThread().setContextClassLoader(contextCL);
|
Thread.currentThread().setContextClassLoader(contextCL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Observes({ stop, failure })
|
@Observes({ stop, failure })
|
||||||
void onStop(ApplicationLifecycle lc) {
|
void onStop(ApplicationLifecycle lc) {
|
||||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||||
|
@ -151,7 +150,8 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Observes(value = addToContext)
|
@Observes(value = addToContext)
|
||||||
void addTo(String token) {
|
void addTo(String token) {
|
||||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
|
@ -181,6 +181,16 @@ public class EServiceManager {
|
||||||
try {
|
try {
|
||||||
resourceRegistryClient.exists(EService.class, eServiceUUID);
|
resourceRegistryClient.exists(EService.class, eServiceUUID);
|
||||||
eService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
eService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
||||||
|
serviceStateFacet = eService.getFacets(ServiceStateFacet.class).get(0);
|
||||||
|
if(serviceStateFacet==null) {
|
||||||
|
serviceStateFacet = new ServiceStateFacetImpl();
|
||||||
|
String state = getState();
|
||||||
|
serviceStateFacet.setValue(state);
|
||||||
|
eService.addFacet(serviceStateFacet);
|
||||||
|
resourceRegistryPublisher.update(eService);
|
||||||
|
}else{
|
||||||
|
updateServiceStateFacet();
|
||||||
|
}
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
eService = instantiateEService();
|
eService = instantiateEService();
|
||||||
createActivatesRelation(eService);
|
createActivatesRelation(eService);
|
||||||
|
@ -196,6 +206,16 @@ public class EServiceManager {
|
||||||
// already be in the context due to propagation constraint.
|
// already be in the context due to propagation constraint.
|
||||||
createActivatesRelation(eService);
|
createActivatesRelation(eService);
|
||||||
}
|
}
|
||||||
|
serviceStateFacet = eService.getFacets(ServiceStateFacet.class).get(0);
|
||||||
|
if(serviceStateFacet==null) {
|
||||||
|
serviceStateFacet = new ServiceStateFacetImpl();
|
||||||
|
String state = getState();
|
||||||
|
serviceStateFacet.setValue(state);
|
||||||
|
eService.addFacet(serviceStateFacet);
|
||||||
|
resourceRegistryPublisher.update(eService);
|
||||||
|
}else{
|
||||||
|
updateServiceStateFacet();
|
||||||
|
}
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue