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. *

*Distinguishes publication in new scopes ({@link #addTo(List)} from publication updates in existing scopes ({@link #update()}. * * * @author Fabio Simeoni * */ public class ServicePublisher extends AbstractProfilePublisher { 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 getAllowedContexts() { return context.container().configuration().authorizationProvider().getContexts(); } }