Merge remote-tracking branch 'origin/feature/22955'

This commit is contained in:
Lucio Lelii 2023-04-04 14:59:58 +02:00
commit dbaed80d4e
22 changed files with 162 additions and 277 deletions

View File

@ -13,15 +13,16 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</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="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="output" path="target/classes"/>
</classpath>

1
.gitignore vendored Normal file
View File

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

View File

@ -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=11

View File

@ -1,6 +1,15 @@
<?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-resource deploy-path="/" source-path="/src/test/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,9 +3,9 @@
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).
## [v2.1.1] - [2022-12-06]
## [v3.0.0-SNAPSHOT] - [2022-05-13]
solved a bug on removeContext
porting to new IAM
## [v2.1.0] - [2022-02-04]

View File

@ -1 +0,0 @@
${gcube.license}

View File

@ -1,66 +0,0 @@
The gCube System - ${name}
--------------------------------------------------
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy
* Lucio Lelii (lucio.lelii@isti.cnr.it), CNR, Italy
Maintainers
-----------
* Lucio Lelii (lucio.lelii@isti.cnr.it), CNR, Italy
Download information
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Installation documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}/Smartgears
Documentation
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}/Smartgears
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

View File

@ -1,11 +0,0 @@
<ReleaseNotes>
<Changeset component="${build.finalName}" date="2017-02-22">
<Change>Chaching for proxing of AppManager objects added</Change>
</Changeset>
<Changeset component="org.gcube.core.common-smartgears-app.2-0-0" date="2015-01-10">
<Change>Added support for initialization using security token</Change>
</Changeset>
<Changeset component="org.gcube.core.common-smartgears-app.1-0-0" date="2013-10-24">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,32 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID />
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>Common</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

66
pom.xml
View File

@ -11,14 +11,15 @@
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId>
<version>2.1.1</version>
<version>3.0.0-SNAPSHOT</version>
<name>Smartgears Application</name>
<properties>
<distroDirectory>distro</distroDirectory>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<scm>
@ -27,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>
@ -39,7 +52,6 @@
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
@ -59,10 +71,14 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
<version>[3.0.0-SNAPSHOT,4.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>
@ -72,40 +88,4 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

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

@ -23,4 +23,8 @@ public class ManagerPair {
}
<<<<<<< HEAD
}
=======
}
>>>>>>> refs/remotes/origin/feature/22955

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,15 +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;
@ -35,7 +32,11 @@ public class OnlineObserver implements AppManagerObserver{
private OnlineProvider provider;
<<<<<<< HEAD
private Collection<String> startingTokens;
=======
private AuthorizationProvider authProvider;
>>>>>>> refs/remotes/origin/feature/22955
private Set<Class<? extends ApplicationManager>> managersClasses;
@ -45,21 +46,30 @@ public class OnlineObserver implements AppManagerObserver{
}
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)
<<<<<<< HEAD
public synchronized void onRegistration(final String securityToken){
log.info("token registered called with token {}", securityToken);
=======
public synchronized void onRegistration(String context){
log.info("registration called in context {}", context);
>>>>>>> refs/remotes/origin/feature/22955
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(new ManagerPair(appManager, appManagerFuture));
if (provider.getAppmanagerMap().containsKey(appManager.getCanonicalName()))
@ -72,21 +82,18 @@ 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();
<<<<<<< HEAD
if(instanciatedManagerPerScope.get(context) != null ) {
for (ManagerPair manager: instanciatedManagerPerScope.get(context)){
service.execute(new ShutDownAppManager(securityToken, context, manager.getFuture()));
@ -94,11 +101,26 @@ public class OnlineObserver implements AppManagerObserver{
}
instanciatedManagerPerScope.remove(context);
}
=======
Secret secret = authProvider.getSecretForContext(context);
>>>>>>> refs/remotes/origin/feature/22955
<<<<<<< HEAD
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);
=======
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);
>>>>>>> refs/remotes/origin/feature/22955
} catch (Exception e1) {
log.error("something failed getting token",e1);
throw new RuntimeException("something failed getting token",e1);
@ -107,6 +129,7 @@ public class OnlineObserver implements AppManagerObserver{
public synchronized void onStop(ApplicationContext appContext){
<<<<<<< HEAD
for (String token :appContext.configuration().startTokens()){
try {
String context = authorizationService().get(token).getContext();
@ -114,7 +137,12 @@ public class OnlineObserver implements AppManagerObserver{
for (ManagerPair manager: instanciatedManagerPerScope.get(context)){
try{
log.info("stoppping {} in context {} ",appContext.name(), context);
=======
for (String context :appContext.authorizationProvider().getContexts())
this.onRemove(context);
>>>>>>> refs/remotes/origin/feature/22955
<<<<<<< HEAD
SecurityTokenProvider.instance.set(token);
ScopeProvider.instance.set(context);
try {
@ -138,6 +166,8 @@ public class OnlineObserver implements AppManagerObserver{
log.error("something failed getting token {}",token,e1);
}
}
=======
>>>>>>> refs/remotes/origin/feature/22955
unregister();
}
@ -148,28 +178,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;
}
@ -178,34 +207,35 @@ 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
<<<<<<< HEAD
public void setStartingTokens(Collection<String> startingTokens) {
this.startingTokens = startingTokens;
=======
public void setAuthorizationProvider(AuthorizationProvider authProvider) {
this.authProvider = authProvider;
>>>>>>> refs/remotes/origin/feature/22955
}

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{
}
}