Author: alexsmirnov
Date: 2009-08-12 20:50:29 -0400 (Wed, 12 Aug 2009)
New Revision: 15164
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.dia
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.png
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.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/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
Log:
Change classes structure according to
http://www.jboss.org/community/wiki/CdkGeneratorArchitecture
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,56 @@
+/*
+ * $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.builder.templates;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class RendererTemplateParser implements ModelBuilder {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -24,9 +24,12 @@
package org.richfaces.cdk;
import java.io.File;
+import java.util.Map;
import org.richfaces.cdk.model.ComponentLibrary;
+import com.google.common.collect.Maps;
+
/**
* <p class="changed_added_4_0">Base CDK context class. Particular build
tool ( Ant, Maven ) should extend that class with
* tool-specific methods.</p>
@@ -44,6 +47,8 @@
private File resourceOutput;
private NamingConventions namingConventions;
+
+ private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
/**
* <p class="changed_added_4_0"></p>
@@ -124,6 +129,15 @@
public void setNamingConventions(NamingConventions namingConventions) {
this.namingConventions = namingConventions;
}
+
+ public void addSources(SourceType type,Iterable<File> files) {
+ sources.put(type, files);
+ }
+ @Override
+ public Iterable<File> getSources(SourceType type) {
+ return sources.get(type);
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -13,6 +13,15 @@
*
*/
public interface CdkContext {
+
+ /**
+ * <p class="changed_added_4_0">Type of source files e.g. Java classes,
faces-configs, renderer templates</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ interface SourceType {
+ String getName();
+ }
/**
* <p class="changed_added_4_0">
@@ -55,5 +64,12 @@
* @return
*/
public NamingConventions getNamingConventions();
+
+ /**
+ * <p class="changed_added_4_0">Get all sources for given
type.</p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSources(SourceType type);
}
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,43 @@
+/*
+ * $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;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CdkWriter {
+
+ interface OutputType {
+ String getName();
+ }
+
+ public void init(CdkContext context);
+
+ public void render(ComponentLibrary library) throws CdkException;
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,48 @@
+/*
+ * $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;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0">Interface for {@link ComponentLibrary}
model builder.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface ModelBuilder {
+
+ /**
+ * <p class="changed_added_4_0">Initialize builder.</p>
+ * @param context
+ */
+ public void init(CdkContext context);
+
+ /**
+ * <p class="changed_added_4_0">Build library model.</p>
+ * @return
+ * @throws CdkException
+ */
+ public ComponentLibrary build() throws CdkException;
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,49 @@
+/*
+ * $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;
+
+import org.richfaces.cdk.CdkWriter.OutputType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public enum StandardOutputs implements OutputType {
+ COMPONENT_CLASSES,
+ RENDERER_CLASSES,
+ EVENT_LISTENER_CLASSES,
+ EVENT_SOURCE_CLASSES,
+ TAG_HANDLER_CLASSES,
+ FACES_CONFIG,
+ TAG_LIBRARY,
+ JBDS_RENDERERS,
+ XML_SCHEMA;
+
+ @Override
+ public String getName() {
+ return name();
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,44 @@
+/*
+ * $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;
+
+import org.richfaces.cdk.CdkContext.SourceType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public enum StandardSources implements SourceType {
+
+ JAVA_SOURCES,
+ FACES_CONFIGS,
+ RENDERER_TEMPLATES;
+
+ @Override
+ public String getName() {
+ return name();
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -43,8 +43,12 @@
import javax.tools.JavaCompiler.CompilationTask;
import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
import com.google.common.collect.Lists;
@@ -56,7 +60,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class CdkCompiler {
+public class CdkCompiler implements ModelBuilder {
private static final Logger log = LoggerFactory.getLogger();
@@ -68,13 +72,17 @@
private Locale locale;
+ private CdkContext context;
+
/**
* <p class="changed_added_4_0">Builder method that creates and
initializes compiler instance.
* That instance can be reused for consecuence processing.</p>
* @param context
* @return
*/
- public static CdkCompiler create(CdkContext context) {
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
CdkCompiler compiler = new CdkCompiler();
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
compiler.setJavaCompiler(javaCompiler);
@@ -132,16 +140,22 @@
context.getLoader());
fileManager.setJavaSourceDirectory(context.getJavaSource());
compiler.setFileManager(fileManager);
- return compiler;
}
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ ComponentLibrary library = new ComponentLibrary();
+ ComponentProcessor processor = new ComponentProcessor(context,library);
+ process(context.getSources(StandardSources.JAVA_SOURCES),processor);
+ return library;
+ }
/**
* <p class="changed_added_4_0">That method process source files and
call appropriate annotation processors</p>
* @param sources
* @param processors
* @throws AptException
*/
- public void process(Iterable<File> sources, Processor...processors) throws
AptException {
+ protected void process(Iterable<File> sources, Processor...processors) throws
AptException {
final List<String> messages = Lists.newArrayList();
DiagnosticListener<JavaFileObject> listener = new
DiagnosticListener<JavaFileObject>() {
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 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -35,7 +35,9 @@
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
@@ -83,7 +85,6 @@
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + getOuterType().hashCode();
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@@ -102,8 +103,6 @@
if (getClass() != obj.getClass())
return false;
BeanProperty other = (BeanProperty) obj;
- if (!getOuterType().equals(other.getOuterType()))
- return false;
if (name == null) {
if (other.name != null)
return false;
@@ -132,10 +131,23 @@
return name;
}
- private CdkProcessor getOuterType() {
- return CdkProcessor.this;
+ /**
+ * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean
property element.</p>
+ * @return
+ */
+ public String getDocComment() {
+ return processingEnv.getElementUtils().getDocComment(element);
}
+ public String getTypeName() {
+ return type.toString();
+ }
+
+ public String getTypeParameters() {
+ // TODO - analyze type parameters for getter/setter methods.
+ return null;
+ }
+
}
/**
@@ -212,18 +224,18 @@
protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(
Class<? extends Annotation> annotation, TypeElement type) {
Set<BeanProperty> properties = Sets.newHashSet();
- List<ExecutableElement> methodsIn = ElementFilter
- .methodsIn(this.processingEnv.getElementUtils().getAllMembers(
- type));
+ List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(
+ type);
// Get all methods and fields annotated by annotation.
- for (ExecutableElement executableElement : methodsIn) {
- if (null != executableElement.getAnnotation(annotation)) {
+ for (Element childElement : members) {
+ if (null != childElement.getAnnotation(annotation)) {
// Have an annotation, infer property name.
String name;
TypeMirror propertyType;
- if (ElementKind.METHOD.equals(executableElement.getKind())) {
- propertyType = executableElement.getReturnType();
- List<? extends VariableElement> parameters = executableElement
+ if (ElementKind.METHOD.equals(childElement.getKind())) {
+ ExecutableElement method = (ExecutableElement) childElement;
+ propertyType = method.getReturnType();
+ List<? extends VariableElement> parameters = method
.getParameters();
if (TypeKind.VOID.equals(propertyType.getKind())
&& 1 == parameters.size()) {
@@ -236,24 +248,25 @@
}
try {
name = PropertyUtils
- .methodToName(executableElement.getSimpleName()
+ .methodToName(childElement.getSimpleName()
.toString());
} catch (InvalidNameException e) {
// TODO Invalid method name for a bean property, throw
// exception ?
continue;
}
-
+ // TODO - Get method type parameters.
+ // List<? extends TypeParameterElement> typeParameters =
method.getTypeParameters();
} else if (ElementKind.FIELD
- .equals(executableElement.getKind())) {
- name = executableElement.getSimpleName().toString();
- propertyType = executableElement.asType();
+ .equals(childElement.getKind())) {
+ name = childElement.getSimpleName().toString();
+ propertyType = childElement.asType();
} else {
continue;
}
BeanProperty property = new BeanProperty(name);
property.type = propertyType;
- property.element = executableElement;
+ property.element = childElement;
// TODO - merge properties with same name ?
properties.add(property);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -34,10 +34,13 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.annotations.Family;
+import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.Component.Type;
import org.richfaces.cdk.util.Strings;
@@ -75,16 +78,33 @@
try {
// Process class-level annotations.
// Calculate type for base UI component class.
+ // TODO - encpsulate that into simple utility classes call.
Component componentAnnotation = component.getAnnotation(Component.class);
String baseClassName = component.getQualifiedName().toString();
String componentType =
namingUtils.inferComponentType(componentAnnotation.type(),baseClassName);
String uiComponentClass = namingUtils.inferUIComponentClass(componentType,
componentAnnotation.className(), baseClassName,
component.getModifiers().contains(Modifier.ABSTRACT));
+ // Create/get component instance.
org.richfaces.cdk.model.Component componentModel = library
.createComponent(componentType, uiComponentClass, baseClassName);
// Component Family.
Family family = component.getAnnotation(Family.class);
componentModel.setFamily(Strings.isEmpty(family.value())?componentType:family.value());
+ // JavaDoc comments
+ componentModel.setDescription(this.processingEnv.getElementUtils().getDocComment(component));
+ // TODO - process Events attribute.
+ // TODO - renderers, ....
// Process attributes.
+ Set<BeanProperty> properties = getBeanPropertiesAnnotatedWith(Attribute.class,
component);
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ Property atribute = componentModel.addAtribute(beanProperty.getName());
+ // Documentation
+ atribute.setDescription(beanProperty.getDocComment());
+ // Type.
+ atribute.setType(new ClassDescription(beanProperty.getTypeName()));
+ // Flags.
+ }
+ // TODO - Process standard information for parent classes and intrfaces.
} catch (InvalidNameException e) {
// rise error and continue.
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
e.getMessage(), component);
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,56 @@
+/*
+ * $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.generate.java;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentClassGenerator implements CdkWriter {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -0,0 +1,56 @@
+/*
+ * $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;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FacesConfigParser implements ModelBuilder {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.dia
===================================================================
(Binary files differ)
Property changes on:
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.dia
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.png
===================================================================
(Binary files differ)
Property changes on:
root/cdk/trunk/plugins/generator/src/main/javadoc/org/richfaces/cdk/MVC.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -54,10 +54,12 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.apt.CdkProcessor.BeanProperty;
import org.richfaces.cdk.model.ComponentLibrary;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
/**
* <p class="changed_added_4_0">
@@ -167,7 +169,8 @@
expect(processor.getSupportedSourceVersion()).andReturn(
SourceVersion.RELEASE_6);
replay(processor);
- CdkCompiler compiler = CdkCompiler.create(cdkContext);
+ CdkCompiler compiler = new CdkCompiler();
+ compiler.init(cdkContext);
compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
verify(cdkContext, processor);
}
@@ -206,7 +209,8 @@
expect(processor.getSupportedSourceVersion()).andReturn(
SourceVersion.RELEASE_6);
replay(processor);
- CdkCompiler compiler = CdkCompiler.create(cdkContext);
+ CdkCompiler compiler = new CdkCompiler();
+ compiler.init(cdkContext);
compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA),
getJavaFile(CLASS_JAVA)), processor);
verify(cdkContext, processor);
@@ -248,7 +252,8 @@
// ComponentLibrary library = new
// ComponentLibrary("org.richfaces.cdk.test");
// processor.library = library;
- CdkCompiler compiler = CdkCompiler.create(cdkContext);
+ CdkCompiler compiler = new CdkCompiler();
+ compiler.init(cdkContext);
compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
processor);
verify(cdkContext);
@@ -281,8 +286,25 @@
TypeElement typeElement = getClassesAnnotatedWith(
Component.class, roundEnv).iterator().next();
Set<BeanProperty> beanProperties =
getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
- assertEquals(1, beanProperties.size());
- assertEquals("testValue", beanProperties.iterator().next().getName());
+ assertEquals(3, beanProperties.size());
+ BeanProperty property = Iterables.get(beanProperties,2);
+ assertEquals("foo", property.getName());
+ assertEquals("int", property.getTypeName());
+ assertNull(property.getDocComment());
+ assertNull(property.getTypeParameters());
+
+ property = Iterables.get(beanProperties,1);
+ assertEquals("testValue", property.getName());
+ assertEquals("java.util.List<java.lang.String>",
property.getTypeName());
+ assertEquals(" Test Attribute\n", property.getDocComment());
+ assertNull(property.getTypeParameters());
+
+ property = Iterables.get(beanProperties,0);
+ assertEquals("barValue", property.getName());
+ assertEquals("java.util.List<M>", property.getTypeName());
+ assertEquals(" Bar Attribute\n", property.getDocComment());
+// assertEquals("<M>" ,property.getTypeParameters());
+
numOfComponents++;
}
return true;
@@ -291,7 +313,8 @@
// ComponentLibrary library = new
// ComponentLibrary("org.richfaces.cdk.test");
// processor.library = library;
- CdkCompiler compiler = CdkCompiler.create(cdkContext);
+ CdkCompiler compiler = new CdkCompiler();
+ compiler.init(cdkContext);
compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)),
processor);
verify(cdkContext);
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-08-13
00:49:45 UTC (rev 15163)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-08-13
00:50:29 UTC (rev 15164)
@@ -26,6 +26,7 @@
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
+import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
@@ -34,16 +35,22 @@
* @author asmirnov(a)exadel.com
*
*/
-(a)Component(type="org.richfaces.cdk.test.TestComponent",family="org.richfaces.Family")
+(a)Component(type="org.richfaces.cdk.test.TestComponent")
public abstract class AbstractTestComponent extends UIComponent implements
ValueHolder {
+ @Attribute
+ private int foo;
+
/**
- *
- * <p class="changed_added_4_0"></p>
- * @return
+ * Test Attribute
*/
@Attribute
- public abstract Object getTestValue();
+ public abstract List<String> getTestValue();
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract <M> void setBarValue(List<M> bar);
}