modified manager

This commit is contained in:
lucio 2024-02-22 16:26:44 +01:00
parent 932e924ba4
commit a8d7d6c381
9 changed files with 49 additions and 17 deletions

View File

@ -25,6 +25,12 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View File

@ -15,6 +15,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name> <name>org.eclipse.m2e.core.maven2Builder</name>
<arguments> <arguments>
@ -22,8 +27,11 @@
</buildCommand> </buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,5 +1,6 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8 encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8 encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8

View File

@ -1,8 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 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.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.release=disabled
org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.compiler.source=11

View File

@ -1,4 +1,4 @@
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java11-tomcat9 FROM smartgears-distribution:4.0.0-SNAPSHOT-java11-tomcat9
COPY ./docker/logback.xml /etc/ COPY ./docker/logback.xml /etc/
COPY ./docker/container.ini /etc/ COPY ./docker/container.ini /etc/

View File

@ -1,5 +1,5 @@
[node] [node]
mode = offline mode = online
hostname = myhostname.isti.cnr.it hostname = myhostname.isti.cnr.it
protocol= http protocol= http
port = 8080 port = 8080

View File

@ -9,8 +9,9 @@
<logger name="org.gcube.service.helloworld" level="DEBUG" /> <logger name="org.gcube.service.helloworld" level="DEBUG" />
<logger name="org.gcube.smartgears" level="DEBUG" />
<root level="DEBUG"> <root level="INFO">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>

View File

@ -3,15 +3,18 @@ package manager;
import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret; import org.gcube.common.security.secrets.Secret;
import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.configuration.Mode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* *
* This class is use to Manage the application initialization and shutdown per context; * This class is use to Manage the application initialization and shutdown per
* The init and shutdown methods are called one per context in which the app is running * context; The init and shutdown methods are called one per context in which
* respectively at init and a shutdown time. * the app is running respectively at init and a shutdown time. It is connected
* It is connected to the app declaring it via the @ManagedBy annotation. (@see HelloWorld class) * to the app declaring it via the @ManagedBy annotation. (@see HelloWorld
* class)
* *
* *
* @author lucio * @author lucio
@ -19,19 +22,27 @@ import org.slf4j.LoggerFactory;
*/ */
public class HelloWorldManager implements ApplicationManager { public class HelloWorldManager implements ApplicationManager {
Logger logger = LoggerFactory.getLogger(HelloWorldManager.class); Logger logger = LoggerFactory.getLogger(HelloWorldManager.class);
@Override @Override
public void onInit() { public void onInit() {
Secret secret = SecretManagerProvider.get(); if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
logger.debug("init called in context {}", secret.getContext()); logger.debug("init called in offline mode");
} else {
Secret secret = SecretManagerProvider.get();
logger.debug("init called in context {}", secret.getContext());
}
} }
@Override @Override
public void onShutdown() { public void onShutdown() {
Secret secret = SecretManagerProvider.get(); if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
logger.debug("shutDown called in context {}", secret.getContext()); logger.debug("shutDown called in offline mode");
} else {
Secret secret = SecretManagerProvider.get();
logger.debug("shutDown called in context {}", secret.getContext());
}
} }
} }

View File

@ -7,6 +7,7 @@ import javax.ws.rs.core.MediaType;
import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret; import org.gcube.common.security.secrets.Secret;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.annotations.ManagedBy; import org.gcube.smartgears.annotations.ManagedBy;
import org.gcube.smartgears.utils.InnerMethodName; import org.gcube.smartgears.utils.InnerMethodName;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -14,7 +15,6 @@ import org.slf4j.LoggerFactory;
import manager.HelloWorldManager; import manager.HelloWorldManager;
@ManagedBy(HelloWorldManager.class) @ManagedBy(HelloWorldManager.class)
@Path("hello") @Path("hello")
public class HelloService { public class HelloService {
@ -28,8 +28,10 @@ public class HelloService {
Secret secret = SecretManagerProvider.get(); Secret secret = SecretManagerProvider.get();
String userId = secret.getOwner().getId(); String userId = secret.getOwner().getId();
String context = secret.getContext(); String context = secret.getContext();
String infrastructureName = ContextProvider.get().container().configuration().infrastructure();
logger.info("caller id is {}",userId); logger.info("caller id is {}",userId);
return String.format("Hello %s in context %s", userId,context); return String.format("Hello %s in context %s in infastructure {}", userId,context, infrastructureName);
} }
} }