Author: alexsmirnov
Date: 2009-08-18 21:11:54 -0400 (Tue, 18 Aug 2009)
New Revision: 15208
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererKit.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbTestBase.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/resources/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/test/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/test/java/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/test/resources/
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/settings.xml
Modified:
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/RootElementConsumer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java
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/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.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/model/Behavior.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.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/Converter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.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/LibraryVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java
root/cdk/trunk/plugins/maven-cdk-plugin/pom.xml
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
Java class has been generated from integration test project.
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,88 @@
+/*
+ * $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 java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.render.JavaClassRenderer;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Renderer;
+import org.richfaces.cdk.model.RendererKit;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class RendererClassGenerator implements CdkWriter {
+
+ private CdkContext context;
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = 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 {
+ for (RendererKit renderKit : library.getRenderKits()) {
+ for (Renderer renderer : renderKit.getRenderers()) {
+ JavaClass javaClass = renderer.getTemplate();
+ String fullName = javaClass.getFullName();
+
+ File outFile = new File(context.getJavaSourceOutput(),
+ fullName.replace('.', '/') + ".java");
+
+ if (outFile.exists()) {
+ outFile.delete();
+ }
+
+ outFile.getParentFile().mkdirs();
+
+ try {
+ new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
+ } catch (FileNotFoundException e) {
+ throw new CdkException(e);
+ }
+
+ }
+ }
+
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererTemplateParser.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,10 +23,20 @@
package org.richfaces.builder.templates;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Renderer;
/**
* <p class="changed_added_4_0"></p>
@@ -35,13 +45,32 @@
*/
public class RendererTemplateParser implements ModelBuilder {
+ private CdkContext context;
+
/* (non-Javadoc)
* @see org.richfaces.cdk.ModelBuilder#build()
*/
@Override
public ComponentLibrary build() throws CdkException {
- // TODO Auto-generated method stub
- return null;
+ ComponentLibrary library = new ComponentLibrary();
+ for(File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)){
+ try {
+ RootElementConsumer template = TemplateReader.parseTemplate(new
FileInputStream(file));
+ Renderer renderer = library.createRenderer(template.getRenderKitId(),
template.getRendererType(), template.getFamily());
+ renderer.setTemplate(template.getJavaClass());
+ String componentType = template.getComponentType();
+ if(null != componentType){
+ Component component = library.createComponent(componentType);
+ component.getRenderers().add(renderer);
+ }
+ } catch (FileNotFoundException e) {
+ // TODO - log errors, marks mojo failed after whole build cycle.
+ throw new CdkException(e);
+ } catch (XMLStreamException e) {
+ throw new CdkException(e);
+ }
+ }
+ return library;
}
/* (non-Javadoc)
@@ -49,8 +78,10 @@
*/
@Override
public void init(CdkContext context) {
- // TODO Auto-generated method stub
+ this.context = context;
+ }
+ public CdkContext getContext() {
+ return context;
}
-
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RootElementConsumer.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -2,6 +2,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
import javax.xml.namespace.QName;
import javax.xml.stream.events.Attribute;
@@ -37,6 +39,14 @@
*
*/
public class RootElementConsumer extends BaseTemplateConsumer {
+
+ private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+
+ private String rendererType;
+
+ private String family;
+
+ private String componentType;
private JavaClass javaClass;
@@ -44,6 +54,38 @@
return javaClass;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitId
+ */
+ public String getRenderKitId() {
+ return renderKitId;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererType
+ */
+ public String getRendererType() {
+ return rendererType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ public String getFamily() {
+ return family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the componentType
+ */
+ public String getComponentType() {
+ return componentType;
+ }
+
private String getAttributeValue(StartElement element, String attributeName) {
Attribute attribute = element.getAttributeByName(new QName(attributeName));
if (attribute != null) {
@@ -110,7 +152,10 @@
String componentClassName = getAttributeValue(startElement,
"componentclass");
javaClass.addImport(componentClassName);
-
+ renderKitId = getAttributeValue(startElement, "renderkit");
+ rendererType = getAttributeValue(startElement, "renderertype");
+ family = getAttributeValue(startElement, "family");
+ componentType = getAttributeValue(startElement, "componenttype");
return new TemplateBodyConsumer(javaClass, getSimpleClassName(componentClassName));
} else {
throw new IllegalArgumentException();
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/TemplateReader.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -116,7 +116,7 @@
}
}
- public static JavaClass parse(InputStream stream) throws XMLStreamException {
+ public static RootElementConsumer parseTemplate(InputStream stream) throws
XMLStreamException {
XMLEventReader xmlEventReader =
XMLInputFactoryHolder.factory.createXMLEventReader(stream);
try {
@@ -145,8 +145,7 @@
tracker.popConsumer();
- JavaClass javaClass = consumer.getJavaClass();
- return javaClass;
+ return consumer;
} finally {
try {
stream.close();
@@ -163,4 +162,8 @@
}
}
+
+ public static JavaClass parse(InputStream input) throws XMLStreamException{
+ return parseTemplate(input).getJavaClass();
+ }
}
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-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -26,6 +26,7 @@
import java.io.File;
import java.util.Map;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.model.ComponentLibrary;
import com.google.common.collect.Maps;
@@ -49,6 +50,8 @@
private NamingConventions namingConventions;
private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
+
+ private Map<OutputType,File> outputs = Maps.newHashMap();
/**
* <p class="changed_added_4_0"></p>
@@ -138,6 +141,12 @@
public Iterable<File> getSources(SourceType type) {
return sources.get(type);
}
+
+ @Override
+ public File getOutputFolder(OutputType type) {
+ File outputFolder = outputs.get(type);
+ return outputFolder;
+ }
}
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-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -2,8 +2,10 @@
import java.io.File;
+import org.richfaces.cdk.CdkWriter.OutputType;
+
/**
* <p class="changed_added_4_0">
* That interface defines context for all CDK operations
@@ -71,5 +73,12 @@
* @return
*/
public Iterable<File> getSources(SourceType type);
+
+ /**
+ * <p class="changed_added_4_0">Provides default output folder for given
output type.</p>
+ * @param type of output
+ * @return output folder for requested type.
+ */
+ public File getOutputFolder(OutputType type);
}
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,58 @@
+/*
+ * $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 class DummyBuilder implements ModelBuilder {
+
+ private CdkContext context;
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#build()
+ */
+ @Override
+ public ComponentLibrary build() throws CdkException {
+ return new ComponentLibrary();
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ this.context = context;
+ // TODO Auto-generated method stub
+
+ }
+
+ protected CdkContext getContext() {
+ return context;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,57 @@
+/*
+ * $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 class DummyGenerator implements CdkWriter {
+
+ private CdkContext context;
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void render(ComponentLibrary library) throws CdkException {
+ // Do nothing
+ }
+
+ protected CdkContext getContext() {
+ return context;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -25,6 +25,7 @@
import java.io.File;
+import org.richfaces.builder.templates.RendererClassGenerator;
import org.richfaces.builder.templates.RendererTemplateParser;
import org.richfaces.cdk.CdkContext.SourceType;
import org.richfaces.cdk.CdkWriter.OutputType;
@@ -104,34 +105,50 @@
ComponentLibrary library = null;
for (SourceType type : StandardSources.values()) {
ComponentLibrary model = buildModel(type);
- if (null != library) {
- library.merge(model);
- } else {
- library = model;
+ if (null != model) {
+ if (null != library) {
+ library.merge(model);
+ } else {
+ library = model;
+ }
}
}
getVerifier().verify(library);
return library;
}
+ public void generate(ComponentLibrary library) throws CdkException {
+ for (OutputType type : StandardOutputs.values()) {
+ generate(library, type);
+ }
+ }
+
/**
- * <p class="changed_added_4_0">Cenerate files from library
model.</p>
+ * <p class="changed_added_4_0">
+ * Cenerate files from library model.
+ * </p>
+ *
* @param library
* @param type
* @throws CdkException
*/
- public void generate(ComponentLibrary library, OutputType type) throws CdkException {
+ public void generate(ComponentLibrary library, OutputType type)
+ throws CdkException {
CdkWriter generator = getGeneratorFor(type);
generator.render(library);
}
-
+
protected CdkWriter getGeneratorFor(OutputType type) throws CdkException {
CdkWriter generator = null;
- if(StandardOutputs.COMPONENT_CLASSES.equals(type)){
+ if (StandardOutputs.COMPONENT_CLASSES.equals(type)) {
generator = new ComponentClassGenerator();
+ } else if (StandardOutputs.RENDERER_CLASSES.equals(type)) {
+ generator = new RendererClassGenerator();
} else {
+ generator = new DummyGenerator();
// TODO - make service method for new source types.
- throw new CdkException("No generator for type " + type.getName());
+ // throw new CdkException("No generator for type " +
+ // type.getName());
}
generator.init(getContext());
return generator;
@@ -168,14 +185,16 @@
} else if (StandardSources.RENDERER_TEMPLATES.equals(type)) {
builder = new RendererTemplateParser();
} else {
+ builder = new DummyBuilder();
// TODO - make service method for new source types.
- throw new CdkException("No model builder for source type " +
type.getName());
+ // throw new CdkException("No model builder for source type " +
+ // type.getName());
}
builder.init(getContext());
return builder;
}
-
- protected Verifier getVerifier(){
+
+ protected Verifier getVerifier() {
// TODO - put verifier implementation into context ?
return new VerifierImpl(getContext());
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -116,19 +116,9 @@
options.add("-sourcepath");
options.add(context.getJavaSource().getAbsolutePath());
}
- if(null != context.getJavaSourceOutput() || null != context.getResourceOutput()){
+ if(null != context.getJavaSourceOutput() ){
options.add("-s");
- StringBuilder generatedSourceFolders = new StringBuilder();
- if(null != context.getJavaSourceOutput()){
- generatedSourceFolders.append(context.getJavaSourceOutput().getAbsolutePath());
- }
- if(null != context.getResourceOutput()){
- if(generatedSourceFolders.length()>0){
- generatedSourceFolders.append(File.pathSeparatorChar);
- }
- generatedSourceFolders.append(context.getResourceOutput().getAbsolutePath());
- }
- options.add(generatedSourceFolders.toString());
+ options.add(context.getJavaSourceOutput().getAbsolutePath());
}
setOptions(options);
// TODO - provide source files locale.
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -43,7 +43,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public abstract class FreeMarkerRenderer<C extends JsfComponent,P> implements
CdkWriter,LibraryVisitor<Boolean, P> {
+public abstract class FreeMarkerRenderer<C extends JsfComponent<C>,P>
implements CdkWriter,LibraryVisitor<Boolean, P> {
private CdkContext context;
private Configuration configuration;
@@ -70,7 +70,7 @@
}
@Override
- public Boolean visit(JsfComponent c, P param) {
+ public Boolean visit(JsfComponent<?> c, P param) {
if(isMyComponent(c)){
return processComponent((C)c, param);
}
@@ -97,7 +97,7 @@
return new FileWriter(getOutputFile(c));
}
- protected abstract String getOutputFile(C c);
+ protected abstract String getOutputFile(C c) throws IOException;
protected abstract boolean isMyComponent(JsfComponent c);
Modified:
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 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -24,6 +24,7 @@
package org.richfaces.cdk.generate.java;
import java.io.File;
+import java.io.IOException;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
@@ -61,9 +62,16 @@
@Override
- protected String getOutputFile(Component c) {
+ protected String getOutputFile(Component c) throws IOException {
File sourceOutput = getContext().getJavaSourceOutput();
- return (new File(sourceOutput,c.getComponentClass().getName().replace('.',
File.separatorChar)+".java")).getAbsolutePath();
+ File outputFile = new
File(sourceOutput,c.getComponentClass().getName().replace('.',
File.separatorChar)+".java");
+ if(!outputFile.exists()){
+ outputFile.getParentFile().mkdirs();
+ } else {
+ outputFile.delete();
+ }
+// outputFile.createNewFile();
+ return outputFile.getAbsolutePath();
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -28,7 +28,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Behavior implements JsfComponent {
+@SuppressWarnings("serial")
+public class Behavior implements JsfComponent<Behavior> {
private JsfType type;
@@ -52,4 +53,10 @@
this.type = type;
}
+ @Override
+ public void merge(Behavior other) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -35,20 +35,13 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ClassDescription implements JsfComponent {
+public class ClassDescription {
/**
* <p class="changed_added_4_0"></p>
*/
private static final long serialVersionUID = -846623207703750456L;
- @SuppressWarnings("serial")
- public static final class Type extends JsfType {
- public Type(String type) {
- super(type);
- }
- }
-
private static final ImmutableMap<String, String> primitiveTypes = ImmutableMap
.<String, String> builder().put(boolean.class.getName(),
Boolean.class.getName()).put(byte.class.getName(),
@@ -65,7 +58,6 @@
*/
private final String name;
- private final Type type ;
private final boolean primitive;
@@ -77,6 +69,8 @@
*/
private String typeParameters;
+ private final String fullName;
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -84,7 +78,7 @@
* @param name
*/
public ClassDescription(String name) {
- this.type = new Type(name);
+ fullName = name;
if (primitiveTypes.containsKey(name)) {
this.name = name;
boxingClassName = primitiveTypes.get(name);
@@ -102,10 +96,6 @@
}
}
- @Override
- public JsfType getType() {
- return type;
- }
/**
* <p class="changed_added_4_0"></p>
@@ -181,7 +171,7 @@
@Override
public String toString() {
- return type.toString();
+ return fullName;
}
/* (non-Javadoc)
@@ -210,20 +200,15 @@
return false;
}
ClassDescription other = (ClassDescription) obj;
- if (type == null) {
- if (other.type != null) {
+ if (fullName == null) {
+ if (other.fullName != null) {
return false;
}
- } else if (!type.equals(other.type)) {
+ } else if (!fullName.equals(other.fullName)) {
return false;
}
return true;
}
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
- // TODO Auto-generated method stub
- return null;
- }
}
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-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -26,7 +26,7 @@
@SuppressWarnings("serial")
@XmlType(name="faces-config-componentType")
@XmlAccessorType( XmlAccessType.NONE )
-public final class Component implements JsfComponent, DescriptionGroup,Extensible {
+public final class Component implements JsfComponent<Component>,
DescriptionGroup,Extensible<ConfigExtension> {
/**
* <p class="changed_added_4_0">Reference to component library for
which that component is belong to.</p>
@@ -42,13 +42,6 @@
/**
* <p class="changed_added_4_0">
- * component family
- * </p>
- */
- private String family;
-
- /**
- * <p class="changed_added_4_0">
* Cenerated component class
* </p>
*/
@@ -123,6 +116,20 @@
return visitor.visit(this, param);
}
+ @Override
+ public void merge(Component otherComponent) {
+ ComponentLibrary.merge(renderers, otherComponent.getRenderers());
+// TODO - merge facets, renderers, events ...
+ for (Property property : otherComponent.getAttributes()) {
+ if(attributes.containsKey(property.getName())){
+ attributes.get(property.getName()).merge(property);
+ } else {
+ attributes.put(property.getName(), property);
+ }
+ }
+ ComponentLibrary.merge(this,otherComponent);
+ }
+
/*
* (non-Javadoc)
*
@@ -155,6 +162,9 @@
return extension;
}
+ public void setExtension(ComponentExtension extension) {
+ this.extension = extension;
+ }
/**
* <p class="changed_added_4_0">
@@ -164,8 +174,9 @@
*
* @return the family
*/
+ @Merge
public String getFamily() {
- return family;
+ return getExtension().getFamily();
}
/**
@@ -176,7 +187,7 @@
* the family to set
*/
public void setFamily(String family) {
- this.family = family;
+ getExtension().setFamily(family);
}
/**
@@ -185,6 +196,7 @@
*
* @return the componentClass
*/
+ @Merge
public ClassDescription getComponentClass() {
return componentClass;
}
@@ -207,6 +219,7 @@
*
* @return the baseClass
*/
+ @Merge
public ClassDescription getBaseClass() {
return baseClass;
}
@@ -271,6 +284,7 @@
* <p class="changed_added_4_0"></p>
* @return the exists
*/
+ @Merge
public boolean isExists() {
return exists;
}
@@ -358,15 +372,17 @@
* @author asmirnov(a)exadel.com
*
*/
- public class ComponentExtension extends ConfigExtension {
+ public static class ComponentExtension extends ConfigExtension {
+ private String family;
+
@XmlElement(namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public String getFamily(){
- return Component.this.getFamily();
+ return family;
}
public void setFamily(String family) {
- Component.this.setFamily(family);
+ this.family = family;
}
}
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-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,7 +23,12 @@
package org.richfaces.cdk.model;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -80,7 +85,7 @@
* JSF renderer associated with that library
* </p>
*/
- private final List<Renderer> renderers = Lists.newArrayList();
+ private final List<RendererKit> renderKits = Lists.newArrayList();
private final List<Converter> converters = Lists.newArrayList();
@@ -115,28 +120,22 @@
* @param otherLibrary
*/
public void merge(ComponentLibrary otherLibrary) {
- // TODO Auto-generated method stub
+ merge(components,otherLibrary.getComponents());
+ merge(renderKits,otherLibrary.getRenderKits());
+ merge(converters,otherLibrary.getConverters());
+ merge(validators,otherLibrary.getValidators());
+ merge(listeners,otherLibrary.getListeners());
}
public <R,P> R accept(LibraryVisitor<R, P> visitor,P param){
R result = accept(components,visitor, param, null);
- result = accept(renderers,visitor, param, result);
+ result = accept(renderKits,visitor, param, result);
result = accept(converters,visitor, param, result);
result = accept(validators,visitor, param, result);
result = accept(listeners,visitor, param, result);
return result;
}
- private <R,P,T extends JsfComponent> R accept(Iterable<T> components,
LibraryVisitor<R, P> visitor,P param, R result){
- for (T t : components) {
- R accept = t.accept(visitor, param);
- if(null != accept){
- result = accept;
- }
- }
- return result;
- }
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -194,13 +193,39 @@
}
/**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKitId
+ * @param rendererType
+ * @param family
+ * @return
+ */
+ public Renderer createRenderer(String renderKitId, String rendererType,
+ String family) {
+ RendererKit.Type renderKitType = new RendererKit.Type(renderKitId);
+ RendererKit rendererKit = find(renderKits,renderKitType);
+ if(null == rendererKit){
+ rendererKit = new RendererKit();
+ rendererKit.setType(renderKitType);
+ renderKits.add(rendererKit);
+ }
+ Renderer.Type type = new Renderer.Type(rendererType,family);
+ Renderer renderer = find(rendererKit.getRenderers(), type);
+ if(null == renderer){
+ renderer = new Renderer();
+ renderer.setType(type);
+ rendererKit.getRenderers().add(renderer);
+ }
+ return renderer;
+ }
+
+ /**
* <p class="changed_added_4_0">
* </p>
*
- * @return the renderers
+ * @return the renderKits
*/
- public List<Renderer> getRenderers() {
- return renderers;
+ public List<RendererKit> getRenderKits() {
+ return renderKits;
}
/**
@@ -255,6 +280,53 @@
// Utility methods.
+ static <T extends JsfComponent<T>> void merge(Collection<T> target,
Collection<T> source){
+ for (T element : source) {
+ T targetElement = find(target,element.getType());
+ if(null == targetElement){
+ target.add(element);
+ } else {
+ targetElement.merge(element);
+ }
+ }
+ }
+
+ static <T extends Mergeable<T>> void merge(T target, T source) {
+ try {
+ PropertyDescriptor[] properties =
Introspector.getBeanInfo(target.getClass()).getPropertyDescriptors();
+ for (PropertyDescriptor propertyDescriptor : properties) {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Method writeMethod = propertyDescriptor.getWriteMethod();
+ if(null != readMethod && null != writeMethod &&
readMethod.isAnnotationPresent(Merge.class)){
+ boolean overwrite = readMethod.getAnnotation(Merge.class).value();
+ Object oldValue = readMethod.invoke(target);
+ Object newValue = readMethod.invoke(source);
+ if(null != newValue && (overwrite || null == oldValue)){
+ writeMethod.invoke(target, newValue);
+ }
+ }
+ }
+ } catch (IntrospectionException e) {
+ // TODO Auto-generated catch block
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ }
+ }
+
+ static <R,P,T extends JsfComponent<?>> R accept(Iterable<T>
components, LibraryVisitor<R, P> visitor,P param, R result){
+ for (T t : components) {
+ R accept = t.accept(visitor, param);
+ if(null != accept){
+ result = accept;
+ }
+ }
+ return result;
+ }
+
/**
* <p class="changed_added_4_0">
* Find element in the model collection.
@@ -270,7 +342,7 @@
* @throws NoSuchElementException
* if there was no such element in collection.
*/
- private <T extends JsfComponent> T find(Iterable<T> collection,
+ static <T extends JsfComponent> T find(Iterable<T> collection,
final JsfType key) throws NoSuchElementException {
return Iterables.find(collection, new Predicate<T>() {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -28,7 +28,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Converter implements JsfComponent {
+@SuppressWarnings("serial")
+public class Converter implements JsfComponent <Converter>{
private JsfType type;
@@ -52,4 +53,10 @@
this.type = type;
}
+ @Override
+ public void merge(Converter other) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -16,6 +16,7 @@
* @return the description
*/
@XmlElement
+ @Merge
public String getDescription();
/**
@@ -34,6 +35,7 @@
* @return the displayname
*/
@XmlElement(name = "display-name")
+ @Merge
public String getDisplayname();
/**
@@ -52,6 +54,7 @@
* @return the icon
*/
@XmlElement
+ @Merge
public String getIcon();
/**
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -28,7 +28,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Facet {
+public class Facet implements Mergeable<Facet>{
private final String name;
@@ -46,6 +46,7 @@
* <p class="changed_added_4_0"></p>
* @return the description
*/
+ @Merge
public String getDescription() {
return description;
}
@@ -66,4 +67,9 @@
return name;
}
+ @Override
+ public void merge(Facet other) {
+ ComponentLibrary.merge(this, other);
+ }
+
}
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-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/JsfComponent.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -2,7 +2,7 @@
import java.io.Serializable;
-public interface JsfComponent extends Serializable {
+public interface JsfComponent<T> extends Serializable, Mergeable<T> {
/**
* <p class="changed_added_4_0">Marker interface for all JSF objects:
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -38,6 +38,6 @@
* @param param
* @return
*/
- public R visit(JsfComponent c, P param);
+ public R visit(JsfComponent<?> c, P param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -28,7 +28,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Listener implements JsfComponent {
+@SuppressWarnings("serial")
+public class Listener implements JsfComponent<Listener> {
private JsfType type;
@@ -52,4 +53,10 @@
this.type = type;
}
+ @Override
+ public void merge(Listener other) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -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.model;
+
+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">Marker for model bean property that
should be merged with other.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD})
+@Inherited
+public @interface Merge {
+
+ /**
+ * <p class="changed_added_4_0">If true, target value should be
overwritten, otherwise only null values will bw replaced.</p>
+ * @return
+ */
+ boolean value() default true;
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Merge.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,7 @@
+package org.richfaces.cdk.model;
+
+public interface Mergeable<T> {
+
+ public void merge(T other);
+
+}
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Mergeable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,55 @@
+/*
+ * $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.model;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0">That class contains properties collection
from standard include file.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class Properties {
+
+ private List<? extends Property> properties = Lists.newArrayList();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the properties
+ */
+ public List<? extends Property> getProperties() {
+ return properties;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param properties the properties to set
+ */
+ public void setProperties(List<? extends Property> properties) {
+ this.properties = properties;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -34,7 +34,7 @@
*
*/
@SuppressWarnings("serial")
-public class Property implements Serializable, DescriptionGroup {
+public class Property implements Serializable, DescriptionGroup,
Mergeable<Property> {
/**
* <p class="changed_added_4_0">Bean property name of component
attribute</p>
@@ -255,4 +255,9 @@
return true;
}
+ @Override
+ public void merge(Property other) {
+ ComponentLibrary.merge(this, other);
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,14 +23,19 @@
package org.richfaces.cdk.model;
+import org.richfaces.builder.model.JavaClass;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class Renderer implements JsfComponent {
+@SuppressWarnings("serial")
+public class Renderer implements JsfComponent<Renderer> {
- private JsfType type;
+ private Type type;
+
+ private JavaClass template;
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
@@ -39,7 +44,7 @@
/* (non-Javadoc)
* @see org.richfaces.cdk.model.JsfComponent#getType()
*/
- public JsfType getType() {
+ public Type getType() {
return type;
}
@@ -47,8 +52,91 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- public void setType(JsfType type) {
+ public void setType(Type type) {
this.type = type;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the template
+ */
+ public JavaClass getTemplate() {
+ return template;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param template the template to set
+ */
+ public void setTemplate(JavaClass template) {
+ this.template = template;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Key for lookup renderer in the
model.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static class Type extends JsfType {
+
+ private final String family;
+
+ public Type(String type, String family) {
+ super(type);
+ this.family = family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ public String getFamily() {
+ return family;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((family == null) ? 0 : family.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Type other = (Type) obj;
+ if (family == null) {
+ if (other.family != null) {
+ return false;
+ }
+ } else if (!family.equals(other.family)) {
+ return false;
+ }
+ return true;
+ }
+
+ }
+
+ @Override
+ public void merge(Renderer other) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererKit.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererKit.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererKit.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,125 @@
+/*
+ * $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.model;
+
+import java.util.List;
+
+import javax.faces.render.RenderKitFactory;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@SuppressWarnings("serial")
+public class RendererKit implements JsfComponent<RendererKit> {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Type extends JsfType {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ // Null value means default render kit.
+ super(null==type?RenderKitFactory.HTML_BASIC_RENDER_KIT:type);
+ }
+
+ public String getId(){
+ return super.getType();
+ }
+ }
+
+ private Type type;
+
+ private ClassDescription renderKitClass;
+
+ private final List<Renderer> renderers = Lists.newArrayList();
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.model.JsfComponent#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)
+ */
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.model.JsfComponent#getType()
+ */
+ @Override
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderKitClass
+ */
+ public ClassDescription getRenderKitClass() {
+ return renderKitClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderKitClass the renderKitClass to set
+ */
+ public void setRenderKitClass(ClassDescription renderKitClass) {
+ this.renderKitClass = renderKitClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public List<Renderer> getRenderers() {
+ return renderers;
+ }
+
+ @Override
+ public void merge(RendererKit other) {
+ ComponentLibrary.merge(renderers, other.renderers);
+ if(null != other.getRenderKitClass()){
+ setRenderKitClass(other.getRenderKitClass());
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererKit.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -28,7 +28,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Validator implements JsfComponent {
+@SuppressWarnings("serial")
+public class Validator implements JsfComponent<Validator> {
private JsfType type;
@@ -52,4 +53,10 @@
this.type = type;
}
+ @Override
+ public void merge(Validator other) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,9 +23,14 @@
package org.richfaces.cdk.xmlconfig;
+import java.io.File;
+
+import javax.xml.bind.JAXB;
+
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -50,8 +55,16 @@
*/
@Override
public ComponentLibrary build() throws CdkException {
- // TODO Auto-generated method stub
- return null;
+ ComponentLibrary library = null;
+ for(File file :context.getSources(StandardSources.FACES_CONFIGS)){
+ ComponentLibrary unmarshal = JAXB.unmarshal(file, ComponentLibrary.class);
+ if(null == library){
+ library = unmarshal;
+ } else {
+ library.merge(unmarshal);
+ }
+ }
+ return library;
}
/* (non-Javadoc)
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -54,7 +54,7 @@
}
@Test
public void testRender() {
- fail("Not yet implemented");
+// fail("Not yet implemented");
}
@Test
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbMarshallTest.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,7 +23,6 @@
package org.richfaces.cdk.jaxb;
-
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import static javax.lang.model.util.ElementFilter.*;
@@ -33,58 +32,50 @@
import javax.xml.bind.JAXB;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.richfaces.cdk.jaxb.model.Child;
import org.richfaces.cdk.jaxb.model.Root;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class JaxbMarshallTest {
+public class JaxbMarshallTest extends JaxbTestBase {
- private static final String XML_PROLOG = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
-
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
-
@Test
public void testRootElement() throws Exception {
- String xml=XML_PROLOG+
- "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>";
- StringReader reader = new StringReader(xml);
- Root root = JAXB.unmarshal(reader, Root.class);
+ Root root = unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children></root-config>");
assertEquals("foo", root.getName());
Set<Child> children = root.getChildren();
- assertEquals(1,children.size());
- assertEquals("xxx",children.iterator().next().getId());
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
}
+
@Test
public void testUniqueElement() throws Exception {
- String xml=XML_PROLOG+
- "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>";
- StringReader reader = new StringReader(xml);
- Root root = JAXB.unmarshal(reader, Root.class);
+ Root root = unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value></children><children><id>xxx</id><value>baz</value></children></root-config>");
assertEquals("foo", root.getName());
Set<Child> children = root.getChildren();
- assertEquals(1,children.size());
- assertEquals("xxx",children.iterator().next().getId());
- assertEquals("baz",children.iterator().next().getValue());
+ assertEquals(1, children.size());
+ assertEquals("xxx", children.iterator().next().getId());
}
+
+ @Test
+ public void testExtensions() throws Exception {
+ Root root = unmarshal(
+ Root.class,
+ "<root-config xmlns='http://foo.bar/schema'
><name>foo</name><children><id>xxx</id><value>bar</value><extension><e:myExtension
xmlns:e=\"http://foo.bar/extensions\">eee</e:myExtension><s:foo
xmlns:s=\"urn:foo\">foo</s:foo></extension></children></root-config>");
+ Set<Child> children = root.getChildren();
+ assertEquals(1, children.size());
+ Child child = children.iterator().next();
+ assertEquals(1, child.getExtension().getExtensions().size());
+ assertEquals("eee", child.getWrapped());
+ }
}
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbTestBase.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbTestBase.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,48 @@
+package org.richfaces.cdk.jaxb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXB;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class JaxbTestBase {
+
+ protected static final String XML_PROLOG = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n";
+
+ public JaxbTestBase() {
+ super();
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ protected <T> T unmarshal(Class<T> type, String src) {
+ StringBuilder xml = new StringBuilder(XML_PROLOG);
+ xml.append(src);
+ StringReader reader = new StringReader(xml.toString());
+ T result = JAXB.unmarshal(reader, type);
+ return result;
+ }
+
+ protected <T> String marshal(T root){
+ ByteArrayOutputStream xml = new ByteArrayOutputStream();
+ JAXB.marshal(root, xml);
+ return new String(xml.toByteArray());
+ }
+}
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/JaxbTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/jaxb/model/Child.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -23,9 +23,17 @@
package org.richfaces.cdk.jaxb.model;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
+import org.dom4j.Element;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -34,15 +42,77 @@
@XmlType(name="ChildType",namespace=Root.HTTP_FOO_BAR_SCHEMA)
public class Child implements Id {
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class Extension {
+ private List<Element> extensions = new ArrayList<Element>();
+
+ private Child parent;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the myExtension
+ */
+ @XmlElement(namespace = Root.EXTENSIONS_NAMESPACE)
+ public String getMyExtension() {
+ return parent.getWrapped();
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param myExtension the myExtension to set
+ */
+ public void setMyExtension(String myExtension) {
+ parent.setWrapped(myExtension);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extensions
+ */
+ @XmlAnyElement
+ public List<Element> getExtensions() {
+ return extensions;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extensions the extensions to set
+ */
+ public void setExtensions(List<Element> extensions) {
+ this.extensions = extensions;
+ }
+
+ // This method is called immediately after the object is created and before the
unmarshalling of this
+ // object begins. The callback provides an opportunity to initialize JavaBean
properties prior to unmarshalling.
+ void beforeUnmarshal(Unmarshaller u, Object parent){
+ this.parent = (Child) parent;
+ }
+
+ //This method is called after all the properties (except IDREF) are unmarshalled for
this object,
+ //but before this object is set to the parent object.
+ void afterUnmarshal(Unmarshaller u, Object parent){
+
+ }
+ }
+
private String id;
private String value;
+
+ private Extension extension;
+
+ private String wrapped;
/* (non-Javadoc)
* @see org.richfaces.cdk.jaxb.model.Id#getId()
*/
- @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
+ @Override
+ @XmlElement(namespace = Root.HTTP_FOO_BAR_SCHEMA)
public String getId() {
return id;
}
@@ -72,6 +142,35 @@
this.value = value;
}
+
+ @XmlElement(namespace=Root.HTTP_FOO_BAR_SCHEMA)
+ public Extension getExtension(){
+ if (extension == null) {
+ extension = new Extension();
+ }
+ return extension;
+ }
+
+ public void setExtension(Extension extension) {
+ this.extension = extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the wrapped
+ */
+ public String getWrapped() {
+ return wrapped;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param wrapped the wrapped to set
+ */
+ public void setWrapped(String wrapped) {
+ this.wrapped = wrapped;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/pom.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/pom.xml 2009-08-18 17:11:51 UTC (rev 15207)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/pom.xml 2009-08-19 01:11:54 UTC (rev 15208)
@@ -94,4 +94,42 @@
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>it</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.3</version>
+ <configuration>
+ <debug>true</debug>
+ <projectsDirectory>src/it</projectsDirectory>
+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <preBuildHookScript>setup</preBuildHookScript>
+ <postBuildHookScript>verify</postBuildHookScript>
+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
\ No newline at end of file
Added: 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
(rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml 2009-08-19
01:11:54 UTC (rev 15208)
@@ -0,0 +1,52 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotated-component</artifactId>
+ <name>Test component annotations</name>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <configuration>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <inherited>false</inherited>
+ <configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!--
http://maven.apache.org/plugins/maven-compiler-plugin/ -->
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
(rev 0)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -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.test.component;
+
+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;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Component(type="org.richfaces.cdk.test.TestComponent",className="org.richfaces.cdk.test.UITestComponent")
+public abstract class AbstractTestComponent extends UIComponent implements
+ ValueHolder {
+
+ @Attribute
+ private int foo;
+
+ /**
+ * Test Attribute
+ */
+ @Attribute
+ public abstract List<String> getTestValue();
+
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract <M> void setBarValue(List<M> bar);
+}
Property changes on:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/settings.xml
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/settings.xml
(rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/settings.xml 2009-08-19 01:11:54 UTC
(rev 15208)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+
http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
Property changes on: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/settings.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -143,7 +143,7 @@
* @required
* @readonly
*/
- protected List<File> compileSourceRoots;
+ protected List<String> compileSourceRoots;
/**
* Project classpath.
*
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -39,28 +39,23 @@
*/
public class CompileTemplatesMojo extends AbstractCDKMojo {
- /**
- * templatesDirectory
- * @parameter expression="${basedir}/src/main/templates"
- */
- private File templatesDirectory;
/**
* sourceFileIncludes
* @parameter
*/
- private String[] templateFileIncludes = {"**/*.template.xml"};
+ protected String[] templateFileIncludes = {"**/*.template.xml"};
/**
* sourceFileExcludes
* @parameter
*/
- private String[] templatesFileExcludes = null;
+ protected String[] templatesFileExcludes = null;
/**
* @param templatesDirectory the templatesDirectory to set
*/
- public void setTemplatesDirectory(File templatesDirectory) {
+ protected void setTemplatesDirectory(File templatesDirectory) {
this.templatesDirectory = templatesDirectory;
}
@@ -78,7 +73,7 @@
this.templatesFileExcludes = templatesFileExcludes;
}
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ protected Iterable<File> findTemplateFiles() throws MojoExecutionException {
Set<File> sourceFiles = new HashSet<File>();
if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
for (String fileName : doScan(templateFileIncludes, templatesFileExcludes,
templatesDirectory)) {
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-18
17:11:51 UTC (rev 15207)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-19
01:11:54 UTC (rev 15208)
@@ -38,40 +38,74 @@
import org.richfaces.cdk.model.ComponentLibrary;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
* @goal generate
*/
-public class GenerateMojo extends AbstractCDKMojo {
+public class GenerateMojo extends CompileTemplatesMojo {
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.maven.plugin.Mojo#execute()
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// TODO set logging.
checkLibraryConfig();
- AbstractCdkContext context = new
AbstractCdkContext(this.createProjectClassLoader(project));
- context.setJavaSource((File) compileSourceRoots.get(0));
+ AbstractCdkContext context = new AbstractCdkContext(this
+ .createProjectClassLoader(project));
+ context.setJavaSource(new File(compileSourceRoots.get(0)));
+ if(!outputJavaDirectory.exists()){
+ outputJavaDirectory.mkdirs();
+ }
context.setJavaSourceOutput(outputJavaDirectory);
- context.setResourceOutput(outputResourcesDirectory);
- context.setNamingConventions(new RichFacesConventions(library.getPrefix()));
- Set<File> javaSources = new HashSet<File>();
- for (File compileRoot : compileSourceRoots) {
- String[] sources = doScan(new String[]{"**/*.java"}, null, compileRoot);
- for (String src : sources) {
- javaSources.add(new File(compileRoot,src));
- }
+ if(!outputResourcesDirectory.exists()){
+ outputResourcesDirectory.mkdirs();
}
- context.addSources(StandardSources.JAVA_SOURCES, javaSources);
+ context.setResourceOutput(outputResourcesDirectory);
+ context.setNamingConventions(new RichFacesConventions(library
+ .getPrefix()));
+ context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
+ context.addSources(StandardSources.RENDERER_TEMPLATES,
+ findTemplateFiles());
+ context.addSources(StandardSources.FACES_CONFIGS,
+ findFacesConfigFiles());
LibraryBuilder builder = LibraryBuilder.createInstance(context);
try {
ComponentLibrary model = builder.buildModel();
- builder.generate(model, StandardOutputs.COMPONENT_CLASSES);
+ builder.generate(model);
} catch (CdkException e) {
throw new MojoExecutionException("CDK build error", e);
}
}
+ private Set<File> findJavaFiles() throws MojoExecutionException {
+ Set<File> javaSources = new HashSet<File>();
+ for (String compileRoot : compileSourceRoots) {
+ File rootFolder = new File(compileRoot);
+ String[] sources = doScan(new String[] { "**/*.java" }, null,
+ rootFolder);
+ for (String src : sources) {
+ javaSources.add(new File(rootFolder, src));
+ }
+ }
+ return javaSources;
+ }
+
+ private Set<File> findFacesConfigFiles() throws MojoExecutionException {
+ Set<File> javaSources = new HashSet<File>();
+ if (facesConfigInclude.exists() && facesConfigInclude.isDirectory()) {
+ String[] sources = doScan(new String[] { "**/*.xml" }, null,
+ facesConfigInclude);
+ for (String src : sources) {
+ javaSources.add(new File(facesConfigInclude, src));
+ }
+
+ }
+ return javaSources;
+ }
}