removing gcore resource dependencies from smartgears
This commit is contained in:
parent
4b619414a7
commit
961676484f
24
pom.xml
24
pom.xml
|
@ -60,7 +60,7 @@
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>common-security</artifactId>
|
<artifactId>common-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.publishing</groupId>
|
<groupId>org.gcube.data.publishing</groupId>
|
||||||
<artifactId>document-store-lib</artifactId>
|
<artifactId>document-store-lib</artifactId>
|
||||||
|
@ -76,16 +76,6 @@
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.resources</groupId>
|
|
||||||
<artifactId>registry-publisher</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.gcube.resources</groupId>
|
|
||||||
<artifactId>common-gcore-resources</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ini4j</groupId>
|
<groupId>org.ini4j</groupId>
|
||||||
<artifactId>ini4j</artifactId>
|
<artifactId>ini4j</artifactId>
|
||||||
|
@ -100,13 +90,17 @@
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.core</groupId>
|
||||||
<artifactId>common-scope</artifactId>
|
<artifactId>common-events</artifactId>
|
||||||
|
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.core</groupId>
|
<groupId>org.gcube.common.security</groupId>
|
||||||
<artifactId>common-events</artifactId>
|
<artifactId>gcube-secrets</artifactId>
|
||||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.smartgears.context.application;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.gcube.common.events.Hub;
|
import org.gcube.common.events.Hub;
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
|
||||||
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
||||||
import org.gcube.smartgears.context.Properties;
|
import org.gcube.smartgears.context.Properties;
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
import org.gcube.smartgears.context.container.ContainerContext;
|
||||||
|
@ -34,9 +33,6 @@ public interface ApplicationContext {
|
||||||
* @return the configuration
|
* @return the configuration
|
||||||
*/
|
*/
|
||||||
ApplicationConfiguration configuration();
|
ApplicationConfiguration configuration();
|
||||||
|
|
||||||
|
|
||||||
GCoreEndpoint profile();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the lifecycle of the application.
|
* Returns the lifecycle of the application.
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package org.gcube.smartgears.context.application;
|
package org.gcube.smartgears.context.application;
|
||||||
|
|
||||||
import static org.gcube.smartgears.Constants.profile_property;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.gcube.common.events.Hub;
|
import org.gcube.common.events.Hub;
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
|
||||||
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
||||||
import org.gcube.smartgears.context.Properties;
|
import org.gcube.smartgears.context.Properties;
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
import org.gcube.smartgears.context.container.ContainerContext;
|
||||||
|
@ -65,11 +62,6 @@ public class DefaultApplicationContext implements ApplicationContext {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public GCoreEndpoint profile() {
|
|
||||||
return properties().lookup(profile_property).value(GCoreEndpoint.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() { //little shortcut for ease of logging
|
public String name() { //little shortcut for ease of logging
|
||||||
return configuration.name();
|
return configuration.name();
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -23,7 +22,7 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.security.ContextBean;
|
||||||
import org.gcube.smartgears.extensions.ApiResource;
|
import org.gcube.smartgears.extensions.ApiResource;
|
||||||
import org.gcube.smartgears.extensions.ApiSignature;
|
import org.gcube.smartgears.extensions.ApiSignature;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -94,12 +93,11 @@ public class FrontPageResource extends ApiResource {
|
||||||
String infrastructure = context().container().configuration().infrastructure();
|
String infrastructure = context().container().configuration().infrastructure();
|
||||||
StringBuilder voValue = new StringBuilder();
|
StringBuilder voValue = new StringBuilder();
|
||||||
|
|
||||||
Collection<String> scopes = context().profile().scopes().asCollection();
|
|
||||||
Set<String> vos = new HashSet<String>();
|
Set<String> vos = new HashSet<String>();
|
||||||
|
|
||||||
//pre-process
|
//pre-process
|
||||||
for (String scope : scopes) {
|
for (String scope : context().container().configuration().authorizationProvider().getContexts()) {
|
||||||
ScopeBean bean = new ScopeBean(scope);
|
ContextBean bean = new ContextBean(scope);
|
||||||
switch (bean.type()) {
|
switch (bean.type()) {
|
||||||
case INFRASTRUCTURE:
|
case INFRASTRUCTURE:
|
||||||
infrastructure = bean.name();
|
infrastructure = bean.name();
|
||||||
|
|
|
@ -13,12 +13,6 @@ import org.gcube.smartgears.extensions.ApiResource;
|
||||||
import org.gcube.smartgears.extensions.ApiSignature;
|
import org.gcube.smartgears.extensions.ApiSignature;
|
||||||
|
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
|
|
||||||
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
|
||||||
import io.micrometer.prometheus.PrometheusConfig;
|
|
||||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||||
|
|
||||||
public class MetricsResource extends ApiResource {
|
public class MetricsResource extends ApiResource {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.Resources;
|
|
||||||
import org.gcube.smartgears.extensions.ApiResource;
|
import org.gcube.smartgears.extensions.ApiResource;
|
||||||
import org.gcube.smartgears.extensions.ApiSignature;
|
import org.gcube.smartgears.extensions.ApiSignature;
|
||||||
|
|
||||||
|
@ -35,7 +34,8 @@ public class ProfileResource extends ApiResource {
|
||||||
@Override
|
@Override
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
|
||||||
Resources.marshal(context().profile(),resp.getWriter());
|
//Resources.marshal(context().profile(),resp.getWriter());
|
||||||
|
//TODO: return something to show
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
package org.gcube.smartgears.handlers.application.lifecycle;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.ServletRegistration;
|
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
|
||||||
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
|
||||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
|
||||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
||||||
|
|
||||||
public class ProfileBuilder {
|
|
||||||
|
|
||||||
private static List<String> servletExcludes = Arrays.asList("default","jsp");
|
|
||||||
|
|
||||||
// private static final Logger log = LoggerFactory.getLogger(ProfileBuilder.class);
|
|
||||||
|
|
||||||
private ApplicationContext context;
|
|
||||||
|
|
||||||
public ProfileBuilder(ApplicationContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void fill(GCoreEndpoint endpoint) {
|
|
||||||
|
|
||||||
|
|
||||||
ApplicationConfiguration configuration = context.configuration();
|
|
||||||
ContainerConfiguration container = context.container().configuration();
|
|
||||||
|
|
||||||
|
|
||||||
endpoint.profile()
|
|
||||||
.description(configuration.description())
|
|
||||||
.serviceName(configuration.name())
|
|
||||||
.serviceClass(configuration.serviceClass())
|
|
||||||
.version(configuration.version())
|
|
||||||
.serviceId(configuration.name() + configuration.serviceClass() + configuration.version())
|
|
||||||
.ghnId(context.container().profile().id());
|
|
||||||
|
|
||||||
endpoint.profile().newDeploymentData()
|
|
||||||
.activationTime(Calendar.getInstance())
|
|
||||||
.status((context.lifecycle().state().remoteForm()));
|
|
||||||
|
|
||||||
endpoint.profile().endpoints().clear();
|
|
||||||
|
|
||||||
String baseAddress;
|
|
||||||
if (configuration.proxied()){
|
|
||||||
String protocol = configuration.proxyAddress().getProtocol();
|
|
||||||
String port = configuration.proxyAddress().getPort()!=null?":"+configuration.proxyAddress().getPort():"";
|
|
||||||
|
|
||||||
baseAddress=String.format("%s://%s%s%s", protocol , configuration.proxyAddress().getHostname(), port,context.application().getContextPath());
|
|
||||||
} else {
|
|
||||||
String protocol = container.protocol();
|
|
||||||
int port = container.port();
|
|
||||||
|
|
||||||
baseAddress=String.format("%s://%s:%d%s", protocol , container.hostname(), port,context.application().getContextPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ServletRegistration servlet : context.application().getServletRegistrations().values())
|
|
||||||
if (!servletExcludes.contains(servlet.getName()))
|
|
||||||
for (String mapping : servlet.getMappings()) {
|
|
||||||
String address = baseAddress+(mapping.endsWith("*")?mapping.substring(0,mapping.length()-2):mapping);
|
|
||||||
endpoint.profile().endpoints().add().nameAndAddress(servlet.getName(),URI.create(address));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -109,8 +109,6 @@ public class ProfileManager extends ApplicationLifecycleHandler {
|
||||||
@Observes({ activation, stop, failure })
|
@Observes({ activation, stop, failure })
|
||||||
void onChanged(ApplicationLifecycle lc) {
|
void onChanged(ApplicationLifecycle lc) {
|
||||||
|
|
||||||
GCoreEndpoint profile = context.profile();
|
|
||||||
|
|
||||||
profile.profile().deploymentData().status(lc.state().remoteForm());
|
profile.profile().deploymentData().status(lc.state().remoteForm());
|
||||||
|
|
||||||
log.debug("moving app {} to {}",context.name(), lc.state().remoteForm());
|
log.debug("moving app {} to {}",context.name(), lc.state().remoteForm());
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
package org.gcube.smartgears.handlers.application.lifecycle;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
|
||||||
import org.gcube.common.resources.gcore.HostingNode;
|
|
||||||
import org.gcube.smartgears.configuration.Mode;
|
|
||||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
||||||
import org.gcube.smartgears.handlers.AbstractProfilePublisher;
|
|
||||||
import org.gcube.smartgears.handlers.ProfileEvents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Publishes the current resource profile of the application.
|
|
||||||
* <p>
|
|
||||||
*Distinguishes publication in new scopes ({@link #addTo(List)} from publication updates in existing scopes ({@link #update()}.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Fabio Simeoni
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ServicePublisher extends AbstractProfilePublisher<GCoreEndpoint> {
|
|
||||||
|
|
||||||
private final ApplicationContext context;
|
|
||||||
|
|
||||||
public ServicePublisher(ApplicationContext context) {
|
|
||||||
super();
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void sharePublished(HostingNode profile) {
|
|
||||||
context.events().fire(profile,ProfileEvents.published);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GCoreEndpoint getProfile() {
|
|
||||||
return context.profile();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isRoot() {
|
|
||||||
return context.container().configuration().mode()!=Mode.root;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sharePublished(GCoreEndpoint profile) {
|
|
||||||
context.events().fire(profile,ProfileEvents.published);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Set<String> getAllowedContexts() {
|
|
||||||
return context.container().configuration().authorizationProvider().getContexts();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import static org.gcube.smartgears.handlers.application.request.RequestError.inv
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.gcube.common.scope.impl.ScopeBean;
|
import org.gcube.common.security.ContextBean;
|
||||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
import org.gcube.common.security.ContextBean.Type;
|
||||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||||
import org.gcube.common.security.secrets.AccessTokenSecret;
|
import org.gcube.common.security.secrets.AccessTokenSecret;
|
||||||
import org.gcube.common.security.secrets.GCubeSecret;
|
import org.gcube.common.security.secrets.GCubeSecret;
|
||||||
|
@ -89,7 +89,7 @@ public class RequestValidator extends RequestHandler {
|
||||||
invalid_request_error.fire("call is unscoped");
|
invalid_request_error.fire("call is unscoped");
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopeBean bean = new ScopeBean(context);
|
ContextBean bean = new ContextBean(context);
|
||||||
|
|
||||||
ContainerConfiguration conf = appContext.container().configuration();
|
ContainerConfiguration conf = appContext.container().configuration();
|
||||||
if (!conf.allowedContexts().contains(context) &&
|
if (!conf.allowedContexts().contains(context) &&
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.gcube.smartgears.publishing;
|
||||||
|
|
||||||
|
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
||||||
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||||
|
|
||||||
|
public interface Publisher {
|
||||||
|
|
||||||
|
boolean publishContainer(ContainerConfiguration container, String ... contexts);
|
||||||
|
|
||||||
|
boolean publishApplication(ApplicationConfiguration application, String ... contexts);
|
||||||
|
|
||||||
|
boolean unpublishContainer(ContainerConfiguration container, String ... contexts);
|
||||||
|
|
||||||
|
boolean unpublishApplication(ApplicationConfiguration application, String ... contexts);
|
||||||
|
}
|
Loading…
Reference in New Issue