diff --git a/.classpath b/.classpath
index 71e1373..2497e80 100644
--- a/.classpath
+++ b/.classpath
@@ -5,11 +5,7 @@
-
-
-
-
-
+
diff --git a/pom.xml b/pom.xml
index 01ce1a1..4d3f8e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,8 @@
distro
+ 1.8
+ 1.8
@@ -49,7 +51,6 @@
org.reflections
reflections
- 0.9.10
diff --git a/src/main/java/org/gcube/smartgears/ManagerPair.java b/src/main/java/org/gcube/smartgears/ManagerPair.java
new file mode 100644
index 0000000..cbd30af
--- /dev/null
+++ b/src/main/java/org/gcube/smartgears/ManagerPair.java
@@ -0,0 +1,26 @@
+package org.gcube.smartgears;
+
+import java.util.concurrent.Future;
+
+public class ManagerPair {
+
+ private Class extends ApplicationManager> clazz;
+
+ private Future future;
+
+ public ManagerPair(Class extends ApplicationManager> clazz, Future future) {
+ super();
+ this.clazz = clazz;
+ this.future = future;
+ }
+
+ public Class extends ApplicationManager> getImplementationClass() {
+ return clazz;
+ }
+
+ public Future getFuture() {
+ return future;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java b/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java
index 2da5322..1a354f6 100644
--- a/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java
+++ b/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java
@@ -16,6 +16,7 @@ import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.Constants;
+import org.gcube.smartgears.ManagerPair;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.security.AuthorizationProvider;
import org.slf4j.Logger;
@@ -27,7 +28,7 @@ public class OnlineObserver implements AppManagerObserver{
private static ExecutorService service = Executors.newCachedThreadPool();
- private Map>> instanciatedManagerPerScope = new HashMap>>();
+ private Map> instanciatedManagerPerScope = new HashMap>();
private OnlineProvider provider;
@@ -49,7 +50,7 @@ public class OnlineObserver implements AppManagerObserver{
@Observes(value=Constants.token_registered, kind=Kind.safe)
public synchronized void onRegistration(String context){
log.info("registration called in context {}", context);
- List> futureList = new ArrayList>();
+ List futureList = new ArrayList();
try {
@@ -61,7 +62,7 @@ public class OnlineObserver implements AppManagerObserver{
Future appManagerFuture = service.submit(new InitAppManager(secret, appManager));
log.info("intializing app using manager {} in context {}",appManager.getClass().getCanonicalName(),context);
- futureList.add(appManagerFuture);
+ futureList.add(new ManagerPair(appManager, appManagerFuture));
if (provider.getAppmanagerMap().containsKey(appManager.getCanonicalName()))
provider.getAppmanagerMap().get(appManager.getCanonicalName()).put(context, appManagerFuture);
else {
@@ -85,10 +86,14 @@ public class OnlineObserver implements AppManagerObserver{
Secret secret = authProvider.getSecretForContext(context);
- for (Future appManager: instanciatedManagerPerScope.get(context)){
- service.execute(new ShutDownAppManager(secret, appManager));
- provider.getAppmanagerMap().get(appManager.getClass().getCanonicalName()).remove(context);
- }
+ if(instanciatedManagerPerScope.get(context) != null ) {
+ for (ManagerPair manager: instanciatedManagerPerScope.get(context)){
+ service.execute(new ShutDownAppManager(secret, manager.getFuture()));
+ provider.getAppmanagerMap().get(manager.getImplementationClass().getCanonicalName()).remove(context);
+ }
+ instanciatedManagerPerScope.remove(context);
+ }
+
instanciatedManagerPerScope.remove(context);
} catch (Exception e1) {
log.error("something failed getting token",e1);