CCM NG: Some JavaDoc
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5141 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
cc5040bd31
commit
2b7f492602
|
|
@ -22,7 +22,6 @@ import org.libreccm.categorization.Categorization;
|
|||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentItemVersion;
|
||||
|
||||
|
|
@ -42,13 +41,15 @@ import javax.ws.rs.NotFoundException;
|
|||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.RendersComponentModel;
|
||||
|
||||
/**
|
||||
* Renderer for the {@link CategorizedItemComponent}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = CategorizedItemComponent.class)
|
||||
@RendersComponentModel(componentModel = CategorizedItemComponent.class)
|
||||
public class CategorizedItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<CategorizedItemComponent> {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import org.libreccm.categorization.CategoryManager;
|
|||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -41,6 +40,7 @@ import javax.transaction.Transactional;
|
|||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.ComponentRenderer;
|
||||
import org.libreccm.pagemodel.RendersComponentModel;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = CategoryTreeComponent.class)
|
||||
@RendersComponentModel(componentModel = CategoryTreeComponent.class)
|
||||
public class CategoryTreeComponentRenderer
|
||||
implements ComponentRenderer<CategoryTreeComponent> {
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.librecms.pagemodel;
|
||||
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
import org.librecms.contentsection.ContentItemRepository;
|
||||
|
||||
|
|
@ -29,13 +28,15 @@ import javax.enterprise.context.RequestScoped;
|
|||
import javax.inject.Inject;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
|
||||
import org.libreccm.pagemodel.RendersComponentModel;
|
||||
|
||||
/**
|
||||
* Renderer for the {@link FixedContentItemComponent}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = FixedContentItemComponent.class)
|
||||
@RendersComponentModel(componentModel = FixedContentItemComponent.class)
|
||||
public class FixedContentItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<FixedContentItemComponent> {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import org.libreccm.categorization.Category;
|
|||
import org.libreccm.categorization.CategoryManager;
|
||||
import org.libreccm.categorization.CategoryRepository;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
import org.librecms.contentsection.ContentItem;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -35,13 +34,15 @@ import javax.ws.rs.NotFoundException;
|
|||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.RendersComponentModel;
|
||||
|
||||
/**
|
||||
* Renderer for the {@link GreetingItemComponent}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = GreetingItemComponent.class)
|
||||
@RendersComponentModel(componentModel = GreetingItemComponent.class)
|
||||
public class GreetingItemComponentRenderer
|
||||
extends AbstractContentItemComponentRenderer<GreetingItemComponent> {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import org.libreccm.categorization.Categorization;
|
|||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.UnexpectedErrorException;
|
||||
import org.libreccm.pagemodel.ComponentModelType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -54,13 +53,15 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
import static org.librecms.pages.PagesConstants.*;
|
||||
|
||||
import org.libreccm.pagemodel.RendersComponentModel;
|
||||
|
||||
/**
|
||||
* Renderer for the {@link ItemListComponent}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@ComponentModelType(componentModel = ItemListComponent.class)
|
||||
@RendersComponentModel(componentModel = ItemListComponent.class)
|
||||
public class ItemListComponentRenderer
|
||||
implements ComponentRenderer<ItemListComponent> {
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ import java.util.UUID;
|
|||
@RequestScoped
|
||||
public class ComponentModelRepository extends AbstractEntityRepository<Long, ComponentModel> {
|
||||
|
||||
private static final long serialVersionUID = -6358512316472857971L;
|
||||
|
||||
@Override
|
||||
public Class<ComponentModel> getEntityClass() {
|
||||
return ComponentModel.class;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,14 @@ import javax.annotation.PostConstruct;
|
|||
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>
|
||||
*/
|
||||
|
|
@ -45,6 +53,10 @@ public class ComponentModels {
|
|||
private final Map<String, PageModelComponentModel> componentInfos
|
||||
= new HashMap<>();
|
||||
|
||||
/**
|
||||
* Creates the list of available {@link ComponentModels}. Called by the CDI
|
||||
* container.
|
||||
*/
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
|
||||
|
|
@ -68,16 +80,44 @@ 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() {
|
||||
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(
|
||||
final Class<? extends ComponentModel> clazz) {
|
||||
|
||||
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(
|
||||
final String className) {
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import java.util.Map;
|
|||
* A {@code ComponentRenderer} transforms a {@link ComponentModel} into a
|
||||
* component.
|
||||
*
|
||||
* An implementation must be annotation with the {@link ComponentModelType}
|
||||
* qualifier annotation.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
* @param <M> Type of the model the component renderer processes.
|
||||
|
|
@ -34,9 +36,9 @@ public interface ComponentRenderer<M extends ComponentModel> {
|
|||
/**
|
||||
* Renders a {@link ComponentModel}.
|
||||
*
|
||||
* The result of the rendering process is a map which uses strings as key.
|
||||
* The values are either Java primitive types or Collections. More exactly
|
||||
* the values are objects of one the following types:
|
||||
* The result of the rendering process is a {@link Map} which uses strings
|
||||
* as key. The values are either Java primitive types or Collections. More
|
||||
* exactly the values are objects of one the following types:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link Double}</li>
|
||||
|
|
@ -50,8 +52,8 @@ public interface ComponentRenderer<M extends ComponentModel> {
|
|||
* </ul>
|
||||
*
|
||||
* 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
|
||||
* the list above. Collections might contain multiple types from the list
|
||||
* guarantee for that. The values in a collection must be one of the types
|
||||
* in the list above. Collections might contain multiple types from the list
|
||||
* above. The keys for a map should always be strings.
|
||||
*
|
||||
* @param componentModel The component model to render.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
extends AnnotationLiteral<ComponentModelType>
|
||||
implements ComponentModelType {
|
||||
extends AnnotationLiteral<RendersComponentModel>
|
||||
implements RendersComponentModel {
|
||||
|
||||
private static final long serialVersionUID = -2601632434295178600L;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
/**
|
||||
* 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
|
||||
* the qualifier {@link PageModelType}.
|
||||
* the qualifier {@link RendersPageModelType}.
|
||||
*
|
||||
* An implementation should add all default components which have to be present
|
||||
* in page. The {@link PageModel} should only specify
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import java.lang.annotation.Target;
|
|||
@Qualifier
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface ComponentModelType {
|
||||
public @interface RendersComponentModel {
|
||||
|
||||
Class<? extends ComponentModel> componentModel();
|
||||
|
||||
|
|
@ -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();
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue