Author: alexsmirnov
Date: 2010-05-10 19:48:39 -0400 (Mon, 10 May 2010)
New Revision: 16980
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/MapEntry.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -46,7 +46,7 @@
*/
public String name() default "";
- public TagType type() default TagType.All;
+ public TagType type() default TagType.None;
public String handler() default "";
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -27,5 +27,17 @@
* @since Feb 11, 2010
*/
public enum TagType {
- Jsp, Facelets, All
+ /**
+ * <p class="changed_added_4_0">Do not generate any tags, this is
default value for {@link Tag#type()} annotation.</p>
+ */
+ None, /**
+ * <p class="changed_added_4_0">Defines JSP tag.</p>
+ */
+ Jsp, /**
+ * <p class="changed_added_4_0">Defines Facelets tag.</p>
+ */
+ Facelets, /**
+ * <p class="changed_added_4_0">Enforces tag annotation to generate
all known tag types</p>
+ */
+ All
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -53,7 +53,6 @@
*/
public FacesId inferComponentType(ClassName componentClass) throws
InvalidNameException;
- public FacesId inferComponentType(String componentFamily) throws
InvalidNameException;
/**
* <p class="changed_added_4_0">Calculates concrete component class
from explicit value or type.</p>
@@ -77,6 +76,13 @@
*/
public String inferUIComponentFamily(FacesId componentType) throws
InvalidNameException;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param componentType
+ * @param markup
+ * @return
+ * @throws InvalidNameException
+ */
public ClassName inferTagHandlerClass(FacesId componentType, String markup) throws
InvalidNameException;
public String inferTagName(FacesId componentType) throws InvalidNameException;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -78,11 +78,6 @@
}
@Override
- public FacesId inferComponentType(String componentFamily) throws InvalidNameException
{
- return new FacesId(componentFamily);
- }
-
- @Override
public ClassName inferUIComponentClass(FacesId componentType) throws
InvalidNameException {
if (null == componentType) {
throw new IllegalArgumentException();
@@ -98,10 +93,6 @@
return new ClassName(name.toString());
}
- private boolean isAbstract(String baseClass, boolean baseClassIsAbstract) {
- return baseClassIsAbstract || baseClass.startsWith(ABSTRACT) ||
baseClass.endsWith(BASE);
- }
-
@Override
public String inferUIComponentFamily(FacesId componentType) {
if (null == componentType) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -4,6 +4,7 @@
import com.google.inject.Provider;
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ClassName;
@@ -49,19 +50,22 @@
protected void setTagInfo(Tag tag, ModelElementBase model) {
TagModel tagModel = new TagModel();
- String name = tag.name();
- if (Strings.isEmpty(name)) {
- name = getNamingConventions().inferTagName(model.getId());
+ if (!TagType.None.equals(tag.type())) {
+ String name = tag.name();
+ if (Strings.isEmpty(name)) {
+ name = getNamingConventions().inferTagName(model.getId());
+ }
+ tagModel.setName(name);
+ tagModel.setType(tag.type());
+ tagModel.setTargetClass(ClassName.parseName(tag.handler()));
+ tagModel.setBaseClass(ClassName.parseName(getBaseClass(tag, model)));
+ tagModel.setGenerate(tag.generate());
+
+ // TODO - move refference integrity to model.
+ tagModel.setModel(model);
+ model.getTags().add(tagModel);
+
}
- tagModel.setName(name);
- tagModel.setType(tag.type());
- tagModel.setTargetClass(ClassName.parseName(tag.handler()));
- tagModel.setBaseClass(ClassName.parseName(getBaseClass(tag, model)));
- tagModel.setGenerate(tag.generate());
-
- // TODO - move refference integrity to model.
- tagModel.setModel(model);
- model.getTags().add(tagModel);
}
private String getBaseClass(Tag tag, ModelElementBase model) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -21,37 +21,33 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.model;
-import com.google.inject.Singleton;
-import org.richfaces.cdk.model.RenderKitModel.Id;
-import org.richfaces.cdk.util.Strings;
-
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.NoSuchElementException;
-import java.util.ArrayList;
+import org.richfaces.cdk.util.Strings;
+
+import com.google.inject.Singleton;
+
/**
* <p class="changed_added_4_0">
* That class contains model of all JSF components asscoiated with that project
* </p>
* <p>
- * To keep consistence of library references, only library methods are allowed
- * to components manipulations.
+ * To keep consistence of library references, only library methods are allowed to
components manipulations.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@Singleton
public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>,
Trackable, Visitable {
@@ -63,20 +59,20 @@
"http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd";
private static final long serialVersionUID = -6055670836731899832L;
- private final ModelCollection<ComponentModel> components =
ModelCollection.<ComponentModel>create();
+ private final ModelCollection<ComponentModel> components =
ModelCollection.<ComponentModel> create();
/**
* <p class="changed_added_4_0">
* JSF renderer associated with that library
* </p>
*/
- private final ModelMap<RenderKitModel.Id, RenderKitModel> renderKits =
ModelMap.<RenderKitModel.Id, RenderKitModel>create();
+ private final ModelCollection<RenderKitModel> renderKits =
ModelCollection.<RenderKitModel> create();
- private final ModelCollection<ConverterModel> converters =
ModelCollection.<ConverterModel>create();
+ private final ModelCollection<ConverterModel> converters =
ModelCollection.<ConverterModel> create();
- private final ModelCollection<ValidatorModel> validators =
ModelCollection.<ValidatorModel>create();
+ private final ModelCollection<ValidatorModel> validators =
ModelCollection.<ValidatorModel> create();
- private final ModelCollection<ListenerModel> listeners =
ModelCollection.<ListenerModel>create();
+ private final ModelCollection<ListenerModel> listeners =
ModelCollection.<ListenerModel> create();
private long lastModified = Long.MIN_VALUE;
@@ -85,12 +81,12 @@
* Application level events fired by the component
* </p>
*/
- private final ModelCollection<EventModel> events =
ModelCollection.<EventModel>create();
+ private final ModelCollection<EventModel> events =
ModelCollection.<EventModel> create();
- private final ModelCollection<BehaviorModel> behaviors =
ModelCollection.<BehaviorModel>create();
+ private final ModelCollection<BehaviorModel> behaviors =
ModelCollection.<BehaviorModel> create();
private ConfigExtension extension;
-
+
private boolean metadataComplete;
/**
@@ -101,8 +97,9 @@
private final TagLibrary tagLibrary;
/**
- * <p class="changed_added_4_0"></p>
- *
+ * <p class="changed_added_4_0">
+ * </p>
+ *
*/
public ComponentLibrary() {
this.tagLibrary = new TagLibrary();
@@ -111,7 +108,7 @@
public void accept(Visitor visitor) {
visitor.visitComponentLibrary(this);
- visitMap(visitor, renderKits);
+ renderKits.accept(visitor);
components.accept(visitor);
converters.accept(visitor);
validators.accept(visitor);
@@ -120,27 +117,27 @@
behaviors.accept(visitor);
}
- private void visitMap(Visitor visitor, ModelMap<Id, RenderKitModel> modelMap)
{
- for (RenderKitModel renderKit : modelMap.values()) {
- renderKit.accept(visitor);
- }
- }
-
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @param renderKitId
* @return
*/
public RenderKitModel addRenderKit(String renderKitId) {
RenderKitModel.Id renderKitType = new RenderKitModel.Id(renderKitId);
- RenderKitModel renderKit = renderKits.get(renderKitType);
+ RenderKitModel renderKit = addRenderKit(renderKitType);
+ return renderKit;
+ }
+ public RenderKitModel addRenderKit(RenderKitModel.Id renderKitType) {
+ RenderKitModel renderKit = getRenderKit(renderKitType);
+
if (null == renderKit) {
renderKit = new RenderKitModel();
- renderKits.put(renderKitType, renderKit);
+ renderKit.setId(renderKitType);
+ renderKits.add(renderKit);
}
return renderKit;
}
@@ -148,7 +145,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the components
*/
public Collection<ComponentModel> getComponents() {
@@ -171,23 +168,26 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the renderKits
*/
- public Map<Id, RenderKitModel> getRenderKits() {
+ public Collection<RenderKitModel> getRenderKits() {
return renderKits;
}
public RenderKitModel getRenderKit(RenderKitModel.Id id) {
- return renderKits.get(id);
+ if (null != id) {
+ for (RenderKitModel renderKit : renderKits) {
+ if (id.equals(renderKit.getId())) {
+ return renderKit;
+ }
+ }
+ }
+ return null;
}
public void addRenderer(RenderKitModel.Id renderKitId, RendererModel rendererModel)
{
- RenderKitModel renderKit = this.renderKits.get(renderKitId);
- if (renderKit == null) {
- renderKit = new RenderKitModel();
- this.renderKits.put(renderKitId, renderKit);
- }
+ RenderKitModel renderKit = addRenderKit(renderKitId);
renderKit.getRenderers().add(rendererModel);
}
@@ -202,7 +202,7 @@
}
List<RendererModel> res = new ArrayList<RendererModel>();
- for (RenderKitModel renderKitModel : renderKits.values()) {
+ for (RenderKitModel renderKitModel : renderKits) {
for (RendererModel rendererModel : renderKitModel.getRenderers()) {
if (componentFamily.equals(rendererModel.getFamily())) {
res.add(rendererModel);
@@ -235,7 +235,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the converters
*/
public Collection<ConverterModel> getConverters() {
@@ -245,7 +245,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the validators
*/
public Collection<ValidatorModel> getValidators() {
@@ -255,7 +255,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the behaviors
*/
public Collection<BehaviorModel> getBehaviors() {
@@ -265,7 +265,7 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the listeners
*/
public Collection<ListenerModel> getListeners() {
@@ -273,7 +273,9 @@
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the events
*/
public Collection<EventModel> getEvents() {
@@ -283,18 +285,19 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the tagLibrary
*/
public TagLibrary getTagLibrary() {
return tagLibrary;
}
-
// Utility methods.
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the extension
*/
public ConfigExtension getExtension() {
@@ -302,15 +305,20 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param extension
+ * the extension to set
*/
public void setExtension(ConfigExtension extension) {
this.extension = extension;
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the metadataComplete
*/
public boolean isMetadataComplete() {
@@ -318,8 +326,11 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param metadataComplete the metadataComplete to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param metadataComplete
+ * the metadataComplete to set
*/
public void setMetadataComplete(boolean metadataComplete) {
this.metadataComplete = metadataComplete;
@@ -336,7 +347,7 @@
try {
// TODO - lookup for equivalent element in target collection.
- // find(target, element.getKey());
+ // find(target, element.getKey());
} catch (NoSuchElementException e) {
// TODO: handle exception
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -25,9 +25,10 @@
package org.richfaces.cdk.model;
-import javax.faces.render.RenderKitFactory;
import java.util.Collection;
+import javax.faces.render.RenderKitFactory;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -40,12 +41,30 @@
private final ModelCollection<BehaviorRenderer> behaviorRenderers =
ModelCollection.<BehaviorRenderer>create();
private ClassName renderKitClass;
+
+ private Id id;
public RenderKitModel() {
}
/**
* <p class="changed_added_4_0"></p>
+ * @return the id
+ */
+ public Id getId() {
+ return this.id;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param id the id to set
+ */
+ public void setId(Id id) {
+ this.id = id;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the renderKitClass
*/
@Merge
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -128,9 +128,8 @@
protected void verifyRenderers(ComponentLibrary library) {
- for (RenderKitModel.Id renderKitId : library.getRenderKits().keySet()) {
+ for (RenderKitModel renderKit : library.getRenderKits()) {
// Check render kit name and class.
- RenderKitModel renderKit = library.getRenderKits().get(renderKitId);
for (RendererModel renderer : renderKit.getRenderers()) {
vefifyRenderer(library, renderer);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -88,7 +88,7 @@
*/
@Override
public void render() throws CdkException {
- for (RenderKitModel renderKit : library.getRenderKits().values()) {
+ for (RenderKitModel renderKit : library.getRenderKits()) {
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -69,7 +69,7 @@
if (null != unmarshal) {
ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
library.getComponents().addAll(facesConfig.getComponents());
- library.getRenderKits().putAll(facesConfig.getRenderKits());
+ library.getRenderKits().addAll(facesConfig.getRenderKits());
library.getConverters().addAll(facesConfig.getConverters());
// TODO - merge changes into library.
// library.getRenderers().addAll(unmarshal.getRenderers());
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -23,19 +23,15 @@
package org.richfaces.cdk.xmlconfig.model;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import java.lang.reflect.Method;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.Extensible;
-import org.richfaces.cdk.model.ModelElement;
import org.richfaces.cdk.util.JavaUtils;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
/**
* <p class="changed_added_4_0"></p>
*
@@ -69,6 +65,7 @@
*
* @throws org.richfaces.cdk.CdkException
*/
+ @SuppressWarnings("unchecked")
public Bean createBean(Class<? extends Bean> beanClass, Model model) throws
CdkException {
try {
Bean bean = beanClass.newInstance();
@@ -87,10 +84,20 @@
}
}
+ /**
+ * <p class="changed_added_4_0">Template method to copy non bean
attributes.</p>
+ * @param model
+ * @param bean
+ */
protected void postMarshal(Model model, Bean bean) {
// template method to perform additional conversations
}
+ /**
+ * <p class="changed_added_4_0">Returns concrete bean
class.</p>
+ * @param model
+ * @return
+ */
protected abstract Class<? extends Bean> getBeanClass(Model model);
@Override
@@ -100,6 +107,7 @@
return model;
}
+ @SuppressWarnings("unchecked")
protected <D, E extends ConfigExtension> E createExtension(D destination)
throws NoSuchMethodException, InstantiationException, IllegalAccessException {
@@ -107,7 +115,7 @@
return ((Class<E>) method.getReturnType()).newInstance();
}
- private void copyExtensions(Extensible source, Extensible<ConfigExtension>
destination, Boolean fromModel) {
+ private void copyExtensions(Extensible<ConfigExtension> source,
Extensible<ConfigExtension> destination, Boolean fromModel) {
try {
ConfigExtension sourceExtension = source.getExtension();
@@ -134,6 +142,7 @@
}
}
+ @SuppressWarnings("unchecked")
protected Model createModelElement(Class<? extends Model> modelClass, Bean
adapter) {
try {
@@ -151,45 +160,20 @@
}
}
+ /**
+ * <p class="changed_added_4_0">Template method to copy non bean
attributes</p>
+ * @param bean
+ * @param model
+ */
protected void postUnmarshal(Bean bean, Model model) {
// template method to perform additional conversations
}
- protected abstract Class<? extends Model> getModelClass(Bean bean);
-
/**
- *
- * @param map
- * @param adapter
- *
+ * <p class="changed_added_4_0">Returns concrete model
class</p>
+ * @param bean
* @return
- *
- * */
- protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>
& Extensible> List<B> marshalMap(Map<K, M> map,
- AdapterBase<B, M> adapter) throws CdkException {
-
- List<B> result = Lists.newArrayList();
- if (null != map && map.size() > 0) {
- for (Map.Entry<K, M> entry : map.entrySet()) {
- B bean = adapter.marshal(entry.getValue());
- bean.setKey(entry.getKey());
- result.add(bean);
- }
- }
- return result;
- }
+ */
+ protected abstract Class<? extends Model> getModelClass(Bean bean);
- protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>
& Extensible> Map<K, M> unmarshalMap(
- List<B> list, AdapterBase<B, M> adapter) throws CdkException {
-
- Map<K, M> map = Maps.newHashMap();
- if (null != list && list.size() > 0) {
- for (B bean : list) {
- M model = adapter.unmarshal(bean);
- map.put(bean.getKey(), model);
- }
- }
- return map;
- }
-
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.xmlconfig.model;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.RenderKitModel;
/**
* <p class="changed_added_4_0"></p>
@@ -33,7 +32,6 @@
*/
public class FacesConfigAdapter extends AdapterBase<FacesConfigBean,
ComponentLibrary> {
- private static final RenderKitAdapter ADAPTER = new RenderKitAdapter();
@Override
protected Class<? extends FacesConfigBean> getBeanClass(ComponentLibrary model)
{
@@ -45,13 +43,4 @@
return ComponentLibrary.class;
}
- @Override
- protected void postMarshal(ComponentLibrary model, FacesConfigBean bean) {
- bean.setRenderKits(marshalMap(model.getRenderKits(), ADAPTER));
- }
-
- @Override
- protected void postUnmarshal(FacesConfigBean bean, ComponentLibrary model) {
- model.getRenderKits().putAll(this.<RenderKitModel.Id, RenderKitBean,
RenderKitModel>unmarshalMap(bean.getRenderKits(), ADAPTER));
- }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -38,6 +38,7 @@
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.Extensible;
+import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.ValidatorModel;
import com.google.common.collect.Lists;
@@ -55,7 +56,8 @@
private List<ComponentModel> components = Lists.newArrayList();
@XmlElement(name = "render-kit", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- private List<RenderKitBean> renderKits = Lists.newArrayList();
+ @XmlJavaTypeAdapter(RenderKitAdapter.class)
+ private List<RenderKitModel> renderKits = Lists.newArrayList();
@XmlElement(name = "converter", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ConverterAdapter.class)
@@ -135,7 +137,7 @@
*
* @return the renderKits
*/
- public List<RenderKitBean> getRenderKits() {
+ public List<RenderKitModel> getRenderKits() {
return renderKits;
}
@@ -144,7 +146,7 @@
*
* @param renderKits the renderKits to set
*/
- public void setRenderKits(List<RenderKitBean> renderKits) {
+ public void setRenderKits(List<RenderKitModel> renderKits) {
this.renderKits = renderKits;
}
Deleted:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/MapEntry.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/MapEntry.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/MapEntry.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -1,37 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * 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.richfaces.cdk.xmlconfig.model;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface MapEntry<T> {
-
- public T getKey();
-
- public void setKey(T key);
-
-}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -34,7 +34,6 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.RenderKitModel.Id;
@@ -48,8 +47,8 @@
@XmlType(
name = "faces-config-render-kitType",
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder = {"key", "renderkitClass", "renderers",
"behaviorRenderers", "extension"})
-public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension>
implements MapEntry<RenderKitModel.Id> {
+ propOrder = {"id", "renderkitClass", "renderers",
"behaviorRenderers", "extension"})
+public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension>
{
private List<RendererModel> renderers = Lists.newArrayList();
private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
@@ -57,15 +56,13 @@
private Id key = new Id(RenderKitFactory.HTML_BASIC_RENDER_KIT);
- @Override
@XmlElement(name = "render-kit-id", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(RenderKitIdAdapter.class)
- public Id getKey() {
+ public Id getId() {
return key;
}
- @Override
- public void setKey(Id key) {
+ public void setId(Id key) {
this.key = key;
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -93,10 +93,7 @@
private FileManager templatesSource;
private RenderKitModel getRenderkitFromModel(String renderkitId) {
- Map<Id, RenderKitModel> renderKits = library.getRenderKits();
- assertNotNull(renderKits);
-
- RenderKitModel renderKit = renderKits.get(new RenderKitModel.Id(renderkitId));
+ RenderKitModel renderKit = library.getRenderKit(new
RenderKitModel.Id(renderkitId));
assertNotNull(renderKit);
return renderKit;
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-05-10
19:40:53 UTC (rev 16979)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-05-10
23:48:39 UTC (rev 16980)
@@ -120,13 +120,13 @@
FacesConfigBean library =
jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/renderkit.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
- List<RenderKitBean> renderKits = library.getRenderKits();
+ List<RenderKitModel> renderKits = library.getRenderKits();
assertEquals(2, renderKits.size());
- RenderKitBean renderKit = renderKits.get(0);
- assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKit.getKey());
+ RenderKitModel renderKit = renderKits.get(0);
+ assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKit.getId());
assertEquals(1, renderKit.getRenderers().size());
- assertEquals(new RenderKitModel.Id("RDFa"),
renderKits.get(1).getKey());
+ assertEquals(new RenderKitModel.Id("RDFa"),
renderKits.get(1).getId());
}
}