CCM NG: Renamed classes ending with "Builder" in in the pagemodel packages to end with "Renderer" to avoid confusion. Classes with a name ending with "Builder" are usually classes which implement the Builder pattern. The classes rendering a page model and its components do not implemement this pattern.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5071 8810af33-2d31-482b-a856-94f89814c4df

Former-commit-id: cac7214f83
pull/2/head
jensp 2017-10-23 05:57:40 +00:00
parent 9dac93e17a
commit 3b971b3682
16 changed files with 107 additions and 118 deletions

View File

@ -21,7 +21,6 @@ package org.librecms.pagemodel;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.pagemodel.ComponentBuilder;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemL10NManager; import org.librecms.contentsection.ContentItemL10NManager;
@ -42,13 +41,15 @@ import javax.ws.rs.core.Response;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.ComponentRenderer;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T> * @param <T>
*/ */
public abstract class AbstractContentItemComponentBuilder<T extends ContentItemComponent> public abstract class AbstractContentItemComponentRenderer<T extends ContentItemComponent>
implements ComponentBuilder<T> { implements ComponentRenderer<T> {
@Inject @Inject
private ConfigurationManager confManager; private ConfigurationManager confManager;
@ -70,7 +71,7 @@ public abstract class AbstractContentItemComponentBuilder<T extends ContentItemC
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@Override @Override
public Map<String, Object> buildComponent( public Map<String, Object> renderComponent(
final T componentModel, final T componentModel,
final Map<String, Object> parameters) { final Map<String, Object> parameters) {

View File

@ -48,8 +48,8 @@ import static org.librecms.pages.PagesConstants.*;
*/ */
@RequestScoped @RequestScoped
@ComponentModelType(componentModel = CategorizedItemComponent.class) @ComponentModelType(componentModel = CategorizedItemComponent.class)
public class CategorizedItemComponentBuilder public class CategorizedItemComponentRenderer
extends AbstractContentItemComponentBuilder<CategorizedItemComponent> { extends AbstractContentItemComponentRenderer<CategorizedItemComponent> {
@Inject @Inject
private CategoryRepository categoryRepo; private CategoryRepository categoryRepo;

View File

@ -27,7 +27,6 @@ import org.libreccm.categorization.DomainRepository;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.pagemodel.ComponentBuilder;
import org.libreccm.pagemodel.ComponentModelType; import org.libreccm.pagemodel.ComponentModelType;
import java.util.HashMap; import java.util.HashMap;
@ -43,45 +42,41 @@ import javax.transaction.Transactional;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.ComponentRenderer;
/** /**
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
@ComponentModelType(componentModel = CategoryTreeComponent.class) @ComponentModelType(componentModel = CategoryTreeComponent.class)
public class CategoryTreeComponentBuilder public class CategoryTreeComponentRenderer
implements ComponentBuilder<CategoryTreeComponent> { implements ComponentRenderer<CategoryTreeComponent> {
@Inject
private DomainRepository domainRepo;
@Inject @Inject
private CategoryManager categoryManager; private CategoryManager categoryManager;
@Inject @Inject
private CategoryRepository categoryRepo; private CategoryRepository categoryRepo;
@Inject @Inject
private ConfigurationManager confManager; private ConfigurationManager confManager;
@Inject
private GlobalizationHelper globalizationHelper;
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@Override @Override
public Map<String, Object> buildComponent( public Map<String, Object> renderComponent(
final CategoryTreeComponent componentModel, final CategoryTreeComponent componentModel,
final Map<String, Object> parameters) { final Map<String, Object> parameters) {
Objects.requireNonNull(componentModel); Objects.requireNonNull(componentModel);
Objects.requireNonNull(parameters); Objects.requireNonNull(parameters);
if (!parameters.containsKey(PARAMETER_CATEGORY)) { if (!parameters.containsKey(PARAMETER_CATEGORY)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The parameters map passed to this GreetingItem component does " "The parameters map passed to this GreetingItem component does "
+ "not include the parameter \"category\""); + "not include the parameter \"category\"");
} }
if (!(parameters.get(PARAMETER_CATEGORY) instanceof Category)) { if (!(parameters.get(PARAMETER_CATEGORY) instanceof Category)) {
throw new IllegalArgumentException(String throw new IllegalArgumentException(String
.format("The parameters map passed to this GreetingItem " .format("The parameters map passed to this GreetingItem "
@ -90,14 +85,14 @@ public class CategoryTreeComponentBuilder
Category.class.getName(), Category.class.getName(),
parameters.get(PARAMETER_CATEGORY).getClass().getName())); parameters.get(PARAMETER_CATEGORY).getClass().getName()));
} }
final Category category = categoryRepo final Category category = categoryRepo
.findById(((CcmObject) parameters.get(PARAMETER_CATEGORY)) .findById(((CcmObject) parameters.get(PARAMETER_CATEGORY))
.getObjectId()) .getObjectId())
.orElseThrow(() -> new IllegalArgumentException(String.format( .orElseThrow(() -> new IllegalArgumentException(String.format(
"No category with ID %d in the database.", "No category with ID %d in the database.",
((CcmObject) parameters.get(PARAMETER_CATEGORY)).getObjectId()))); ((CcmObject) parameters.get(PARAMETER_CATEGORY)).getObjectId())));
final Locale language; final Locale language;
if (parameters.containsKey(PARAMETER_LANGUAGE)) { if (parameters.containsKey(PARAMETER_LANGUAGE)) {
language = new Locale((String) parameters.get(PARAMETER_LANGUAGE)); language = new Locale((String) parameters.get(PARAMETER_LANGUAGE));
@ -106,19 +101,19 @@ public class CategoryTreeComponentBuilder
.findConfiguration(KernelConfig.class); .findConfiguration(KernelConfig.class);
language = kernelConfig.getDefaultLocale(); language = kernelConfig.getDefaultLocale();
} }
final Map<String, Object> result = new HashMap<>(); final Map<String, Object> result = new HashMap<>();
if (componentModel.isShowFullTree()) { if (componentModel.isShowFullTree()) {
final Category rootCategory = findRootCategory(category); final Category rootCategory = findRootCategory(category);
result.put("categoryName", rootCategory.getName()); result.put("categoryName", rootCategory.getName());
result.put("categoryPath", result.put("categoryPath",
categoryManager.getCategoryPath(rootCategory)); categoryManager.getCategoryPath(rootCategory));
result.put("categoryTitle", result.put("categoryTitle",
rootCategory.getTitle().getValue(language)); rootCategory.getTitle().getValue(language));
result.put("selected", rootCategory.equals(category)); result.put("selected", rootCategory.equals(category));
final List<Map<String, Object>> subCategories = rootCategory final List<Map<String, Object>> subCategories = rootCategory
.getSubCategories() .getSubCategories()
.stream() .stream()
@ -132,7 +127,7 @@ public class CategoryTreeComponentBuilder
result.put("categoryPath", result.put("categoryPath",
categoryManager.getCategoryPath(category)); categoryManager.getCategoryPath(category));
result.put("categoryTitle", category.getTitle().getValue(language)); result.put("categoryTitle", category.getTitle().getValue(language));
final List<Map<String, Object>> subCategories = category final List<Map<String, Object>> subCategories = category
.getSubCategories() .getSubCategories()
.stream() .stream()
@ -142,28 +137,28 @@ public class CategoryTreeComponentBuilder
} }
return result; return result;
} }
protected Map<String, Object> generateCategory(final Category category, protected Map<String, Object> generateCategory(final Category category,
final Locale language) { final Locale language) {
final Map<String, Object> result = new HashMap<>(); final Map<String, Object> result = new HashMap<>();
result.put("categoryName", category.getName()); result.put("categoryName", category.getName());
result.put("categoryPath", categoryManager.getCategoryPath(category)); result.put("categoryPath", categoryManager.getCategoryPath(category));
result.put("categoryTitle", category.getTitle().getValue(language)); result.put("categoryTitle", category.getTitle().getValue(language));
return result; return result;
} }
protected Map<String, Object> generateCategoryWithTree( protected Map<String, Object> generateCategoryWithTree(
final Category category, final Category category,
final Category selectedCategory, final Category selectedCategory,
final Locale language) { final Locale language) {
final Map<String, Object> result = new HashMap<>(); final Map<String, Object> result = new HashMap<>();
result.put("categoryName", category.getName()); result.put("categoryName", category.getName());
result.put("categoryPath", categoryManager.getCategoryPath(category)); result.put("categoryPath", categoryManager.getCategoryPath(category));
result.put("categoryTitle", category.getTitle().getValue(language)); result.put("categoryTitle", category.getTitle().getValue(language));
result.put("selected", selectedCategory.equals(category)); result.put("selected", selectedCategory.equals(category));
if (!category.getSubCategories().isEmpty()) { if (!category.getSubCategories().isEmpty()) {
final List<Map<String, Object>> subCategories = category final List<Map<String, Object>> subCategories = category
.getSubCategories() .getSubCategories()
@ -174,17 +169,17 @@ public class CategoryTreeComponentBuilder
.collect(Collectors.toList()); .collect(Collectors.toList());
result.put("subCategories", subCategories); result.put("subCategories", subCategories);
} }
return result; return result;
} }
protected Category findRootCategory(final Category category) { protected Category findRootCategory(final Category category) {
if (category.getParentCategory() == null) { if (category.getParentCategory() == null) {
return category; return category;
} else { } else {
return findRootCategory(category.getParentCategory()); return findRootCategory(category.getParentCategory());
} }
} }
} }

View File

@ -21,16 +21,10 @@ package org.librecms.pagemodel;
import org.libreccm.pagemodel.ComponentModel; import org.libreccm.pagemodel.ComponentModel;
import org.libreccm.pagemodel.PageModel; import org.libreccm.pagemodel.PageModel;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import javax.persistence.CollectionTable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Table; import javax.persistence.Table;
import static org.librecms.CmsConstants.*; import static org.librecms.CmsConstants.*;

View File

@ -35,8 +35,8 @@ import javax.ws.rs.NotFoundException;
*/ */
@RequestScoped @RequestScoped
@ComponentModelType(componentModel = FixedContentItemComponent.class) @ComponentModelType(componentModel = FixedContentItemComponent.class)
public class FixedContentItemComponentBuilder public class FixedContentItemComponentRenderer
extends AbstractContentItemComponentBuilder<FixedContentItemComponent> { extends AbstractContentItemComponentRenderer<FixedContentItemComponent> {
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;

View File

@ -41,8 +41,8 @@ import static org.librecms.pages.PagesConstants.*;
*/ */
@RequestScoped @RequestScoped
@ComponentModelType(componentModel = GreetingItemComponent.class) @ComponentModelType(componentModel = GreetingItemComponent.class)
public class GreetingItemComponentBuilder public class GreetingItemComponentRenderer
extends AbstractContentItemComponentBuilder<GreetingItemComponent> { extends AbstractContentItemComponentRenderer<GreetingItemComponent> {
@Inject @Inject
private CategoryRepository categoryRepo; private CategoryRepository categoryRepo;

View File

@ -76,6 +76,7 @@ public class ItemListComponent extends ComponentModel {
joinColumns = { joinColumns = {
@JoinColumn(name = "ITEM_LIST_ID") @JoinColumn(name = "ITEM_LIST_ID")
}) })
@Column(name = "LIST_ORDER")
private List<String> listOrder; private List<String> listOrder;
public boolean isDescending() { public boolean isDescending() {

View File

@ -18,7 +18,7 @@
*/ */
package org.librecms.pages; package org.librecms.pages;
import org.libreccm.pagemodel.AbstractPageBuilder; import org.libreccm.pagemodel.AbstractPageRenderer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -30,10 +30,10 @@ import javax.enterprise.context.RequestScoped;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
public class CmsPageBuilder extends AbstractPageBuilder { public class CmsPageBuilder extends AbstractPageRenderer {
@Override @Override
public Map<String, Object> buildPage(final Map<String, Object> parameters) { public Map<String, Object> renderPage(final Map<String, Object> parameters) {
final Map<String, Object> result = new HashMap<>(); final Map<String, Object> result = new HashMap<>();

View File

@ -444,9 +444,9 @@ public class PagesRouter {
final Map<String, Object> result; final Map<String, Object> result;
if (pageModel == null) { if (pageModel == null) {
result = pageBuilder.buildPage(parameters); result = pageBuilder.renderPage(parameters);
} else { } else {
result = pageBuilder.buildPage(pageModel, parameters); result = pageBuilder.renderPage(pageModel, parameters);
} }
return result; return result;

View File

@ -25,40 +25,40 @@ import javax.inject.Inject;
import java.util.Optional; import java.util.Optional;
/** /**
* An abstract base class for implementations of the {@link PageBuilder} * An abstract base class for implementations of the {@link PageRenderer}
* interface providing some functionality needed by all implementations of the * interface providing some functionality needed by all implementations of the
* {@link PageBuilder} interface. * {@link PageRenderer} interface.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* *
*/ */
public abstract class AbstractPageBuilder implements PageBuilder { public abstract class AbstractPageRenderer implements PageRenderer {
@Inject @Inject
private ComponentBuilderManager componentBuilderManager; private ComponentRendererManager componentRendererManager;
/** /**
* Build a {@code Page} based on a {@link PageModel}. This implementation * Renders a {@code Page} based on a {@link PageModel}. This implementation
* first calls {@link #buildPage()} to create the page object. After that * first calls {@link #renderPage()} to create the page object. After that
* all {@link ComponentModel}s of the {@link PageModel} are processed and * all {@link ComponentModel}s of the {@link PageModel} are processed and
* the component objects created by the {@link ComponentBuilder}s are added * the component objects created by the {@link ComponentRenderer}s are added
* to the page. * to the page.
* *
* @param pageModel The {@link PageModel} to process. * @param pageModel The {@link PageModel} to process.
* @param parameters Parameters provided by application which wants to * @param parameters Parameters provided by application which wants to
* render a {@link PageModel}. The parameters are passed * render a {@link PageModel}. The parameters are passed
* the {@link ComponentBuilder}s. * the {@link ComponentRenderer}s.
* *
* @return A page containing all components from the {@link PageModel}. * @return A page containing all components from the {@link PageModel}.
*/ */
@Override @Override
public Map<String, Object> buildPage(final PageModel pageModel, public Map<String, Object> renderPage(final PageModel pageModel,
final Map<String, Object> parameters) { final Map<String, Object> parameters) {
final Map<String, Object> page = buildPage(parameters); final Map<String, Object> page = renderPage(parameters);
for (final ComponentModel componentModel : pageModel.getComponents()) { for (final ComponentModel componentModel : pageModel.getComponents()) {
final Optional<Object> component = buildComponent( final Optional<Object> component = renderComponent(
componentModel, componentModel.getClass(), componentModel, componentModel.getClass(),
parameters); parameters);
if (component.isPresent()) { if (component.isPresent()) {
@ -71,7 +71,7 @@ public abstract class AbstractPageBuilder implements PageBuilder {
} }
/** /**
* Helper method for building the components. * Helper method for rendering the components.
* *
* @param <M> Generics variable for the type the component * @param <M> Generics variable for the type the component
* created. * created.
@ -79,24 +79,24 @@ public abstract class AbstractPageBuilder implements PageBuilder {
* @param componentModelClass The class of the {@link ComponentModel}. * @param componentModelClass The class of the {@link ComponentModel}.
* @param parameters Parameters provided by application which wants * @param parameters Parameters provided by application which wants
* to render a {@link PageModel}. The parameters * to render a {@link PageModel}. The parameters
* are passed the {@link ComponentBuilder}s. * are passed the {@link ComponentRenderer}s.
* *
* @return The components described by the {@code componentModel}. * @return The components described by the {@code componentModel}.
*/ */
protected <M extends ComponentModel> Optional<Object> buildComponent( protected <M extends ComponentModel> Optional<Object> renderComponent(
final ComponentModel componentModel, final ComponentModel componentModel,
final Class<M> componentModelClass, final Class<M> componentModelClass,
final Map<String, Object> parameters) { final Map<String, Object> parameters) {
componentBuilderManager.findComponentBuilder(componentModel.getClass()); componentRendererManager.findComponentRenderer(componentModel.getClass());
final Optional<ComponentBuilder<M>> builder = componentBuilderManager final Optional<ComponentRenderer<M>> renderer = componentRendererManager
.findComponentBuilder(componentModelClass); .findComponentRenderer(componentModelClass);
if (builder.isPresent()) { if (renderer.isPresent()) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final M model = (M) componentModel; final M model = (M) componentModel;
return Optional.of(builder.get().buildComponent(model, parameters)); return Optional.of(renderer.get().renderComponent(model, parameters));
} else { } else {
return Optional.empty(); return Optional.empty();
} }

View File

@ -25,8 +25,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** /**
* Specifies for which component and view technology a {@link ComponentBuilder} builds the * Specifies which type of components a {@link ComponentRenderer} implenentation
* components. * renders.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@ -36,6 +36,5 @@ import java.lang.annotation.Target;
public @interface ComponentModelType { public @interface ComponentModelType {
Class<? extends ComponentModel> componentModel(); Class<? extends ComponentModel> componentModel();
} }

View File

@ -21,16 +21,16 @@ package org.libreccm.pagemodel;
import java.util.Map; import java.util.Map;
/** /**
* A {@code ComponentBuilder} transforms a {@link ComponentModel} into a * A {@code ComponentRenderer} transforms a {@link ComponentModel} into a
* component. * component.
* *
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <M> Type of the model the component builder processes. * @param <M> Type of the model the component renderer processes.
*/ */
public interface ComponentBuilder<M extends ComponentModel> { public interface ComponentRenderer<M extends ComponentModel> {
Map<String, Object> buildComponent(M componentModel, Map<String, Object> renderComponent(M componentModel,
final Map<String, Object> parameters); final Map<String, Object> parameters);
} }

View File

@ -30,63 +30,63 @@ import java.util.Optional;
/** /**
* Provides access to all available implementations of the * Provides access to all available implementations of the
* {@link ComponentBuilder} interface. * {@link ComponentRenderer} interface.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@RequestScoped @RequestScoped
public class ComponentBuilderManager { public class ComponentRendererManager {
private static final Logger LOGGER = LogManager.getLogger( private static final Logger LOGGER = LogManager.getLogger(
ComponentBuilderManager.class); ComponentRendererManager.class);
@Inject @Inject
private Instance<ComponentBuilder<?>> componentBuilders; private Instance<ComponentRenderer<?>> componentRenderers;
/** /**
* Find an implementation of the {@link ComponentBuilder} interface for a * Find an implementation of the {@link ComponentRenderer} interface for a
* specific {@link ComponentModel}. * specific {@link ComponentModel}.
* *
* @param <M> Generic variable for the subtype of * @param <M> Generic variable for the subtype of
* {@link ComponentModel} which is produced by * {@link ComponentModel} which is produced by
* the {@link ComponentBuilder} implementation. * the {@link ComponentRenderer} implementation.
* @param componentModelClass The sub class of the {@link ComponentModel} * @param componentModelClass The sub class of the {@link ComponentModel}
* for which is processed by the * for which is processed by the
* {@link ComponentBuilder}. * {@link ComponentRenderer}.
* *
* @return An {@link Optional} containing the implementation of the * @return An {@link Optional} containing the implementation of the
* {@link ComponentBuilder} interface for the specified parameters. * {@link ComponentRenderer} interface for the specified parameters.
* If there is no implementation for the specified parameters an * If there is no implementation for the specified parameters an
* empty {@link Optional} is returned. * empty {@link Optional} is returned.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <M extends ComponentModel> Optional<ComponentBuilder<M>> findComponentBuilder( public <M extends ComponentModel> Optional<ComponentRenderer<M>> findComponentRenderer(
final Class<M> componentModelClass) { final Class<M> componentModelClass) {
LOGGER.debug("Trying to find ComponentBuilder for ComponentModel\"{}\"" LOGGER.debug("Trying to find ComponentRenderer for ComponentModel\"{}\""
+ "and type \"{}\"...", + "and type \"{}\"...",
componentModelClass.getName()); componentModelClass.getName());
final ComponentModelTypeLiteral literal = new ComponentModelTypeLiteral( final ComponentModelTypeLiteral literal = new ComponentModelTypeLiteral(
componentModelClass); componentModelClass);
final Instance<ComponentBuilder<?>> instance = componentBuilders final Instance<ComponentRenderer<?>> instance = componentRenderers
.select(literal); .select(literal);
if (instance.isUnsatisfied()) { if (instance.isUnsatisfied()) {
LOGGER.warn("No ComponentBuilder for component model \"%s\" " LOGGER.warn("No ComponentRenderer for component model \"%s\" "
+ "and type \"%s\". Ignoring component model."); + "and type \"%s\". Ignoring component model.");
return Optional.empty(); return Optional.empty();
} else if (instance.isAmbiguous()) { } else if (instance.isAmbiguous()) {
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"Multiple ComponentBuilders for component model \"%s\"available. " "Multiple ComponentRenderers for component model \"%s\"available. "
+ "Something is wrong", + "Something is wrong",
componentModelClass.getName())); componentModelClass.getName()));
} else { } else {
final Iterator<ComponentBuilder<?>> iterator = instance. final Iterator<ComponentRenderer<?>> iterator = instance.
iterator(); iterator();
final ComponentBuilder<?> componentBuilder = iterator.next(); final ComponentRenderer<?> componentRenderer = iterator.next();
return Optional.of((ComponentBuilder<M>) componentBuilder); return Optional.of((ComponentRenderer<M>) componentRenderer);
} }
} }

View File

@ -50,14 +50,14 @@ import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* A {@link PageModel} is used by a {@link PageBuilder} implementation to build * A {@link PageModel} is used by a {@link PageRenderer} implementation to render
* a page. The {@code PageModel} specifics which components are used on a page. * a page. The {@code PageModel} specifics which components are used on a page.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* *
* @see PageModelRepository * @see PageModelRepository
* @see PageModelManager * @see PageModelManager
* @see PageBuilder * @see PageRenderer
*/ */
@Entity @Entity
@Inheritance(strategy = InheritanceType.JOINED) @Inheritance(strategy = InheritanceType.JOINED)

View File

@ -20,11 +20,10 @@ package org.libreccm.pagemodel;
import java.util.Map; import java.util.Map;
/** /**
* Interface for page builders. A page builder is invoked to build a page a * Interface for page renderers. A page renderer is invoked to render a page of
* specific type. An implementation should be a CDI bean which is annotated with * specific type. An implementation should be a CDI bean which is annotated with
* the qualifier {@link PageModelType}. * the qualifier {@link PageModelType}.
* *
* An implementation should add all default components which have to be present * An implementation should add all default components which have to be present
* in page. The {@link PageModel} should only specify * in page. The {@link PageModel} should only specify
@ -33,35 +32,35 @@ import java.util.Map;
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public interface PageBuilder { public interface PageRenderer {
/** /**
* Build a page for the view technology supported by this page builder * Render a page for the view technology supported by this page renderer
* without any additional components. * without any additional components.
* {@link #buildPage(org.libreccm.pagemodel.PageModel)} should use this * {@link #renderPage(org.libreccm.pagemodel.PageModel)} should use this
* method for creating the default page. * method for creating the default page.
* *
* @param parameters Parameters provided by application which wants to * @param parameters Parameters provided by application which wants to
* render a {@link PageModel}. The parameters are passed * render a {@link PageModel}. The parameters are passed
* the {@link ComponentBuilder}s. * the {@link ComponentRenderer}s.
* *
* @return A page with the default components. * @return A page with the default components.
*/ */
Map<String, Object> buildPage(Map<String, Object> parameters); Map<String, Object> renderPage(Map<String, Object> parameters);
/** /**
* Build a page of type {@code P} using the provided {@link PageModel}. * Render a page of type {@code P} using the provided {@link PageModel}.
* Implementations should call the implementation of {@link #buildPage()} * Implementations should call the implementation of {@link #renderPage()}
* for creating the basic page with the default components. * for creating the basic page with the default components.
* *
* @param pageModel The {@link PageModel} from which the page is generated. * @param pageModel The {@link PageModel} from which the page is generated.
* @param parameters Parameters provided by application which wants to * @param parameters Parameters provided by application which wants to
* render a {@link PageModel}. The parameters are passed * render a {@link PageModel}. The parameters are passed
* the {@link ComponentBuilder}s. * the {@link ComponentRenderer}s.
* *
* @return The page generated from the provided {@link PageModel}. * @return The page generated from the provided {@link PageModel}.
*/ */
Map<String, Object> buildPage(PageModel pageModel, Map<String, Object> renderPage(PageModel pageModel,
Map<String, Object> parameters); Map<String, Object> parameters);
} }

View File

@ -24,19 +24,19 @@
* </p> * </p>
* <p> * <p>
* The Page Model system allows it to specify which components are used on a * The Page Model system allows it to specify which components are used on a
* page are therefore which information is displayed on a page. It is intended * page and therefore which information is displayed on a page. It is intended
* to be used for public pages (like the item page of a content item category * to be used for public pages (like the item page of a content item category
* page in ccm-cms. The Page Model system uses data containers which are read by * page in ccm-cms. The Page Model system uses data containers which are read by
* some builder classes. Because we are not using any active code in the page * a renderer class. Because we are not using any active code in the page
* models this avoids a potential attack point. * models this avoids a potential attack point.
* </p> * </p>
* <p> * <p>
* The central interface is the {@link org.libreccm.pagemodel.PageBuilder} * The central interface is the {@link org.libreccm.pagemodel.PageRenderer}
* interface. An implementation of this interface will take a * interface. An implementation of this interface will take a
* {@link org.libreccm.pagemodel.PageModel} and process it and create a page * {@link org.libreccm.pagemodel.PageModel} and process it and create a page
* from it using the view technology supported by the implementation. * from it using the view technology supported by the implementation.
* {@code PageBuilder}s are CDI beans. Implementations can be retrieved using * {@code PageRenderer}s are CDI beans. Implementations can be retrieved using
* the {@link org.libreccm.pagemodel.PageBuilderManager#findPageBuilder(String, Class)} method. * the {@link org.libreccm.pagemodel.PageRendererManager#findPageRenderer(String, Class)} method.
* </p> * </p>
* *
*/ */