Skip to content

Commit

Permalink
issue #520: JavaDoc & cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
pepperbob committed Dec 12, 2020
1 parent ede07f4 commit 4c43484
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static class Builder {

private MethodAccessValidator methodAccessValidator = new BlacklistMethodAccessValidator();

private ExtensionRegistryFactory factory = new ExtensionRegistryFactory();
private final ExtensionRegistryFactory factory = new ExtensionRegistryFactory();

/**
* Creates the builder.
Expand Down Expand Up @@ -558,14 +558,13 @@ public Builder greedyMatchMethod(boolean greedyMatchMethod) {
}

/**
* Registeres a customizer which is called before the core functionality provided by default is registered
* into the {@link PebbleEngine}.
* Registeres an implementation of {@link ExtensionCustomizer} to change runtime-behaviour of standard
* functionality.
*
* @param customizer The customizer which is called before registering the target extension
* @param <T>
* @param customizer The customizer which wraps any non-user-provided extension
* @return This build object
*/
public <T extends Extension> Builder registerExtensionCustomizer(Function<Extension, ExtensionCustomizer> customizer) {
public Builder registerExtensionCustomizer(Function<Extension, ExtensionCustomizer> customizer) {
this.factory.registerExtensionCustomizer(customizer);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
import java.util.List;
import java.util.Map;

/**
* Base class that allows implementing a customizer to modify Pebbles build-in extensions.
* It is meant to provide a way to remove or replace functions, filters, tags, etc. to change
* the standard behaviour. Use-cases can be down-stripping available functionality for security
* reasons.
*
* Implementations of this class are meant to overwrite methods and access registered functionality
* before it is loaded into the PebbleEngine by calling super.
*
* The ExentsionCustomizer can be registred via {@link com.mitchellbosecke.pebble.PebbleEngine.Builder#registerExtensionCustomizer}
* and is applied for every non-user-provided extension.
*
*/
public abstract class ExtensionCustomizer implements Extension {

private final Extension delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import java.util.function.Function;
import java.util.stream.Stream;

/**
* Provides configuration methods and builds the {@link ExtensionRegistry}. Used only internally by
* the {@link com.mitchellbosecke.pebble.PebbleEngine.Builder}.
*
*/
public class ExtensionRegistryFactory {

private final List<Extension> userProvidedExtensions = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.extension.core.CoreExtension;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.StringWriter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand Down

0 comments on commit 4c43484

Please sign in to comment.