Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #10852 - Add ResourceHandler.setUseFileMapping(boolean) feature #11071

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class ResourceHandler extends Handler.Wrapper
private Resource _styleSheet;
private MimeTypes _mimeTypes;
private List<String> _welcomes = List.of("index.html");
private boolean _useFileMapping = true;

public ResourceHandler()
{
Expand Down Expand Up @@ -123,7 +124,8 @@ public HttpContent.Factory getHttpContentFactory()
protected HttpContent.Factory newHttpContentFactory()
{
HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(getBaseResource()), getMimeTypes());
contentFactory = new FileMappingHttpContentFactory(contentFactory);
if (isUseFileMapping())
contentFactory = new FileMappingHttpContentFactory(contentFactory);
contentFactory = new VirtualHttpContentFactory(contentFactory, getStyleSheet(), "text/css");
contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats());
contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, Duration.ofSeconds(1).toMillis(), getByteBufferPool());
Expand Down Expand Up @@ -241,6 +243,11 @@ public boolean isEtags()
return _resourceService.isEtags();
}

public boolean isUseFileMapping()
{
return _useFileMapping;
}

/**
* @return Precompressed resources formats that can be used to serve compressed variant of resources.
*/
Expand Down Expand Up @@ -351,6 +358,13 @@ public void setMimeTypes(MimeTypes mimeTypes)
_mimeTypes = mimeTypes;
}

public void setUseFileMapping(boolean useFileMapping)
{
if (isRunning())
throw new IllegalStateException("Unable to set useFileMapping on started " + this);
_useFileMapping = useFileMapping;
}

public void setWelcomeMode(ResourceService.WelcomeMode welcomeMode)
{
_resourceService.setWelcomeMode(welcomeMode);
Expand Down