> templateFactories, final Class> factoryClass) {
+ return new TemplateDefinitionProvider(
+ Collections.emptyList(),
+ templateAvailabilityResolver,
+ () -> Components.newInstance(ConfiguredAreaDefinition.class),
+ templateFactories,
+ () -> Components.newInstance(factoryClass),
+ factoryClass
+ );
+ }
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Available.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Available.java
new file mode 100644
index 0000000..ffd1d28
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Available.java
@@ -0,0 +1,10 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Available {}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/DynamicFragment.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/DynamicFragment.java
new file mode 100644
index 0000000..177f96f
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/DynamicFragment.java
@@ -0,0 +1,19 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares a component/area as dynamicFragment
+ *
+ * Can be used to disable caching of a component or an area
+ *
+ *
See Dynamic page caching
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface DynamicFragment {
+ long ttlInSeconds() default 0;
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Template.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Template.java
new file mode 100644
index 0000000..c36d263
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/Template.java
@@ -0,0 +1,61 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation;
+
+import info.magnolia.rendering.template.type.DefaultTemplateTypes;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Template {
+
+ String id();
+
+ String renderer();
+
+ Class> modelClass() default Class.class;
+
+ String title() default "";
+
+ String description() default "";
+
+ String dialog() default "";
+
+ String templateScript() default "";
+
+ /**
+ * Defines the visibility of the template. When set to false the template is never presented in the user interface.
+ * This is useful for templates that are only used for pages that are created by scheduled jobs rather than by
+ * editors.
+ */
+ TernaryBoolean visible() default TernaryBoolean.UNSPECIFIED;
+
+ /**
+ * Specifies the template type, e.g. "home", "section", etc.
+ *
+ * @see info.magnolia.rendering.template.type.DefaultTemplateTypes
+ */
+ String type() default DefaultTemplateTypes.CONTENT;
+
+ /**
+ * Specifies the template subtype, such as specific features, e.g. "news", etc.
+ */
+ String subtype() default "";
+
+ /**
+ * Specifies whether a component can be changed.
+ */
+ TernaryBoolean writable() default TernaryBoolean.UNSPECIFIED;
+
+ /**
+ * Specifies whether a component can be moved.
+ */
+ TernaryBoolean moveable() default TernaryBoolean.UNSPECIFIED;
+
+ /**
+ * Specifies whether a component can be deleted.
+ */
+ TernaryBoolean deletable() default TernaryBoolean.UNSPECIFIED;
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TemplateFactories.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TemplateFactories.java
new file mode 100644
index 0000000..5942bbd
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TemplateFactories.java
@@ -0,0 +1,13 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+@BindingAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.PARAMETER })
+public @interface TemplateFactories {}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TernaryBoolean.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TernaryBoolean.java
new file mode 100644
index 0000000..2153799
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/TernaryBoolean.java
@@ -0,0 +1,17 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation;
+
+public enum TernaryBoolean {
+ TRUE(true),
+ FALSE(false),
+ UNSPECIFIED(null);
+
+ private final Boolean value;
+
+ TernaryBoolean(final Boolean value) {
+ this.value = value;
+ }
+
+ public Boolean getValue() {
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Area.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Area.java
new file mode 100644
index 0000000..2f28c57
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Area.java
@@ -0,0 +1,36 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.merkle.oss.magnolia.templatebuilder.annotation.TernaryBoolean;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Area {
+
+ String id();
+
+ String name();
+
+ /**
+ * Template renderer will be set if not specified
+ */
+ String renderer() default "";
+
+ String templateScript() default "";
+
+ String title() default "";
+
+ String dialog() default "";
+
+ AreaType type() default AreaType.LIST;
+
+ TernaryBoolean optional() default TernaryBoolean.UNSPECIFIED;
+
+ int maxComponents() default Integer.MAX_VALUE;
+
+ TernaryBoolean createAreaNode() default TernaryBoolean.UNSPECIFIED;
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AreaType.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AreaType.java
new file mode 100644
index 0000000..dad05e3
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AreaType.java
@@ -0,0 +1,29 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import info.magnolia.rendering.template.AreaDefinition;
+
+/**
+ * Enumeration of area types.
+ *
+ * - NO_COMPONENT The area does not have any components within it
+ * - LIST The area can have zero or more components within it
+ * - SINGLE The area can have zero or one component within it
+ *
+ *
+ * @see Area
+ */
+public enum AreaType {
+ NO_COMPONENT(AreaDefinition.TYPE_NO_COMPONENT),
+ LIST(AreaDefinition.TYPE_LIST),
+ SINGLE(AreaDefinition.TYPE_SINGLE);
+
+ private final String definitionFormat;
+
+ AreaType(final String definitionFormat) {
+ this.definitionFormat = definitionFormat;
+ }
+
+ public String getDefinitionFormat() {
+ return definitionFormat;
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AutoGenerator.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AutoGenerator.java
new file mode 100644
index 0000000..d320151
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AutoGenerator.java
@@ -0,0 +1,15 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Declares a method to be called when an area is rendered to perform automatic generation of content. Often used for
+ * adding components automatically when a new page is created so editors don't have to do it manually every time.
+ * @see Area
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface AutoGenerator {}
\ No newline at end of file
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponentClasses.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponentClasses.java
new file mode 100644
index 0000000..4706e7e
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponentClasses.java
@@ -0,0 +1,21 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to set the available components in an area either by specifying the component class directly or by
+ * specifying a component category annotation, in which case all components have that category annotation will be
+ * available. When used in combination with {@link AvailableComponents} components from both annotations are used.
+ *
+ * @see Area
+ * @see AvailableComponents
+ * @see ComponentCategory
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface AvailableComponentClasses {
+ Class>[] value() default {};
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponents.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponents.java
new file mode 100644
index 0000000..8307009
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/AvailableComponents.java
@@ -0,0 +1,20 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to set the available components in an area by their id. When used in combination with
+ * {@link AvailableComponentClasses} components from both annotations are used.
+ *
+ * @see Area
+ * @see AvailableComponentClasses
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface AvailableComponents {
+
+ String[] value() default {};
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentCategory.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentCategory.java
new file mode 100644
index 0000000..ea62eaa
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentCategory.java
@@ -0,0 +1,30 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes an annotation as a component category annotation.
+ *
+ * A component category annotation is used to annotate components as being part of a certain category. The annotation
+ * is then specified in the `@AvailableComponentClasses` annotation on areas. All components in the category will
+ * then be available in the area.
+ *
+ *
+ * @Retention(RetentionPolicy.RUNTIME)
+ * @Target(ElementType.TYPE)
+ * @ComponentCategory
+ * public @interface Promo {
+ * }
+ *
+ *
+ * @see com.merkle.oss.magnolia.templatebuilder.annotation.Template
+ * @see Area
+ * @see AvailableComponentClasses
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.ANNOTATION_TYPE)
+public @interface ComponentCategory {
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentInheritanceMode.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentInheritanceMode.java
new file mode 100644
index 0000000..e959984
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/ComponentInheritanceMode.java
@@ -0,0 +1,31 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import info.magnolia.rendering.template.configured.ConfiguredInheritance;
+
+/**
+ * Enumeration for modes of inheriting components.
+ *
+ * - ALL All components are inherited
+ * - NONE No components are inherited
+ * - FILTERED Only components having a property
inheritable
set to true are inherited
+ *
+ *
+ * @see Inherits
+ * @see info.magnolia.rendering.template.InheritanceConfiguration
+ * @see ConfiguredInheritance
+ */
+public enum ComponentInheritanceMode {
+ ALL(ConfiguredInheritance.COMPONENTS_ALL),
+ NONE(ConfiguredInheritance.COMPONENTS_NONE),
+ FILTERED(ConfiguredInheritance.COMPONENTS_FILTERED);
+
+ private final String configurationFormat;
+
+ ComponentInheritanceMode(String configurationFormat) {
+ this.configurationFormat = configurationFormat;
+ }
+
+ public String getConfigurationFormat() {
+ return configurationFormat;
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Inherits.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Inherits.java
new file mode 100644
index 0000000..33dc1b2
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/Inherits.java
@@ -0,0 +1,16 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to configure how an area inherits from parent pages.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Inherits {
+ ComponentInheritanceMode components() default ComponentInheritanceMode.FILTERED;
+ PropertyInheritanceMode properties() default PropertyInheritanceMode.NONE;
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/PropertyInheritanceMode.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/PropertyInheritanceMode.java
new file mode 100644
index 0000000..2a6f2f3
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/annotation/area/PropertyInheritanceMode.java
@@ -0,0 +1,29 @@
+package com.merkle.oss.magnolia.templatebuilder.annotation.area;
+
+import info.magnolia.rendering.template.configured.ConfiguredInheritance;
+
+/**
+ * Enumeration for modes of inheriting properties.
+ *
+ * - ALL All properties are inherited
+ * - NONE No properties are inherited
+ *
+ *
+ * @see Inherits
+ * @see info.magnolia.rendering.template.InheritanceConfiguration
+ * @see ConfiguredInheritance
+ */
+public enum PropertyInheritanceMode {
+ ALL(ConfiguredInheritance.PROPERTIES_ALL),
+ NONE(ConfiguredInheritance.PROPERTIES_NONE);
+
+ private final String configurationFormat;
+
+ PropertyInheritanceMode(final String configurationFormat) {
+ this.configurationFormat = configurationFormat;
+ }
+
+ public String getConfigurationFormat() {
+ return configurationFormat;
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/configuration/TemplateBuilderGuiceComponentConfigurer.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/configuration/TemplateBuilderGuiceComponentConfigurer.java
new file mode 100644
index 0000000..8cdcb26
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/configuration/TemplateBuilderGuiceComponentConfigurer.java
@@ -0,0 +1,15 @@
+package com.merkle.oss.magnolia.templatebuilder.configuration;
+
+import info.magnolia.objectfactory.guice.AbstractGuiceComponentConfigurer;
+
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import com.merkle.oss.magnolia.templatebuilder.annotation.TemplateFactories;
+
+public class TemplateBuilderGuiceComponentConfigurer extends AbstractGuiceComponentConfigurer {
+ @Override
+ protected void configure() {
+ super.configure();
+ Multibinder.newSetBinder(binder(), new TypeLiteral>(){}, TemplateFactories.class);
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AutoGeneratorParameterResolverFactory.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AutoGeneratorParameterResolverFactory.java
new file mode 100644
index 0000000..c0c7d82
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AutoGeneratorParameterResolverFactory.java
@@ -0,0 +1,12 @@
+package com.merkle.oss.magnolia.templatebuilder.parameter;
+
+import info.magnolia.rendering.template.configured.ConfiguredAreaDefinition;
+import info.magnolia.rendering.template.configured.ConfiguredTemplateDefinition;
+
+import javax.jcr.Node;
+
+import com.merkle.oss.magnolia.builder.parameter.ParameterResolver;
+
+public interface AutoGeneratorParameterResolverFactory {
+ ParameterResolver create(Node node, ConfiguredTemplateDefinition template, ConfiguredAreaDefinition area);
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AvailabilityParameterResolverFactory.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AvailabilityParameterResolverFactory.java
new file mode 100644
index 0000000..7232cbc
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/AvailabilityParameterResolverFactory.java
@@ -0,0 +1,11 @@
+package com.merkle.oss.magnolia.templatebuilder.parameter;
+
+import info.magnolia.rendering.template.TemplateDefinition;
+
+import javax.jcr.Node;
+
+import com.merkle.oss.magnolia.builder.parameter.ParameterResolver;
+
+public interface AvailabilityParameterResolverFactory {
+ ParameterResolver create(Node node, TemplateDefinition templateDefinition);
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAutoGeneratorParameterResolver.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAutoGeneratorParameterResolver.java
new file mode 100644
index 0000000..5a26ee9
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAutoGeneratorParameterResolver.java
@@ -0,0 +1,67 @@
+package com.merkle.oss.magnolia.templatebuilder.parameter;
+
+import info.magnolia.cms.security.MgnlUser;
+import info.magnolia.cms.security.User;
+import info.magnolia.context.Context;
+import info.magnolia.context.MgnlContext;
+import info.magnolia.context.WebContext;
+import info.magnolia.rendering.template.TemplateDefinition;
+
+import javax.jcr.Node;
+
+import com.merkle.oss.magnolia.builder.parameter.ParameterResolver;
+
+/**
+ * Resolves the following types:
+ *
+ * - {@link Node}
+ *
- {@link TemplateDefinition}
+ *
- {@link WebContext}
+ *
- {@link Context}
+ *
- {@link User}
+ *
- {@link MgnlUser}
+ *
+ */
+public class DefaultAutoGeneratorParameterResolver extends ParameterResolver {
+ private final Node node;
+ private final TemplateDefinition templateDefinition;
+
+ public DefaultAutoGeneratorParameterResolver(
+ final Node node,
+ final TemplateDefinition templateDefinition
+ ) {
+ super(null);
+ this.node = node;
+ this.templateDefinition = templateDefinition;
+ }
+
+ @Override
+ public Object resolveParameter(final Class> parameterType) {
+ if (parameterType.equals(Node.class)) {
+ return node;
+ }
+ if (parameterType.equals(TemplateDefinition.class)) {
+ return templateDefinition;
+ }
+ if (parameterType.isAssignableFrom(WebContext.class)) {
+ return MgnlContext.getWebContext();
+ }
+ if (parameterType.isAssignableFrom(Context.class)) {
+ return MgnlContext.getInstance();
+ }
+ if (parameterType.isAssignableFrom(User.class)) {
+ return MgnlContext.getUser();
+ }
+ if (parameterType.isAssignableFrom(MgnlUser.class)) {
+ return MgnlContext.getUser();
+ }
+ return super.resolveParameter(parameterType);
+ }
+
+ public static class Factory implements AvailabilityParameterResolverFactory {
+ @Override
+ public ParameterResolver create(final Node node, final TemplateDefinition templateDefinition) {
+ return new DefaultAutoGeneratorParameterResolver(node, templateDefinition);
+ }
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAvailabilityParameterResolver.java b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAvailabilityParameterResolver.java
new file mode 100644
index 0000000..97638c6
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/java/com/merkle/oss/magnolia/templatebuilder/parameter/DefaultAvailabilityParameterResolver.java
@@ -0,0 +1,67 @@
+package com.merkle.oss.magnolia.templatebuilder.parameter;
+
+import info.magnolia.cms.security.MgnlUser;
+import info.magnolia.cms.security.User;
+import info.magnolia.context.Context;
+import info.magnolia.context.MgnlContext;
+import info.magnolia.context.WebContext;
+import info.magnolia.rendering.template.TemplateDefinition;
+
+import javax.jcr.Node;
+
+import com.merkle.oss.magnolia.builder.parameter.ParameterResolver;
+
+/**
+ * Resolves the following types:
+ *
+ * - {@link Node}
+ *
- {@link TemplateDefinition}
+ *
- {@link WebContext}
+ *
- {@link Context}
+ *
- {@link User}
+ *
- {@link MgnlUser}
+ *
+ */
+public class DefaultAvailabilityParameterResolver extends ParameterResolver {
+ private final Node node;
+ private final TemplateDefinition templateDefinition;
+
+ public DefaultAvailabilityParameterResolver(
+ final Node node,
+ final TemplateDefinition templateDefinition
+ ) {
+ super(null);
+ this.node = node;
+ this.templateDefinition = templateDefinition;
+ }
+
+ @Override
+ public Object resolveParameter(final Class> parameterType) {
+ if (parameterType.equals(Node.class)) {
+ return node;
+ }
+ if (parameterType.equals(TemplateDefinition.class)) {
+ return templateDefinition;
+ }
+ if (parameterType.isAssignableFrom(WebContext.class)) {
+ return MgnlContext.getWebContext();
+ }
+ if (parameterType.isAssignableFrom(Context.class)) {
+ return MgnlContext.getInstance();
+ }
+ if (parameterType.isAssignableFrom(User.class)) {
+ return MgnlContext.getUser();
+ }
+ if (parameterType.isAssignableFrom(MgnlUser.class)) {
+ return MgnlContext.getUser();
+ }
+ return super.resolveParameter(parameterType);
+ }
+
+ public static class Factory implements AvailabilityParameterResolverFactory {
+ @Override
+ public ParameterResolver create(final Node node, final TemplateDefinition templateDefinition) {
+ return new DefaultAvailabilityParameterResolver(node, templateDefinition);
+ }
+ }
+}
diff --git a/magnolia-templatebuilder/src/main/resources/META-INF/magnolia/magnolia-templatebuilder.xml b/magnolia-templatebuilder/src/main/resources/META-INF/magnolia/magnolia-templatebuilder.xml
new file mode 100644
index 0000000..4a75d98
--- /dev/null
+++ b/magnolia-templatebuilder/src/main/resources/META-INF/magnolia/magnolia-templatebuilder.xml
@@ -0,0 +1,35 @@
+
+
+
+ magnolia-templatebuilder
+ Magnolia TemplateBuilder
+ The TemplateBuilder is a builder for Magnolia templates using java code.
+ com.merkle.oss.magnolia.templatebuilder.TemplateBuilderModule
+ ${project.version}
+
+
+ main
+
+ com.merkle.oss.magnolia.templatebuilder.configuration.TemplateBuilderGuiceComponentConfigurer
+
+
+ com.merkle.oss.magnolia.templatebuilder.TemplateAvailabilityResolver
+ com.merkle.oss.magnolia.templatebuilder.TemplateAvailabilityResolver
+
+
+ com.merkle.oss.magnolia.templatebuilder.parameter.AvailabilityParameterResolverFactory
+ com.merkle.oss.magnolia.templatebuilder.parameter.DefaultAvailabilityParameterResolver$Factory
+
+
+ com.merkle.oss.magnolia.templatebuilder.parameter.AutoGeneratorParameterResolverFactory
+ com.merkle.oss.magnolia.templatebuilder.parameter.DefaultAutoGeneratorParameterResolver$Factory
+
+
+
+
+
+ core
+ *
+
+
+
diff --git a/pom.xml b/pom.xml
index de2aeda..0397149 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,12 +39,14 @@
magnolia-builder-common
magnolia-appbuilder
magnolia-dialogbuilder
+ magnolia-templatebuilder
magnolia-virtualUriMapping-builder
6.3.0
+ 3.0.0
3.0.2
1.2.0
@@ -78,6 +80,12 @@
pom
import
+
+ info.magnolia.advancedcache
+ magnolia-advanced-cache-dpc
+ ${magnolia.advancedcache.version}
+
+
com.google.code.findbugs
jsr305