Search in sources :

Example 1 with RestCacheManager

use of org.infinispan.rest.cachemanager.RestCacheManager in project infinispan by infinispan.

the class RestServer method startInternal.

@Override
protected void startInternal() {
    this.maxContentLength = configuration.maxContentLength() + MAX_INITIAL_LINE_SIZE + MAX_HEADER_SIZE;
    AuthenticationConfiguration auth = configuration.authentication();
    if (auth.enabled()) {
        auth.authenticator().init(this);
    }
    super.startInternal();
    restCacheManager = new RestCacheManager<>(cacheManager, this::isCacheIgnored);
    invocationHelper = new InvocationHelper(this, restCacheManager, (EmbeddedCounterManager) EmbeddedCounterManagerFactory.asCounterManager(cacheManager), configuration, server, getExecutor());
    String restContext = configuration.contextPath();
    String rootContext = "/";
    ResourceManager resourceManager = new ResourceManagerImpl();
    resourceManager.registerResource(restContext, new CacheResourceV2(invocationHelper));
    resourceManager.registerResource(restContext, new CounterResource(invocationHelper));
    resourceManager.registerResource(restContext, new ContainerResource(invocationHelper));
    resourceManager.registerResource(restContext, new XSiteResource(invocationHelper));
    resourceManager.registerResource(restContext, new SearchAdminResource(invocationHelper));
    resourceManager.registerResource(restContext, new TasksResource(invocationHelper));
    resourceManager.registerResource(restContext, new ProtobufResource(invocationHelper));
    resourceManager.registerResource(rootContext, new MetricsResource(auth.metricsAuth(), invocationHelper));
    Path staticResources = configuration.staticResources();
    if (staticResources != null) {
        Path console = configuration.staticResources().resolve("console");
        resourceManager.registerResource(rootContext, new StaticContentResource(staticResources, "static"));
        resourceManager.registerResource(rootContext, new StaticContentResource(console, "console", (path, resource) -> {
            if (!path.contains("."))
                return StaticContentResource.DEFAULT_RESOURCE;
            return path;
        }));
        resourceManager.registerResource(rootContext, new RedirectResource(rootContext, rootContext + "console/welcome", true));
    }
    if (adminEndpoint) {
        resourceManager.registerResource(restContext, new ServerResource(invocationHelper));
        resourceManager.registerResource(restContext, new ClusterResource(invocationHelper));
        resourceManager.registerResource(restContext, new SecurityResource(invocationHelper, rootContext + "console/", rootContext + "console/forbidden.html"));
        registerLoggingResource(resourceManager, restContext);
    }
    this.restDispatcher = new RestDispatcherImpl(resourceManager, restCacheManager.getAuthorizer());
}
Also used : AuthenticationConfiguration(org.infinispan.rest.configuration.AuthenticationConfiguration) Path(java.nio.file.Path) RestDispatcherImpl(org.infinispan.rest.framework.impl.RestDispatcherImpl) RedirectResource(org.infinispan.rest.resources.RedirectResource) SearchAdminResource(org.infinispan.rest.resources.SearchAdminResource) MetricsResource(org.infinispan.rest.resources.MetricsResource) ChannelInboundHandler(io.netty.channel.ChannelInboundHandler) Log(org.infinispan.server.core.logging.Log) ResourceManagerImpl(org.infinispan.rest.framework.impl.ResourceManagerImpl) ArrayList(java.util.ArrayList) SecurityResource(org.infinispan.rest.resources.SecurityResource) MAX_HEADER_SIZE(org.infinispan.rest.RestChannelInitializer.MAX_HEADER_SIZE) AbstractProtocolServer(org.infinispan.server.core.AbstractProtocolServer) RestCacheManager(org.infinispan.rest.cachemanager.RestCacheManager) XSiteResource(org.infinispan.rest.resources.XSiteResource) ChannelMatcher(io.netty.channel.group.ChannelMatcher) Path(java.nio.file.Path) ClusterResource(org.infinispan.rest.resources.ClusterResource) RestDispatcher(org.infinispan.rest.framework.RestDispatcher) CacheResourceV2(org.infinispan.rest.resources.CacheResourceV2) ServerResource(org.infinispan.rest.resources.ServerResource) StaticContentResource(org.infinispan.rest.resources.StaticContentResource) ProtobufResource(org.infinispan.rest.resources.ProtobufResource) ChannelInitializer(io.netty.channel.ChannelInitializer) LoggingResource(org.infinispan.rest.resources.LoggingResource) ChannelOutboundHandler(io.netty.channel.ChannelOutboundHandler) CorsConfig(io.netty.handler.codec.http.cors.CorsConfig) TasksResource(org.infinispan.rest.resources.TasksResource) IOException(java.io.IOException) ResourceManager(org.infinispan.rest.framework.ResourceManager) EmbeddedCounterManagerFactory(org.infinispan.counter.EmbeddedCounterManagerFactory) Channel(io.netty.channel.Channel) MAX_INITIAL_LINE_SIZE(org.infinispan.rest.RestChannelInitializer.MAX_INITIAL_LINE_SIZE) AuthenticationConfiguration(org.infinispan.rest.configuration.AuthenticationConfiguration) List(java.util.List) NettyInitializers(org.infinispan.server.core.transport.NettyInitializers) LogFactory(org.infinispan.commons.logging.LogFactory) RestServerConfiguration(org.infinispan.rest.configuration.RestServerConfiguration) EmbeddedCounterManager(org.infinispan.counter.impl.manager.EmbeddedCounterManager) ContainerResource(org.infinispan.rest.resources.ContainerResource) CounterResource(org.infinispan.rest.resources.CounterResource) CounterResource(org.infinispan.rest.resources.CounterResource) MetricsResource(org.infinispan.rest.resources.MetricsResource) RedirectResource(org.infinispan.rest.resources.RedirectResource) StaticContentResource(org.infinispan.rest.resources.StaticContentResource) ResourceManagerImpl(org.infinispan.rest.framework.impl.ResourceManagerImpl) CacheResourceV2(org.infinispan.rest.resources.CacheResourceV2) ServerResource(org.infinispan.rest.resources.ServerResource) EmbeddedCounterManager(org.infinispan.counter.impl.manager.EmbeddedCounterManager) ResourceManager(org.infinispan.rest.framework.ResourceManager) ClusterResource(org.infinispan.rest.resources.ClusterResource) XSiteResource(org.infinispan.rest.resources.XSiteResource) RestDispatcherImpl(org.infinispan.rest.framework.impl.RestDispatcherImpl) ContainerResource(org.infinispan.rest.resources.ContainerResource) ProtobufResource(org.infinispan.rest.resources.ProtobufResource) TasksResource(org.infinispan.rest.resources.TasksResource) SearchAdminResource(org.infinispan.rest.resources.SearchAdminResource) SecurityResource(org.infinispan.rest.resources.SecurityResource)

Aggregations

Channel (io.netty.channel.Channel)1 ChannelInboundHandler (io.netty.channel.ChannelInboundHandler)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 ChannelOutboundHandler (io.netty.channel.ChannelOutboundHandler)1 ChannelMatcher (io.netty.channel.group.ChannelMatcher)1 CorsConfig (io.netty.handler.codec.http.cors.CorsConfig)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LogFactory (org.infinispan.commons.logging.LogFactory)1 EmbeddedCounterManagerFactory (org.infinispan.counter.EmbeddedCounterManagerFactory)1 EmbeddedCounterManager (org.infinispan.counter.impl.manager.EmbeddedCounterManager)1 MAX_HEADER_SIZE (org.infinispan.rest.RestChannelInitializer.MAX_HEADER_SIZE)1 MAX_INITIAL_LINE_SIZE (org.infinispan.rest.RestChannelInitializer.MAX_INITIAL_LINE_SIZE)1 RestCacheManager (org.infinispan.rest.cachemanager.RestCacheManager)1 AuthenticationConfiguration (org.infinispan.rest.configuration.AuthenticationConfiguration)1 RestServerConfiguration (org.infinispan.rest.configuration.RestServerConfiguration)1 ResourceManager (org.infinispan.rest.framework.ResourceManager)1 RestDispatcher (org.infinispan.rest.framework.RestDispatcher)1