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() {
|
||||
|
||||
// @Observes({ activation, stop, failure })
|
||||
@Observes({ activation })
|
||||
@Observes({ activation, stop, failure })
|
||||
void onChanged(ApplicationLifecycle lc) {
|
||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||
String previousToken = SecurityTokenProvider.instance.get();
|
||||
|
@ -129,9 +128,9 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
|||
ContextUtility.setContextFromToken(previousToken);
|
||||
Thread.currentThread().setContextClassLoader(contextCL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Observes({ stop, failure })
|
||||
void onStop(ApplicationLifecycle lc) {
|
||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||
|
@ -151,7 +150,8 @@ public class EServiceHandler extends ApplicationLifecycleHandler {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@Observes(value = addToContext)
|
||||
void addTo(String token) {
|
||||
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
|
||||
|
|
|
@ -181,6 +181,16 @@ public class EServiceManager {
|
|||
try {
|
||||
resourceRegistryClient.exists(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) {
|
||||
eService = instantiateEService();
|
||||
createActivatesRelation(eService);
|
||||
|
@ -196,6 +206,16 @@ public class EServiceManager {
|
|||
// already be in the context due to propagation constraint.
|
||||
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) {
|
||||
throw e;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue