added the use of smartgears application managers
This commit is contained in:
parent
ff70a6a400
commit
932e924ba4
|
@ -3,8 +3,7 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||||
version="4.0"
|
version="4.0">
|
||||||
metadata-complete="true">
|
|
||||||
<display-name>Hello World</display-name>
|
<display-name>Hello World</display-name>
|
||||||
<description>
|
<description>
|
||||||
A gcube HelloWorld service - smartgears 4
|
A gcube HelloWorld service - smartgears 4
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package manager;
|
||||||
|
|
||||||
|
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||||
|
import org.gcube.common.security.secrets.Secret;
|
||||||
|
import org.gcube.smartgears.ApplicationManager;
|
||||||
|
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)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author lucio
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HelloWorldManager implements ApplicationManager {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(HelloWorldManager.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInit() {
|
||||||
|
Secret secret = SecretManagerProvider.get();
|
||||||
|
logger.debug("init called in context {}", secret.getContext());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onShutdown() {
|
||||||
|
Secret secret = SecretManagerProvider.get();
|
||||||
|
logger.debug("shutDown called in context {}", secret.getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,10 +7,15 @@ 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.annotations.ManagedBy;
|
||||||
import org.gcube.smartgears.utils.InnerMethodName;
|
import org.gcube.smartgears.utils.InnerMethodName;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import manager.HelloWorldManager;
|
||||||
|
|
||||||
|
|
||||||
|
@ManagedBy(HelloWorldManager.class)
|
||||||
@Path("hello")
|
@Path("hello")
|
||||||
public class HelloService {
|
public class HelloService {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue