Author: alexsmirnov
Date: 2010-01-29 19:19:36 -0500 (Fri, 29 Jan 2010)
New Revision: 16382
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
Modified:
root/cdk/branches/guice/plugins/generator/pom.xml
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
Log:
https://jira.jboss.org/jira/browse/RF-8288 template compiler converted to dependency
injection
Modified: root/cdk/branches/guice/plugins/generator/pom.xml
===================================================================
--- root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-30 00:19:36 UTC (rev 16382)
@@ -202,13 +202,13 @@
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
- </dependency>
+ </dependency><!--
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
- <dependency>
+ --><dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0</version>
@@ -224,11 +224,11 @@
<version>2.0</version>
</dependency>
- <!--
<dependency>
<groupId>com.sun.xsom</groupId>
<artifactId>xsom</artifactId>
</dependency>
+ <!--
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,44 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@Target(ANNOTATION_TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface Implementation {
+ public Class<? extends Annotation> value();
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
package org.richfaces.cdk;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.model.ComponentLibrary;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -22,10 +22,8 @@
package org.richfaces.cdk;
-import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
import com.google.inject.BindingAnnotation;
@@ -36,7 +34,6 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
-(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
public @interface OutputFolder {
public StandardOutputFolders value();
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -7,6 +7,10 @@
private final StandardOutputFolders value;
+ public OutputFolderImpl(OutputFolder value) {
+ this.value = value.value();
+ }
+
public OutputFolderImpl(StandardOutputFolders value) {
this.value = value;
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -22,11 +22,11 @@
package org.richfaces.cdk;
-import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+
import com.google.inject.BindingAnnotation;
/**
@@ -34,9 +34,10 @@
* @version $Id$
*
*/
+@Documented
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
-(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+(a)Implementation(SourceImpl.class)
public @interface Source {
public StandardSources value();
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -7,6 +7,10 @@
private final StandardSources value;
+ public SourceImpl(Source value) {
+ this.value = value.value();
+ }
+
public SourceImpl(StandardSources value) {
this.value = value;
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*/
public enum StandardSources implements SourceType {
- JAVA_SOURCES, FACES_CONFIGS,
RENDERER_TEMPLATES,JAVA_SOURCE_FOLDERS,FACES_CONFIG_FOLDERS,TEMPLATE_FOLDERS;
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
@Override
public String getName() {
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -32,7 +32,7 @@
import java.util.Collection;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0"></p>
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -29,7 +29,7 @@
import java.util.Arrays;
import javax.annotation.processing.Processor;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.JavaCompiler.CompilationTask;
import org.richfaces.cdk.CdkException;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
import java.lang.annotation.Annotation;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -28,7 +28,7 @@
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -2,7 +2,7 @@
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.NamingConventions;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -29,7 +29,7 @@
import java.util.Collections;
import java.util.Locale;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -42,6 +42,7 @@
import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.OutputFolder;
import org.richfaces.cdk.Source;
@@ -100,11 +101,11 @@
@Inject
@OutputFolder(StandardOutputFolders.JAVA_CLASSES)
- private File outputFolder;
+ private FileManager outputFolder;
@Inject
@Source(StandardSources.JAVA_SOURCES)
- private Iterable<File> sourceFolders;
+ private FileManager sourceFolders;
private JavaCompiler javaCompiler;
@@ -133,11 +134,11 @@
try {
fileManager.setLocation(StandardLocation.CLASS_PATH,
classPathLoader.getFiles());
if (null != outputFolder) {
-
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT,Collections.singleton(outputFolder));
+
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT,outputFolder.getFolders());
}
- if (null != sourceFolders && sourceFolders.iterator().hasNext())
{
- fileManager.setLocation(StandardLocation.SOURCE_PATH,
sourceFolders);
+ if (null != sourceFolders ) {
+ fileManager.setLocation(StandardLocation.SOURCE_PATH,
sourceFolders.getFolders());
}
} catch (IOException e) {
throw new CdkException("Cannot configure JavaFileManager for
compilator",e);
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -34,7 +34,7 @@
import java.util.List;
import java.util.Set;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileManager;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.freemarker;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.Logger;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -30,7 +30,7 @@
import java.io.IOException;
import java.io.Writer;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -27,7 +27,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -39,7 +39,7 @@
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* @author Nick Belaevski
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -29,46 +29,30 @@
import java.util.HashMap;
import java.util.Map;
-import org.richfaces.cdk.CdkContext;
-
-import freemarker.ext.beans.BeanModel;
-import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0"></p>
- *
+ * TODO: injection.
* @author asmirnov(a)exadel.com
*/
public class JavaClassConfiguration extends Configuration implements FreeMarkerRenderer
{
private static final String TEMPLATES = "/META-INF/templates/java";
- private final CdkContext context;
- public JavaClassConfiguration(CdkContext context) {
- super();
- this.context = context;
+ public JavaClassConfiguration(){
// TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), TEMPLATES);
+ setClassForTemplateLoading(this.getClass(), TEMPLATES);
// TODO create an object wrapper for library model.
setObjectWrapper(new JavaClassModelWrapper(this));
// Add context variables
- this.setSharedVariable("context", new BeanModel(context, new
BeansWrapper()));
+// this.setSharedVariable("context", new BeanModel(context, new
BeansWrapper()));
}
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
-
/* (non-Javadoc)
* @see
org.richfaces.cdk.templatecompiler.FreeMarkerRenderer#writeSnippet(java.lang.String,
java.lang.Object, java.io.Writer)
*/
@@ -100,12 +84,6 @@
} catch (TemplateException e) {
// TODO: handle exception
return e.getMessage();
- } finally {
- try {
- writer.close();
- } catch (IOException e) {
- //do nothing
- }
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -27,91 +27,95 @@
import java.io.IOException;
import java.io.PrintWriter;
+import com.google.inject.Inject;
+
import org.richfaces.builder.model.JavaClass;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassGenerator implements CdkWriter {
- private CdkContext context;
+ private ComponentLibrary library;
+ private FileManager output;
+ private Logger log;
+ private TemplateVisitorFactory<RendererClassVisitor> visitorFactory;
+ private FreeMarkerRenderer renderer;
- /*
- * (non-Javadoc)
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
*
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ * @param library
+ * @param output
+ * @param log
+ * @param visitorFactory
*/
- @Override
- public void init(CdkContext context) {
- this.context = context;
+ @Inject
+ public RendererClassGenerator(ComponentLibrary library,
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output, Logger
log,
+ TemplateVisitorFactory<RendererClassVisitor> visitorFactory,
FreeMarkerRenderer renderer) {
+ this.library = library;
+ this.output = output;
+ this.log = log;
+ this.visitorFactory = visitorFactory;
+ this.renderer = renderer;
}
/*
* (non-Javadoc)
*
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
)
*/
@Override
public void render() throws CdkException {
- ComponentLibrary library = context.getLibrary();
for (RenderKitModel renderKit : library.getRenderKits().values()) {
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- RendererClassVisitor visitor = new RendererClassVisitor(
- template.getInterface(), context.getLoader(),
context.getWorker(JAXBBinding.class));
+ RendererClassVisitor visitor =
visitorFactory.createVisitor(template.getInterface());
try {
// TODO - put real parameters.
- visitor.preProcess();
template.getImplementation().visit(visitor);
- visitor.postProcess();
} finally {
RendererClassVisitor.clearCaches();
}
-
+
JavaClass javaClass = visitor.getGeneratedClass();
String fullName = javaClass.getName();
- File outFile = context.createOutputFile(
- StandardOutputs.RENDERER_CLASSES, fullName.replace(
- '.', '/')
- + ".java", library.lastModified());
+ try {
+ File outFile = output.createFile(fullName.replace('.',
'/') + ".java", library.lastModified());
- if (null != outFile) {
- PrintWriter outputWriter = null;
+ if (null != outFile) {
+ PrintWriter outputWriter = null;
- try {
outputWriter = new PrintWriter(outFile);
- JavaClassConfiguration cdkConfiguration = new
JavaClassConfiguration(context);
- cdkConfiguration.writeSnippet("class", javaClass,
outputWriter);
- } catch (IOException e) {
- throw new CdkException(e);
- } catch (TemplateException e) {
- throw new CdkException(e);
- } finally {
- if (outputWriter != null) {
- outputWriter.close();
- }
+ this.renderer.writeSnippet("class", javaClass,
outputWriter);
+ outputWriter.close();
}
+ } catch (IOException e) {
+ throw new CdkException(e);
+ } catch (TemplateException e) {
+ throw new CdkException(e);
}
+ }
- }
}
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -38,7 +38,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.xml.namespace.QName;
import org.richfaces.builder.model.Argument;
@@ -69,10 +69,12 @@
import org.richfaces.cdk.templatecompiler.model.CdkObjectElement;
import org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement;
import org.richfaces.cdk.templatecompiler.model.CdkWhenElement;
+import org.richfaces.cdk.templatecompiler.model.CompositeImplementation;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
import org.richfaces.cdk.util.Strings;
+import org.richfaces.cdk.xmlconfig.JAXB;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import com.google.common.collect.Lists;
@@ -141,11 +143,11 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
- public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader
classLoader, JAXBBinding jaxbBinding) {
+ public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader
classLoader, JAXB jaxbBinding, Logger log) {
this.compositeInterface = compositeInterface;
this.classLoader = classLoader;
-
- // TODO - cache unmarshalled data (as CDKWorker?)
+ this.LOG = log;
+ // TODO - cache unmarshalled data (as injection)
SchemaSet schemaSet =
jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
this.attributesSchema = schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
}
@@ -714,7 +716,8 @@
/**
*
*/
- public void preProcess() {
+ @Override
+ public void preProcess(CompositeImplementation implementation) {
initializeJavaClass();
passThroughCounter = -1;
}
@@ -722,7 +725,8 @@
/**
*
*/
- public void postProcess() {
+ @Override
+ public void postProcess(CompositeImplementation implementation) {
flushToEncodeMethod("encodeEnd");
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -32,9 +32,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.richfaces.cdk.CdkContext;
+import com.google.inject.Inject;
+
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.Source;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -46,7 +50,7 @@
import org.richfaces.cdk.templatecompiler.model.ClientBehavior;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -64,9 +68,30 @@
private static final Pattern COMMA_SEPARATED_PATTERN =
Pattern.compile("\\s*,\\s*", Pattern.COMMENTS);
- private CdkContext context;
+ private ComponentLibrary library;
+
+ private JAXB jaxbBinding;
+
+ private Logger log;
+
+ private FileManager sources;
+
+
- private JAXBBinding jaxbBinding;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param library
+ * @param jaxbBinding
+ * @param log
+ * @param sources
+ */
+ @Inject
+ public RendererTemplateParser(ComponentLibrary library, JAXB jaxbBinding, Logger log,
@Source(StandardSources.RENDERER_TEMPLATES) FileManager sources) {
+ this.library = library;
+ this.jaxbBinding = jaxbBinding;
+ this.log = log;
+ this.sources = sources;
+ }
private Set<EventName> convert(Collection<ClientBehavior>
clientBehaviors) {
if (clientBehaviors == null || clientBehaviors.isEmpty()) {
@@ -122,7 +147,7 @@
*/
@Override
public void build() throws CdkException {
- Iterable<File> sources =
getContext().getSources(StandardSources.RENDERER_TEMPLATES);
+ Iterable<File> sources = this.sources.getFiles();
if (null != sources) {
for (File file : sources) {
Template template = parseTemplate(file);
@@ -132,7 +157,6 @@
}
protected void mergeTemplateIntoModel(Template template) throws CdkException {
- ComponentLibrary library = context.getLibrary();
CompositeInterface compositeInterface = template.getInterface();
// TODO - infer values ?
RenderKitModel renderKit =
library.addRenderKit(compositeInterface.getRenderKitId());
@@ -208,13 +232,4 @@
*
* @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
*/
- @Override
- public void init(CdkContext context) {
- this.context = context;
- jaxbBinding = context.getWorker(JAXBBinding.class);
- }
-
- public CdkContext getContext() {
- return context;
- }
}
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,38 @@
+/*
+ * $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.templatecompiler;
+
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface TemplateVisitorFactory <T extends TemplateVisitor> {
+
+ public T createVisitor(CompositeInterface composite);
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,67 @@
+/*
+ * $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.templatecompiler;
+
+import com.google.inject.Inject;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import org.richfaces.cdk.xmlconfig.JAXB;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class VisitorFactoryImpl implements
TemplateVisitorFactory<RendererClassVisitor> {
+
+ private CdkClassLoader classLoader;
+ private JAXB jaxbBinding;
+ private Logger log;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param classLoader
+ * @param jaxbBinding
+ * @param log
+ */
+ @Inject
+ public VisitorFactoryImpl(CdkClassLoader classLoader, JAXB jaxbBinding, Logger log)
{
+ this.classLoader = classLoader;
+ this.jaxbBinding = jaxbBinding;
+ this.log = log;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.templatecompiler.TemplateVisitorFactory#createVisitor(org.richfaces.cdk.templatecompiler.model.CompositeInterface)
+ */
+ @Override
+ public RendererClassVisitor createVisitor(CompositeInterface composite) {
+ return new RendererClassVisitor(composite, classLoader, jaxbBinding,log);
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -27,6 +27,8 @@
import javax.xml.bind.annotation.XmlRootElement;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -36,4 +38,14 @@
public class CompositeImplementation extends ModelFragment implements Serializable {
private static final long serialVersionUID = -3046226976516170979L;
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.preProcess(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.postProcess(this);
+ }
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -66,4 +66,8 @@
void endElement(CdkForEachElement cdkForEachElement);
+ void preProcess(CompositeImplementation compositeImplementation);
+
+ void postProcess(CompositeImplementation compositeImplementation);
+
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -30,9 +30,10 @@
import java.io.InputStream;
import java.net.URI;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.SourceType;
import org.richfaces.cdk.StandardSources;
@@ -94,10 +95,10 @@
@Inject
private CdkClassLoader loader;
- @Inject @Source(StandardSources.FACES_CONFIG_FOLDERS)
- private Iterable<File> facesConfigFolders;
- @Inject @Source(StandardSources.TEMPLATE_FOLDERS)
- private Iterable<File> rendererTemplatesFolders;
+ @Inject @Source(StandardSources.FACES_CONFIGS)
+ private FileManager facesConfigFolders;
+ @Inject @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager rendererTemplatesFolders;
/*
* (non-Javadoc)
@@ -223,22 +224,17 @@
return entity;
}
- protected InputSource getProjectInputSource(Iterable<File> folders, String
path) throws FileNotFoundException {
+ protected InputSource getProjectInputSource(FileManager folders, String path) throws
FileNotFoundException {
InputSource entity = null;
- for (File folder : folders) {
- if (folder.exists() && folder.isDirectory()) {
- File configFile = new File(folder, path);
+ File configFile = folders.getFile(path);
- if (configFile.exists()) {
- InputStream inputStream = new FileInputStream(configFile);
+ if (configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
+ entity = new InputSource(inputStream);
- break;
- }
- }
}
return entity;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -27,7 +27,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -26,7 +26,7 @@
import java.util.Collections;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -39,7 +39,7 @@
import java.net.URISyntaxException;
import java.util.Collection;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -32,7 +32,7 @@
import java.util.HashMap;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import com.wutka.dtd.DTD;
import com.wutka.dtd.DTDAttribute;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-29
13:12:29 UTC (rev 16381)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -40,7 +40,7 @@
import java.util.HashMap;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,186 @@
+/*
+ * $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 java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.easymock.EasyMock;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+import com.google.common.collect.Sets;
+import com.google.inject.AbstractModule;
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.binder.AnnotatedBindingBuilder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CdkTestRunner extends BlockJUnit4ClassRunner {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param klass
+ * @throws InitializationError
+ * @throws InitializationError
+ */
+ public CdkTestRunner(Class<?> klass) throws InitializationError {
+ super(klass);
+ }
+
+ /**
+ * Gets all declared fields and all inherited fields.
+ */
+ protected Set<Field> getFields(Class<?> c) {
+ Set<Field> fields = Sets.newHashSet(c.getDeclaredFields());
+ while ( (c = c.getSuperclass()) != null ) {
+ for ( Field f : c.getDeclaredFields() ) {
+ if ( !Modifier.isStatic(f.getModifiers())
+ && !Modifier.isPrivate(f.getModifiers())
+ ) {
+ fields.add(f);
+ }
+ }
+ }
+ return fields;
+ }
+
+ @Override
+ protected Object createTest() throws Exception {
+ Class<?> c = getTestClass().getJavaClass();
+ Set<Field> testFields = getFields(c);
+
+
+ // make sure we have one (and only one) @Unit field
+// Field unitField = getUnitField(testFields);
+// if ( unitField.getAnnotation(Mock.class) != null ) {
+// throw new IncompatibleAnnotationException(Unit.class, Mock.class);
+// }
+//
+ final Map<Field,Object> fieldValues = getMockValues(testFields);
+// if ( fieldValues.containsKey(unitField)) {
+// throw new IncompatibleAnnotationException(Unit.class,
unitField.getType());
+// }
+
+ Object test = createTest(c, fieldValues);
+
+ // any field values created by AtUnit but not injected by the container are
injected here.
+ for ( Field field : fieldValues.keySet() ) {
+ field.setAccessible(true);
+ if ( field.get(test) == null ) {
+ field.set(test, fieldValues.get(field));
+ }
+ }
+
+ return test;
+ }
+
+ private Object createTest(Class<?> testClass, Map<Field, Object>
fieldValues) throws Exception {
+ FieldModule fields = new FieldModule(fieldValues);
+
+ Injector injector;
+ if ( Module.class.isAssignableFrom(testClass)) {
+ injector = Guice.createInjector(fields, (Module)testClass.newInstance() );
+ } else {
+ injector = Guice.createInjector(fields);
+ }
+ return injector.getInstance(testClass);
+ }
+
+
+ protected class FieldModule extends AbstractModule {
+ final Map<Field,Object> fields;
+
+ public FieldModule(Map<Field,Object> fields) {
+ this.fields = fields;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void configure() {
+
+ // map field values by type
+ for ( Field field : fields.keySet() ) {
+ TypeLiteral literal = TypeLiteral.get(field.getGenericType());
+ AnnotatedBindingBuilder builder = bind(literal);
+ // Check field annotations.
+ Annotation[] fieldAnnotations = field.getAnnotations();
+ for (Annotation annotation : fieldAnnotations) {
+ Class<? extends Annotation> annotationType =
annotation.annotationType();
+ if(/*annotationType.isAnnotationPresent(Qualifier.class)||*/
annotationType.isAnnotationPresent(BindingAnnotation.class)){
+ Implementation implementation =
annotationType.getAnnotation(Implementation.class);
+ if(null != implementation){
+ try {
+ Annotation value =
implementation.value().getConstructor(annotationType).newInstance(annotation);
+ builder.annotatedWith(value);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ builder.annotatedWith(annotationType);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ builder.annotatedWith(annotationType);
+ }
+ }
+ }
+ builder.toInstance(fields.get(field));
+ }
+ }
+ }
+
+ private Map<Field, Object> getMockValues(Set<Field> testFields) {
+ Map<Field,Object> mocksAndStubs = new HashMap<Field,Object>();
+
+ for ( Field field : testFields ) {
+ if ( field.getAnnotation(Mock.class) != null ) {
+ mocksAndStubs.put(field, EasyMock.createStrictMock(field.getType()));
+ } else if ( field.getAnnotation(Stub.class) != null ) {
+ mocksAndStubs.put(field, EasyMock.createNiceMock(field.getType()));
+ }
+ }
+
+ return mocksAndStubs;
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,41 @@
+/*
+ * $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">This application should create GraphVis
.dot file with Cdk dependencies</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class DependenciesGraph {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,40 @@
+/*
+ * $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 java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface Mock {
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,28 @@
+package org.richfaces.cdk;
+
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+(a)RunWith(CdkTestRunner.class)
+public class RunnerTest {
+
+ @Mock
+ private Logger log;
+
+ @Stub
+ @Source(StandardSources.JAVA_SOURCES)
+ FileManager sources;
+
+
+ @Test
+ public void easyMockInjections() throws Exception {
+ assertNotNull(log);
+ assertNotNull(sources);
+ replay(log,sources);
+ verify(log,sources);
+ }
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java 2010-01-30
00:19:36 UTC (rev 16382)
@@ -0,0 +1,40 @@
+/*
+ * $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 java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface Stub {
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain