modified manager
This commit is contained in:
parent
932e924ba4
commit
a8d7d6c381
|
@ -25,6 +25,12 @@
|
|||
</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.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
|
8
.project
8
.project
|
@ -15,6 +15,11 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
|
@ -22,8 +27,11 @@
|
|||
</buildCommand>
|
||||
</buildSpec>
|
||||
<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.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
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.compliance=11
|
||||
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
|
||||
|
|
|
@ -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/container.ini /etc/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[node]
|
||||
mode = offline
|
||||
mode = online
|
||||
hostname = myhostname.isti.cnr.it
|
||||
protocol= http
|
||||
port = 8080
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
|
||||
<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" />
|
||||
</root>
|
||||
|
||||
|
|
|
@ -3,15 +3,18 @@ package manager;
|
|||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.smartgears.ApplicationManager;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.configuration.Mode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is use to Manage the application initialization and shutdown per context;
|
||||
* The init and shutdown methods are called one per context in which the app is running
|
||||
* respectively at init and a shutdown time.
|
||||
* It is connected to the app declaring it via the @ManagedBy annotation. (@see HelloWorld class)
|
||||
* This class is use to Manage the application initialization and shutdown per
|
||||
* context; The init and shutdown methods are called one per context in which
|
||||
* the app is running respectively at init and a shutdown time. It is connected
|
||||
* to the app declaring it via the @ManagedBy annotation. (@see HelloWorld
|
||||
* class)
|
||||
*
|
||||
*
|
||||
* @author lucio
|
||||
|
@ -23,15 +26,23 @@ public class HelloWorldManager implements ApplicationManager {
|
|||
|
||||
@Override
|
||||
public void onInit() {
|
||||
if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
|
||||
logger.debug("init called in offline mode");
|
||||
} else {
|
||||
Secret secret = SecretManagerProvider.get();
|
||||
logger.debug("init called in context {}", secret.getContext());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShutdown() {
|
||||
if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
|
||||
logger.debug("shutDown called in offline mode");
|
||||
} else {
|
||||
Secret secret = SecretManagerProvider.get();
|
||||
logger.debug("shutDown called in context {}", secret.getContext());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import javax.ws.rs.core.MediaType;
|
|||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -14,7 +15,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import manager.HelloWorldManager;
|
||||
|
||||
|
||||
@ManagedBy(HelloWorldManager.class)
|
||||
@Path("hello")
|
||||
public class HelloService {
|
||||
|
@ -28,8 +28,10 @@ public class HelloService {
|
|||
Secret secret = SecretManagerProvider.get();
|
||||
String userId = secret.getOwner().getId();
|
||||
String context = secret.getContext();
|
||||
|
||||
String infrastructureName = ContextProvider.get().container().configuration().infrastructure();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue