Author: alexsmirnov
Date: 2009-08-21 20:42:50 -0400 (Fri, 21 Aug 2009)
New Revision: 15269
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
Modified:
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/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/ModelBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.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/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/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.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/xmlconfig/CdkResolverTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
faces-config.xml parser implemented.
Modified:
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 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/templates/RendererClassGenerator.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -32,6 +32,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Renderer;
import org.richfaces.cdk.model.RenderKit;
@@ -65,7 +66,7 @@
JavaClass javaClass = renderer.getTemplate();
String fullName = javaClass.getFullName();
- File outFile = new File(context.getJavaSourceOutput(),
+ File outFile = new File(context.getOutputFolder(StandardOutputs.RENDERER_CLASSES),
fullName.replace('.', '/') + ".java");
if (outFile.exists()) {
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -43,73 +43,16 @@
private final ClassLoader loader;
- private File javaSource;
-
- private File javaSourceOutput;
-
- private File resourceOutput;
-
- private NamingConventions namingConventions;
-
private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
private Map<OutputType,File> outputs = Maps.newHashMap();
- private Map<SourceType,File> inputFolders = Maps.newHashMap();
+ private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
+ private Map<Class<? extends CdkWorker>,CdkWorker> workers =
Maps.newHashMap();
+
private List<CdkError> errors = Lists.newArrayList();
- /**
- * <p class="changed_added_4_0"></p>
- * @return the javaSource
- */
- @Override
- public File getJavaSource() {
- return javaSource;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaSource the javaSource to set
- */
- public void setJavaSource(File javaSource) {
- this.javaSource = javaSource;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the javaSourceOutput
- */
- @Override
- public File getJavaSourceOutput() {
- return javaSourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaSourceOutput the javaSourceOutput to set
- */
- public void setJavaSourceOutput(File javaSourceOutput) {
- this.javaSourceOutput = javaSourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the resourceOutput
- */
- @Override
- public File getResourceOutput() {
- return resourceOutput;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param resourceOutput the resourceOutput to set
- */
- public void setResourceOutput(File resourceOutput) {
- this.resourceOutput = resourceOutput;
- }
-
public AbstractCdkContext(ClassLoader loader) {
this.loader = loader;
// TODO Auto-generated constructor stub
@@ -122,23 +65,6 @@
return loader;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the namingConventions
- */
- @Override
- public NamingConventions getNamingConventions() {
- return namingConventions;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param namingConventions the namingConventions to set
- */
- public void setNamingConventions(NamingConventions namingConventions) {
- this.namingConventions = namingConventions;
- }
-
public void addSources(SourceType type,Iterable<File> files) {
sources.put(type, files);
}
@@ -154,15 +80,53 @@
return outputFolder;
}
+
+ public void setOutputFolder(OutputType type, File folder) {
+ outputs.put(type, folder);
+ }
+
@Override
public void sendError(CdkError error) {
errors.add(error);
}
+
+ @Override
+ public Iterable<CdkError> getErrors() {
+ return errors;
+ }
+
@Override
- public File getSourceFolder(SourceType type) {
+ public Iterable<File> getSourceFolders(SourceType type) {
return inputFolders.get(type);
}
+
+ public void setSourceFolders(SourceType type, Iterable<File> folders){
+ inputFolders.put(type, folders);
+ }
+ @Override
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
+ throws CdkException {
+ CdkWorker worker = workers.get(workerClass);
+ if(null == worker){
+ // TODO - instantiate worker.
+ try {
+ worker = workerClass.newInstance();
+ worker.init(this);
+ workers.put(workerClass, worker);
+ } catch (InstantiationException e) {
+ throw new CdkException("error to instantiate cdk component
"+workerClass.getName(), e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("Illegal access to cdk component
"+workerClass.getName(), e);
+ }
+ }
+ return (W) worker;
+ }
+
+
+ public <W extends CdkWorker> void addWorker(Class<W> workerClass, W worker)
{
+ workers.put(workerClass, worker);
+ }
}
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -35,39 +35,6 @@
public ClassLoader getLoader();
/**
- * <p class="changed_added_4_0">
- * Output folder for generated resources.
- * </p>
- *
- * @return
- */
- public abstract File getResourceOutput();
-
- /**
- * <p class="changed_added_4_0">
- * Output folder for generated Java sources.
- * </p>
- *
- * @return
- */
- public abstract File getJavaSourceOutput();
-
- /**
- * <p class="changed_added_4_0">
- * Java source folder.
- * </p>
- *
- * @return
- */
- public abstract File getJavaSource();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return
- */
- public NamingConventions getNamingConventions();
-
- /**
* <p class="changed_added_4_0">Get all sources for given
type.</p>
* @param type
* @return
@@ -76,13 +43,34 @@
/**
* <p class="changed_added_4_0">Provides default output folder for given
output type.</p>
+ * TODO - define "output families" to group similar outputs ( classes,
resources, tests ... ).
* @param type of output
* @return output folder for requested type.
*/
public File getOutputFolder(OutputType type);
+ /**
+ * <p class="changed_added_4_0">Record recowerable CdkError. To avoid
consequence builds of the project with many errors, all non-fatal errors ( Java
compilation errors, incorrect xml fales, inconsistent component descriptions ) these error
are stored in the context and marks whole build failed.</p>
+ * @param error
+ */
public void sendError(CdkError error);
- public File getSourceFolder(SourceType type);
+ public abstract Iterable<CdkError> getErrors();
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ * @return
+ */
+ public Iterable<File> getSourceFolders(SourceType type);
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param <W>
+ * @param workerClass
+ * @return
+ * @throws CdkException
+ */
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
throws CdkException;
+
}
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,36 @@
+/*
+ * $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;
+
+/**
+ * <p class="changed_added_4_0">Interface for all CDK worker objects (
parsers, validators, renderers etc. ).
+ * Instances of these objects are stored in the {@link CdkContext}</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CdkWorker {
+
+ public void init(CdkContext context) throws CdkException;
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -45,14 +45,14 @@
* @author asmirnov(a)exadel.com
*
*/
-public final class LibraryBuilder {
+public final class LibraryBuilder implements CdkWorker {
/**
* <p class="changed_added_4_0">
* Current CDK context
* </p>
*/
- private final CdkContext context;
+ private CdkContext context;
/**
* <p class="changed_added_4_0">
@@ -60,7 +60,12 @@
*
* @param context
*/
- LibraryBuilder(CdkContext context) {
+ public LibraryBuilder() {
+
+ }
+
+ @Override
+ public void init(CdkContext context) throws CdkException {
this.context = context;
}
@@ -70,9 +75,10 @@
* </p>
*
* @return
+ * @throws CdkException
*/
- public static LibraryBuilder createInstance(CdkContext context) {
- return new LibraryBuilder(context);
+ public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
+ return context.getWorkerInstance(LibraryBuilder.class);
}
/**
@@ -194,8 +200,7 @@
return builder;
}
- protected ModelValidator getVerifier() {
- // TODO - put verifier implementation into context ?
- return new ValidatorImpl(getContext());
+ protected ModelValidator getVerifier() throws CdkException {
+ return getContext().getWorkerInstance(ModelValidator.class);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -30,13 +30,14 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelBuilder {
+public interface ModelBuilder extends CdkWorker {
/**
* <p class="changed_added_4_0">Initialize builder.</p>
* @param context
+ * @throws CdkException
*/
- public void init(CdkContext context);
+ public void init(CdkContext context) throws CdkException;
/**
* <p class="changed_added_4_0">Build library model.</p>
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelValidator {
+public interface ModelValidator extends CdkWorker {
/**
* <p class="changed_added_4_0">Perform verify procedure on the library
model.</p>
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -38,7 +38,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface NamingConventions {
+public interface NamingConventions extends CdkWorker {
/**
* <p class="changed_added_4_0">Calculates component type from explicit
value or base class name.</p>
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -25,6 +25,7 @@
* </p>
*/
private final String baseName;
+ private CdkContext context;
/**
@@ -36,6 +37,12 @@
}
+ @Override
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ }
+
+
private final String[] COMPONENT_SUFFIXES = { BASE };
private final String[] COMPONENT_PREFIXES = { UI, ABSTRACT };
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -39,10 +39,13 @@
*/
public class ValidatorImpl implements ModelValidator {
- private final CdkContext context;
+ private CdkContext context;
+
+ private NamingConventions namingConventions;
- public ValidatorImpl(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
+ this.namingConventions = context.getWorkerInstance(NamingConventions.class);
}
/* (non-Javadoc)
@@ -90,7 +93,7 @@
}
private NamingConventions getNamingConventions() {
- return context.getNamingConventions();
+ return namingConventions;
}
protected void compact(Collection<?> collection) {
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -47,6 +47,7 @@
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -112,13 +113,18 @@
log.info("Compiler classpath:" + classPathOption);
}
- if(null != context.getJavaSource()){
+ Iterable<File> sourceFolders =
context.getSourceFolders(StandardSources.JAVA_SOURCES);
+ File javaSource;
+ if(null != sourceFolders && sourceFolders.iterator().hasNext()){
options.add("-sourcepath");
- options.add(context.getJavaSource().getAbsolutePath());
+ javaSource = sourceFolders.iterator().next();
+ options.add(javaSource.getAbsolutePath());
+ } else {
+ javaSource = null;
}
- if(null != context.getJavaSourceOutput() ){
+ if(null != context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES)){
options.add("-s");
- options.add(context.getJavaSourceOutput().getAbsolutePath());
+ options.add(context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES).getAbsolutePath());
}
setOptions(options);
// TODO - provide source files locale.
@@ -129,7 +135,7 @@
// TODO - use standard file manager for all tasks.
VirtualFileManager fileManager = new VirtualFileManager(stdFileManager,
context.getLoader());
- fileManager.setJavaSourceDirectory(context.getJavaSource());
+ fileManager.setJavaSourceDirectory(javaSource);
setFileManager(fileManager);
initialized = true;
}
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -44,6 +44,8 @@
import javax.lang.model.util.ElementFilter;
import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
@@ -283,5 +285,9 @@
}
return properties;
}
+
+ protected NamingConventions getNamingConventions() throws CdkException {
+ return getContext().getWorkerInstance(NamingConventions.class);
+ }
}
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -58,16 +58,19 @@
public class ComponentProcessor extends CdkProcessor {
private final ComponentLibrary library;
+ private FragmentParser fragmentParser;
/**
* <p class="changed_added_4_0">
* </p>
*
* @param context
+ * @throws CdkException
*/
- public ComponentProcessor(CdkContext context, ComponentLibrary library) {
+ public ComponentProcessor(CdkContext context, ComponentLibrary library) throws
CdkException {
super(context);
this.library = library;
+ fragmentParser = FragmentParser.getInstance(context);
}
/*
@@ -91,7 +94,7 @@
Component componentAnnotation = componentElement
.getAnnotation(Component.class);
// Because component type is a primary key for components collection, we have to
infer explicit value here.
- String type =
getContext().getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
+ String type =
getNamingConventions().inferComponentType(componentAnnotation.value(),componentElement.getQualifiedName().toString());
org.richfaces.cdk.model.Component component = library.findOrCreateComponent(type);
// Should that component be generated ?
setClassNames(componentElement, component);
@@ -201,8 +204,7 @@
String[] includes = attributes.value();
for (String attributesConfig : includes) {
// process additional properties.
- FragmentParser parser = new FragmentParser(getContext());
- component.getAttributes().addAll(parser.parseProperties(attributesConfig));
+ component.getAttributes().addAll(fragmentParser.parseProperties(attributesConfig));
}
}
// TODO - Process standard information for parent classes
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -64,7 +65,7 @@
@Override
protected String getOutputFile(Component c) throws IOException {
- File sourceOutput = getContext().getJavaSourceOutput();
+ File sourceOutput = getContext().getOutputFolder(StandardOutputs.COMPONENT_CLASSES);
File outputFile = new
File(sourceOutput,c.getComponentClass().getName().replace('.',
File.separatorChar)+".java");
if(!outputFile.exists()){
outputFile.getParentFile().mkdirs();
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -49,15 +49,12 @@
*/
public class CdkEntityResolver implements EntityResolver2 {
- // configure a validating SAX2.0 parser (Xerces2)
- public static final String JAXP_SCHEMA_LANGUAGE =
- "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- public static final String JAXP_SCHEMA_LOCATION =
- "http://java.sun.com/xml/jaxp/properties/schemaSource";
- public static final String W3C_XML_SCHEMA =
- "http://www.w3.org/2001/XMLSchema";
+ // configure a validating SAX2.0 parser (Xerces2)
+ public static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ public static final String JAXP_SCHEMA_LOCATION =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
+ public static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
- private static final String URN_SYSTEM = "urn:system:";
+ private static final String URN_SYSTEM = "urn:system:";
private static final ImmutableMap<String, String> systemEntities = ImmutableMap
.<String, String> builder()
@@ -132,11 +129,11 @@
@Override
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException {
- InputSource entity = null;
+ InputSource entity = null;
if (null != systemId) {
entity = resolveSystemId(systemId);
} else {
- //TODO - check publicId
+ // TODO - check publicId
}
return entity;
}
@@ -168,7 +165,8 @@
}
} else if (systemId.startsWith(URN_ATTRIBUTES)) {
- // Standard attributes. Look for them in the satndard place via project classloader.
+ // Standard attributes. Look for them in the satndard place via
+ // project classloader.
String path = systemId.substring(URN_ATTRIBUTES.length());
InputStream inputStream = getContext().getLoader()
.getResourceAsStream(ATTRIBUTES_PREFIX + path);
@@ -183,20 +181,24 @@
} else if (systemId.startsWith(URN_TEMPLATES)) {
// Templates folder.
String path = systemId.substring(URN_TEMPLATES.length());
- entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES, path);
+ entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES,
+ path);
}
return entity;
}
protected InputSource getProjectInputSource(SourceType type, String path)
throws FileNotFoundException {
- File folder = getContext().getSourceFolder(type);
+ Iterable<File> folders = getContext().getSourceFolders(type);
InputSource entity = null;
- if(null != folder && folder.exists() && folder.isDirectory()){
- File configFile = new File(folder,path);
- if(configFile.exists()){
- InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
+ for (File folder : folders) {
+ if (folder.exists() && folder.isDirectory()) {
+ File configFile = new File(folder, path);
+ if (configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
+ entity = new InputSource(inputStream);
+ break;
+ }
}
}
return entity;
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -32,6 +32,7 @@
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
/**
* <p class="changed_added_4_0"></p>
@@ -41,6 +42,7 @@
public class FacesConfigParser implements ModelBuilder {
private CdkContext context;
+ private JAXBBinding jaxbBinding;
/**
* <p class="changed_added_4_0"></p>
@@ -55,24 +57,31 @@
*/
@Override
public ComponentLibrary build() throws CdkException {
- ComponentLibrary library = null;
+ ComponentLibrary library = new ComponentLibrary();
for(File file :context.getSources(StandardSources.FACES_CONFIGS)){
- ComponentLibrary unmarshal = JAXB.unmarshal(file, ComponentLibrary.class);
- if(null == library){
- library = unmarshal;
- } else {
- library.merge(unmarshal);
- }
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
+ library.getComponents().addAll(unmarshal.getComponents());
+ // TODO - merge changes into library.
+// library.getRenderers().addAll(unmarshal.getRenderers());
+// library.getValidators().addAll(unmarshal.getValidators);
+// library.getConverters().addAll(unmarshal.getConverters());
+// library.getBehaviors().addAll(unmarshal.getBehaviors());
+// library.setExtensions(unmarshal.getExtensions());
}
return library;
}
+ protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
+ return jaxbBinding.unmarshal(file,
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,FacesConfigBean.class);
+ }
+
/* (non-Javadoc)
* @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
*/
@Override
- public void init(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
+ jaxbBinding = JAXBBinding.getInstance(context);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -23,29 +23,14 @@
package org.richfaces.cdk.xmlconfig;
-import java.io.FileNotFoundException;
import java.util.Collection;
import java.util.Collections;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.sax.SAXSource;
-
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.model.Properties;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
/**
* <p class="changed_added_4_0">
@@ -59,18 +44,28 @@
public class FragmentParser {
private CdkContext context;
+ private JAXBBinding binding;
- private CdkEntityResolver resolver;
+ public static FragmentParser getInstance(CdkContext context) throws CdkException{
+ FragmentParser parser = new FragmentParser();
+ parser.init(context);
+ return parser;
+ }
+
+ protected FragmentParser() {
+ // TODO Auto-generated constructor stub
+ }
/**
* <p class="changed_added_4_0">
* </p>
*
* @param context
+ * @throws CdkException
*/
- public FragmentParser(CdkContext context) {
+ public void init(CdkContext context) throws CdkException {
this.context = context;
- this.resolver = new CdkEntityResolver(context);
+ binding = JAXBBinding.getInstance(context);
}
/**
@@ -82,53 +77,10 @@
* @return
*/
public Collection<Property> parseProperties(String url) throws CdkException {
- SAXParserFactory spf =
SAXParserFactory.newInstance("org.apache.xerces.jaxp.SAXParserFactoryImpl",FragmentParser.class.getClassLoader());
- spf.setNamespaceAware(true);
- spf.setValidating(true);
- try {
-
spf.setFeature("http://apache.org/xml/features/validation/schema", true);
-
spf.setFeature("http://apache.org/xml/features/xinclude", true);
-
spf.setFeature("http://apache.org/xml/features/xinclude/fixup-base-u...;,
false);
- SAXParser saxParser = spf.newSAXParser();
- try {
- saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LANGUAGE,
- CdkEntityResolver.W3C_XML_SCHEMA);
- saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LOCATION,
- ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
-
- } catch (SAXNotRecognizedException x) {
- // exception handling omitted
- } catch (SAXNotSupportedException e) {
- throw new CdkException(e);
- }
-
- XMLReader xmlReader = saxParser.getXMLReader();
- xmlReader.setEntityResolver(resolver);
- SAXSource source = new SAXSource(xmlReader, resolver.resolveSystemId(url));
-
- // Setup JAXB to unmarshal
- JAXBContext jc = JAXBContext.newInstance(Properties.class);
- Unmarshaller u = jc.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
- u.setEventHandler(vec);
-
- // turn off the JAXB provider's default validation mechanism to
- // avoid duplicate validation
-// u.setValidating(false);
- Properties unmarshal = (Properties) u.unmarshal(source);
- return unmarshal.getProperty();
- } catch(SAXException e){
-
- } catch (ParserConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (JAXBException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return Collections.emptySet();
+ String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ Class<Properties> bindClass = Properties.class;
+ Properties unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
+ return null ==
unmarshal?Collections.<Property>emptySet():unmarshal.getProperty();
}
+
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,225 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.XMLReader;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class JAXBBinding {
+
+ private CdkContext context;
+
+ private CdkEntityResolver resolver;
+
+ private SAXParserFactory spf;
+
+ /**
+ * <p class="changed_added_4_0">
+ * Factory method for binding instance.
+ * </p>
+ *
+ * @param context
+ * @return
+ * @throws CdkException
+ */
+ public static JAXBBinding getInstance(CdkContext context)
+ throws CdkException {
+ JAXBBinding jaxbBinding = new JAXBBinding();
+ jaxbBinding.init(context);
+ return jaxbBinding;
+ }
+
+ protected JAXBBinding() {
+
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param context
+ */
+ public void init(CdkContext context) throws CdkException {
+ this.context = context;
+ this.resolver = new CdkEntityResolver(context);
+ spf = createParserFactory(context);
+ }
+
+ private SAXParserFactory createParserFactory(CdkContext context)
+ throws CdkException {
+ SAXParserFactory spf = SAXParserFactory.newInstance(
+ "org.apache.xerces.jaxp.SAXParserFactoryImpl",
+ FragmentParser.class.getClassLoader());
+ spf.setNamespaceAware(true);
+ spf.setValidating(true);
+ try {
+
spf.setFeature("http://apache.org/xml/features/validation/schema",
+ true);
+
spf.setFeature("http://apache.org/xml/features/xinclude", true);
+ spf.setFeature(
+ "http://apache.org/xml/features/xinclude/fixup-base-uris",
+ false);
+ } catch (ParserConfigurationException e) {
+ throw new CdkException(
+ "parser does not support desired configuration", e);
+ } catch (SAXNotRecognizedException e) {
+ throw new CdkException("parser does not recofnize property", e);
+ } catch (SAXNotSupportedException e) {
+ throw new CdkException("parser feature does not supported", e);
+ }
+ return spf;
+ }
+
+ public <T> T unmarshal(File file,
+ String schemaLocation, Class<T> bindClass) throws CdkException {
+ try {
+ InputSource input = new InputSource(new FileInputStream(file));
+ T unmarshal = unmarshal(schemaLocation, bindClass, input);
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found",e);
+ }
+ }
+
+ public <T> T unmarshal(String url, String schemaLocation,
+ Class<T> bindClass) throws CdkException {
+ try {
+ InputSource inputSource = resolver.resolveSystemId(url);
+ if(null == inputSource){
+ inputSource = new InputSource(url);
+ }
+ T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
+ return unmarshal;
+ } catch (FileNotFoundException e) {
+ throw new CdkException("XML file not found",e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T unmarshal(String schemaLocation, Class<T> bindClass,
+ InputSource inputSource) throws CdkException {
+ T unmarshal = null;
+ Source source = createXmlSource(inputSource, schemaLocation);
+ try {
+ // Setup JAXB to unmarshal
+ JAXBContext jc = JAXBContext.newInstance(bindClass);
+ Unmarshaller u = jc.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ u.setEventHandler(vec);
+
+ // turn off the JAXB provider's default validation mechanism to
+ // avoid duplicate validation
+ // u.setValidating(false);
+ unmarshal = (T) u.unmarshal(source);
+ } catch (JAXBException e) {
+ throw new CdkException("JAXB Unmarshaller error", e);
+ } finally {
+ closeSource(source);
+ }
+ return unmarshal;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Close input source after parsing.
+ * </p>
+ *
+ * @param source
+ */
+ private void closeSource(Source source) {
+ if (source instanceof SAXSource) {
+ SAXSource saxSource = (SAXSource) source;
+ InputSource inputSource = saxSource.getInputSource();
+ try {
+ Reader stream = inputSource.getCharacterStream();
+ if (null != stream) {
+ stream.close();
+ } else {
+ InputStream byteStream = inputSource.getByteStream();
+ if (null != byteStream) {
+ byteStream.close();
+ }
+ }
+ } catch (IOException e) {
+ // Can be ignored because source has already been read.
+ }
+ }
+ }
+
+ private Source createXmlSource(InputSource input, String schemaLocation)
+ throws CdkException {
+ try {
+ SAXParser saxParser = spf.newSAXParser();
+ if (null != schemaLocation) {
+ saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LANGUAGE,
+ CdkEntityResolver.W3C_XML_SCHEMA);
+ saxParser.setProperty(CdkEntityResolver.JAXP_SCHEMA_LOCATION,
+ schemaLocation);
+
+ }
+ XMLReader xmlReader = saxParser.getXMLReader();
+ xmlReader.setEntityResolver(resolver);
+ SAXSource source = new SAXSource(xmlReader, input);
+ return source;
+ } catch (SAXNotRecognizedException x) {
+ throw new CdkException(x);
+ } catch (SAXException e) {
+ throw new CdkException(e);
+ } catch (ParserConfigurationException e) {
+ throw new CdkException(e);
+ }
+
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ConfigExtension;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentAdapter extends XmlAdapter<ComponentBean, Component> {
+
+ @Override
+ public ComponentBean marshal(Component v) throws Exception {
+ ComponentBean bean = new ComponentBean();
+ bean.setType(v.getType().toString());
+ bean.setClassName(v.getComponentClass().getName());
+ bean.getAttributes().addAll(v.getAttributes());
+ ComponentBean.ComponentExtension extension = new ComponentBean.ComponentExtension();
+ extension.setFamily(v.getFamily());
+ ConfigExtension configExtension = v.getExtension();
+ if(null != configExtension){
+ extension.setExtensions(configExtension.getExtensions());
+ }
+ bean.setExtension(extension);
+ return bean;
+ }
+
+ @Override
+ public Component unmarshal(ComponentBean v) throws Exception {
+ Component component = new Component(new Component.Type(v.getType()));
+ component.setComponentClass(new ClassDescription(v.getClassName()));
+ component.getAttributes().addAll(v.getAttributes());
+ ConfigExtension extension = new ConfigExtension();
+ ComponentBean.ComponentExtension configExtension = v.getExtension();
+ if(null != configExtension){
+ component.setFamily(configExtension.getFamily());
+ extension.setExtensions(configExtension.getExtensions());
+ component.setExtension(extension);
+ }
+ return component;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,141 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.Property;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentBean {
+
+ private String type;
+
+ private String className;
+
+ private List<Property> attributes = Lists.newArrayList();
+
+ private ComponentExtension extension;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name="component-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the className
+ */
+ @XmlElement(name="component-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param className the className to set
+ */
+ public void setClassName(String className) {
+ this.className = className;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the attributes
+ */
+ @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),(a)XmlElement(name="attribute",type=PropertyBean.class)})
+// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public List<Property> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param attributes the attributes to set
+ */
+ public void setAttributes(List<Property> property) {
+ this.attributes = property;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name="component-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public ComponentExtension getExtension() {
+ return extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(ComponentExtension extension) {
+ this.extension = extension;
+ }
+
+ public static class ComponentExtension extends ConfigExtension {
+
+ private String family;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param family the family to set
+ */
+ public void setFamily(String family) {
+ this.family = family;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the family
+ */
+ @XmlElement(name="component-family",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public String getFamily() {
+ return family;
+ }
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FacesConfigAdapter extends XmlAdapter<FacesConfigBean,
ComponentLibrary> {
+
+ @Override
+ public FacesConfigBean marshal(ComponentLibrary v) throws Exception {
+ FacesConfigBean facesConfigBean = new FacesConfigBean();
+ return facesConfigBean;
+ }
+
+ @Override
+ public ComponentLibrary unmarshal(FacesConfigBean v) throws Exception {
+ ComponentLibrary library = new ComponentLibrary();
+ return library;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,64 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class FacesConfigBean {
+
+ @XmlElement(name="component",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ComponentAdapter.class)
+ private List<Component> components = Lists.newArrayList();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the components
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param components the components to set
+ */
+ public void setComponents(List<Component> components) {
+ this.components = components;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -49,7 +49,7 @@
* <p class="changed_added_4_0"></p>
* @return the property
*/
- @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class)/*,(a)XmlElement(name="attribute",type=Attribute.class)*/})
+ @XmlElements({@XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,type=PropertyBean.class),(a)XmlElement(name="attribute",type=PropertyBean.class)})
// @XmlElement(name="property",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public List<Property> getProperty() {
return property;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -9,12 +9,15 @@
location=ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION,
xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "cdk",
namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
-(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class)
+@XmlJavaTypeAdapters({(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class),
+ @XmlJavaTypeAdapter(type=ComponentLibrary.class,value=FacesConfigAdapter.class)
+ })
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -29,6 +29,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Collections;
import java.util.logging.LogManager;
import org.junit.After;
@@ -41,12 +42,12 @@
*/
public class CdkTestBase {
- protected File testSourceDirectory;
+ protected Iterable<File> testSourceDirectory;
@Before
public void setUpSourceDirectory() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
+ testSourceDirectory =
Collections.singleton(getJavaFile("test.source.properties")
+ .getParentFile());
InputStream stream = this.getClass().getResourceAsStream(
"logging.properties");
if (null != stream) {
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -46,6 +46,9 @@
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.apt.CdkProcessor.BeanProperty;
@@ -114,9 +117,8 @@
public void testProcess() 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.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation.class.getClassLoader());
replay(cdkContext);
@@ -153,9 +155,8 @@
public void testProcessSubClass() 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.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
@@ -198,9 +199,8 @@
public void testGetClassesAnnotatedWith() 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.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
@@ -239,9 +239,8 @@
public void testGetPropertiesAnnotatedWith() 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.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation2.class.getClassLoader());
replay(cdkContext);
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -42,6 +42,12 @@
import org.junit.Before;
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
@@ -57,7 +63,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ComponentProcessorTest {
+public class ComponentProcessorTest extends CdkTestBase {
private static final String INTERFACE_JAVA =
"org/richfaces/cdk/apt/TestInterface.java";
@@ -67,35 +73,7 @@
.of(TestAnnotation.class.getName());
private static final String COMPONENT_CLASS_JAVA =
"org/richfaces/cdk/test/component/AbstractTestComponent.java";
- private File testSourceDirectory;
- private ClassLoader testLoader;
- @Before
- public void setUp() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
-
- @After
- public void tearDown() {
- testSourceDirectory = null;
- }
-
/**
* Test method for
* {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)}
@@ -120,23 +98,16 @@
assertEquals(3, attributes.size());
}
- private CdkContext createMockContext() {
+ private CdkContext createMockContext() throws Exception {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
TestAnnotation.class.getClassLoader());
+ expect(cdkContext.getWorkerInstance(NamingConventions.class)).andStubReturn(new
RichFacesConventions("foo.bar"));
replay(cdkContext);
return cdkContext;
}
- private File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
}
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -18,41 +18,16 @@
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.TestAnnotation;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.Searchable;
import org.richfaces.cdk.model.Visitable;
-public class FreeMarkerRendererTest {
+public class FreeMarkerRendererTest extends CdkTestBase {
- private File testSourceDirectory;
- private ClassLoader testLoader;
-
- @Before
- public void setUp() throws Exception {
- testSourceDirectory = getJavaFile("test.source.properties")
- .getParentFile();
- InputStream stream = this.getClass().getResourceAsStream(
- "logging.properties");
- if (null != stream) {
- try {
- LogManager.getLogManager().readConfiguration(stream);
- } catch (Exception e) {
- // Ignore it.
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- // Ignore it.
- }
- }
- }
- }
-
- @After
- public void tearDown() {
- testSourceDirectory = null;
- }
@Test
public void testRender() {
// fail("Not yet implemented");
@@ -92,21 +67,13 @@
private CdkContext createMockContext() {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(
- testLoader);
+ FreeMarkerRendererTest.class.getClassLoader());
replay(cdkContext);
return cdkContext;
}
- private File getJavaFile(String name) throws URISyntaxException {
- ClassLoader classLoader = this.getClass().getClassLoader();
- URL testResource = classLoader.getResource(name);
- URI testUri = testResource.toURI();
- final File classFile = new File(testUri);
- return classFile;
- }
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -16,6 +16,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
import org.richfaces.cdk.apt.TestAnnotation2;
import org.xml.sax.InputSource;
@@ -71,16 +72,15 @@
private CdkContext createMockContext() {
CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getJavaSource()).andStubReturn(testSourceDirectory);
- expect(cdkContext.getJavaSourceOutput()).andStubReturn(null);
- expect(cdkContext.getResourceOutput()).andStubReturn(null);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
return cdkContext;
}
@Test
public void testGetProjectInputSource() throws Exception {
CdkContext cdkContext = createMockContext();
- expect(cdkContext.getSourceFolder(StandardSources.FACES_CONFIGS)).andReturn(this.testSourceDirectory);
+ expect(cdkContext.getSourceFolders(StandardSources.FACES_CONFIGS)).andStubReturn(testSourceDirectory);
replay(cdkContext);
CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
InputSource input = entityResolver.getProjectInputSource(StandardSources.FACES_CONFIGS,
"org/richfaces/cdk/apt/test.html");
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,61 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Test;
+import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
+
+import com.google.common.collect.Iterables;
+
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FacesConfigTest extends CdkTestBase {
+
+
+ @Test
+ public void testComponentUnmarshal() throws Exception {
+ JAXBBinding jaxbBinding = JAXBBinding.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ FacesConfigBean library =
jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
+ assertEquals(1,library.getComponents().size());
+ Component component = library.getComponents().get(0);
+ assertEquals("javax.faces.Panel", component.getType().toString());
+ assertEquals("javax.faces.Panel", component.getFamily());
+ assertEquals("javax.faces.component.UIPanel",
component.getComponentClass().getName());
+ Collection<Property> attributes = component.getAttributes();
+ assertEquals(10, attributes.size());
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-08-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -41,7 +41,7 @@
@Test
public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ FragmentParser parser = FragmentParser.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
assertEquals(3,properties.size());
}
Added:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml 2009-08-22
00:42:50 UTC (rev 15269)
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
+
xmlns:cdk="http://richfaces.org/cdk/extensions"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <component>
+ <component-type>javax.faces.Panel</component-type>
+ <component-class>javax.faces.component.UIPanel</component-class>
+
+ <property>
+ <description><![CDATA[
+ A mutable Map of the attributes associated with
+ this component, keyed by attribute name.
+ ]]></description>
+ <display-name>Attributes Map</display-name>
+ <icon />
+ <property-name>attributes</property-name>
+ <property-class>java.util.Map</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The number of child components associated with
+ this component.
+ ]]></description>
+ <display-name>Child Component Count</display-name>
+ <icon />
+ <property-name>childCount</property-name>
+ <property-class>int</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ A mutable List of the child components associated with
+ this component.
+ ]]></description>
+ <display-name>Child Component List</display-name>
+ <icon />
+ <property-name>children</property-name>
+ <property-class>java.util.List</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ A mutable Map of the facets associated with
+ this component, keyed by facet name.
+ ]]></description>
+ <display-name>Facets Map</display-name>
+ <icon />
+ <property-name>facets</property-name>
+ <property-class>java.util.Map</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The component family to which this component belongs. This property
+ is used to select an appropriate Renderer.
+ ]]></description>
+ <display-name>Component Family</display-name>
+ <icon />
+ <property-name>family</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ The component identifier for this component. This value must be
+ unique within the closest parent component that is a naming
+ container.
+ ]]></description>
+ <display-name>Component Identifier</display-name>
+ <icon />
+ <property-name>id</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description><![CDATA[
+ The parent component for this component. On the root component
+ in the component tree (which must be of type UIViewRoot), this
+ property is null.
+ ]]></description>
+ <display-name>Parent Component</display-name>
+ <icon />
+ <property-name>parent</property-name>
+ <property-class>javax.faces.component.UIComponent</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Flag indicating whether or not this component should be rendered
+ (during Render Response Phase), or processed on any subsequent
+ form submit. The default value for this property is true.
+ ]]></description>
+ <display-name>Rendered Flag</display-name>
+ <icon />
+ <property-name>rendered</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <value-expression-enabled>true</value-expression-enabled>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Identifier used (in conjunction with the "family" property) to
+ select an appropriate Renderer to encode and decode this component.
+ ]]></description>
+ <display-name>Renderer Type</display-name>
+ <icon />
+ <property-name>rendererType</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ </property-extension>
+ </property>
+ <property>
+ <description><![CDATA[
+ Flag indicating whether or not this component takes responsibility
+ for rendering its own children. This decision is normally delegated
+ to the associated Renderer, if there is one.
+ ]]></description>
+ <display-name>Renders Children</display-name>
+ <icon />
+ <property-name>rendersChildren</property-name>
+ <property-class>boolean</property-class>
+ <property-extension>
+ <tag-attribute>false</tag-attribute>
+ <read-only>true</read-only>
+ </property-extension>
+ </property>
+
+ <component-extension>
+ <cdk:component-family>javax.faces.Panel</cdk:component-family>
+ </component-extension>
+ </component>
+</faces-config>
\ No newline at end of file
Property changes on:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-21
18:45:20 UTC (rev 15268)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-22
00:42:50 UTC (rev 15269)
@@ -24,6 +24,7 @@
package org.richfaces.builder.mojo;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@@ -32,9 +33,12 @@
import org.richfaces.cdk.AbstractCdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.ModelValidator;
+import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.RichFacesConventions;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.ValidatorImpl;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -58,24 +62,37 @@
checkLibraryConfig();
AbstractCdkContext context = new AbstractCdkContext(this
.createProjectClassLoader(project));
- context.setJavaSource(new File(compileSourceRoots.get(0)));
+ ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
+ for (String sourceFolder : compileSourceRoots) {
+ File folder = new File(sourceFolder);
+ if(folder.exists() && folder.isDirectory()){
+ folders.add(folder);
+ }
+ }
+ context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
if(!outputJavaDirectory.exists()){
outputJavaDirectory.mkdirs();
}
- context.setJavaSourceOutput(outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.COMPONENT_CLASSES, outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.EVENT_LISTENER_CLASSES, outputJavaDirectory);
+ context.setOutputFolder(StandardOutputs.EVENT_SOURCE_CLASSES, outputJavaDirectory);
if(!outputResourcesDirectory.exists()){
outputResourcesDirectory.mkdirs();
}
- context.setResourceOutput(outputResourcesDirectory);
- context.setNamingConventions(new RichFacesConventions(library
+ context.setOutputFolder(StandardOutputs.FACES_CONFIG, outputResourcesDirectory);
+ context.setOutputFolder(StandardOutputs.TAG_LIBRARY, outputResourcesDirectory);
+ context.setOutputFolder(StandardOutputs.XML_SCHEMA, outputResourcesDirectory);
+ // TODO - configure.
+ context.addWorker(NamingConventions.class, new RichFacesConventions(library
.getPrefix()));
+ context.addWorker(ModelValidator.class, new ValidatorImpl());
context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
context.addSources(StandardSources.RENDERER_TEMPLATES,
findTemplateFiles());
context.addSources(StandardSources.FACES_CONFIGS,
findFacesConfigFiles());
- LibraryBuilder builder = LibraryBuilder.createInstance(context);
try {
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
ComponentLibrary model = builder.buildModel();
builder.generate(model);
} catch (CdkException e) {