Author: alexsmirnov
Date: 2009-08-07 20:41:50 -0400 (Fri, 07 Aug 2009)
New Revision: 15141
Added:
root/cdk/trunk/plugins/annotations/
root/cdk/trunk/plugins/annotations/pom.xml
root/cdk/trunk/plugins/annotations/src/
root/cdk/trunk/plugins/annotations/src/main/
root/cdk/trunk/plugins/annotations/src/main/java/
root/cdk/trunk/plugins/annotations/src/main/java/org/
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
root/cdk/trunk/plugins/annotations/src/test/
root/cdk/trunk/plugins/annotations/src/test/java/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/annotations/
Modified:
root/cdk/trunk/plugins/generator/pom.xml
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/main/java/org/richfaces/cdk/model/Component.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/InvalidNameException.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfComponent.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/NamingConventions.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java
root/cdk/trunk/plugins/pom.xml
Log:
extract annotations to separate project
Added: root/cdk/trunk/plugins/annotations/pom.xml
===================================================================
--- root/cdk/trunk/plugins/annotations/pom.xml (rev 0)
+++ root/cdk/trunk/plugins/annotations/pom.xml 2009-08-08 00:41:50 UTC (rev 15141)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>maven-plugins</artifactId>
+ <groupId>org.richfaces.cdk</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <description>That project contains annotations for JSF
classes</description>
+ <name>annotations</name>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ </dependencies>
+</project>
Added:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
(rev 0)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -0,0 +1,47 @@
+/*
+ * $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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.CLASS)
+(a)Target({ElementType.FIELD,ElementType.METHOD})
+@Inherited
+public @interface Attribute {
+
+ boolean hidden() default false;
+
+ boolean readOnly() default false;
+
+ String name() default "";
+}
Added:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
(rev 0)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -0,0 +1,65 @@
+/*
+ * $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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.CLASS)
+(a)Target(ElementType.TYPE)
+@Inherited
+public @interface Component {
+
+ public static final String NAME = "org.richfaces.cdk.annotations.Component";
+
+ /**
+ * <p class="changed_added_4_0">
+ * Type of the component. If this value an empty, component type will be inferred from
class name.
+ * </p>
+ *
+ * @return component type.
+ */
+ public String type() default "";
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * Name of the final component class. May be empty, in that case name will be
+ * inferred from naming conventions.
+ * </p>
+ *
+ * @return
+ */
+ public String className() default "";
+}
Added:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java
(rev 0)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Family.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -0,0 +1,53 @@
+/*
+ * $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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0">Defines family of component or
renderer.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.CLASS)
+(a)Target(ElementType.TYPE)
+@Inherited
+public @interface Family {
+
+ public static final String NAME = "org.richfaces.cdk.annotations.Family";
+
+ /**
+ * <p class="changed_added_4_0">
+ * Family of the component. If this value an empty, it will be inferred.
+ * </p>
+ *
+ * @return component family.
+ */
+ public String value() default "";
+
+}
Added:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
(rev 0)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -0,0 +1,7 @@
+/**
+ * <h1>Java annotations used by the CDK.</h1>
+ *
+ */
+package org.richfaces.cdk.annotations;
+
+
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2009-08-07 18:46:54 UTC (rev 15140)
+++ root/cdk/trunk/plugins/generator/pom.xml 2009-08-08 00:41:50 UTC (rev 15141)
@@ -26,18 +26,18 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <useManifestOnlyJar>false</useManifestOnlyJar>
+ <useManifestOnlyJar>false</useManifestOnlyJar>
<useSystemClassLoader>true</useSystemClassLoader>
</configuration>
</plugin>
- <!--
- plugin> <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId> <executions>
<execution>
- <goals> <goal>xjc</goal> </goals> </execution>
</executions>
- <configuration> <packageName>org.richfaces.cdk.model</packageName>
- </configuration> </plugin
- -->
- </plugins>
+ <!--
+ plugin> <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId> <executions>
<execution>
+ <goals> <goal>xjc</goal> </goals> </execution>
</executions>
+ <configuration> <packageName>org.richfaces.cdk.model</packageName>
+ </configuration> </plugin
+ -->
+ </plugins>
</build>
<dependencies>
<dependency>
@@ -51,6 +51,11 @@
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<!--
<dependency> <groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId> <version>2.1</version>
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-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkCompiler.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.Locale;
import javax.annotation.processing.Processor;
@@ -38,12 +39,15 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
+import javax.tools.Diagnostic.Kind;
import javax.tools.JavaCompiler.CompilationTask;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
+import com.google.common.collect.Lists;
+
/**
* <p class="changed_added_4_0">
* That class compiles files from sources and process annotations
@@ -138,14 +142,18 @@
* @throws AptException
*/
public void process(Iterable<File> sources, Processor...processors) throws
AptException {
- DiagnosticListener<JavaFileObject> listener = null /*new
DiagnosticListener<JavaFileObject>() {
+ final List<String> messages = Lists.newArrayList();
+ DiagnosticListener<JavaFileObject> listener = new
DiagnosticListener<JavaFileObject>() {
@Override
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
log.debug("LOG: " + diagnostic.getMessage(null));
+ if(Kind.ERROR.equals(diagnostic.getKind())){
+ messages.add(diagnostic.getMessage(null));
+ }
}
- }*/;
+ };
ArrayList<VirtualJavaFileObject> sourceObjects = new
ArrayList<VirtualJavaFileObject>();
for (File file : sources) {
VirtualJavaFileObject sourceObject = new VirtualJavaFileSystemObject(file);
@@ -154,7 +162,9 @@
CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener,
getOptions(), null, sourceObjects);
task.setProcessors(Arrays.asList(processors));
task.setLocale(locale);
- task.call();
+ if(!task.call()){
+ throw new AptException("Compilation error: "+messages);
+ }
}
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-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -23,43 +23,77 @@
package org.richfaces.cdk.apt;
+import java.lang.annotation.Annotation;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkContext;
+import com.google.common.collect.Sets;
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * Base class for all CDK Annotation processors. That class provides access to
+ * current CDK context and utility methods for Java source models.
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-(a)SupportedSourceVersion(SourceVersion.RELEASE_5)
public abstract class CdkProcessor extends AbstractProcessor {
-
- private final CdkContext context;
- public CdkProcessor(CdkContext context) {
+ /**
+ * <p class="changed_added_4_0">CDK context.</p>
+ */
+ protected final CdkContext context;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param context current CDK context
+ */
+ protected CdkProcessor(CdkContext context) {
super();
this.context = context;
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the context
*/
protected CdkContext getContext() {
return context;
}
-
+
@Override
public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.RELEASE_5;
+ // CDK supports Java 5 or 6 source code.
+ return SourceVersion.RELEASE_6;
}
-
+ /**
+ * <p class="changed_added_4_0">Get all classes annotated with
particular annotation.</p>
+ * @param annotation annotation class.
+ * @param round current round environment.
+ * @return {@link Set} of all classes annotated with {@code annotation} type.
+ */
+ protected Set<? extends TypeElement> getClassesAnnotatedWith(Class<? extends
Annotation> annotation,RoundEnvironment round){
+ Set<TypeElement> classes = Sets.newHashSet();
+ Set<? extends Element> annotatedWith =
round.getElementsAnnotatedWith(annotation);
+ for (Element element : annotatedWith) {
+ if (ElementKind.CLASS.equals(element.getKind())) {
+ TypeElement classElement = (TypeElement) element;
+ classes.add(classElement);
+ }
+ }
+ return classes;
+ }
}
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-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -34,6 +34,8 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.model.NamingConventions;
/**
* <p class="changed_added_4_0"></p>
@@ -61,12 +63,26 @@
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if(null != annotations && !annotations.isEmpty()){
- Set<? extends Element> annotatedComponents =
roundEnv.getElementsAnnotatedWith(Component.class);
- for (Element component : annotatedComponents) {
- Component componentAnnotation = component.getAnnotation(Component.class);
- String componentType = componentAnnotation.type();
- String componentFamily = componentAnnotation.family();
- String componentClassName = componentAnnotation.className();
+ ComponentLibrary library = getLibrary();
+ NamingConventions namingUtils = library.getNamingUtils();
+ // Process all component classes.
+ Set<? extends TypeElement> componentClasses =
getClassesAnnotatedWith(Component.class, roundEnv);
+ for (TypeElement component : componentClasses) {
+ try {
+ // Process class-level annotations.
+ // Calculate type
+ Component componentAnnotation = component.getAnnotation(Component.class);
+ String componentType =
namingUtils.inferComponentType(componentAnnotation.type(),component.getQualifiedName().toString());
+ org.richfaces.cdk.model.Component componentModel = library
+ .getComponent(componentType, true);
+ // Calculate classes.
+ String componentClassName = componentAnnotation.className();
+ // Process attributes.
+ } catch (InvalidNameException e) {
+ // rise error and continue.
+ processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR,
e.getMessage(), component);
+ continue;
+ }
}
return true;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -14,6 +14,7 @@
* @author asmirnov(a)exadel.com
*
*/
+@SuppressWarnings("serial")
public final class Component implements JsfComponent {
/**
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 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -23,101 +23,167 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.richfaces.cdk.util.Strings;
+
import com.google.common.collect.Maps;
/**
- * <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.</p>
+ * <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.
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class ComponentLibrary {
-
+public class ComponentLibrary implements Serializable {
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ */
+ private static final long serialVersionUID = -6055670836731899832L;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
final class RichFacesConventions implements NamingConventions {
+ private final String[] COMPONENT_SUFFIXES = { "Base" };
+ private final String[] COMPONENT_PREFIXES = { "UI", "Abstract" };
+
@Override
- public String getComponentType(String className) throws InvalidNameException {
+ public String inferComponentType(String explicitType, String className)
+ throws InvalidNameException {
// check parameters.
- if(null == className || className.length()==0){
- throw new IllegalArgumentException();
+ if (Strings.isEmpty(explicitType)) {
+ if (Strings.isEmpty(className)) {
+ throw new IllegalArgumentException();
+ }
+ Name name = Name.create(className);
+ // Use base library prefix.
+ name.setPrefix(getBaseName());
+ // Component type does not contain class or markup parts.
+ name.setClassifier(null);
+ name.setMarkup(null);
+ String simpleName = name.getSimpleName();
+ // Remove common prefixes.
+ for (int i = 0; i < COMPONENT_PREFIXES.length; i++) {
+ if (simpleName.startsWith(COMPONENT_PREFIXES[i])) {
+ simpleName = simpleName.substring(COMPONENT_PREFIXES[i]
+ .length());
+ break;
+ }
+ }
+ // Remove common suffixes.
+ for (int i = 0; i < COMPONENT_SUFFIXES.length; i++) {
+ if (simpleName.endsWith(COMPONENT_SUFFIXES[i])) {
+ simpleName = simpleName.substring(0, simpleName
+ .length()
+ - COMPONENT_SUFFIXES[i].length());
+ break;
+ }
+ }
+ name.setSimpleName(simpleName);
+ return name.toString();
+ } else {
+ return explicitType;
}
- Name.create(className);
- //
- return null;
}
@Override
- public String getComponentClass(String componentType) {
+ public String inferUIComponentClass(String explicitClass, String componentType) {
// TODO Auto-generated method stub
return null;
}
-
+
}
+
/**
- * <p class="changed_added_4_0">JSF components in that
library</p>
- */
- private final Map<Component.Type,Component> components = Maps.newHashMap();
-
- private final Collection<Component> componentsSet =
Collections.unmodifiableCollection(components.values());
+ * <p class="changed_added_4_0">
+ * JSF components in that library
+ * </p>
+ */
+ private final Map<Component.Type, Component> components = Maps.newHashMap();
+ private final Collection<Component> componentsSet = Collections
+ .unmodifiableCollection(components.values());
+
/**
- * <p class="changed_added_4_0">JSF renderer associated with that
library</p>
- */
+ * <p class="changed_added_4_0">
+ * JSF renderer associated with that library
+ * </p>
+ */
private final List<Renderer> renderers = new ArrayList<Renderer>();
-
+
private final List<Converter> converters = new ArrayList<Converter>();
-
+
private final List<Validator> validators = new ArrayList<Validator>();
-
+
private final List<Behavior> behaviors = new ArrayList<Behavior>();
private final List<Listener> listeners = new ArrayList<Listener>();
-
+
/**
- * <p class="changed_added_4_0">Tag library with references of all used
tags</p>
- */
+ * <p class="changed_added_4_0">
+ * Tag library with references of all used tags
+ * </p>
+ */
private final TagLibrary tagLibrary;
-
+
/**
- * <p class="changed_added_4_0"></p>
- */
+ * <p class="changed_added_4_0">
+ * </p>
+ */
private final String baseName;
private NamingConventions namingConventions = new RichFacesConventions();
-
-
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param baseName
*/
public ComponentLibrary(String baseName) {
this.baseName = baseName;
this.tagLibrary = new TagLibrary(baseName);
}
+
/**
- * <p class="changed_added_4_0">Merge component library model with
other.</p>
+ * <p class="changed_added_4_0">
+ * Merge component library model with other.
+ * </p>
+ *
* @param otherLibrary
*/
public void apply(ComponentLibrary otherLibrary) {
// TODO Auto-generated method stub
-
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the components
*/
public Collection<Component> getComponents() {
return componentsSet;
}
-
/**
* <p class="changed_added_4_0">
* Lookup for component with given type. If such component did not exist and
@@ -125,72 +191,92 @@
* created
* </p>
*
- * @param type
+ * @param type
* @param create
* @return
*/
public Component getComponent(String type, boolean create) {
Component.Type componentType = new Component.Type(type);
Component component = components.get(componentType);
- if(null == component && create){
+ if (null == component && create) {
component = new Component(componentType);
components.put(componentType, component);
}
return component;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the renderers
*/
public List<Renderer> getRenderers() {
return renderers;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the converters
*/
public List<Converter> getConverters() {
return converters;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the validators
*/
public List<Validator> getValidators() {
return validators;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the behaviors
*/
public List<Behavior> getBehaviors() {
return behaviors;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the listeners
*/
public List<Listener> getListeners() {
return listeners;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the tagLibrary
*/
public TagLibrary getTagLibrary() {
return tagLibrary;
}
-
- public NamingConventions getNamingUtils(){
+
+ public NamingConventions getNamingUtils() {
return namingConventions;
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the baseName
*/
protected String getBaseName() {
return baseName;
}
-
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/InvalidNameException.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -26,17 +26,18 @@
import org.richfaces.cdk.CdkException;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">That exception indicates what some name
does not meet CDK naming conventions.</p>
* @author asmirnov(a)exadel.com
*
*/
+@SuppressWarnings("serial")
public class InvalidNameException extends CdkException {
/**
* <p class="changed_added_4_0"></p>
*/
public InvalidNameException() {
- // TODO Auto-generated constructor stub
+ super();
}
/**
@@ -45,7 +46,6 @@
*/
public InvalidNameException(String message) {
super(message);
- // TODO Auto-generated constructor stub
}
/**
@@ -54,7 +54,6 @@
*/
public InvalidNameException(Throwable cause) {
super(cause);
- // TODO Auto-generated constructor stub
}
/**
@@ -64,7 +63,6 @@
*/
public InvalidNameException(String message, Throwable cause) {
super(message, cause);
- // TODO Auto-generated constructor stub
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfComponent.java 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfComponent.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -1,7 +1,9 @@
package org.richfaces.cdk.model;
-public interface JsfComponent {
+import java.io.Serializable;
+public interface JsfComponent extends Serializable {
+
/**
* <p class="changed_added_4_0">Marker interface for all JSF objects:
* {@code Validator}, {@code Converter}, {@code Behavior}, {@code
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Name.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -23,110 +23,156 @@
package org.richfaces.cdk.model;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * <p class="changed_added_4_0">Represents parts of component
type/family/classname according to CDK naming conventions.</p>
+ * <p class="changed_added_4_0">
+ * Represents parts of component type/family/classname according to CDK naming
+ * conventions.
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class Name {
-
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * Standard package names for components, renderers, event listeners and taglib.
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public enum Classifier {
- component,
- renderkit,
- event,
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ component,
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ renderkit,
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ event,
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
taglib;
}
- private static final Pattern namePattern = Pattern.compile("^(?:(.+)\\.)?(?:("
+ Classifier.component
- + "|" + Classifier.renderkit + "|" + Classifier.event +
"|" + Classifier.taglib + ")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
+ private static final Pattern namePattern = Pattern
+ .compile("^(?:(.+)\\.)?(?:(" + Classifier.component + "|"
+ + Classifier.renderkit + "|" + Classifier.event + "|"
+ + Classifier.taglib + ")\\.(?:([^\\.]+)\\.)?)?([^\\.]+)$");
/**
- * <p class="changed_added_4_0">represents library part prefix of
name.</p>
- */
+ * <p class="changed_added_4_0">
+ * represents library part prefix of name.
+ * </p>
+ */
private String prefix;
-
+
/**
- * <p class="changed_added_4_0">Element type classifier -
"component","event","renderkit","taglib"</p>
- */
+ * <p class="changed_added_4_0">
+ * Element type classifier -
"component","event","renderkit","taglib"
+ * </p>
+ */
private Classifier classifier;
-
+
/**
- * <p class="changed_added_4_0">Markup-specific part of name (
"html","xhtml","wml" ... )</p>
- */
+ * <p class="changed_added_4_0">
+ * Markup-specific part of name ( "html","xhtml","wml" ...
)
+ * </p>
+ */
private String markup;
-
+
/**
- * <p class="changed_added_4_0">Simple name ( last word after a period
).</p>
- */
+ * <p class="changed_added_4_0">
+ * Simple name ( last word after a period ).
+ * </p>
+ */
private String simpleName;
/**
- * <p class="changed_added_4_0">Creates RichFaces name representation
from string.</p>
+ * <p class="changed_added_4_0">
+ * Creates RichFaces name representation from string.
+ * </p>
+ *
* @param name
* @return
* @throws InvalidNameException
*/
public static Name create(String name) throws InvalidNameException {
- Name cdkName = new Name();
- StringBuilder prefix = new StringBuilder(name.length());
- String[] parts = name.split("\\.");
- cdkName.setSimpleName(parts[parts.length-1]);
- if(parts.length>1){
- try{
- cdkName.setClassifier(Classifier.valueOf(parts[parts.length-2]));
- fillPrefix(prefix, parts,parts.length-2);
- } catch (IllegalArgumentException e) {
- if(parts.length>2){
- try{
- cdkName.setClassifier(Classifier.valueOf(parts[parts.length-3]));
- fillPrefix(prefix, parts,parts.length-3);
- cdkName.setMarkup(parts[parts.length-2]);
- } catch (IllegalArgumentException e1) {
- fillPrefix(prefix, parts,parts.length-1);
- }
-
- } else {
- prefix.append(parts[0]);
+ Name cdkName = new Name();
+ StringBuilder prefix = new StringBuilder(name.length());
+ String[] parts = name.split("\\.");
+ cdkName.setSimpleName(parts[parts.length - 1]);
+ if (parts.length > 1) {
+ try {
+ cdkName.setClassifier(Classifier
+ .valueOf(parts[parts.length - 2]));
+ fillPrefix(prefix, parts, parts.length - 2);
+ } catch (IllegalArgumentException e) {
+ if (parts.length > 2) {
+ try {
+ cdkName.setClassifier(Classifier
+ .valueOf(parts[parts.length - 3]));
+ fillPrefix(prefix, parts, parts.length - 3);
+ cdkName.setMarkup(parts[parts.length - 2]);
+ } catch (IllegalArgumentException e1) {
+ fillPrefix(prefix, parts, parts.length - 1);
}
+
+ } else {
+ prefix.append(parts[0]);
}
- if(prefix.length()>0){
- cdkName.setPrefix(prefix.toString());
- }
}
- return cdkName;
+ if (prefix.length() > 0) {
+ cdkName.setPrefix(prefix.toString());
+ }
+ }
+ return cdkName;
}
- private static void fillPrefix(StringBuilder prefix, String[] parts, int size) {
+ /**
+ * <p class="changed_added_4_0">Utility method that composes library
prefix from first elements of array</p>
+ * @param prefix buffer that collects prefix.
+ * @param parts package name parts
+ * @param size size of prefix part of array.
+ */
+ private static void fillPrefix(StringBuilder prefix, String[] parts,
+ int size) {
for (int i = 0; i < size; i++) {
- if(i!=0){
+ if (i != 0) {
prefix.append('.');
}
prefix.append(parts[i]);
}
}
- public static Name create(String prefix,String name) throws InvalidNameException {
+ public static Name create(String prefix, String name)
+ throws InvalidNameException {
Name cdkName = create(name);
- if(prefix.equals(cdkName.getPrefix())){
+ if (prefix.equals(cdkName.getPrefix())) {
return new Name();
} else {
- throw new InvalidNameException("Nape "+name+" does not start with
prefix "+prefix);
+ throw new InvalidNameException("Nape " + name
+ + " does not start with prefix " + prefix);
}
}
- public static Name create(String prefix, Classifier classifier, String name) throws
InvalidNameException {
+ public static Name create(String prefix, Classifier classifier, String name)
+ throws InvalidNameException {
return new Name();
}
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the prefix
*/
public String getPrefix() {
@@ -134,15 +180,20 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param prefix the prefix to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param prefix
+ * the prefix to set
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the classifier
*/
public Classifier getClassifier() {
@@ -150,15 +201,20 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param classifier the classifier to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param classifier
+ * the classifier to set
*/
public void setClassifier(Classifier classifier) {
this.classifier = classifier;
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the markup
*/
public String getMarkup() {
@@ -166,15 +222,20 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param markup the markup to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param markup
+ * the markup to set
*/
public void setMarkup(String markup) {
this.markup = markup;
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the simpleName
*/
public String getSimpleName() {
@@ -182,11 +243,30 @@
}
/**
- * <p class="changed_added_4_0"></p>
- * @param simpleName the simpleName to set
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param simpleName
+ * the simpleName to set
*/
public void setSimpleName(String simpleName) {
this.simpleName = simpleName;
}
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ if(null != prefix){
+ result.append(prefix).append('.');
+ }
+ if(null != classifier){
+ result.append(classifier).append('.');
+ }
+ if(null != markup){
+ result.append(markup).append('.');
+ }
+ result.append(simpleName);
+ return result.toString();
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/NamingConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/NamingConventions.java 2009-08-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/NamingConventions.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -36,26 +36,28 @@
public interface NamingConventions {
/**
- * <p class="changed_added_4_0">Calculates component type from the base
class name.</p>
+ * <p class="changed_added_4_0">Calculates component type from explicit
value or base class name.</p>
* <ul>
*
<li><code><prefix>.component.Abstract<Name></code>
=> <code><prefix>.<Name></code>
</li>
*
<li><code><prefix>.component.<Name>Base</code>
=> <code><prefix>.<Name></code>
</li>
*
<li><code><prefix>.component.UI<Name></code>
=> <code><prefix>.<Name></code>
</li>
* </ul>
+ * @param explicitType
* @param className
* @return
* @throws InvalidNameException if className does not match naming conventions.
*/
- public String getComponentType(String className) throws InvalidNameException;
+ public String inferComponentType(String explicitType, String className) throws
InvalidNameException;
/**
- * <p class="changed_added_4_0">Calculates component base class from
type.</p>
+ * <p class="changed_added_4_0">Calculates concrete component class from
explicit value or type.</p>
* <ul>
* <li><code><prefix>.<Name></code>
=> <code><prefix>.component.UI<Name></code>
</li>
* </ul>
+ * @param explicitClass
* @param className
* @return
*/
- public String getComponentClass(String componentType);
+ public String inferUIComponentClass(String explicitClass, String componentType);
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/Strings.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -0,0 +1,85 @@
+/*
+ * $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.util;
+
+/**
+ * <p class="changed_added_4_0">String manipulation utils.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public final class Strings {
+
+ private Strings() {
+ // this is utility class with static methods only.
+ }
+
+ /**
+ * <p class="changed_added_4_0">Remove characters from string
end</p>
+ * @param in input string
+ * @param size number of characters to remove.
+ * @return
+ */
+ public static String cut(String in, int size) {
+ if(size >0){
+ return in.substring(0, in.length()-size);
+ }
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to
lower, as it required by the Java Beans property and setter/getter method name
conventions:</p>
+ * <p>"PropertyFoo" will be changed to
"propertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToLowerCase(String in) {
+ if(!isEmpty(in)){
+ in = in.substring(0,1).toLowerCase()+in.substring(1);
+ }
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Change case of the first character to
upper, as it required by the Java Beans property and setter/getter method name
conventions:</p>
+ * <p>"propertyFoo" will be changed to
"PropertyFoo"</p>
+ * @param in
+ * @return {@code in} with first character changed to lower case.
+ */
+ public static String firstToUpperCase(String in) {
+ if(!isEmpty(in)){
+ in = in.substring(0,1).toUpperCase()+in.substring(1);
+ }
+ return in;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Check string for null or empty
value</p>
+ * @param type
+ * @return true if {@code type} is null or zero-length string.
+ */
+ public static boolean isEmpty(String type) {
+ return type == null || type.length()==0;
+ }
+
+}
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-07
18:46:54 UTC (rev 15140)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ProcessorTest.java 2009-08-08
00:41:50 UTC (rev 15141)
@@ -88,7 +88,9 @@
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.util.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -128,66 +130,10 @@
@Override
public boolean process(Set<? extends TypeElement> annotations,
- RoundEnvironment environment) {
- System.out.println("Run Process at round: "+environment.processingOver());
- if(!environment.processingOver()){
- // Get all classes annotated by "component"
- Set<? extends Element> annotatedWith =
environment.getElementsAnnotatedWith(Component.class);
- numOfComponents = annotatedWith.size();
- for (Element element : annotatedWith) {
- if (ElementKind.CLASS.equals(element.getKind())) {
- TypeElement classElement = (TypeElement) element;
- Component annotation = element
- .getAnnotation(Component.class);
- String type = annotation.type();
- // TODO - infer type for an empty one. Is thart method
- // for library or for environment ?
- if (isEmpty(type)) {
- classElement.getQualifiedName().toString();
- }
- org.richfaces.cdk.model.Component component = library
- .getComponent(type, true);
- Elements elementUtils = processingEnv.getElementUtils();
- Types typeUtils = processingEnv.getTypeUtils();
- component.setDescription(elementUtils
- .getDocComment(element));
- List<ExecutableElement> methodsIn = ElementFilter
- .methodsIn(elementUtils
- .getAllMembers(classElement));
- for (ExecutableElement method : methodsIn) {
- Attribute attribute = method
- .getAnnotation(Attribute.class);
- if (null != attribute) {
- TypeMirror returnType = method.getReturnType();
- String methodName = method.getSimpleName()
- .toString();
- List<? extends VariableElement> parameters = method
- .getParameters();
- Set<Modifier> modifiers = method.getModifiers();
- if (methodName.startsWith("get")
- && parameters.isEmpty()
- && modifiers.contains(Modifier.PUBLIC)) {
- // Bean getter method.
- String attributeName = methodName
- .substring(3, 4).toLowerCase()
- + methodName.substring(4);
- Property atribute = component
- .addAtribute(attributeName);
- atribute.setDescription(elementUtils
- .getDocComment(method));
- }
- }
-
- }
- }
- }
- }
- return true;
+ RoundEnvironment roundEnv) {
+ return false;
}
- private boolean isEmpty(String type) {
- return type == null || type.length()==0;
- }
}
@@ -313,38 +259,10 @@
CdkCompiler compiler = CdkCompiler.create(cdkContext);
compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
- assertEquals(1, library.getComponents().size());
- org.richfaces.cdk.model.Component component =
library.getComponents().iterator().next();
- assertEquals(1, component.getAttributes().size());
-
+ assertTrue(processor.isInitialized());
}
/**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testComponentProcessor() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(TestAnnotation2.class.getClassLoader());
- replay(cdkContext);
- ComponentLibrary library = new ComponentLibrary("org.richfaces.cdk.test");
- Processor processor = new ComponentProcessor(cdkContext,library);
- CdkCompiler compiler = CdkCompiler.create(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- }
-
- /**
* <p class="changed_added_4_0"></p>
*
* @param name
Modified: root/cdk/trunk/plugins/pom.xml
===================================================================
--- root/cdk/trunk/plugins/pom.xml 2009-08-07 18:46:54 UTC (rev 15140)
+++ root/cdk/trunk/plugins/pom.xml 2009-08-08 00:41:50 UTC (rev 15141)
@@ -1,25 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-
http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.richfaces</groupId>
- <artifactId>cdk</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-plugins</artifactId>
- <packaging>pom</packaging>
- <name>maven plugin CDK plugins</name>
-
-
- <modules>
- <module>generator</module>
- <module>maven-cdk-plugin</module>
- </modules>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>cdk</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <packaging>pom</packaging>
+ <name>maven plugin CDK plugins</name>
+
+
+ <modules>
+ <module>generator</module>
+ <module>maven-cdk-plugin</module>
+ <module>annotations</module>
+ </modules>
+
</project>
\ No newline at end of file