Compare commits

...

11 Commits

Author SHA1 Message Date
lucio 6b056664a9 updated 2023-04-04 09:26:45 +02:00
lucio 7738b1ea1f warning removed 2023-02-02 11:14:56 +01:00
lucio 73cba3adc7 updated 2023-02-01 14:41:47 +01:00
Lucio Lelii d04d5dafbf AuthorizationProvider moved from configuration to context 2023-01-19 16:16:48 +01:00
Lucio Lelii c80f8896a1 solved bug on remove context 2022-12-06 14:50:36 +01:00
Lucio Lelii c20234af24 solved bug on shutdown 2022-09-12 15:32:57 +02:00
Lucio Lelii bdbbd55d8c logs improved 2022-06-22 18:26:37 +02:00
Lucio Lelii b65fe507af changes on OnlineObserver 2022-06-10 17:11:39 +02:00
Lucio Lelii e076dc39de removed ScopeProvider 2022-05-30 18:30:17 +02:00
Lucio Lelii 9f90b83724 removed ScopeProvier 2022-05-25 18:58:02 +02:00
Lucio Lelii 558e8af575 pom updated 2022-05-09 10:03:16 +02:00
17 changed files with 181 additions and 162 deletions

View File

@ -1,5 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
@ -13,16 +24,5 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target/

View File

@ -1,8 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@ -10,6 +10,6 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.source=11

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="common-smartgears-app">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/src/main/java"/>
</wb-module>
</project-modules>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.utility" version="1.0"/>
<installed facet="java" version="1.8"/>
<installed facet="java" version="11"/>
</faceted-project>

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.0.0-SNAPSHOT] - [2022-05-13]
porting to new IAM
## [v2.1.0] - [2022-02-04]
added OfflineObserver for test purpose

31
pom.xml
View File

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -10,12 +11,15 @@
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId>
<version>2.1.0</version>
<version>3.0.0-SNAPSHOT</version>
<name>Smartgears Application</name>
<properties>
<distroDirectory>distro</distroDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<scm>
@ -24,6 +28,18 @@
<url>https://code-repo.d4science.org/gCubeSystem/common-smartgears-app</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
@ -36,7 +52,6 @@
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
@ -56,10 +71,14 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-security</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -32,16 +32,19 @@ public abstract class ApplicationManagerProvider {
protected static synchronized void init(ApplicationContext appcontext) {
if (!initialized) {
if (appcontext.container().configuration().mode()== Mode.offline)
if (appcontext.container().configuration().mode()== Mode.offline)
instance = new OfflineProvider();
else
instance = new OnlineProvider();
initialized =true;
}
}
public static synchronized ApplicationManager get(final Class<? extends ApplicationManager> applicationManagerClass){
if (!initialized) throw new RuntimeException("ApplicationManagerProvider not yet initialized");
logger.debug("retrieveing application manager of {} ",applicationManagerClass.getCanonicalName());
Object obj = instance.getApplicationManagerObject(applicationManagerClass);
return applicationManagerClass.cast(obj);
}
@ -56,16 +59,17 @@ public abstract class ApplicationManagerProvider {
logger.trace("getting object {} from cache ",_class.getCanonicalName());
return obj;
} else {
obj = _class.newInstance();
obj = _class.getDeclaredConstructor().newInstance();
classProxyObjetMap.put(_class.getCanonicalName(), obj);
}
logger.debug("proxy created for {} ",applicationManagerClass.getCanonicalName());
} catch (Exception e) {
throw new RuntimeException("error creating proxy ", e);
}
((ProxyObject)obj).setHandler(getMethdoHandler(applicationManagerClass));
((ProxyObject)obj).setHandler(this.getMethodHandler(applicationManagerClass));
return obj;
}
@ -108,7 +112,7 @@ public abstract class ApplicationManagerProvider {
}
protected abstract Future<ApplicationManager> retrieveFuture(Class<? extends ApplicationManager> applicationManagerClass);
protected abstract MethodHandler getMethdoHandler(Class<? extends ApplicationManager> applicationManagerClass);
protected abstract MethodHandler getMethodHandler(Class<? extends ApplicationManager> applicationManagerClass);
protected abstract AppManagerObserver getObserver();
}

View File

@ -4,12 +4,10 @@ import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.gcube.smartgears.Constants;
import org.gcube.smartgears.annotations.ManagedBy;
import org.gcube.smartgears.application.manager.AppManagerObserver;
import org.gcube.smartgears.context.application.ApplicationContext;
@ -61,15 +59,14 @@ public class ContextListener implements ServletContextListener {
Set<Class<? extends ApplicationManager>> managers = new HashSet<Class<? extends ApplicationManager>>();
for (Class<?> initializer: toInitialize ){
ManagedBy manageBy = initializer.getAnnotation(ManagedBy.class);
log.info("ApplicationManager added {} @ {}", manageBy.value().getSimpleName(), context.name());
log.info("ApplicationManager added {} to {} @ {}", manageBy.value().getSimpleName(), initializer.getSimpleName(), context.name());
managers.add(manageBy.value());
}
if (managers.size()>0){
observer = ApplicationManagerProvider.instance.getObserver();
observer.setStartingTokens(context.configuration().startTokens());
observer.setAuthorizationProvider(context.container().authorizationProvider());
observer.setApplicationManagerClasses(managers);
observer.register();
context.events().subscribe(observer);
}
}

View File

@ -8,7 +8,8 @@ import org.gcube.smartgears.context.Properties;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.context.container.ContainerContext;
import org.gcube.smartgears.lifecycle.application.ApplicationLifecycle;
import org.gcube.smartgears.persistence.Persistence;
import org.gcube.smartgears.persistence.PersistenceWriter;
import org.gcube.smartgears.security.AuthorizationProvider;
/**
* Embedded in an application, makes available its context as a gCube resource.
@ -56,12 +57,7 @@ public class ContextProvider {
public ApplicationConfiguration configuration() {
return delegate.configuration();
}
@Override
public <T> T profile(Class<T> type) {
return delegate.profile(type);
}
@Override
public ApplicationLifecycle lifecycle() {
return delegate.lifecycle();
@ -71,12 +67,7 @@ public class ContextProvider {
public Hub events() {
return delegate.events();
}
@Override
public Persistence persistence() {
return delegate.persistence();
}
@Override
public ServletContext application() {
return delegate.application();
@ -96,6 +87,16 @@ public class ContextProvider {
public String id() {
return delegate.id();
}
@Override
public PersistenceWriter persistence() {
return delegate.persistence();
}
@Override
public AuthorizationProvider authorizationProvider() {
return delegate.authorizationProvider();
}
}
}

View File

@ -0,0 +1,26 @@
package org.gcube.smartgears;
import java.util.concurrent.Future;
public class ManagerPair {
private Class<? extends ApplicationManager> clazz;
private Future<ApplicationManager> future;
public ManagerPair(Class<? extends ApplicationManager> clazz, Future<ApplicationManager> future) {
super();
this.clazz = clazz;
this.future = future;
}
public Class<? extends ApplicationManager> getImplementationClass() {
return clazz;
}
public Future<ApplicationManager> getFuture() {
return future;
}
}

View File

@ -1,10 +1,10 @@
package org.gcube.smartgears.application.manager;
import java.util.Collection;
import java.util.Set;
import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.security.AuthorizationProvider;
public interface AppManagerObserver {
@ -16,7 +16,7 @@ public interface AppManagerObserver {
void unregister();
void setStartingTokens(Collection<String> startingTokens);
public void setAuthorizationProvider(AuthorizationProvider authProvider);
void setApplicationManagerClasses(Set<Class<? extends ApplicationManager>> managersClasses);

View File

@ -1,6 +1,5 @@
package org.gcube.smartgears.application.manager;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@ -13,6 +12,7 @@ import org.gcube.common.events.Observes.Kind;
import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.Constants;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.smartgears.security.AuthorizationProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -79,7 +79,7 @@ public class OfflineObserver implements AppManagerObserver {
@Override
public ApplicationManager call() throws Exception {
ApplicationManager manager = managerClass.newInstance();
ApplicationManager manager = managerClass.getDeclaredConstructor().newInstance();
try {
log.info("calling on onInit of {}",manager.getClass().getCanonicalName());
manager.onInit();
@ -109,13 +109,15 @@ public class OfflineObserver implements AppManagerObserver {
}
}
@Override
public void setStartingTokens(Collection<String> startingTokens) {
}
@Override
public void setApplicationManagerClasses(Set<Class<? extends ApplicationManager>> managerClasses) {
this.managerClasses = managerClasses;
}
@Override
public void setAuthorizationProvider(AuthorizationProvider authProvider) {
}
}

View File

@ -27,7 +27,7 @@ public class OfflineProvider extends ApplicationManagerProvider {
}
@Override
protected MethodHandler getMethdoHandler(Class<? extends ApplicationManager> applicationManagerClass) {
protected MethodHandler getMethodHandler(Class<? extends ApplicationManager> applicationManagerClass) {
MethodHandler handler = new MethodHandler() {
@Override
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {

View File

@ -1,9 +1,6 @@
package org.gcube.smartgears.application.manager;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -13,14 +10,15 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.events.Observes;
import org.gcube.common.events.Observes.Kind;
import org.gcube.common.scope.api.ScopeProvider;
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;
import org.slf4j.LoggerFactory;
@ -30,37 +28,41 @@ public class OnlineObserver implements AppManagerObserver{
private static ExecutorService service = Executors.newCachedThreadPool();
private Map<String, List<Future<ApplicationManager>>> instanciatedManagerPerScope = new HashMap<String, List<Future<ApplicationManager>>>();
private Map<String, List<ManagerPair>> instanciatedManagerPerScope = new HashMap<String, List<ManagerPair>>();
private OnlineProvider provider;
private Collection<String> startingTokens;
private AuthorizationProvider authProvider;
private Set<Class<? extends ApplicationManager>> managersClasses;
public OnlineObserver(OnlineProvider provider) {
this.provider = provider;
}
public void register() {
for (String startingToken : startingTokens )
this.onRegistration(startingToken);
for (String context : authProvider.getContexts()) {
this.onRegistration(context);
}
}
@Observes(value=Constants.token_registered, kind=Kind.safe)
public synchronized void onRegistration(final String securityToken){
log.info("token registered called with token {}", securityToken);
List<Future<ApplicationManager>> futureList = new ArrayList<Future<ApplicationManager>>();
public synchronized void onRegistration(String context){
log.info("registration called in context {}", context);
List<ManagerPair> futureList = new ArrayList<ManagerPair>();
try {
final String context = authorizationService().get(securityToken).getContext();
Secret secret = authProvider.getSecretForContext(context);
for (Class<? extends ApplicationManager> appManager: managersClasses){
Future<ApplicationManager> appManagerFuture = service.submit(new InitAppManager(securityToken, context, appManager));
log.info("intializing app in context {} with token {} ",context, securityToken);
Future<ApplicationManager> 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 {
@ -71,31 +73,28 @@ public class OnlineObserver implements AppManagerObserver{
}
if (!futureList.isEmpty())
instanciatedManagerPerScope.put(context, futureList);
} catch (ObjectNotFound e1) {
log.error("it should never happen (token has just been created)",e1);
throw new RuntimeException("it should never happen (token has just been created",e1);
} catch (Exception e1) {
log.error("something failed getting token",e1);
throw new RuntimeException("something failed getting token",e1);
log.error("something failed getting authorization",e1);
throw new RuntimeException("something failed getting authorization",e1);
}
}
@Observes(value=Constants.token_removed, kind=Kind.critical)
public synchronized void onRemove(final String securityToken){
public synchronized void onRemove(String context){
try {
final String context = authorizationService().get(securityToken).getContext();
for (Future<ApplicationManager> appManager: instanciatedManagerPerScope.get(context)){
service.execute(new ShutDownAppManager(securityToken, context, appManager));
provider.getAppmanagerMap().get(appManager).remove(context);
}
Secret secret = authProvider.getSecretForContext(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);
SecurityTokenProvider.instance.reset();
} catch (ObjectNotFound e1) {
log.error("it should never happen (token has just been created)",e1);
throw new RuntimeException("it should never happen (token has just been created",e1);
} catch (Exception e1) {
log.error("something failed getting token",e1);
throw new RuntimeException("something failed getting token",e1);
@ -104,35 +103,9 @@ public class OnlineObserver implements AppManagerObserver{
public synchronized void onStop(ApplicationContext appContext){
for (String token :appContext.configuration().startTokens()){
try {
String context = authorizationService().get(token).getContext();
for (Future<ApplicationManager> appManagerEntry: instanciatedManagerPerScope.get(context)){
try{
log.info("stoppping {} in context {} ",appContext.name(), context);
for (String context :appContext.authorizationProvider().getContexts())
this.onRemove(context);
SecurityTokenProvider.instance.set(token);
ScopeProvider.instance.set(context);
try {
appManagerEntry.get().onShutdown();
log.info("manager {} correctly suhtdown on context {}",appContext.name(), context);
} catch (Exception e){
log.warn("problem calling onShutdown for context {}", context, e);
}
}catch(Exception e){
log.error("error retrieving token on shutdown on context {}", context,e);
throw new RuntimeException("error retrieving token on shutdown",e);
}finally{
ScopeProvider.instance.reset();
SecurityTokenProvider.instance.reset();
}
}
} catch (ObjectNotFound e1) {
log.error("token not found : {}",token,e1);
} catch (Exception e1) {
log.error("something failed getting token {}",token,e1);
}
}
unregister();
}
@ -143,28 +116,27 @@ public class OnlineObserver implements AppManagerObserver{
public class InitAppManager implements Callable<ApplicationManager>{
private Class<? extends ApplicationManager> managerClass;
private String securityToken;
private String context;
private Secret secret;
public InitAppManager(String securityToken, String context, Class<? extends ApplicationManager> managerClass){
public InitAppManager(Secret secret, Class<? extends ApplicationManager> managerClass){
this.managerClass = managerClass;
this.securityToken = securityToken;
this.context = context;
this.secret = secret;
}
@Override
public ApplicationManager call() throws Exception {
SecurityTokenProvider.instance.set(securityToken);
ScopeProvider.instance.set(context);
ApplicationManager manager = managerClass.newInstance();
log.info("on init called");
SecretManagerProvider.instance.set(secret);
ApplicationManager manager = null;
try {
log.info("calling on onInit of {} on token {}",manager.getClass().getCanonicalName(), securityToken);
manager = managerClass.getDeclaredConstructor().newInstance();
log.info("calling on onInit on manager {} with secret {}",manager.getClass().getCanonicalName(),secret);
manager.onInit();
} catch (Exception e) {
log.warn("error on onInit of {} on token {}",manager.getClass().getCanonicalName(), securityToken, e);
log.warn("error on onInit of {} on context {}",manager.getClass().getCanonicalName(), secret.getContext(), e);
} finally{
ScopeProvider.instance.reset();
SecurityTokenProvider.instance.reset();
SecretManagerProvider.instance.reset();
}
return manager;
}
@ -173,35 +145,31 @@ public class OnlineObserver implements AppManagerObserver{
public class ShutDownAppManager implements Runnable{
private Future<ApplicationManager> appManager;
private String securityToken;
private String context;
private Secret secret;
public ShutDownAppManager(String securityToken, String context, Future<ApplicationManager> appManager){
public ShutDownAppManager(Secret secret, Future<ApplicationManager> appManager){
this.appManager = appManager;
this.securityToken = securityToken;
this.context = context;
}
@Override
public void run() {
SecurityTokenProvider.instance.set(securityToken);
ScopeProvider.instance.set(context);
SecretManagerProvider.instance.set(secret);
try {
log.info("calling on ShutDown of {} on token {}",appManager.getClass().getCanonicalName(), securityToken);
log.info("calling on ShutDown of {} on context {}",appManager.getClass().getCanonicalName(), secret.getContext());
appManager.get().onShutdown();
} catch (Exception e) {
log.warn("error on onShutdown of {} on token {}",appManager.getClass().getCanonicalName(), securityToken, e);
log.warn("error on onShutdown of {} on context {}",appManager.getClass().getCanonicalName(), secret.getContext(), e);
} finally{
ScopeProvider.instance.reset();
SecurityTokenProvider.instance.reset();
SecretManagerProvider.instance.reset();
}
}
}
@Override
public void setStartingTokens(Collection<String> startingTokens) {
this.startingTokens = startingTokens;
public void setAuthorizationProvider(AuthorizationProvider authProvider) {
this.authProvider = authProvider;
}
@Override
@ -209,5 +177,5 @@ public class OnlineObserver implements AppManagerObserver{
this.managersClasses = managersClasses;
}
}

View File

@ -5,7 +5,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.ApplicationManagerProvider;
import org.slf4j.Logger;
@ -25,15 +26,18 @@ public class OnlineProvider extends ApplicationManagerProvider {
@Override
protected Future<ApplicationManager> retrieveFuture(Class<? extends ApplicationManager> applicationManagerClass) {
return appManagerMap.get(applicationManagerClass.getCanonicalName()).get(ScopeProvider.instance.get());
Secret secret = SecretManagerProvider.instance.get();
String context = secret.getContext();
logger.debug("retrieving appManager {} in context {}",applicationManagerClass.getCanonicalName(), context);
return appManagerMap.get(applicationManagerClass.getCanonicalName()).get(context);
}
@Override
protected MethodHandler getMethdoHandler(Class<? extends ApplicationManager> applicationManagerClass) {
protected MethodHandler getMethodHandler(Class<? extends ApplicationManager> applicationManagerClass) {
MethodHandler handler = new MethodHandler() {
@Override
public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
if (ScopeProvider.instance.get()==null) throw new RuntimeException("error invoking application manager method, scope is not set in this thread");
if (SecretManagerProvider.instance.get()==null) throw new Exception("error invoking application manager method, secret is not set in this thread");
logger.debug("applicationManagerClass is {}",applicationManagerClass.getCanonicalName());
Future<ApplicationManager> appManagerFuture = retrieveFuture(applicationManagerClass);
logger.debug("appmanager future is null? {}", appManagerFuture==null);

View File

@ -1,12 +0,0 @@
package org.gcube.smartgears.stateful;
import org.junit.Test;
public class ResourceBinder {
@Test
public void bind() throws Exception{
}
}