Author: alexsmirnov
Date: 2010-05-18 20:30:44 -0400 (Tue, 18 May 2010)
New Revision: 17111
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/package-info.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.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/AptModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.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/apt/processors/RendererProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
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/TagLibrary.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -37,18 +37,50 @@
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PACKAGE)
public @interface TagLibrary {
- public String tlibVersion();
+
+ /**
+ * <p class="changed_added_4_0">Library URI, the same used for JSP
and Facelets.</p>
+ * @return
+ */
+ public String uri();
- public String validatorClass();
+ /**
+ * <p class="changed_added_4_0">Implementation version of the
generated taglib.</p>
+ * @return
+ */
+ public String tlibVersion() default "";
- public String displayName();
+ /**
+ * <p class="changed_added_4_0">JSP taglib validator. TODO - ?
extends Validator ?</p>
+ * @return
+ */
+ public Class<?> validatorClass() default NONE.class;
- public String jspVersion();
+ /**
+ * <p class="changed_added_4_0">Servlet ... listener used by JSP
library. TODO - ? extends {@link EventListener} ?</p>
+ * @return
+ */
+ public Class<?> listenerClass() default NONE.class;
- public String listenerClass();
+ /**
+ * <p class="changed_added_4_0">Library description to use by
IDE</p>
+ * @return
+ */
+ public String displayName() default "";
+ /**
+ * <p class="changed_added_4_0">Java Server Pages version for
generated tld.</p>
+ * @return
+ */
+ public String jspVersion() default "2.0";
+
+
+ /**
+ * <p class="changed_added_4_0">Library short name ( default prefix
)</p>
+ * @return
+ */
public String shortName();
- public String uri();
+ public static final class NONE {}
}
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-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -24,6 +24,7 @@
package org.richfaces.cdk;
import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.RendererModel;
@@ -106,6 +107,15 @@
public String inferRendererBaseName(RendererModel.Type type);
public FacesId inferBehaviorType(ClassName targetClass);
+
public ClassName inferBehaviorClass(FacesId id);
+
+
+ public String inferTaglibUri(ComponentLibrary library);
+
+
+ public String inferTaglibName(String uri);
+
+
}
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-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -1,6 +1,7 @@
package org.richfaces.cdk;
import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Name;
@@ -8,6 +9,7 @@
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.util.Strings;
+import java.net.URI;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -26,7 +28,7 @@
private static final String[] COMPONENT_PREFIXES = { UI, ABSTRACT };
// TODO - inject base name.
- private String baseName;
+ private String baseName ;//= "org.richfaces";
public RichFacesConventions() {
}
@@ -239,4 +241,33 @@
return new FacesId(name.toString());
}
+
+ @Override
+ public String inferTaglibName(String uri) throws InvalidNameException {
+ try {
+ URI taglibUri = URI.create(uri);
+ String path = taglibUri.getPath();
+ if(null != path){
+ int lastIndexOfPathSeparator = path.lastIndexOf('/');
+ if(lastIndexOfPathSeparator>=0){
+ path = path.substring(lastIndexOfPathSeparator+1);
+ }
+ int indexOfDot = path.indexOf('.');
+ if(indexOfDot>0){
+ path = path.substring(0, indexOfDot);
+ }
+ return path;
+ } else {
+ throw new InvalidNameException("Invalid taglib uri, no path defined
" + uri );
+ }
+ } catch (IllegalArgumentException e) {
+ throw new InvalidNameException("Invalid taglib uri " + uri + "
, " + e.getMessage());
+ }
+ }
+
+ @Override
+ public String inferTaglibUri(ComponentLibrary library) {
+ // TODO infer name from library base names.
+ return "http://richfaces.org/a4j";
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -36,6 +36,7 @@
import org.richfaces.cdk.apt.processors.DescriptionProcessor;
import org.richfaces.cdk.apt.processors.DescriptionProcessorImpl;
import org.richfaces.cdk.apt.processors.RendererProcessor;
+import org.richfaces.cdk.apt.processors.TagLibProcessor;
import org.richfaces.cdk.apt.processors.ValidatorProcessor;
import javax.annotation.processing.Processor;
@@ -59,6 +60,7 @@
setBinder.addBinding().to(RendererProcessor.class);
setBinder.addBinding().to(ConverterProcessor.class);
setBinder.addBinding().to(ValidatorProcessor.class);
+ setBinder.addBinding().to(TagLibProcessor.class);
bind(Processor.class).to(CdkProcessor.class);
bind(AttributesProcessor.class).to(AttributesProcessorImpl.class);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -96,6 +96,7 @@
for (ModelBuilder builder : builders) {
builder.build();
}
+ // validator should be called even if previvous phases finish with errors, to
collect all possible problems.
validator.verify(library);
} else if (0 == log.getErrorCount()) {
// processing over, generate files.
@@ -109,10 +110,10 @@
try {
Set<? extends Element> rootElements = environment.getRootElements();
for (Element element : rootElements) {
- if (ElementKind.CLASS.equals(element.getKind())
+ if ((ElementKind.CLASS.equals(element.getKind()) ||
ElementKind.PACKAGE.equals(element.getKind()))
&& null !=
element.getAnnotation(processor.getProcessedAnnotation())){
try {
- processor.process((TypeElement) element, library);
+ processor.process(element, library);
} catch (CdkProcessingException e) {
sendError(element, e);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -26,6 +26,7 @@
import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
@@ -43,16 +44,16 @@
public class BehaviorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
@Override
- public void process(TypeElement element, ComponentLibrary library) throws
CdkProcessingException {
+ public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
BehaviorModel behaviorModel = new BehaviorModel(new FacesId(behavior.id()));
- setClassNames(element, behaviorModel, behavior.generate());
+ setClassNames((TypeElement) element, behaviorModel, behavior.generate());
setTagInfo(behavior.tag(), behaviorModel);
AttributesProcessor attributesProcessor = getAttributeProcessor();
attributesProcessor.processXmlFragment(behaviorModel, behavior.attributes());
- attributesProcessor.processType(behaviorModel, element);
+ attributesProcessor.processType(behaviorModel, (TypeElement) element);
setDescription(behaviorModel, behavior.description(), getDocComment(element));
library.getBehaviors().add(behaviorModel);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -23,12 +23,13 @@
package org.richfaces.cdk.apt.processors;
+import java.lang.annotation.Annotation;
+
+import javax.lang.model.element.Element;
+
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.model.ComponentLibrary;
-import javax.lang.model.element.TypeElement;
-import java.lang.annotation.Annotation;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -43,7 +44,7 @@
* @param library TODO
* @throws CdkProcessingException
*/
- public void process(TypeElement element, ComponentLibrary library) throws
CdkProcessingException;
+ public void process(Element element, ComponentLibrary library) throws
CdkProcessingException;
public Class<? extends Annotation> getProcessedAnnotation();
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Set;
+import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
@@ -71,7 +72,7 @@
@Inject
private RendererProcessor rendererProcessor;
- public void process(TypeElement componentElement, ComponentLibrary library) {
+ public void process(Element componentElement, ComponentLibrary library) {
final JsfComponent annotation =
componentElement.getAnnotation(JsfComponent.class);
if (annotation == null) {
return;
@@ -81,8 +82,8 @@
ComponentModel component = new ComponentModel();
// Should that component be generated ?
- setClassNames(componentElement, component, annotation.generate());
- setComponentProperties(componentElement, component, annotation);
+ setClassNames((TypeElement) componentElement, component, annotation.generate());
+ setComponentProperties((TypeElement) componentElement, component, annotation);
library.getComponents().add(component);
// Process the second level annotations.
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -21,6 +21,13 @@
package org.richfaces.cdk.apt.processors;
+import java.lang.annotation.Annotation;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfConverter;
import org.richfaces.cdk.model.ClassName;
@@ -28,11 +35,6 @@
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.FacesId;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.MirroredTypeException;
-import java.lang.annotation.Annotation;
-
/**
* @author akolonitsky
* @since Jan 4, 2010
@@ -41,7 +43,7 @@
public class ConverterProcessor extends ProcessorBase implements CdkAnnotationProcessor
{
@Override
- public void process(TypeElement element, ComponentLibrary library) throws
CdkProcessingException {
+ public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
JsfConverter converter = element.getAnnotation(JsfConverter.class);
ConverterModel converterModel = new ConverterModel();
@@ -63,8 +65,8 @@
AttributesProcessor attributesProcessor = getAttributeProcessor();
attributesProcessor.processXmlFragment(converterModel, converter.attributes());
- attributesProcessor.processType(converterModel, element);
- setClassNames(element, converterModel, converter.generate());
+ attributesProcessor.processType(converterModel, (TypeElement) element);
+ setClassNames((TypeElement) element, converterModel, converter.generate());
setTagInfo(converter.tag(), converterModel);
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-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -11,6 +11,7 @@
import org.richfaces.cdk.model.TagModel;
import org.richfaces.cdk.util.Strings;
+import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
@@ -69,8 +70,8 @@
}
- protected String getDocComment(TypeElement componentElement) {
- return null != componentElement ?
getSourceUtils().getDocComment(componentElement) : null;
+ protected String getDocComment(Element element) {
+ return null != element ? getSourceUtils().getDocComment(element) : null;
}
/**
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -27,6 +27,7 @@
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.faces.render.RenderKitFactory;
+import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
@@ -61,10 +62,10 @@
@Inject
private RendererTemplateParser templateParser;
- public void process(TypeElement rendererElement, ComponentLibrary library) {
+ public void process(Element rendererElement, ComponentLibrary library) {
JsfRenderer annotation = rendererElement.getAnnotation(JsfRenderer.class);
- RendererModel rendererModel = process(rendererElement, annotation, library);
+ RendererModel rendererModel = process((TypeElement) rendererElement, annotation,
library);
addToRenderKit(annotation, library, rendererModel);
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -0,0 +1,74 @@
+/*
+ * $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.apt.processors;
+
+import java.lang.annotation.Annotation;
+
+import javax.lang.model.element.Element;
+
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.TagLibrary;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Taglib;
+import org.richfaces.cdk.util.Strings;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TagLibProcessor implements CdkAnnotationProcessor {
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#getProcessedAnnotation()
+ */
+ @Override
+ public Class<? extends Annotation> getProcessedAnnotation() {
+ return TagLibrary.class;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#process(javax.lang.model.element.Element,
org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
+ TagLibrary tagLibrary = element.getAnnotation(TagLibrary.class);
+ Taglib taglibModel = new Taglib();
+ taglibModel.setUri(tagLibrary.uri());
+ String shortName = tagLibrary.shortName();
+ if(!Strings.isEmpty(shortName)){
+ taglibModel.setShortName(shortName);
+ }
+ String displayName = tagLibrary.displayName();
+ if(!Strings.isEmpty(displayName)){
+ taglibModel.setDisplayName(displayName);
+ }
+ String tlibVersion = tagLibrary.tlibVersion();
+ if(!Strings.isEmpty(tlibVersion)){
+ taglibModel.setTlibVersion(tlibVersion);
+ }
+ library.setTaglib(taglibModel);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -28,6 +28,7 @@
import org.richfaces.cdk.model.ValidatorModel;
import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.lang.annotation.Annotation;
@@ -39,11 +40,11 @@
public class ValidatorProcessor extends ProcessorBase implements CdkAnnotationProcessor
{
@Override
- public void process(TypeElement element, ComponentLibrary library) throws
CdkProcessingException {
+ public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
JsfValidator validator = element.getAnnotation(JsfValidator.class);
ValidatorModel validatorModel = new
ValidatorModel(FacesId.parseId(validator.id()));
- setClassNames(element, validatorModel, validator.generate());
+ setClassNames((TypeElement) element, validatorModel, validator.generate());
setDescription(validatorModel, validator.description(), getDocComment(element));
setTagInfo(validator.tag(), validatorModel);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -39,6 +39,7 @@
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.TagModel;
import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.model.RendererModel.Type;
import java.util.List;
@@ -58,10 +59,8 @@
private ComponentLibrary componentLibrary;
- private String id;
- public TaglibGeneratorVisitor(String id) {
- this.id = id;
+ public TaglibGeneratorVisitor() {
}
public Document getDocument() {
@@ -80,9 +79,9 @@
faceletTaglib.addAttribute("xsi:schemaLocation",
"http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
faceletTaglib.addAttribute("version", "2.0");
- faceletTaglib.addAttribute("id", id); // TODO do it as param
+ faceletTaglib.addAttribute("id",
componentLibrary.getTaglib().getShortName());
-
faceletTaglib.addElement("namespace").addText("http://rich...
+ id); // TODO do it as param
+
faceletTaglib.addElement("namespace").addText(componentLibrary.getTaglib().getUri());
}
@Override
@@ -95,20 +94,32 @@
}
Element tag = createTag(tagModel.getName());
+ // TODO - investigate proper usage of the <handler-class> element.
+ // Most libraries use <handler-class> INSTEAD of <component>
Element component = tag.addElement(COMPONENT);
- component.addElement(COMPONENT_TYPE).addText(model.getType().getType());
- RendererModel renderer = componentLibrary.getRenderer(model.getFamily(),
model.getType().getType());
- if (null != renderer) {
-
component.addElement(RENDERER_TYPE).addText(renderer.getType().getType());
+ component.addElement(COMPONENT_TYPE).addText(model.getId().getType());
+ Type rendererType = model.getRendererType();
+// RendererModel renderer = componentLibrary.getRenderer(model.getFamily(),
model.getId().getType());
+ if (null != rendererType) {
+ component.addElement(RENDERER_TYPE).addText(rendererType.getType());
}
addTagHandler(component, tagModel);
appendAttributs(tag, model);
}
}
- private void addTagHandler(Element parent, TagModel tag) {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param parent DOM element for which <handler-class> element should
be appended.
+ * @param tag model.
+ * @return true is explicit handler class definition was generated.
+ */
+ private boolean addTagHandler(Element parent, TagModel tag) {
if (tag != null && tag.getTargetClass() != null) {
parent.addElement(HANDLER_CLASS).addText(tag.getTargetClass().toString());
+ return true;
+ } else {
+ return false;
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -55,7 +55,7 @@
@Override
public void render() throws CdkException {
- TaglibGeneratorVisitor visitor = new
TaglibGeneratorVisitor(generator.getNamespace());
+ TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
library.accept(visitor);
Document document = visitor.getDocument();
@@ -77,8 +77,7 @@
protected Writer getOutput() throws CdkException {
try {
- // TODO - use short name from the library.
- return output.createOutput("META-INF/" + generator.getNamespace() +
".taglib.xml", library.lastModified());
+ return output.createOutput("META-INF/" +
library.getTaglib().getShortName() + ".taglib.xml", library.lastModified());
} catch (IOException e) {
throw new CdkException(e);
}
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-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -41,6 +41,7 @@
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.TagModel;
+import org.richfaces.cdk.model.Taglib;
import org.richfaces.cdk.util.Strings;
import java.util.Collection;
@@ -108,8 +109,32 @@
verifyComponents(library);
verifyBehaviors(library);
verifyRenderers(library);
+ verifyTaglib(library);
}
+ protected void verifyTaglib(ComponentLibrary library) {
+ Taglib taglib = library.getTaglib();
+ if(null == taglib){
+ // Oops, create taglib model
+ taglib = new Taglib();
+ library.setTaglib(taglib);
+ }
+ // Verify URI
+ String uri = taglib.getUri();
+ if(null == uri){
+ // infer default value.
+ uri = namingConventions.inferTaglibUri(library);
+ taglib.setUri(uri);
+// log.error("No uri defined for taglib");
+ }
+ String shortName = taglib.getShortName();
+ if(null == shortName){
+ shortName = namingConventions.inferTaglibName(uri);
+ taglib.setShortName(shortName);
+// log.error("No short defined for taglib");
+ }
+ }
+
/**
* <p class="changed_added_4_0">
* Verify all behaviors in the library.
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-05-18
21:48:55 UTC (rev 17110)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.model.Taglib;
import org.richfaces.cdk.model.ValidatorModel;
import java.util.Set;
@@ -55,8 +56,11 @@
ComponentLibrary library = new ComponentLibrary();
library.getValidators().add(validator);
-
- TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor("a4j");
+ Taglib taglib = new Taglib();
+ taglib.setShortName("a4j");
+ taglib.setUri("http://foo.bar/a4j");
+ library.setTaglib(taglib);
+ TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
library.accept(visitor);
// visitor.generate();
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml 2010-05-18
21:48:55 UTC (rev 17110)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml 2010-05-19
00:30:44 UTC (rev 17111)
@@ -50,7 +50,7 @@
</dependency>
<dependency>
<groupId>org.richfaces.commons</groupId>
- <artifactId>commons-api</artifactId>
+ <artifactId>richfaces-commons-api</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/package-info.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/package-info.java
(rev 0)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/package-info.java 2010-05-19
00:30:44 UTC (rev 17111)
@@ -0,0 +1,6 @@
+/**
+ *
+ */
+@TagLibrary(uri="http://richfaces.org/test",shortName="testLib")
+package org.richfaces.cdk.test.component;
+import org.richfaces.cdk.annotations.TagLibrary;
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain