CCM NG: Some JavaDoc

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5141 8810af33-2d31-482b-a856-94f89814c4df
jensp 2017-11-27 10:25:37 +00:00
parent 10fa61b0c0
commit 30d9dc0c15
12 changed files with 114 additions and 25 deletions

View File

@ -22,7 +22,6 @@ import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.pagemodel.ComponentModelType;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemVersion; import org.librecms.contentsection.ContentItemVersion;
@ -42,13 +41,15 @@ import javax.ws.rs.NotFoundException;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.RendersComponentModel;
/** /**
* Renderer for the {@link CategorizedItemComponent}. * Renderer for the {@link CategorizedItemComponent}.
* *
* @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 = CategorizedItemComponent.class) @RendersComponentModel(componentModel = CategorizedItemComponent.class)
public class CategorizedItemComponentRenderer public class CategorizedItemComponentRenderer
extends AbstractContentItemComponentRenderer<CategorizedItemComponent> { extends AbstractContentItemComponentRenderer<CategorizedItemComponent> {

View File

@ -25,7 +25,6 @@ import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.pagemodel.ComponentModelType;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -41,6 +40,7 @@ import javax.transaction.Transactional;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.ComponentRenderer; import org.libreccm.pagemodel.ComponentRenderer;
import org.libreccm.pagemodel.RendersComponentModel;
/** /**
* Renderer for the {@link CategoryTreeComponent}. * Renderer for the {@link CategoryTreeComponent}.
@ -48,7 +48,7 @@ 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) @RendersComponentModel(componentModel = CategoryTreeComponent.class)
public class CategoryTreeComponentRenderer public class CategoryTreeComponentRenderer
implements ComponentRenderer<CategoryTreeComponent> { implements ComponentRenderer<CategoryTreeComponent> {

View File

@ -18,7 +18,6 @@
*/ */
package org.librecms.pagemodel; package org.librecms.pagemodel;
import org.libreccm.pagemodel.ComponentModelType;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
@ -29,13 +28,15 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.ws.rs.NotFoundException; import javax.ws.rs.NotFoundException;
import org.libreccm.pagemodel.RendersComponentModel;
/** /**
* Renderer for the {@link FixedContentItemComponent}. * Renderer for the {@link FixedContentItemComponent}.
* *
* @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 = FixedContentItemComponent.class) @RendersComponentModel(componentModel = FixedContentItemComponent.class)
public class FixedContentItemComponentRenderer public class FixedContentItemComponentRenderer
extends AbstractContentItemComponentRenderer<FixedContentItemComponent> { extends AbstractContentItemComponentRenderer<FixedContentItemComponent> {

View File

@ -22,7 +22,6 @@ import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager; import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.CategoryRepository; import org.libreccm.categorization.CategoryRepository;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.pagemodel.ComponentModelType;
import org.librecms.contentsection.ContentItem; import org.librecms.contentsection.ContentItem;
import java.util.Map; import java.util.Map;
@ -35,13 +34,15 @@ import javax.ws.rs.NotFoundException;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.RendersComponentModel;
/** /**
* Renderer for the {@link GreetingItemComponent}. * Renderer for the {@link GreetingItemComponent}.
* *
* @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 = GreetingItemComponent.class) @RendersComponentModel(componentModel = GreetingItemComponent.class)
public class GreetingItemComponentRenderer public class GreetingItemComponentRenderer
extends AbstractContentItemComponentRenderer<GreetingItemComponent> { extends AbstractContentItemComponentRenderer<GreetingItemComponent> {

View File

@ -24,7 +24,6 @@ import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Category; import org.libreccm.categorization.Category;
import org.libreccm.configuration.ConfigurationManager; import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.core.UnexpectedErrorException; import org.libreccm.core.UnexpectedErrorException;
import org.libreccm.pagemodel.ComponentModelType;
import java.util.Map; import java.util.Map;
@ -54,13 +53,15 @@ import javax.servlet.http.HttpServletRequest;
import static org.librecms.pages.PagesConstants.*; import static org.librecms.pages.PagesConstants.*;
import org.libreccm.pagemodel.RendersComponentModel;
/** /**
* Renderer for the {@link ItemListComponent}. * Renderer for the {@link ItemListComponent}.
* *
* @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 = ItemListComponent.class) @RendersComponentModel(componentModel = ItemListComponent.class)
public class ItemListComponentRenderer public class ItemListComponentRenderer
implements ComponentRenderer<ItemListComponent> { implements ComponentRenderer<ItemListComponent> {

View File

@ -35,6 +35,8 @@ import java.util.UUID;
@RequestScoped @RequestScoped
public class ComponentModelRepository extends AbstractEntityRepository<Long, ComponentModel> { public class ComponentModelRepository extends AbstractEntityRepository<Long, ComponentModel> {
private static final long serialVersionUID = -6358512316472857971L;
@Override @Override
public Class<ComponentModel> getEntityClass() { public Class<ComponentModel> getEntityClass() {
return ComponentModel.class; return ComponentModel.class;

View File

@ -33,6 +33,14 @@ import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
/** /**
* An Utility class which provides access to all component models available.
*
* This class is an {@link ApplicationScoped} CDI bean. The {@link #init} method
* is called by the CDI container after creating an instance of this class. The
* {@link #init} method retrieves the informations about the available
* {@link ComponentModel}s from the module classes. For exactly from the
* {@link Module#pageModelComponentModels()} property of the {@link Module}
* annotation of the module class.
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@ -40,11 +48,15 @@ import javax.enterprise.context.ApplicationScoped;
public class ComponentModels { public class ComponentModels {
private final List<PageModelComponentModel> availableComponentModels private final List<PageModelComponentModel> availableComponentModels
= new ArrayList<>(); = new ArrayList<>();
private final Map<String, PageModelComponentModel> componentInfos private final Map<String, PageModelComponentModel> componentInfos
= new HashMap<>(); = new HashMap<>();
/**
* Creates the list of available {@link ComponentModels}. Called by the CDI
* container.
*/
@PostConstruct @PostConstruct
private void init() { private void init() {
@ -68,18 +80,46 @@ public class ComponentModels {
} }
} }
/**
* Get a list of the available {@link ComponentModel}s.
*
* @return A (unmodifiable) list of all available {@link ComponentModel}s.
*/
public List<PageModelComponentModel> findAvailableComponentModels() { public List<PageModelComponentModel> findAvailableComponentModels() {
return Collections.unmodifiableList(availableComponentModels); return Collections.unmodifiableList(availableComponentModels);
} }
/**
* Get the informations about a specific {@link ComponentModel}
* implementation.
*
* @param clazz The class of the {@link ComponentModel} implementation.
*
* @return An {@link Optional} containing the informations about the
* {@link ComponentModel} implementation. If the class is not a
* {@link ComponentModel} implementation or is an unknown
* implementation an empty {@link Optional} is returned.
*/
public Optional<PageModelComponentModel> getComponentModelInfo( public Optional<PageModelComponentModel> getComponentModelInfo(
final Class<? extends ComponentModel> clazz) { final Class<? extends ComponentModel> clazz) {
return getComponentModelInfo(clazz.getName()); return getComponentModelInfo(clazz.getName());
} }
/**
* Get the informations about a specific {@link ComponentModel}
* implementation.
*
* @param className The name of the class of the {@link ComponentModel}
* implementation.
*
* @return An {@link Optional} containing the informations about the
* {@link ComponentModel} implementation. If the class is not a
* {@link ComponentModel} implementation or is an unknown
* implementation an empty {@link Optional} is returned.
*/
public Optional<PageModelComponentModel> getComponentModelInfo( public Optional<PageModelComponentModel> getComponentModelInfo(
final String className) { final String className) {
if (componentInfos.containsKey(className)) { if (componentInfos.containsKey(className)) {
return Optional.of(componentInfos.get(className)); return Optional.of(componentInfos.get(className));

View File

@ -25,6 +25,8 @@ import java.util.Map;
* A {@code ComponentRenderer} transforms a {@link ComponentModel} into a * A {@code ComponentRenderer} transforms a {@link ComponentModel} into a
* component. * component.
* *
* An implementation must be annotation with the {@link ComponentModelType}
* qualifier annotation.
* *
* @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 renderer processes. * @param <M> Type of the model the component renderer processes.
@ -34,9 +36,9 @@ public interface ComponentRenderer<M extends ComponentModel> {
/** /**
* Renders a {@link ComponentModel}. * Renders a {@link ComponentModel}.
* *
* The result of the rendering process is a map which uses strings as key. * The result of the rendering process is a {@link Map} which uses strings
* The values are either Java primitive types or Collections. More exactly * as key. The values are either Java primitive types or Collections. More
* the values are objects of one the following types: * exactly the values are objects of one the following types:
* *
* <ul> * <ul>
* <li>{@link Double}</li> * <li>{@link Double}</li>
@ -50,8 +52,8 @@ public interface ComponentRenderer<M extends ComponentModel> {
* </ul> * </ul>
* *
* Other subtypes {@link Collection} are might be supported but there is no * Other subtypes {@link Collection} are might be supported but there is no
* grantee for that. The values in a collection must be one of the types in * guarantee for that. The values in a collection must be one of the types
* the list above. Collections might contain multiple types from the list * in the list above. Collections might contain multiple types from the list
* above. The keys for a map should always be strings. * above. The keys for a map should always be strings.
* *
* @param componentModel The component model to render. * @param componentModel The component model to render.

View File

@ -92,11 +92,11 @@ public class ComponentRendererManager {
} }
/** /**
* Annotation literal for the {@link ComponentModelType} annotation. * Annotation literal for the {@link RendersComponentModel} annotation.
*/ */
private static class ComponentModelTypeLiteral private static class ComponentModelTypeLiteral
extends AnnotationLiteral<ComponentModelType> extends AnnotationLiteral<RendersComponentModel>
implements ComponentModelType { implements RendersComponentModel {
private static final long serialVersionUID = -2601632434295178600L; private static final long serialVersionUID = -2601632434295178600L;

View File

@ -23,7 +23,7 @@ import java.util.Map;
/** /**
* Interface for page renderers. A page renderer is invoked to render a page of * 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 RendersPageModelType}.
* *
* 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

View File

@ -33,7 +33,7 @@ import java.lang.annotation.Target;
@Qualifier @Qualifier
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
public @interface ComponentModelType { public @interface RendersComponentModel {
Class<? extends ComponentModel> componentModel(); Class<? extends ComponentModel> componentModel();

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2017 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.pagemodel;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
* Specifies which type of {@link PageModel} an implementation of
* {@link PageRenderer} can render.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RendersPageModelType {
String value();
}