JBoss Rich Faces SVN: r16423 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/parser/el/node and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-02-07 18:14:28 -0500 (Sun, 07 Feb 2010)
New Revision: 16423
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/equals-check-method.ftl
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
Log:
https://jira.jboss.org/jira/browse/RF-7732
Fixed incorrect handling of equality/inequality for non-primitive types
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-05 18:42:09 UTC (rev 16422)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -47,6 +47,7 @@
public static final String COLON = " : ";
public static final String COMMA = ",";
+ public static final String IS_EQUAL_FUNCTION = "isEqual";
public static final String CONVERT_TO_STRING_FUNCTION = "convertToString";
public static final String DOT = ".";
public static final String DOUBLE_VALUE_OF_FUNCTION = "Double.valueOf";
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2010-02-05 18:42:09 UTC (rev 16422)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELParserUtils.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -89,6 +89,7 @@
import org.richfaces.cdk.parser.el.node.BinaryArithmeticOperationTreeNode;
import org.richfaces.cdk.parser.el.node.BinaryBooleanOperationTreeNode;
import org.richfaces.cdk.parser.el.node.ConstantValueTreeNode;
+import org.richfaces.cdk.parser.el.node.EqualityTestTreeNode;
import org.richfaces.cdk.parser.el.node.ITreeNode;
import org.richfaces.cdk.parser.el.types.TypesFactory;
@@ -206,7 +207,7 @@
} else if (child instanceof AstAnd) {
treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.AND_OPERATOR);
} else if (child instanceof AstEqual) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.EQUALITY_OPERATOR);
+ treeNode = new EqualityTestTreeNode(child);
} else if (child instanceof AstGreaterThan) {
treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.GREATER_THEN_OPERATOR);
} else if (child instanceof AstGreaterThanEqual) {
@@ -216,7 +217,7 @@
} else if (child instanceof AstLessThanEqual) {
treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.LESS_THEN_OR_EQUALITY_OPERATOR);
} else if (child instanceof AstNotEqual) {
- treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.INEQUALITY_OPERATOR);
+ treeNode = new EqualityTestTreeNode(child, true);
} else if (child instanceof AstOr) {
treeNode = new BinaryBooleanOperationTreeNode(child, ELNodeConstants.OR_OPERATOR);
} else if (child instanceof AstDiv) {
@@ -239,8 +240,6 @@
treeNode = new AstMethodSuffixTreeNode(child);
} else if (child instanceof AstPropertySuffix) {
treeNode = new AstPropertySuffixTreeNode(child);
- } else if (child instanceof AstBracketSuffix) {
- treeNode = new AstBracketSuffixTreeNode(child);
} else {
throw new ParsingException("Node " + child.getClass().getSimpleName() + "[" + child.getImage()
+ "] is not recognized;");
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2010-02-05 18:42:09 UTC (rev 16422)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELVisitor.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -37,7 +37,8 @@
boolean useConversionToString;
boolean useEmptinessCheck;
-
+ boolean useEqualsCheck;
+
private String parsedExpression = null;
private Type variableType = null;
@@ -56,6 +57,14 @@
public void setUseEmptinessCheck(boolean useCheckForEmpty) {
this.useEmptinessCheck = useCheckForEmpty;
}
+
+ public boolean isUseEqualsCheck() {
+ return useEqualsCheck;
+ }
+
+ public void setUseEqualsCheck(boolean useEqualsCheck) {
+ this.useEqualsCheck = useEqualsCheck;
+ }
public Type getVariableType() {
return variableType;
@@ -116,6 +125,7 @@
parsedExpression = null;
useConversionToString = false;
useEmptinessCheck = false;
+ useEqualsCheck = false;
variableType = null;
}
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/EqualityTestTreeNode.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.parser.el.node;
+
+import java.util.Map;
+
+import org.jboss.el.parser.Node;
+import org.richfaces.cdk.parser.el.ELNodeConstants;
+import org.richfaces.cdk.parser.el.ELVisitor;
+import org.richfaces.cdk.parser.el.ParsingException;
+import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.parser.el.types.TypesFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class EqualityTestTreeNode extends AbstractTreeNode {
+
+ private boolean negateValue = false;
+
+ /**
+ * @param node
+ */
+ public EqualityTestTreeNode(Node node) {
+ super(node);
+ }
+
+ public EqualityTestTreeNode(Node node, boolean negateValue) {
+ super(node);
+
+ this.negateValue = negateValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.parser.el.node.AbstractTreeNode#visit(java.lang.StringBuilder, java.util.Map, org.richfaces.cdk.parser.el.ELVisitor)
+ */
+ @Override
+ public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
+ String firstChildOutput = getChildOutput(0, context, visitor);
+ Type firstChildType = visitor.getVariableType();
+ String secondChildOutput = getChildOutput(1, context, visitor);
+ Type secondChildType = visitor.getVariableType();
+
+ if (!firstChildType.getRawType().isPrimitive() ||
+ !secondChildType.getRawType().isPrimitive()) {
+
+ if (negateValue) {
+ sb.append(ELNodeConstants.EXCLAMATION_MARK);
+ } else {
+ //do nothing
+ }
+
+ sb.append(ELNodeConstants.IS_EQUAL_FUNCTION);
+
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+ sb.append(firstChildOutput);
+ sb.append(ELNodeConstants.COMMA);
+ sb.append(secondChildOutput);
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+
+ visitor.setUseEqualsCheck(true);
+ } else {
+ sb.append(ELNodeConstants.LEFT_BRACKET);
+
+ sb.append(firstChildOutput);
+
+ if (negateValue) {
+ sb.append(ELNodeConstants.INEQUALITY_OPERATOR);
+ } else {
+ sb.append(ELNodeConstants.EQUALITY_OPERATOR);
+ }
+
+ sb.append(secondChildOutput);
+
+ sb.append(ELNodeConstants.RIGHT_BRACKET);
+ }
+
+ visitor.setVariableType(TypesFactory.getType(Boolean.TYPE));
+ }
+
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class EqualsCheckingMethodBodyStatement extends AbstractTemplateMethodBodyStatement {
+
+ public EqualsCheckingMethodBodyStatement() {
+ super("equals-check-method");
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-05 18:42:09 UTC (rev 16422)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -136,7 +136,8 @@
private ClassLoader classLoader;
private boolean isAddedMethodForConversionToString;
private boolean isAddedMethodForCheckingEmptiness;
-
+ private boolean isAddedMethodForCheckingEquals;
+
private Type lastCompiledExpressionType;
private int passThroughCounter;
private Map<String, Property> attributes;
@@ -204,6 +205,24 @@
}
}
+ private void addMethodForCheckingEquals() {
+ if (!isAddedMethodForCheckingEquals) {
+ isAddedMethodForCheckingEquals = true;
+
+ JavaMethod checkingMethod = new JavaMethod("isEqual", boolean.class, new Argument("o1", Object.class),
+ new Argument("o2", Object.class));
+
+ checkingMethod.addModifier(JavaModifier.PRIVATE);
+ checkingMethod.addModifier(JavaModifier.FINAL);
+
+ MethodBody checkingMethodBody = new MethodBody(checkingMethod);
+ checkingMethod.setMethodBody(checkingMethodBody);
+ checkingMethodBody.addStatement(new EqualsCheckingMethodBodyStatement());
+
+ generatedClass.addMethod(checkingMethod);
+ }
+ }
+
private String compileEl(String expression, Class<?> type) {
try {
ELVisitor elVisitor = new ELVisitor();
@@ -220,6 +239,10 @@
addMethodForCheckingEmptiness();
}
+ if (elVisitor.isUseEqualsCheck()) {
+ addMethodForCheckingEquals();
+ }
+
return parsedExpression + "/* " + expression.trim() + " */";
} catch (ParsingException e) {
// TODO Auto-generated catch block
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/equals-check-method.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/equals-check-method.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/equals-check-method.ftl 2010-02-07 23:14:28 UTC (rev 16423)
@@ -0,0 +1,6 @@
+if (o1 != null) {
+ return o1.equals(o2);
+} else {
+ //o1 == null
+ return o2 == null;
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2010-02-05 18:42:09 UTC (rev 16422)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/parser/el/test/ELParserTest.java 2010-02-07 23:14:28 UTC (rev 16423)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.parser.el.test;
+import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -108,6 +109,16 @@
parseExpression("#{2 != 3}");
assertEquals("(2 != 3)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+
+ parseExpression("#{action != clientId}");
+ assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertTrue(visitor.isUseEqualsCheck());
+
+ parseExpression("#{action ne clientId}");
+ assertEquals("!isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertTrue(visitor.isUseEqualsCheck());
}
@Test
@@ -188,6 +199,16 @@
parseExpression("#{3 == 2}");
assertEquals("(3 == 2)", visitor.getParsedExpression());
assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+
+ parseExpression("#{action == clientId}");
+ assertEquals("isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertTrue(visitor.isUseEqualsCheck());
+
+ parseExpression("#{action eq clientId}");
+ assertEquals("isEqual(action,clientId)", visitor.getParsedExpression());
+ assertEquals(Boolean.TYPE, visitor.getVariableType().getRawType());
+ assertTrue(visitor.isUseEqualsCheck());
}
@Test
14 years, 3 months
JBoss Rich Faces SVN: r16422 - in root/cdk/trunk/plugins: generator and 25 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-02-05 13:42:09 -0500 (Fri, 05 Feb 2010)
New Revision: 16422
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/As.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
Modified:
root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
root/cdk/trunk/plugins/generator/
root/cdk/trunk/plugins/generator/pom.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.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/Logger.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/StandardOutputFolders.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/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/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.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/apt/ConverterProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.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/generate/java/ConverterClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.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/FacesConfigGenerator.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/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.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/ConverterBean.java
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/ValidatorBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.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/LibraryBuilderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.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/apt/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.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/freemarker/ValidatorTaglibGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.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/FacesConfigTest.java
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/JaxbMarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
https://jira.jboss.org/jira/browse/RF-8288 merged from branch
Modified: root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
===================================================================
--- root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,11 +21,7 @@
*/
package org.richfaces.cdk.attributes;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.io.StringReader;
import java.io.StringWriter;
Property changes on: root/cdk/trunk/plugins/generator
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/pom.xml 2010-02-05 18:42:09 UTC (rev 16422)
@@ -197,15 +197,38 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.2</version>
+ <scope>test</scope>
</dependency>
<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>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-assisted-inject</artifactId>
+ <version>2.0</version>
+ </dependency>
+
<dependency>
<groupId>com.sun.xsom</groupId>
<artifactId>xsom</artifactId>
</dependency>
+ <!--
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
@@ -217,5 +240,5 @@
</exclusion>
</exclusions>
</dependency>
- </dependencies>
+ --></dependencies>
</project>
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,11 +21,11 @@
package org.richfaces.builder.model;
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
import java.util.ArrayList;
import java.util.List;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
/**
* @author Nick Belaevski
* @since 4.0
Deleted: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,115 +0,0 @@
-package org.richfaces.cdk;
-
-import java.io.File;
-
-import org.richfaces.cdk.model.ComponentLibrary;
-
-/**
- * <p class="changed_added_4_0">
- * That interface defines context for all CDK operations
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface CdkContext {
-
- /**
- * <p class="changed_added_4_0">
- * Tools classloader.
- * </p>
- *
- * @return the loader
- */
- public CdkClassLoader getLoader();
-
- /**
- * <p class="changed_added_4_0">Get all sources for given type.</p>
- * @param type
- * @return
- */
- public Iterable<File> getSources(SourceType type);
-
- /**
- * <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">This method creates output file in the appropriate output folder. If target file exists and its modification time is late than model modification time from {@code lastModified} parameter, no new file will be created.</p>
- * @param output target output folder.
- * @param relativePath path to file in the output folder.
- * @param lastModified model modification time. If that parameter is less then 0, no checks for existing file will be performed.
- * @return new created file or null if the target file exists and its modification time is late then model.
- */
- public File createOutputFile(OutputType output, String relativePath, long lastModified) throws CdkException;
-
- /**
- * <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(CdkProcessingException error);
-
- public abstract Iterable<CdkProcessingException> 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 getWorker(Class<W> workerClass) throws CdkException;
-
- public abstract <W extends CdkWorker> W setWorker(Class<W> workerClass, W workerInstance);
-
- /**
- * <p class="changed_added_4_0">Get value of configuration option.</p>
- * TODO make it type safe.
- * @param name option name.
- * @return option value or null.
- */
- public String getOption(String name);
-
- /**
- * <p class="changed_added_4_0">current JSF components library model</p>
- * @return
- */
- public ComponentLibrary getLibrary();
-
- public abstract ModelBuilder getBuilderFor(SourceType type) throws CdkException;
-
- public abstract CdkWriter getGeneratorFor(OutputType type) throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Id of source files e.g. Java classes, faces-configs, renderer templates</p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface SourceType {
-
- String getName();
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface OutputType {
- String getName();
-
- OutputType getFolderType();
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,294 +0,0 @@
-/*
- * $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.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.apt.AptBuilder;
-import org.richfaces.cdk.generate.java.ComponentClassGenerator;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.templatecompiler.RendererClassGenerator;
-import org.richfaces.cdk.templatecompiler.RendererTemplateParser;
-import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
-import org.richfaces.cdk.xmlconfig.FacesConfigParser;
-import org.richfaces.cdk.freemarker.ValidatorTaglibGenerator;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.MutableClassToInstanceMap;
-
-/**
- * <p class="changed_added_4_0">Base CDK context class. Particular build tool ( Ant, Maven ) should extend that
- * class with tool-specific methods.</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class CdkContextBase implements CdkContext {
-
- /* Map contains writer classes for standard outputs.
- */
- static final ImmutableMap<OutputType, Class<? extends CdkWriter>> WRITERS =
- ImmutableMap.<OutputType, Class<? extends CdkWriter>>builder()
- .put(StandardOutputs.COMPONENT_CLASSES, ComponentClassGenerator.class)
- .put(StandardOutputs.TAG_LIBRARY, ValidatorTaglibGenerator.class)
- .put(StandardOutputs.RENDERER_CLASSES, RendererClassGenerator.class)
- .put(StandardOutputs.FACES_CONFIG, FacesConfigGenerator.class)
- .build();
-
- /**
- * map contain library model builder classes for each source type.
- */
- static final ImmutableMap<SourceType, Class<? extends ModelBuilder>> BUILDERS =
- ImmutableMap.<SourceType, Class<? extends ModelBuilder>> builder()
- .put(StandardSources.FACES_CONFIGS, FacesConfigParser.class)
- .put(StandardSources.JAVA_SOURCES, AptBuilder.class)
- .put(StandardSources.RENDERER_TEMPLATES, RendererTemplateParser.class)
- .build();
-
- private Map<String, String> options = Maps.newHashMap();
- private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
- private Map<OutputType, File> outputs = Maps.newHashMap();
- private Map<SourceType, Iterable<File>> inputFolders = Maps.newHashMap();
- private ClassToInstanceMap<CdkWorker> workers = MutableClassToInstanceMap.create();
- private List<CdkProcessingException> errors = Lists.newArrayList();
- private final CdkClassLoader loader;
- private ComponentLibrary library;
-
- public CdkContextBase(CdkClassLoader loader) {
- this.loader = loader;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkContext#getLoader()
- */
- @Override
- public CdkClassLoader getLoader() {
- return loader;
- }
-
- public void addSources(SourceType type, Iterable<File> files) {
- sources.put(type, files);
- }
-
- @Override
- public Iterable<File> getSources(SourceType type) {
- return sources.get(type);
- }
-
- @Override
- public File getOutputFolder(OutputType type) {
- File outputFolder = outputs.get(type);
- OutputType folderType = type.getFolderType();
-
- if (null == outputFolder && null != folderType) {
-
- // Lookup for standard folder type.
- outputFolder = outputs.get(folderType);
-
- // Lookup for output with same folder type.
- Iterator<OutputType> keysIterator = outputs.keySet().iterator();
-
- while (null == outputFolder && keysIterator.hasNext()) {
- OutputType outputType = keysIterator.next();
-
- if (folderType.equals(outputType.getFolderType())) {
- outputFolder = outputs.get(outputType);
- }
- }
- }
-
- return outputFolder;
- }
-
- public void setOutputFolder(OutputType type, File folder) {
- outputs.put(type, folder);
- }
-
- @Override
- public void sendError(CdkProcessingException error) {
- errors.add(error);
- }
-
- @Override
- public Iterable<CdkProcessingException> getErrors() {
- return errors;
- }
-
- @Override
- 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 getWorker(Class<W> workerClass) throws CdkException {
- W worker = workers.getInstance(workerClass);
-
- if (null == worker) {
-
- // instantiate worker.
- try {
- worker = workerClass.newInstance();
- worker.init(this);
- workers.putInstance(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 worker;
- }
-
- @Override
- public <W extends CdkWorker> W setWorker(Class<W> workerClass, W workerInstance) {
- return workers.putInstance(workerClass, workerInstance);
- }
-
- @Override
- public File createOutputFile(OutputType output, String relativePath, long lastModified) throws CdkException {
- if (null == relativePath) {
- throw new NullPointerException();
- }
-
- File outputFolder = getOutputFolder(output);
-
- if (null == outputFolder) {
- throw new CdkException("No output folder for type " + output.getName());
- }
-
- if (outputFolder.exists() && !outputFolder.isDirectory()) {
- throw new CdkException("Output folder " + outputFolder + " not is directory.");
- }
-
- // Strip leading '/'
- if (relativePath.startsWith(File.separator)) {
- relativePath = relativePath.substring(1);
- }
-
- File outputFile = new File(outputFolder, relativePath);
-
- if (outputFile.exists()) {
- if (lastModified > 0 && outputFile.lastModified() > lastModified) {
- return null;
- } else {
- outputFile.delete();
- }
- }
-
- // Create file folder.
- outputFile.getParentFile().mkdirs();
-
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new CdkException("Error create output file", e);
- }
-
- return outputFile;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param options the options to set
- */
- public void setOptions(Map<String, String> options) {
- this.options.putAll(options);
- }
-
- @Override
- public String getOption(String name) {
- return options.get(name);
- }
-
- /**
- * This method returns instance of {@link CdkWriter} for given output type.
- * @param type
- * @return
- * @throws CdkException
- */
- @Override
- public CdkWriter getGeneratorFor(OutputType type) throws CdkException {
- CdkWriter generator = null;
- Class<? extends CdkWriter> writerClass = CdkContextBase.WRITERS.get(type);
-
- if (null != writerClass) {
- generator = getWorker(writerClass);
- } else {
- generator = new DummyGenerator();
- generator.init(this);
-
- // TODO - make service method for new source types.
- // throw new CdkException("No generator for type " +
- // type.getName());
- }
-
- return generator;
- }
-
- /**
- * This method returns initialized instance of the {@link ModelBuilder} for given source type.
- * @param type
- * @return
- * @throws CdkException
- */
- @Override
- public ModelBuilder getBuilderFor(SourceType type) throws CdkException {
- ModelBuilder builder;
- Class<? extends ModelBuilder> builderClass = CdkContextBase.BUILDERS.get(type);
-
- if (null != builderClass) {
- builder = getWorker(builderClass);
- } else {
- builder = new DummyBuilder();
- builder.init(this);
-
- // TODO - make service method for new source types.
- // throw new CdkException("No model builder for source type " +
- // type.getName());
- }
-
- return builder;
- }
-
- @Override
- public ComponentLibrary getLibrary() {
- if (library == null) {
- library = new ComponentLibrary();
- }
- return library;
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,79 +0,0 @@
-/*
- * $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">That class incapsulates information about recoverable CDK errors.</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class CdkError {
- private Throwable cause;
- private String description;
- private String message;
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- */
- public CdkError(String message) {
- this.message = message;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- * @param cause
- */
- public CdkError(String message, Throwable cause) {
- this.message = message;
- this.cause = cause;
- }
-
- public Throwable getCause() {
- return cause;
- }
-
- public void setCause(Throwable cause) {
- this.cause = cause;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,74 +0,0 @@
-/*
- * $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">That exception indicates recoverable CDK error, that it is, means
- * errors in source code or configuration files that makes project build failed, so no result shulde be generated,
- * but does not stop further processing of other classes or files. CDK should collect such errors but do not stop
- * processing that let developer to know about all errors in the project.</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class CdkProcessingError extends CdkException {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -3696046213271071968L;
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkProcessingError() {
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- */
- public CdkProcessingError(String message) {
- super(message);
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param cause
- */
- public CdkProcessingError(Throwable cause) {
- super(cause);
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- * @param cause
- */
- public CdkProcessingError(String message, Throwable cause) {
- super(message, cause);
- }
-}
Deleted: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,39 +0,0 @@
-/*
- * $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);
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface CdkWriter extends CdkWorker {
+public interface CdkWriter {
public void render() throws CdkException;
}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,63 +0,0 @@
-/*
- * $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 is dummy model builder class for not yet implemented source types</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class DummyBuilder implements ModelBuilder {
- private CdkContext context;
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public void build() throws CdkException {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- protected CdkContext getContext() {
- return context;
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,58 +0,0 @@
-/*
- * $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 is dummy generator for not yet implemented output types</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class DummyGenerator implements CdkWriter {
- private CdkContext context;
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void render() throws CdkException {
-
- // Do nothing
- }
-
- protected CdkContext getContext() {
- return context;
- }
-}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,46 @@
+/*
+ * $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.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface FileManager {
+
+ public File getFile(String path) throws FileNotFoundException;
+
+ public Iterable<File> getFiles();
+
+ public Writer createOutput(String path, long lastModified) throws IOException;
+
+ public abstract Iterable<File> getFolders();
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import static com.google.common.base.Preconditions.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Map;
+
+import org.richfaces.cdk.apt.AptModule;
+import org.richfaces.cdk.freemarker.FreeMakerModule;
+import org.richfaces.cdk.generate.java.ClassGeneratorModule;
+import org.richfaces.cdk.model.ModelModule;
+import org.richfaces.cdk.templatecompiler.TemplateModule;
+import org.richfaces.cdk.xmlconfig.XmlModule;
+
+import com.google.common.collect.Maps;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Stage;
+import com.google.inject.name.Names;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+public class Generator {
+
+ private CdkClassLoader loader;
+
+ private Logger log = new JavaLogger();
+
+ private Injector injector;
+
+ private Locale locale = Locale.getDefault();
+
+ private Charset charset = Charset.defaultCharset();
+
+ private Map<StandardOutputFolders, FileManager> outputFolders = Maps.newEnumMap(StandardOutputFolders.class);
+
+ private Map<StandardSources,FileManager> sources = Maps.newEnumMap(StandardSources.class);
+
+ private LibraryBuilder libraryBuilder;
+
+ private Map<String, String> options = Maps.newHashMap();
+
+
+ public Generator() {
+ EmptyFileManager emptyFileManager = new EmptyFileManager();
+ for (StandardSources source : StandardSources.values()) {
+ sources.put(source, emptyFileManager);
+ }
+
+ for (StandardOutputFolders output : StandardOutputFolders.values()) {
+ outputFolders.put(output, emptyFileManager);
+ }
+ }
+
+
+ public void setLoader(CdkClassLoader loader) {
+ this.loader = loader;
+ }
+
+ public void setLog(Logger log) {
+ this.log = log;
+ }
+
+ public void addOutputFolder(StandardOutputFolders type, File outputFolder) {
+ this.outputFolders.put(type, new OutputFileManager(outputFolder));
+ }
+
+ public void addSources(StandardSources type, Iterable<File> files, Iterable<File> folders){
+ this.sources.put(type, new SourceFileManager(files, folders));
+ }
+
+ public void setOptions(Map<String, String> options) {
+ this.options = options;
+
+ }
+
+
+ public void init(){
+ injector = Guice.createInjector(Stage.PRODUCTION,new CdkConfigurationModule(),new AptModule(),new ModelModule(),
+ new ClassGeneratorModule(),new FreeMakerModule(),new TemplateModule(),new XmlModule());
+ // Create builder instance.
+ this.libraryBuilder = injector.getInstance(LibraryBuilder.class);
+ }
+
+ public void execute() {
+ checkNotNull(libraryBuilder, "initialized");
+ libraryBuilder.build();
+ }
+
+ public static final class EmptyFileManager implements FileManager {
+ @Override
+ public Iterable<File> getFolders() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Iterable<File> getFiles() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public File getFile(String path) throws FileNotFoundException {
+ throw new FileNotFoundException();
+ }
+
+ @Override
+ public Writer createOutput(String path, long lastModified) throws IOException {
+ throw new IOException("read-only");
+ }
+ }
+
+ public class CdkConfigurationModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(CdkClassLoader.class).toInstance(loader);
+ bind(Logger.class).toInstance(log);
+ bind(Locale.class).toInstance(locale);
+ bind(Charset.class).toInstance(charset);
+ for (Map.Entry<StandardOutputFolders, FileManager> entry : outputFolders.entrySet()) {
+ bind(FileManager.class).annotatedWith(new OutputFolderImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ for (Map.Entry<StandardSources, FileManager> entry : sources.entrySet()) {
+ bind(FileManager.class).annotatedWith(new SourceImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ bind(NamingConventions.class).to(RichFacesConventions.class);
+ bind(ModelValidator.class).to(ValidatorImpl.class);
+
+ Names.bindProperties(binder(), options);
+ }
+
+
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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();
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -30,9 +30,14 @@
*
* @author asmirnov(a)exadel.com
*/
-class JavaLogger implements Logger {
- java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
+public class JavaLogger implements Logger {
+
+ public static final String CDK_LOG = "org.richfaces.cdk";
+ private int errorCount = 0;
+
+ private java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(CDK_LOG);
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
@@ -66,6 +71,7 @@
*/
@Override
public void error(CharSequence content) {
+ errorCount++;
jdkLogger.severe(String.valueOf(content));
}
@@ -75,6 +81,7 @@
*/
@Override
public void error(CharSequence content, Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
}
@@ -84,9 +91,15 @@
*/
@Override
public void error(Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, "", error);
}
+ @Override
+ public int getErrorCount() {
+ return errorCount;
+ }
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,9 +25,8 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
-import org.richfaces.cdk.CdkContext.SourceType;
+
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
@@ -37,116 +36,26 @@
* @author asmirnov(a)exadel.com
*
*/
-public final class LibraryBuilder implements CdkWorker {
+public interface LibraryBuilder {
- /**
- * <p class="changed_added_4_0">
- * Current CDK context
- * </p>
- */
- private CdkContext context;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public LibraryBuilder() {}
- @Override
- public void init(CdkContext context) {
- this.context = context;
- // default workers.
- }
-
/**
* <p class="changed_added_4_0">
- * Static factory method
- * </p>
- *
- * @return
- * @throws CdkException
- */
- public static LibraryBuilder createInstance(CdkContext context) throws CdkException {
- return context.getWorker(LibraryBuilder.class);
- }
-
- /**
- * <p class="changed_added_4_0">
- * Parse source files for annotations and populate CDK-related information
- * into model.
- * </p>
- * @param library TODO
- * @param sources
- * Java Source files.
- *
- * @return generated library model.
- * @throws CdkException
- */
- public void buildModel(SourceType type) throws CdkException {
- ModelBuilder modelBuilder = context.getBuilderFor(type);
- modelBuilder.build();
- }
-
- /**
- * <p class="changed_added_4_0">
* Build library model from all available sources.
* </p>
*
* @param templates
* @throws CdkException
*/
- public void build() throws CdkException {
+ public void build() throws CdkException ;
- for (SourceType type : StandardSources.values()) {
- buildModel(type);
- }
-
- getVerifier().verify(context.getLibrary());
-
- generate();
- }
-
/**
* Generate all types of files from library model.
* @param library
* @throws CdkException
*/
- public void generate() throws CdkException {
- for (OutputType type : StandardOutputs.values()) {
- generate(type);
- }
- }
+ public void generate() throws CdkException ;
- /**
- * <p class="changed_added_4_0">
- * Cenerate files from library model for given type ( eg. component classes, faces-config ).
- * </p>
- *
- * @param library model
- * @param type of generated files.
- * @throws CdkException
- */
- public void generate(OutputType type) throws CdkException {
- CdkWriter generator = context.getGeneratorFor(type);
- generator.render();
- }
-
- /**
- * <p class="changed_added_4_0">
- * Getter for the current CDK context
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
-
-
- protected ModelValidator getVerifier() throws CdkException {
- return getContext().getWorker(ModelValidator.class);
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,43 +21,48 @@
package org.richfaces.cdk;
+import com.google.inject.ImplementedBy;
+
/**
- * That interface hides current logging system from generator classe.
+ * That interface hides current logging system from generator classes.
* Concrete tools ( Maven, Ant, JUnit ) should provide appropriate logger instance that delegates
* messages to the current log system.
*
* @author shura
*/
+(a)ImplementedBy(JavaLogger.class)
public interface Logger {
- boolean isDebugEnabled();
+ public boolean isDebugEnabled();
- void debug(CharSequence content);
+ public void debug(CharSequence content);
- void debug(CharSequence content, Throwable error);
+ public void debug(CharSequence content, Throwable error);
- void debug(Throwable error);
+ public void debug(Throwable error);
- boolean isInfoEnabled();
+ public boolean isInfoEnabled();
- void info(CharSequence content);
+ public void info(CharSequence content);
- void info(CharSequence content, Throwable error);
+ public void info(CharSequence content, Throwable error);
- void info(Throwable error);
+ public void info(Throwable error);
- boolean isWarnEnabled();
+ public boolean isWarnEnabled();
- void warn(CharSequence content);
+ public void warn(CharSequence content);
- void warn(CharSequence content, Throwable error);
+ public void warn(CharSequence content, Throwable error);
- void warn(Throwable error);
+ public void warn(Throwable error);
- boolean isErrorEnabled();
+ public boolean isErrorEnabled();
- void error(CharSequence content);
+ public void error(CharSequence content);
- void error(CharSequence content, Throwable error);
+ public void error(CharSequence content, Throwable error);
- void error(Throwable error);
+ public void error(Throwable error);
+
+ public int getErrorCount();
}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,143 +0,0 @@
-/*
- * $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"></p>
- *
- * @author asmirnov(a)exadel.com
- */
-public final class LoggerFactory {
- public static final String CDK_LOG = "org.richfaces.cdk";
-
- /**
- * <p class="changed_added_4_0">Current logger. By default all calls will be sent to system
- * {@link java.util.logging.Logger}</p>
- */
- private static Logger logger = new JavaLogger();
-
- /**
- * <p class="changed_added_4_0">
- * That constant wraps current logger object to allow access to logger at
- * the class instantiation time.
- * </p>
- */
- private static final Logger WRAPPER = new LoggerWrapper();
-
- private LoggerFactory() {
-
- // That class has static methods only.
- }
-
- public static Logger getLogger() {
- return WRAPPER;
- }
-
- public static void setLogger(Logger newLogger) {
- assert null != newLogger;
- logger = newLogger;
- }
-
- private static final class LoggerWrapper implements Logger {
- @Override
- public void debug(CharSequence content) {
- logger.debug(content);
- }
-
- @Override
- public void debug(CharSequence content, Throwable error) {
- logger.debug(content, error);
- }
-
- @Override
- public void debug(Throwable error) {
- logger.debug(error);
- }
-
- @Override
- public void error(CharSequence content) {
- logger.error(content);
- }
-
- @Override
- public void error(CharSequence content, Throwable error) {
- logger.error(content, error);
- }
-
- @Override
- public void error(Throwable error) {
- logger.error(error);
- }
-
- @Override
- public void info(CharSequence content) {
- logger.info(content);
- }
-
- @Override
- public void info(CharSequence content, Throwable error) {
- logger.info(content, error);
- }
-
- @Override
- public void info(Throwable error) {
- logger.info(error);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- @Override
- public void warn(CharSequence content) {
- logger.warn(content);
- }
-
- @Override
- public void warn(CharSequence content, Throwable error) {
- logger.warn(content, error);
- }
-
- @Override
- public void warn(Throwable error) {
- logger.warn(error);
- }
- }
-}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -31,16 +31,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelBuilder extends CdkWorker {
+public interface ModelBuilder {
- /**
- * <p class="changed_added_4_0">
- * Initialize builder.
- * </p>
- *
- * @param context
- */
- public void init(CdkContext context);
/**
* <p class="changed_added_4_0">
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,14 +23,13 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ComponentLibrary;
/**
* <p class="changed_added_4_0">Interface for CDK library model verifier.</p>
*
* @author asmirnov(a)exadel.com
*/
-public interface ModelValidator extends CdkWorker {
+public interface ModelValidator {
/**
* <p class="changed_added_4_0">Perform verify procedure on the library model.</p>
@@ -38,5 +37,5 @@
* @param library
* @throws CdkException
*/
- public void verify(ComponentLibrary library) throws CdkException;
+ public void verify() throws CdkException;
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -34,7 +34,7 @@
*
* @author asmirnov(a)exadel.com
*/
-public interface NamingConventions extends CdkWorker {
+public interface NamingConventions {
/**
* <p class="changed_added_4_0">Calculates component type from explicit value or base class name.</p>
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,128 @@
+/*
+ * $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.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collections;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class OutputFileManager implements FileManager {
+
+ private final Iterable<File> folders;
+ private final File folder;
+
+ public OutputFileManager(File folder) {
+ this.folder = folder;
+ this.folders = Collections.singleton(folder);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
+ */
+ @Override
+ public Writer createOutput(String path, long lastModified) throws IOException {
+ if (null == path) {
+ throw new NullPointerException();
+ }
+
+
+ if (null == folder) {
+ throw new FileNotFoundException("No output folder set for file " + path);
+ }
+
+ if (folder.exists() && !folder.isDirectory()) {
+ throw new IOException("Output folder " + folder + " not is directory.");
+ }
+
+ // Strip leading '/'
+ if (path.startsWith(File.separator)) {
+ path = path.substring(1);
+ }
+
+ File outputFile = new File(folder, path);
+
+ if (outputFile.exists()) {
+ if (lastModified > 0 && outputFile.lastModified() > lastModified) {
+ return null;
+ } else {
+ outputFile.delete();
+ }
+ }
+
+ // Create file folder.
+ outputFile.getParentFile().mkdirs();
+ outputFile.createNewFile();
+
+ return new FileWriter(outputFile);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
+ */
+ @Override
+ public File getFile(String path) throws FileNotFoundException {
+ File file = new File(folder, path);
+ if (file.exists()) {
+ return file;
+ }
+ throw new FileNotFoundException(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFiles()
+ */
+ @Override
+ public Iterable<File> getFiles() {
+ // TODO - list all files in folder.
+ return Collections.emptySet();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the folders
+ */
+ @Override
+ public Iterable<File> getFolders() {
+ return this.folders;
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+public @interface OutputFolder {
+ public StandardOutputFolders value();
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,41 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class OutputFolderImpl implements OutputFolder {
+
+ private final StandardOutputFolders value;
+
+ public OutputFolderImpl(OutputFolder value) {
+ this.value = value.value();
+ }
+
+ public OutputFolderImpl(StandardOutputFolders value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardOutputFolders value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof OutputFolder)) {
+ return false;
+ }
+
+ OutputFolder other = (OutputFolder) o;
+ return value.equals(other.value());
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return OutputFolder.class;
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,12 @@
+package org.richfaces.cdk;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface OutputType {
+ String getName();
+
+ OutputType getFolderType();
+}
\ No newline at end of file
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -20,14 +20,9 @@
private static final String[] COMPONENT_PREFIXES = {UI, ABSTRACT};
private String baseName;
- private CdkContext context;
public RichFacesConventions() {}
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
@Override
public String inferComponentType(String explicitType, String className) throws InvalidNameException {
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Source.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Source.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+@Documented
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+(a)Implementation(SourceImpl.class)
+public @interface Source {
+ public StandardSources value();
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,104 @@
+/*
+ * $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.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class SourceFileManager implements FileManager {
+
+ private final Iterable<File> sources;
+ private final Iterable<File> folders;
+
+ public SourceFileManager(Iterable<File> sources, Iterable<File> folders) {
+ this.sources = sources;
+ this.folders = folders;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#createFile(java.lang.String)
+ */
+ @Override
+ public Writer createOutput(String path, long lastModified) throws IOException {
+ throw new UnsupportedOperationException("Cannot create file in source folder");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFile(java.lang.String)
+ */
+ @Override
+ public File getFile(String path) throws FileNotFoundException {
+ if (null != folders) {
+ for (File folder : folders) {
+ if (folder.exists() && folder.isDirectory()) {
+ File configFile = new File(folder, path);
+ if (configFile.exists()) {
+ return configFile;
+ }
+ }
+ }
+ }
+ if(null != sources){
+ for (File file : sources) {
+ if(file.getAbsolutePath().endsWith(path)){
+ return file;
+ }
+ }
+ }
+ throw new FileNotFoundException(path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.FileManager#getFiles()
+ */
+ @Override
+ public Iterable<File> getFiles() {
+ return sources;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the folders
+ */
+ @Override
+ public Iterable<File> getFolders() {
+ return this.folders;
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,41 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class SourceImpl implements Source {
+
+ private final StandardSources value;
+
+ public SourceImpl(Source value) {
+ this.value = value.value();
+ }
+
+ public SourceImpl(StandardSources value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardSources value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Source)) {
+ return false;
+ }
+
+ Source other = (Source) o;
+ return value.equals(other.value());
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Source.class;
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,11 @@
+package org.richfaces.cdk;
+
+/**
+ * <p class="changed_added_4_0">Id of source files e.g. Java classes, faces-configs, renderer templates</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface SourceType {
+
+ String getName();
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,7 +25,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
/**
* <p class="changed_added_4_0">This enumeration defines standard types of output folders.</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,7 +25,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,7 +23,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.SourceType;
/**
* <p class="changed_added_4_0">This enumeration defines standard types for project sources.</p>
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,12 +25,14 @@
package org.richfaces.cdk;
+import java.util.Collection;
+
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
-import java.util.Collection;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0"></p>
@@ -38,26 +40,32 @@
*
*/
public class ValidatorImpl implements ModelValidator {
- private CdkContext context;
- public void init(CdkContext context) {
- this.context = context;
+ @Inject
+ private Logger log;
+
+ private final ComponentLibrary library;
+ private final NamingConventions namingConventions;
+
+ @Inject
+ public ValidatorImpl(ComponentLibrary library, NamingConventions namingConventions) {
+ this.library = library;
+ this.namingConventions = namingConventions;
}
-
/*
* (non-Javadoc)
* @see org.richfaces.cdk.ValidatorModel#verify(org.richfaces.cdk.model.ComponentLibrary)
*/
@Override
- public void verify(ComponentLibrary library) throws CdkException {
- verifyRenderers(library);
- verifyComponents(library);
+ public void verify() throws CdkException {
+ verifyRenderers();
+ verifyComponents();
// After all, merge all similar elements.
compact(library.getComponents());
}
- protected void verifyRenderers(ComponentLibrary library) {
+ protected void verifyRenderers() {
for (RenderKitModel.Id renderKitId : library.getRenderKits().keySet()) {
// Check render kit name and class.
RenderKitModel renderKit = library.getRenderKits().get(renderKitId);
@@ -73,8 +81,7 @@
}
}
- protected void verifyComponents(ComponentLibrary library) throws CdkException {
- NamingConventions namingConventions = getNamingConventions();
+ protected void verifyComponents() throws CdkException {
for (ComponentModel component : library.getComponents()) {
@@ -92,10 +99,6 @@
}
}
- private NamingConventions getNamingConventions() throws CdkException {
- return context.getWorker(NamingConventions.class);
- }
-
protected void compact(Collection<?> collection) {
// if (collection instanceof ModelCollection) {
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,35 +25,16 @@
package org.richfaces.cdk.apt;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
+import java.util.Set;
-import javax.annotation.processing.Processor;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import javax.tools.Diagnostic.Kind;
import javax.tools.JavaCompiler.CompilationTask;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.LibraryBuilder;
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 com.google.common.collect.Lists;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -63,177 +44,34 @@
* @author asmirnov(a)exadel.com
*
*/
-public class AptBuilder implements ModelBuilder {
- private static final Logger LOG = LoggerFactory.getLogger();
- private boolean initialized = false;
- private CdkContext context;
- private StandardJavaFileManager fileManager;
- private JavaCompiler javaCompiler;
- private Locale locale;
- private Iterable<String> options;
+public class AptBuilder implements LibraryBuilder {
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private CompilationTaskFactory taskFactory;
- /**
- * <p class="changed_added_4_0">Builder method that creates and initializes compiler instance.
- * That instance can be reused for consecuence processing.</p>
- * @param context
- * @return
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
+ @Inject
+ private Set<CdkWriter> generators;
- setJavaCompiler(javaCompiler);
-
- ArrayList<String> options = new ArrayList<String>();
-
- options.add("-proc:only");
- options.add("-implicit:class");
- options.add("-verbose");
-
- CdkClassLoader classPathLoader = context.getLoader();
-
- setOptions(options);
-
- // TODO - provide source files locale.
- setLocale(Locale.getDefault());
-
- // TODO -set locale and charset for platform-independent processing. Provide own diagnostics listener.
-
- StandardJavaFileManager stdFileManager = javaCompiler.getStandardFileManager(null, null, null);
- try {
- stdFileManager.setLocation(StandardLocation.CLASS_PATH, classPathLoader.getFiles());
- File outputFolder = context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES);
- if (null != outputFolder) {
- stdFileManager.setLocation(StandardLocation.SOURCE_OUTPUT,Collections.singleton(outputFolder));
- }
- Iterable<File> sourceFolders = context.getSourceFolders(StandardSources.JAVA_SOURCES);
-
- if (null != sourceFolders && sourceFolders.iterator().hasNext()) {
- stdFileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders);
- }
- } catch (IOException e) {
- throw new CdkException(e);
- }
- setFileManager(stdFileManager);
- initialized = true;
- }
-
public void build() throws CdkException {
- if (!initialized) {
- throw new CdkException("Annotation processor is not initialized");
+ CompilationTask task = taskFactory.get();
+ if (!task.call()) {
+ throw new AptException("Compilation error");
}
-
- CdkProcessor processor = context.getWorker(CdkProcessor.class);
-
- process(context.getSources(StandardSources.JAVA_SOURCES), processor);
}
- /**
- * <p class="changed_added_4_0">That method process source files and call appropriate annotation processors</p>
- * @param sources
- * @param processors
- * @throws AptException
- */
- protected void process(Iterable<File> sources, Processor... processors) throws AptException {
- final List<String> messages = Lists.newArrayList();
- DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>() {
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- LOG.debug("LOG: " + diagnostic.getMessage(null));
-
- if (Kind.ERROR.equals(diagnostic.getKind())) {
- messages.add(diagnostic.getMessage(null));
- }
+ @Override
+ public void generate() throws CdkException {
+ if (0 == log.getErrorCount()) {
+ // processing over, generate files.
+ for (CdkWriter generator : generators) {
+ generator.render();
}
- };
- Iterable<? extends JavaFileObject> sourceObjects = getFileManager().getJavaFileObjectsFromFiles(sources);
-
- if (sourceObjects != null && sourceObjects.iterator().hasNext()) {
- CompilationTask task = getJavaCompiler().getTask(null, getFileManager(), listener, getOptions(), null,
- sourceObjects);
-
- task.setProcessors(Arrays.asList(processors));
- task.setLocale(locale);
-
- if (!task.call()) {
- throw new AptException("Compilation error: " + messages);
- }
- } else {
- LOG.info("No compilation units found, skipping Java sources processing");
- }
+ }
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the options
- */
- protected Iterable<String> getOptions() {
- return options;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param options
- * the options to set
- */
- protected void setOptions(Iterable<String> options) {
- this.options = options;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fileManager
- */
- protected StandardJavaFileManager getFileManager() {
- return fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param fileManager the fileManager to set
- */
- protected void setFileManager(StandardJavaFileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaCompiler the javaCompiler to set
- */
- protected void setJavaCompiler(JavaCompiler javaCompiler) {
- this.javaCompiler = javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaCompiler
- */
- protected JavaCompiler getJavaCompiler() {
- return javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the locale
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,60 @@
+/*
+ * $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.apt;
+
+import javax.annotation.processing.Processor;
+
+import org.richfaces.cdk.LibraryBuilder;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class AptModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<CdkAnnotationProcessor> setBinder = Multibinder.newSetBinder(binder(),CdkAnnotationProcessor.class);
+ setBinder.addBinding().to(ComponentProcessor.class);
+ setBinder.addBinding().to(FacesComponentProcessor.class);
+ setBinder.addBinding().to(BehaviorProcessor.class);
+ setBinder.addBinding().to(RendererProcessor.class);
+ setBinder.addBinding().to(ConverterProcessor.class);
+ setBinder.addBinding().to(ValidatorProcessor.class);
+ bind(Processor.class).to(CdkProcessor.class);
+ bind(CompilationTaskFactory.class).to(TaskFactoryImpl.class);
+ bind(LibraryBuilder.class).to(AptBuilder.class);
+ bind(SourceUtilsProvider.class).in(Singleton.class);
+ bind(SourceUtils.class).toProvider(SourceUtilsProvider.class);
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,264 @@
+package org.richfaces.cdk.apt;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.util.PropertyUtils;
+
+import com.google.common.collect.Sets;
+
+public class AptSourceUtils implements SourceUtils {
+
+
+ private final ProcessingEnvironment processingEnv;
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param processingEnv
+ */
+ public AptSourceUtils(ProcessingEnvironment processingEnv) {
+ this.processingEnv = processingEnv;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Get all fields and bean properties that are annotated with given
+ * annotation.
+ * </p>
+ *
+ * @param annotation
+ * @param type
+ * @return
+ */
+ public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
+ ClassDescription type) {
+ Set<BeanProperty> properties = Sets.newHashSet();
+ List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(asTypeElement(type));
+
+ // Get all methods and fields annotated by annotation.
+ for (Element childElement : members) {
+ if (null != childElement.getAnnotation(annotation)) {
+
+ // Have an annotation, infer property name.
+ String name;
+ TypeMirror propertyType;
+ boolean exists = false;
+
+ if (ElementKind.METHOD.equals(childElement.getKind())) {
+ ExecutableElement method = (ExecutableElement) childElement;
+
+ propertyType = method.getReturnType();
+
+ List<? extends VariableElement> parameters = method.getParameters();
+
+ if (TypeKind.VOID.equals(propertyType.getKind()) && 1 == parameters.size()) {
+
+ // That is setter method, get type from parameter.
+ propertyType = parameters.get(0).asType();
+ } else if (!parameters.isEmpty()) {
+
+ // TODO Invalid method signature for a bean property,
+ // throw exception ?
+ continue;
+ }
+
+ try {
+ name = PropertyUtils.methodToName(childElement.getSimpleName().toString());
+ } catch (InvalidNameException e) {
+
+ // TODO Invalid method name for a bean property, throw
+ // exception ?
+ continue;
+ }
+
+ exists = !method.getModifiers().contains(Modifier.ABSTRACT);
+
+ // List<? extends TypeParameterElement> typeParameters = method.getTypeParameters();
+ } else if (ElementKind.FIELD.equals(childElement.getKind())) {
+ name = childElement.getSimpleName().toString();
+ propertyType = childElement.asType();
+
+ // TODO - find getter/setter, check them for abstract.
+ exists = true;
+ } else {
+ continue;
+ }
+
+ AptBeanProperty property = new AptBeanProperty(name);
+
+ property.type = asClassDescription(propertyType);
+ property.element = childElement;
+ property.exists = exists;
+
+ // TODO - merge properties with same name ?
+ properties.add(property);
+ }
+ }
+
+ return properties;
+ }
+
+ private ClassDescription asClassDescription(TypeMirror type) {
+ return new ClassDescription(type.toString());
+ }
+
+ public String getDocComment(ClassDescription componentElement) {
+ return this.processingEnv.getElementUtils().getDocComment(asTypeElement(componentElement));
+ }
+
+ public Object getConstant(ClassDescription componentElement, String name) {
+ List<VariableElement> fieldsIn =
+ ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(asTypeElement(componentElement)));
+ Object value = null;
+
+ for (VariableElement field : fieldsIn) {
+ Set<Modifier> modifiers = field.getModifiers();
+
+ if (modifiers.contains(Modifier.FINAL) && modifiers.contains(Modifier.STATIC)
+ && field.getSimpleName().equals(name)) {
+ value = field.getConstantValue();
+ }
+ }
+ return value;
+ }
+
+
+ public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor) {
+ visitSupertypes(asTypeElement(type).asType(),visitor);
+ }
+
+ private TypeElement asTypeElement(ClassDescription type) {
+ return processingEnv.getElementUtils().getTypeElement(type.toString());
+ }
+
+
+ private void visitSupertypes(TypeMirror type, SuperTypeVisitor visitor) {
+ List<? extends TypeMirror> supertypes = this.processingEnv.getTypeUtils().directSupertypes(type);
+ for (TypeMirror typeMirror : supertypes) {
+ visitSupertypes(typeMirror, visitor);
+ }
+ visitor.visit(asClassDescription(type));
+ }
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ protected final class AptBeanProperty implements BeanProperty {
+ private Element element;
+ private boolean exists;
+ private final String name;
+ private ClassDescription type;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public AptBeanProperty(String name) {
+ this.name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ AptBeanProperty other = (AptBeanProperty) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean property element.</p>
+ * @return
+ */
+ public String getDocComment() {
+ return processingEnv.getElementUtils().getDocComment(element);
+ }
+
+ public ClassDescription getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the exists
+ */
+ public boolean isExists() {
+ return exists;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ return element.getAnnotation(annotationType);
+ }
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,16 +23,17 @@
package org.richfaces.cdk.apt;
+import java.lang.annotation.Annotation;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ClassDescription;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import java.lang.annotation.Annotation;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -28,15 +28,15 @@
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.CdkWorker;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public interface CdkAnnotationProcessor extends CdkWorker {
+public interface CdkAnnotationProcessor {
+
/**
* <p class="changed_added_4_0"></p>
* @param element
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -27,20 +27,20 @@
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.CdkWorker;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.CdkContext.OutputType;
-import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -51,92 +51,73 @@
* @author asmirnov(a)exadel.com
*
*/
-public class CdkProcessor extends AbstractProcessor implements CdkWorker {
+public class CdkProcessor extends AbstractProcessor {
private static final Set<String> ANY_ANNOTATION = Collections.singleton("*");
+
+ @Inject
+ private Logger log;
- private static final ImmutableList<? extends Class<? extends CdkAnnotationProcessor>> PROCESSORS = ImmutableList
- .of(ComponentProcessor.class,
- FacesComponentProcessor.class,
- BehaviorProcessor.class,
- ValidatorProcessor.class,
- ConverterProcessor.class);
+ @Inject
+ private Set<CdkAnnotationProcessor> processors;
- /**
- * <p class="changed_added_4_0">
- * CDK context.
- * </p>
- */
- private CdkContext context;
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * current CDK context
- * @throws CdkException
- */
+ @Inject
+ private Set<ModelBuilder> builders;
+
+ @Inject
+ private SourceUtilsProvider sourceUtilsProducer;
+
+ @Inject
+ private ModelValidator validator;
+
+ @Inject
+ private LibraryBuilder builder;
+
@Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ sourceUtilsProducer.setProcessingEnv(processingEnv);
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- SourceUtils sourceUtils = new SourceUtils(this.processingEnv, roundEnv);
- sourceUtils.init(getContext());
- getContext().setWorker(SourceUtils.class, sourceUtils);
if (!roundEnv.processingOver()) {
// Process annotations.
- for (Class<? extends CdkAnnotationProcessor> process : PROCESSORS) {
- processAnnotation(process);
+ for (CdkAnnotationProcessor process : processors) {
+ processAnnotation(process,roundEnv);
}
// parse non-java sources
- getContext().getBuilderFor(StandardSources.FACES_CONFIGS).build();
- getContext().getBuilderFor(StandardSources.RENDERER_TEMPLATES).build();
- getContext().getWorker(ModelValidator.class).verify(getContext().getLibrary());
- } else if (!getContext().getErrors().iterator().hasNext()) {
- // processing over, generate files.
- for (OutputType type : StandardOutputs.values()) {
- getContext().getGeneratorFor(type).render();
+ for (ModelBuilder builder : builders) {
+ builder.build();
}
+ validator.verify();
+ } else if (0 == log.getErrorCount()) {
+ // processing over, generate files.
+ builder.generate();
}
- getContext().setWorker(SourceUtils.class, null);
return false;
}
- protected void processAnnotation(Class<? extends CdkAnnotationProcessor> processor) {
- CdkAnnotationProcessor cdkAnnotationProcessor = getContext().getWorker(processor);
- Set<? extends TypeElement> annotatedWith = getContext().getWorker(SourceUtils.class)
- .getClassesAnnotatedWith(cdkAnnotationProcessor.getProcessedAnnotation());
-
- for (TypeElement typeElement : annotatedWith) {
- try {
- cdkAnnotationProcessor.process(typeElement);
- } catch (CdkProcessingException e) {
- sendError(typeElement, e);
+
+ protected void processAnnotation(CdkAnnotationProcessor processor, RoundEnvironment environment) {
+ Set<? extends Element> annotatedWith = environment.getElementsAnnotatedWith(processor.getProcessedAnnotation());
+ for (Element element : annotatedWith) {
+ if (ElementKind.CLASS.equals(element.getKind())) {
+ try {
+ processor.process((TypeElement) element);
+ } catch (CdkProcessingException e) {
+ sendError(element, e);
+ }
}
}
}
- protected void sendError(TypeElement componentElement, CdkProcessingException e) {
+ protected void sendError(Element componentElement, CdkProcessingException e) {
// rise error and continue.
processingEnv.getMessager().printMessage(javax.tools.Diagnostic.Kind.ERROR, e.getMessage(), componentElement);
- getContext().sendError(e);
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
-
@Override
public Set<String> getSupportedAnnotationTypes() {
return ANY_ANNOTATION;
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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.apt;
+
+
+import javax.tools.JavaCompiler.CompilationTask;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CompilationTaskFactory {
+
+ CompilationTask get() throws AptException;
+
+}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -27,7 +27,6 @@
import java.lang.annotation.Annotation;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.annotation.processing.SupportedAnnotationTypes;
@@ -39,7 +38,6 @@
import javax.lang.model.type.TypeMirror;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Attributes;
import org.richfaces.cdk.annotations.Component;
@@ -59,13 +57,12 @@
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacetModel;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ComponentModel.Type;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
-import org.richfaces.cdk.xmlconfig.FragmentParser;
import com.google.common.collect.Lists;
@@ -79,6 +76,7 @@
*/
@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", Component.NAME})
public class ComponentProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
public void process(TypeElement componentElement) {
ComponentLibrary library = getLibrary();
// Process class-level annotations.
@@ -102,9 +100,6 @@
return explicitType;
}
- private NamingConventions getNamingConventions() {
- return getContext().getWorker(NamingConventions.class);
- }
private void setComponentProperties(TypeElement componentElement, ComponentModel component)
@@ -124,8 +119,8 @@
}
private void processFacets(TypeElement componentElement, ComponentModel component) {
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
- Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
+ SourceUtils sourceUtils = getSourceUtils();
+ Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, asClassDesctiption(componentElement));
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
@@ -176,7 +171,7 @@
component.setFamily(family.value());
} else {
// static final COMPONENT_FAMILY string constant.
- Object value = getContext().getWorker(SourceUtils.class).getConstant(componentElement, "COMPONENT_FAMILY");
+ Object value = getSourceUtils().getConstant(asClassDesctiption(componentElement), "COMPONENT_FAMILY");
if (null != value) {
component.setFamily(value.toString());
}
@@ -207,7 +202,7 @@
Generate generate = componentElement.getAnnotation(Generate.class);
// Set generated and base class names.
- ClassDescription baseClass = new ClassDescription(componentElement.getQualifiedName().toString());
+ ClassDescription baseClass = asClassDesctiption(componentElement);
if (null != generate) {
component.setComponentClass(new ClassDescription(generate.value()));
@@ -240,11 +235,11 @@
}
}
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
- sourceUtils.visitSupertypes(componentElement.asType(), new SuperTypeVisitor() {
+ SourceUtils sourceUtils = getSourceUtils();
+ sourceUtils.visitSupertypes(asClassDesctiption(componentElement), new SuperTypeVisitor() {
@Override
- public void visit(TypeMirror type) {
+ public void visit(ClassDescription type) {
try {
component.getAttributes().putAll(parseProperties(
CdkEntityResolver.URN_ATTRIBUTES + type.toString() + ".xml"));
@@ -255,7 +250,7 @@
}
});
- Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, componentElement);
+ Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, asClassDesctiption(componentElement));
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
@@ -286,7 +281,7 @@
}
// type.
- attribute.setType(new ClassDescription(beanProperty.getType().toString()));
+ attribute.setType(beanProperty.getType());
// MethodExpression call signature.
Signature signature = beanProperty.getAnnotation(Signature.class);
@@ -342,10 +337,6 @@
}
- private Map<String, Property> parseProperties(String attributesConfig) {
- return getContext().getWorker(FragmentParser.class).parseProperties(CdkEntityResolver.URN_ATTRIBUTES +attributesConfig+".xml");
- }
-
private void setBehaviorEvent(Property attribute, EventName eventName) {
if (null != eventName) {
org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,17 +21,18 @@
package org.richfaces.cdk.apt;
+import java.lang.annotation.Annotation;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfConverter;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ConverterModel;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.type.MirroredTypeException;
-import java.lang.annotation.Annotation;
-
/**
* @author akolonitsky
* @since Jan 4, 2010
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,20 +1,63 @@
package org.richfaces.cdk.apt;
+import java.util.Map;
+
import javax.lang.model.element.TypeElement;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkWorker;
+import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.DisplayName;
import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.DescriptionGroup;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
+import org.richfaces.cdk.xmlconfig.FragmentParser;
-public class ProcessorBase implements CdkWorker {
+import com.google.inject.Inject;
+import com.google.inject.Provider;
- private CdkContext context;
+public class ProcessorBase {
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ private Provider<SourceUtils> sourceUtils;
+
+ @Inject
+ private NamingConventions namingConventions;
+
+ @Inject
+ private FragmentParser fragmentParser;
+
/**
* <p class="changed_added_4_0"></p>
+ * @return the fragmentParser
+ */
+ public FragmentParser getFragmentParser() {
+ return this.fragmentParser;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the sourceUtils
+ */
+ public SourceUtils getSourceUtils() {
+ return this.sourceUtils.get();
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the namingConventions
+ */
+ public NamingConventions getNamingConventions() {
+ return this.namingConventions;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @param component
* @param icon
*/
@@ -33,27 +76,15 @@
}
public ComponentLibrary getLibrary() {
- return getContext().getLibrary();
+ return library;
}
- @Override
- public void init(CdkContext context) {
- this.context=context;
- }
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
protected void setDescription(TypeElement element, DescriptionGroup component) {
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
// JavaDoc comments
- component.setDescription(sourceUtils.getDocComment(element));
+ component.setDescription(getSourceUtils().getDocComment(asClassDesctiption(element)));
Icon icon = element.getAnnotation(Icon.class);
@@ -68,4 +99,12 @@
}
}
+ protected Map<String, Property> parseProperties(String attributesConfig) {
+ return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES +attributesConfig+".xml");
+ }
+
+ protected ClassDescription asClassDesctiption(TypeElement componentElement) {
+ return new ClassDescription(componentElement.getQualifiedName().toString());
+ }
+
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,75 @@
+/*
+ * $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.apt;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import org.richfaces.cdk.model.ClassDescription;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ReflectionUtils implements SourceUtils {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.apt.SourceUtils#getBeanPropertiesAnnotatedWith(java.lang.Class, org.richfaces.cdk.model.ClassDescription)
+ */
+ @Override
+ public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
+ ClassDescription type) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.apt.SourceUtils#getConstant(org.richfaces.cdk.model.ClassDescription, java.lang.String)
+ */
+ @Override
+ public Object getConstant(ClassDescription componentElement, String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.apt.SourceUtils#getDocComment(org.richfaces.cdk.model.ClassDescription)
+ */
+ @Override
+ public String getDocComment(ClassDescription componentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.apt.SourceUtils#visitSupertypes(org.richfaces.cdk.model.ClassDescription, org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor)
+ */
+ @Override
+ public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,24 +22,18 @@
package org.richfaces.cdk.apt;
import java.lang.annotation.Annotation;
-import java.util.Map;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.annotations.DisplayName;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.Icon;
import org.richfaces.cdk.annotations.Renderer;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RendererModel;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
-import org.richfaces.cdk.xmlconfig.FragmentParser;
/**
* @author akolonitsky
@@ -73,17 +67,12 @@
return componentElement.getAnnotation(Component.class).value();
}
- private NamingConventions getNamingConventions() {
- return getContext().getWorker(NamingConventions.class);
- }
-
-
private void setRendererProperties(TypeElement componentElement, RendererModel renderer)
throws CdkException {
// Component family
setRendererFamily(componentElement, renderer);
- setRendererDescription(componentElement, renderer);
+ setDescription(componentElement, renderer);
// processFacets(componentElement, renderer);
// process Events.
@@ -94,25 +83,6 @@
// processAttributes(componentElement, component);
}
- private void setRendererDescription(TypeElement componentElement, RendererModel component) {
-
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
- // JavaDoc comments
- component.setDescription(sourceUtils.getDocComment(componentElement));
-
- Icon icon = componentElement.getAnnotation(Icon.class);
-
- if (null != icon) {
- setIcon(component, icon);
- }
-
- DisplayName displayName = componentElement.getAnnotation(DisplayName.class);
-
- if (null != displayName) {
- component.setDisplayname(displayName.value());
- }
- }
-
private void setRendererFamily(TypeElement rendererElement, RendererModel renderer) {
Family family = rendererElement.getAnnotation(Family.class);
@@ -122,7 +92,7 @@
renderer.setFamily(family.value());
} else {
// static final COMPONENT_FAMILY string constant.
- Object value = getContext().getWorker(SourceUtils.class).getConstant(rendererElement, "COMPONENT_FAMILY");
+ Object value = getSourceUtils().getConstant(asClassDesctiption(rendererElement), "COMPONENT_FAMILY");
if (null != value) {
renderer.setFamily(value.toString());
}
@@ -170,10 +140,6 @@
// }
// }
- private Map<String, Property> parseProperties(String attributesConfig) {
- return getContext().getWorker(FragmentParser.class).parseProperties(CdkEntityResolver.URN_ATTRIBUTES +attributesConfig+".xml");
- }
-
private void setBehaviorEvent(Property attribute, EventName eventName) {
if (null != eventName) {
org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -24,35 +24,20 @@
package org.richfaces.cdk.apt;
import java.lang.annotation.Annotation;
-import java.util.List;
import java.util.Set;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.ElementFilter;
+import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.util.PropertyUtils;
+import com.google.inject.ProvidedBy;
-import com.google.common.collect.Sets;
-
/**
* <p class="changed_added_4_0">This class provides utility methods to analayze java classes. This implementation uses APT API to get
* information about Java code.</p>
* @author asmirnov(a)exadel.com
*
*/
-public class SourceUtils implements CdkWorker {
+(a)ProvidedBy(SourceUtilsProvider.class)
+public interface SourceUtils {
@@ -62,262 +47,63 @@
*
*/
public interface SuperTypeVisitor {
- public void visit(TypeMirror type);
+ public void visit(ClassDescription type);
}
- private CdkContext context;
- private final ProcessingEnvironment processingEnv;
- private final RoundEnvironment roundEnvironment;
-
- public SourceUtils(ProcessingEnvironment processingEnv, RoundEnvironment roundEnv) {
- this.processingEnv = processingEnv;
- this.roundEnvironment = roundEnv;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWorker#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
/**
* <p class="changed_added_4_0">
- * Get all classes annotated with particular annotation.
* </p>
- * @param round
- * current round environment.
- * @param annotation
- * annotation class.
*
- * @return {@link Set} of all classes annotated with {@code annotation}
- * type.
- */
- public Set<? extends TypeElement> getClassesAnnotatedWith(
- Class<? extends Annotation> annotation) {
- Set<? extends Element> annotatedWith = roundEnvironment.getElementsAnnotatedWith(annotation);
-
- Set<TypeElement> classes = Sets.newHashSetWithExpectedSize(annotatedWith.size());
- for (Element element : annotatedWith) {
- if (ElementKind.CLASS.equals(element.getKind())) {
- classes.add((TypeElement) element);
- }
- }
-
- return classes;
- }
-
- /**
- * <p class="changed_added_4_0">
- * Get all fields and bean properties that are annotated with given
- * annotation.
- * </p>
- *
- * @param annotation
- * @param type
- * @return
- */
- protected Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
- TypeElement type) {
- Set<BeanProperty> properties = Sets.newHashSet();
- List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
-
- // Get all methods and fields annotated by annotation.
- for (Element childElement : members) {
- if (null != childElement.getAnnotation(annotation)) {
-
- // Have an annotation, infer property name.
- String name;
- TypeMirror propertyType;
- boolean exists = false;
-
- if (ElementKind.METHOD.equals(childElement.getKind())) {
- ExecutableElement method = (ExecutableElement) childElement;
-
- propertyType = method.getReturnType();
-
- List<? extends VariableElement> parameters = method.getParameters();
-
- if (TypeKind.VOID.equals(propertyType.getKind()) && 1 == parameters.size()) {
-
- // That is setter method, get type from parameter.
- propertyType = parameters.get(0).asType();
- } else if (!parameters.isEmpty()) {
-
- // TODO Invalid method signature for a bean property,
- // throw exception ?
- continue;
- }
-
- try {
- name = PropertyUtils.methodToName(childElement.getSimpleName().toString());
- } catch (InvalidNameException e) {
-
- // TODO Invalid method name for a bean property, throw
- // exception ?
- continue;
- }
-
- exists = !method.getModifiers().contains(Modifier.ABSTRACT);
-
- // List<? extends TypeParameterElement> typeParameters = method.getTypeParameters();
- } else if (ElementKind.FIELD.equals(childElement.getKind())) {
- name = childElement.getSimpleName().toString();
- propertyType = childElement.asType();
-
- // TODO - find getter/setter, check them for abstract.
- exists = true;
- } else {
- continue;
- }
-
- BeanProperty property = new BeanProperty(name);
-
- property.type = propertyType;
- property.element = childElement;
- property.exists = exists;
-
- // TODO - merge properties with same name ?
- properties.add(property);
- }
- }
-
- return properties;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
* @author asmirnov(a)exadel.com
*
*/
- protected final class BeanProperty {
- private Element element;
- private boolean exists;
- private final String name;
- private TypeMirror type;
-
+ public interface BeanProperty {
+
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param name
- */
- public BeanProperty(String name) {
- this.name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((name == null) ? 0 : name.hashCode());
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- BeanProperty other = (BeanProperty) obj;
-
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
* @return the name
*/
- public String getName() {
- return name;
- }
-
+ public String getName();
+
/**
* <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean property element.</p>
* @return
*/
- public String getDocComment() {
- return processingEnv.getElementUtils().getDocComment(element);
- }
-
- public TypeMirror getType() {
- return type;
- }
-
+ public String getDocComment();
+
+ public ClassDescription getType();
+
/**
* <p class="changed_added_4_0"></p>
* @return the exists
*/
- public boolean isExists() {
- return exists;
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
- return element.getAnnotation(annotationType);
- }
+ public boolean isExists();
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType);
}
- public String getDocComment(Element componentElement) {
- return this.processingEnv.getElementUtils().getDocComment(componentElement);
- }
- public Object getConstant(TypeElement componentElement, String name) {
- List<VariableElement> fieldsIn =
- ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
- Object value = null;
+ /**
+ * <p class="changed_added_4_0">
+ * Get all fields and bean properties that are annotated with given
+ * annotation.
+ * </p>
+ *
+ * @param annotation
+ * @param type
+ * @return
+ */
+ public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
+ ClassDescription type);
- for (VariableElement field : fieldsIn) {
- Set<Modifier> modifiers = field.getModifiers();
+ public String getDocComment(ClassDescription componentElement);
- if (modifiers.contains(Modifier.FINAL) && modifiers.contains(Modifier.STATIC)
- && field.getSimpleName().equals(name)) {
- value = field.getConstantValue();
- }
- }
- return value;
- }
+ public Object getConstant(ClassDescription componentElement, String name);
- public void visitSupertypes(TypeMirror type, SuperTypeVisitor visitor) {
- List<? extends TypeMirror> supertypes = this.processingEnv.getTypeUtils().directSupertypes(type);
- for (TypeMirror typeMirror : supertypes) {
- visitSupertypes(typeMirror, visitor);
- }
- visitor.visit(type);
- }
+ public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor);
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,79 @@
+/*
+ * $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.apt;
+
+import javax.annotation.processing.ProcessingEnvironment;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@Singleton
+public class SourceUtilsProvider implements Provider<SourceUtils> {
+
+
+ private SourceUtils utils;
+
+ private final ReflectionUtils defaultUtils;
+
+ private final Injector injector;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultUtils
+ */
+ @Inject
+ public SourceUtilsProvider(ReflectionUtils defaultUtils,Injector injector) {
+ this.defaultUtils = defaultUtils;
+ this.utils = defaultUtils;
+ this.injector = injector;
+ }
+
+
+ @Override
+ public SourceUtils get() {
+ return utils;
+ }
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param processingEnv the processingEnv to set
+ */
+ public void setProcessingEnv(ProcessingEnvironment processingEnv) {
+ if(null != processingEnv){
+ this.utils = new AptSourceUtils(processingEnv);
+ injector.injectMembers(this.utils);
+ } else {
+ this.utils = this.defaultUtils;
+ }
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,160 @@
+/*
+ * $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.apt;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Locale;
+
+import javax.annotation.processing.Processor;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler.CompilationTask;
+
+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;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.StandardSources;
+
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TaskFactoryImpl implements CompilationTaskFactory {
+
+ private final class DiagnosticListenerImplementation implements DiagnosticListener<JavaFileObject> {
+
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ StringBuilder message = new StringBuilder(diagnostic.getMessage(locale));
+ JavaFileObject source = diagnostic.getSource();
+ if (null != source) {
+ message.append(", in the file:").append(source.getName()).append(" at line ").append(
+ diagnostic.getLineNumber()).append(" in column ").append(diagnostic.getColumnNumber());
+ }
+ Kind kind = diagnostic.getKind();
+ if (Kind.ERROR.equals(kind)) {
+ log.error(message);
+ } else if (Kind.MANDATORY_WARNING.equals(kind) || Kind.WARNING.equals(kind)) {
+ log.warn(message);
+ } else if (Kind.NOTE.equals(kind)) {
+ log.info(message);
+ } else {
+ log.debug(message);
+ }
+ }
+ }
+
+ private static final ImmutableCollection<String> COMPILER_OPTIONS = ImmutableList.of("-proc:only","-implicit:class","-verbose");
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private Locale locale;
+
+ @Inject
+ private Charset charset;
+
+ @Inject
+ private CdkClassLoader classPathLoader;
+
+ @Inject
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES)
+ private FileManager outputFolder;
+
+ @Inject
+ @Source(StandardSources.JAVA_SOURCES)
+ private FileManager sourceFolders;
+
+ @Inject
+ private Processor cdkProcessor;
+
+ private JavaCompiler javaCompiler;
+
+ private StandardJavaFileManager fileManager;
+
+ private DiagnosticListener<JavaFileObject> diagnosticListener = new DiagnosticListenerImplementation();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.apt.CompilationTaskFactory#getTask(java.lang.Iterable)
+ */
+ @Override
+ public CompilationTask get() throws AptException {
+ diagnosticListener = new DiagnosticListenerImplementation();
+ Iterable<? extends JavaFileObject> sourceObjects = getFileManager().getJavaFileObjectsFromFiles(sourceFolders.getFiles());
+ CompilationTask task =
+ getJavaCompiler().getTask(null, getFileManager(), diagnosticListener, COMPILER_OPTIONS, null, sourceObjects);
+ task.setLocale(locale);
+ task.setProcessors(Collections.singleton(cdkProcessor));
+ return task;
+ }
+
+ private StandardJavaFileManager getFileManager() {
+ if (fileManager == null) {
+ fileManager = getJavaCompiler().getStandardFileManager(diagnosticListener, locale, charset);
+ try {
+ fileManager.setLocation(StandardLocation.CLASS_PATH, classPathLoader.getFiles());
+ Iterable<File> outputFolders = outputFolder.getFolders();
+ if (null != outputFolders) {
+ fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, outputFolders);
+ }
+ fileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders.getFolders());
+ } catch (IOException e) {
+ throw new CdkException("Cannot configure JavaFileManager for compilator",e);
+ }
+
+ }
+ return fileManager;
+ }
+
+ private JavaCompiler getJavaCompiler() {
+ if (javaCompiler == null) {
+ javaCompiler = ToolProvider.getSystemJavaCompiler();
+ }
+ return javaCompiler;
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,16 +21,17 @@
package org.richfaces.cdk.apt;
+import java.lang.annotation.Annotation;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfValidator;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ValidatorModel;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.Modifier;
-import java.lang.annotation.Annotation;
-
/**
* @author akolonitsky
* @since Jan 13, 2010
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,18 +23,6 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Lists;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.StandardLocation;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@@ -44,6 +32,20 @@
import java.util.List;
import java.util.Set;
+import javax.tools.FileObject;
+import javax.tools.ForwardingJavaFileManager;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+import javax.tools.JavaFileObject.Kind;
+
+import org.richfaces.cdk.Logger;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* That class wraps {@link javax.tools.StandardJavaFileManager}
@@ -52,7 +54,8 @@
* @author asmirnov(a)exadel.com
*/
final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
- private static final Logger LOG = LoggerFactory.getLogger();
+ @Inject
+ private Logger log;
// private final BiMap<FileObjectKey, FileObject> classPathFiles;
// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
@@ -89,8 +92,8 @@
*/
@Override
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.getJavaFileForInput(" + String.valueOf(location) + "," + className + ","
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.getJavaFileForInput(" + String.valueOf(location) + "," + className + ","
+ String.valueOf(kind) + ")");
}
@@ -117,8 +120,8 @@
@Override
public ClassLoader getClassLoader(Location location) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.getClassLoader(" + String.valueOf(location) + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.getClassLoader(" + String.valueOf(location) + ")");
}
if (StandardLocation.CLASS_OUTPUT.equals(location) || StandardLocation.SOURCE_PATH.equals(location)
@@ -139,8 +142,8 @@
*/
@Override
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.getJavaFileForOutput(" + String.valueOf(location) + "," + className + ","
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.getJavaFileForOutput(" + String.valueOf(location) + "," + className + ","
+ String.valueOf(kind) + "," + String.valueOf(sibling) + ")");
}
@@ -167,8 +170,8 @@
public boolean hasLocation(Location location) {
boolean hasLocation;
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.hasLocation(" + String.valueOf(location) + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.hasLocation(" + String.valueOf(location) + ")");
}
if (StandardLocation.SOURCE_PATH.equals(location)) {
@@ -186,8 +189,8 @@
public Iterable<JavaFileObject> list(final Location location, final String packageName, final Set<Kind> kinds,
final boolean recurse) throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.list(" + String.valueOf(location) + "," + packageName + ","
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.list(" + String.valueOf(location) + "," + packageName + ","
+ String.valueOf(kinds) + "," + String.valueOf(recurse) + ")");
}
@@ -280,8 +283,8 @@
*/
@Override
public void close() throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.close()");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.close()");
}
super.close();
@@ -294,8 +297,8 @@
*/
@Override
public void flush() throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.flush()");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.flush()");
}
super.flush();
@@ -309,8 +312,8 @@
*/
@Override
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.getFileForInput(" + String.valueOf(location) + "," + packageName + ","
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.getFileForInput(" + String.valueOf(location) + "," + packageName + ","
+ relativeName + ")");
}
@@ -342,8 +345,8 @@
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling)
throws IOException {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.getFileForOutput(" + String.valueOf(location) + "," + packageName + ","
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.getFileForOutput(" + String.valueOf(location) + "," + packageName + ","
+ relativeName + "," + String.valueOf(sibling) + ")");
}
@@ -358,8 +361,8 @@
*/
@Override
public boolean handleOption(String current, Iterator<String> remaining) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.handleOption(" + current + ",remaining)");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.handleOption(" + current + ",remaining)");
}
return super.handleOption(current, remaining);
@@ -373,8 +376,8 @@
*/
@Override
public String inferBinaryName(Location location, JavaFileObject file) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.inferBinaryName(" + String.valueOf(location) + "," + String.valueOf(file)
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.inferBinaryName(" + String.valueOf(location) + "," + String.valueOf(file)
+ ")");
}
@@ -400,8 +403,8 @@
*/
@Override
public boolean isSameFile(FileObject a, FileObject b) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.isSameFile(" + String.valueOf(a) + "," + String.valueOf(b) + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.isSameFile(" + String.valueOf(a) + "," + String.valueOf(b) + ")");
}
if (a instanceof VirtualJavaFileObject) {
@@ -419,8 +422,8 @@
*/
@Override
public int isSupportedOption(String option) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("VirtualFileManager.isSupportedOption(" + option + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("VirtualFileManager.isSupportedOption(" + option + ")");
}
return super.isSupportedOption(option);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,7 +23,6 @@
package org.richfaces.cdk.apt;
-import javax.tools.SimpleJavaFileObject;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -32,6 +31,8 @@
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
+import javax.tools.SimpleJavaFileObject;
+
/**
* <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created
* from {@link java.io.File} or {@link java.net.URL}</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,12 @@
package org.richfaces.cdk.freemarker;
-import freemarker.ext.beans.BeanModel;
-import freemarker.ext.beans.BeansWrapper;
+import org.richfaces.cdk.Logger;
+
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
-import org.richfaces.cdk.CdkContext;
+import freemarker.template.ObjectWrapper;
/**
* <p class="changed_added_4_0"></p>
@@ -34,21 +36,23 @@
* @author asmirnov(a)exadel.com
*/
public class CdkConfiguration extends Configuration {
+
private static final String TEMPLATES = "/META-INF/templates";
- private final CdkContext context;
+
+ private Logger log;
- public CdkConfiguration(CdkContext context) {
+ @Inject
+ public CdkConfiguration(ObjectWrapper wrapper,Logger log) {
super();
- this.context = context;
+ this.log = log;
// TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), TEMPLATES);
+ setClassForTemplateLoading(this.getClass(), TEMPLATES);
- // TODO create an object wrapper for library model.
- setObjectWrapper(new LibraryModelWrapper());
+ setObjectWrapper(wrapper);
// Add context variables
- this.setSharedVariable("context", new BeanModel(context, new BeansWrapper()));
+// this.setSharedVariable("context", new BeanModel(context, new BeansWrapper()));
}
/**
@@ -56,7 +60,4 @@
*
* @return the context
*/
- protected CdkContext getContext() {
- return context;
- }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,47 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.freemarker;
+
+import com.google.inject.AbstractModule;
+
+import freemarker.template.Configuration;
+import freemarker.template.ObjectWrapper;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FreeMakerModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ bind(Configuration.class).to(CdkConfiguration.class);
+ bind(ObjectWrapper.class).to(LibraryModelWrapper.class);
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,37 +25,44 @@
package org.richfaces.cdk.freemarker;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContext.OutputType;
+import java.io.IOException;
+import java.io.Writer;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+
/**
* <p class="changed_added_4_0">Base class for all output file buildes that use FreeMarker as template engine.</p>
* @author asmirnov(a)exadel.com
*
*/
public abstract class FreeMarkerRenderer<C extends Visitable, P> implements CdkWriter, LibraryVisitor<Boolean, P> {
- private Configuration configuration;
- private CdkContext context;
- private Template template;
- @Override
- public void init(CdkContext context) {
- this.context = context;
- this.configuration = new CdkConfiguration(context);
+ private final Configuration configuration;
+ private final Template template;
+
+ private final ComponentLibrary library;
+
+ private final FileManager output;
+
+ @Inject
+ public FreeMarkerRenderer(Configuration configuration,ComponentLibrary library, FileManager output) {
+ this.configuration = configuration;
+ this.library = library;
+ this.output = output;
+
try {
template = configuration.getTemplate(getTemplateName());
} catch (IOException e) {
@@ -65,7 +72,7 @@
@Override
public void render() throws CdkException {
- context.getLibrary().accept(this, getVisitorParameter());
+ library.accept(this, getVisitorParameter());
}
private P getVisitorParameter() {
@@ -109,10 +116,8 @@
lastModified = trackuble.lastModified();
}
- File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c), lastModified);
-
try {
- return new FileWriter(sourceOutput);
+ return output.createOutput(getOutputFile(c), lastModified);
} catch (IOException e) {
throw new CdkException(e);
}
@@ -123,14 +128,4 @@
protected abstract boolean isMyComponent(Visitable c);
protected abstract String getTemplateName();
-
- protected abstract OutputType getOutputType();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,11 +25,12 @@
package org.richfaces.cdk.freemarker;
+import org.richfaces.cdk.model.ModelElementBase;
+
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.cdk.model.ModelElementBase;
/**
* <p class="changed_added_4_0"></p>
@@ -37,6 +38,7 @@
*
*/
public class LibraryModelWrapper extends BeansWrapper implements ObjectWrapper {
+
public LibraryModelWrapper() {
super();
setStrict(true);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,23 +25,25 @@
package org.richfaces.cdk.freemarker;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -30,7 +30,6 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
-
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,21 +22,31 @@
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+
/**
* @author akolonitsky
* @since Jan 18, 2010
*/
public class ValidatorTaglibGenerator extends FreeMarkerRenderer<ValidatorModel, ComponentLibrary>{
+ @Inject
+ public ValidatorTaglibGenerator(Configuration configuration, ComponentLibrary library, @OutputFolder(StandardOutputFolders.RESOURCES)FileManager output) {
+ super(configuration, library, output);
+ }
+
@Override
protected String getOutputFile(ValidatorModel validatorModel) throws CdkException {
return validatorModel.getValidatorClass().getName().replace('.', File.separatorChar) + "-taglib.xml";
@@ -51,9 +61,4 @@
protected String getTemplateName() {
return "taglib/validator.ftl";
}
-
- @Override
- protected CdkContext.OutputType getOutputType() {
- return StandardOutputs.TAG_LIBRARY;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,17 +22,22 @@
package org.richfaces.cdk.generate.java;
+import java.io.File;
+
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
+import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Visitable;
-import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
-import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.StandardOutputs;
-import java.io.File;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
@@ -43,9 +48,9 @@
* (non-Javadoc)
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
- @Override
- public void init(CdkContext context) {
- super.init(context);
+ @Inject
+ public BehaviorClassGenerator(Configuration configuration, ComponentLibrary library, @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output) {
+ super(configuration, library, output);
}
@Override
@@ -67,8 +72,4 @@
return "behavior.ftl";
}
- @Override
- protected CdkContext.OutputType getOutputType() {
- return StandardOutputs.BEHAVIOR_CLASSES;
- }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.generate.java;
+
+import org.richfaces.cdk.CdkWriter;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ClassGeneratorModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<CdkWriter> setBinder = Multibinder.newSetBinder(binder(),CdkWriter.class);
+ setBinder.addBinding().to(ComponentClassGenerator.class);
+ setBinder.addBinding().to(ConverterClassGenerator.class);
+ setBinder.addBinding().to(ValidatorClassGenerator.class);
+ setBinder.addBinding().to(BehaviorClassGenerator.class);
+ }
+
+}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,18 +25,22 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.CdkContext.OutputType;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
-import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -48,9 +52,9 @@
* (non-Javadoc)
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
- @Override
- public void init(CdkContext context) {
- super.init(context);
+ @Inject
+ public ComponentClassGenerator(Configuration configuration, ComponentLibrary library, @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output) {
+ super(configuration, library, output);
}
@Override
@@ -71,9 +75,4 @@
protected String getTemplateName() {
return "component.ftl";
}
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.COMPONENT_CLASSES;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,25 +22,32 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+
/**
* @author akolonitsky
* @since Jan 20, 2010
*/
public class ConverterClassGenerator extends FreeMarkerRenderer<ConverterModel, ComponentLibrary> implements CdkWriter {
- @Override
- public void init(CdkContext context) {
- super.init(context);
+
+ @Inject
+ public ConverterClassGenerator(Configuration configuration, ComponentLibrary library,
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output) {
+ super(configuration, library, output);
}
@Override
@@ -61,9 +68,4 @@
protected String getTemplateName() {
return "converter.ftl";
}
-
- @Override
- protected CdkContext.OutputType getOutputType() {
- return StandardOutputs.CONVERTER_CLASSES;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,25 +22,31 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+
/**
* @author akolonitsky
* @since Jan 15, 2010
*/
public class ValidatorClassGenerator extends FreeMarkerRenderer<ValidatorModel, ComponentLibrary> implements CdkWriter {
- @Override
- public void init(CdkContext context) {
- super.init(context);
+
+ @Inject
+ public ValidatorClassGenerator(Configuration configuration, ComponentLibrary library, @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output) {
+ super(configuration, library, output);
}
@Override
@@ -61,9 +67,4 @@
protected String getTemplateName() {
return "validator.ftl";
}
-
- @Override
- protected CdkContext.OutputType getOutputType() {
- return StandardOutputs.VALIDATOR_CLASSES;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+
import com.google.common.collect.ImmutableMap;
-import java.io.Serializable;
-
/**
* <p class="changed_added_4_0">
* Tthat class represents information about Jsf object class.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,9 +25,6 @@
package org.richfaces.cdk.model;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.model.RenderKitModel.Id;
-
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -38,6 +35,11 @@
import java.util.Map;
import java.util.NoSuchElementException;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.model.RenderKitModel.Id;
+
+import com.google.inject.Singleton;
+
/**
* <p class="changed_added_4_0">
* That class contains model of all JSF components asscoiated with that project
@@ -50,6 +52,7 @@
* @author asmirnov(a)exadel.com
*
*/
+@Singleton
public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>, Trackable {
public static final String CDK_EXTENSIONS_NAMESPACE = "http://richfaces.org/cdk/extensions";
public static final String FACES_CONFIG_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,10 +1,10 @@
package org.richfaces.cdk.model;
-import org.richfaces.cdk.CdkException;
-
import java.util.Collection;
import java.util.Map;
+import org.richfaces.cdk.CdkException;
+
/**
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,11 +23,13 @@
package org.richfaces.cdk.model;
-import org.dom4j.Element;
-import javax.xml.bind.annotation.XmlAnyElement;
import java.util.List;
+import javax.xml.bind.annotation.XmlAnyElement;
+
+import org.w3c.dom.Element;
+
/**
* <p class="changed_added_4_0">That class represents all faces-config "extension" fields.</p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,9 +23,10 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
-import java.io.Serializable;
/**
* <p class="changed_added_4_0"></p>
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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.model;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ModelModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ bind(ComponentLibrary.class).in(Singleton.class);
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.model;
+import java.util.List;
+
import com.google.common.collect.Lists;
-import java.util.List;
-
/**
* <p class="changed_added_4_0">That class contains properties collection from standard include file.</p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,13 +23,13 @@
package org.richfaces.cdk.model;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
import org.richfaces.cdk.CdkException;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
/**
* That class represents JSF component property.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,9 +23,9 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.io.Serializable;
/**
* <p class="changed_added_4_0">That bean represents whole tag library.</p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -41,8 +41,8 @@
import javax.faces.render.Renderer;
import javax.faces.validator.Validator;
+import org.richfaces.cdk.JavaLogger;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.util.ArrayUtils;
@@ -52,7 +52,7 @@
*/
public final class TypesFactory {
- private static final Logger LOG = LoggerFactory.getLogger();
+ private static Logger log = new JavaLogger();
private static final Map<java.lang.reflect.Type, Type> REFLECTION_TYPES_CACHE = Collections
.synchronizedMap(new HashMap<java.lang.reflect.Type, Type>());
@@ -150,8 +150,8 @@
} catch (ClassNotFoundException e) {
// ignore
} catch (LinkageError e) {
- if (LOG.isInfoEnabled()) {
- LOG.info(MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", guessTypeName,
+ if (log.isInfoEnabled()) {
+ log.info(MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", guessTypeName,
e.getMessage()));
}
}
@@ -166,8 +166,8 @@
} catch (LinkageError e) {
String errorMessage = MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", className,
e.getMessage());
- if (LOG.isInfoEnabled()) {
- LOG.info(errorMessage);
+ if (log.isInfoEnabled()) {
+ log.info(errorMessage);
}
throw new ClassNotFoundException(errorMessage, e);
}
@@ -222,8 +222,8 @@
return baseType;
}
} else {
- if (LOG.isWarnEnabled()) {
- LOG.warn(MessageFormat.format("Cannot parse type signature: ''{0}''", typeString));
+ if (log.isWarnEnabled()) {
+ log.warn(MessageFormat.format("Cannot parse type signature: ''{0}''", typeString));
}
return getReferencedType(typeString);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,10 +1,10 @@
package org.richfaces.cdk.templatecompiler;
-import freemarker.template.TemplateException;
-
import java.io.IOException;
import java.io.Writer;
+import freemarker.template.TemplateException;
+
public interface FreeMarkerRenderer {
public void writeSnippet(String templateName, Object object, Writer writer)
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,10 +1,11 @@
package org.richfaces.cdk.templatecompiler;
+import org.richfaces.builder.model.MethodBodyStatement;
+
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.builder.model.MethodBodyStatement;
public class JavaClassModelWrapper extends BeansWrapper implements ObjectWrapper {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,11 @@
package org.richfaces.cdk.templatecompiler;
+import org.richfaces.builder.model.MethodBodyStatement;
+
import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.builder.model.MethodBodyStatement;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,17 +23,18 @@
package org.richfaces.cdk.templatecompiler;
-import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.Writer;
import java.util.Collection;
import java.util.Map;
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.ComponentModel;
import org.richfaces.cdk.model.Property;
@@ -41,9 +42,9 @@
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.RendererModel.Type;
import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
import com.google.common.collect.Maps;
+import com.google.inject.Inject;
import freemarker.template.TemplateException;
@@ -54,23 +55,37 @@
* @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;
}
-
+
private ComponentModel findComponentByRenderer(RendererModel renderer) {
String rendererFamily = renderer.getFamily();
Type rendererType = renderer.getType();
- Collection<ComponentModel> components = context.getLibrary().getComponents();
+ Collection<ComponentModel> components = library.getComponents();
if (components != null) {
for (ComponentModel component : components) {
if (!rendererFamily.equals(component.getFamily())) {
@@ -99,7 +114,6 @@
*/
@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();
@@ -112,45 +126,32 @@
}
attributesMap.putAll(renderer.getAttributes());
+ RendererClassVisitor visitor = visitorFactory.createVisitor(template.getInterface(), attributesMap);
- RendererClassVisitor visitor = new RendererClassVisitor(template.getInterface(),
- attributesMap, context.getLoader(), context.getWorker(JAXBBinding.class));
-
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 {
+ Writer outFile =
+ output.createOutput(fullName.replace('.', '/') + ".java", library.lastModified());
- 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();
- }
+ if (null != outFile) {
+ this.renderer.writeSnippet("class", javaClass, outFile);
+ outFile.close();
}
+ } catch (IOException e) {
+ throw new CdkException(e);
+ } catch (TemplateException e) {
+ throw new CdkException(e);
}
+ }
- }
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -48,7 +48,6 @@
import org.richfaces.builder.model.MethodBodyStatementsContainer;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.attributes.Attribute;
import org.richfaces.cdk.attributes.Element;
import org.richfaces.cdk.attributes.Schema;
@@ -70,14 +69,16 @@
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.JAXBBinding;
+import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
/**
@@ -118,14 +119,10 @@
*/
private static final String PASS_THROUGH_ATTRIBUTES_FIELD_NAME = "PASS_THROUGH_ATTRIBUTES";
- private static final Logger LOG = LoggerFactory.getLogger();
+ private static final Set<String> DEFAULT_NAMESPACES = ImmutableSet.of(Template.XHTML_EL_NAMESPACE,Template.XHTML_NAMESPACE);
- private static final Set<String> DEFAULT_NAMESPACES = new HashSet<String>();
+ private final Logger log;
- static {
- DEFAULT_NAMESPACES.add(Template.XHTML_EL_NAMESPACE);
- DEFAULT_NAMESPACES.add(Template.XHTML_NAMESPACE);
- }
private MethodBodyStatementsContainer currentStatement;
@@ -145,11 +142,11 @@
private Map<String, Property> attributes;
public RendererClassVisitor(CompositeInterface compositeInterface, Map<String, Property> attributes,
- ClassLoader classLoader, JAXBBinding jaxbBinding) {
+ ClassLoader classLoader, JAXB jaxbBinding, Logger log) {
this.compositeInterface = compositeInterface;
this.attributes = attributes;
this.classLoader = classLoader;
-
+ this.log = log;
// TODO - cache unmarshalled data (as CDKWorker?)
SchemaSet schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
this.attributesSchema = schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
@@ -740,7 +737,7 @@
/**
*
*/
- public void preProcess() {
+ public void preProcess(CompositeImplementation impl) {
initializeJavaClass();
passThroughCounter = -1;
}
@@ -748,7 +745,7 @@
/**
*
*/
- public void postProcess() {
+ public void postProcess(CompositeImplementation impl) {
flushToEncodeMethod("encodeEnd");
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -32,9 +32,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.richfaces.cdk.CdkContext;
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;
@@ -48,10 +50,11 @@
import org.richfaces.cdk.templatecompiler.model.ImportAttributes;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -66,9 +69,33 @@
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 FragmentParser fragmentParser;
+
+
- 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,FragmentParser fragmentParser) {
+ this.library = library;
+ this.jaxbBinding = jaxbBinding;
+ this.log = log;
+ this.sources = sources;
+ this.fragmentParser = fragmentParser;
+ }
private Set<EventName> convert(Collection<ClientBehavior> clientBehaviors) {
if (clientBehaviors == null || clientBehaviors.isEmpty()) {
@@ -124,7 +151,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);
@@ -134,7 +161,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());
@@ -164,7 +190,7 @@
if (attributesImports != null) {
for (ImportAttributes attributesImport : attributesImports) {
String importURI = attributesImport.getSource();
- Map<String, Property> properties = getContext().getWorker(FragmentParser.class).parseProperties(importURI);
+ Map<String, Property> properties = fragmentParser.parseProperties(importURI);
if (properties != null) {
rendererAttributes.putAll(properties);
}
@@ -186,7 +212,6 @@
rendererProperty.getEventNames().addAll(eventNamesSet);
}
- //TODO handle attributes - add extensions to schema & handling for them
// rendererProperty.setAliases(aliases)
// rendererProperty.setExtension(extension)
// rendererProperty.setGenerate(exists)
@@ -227,13 +252,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;
- }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,52 @@
+/*
+ * $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.CdkWriter;
+import org.richfaces.cdk.ModelBuilder;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TemplateModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<ModelBuilder> modelBinder = Multibinder.newSetBinder(binder(), ModelBuilder.class);
+ modelBinder.addBinding().to(RendererTemplateParser.class);
+ Multibinder.newSetBinder(binder(),CdkWriter.class).addBinding().to(RendererClassGenerator.class);
+ bind(new TypeLiteral<TemplateVisitorFactory<RendererClassVisitor>>(){}).to(VisitorFactoryImpl.class);
+ bind(FreeMarkerRenderer.class).to(JavaClassConfiguration.class);
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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.templatecompiler;
+
+import java.util.Map;
+
+import org.richfaces.cdk.model.Property;
+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,Map<String, Property> attributes);
+
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,68 @@
+/*
+ * $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 java.util.Map;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.xmlconfig.JAXB;
+
+import com.google.inject.Inject;
+
+/**
+ * <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,Map<String, Property> attributes) {
+ return new RendererClassVisitor(composite, attributes,classLoader, jaxbBinding, log);
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,12 +23,13 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.Map;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.namespace.QName;
-import java.util.Map;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.templatecompiler.model;
+import javax.xml.bind.annotation.XmlRootElement;
+
import org.richfaces.cdk.CdkException;
-import javax.xml.bind.annotation.XmlRootElement;
-
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,12 +23,12 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
-
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,13 +21,14 @@
*/
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
-import java.util.List;
+import org.richfaces.cdk.CdkException;
+
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,11 +21,11 @@
*/
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
-
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import org.richfaces.cdk.CdkException;
+
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,10 +21,10 @@
*/
package org.richfaces.cdk.templatecompiler.model;
+import javax.xml.bind.annotation.XmlRootElement;
+
import org.richfaces.cdk.CdkException;
-import javax.xml.bind.annotation.XmlRootElement;
-
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,11 +23,6 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import javax.xml.XMLConstants;
import javax.xml.bind.JAXB;
import javax.xml.bind.ValidationEventHandler;
@@ -40,6 +35,11 @@
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,8 +1,9 @@
package org.richfaces.cdk.templatecompiler.model;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
-import java.util.List;
public interface LeafModelElement extends ModelElement {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.templatecompiler.model;
+import java.util.List;
+
import com.google.common.collect.Lists;
-import java.util.List;
-
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,12 +1,13 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlSeeAlso;
-import java.util.List;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0">All classes that are used in template bodey should be presented
* in the {@link XmlSeeAlso} annotation </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -66,4 +66,8 @@
void endElement(CdkForEachElement cdkForEachElement);
+ void preProcess(CompositeImplementation compositeImplementation);
+
+ void postProcess(CompositeImplementation compositeImplementation);
+
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,14 +23,6 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.ImmutableMap;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContext.SourceType;
-import org.richfaces.cdk.StandardSources;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.EntityResolver2;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -38,6 +30,17 @@
import java.io.InputStream;
import java.net.URI;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.EntityResolver2;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* That class resolves entities used by CDK ( standard JSF schemas, extensions,
@@ -87,11 +90,13 @@
"http://richfaces.org/cdk/xhtml-el.xsd",
URN_SYSTEM + "/xhtml-el.xsd").build();
- private final CdkContext context;
- public CdkEntityResolver(CdkContext context) {
- this.context = context;
- }
+ @Inject
+ private CdkClassLoader loader;
+ @Inject @Source(StandardSources.FACES_CONFIGS)
+ private FileManager facesConfigFolders;
+ @Inject @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager rendererTemplatesFolders;
/*
* (non-Javadoc)
@@ -178,7 +183,7 @@
// Project resources
String path = systemIdInternal.substring(URN_RESOURCE.length());
- InputStream inputStream = getContext().getLoader().getResourceAsStream(RESOURCE_PREFIX + path);
+ InputStream inputStream = loader.getResourceAsStream(RESOURCE_PREFIX + path);
if (null != inputStream) {
entity = new InputSource(inputStream);
@@ -189,7 +194,7 @@
// project classloader.
String path = systemIdInternal.substring(URN_ATTRIBUTES.length());
// Project classpath has precedence
- InputStream inputStream = getContext().getLoader().getResourceAsStream(ATTRIBUTES_PREFIX + path);
+ InputStream inputStream = loader.getResourceAsStream(ATTRIBUTES_PREFIX + path);
if (null == inputStream) {
inputStream = getClass().getClassLoader().getResourceAsStream(ATTRIBUTES_PREFIX + path);
}
@@ -201,13 +206,13 @@
// Config folder.
String path = systemIdInternal.substring(URN_CONFIG.length());
- entity = getProjectInputSource(StandardSources.FACES_CONFIGS, path);
+ entity = getProjectInputSource(facesConfigFolders, path);
} else if (systemIdInternal.startsWith(URN_TEMPLATES)) {
// Templates folder.
String path = systemIdInternal.substring(URN_TEMPLATES.length());
- entity = getProjectInputSource(StandardSources.RENDERER_TEMPLATES, path);
+ entity = getProjectInputSource(rendererTemplatesFolders, path);
}
if (null != entity) {
@@ -217,34 +222,20 @@
return entity;
}
- protected InputSource getProjectInputSource(SourceType type, String path) throws FileNotFoundException {
- Iterable<File> folders = getContext().getSourceFolders(type);
+ 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 (null != configFile && configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
+ entity = new InputSource(inputStream);
- break;
- }
- }
}
return entity;
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,15 +25,18 @@
package org.richfaces.cdk.xmlconfig;
-import java.io.File;
+import java.io.Writer;
-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.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -47,19 +50,16 @@
+ ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
private static final String FACES_CONFIG_XML = "META-INF/faces-config.xml";
- private CdkContext context;
- private JAXBBinding jaxbBinding;
+ @Inject
+ private JAXB jaxbBinding;
+ @Inject
+ private ComponentLibrary library;
+ @Inject @OutputFolder(StandardOutputFolders.RESOURCES)
+ private FileManager outputFileManager;
+
private FacesConfigAdapter libraryAdapter;
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- jaxbBinding = context.getWorker(JAXBBinding.class);
+ public FacesConfigGenerator() {
libraryAdapter = new FacesConfigAdapter();
}
@@ -73,24 +73,19 @@
@Override
public void render() throws CdkException {
- ComponentLibrary library = context.getLibrary();
// TODO - check modification time.
- File facesConfigXml = context.createOutputFile(StandardOutputs.FACES_CONFIG, FACES_CONFIG_XML,
- library.lastModified());
+ try {
+ Writer facesConfigXml = outputFileManager.createOutput(FACES_CONFIG_XML, library.lastModified());
- if (null != facesConfigXml) {
- try {
-
- // TODO - transform output to strip prefixes from faces-config
- // namespace.
+ if (null != facesConfigXml) {
jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION, libraryAdapter.marshal(library));
- } catch (Exception e) {
- if (e instanceof CdkException) {
- throw(CdkException) e;
- } else {
- throw new CdkException(e);
- }
}
+ } catch (Exception e) {
+ if (e instanceof CdkException) {
+ throw (CdkException) e;
+ } else {
+ throw new CdkException(e);
+ }
}
}
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,15 +23,18 @@
package org.richfaces.cdk.xmlconfig;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.Source;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
-import java.io.File;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -44,18 +47,13 @@
private static final FacesConfigAdapter ADAPTER = new FacesConfigAdapter();
- private CdkContext context;
- private JAXBBinding jaxbBinding;
+ @Inject
+ private JAXB jaxbBinding;
+ @Inject
+ private ComponentLibrary library;
+ @Inject @Source(StandardSources.FACES_CONFIGS)
+ private FileManager configFiles;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
/*
* (non-Javadoc)
@@ -64,41 +62,25 @@
*/
@Override
public void build() throws CdkException {
- ComponentLibrary library = context.getLibrary();
- Iterable<File> sources = context.getSources(StandardSources.FACES_CONFIGS);
- if (null != sources) {
- for (File file : sources) {
- FacesConfigBean unmarshal = unmarshalFacesConfig(file);
- if (null != unmarshal) {
- ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
- library.getComponents().addAll(facesConfig.getComponents());
- library.getRenderKits().putAll(facesConfig.getRenderKits());
- library.getConverters().addAll(facesConfig.getConverters());
- // 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());
- }
+ for (File file : configFiles.getFiles()) {
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
+ if (null != unmarshal) {
+ ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
+ library.getComponents().addAll(facesConfig.getComponents());
+ library.getRenderKits().putAll(facesConfig.getRenderKits());
+ library.getConverters().addAll(facesConfig.getConverters());
+ // 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());
}
-
}
}
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) {
- this.context = context;
- jaxbBinding = context.getWorker(JAXBBinding.class);
- }
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,73 +21,56 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.xmlconfig;
import java.util.Collections;
import java.util.Map;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.model.ComponentAdapter;
import org.richfaces.cdk.xmlconfig.model.Fragment;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
- * That class parses xml document with fragment of faces-config ( eg, standard
- * component attributes )
+ * That class parses xml document with fragment of faces-config ( eg, standard component attributes )
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class FragmentParser implements CdkWorker {
- private CdkContext context;
+public class FragmentParser {
+
private ComponentAdapter adapter;
+ private final JAXB binding;
- public FragmentParser() {}
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
- public void init(CdkContext context) {
+ @Inject
+ public FragmentParser(JAXB binding) {
+ this.binding = binding;
this.adapter = new ComponentAdapter();
- this.context = context;
}
/**
* <p class="changed_added_4_0">
* Parses faces-config.xml fragment with component/renderer properties.
* </p>
- *
+ *
* @param url
* @return
*/
public Map<String, Property> parseProperties(String url) throws CdkException {
String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
Class<Fragment> bindClass = Fragment.class;
- Fragment unmarshal = getBinding().unmarshal(url, schemaLocation, bindClass);
- if(null != unmarshal ){
+ Fragment unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
+ if (null != unmarshal) {
ComponentModel component = adapter.unmarshal(unmarshal);
return component.getAttributes();
} else {
- return Collections.<String, Property>emptyMap();
+ return Collections.<String, Property> emptyMap();
}
}
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the binding
- */
- protected JAXBBinding getBinding() {
- return context.getWorker(JAXBBinding.class);
- }
}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,20 @@
+package org.richfaces.cdk.xmlconfig;
+
+import java.io.File;
+import java.io.Writer;
+
+import javax.xml.transform.Result;
+
+import org.richfaces.cdk.CdkException;
+
+public interface JAXB {
+
+ public abstract <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException;
+
+ public abstract <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException;
+
+ public abstract <T> void marshal(Writer output, String schemaLocation, T model) throws CdkException;
+
+ public abstract <T> void marshal(Result output, String schemaLocation, T model) throws CdkException;
+
+}
\ No newline at end of file
Modified: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -30,10 +30,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.io.Writer;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
@@ -51,17 +51,17 @@
import javax.xml.transform.stream.StreamResult;
import org.apache.cocoon.pipeline.component.sax.XIncludeTransformer;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.Extensible;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
+import org.xml.sax.ext.EntityResolver2;
import org.xml.sax.helpers.XMLReaderFactory;
import com.google.common.collect.ImmutableSet;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -70,12 +70,12 @@
* @author asmirnov(a)exadel.com
*
*/
-public class JAXBBinding implements CdkWorker {
+public class JAXBBinding implements JAXB {
private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new FacesConfigNamespacePreffixMapper();
private static final ImmutableSet<String> IGNORE_PROPERTIES = ImmutableSet.of("class", "extension");
- private CdkContext context;
- private CdkEntityResolver resolver;
+ @Inject
+ private EntityResolver2 resolver;
public JAXBBinding() { }
@@ -85,11 +85,11 @@
*
* @param context
*/
- public void init(CdkContext context) {
- this.context = context;
- this.resolver = new CdkEntityResolver(context);
- }
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.io.File, java.lang.String, java.lang.Class)
+ */
+ @Override
public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException {
try {
InputSource input = new InputSource(new FileInputStream(file));
@@ -104,9 +104,18 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.lang.String, java.lang.String, java.lang.Class)
+ */
+ @Override
public <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException {
try {
- InputSource inputSource = resolver.resolveSystemId(url);
+ InputSource inputSource;
+ try {
+ inputSource = resolver.resolveEntity(null, url);
+ } catch (SAXException e) {
+ inputSource = null;
+ }
if (null == inputSource) {
inputSource = new InputSource(url);
@@ -115,14 +124,14 @@
T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
return unmarshal;
- } catch (FileNotFoundException e) {
+ } catch (IOException e) {
throw new CdkException("XML file not found", e);
}
}
@SuppressWarnings("unchecked")
//TODO nick - schemaLocation is unused
- public <T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
+ <T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
T unmarshal = null;
try {
@@ -176,14 +185,17 @@
return unmarshal;
}
- public <T> void marshal(File output, String schemaLocation, T model) throws CdkException {
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#marshal(java.io.File, java.lang.String, T)
+ */
+ @Override
+ public <T> void marshal(Writer output, String schemaLocation, T model) throws CdkException {
try {
- FileOutputStream outputStream = new FileOutputStream(output);
- StreamResult result = new StreamResult(outputStream);
+ StreamResult result = new StreamResult(output);
marshal(result, schemaLocation, model);
- outputStream.flush();
- outputStream.close();
+ output.flush();
+ output.close();
} catch (FileNotFoundException e) {
throw new CdkException("File not found", e);
} catch (IOException e) {
@@ -191,6 +203,10 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#marshal(javax.xml.transform.Result, java.lang.String, T)
+ */
+ @Override
public <T> void marshal(Result output, String schemaLocation, T model) throws CdkException {
try {
JAXBContext jc = JAXBContext.newInstance(model.getClass());
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.ModelBuilder;
+import org.xml.sax.ext.EntityResolver2;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+public class XmlModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ bind(EntityResolver2.class).to(CdkEntityResolver.class);
+ bind(JAXB.class).to(JAXBBinding.class);
+ bind(NamespacePrefixMapper.class).to(FacesConfigNamespacePreffixMapper.class);
+ Multibinder<ModelBuilder> modelBinder = Multibinder.newSetBinder(binder(), ModelBuilder.class);
+ modelBinder.addBinding().to(FacesConfigParser.class);
+ Multibinder.newSetBinder(binder(),CdkWriter.class).addBinding().to(FacesConfigGenerator.class);
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,15 +23,17 @@
package org.richfaces.cdk.xmlconfig.model;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ModelElement;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,17 +22,18 @@
package org.richfaces.cdk.xmlconfig.model;
-import com.google.common.collect.Lists;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.List;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import com.google.common.collect.Lists;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
Modified: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,9 +25,9 @@
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentModel.Type;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.ComponentModel.Type;
/**
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,16 +23,16 @@
import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import com.google.common.collect.Lists;
-import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
/**
* @author akolonitsky
* @since Jan 6, 2010
Modified: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -31,14 +31,14 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.Extensible;
-import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.BehaviorModel;
import com.google.common.collect.Lists;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,15 +21,16 @@
package org.richfaces.cdk.xmlconfig.model;
-import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.ComponentLibrary;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.List;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+
import com.google.common.collect.Lists;
/**
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,10 +21,10 @@
package org.richfaces.cdk.xmlutils;
+import java.util.Comparator;
+
import org.w3c.dom.Node;
-import java.util.Comparator;
-
/**
* @author Nick Belaevski
* @since 3.2.2
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,6 +21,20 @@
package org.richfaces.cdk.xmlutils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
@@ -30,19 +44,6 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
class ArrayNodeList implements NodeList {
private Node[] nodes;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,15 +21,6 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -37,6 +28,16 @@
import java.util.List;
import java.util.Set;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,9 +21,7 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.NodeList;
+import java.io.StringWriter;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Transformer;
@@ -31,8 +29,11 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.StringWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,13 +21,14 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Node;
+import java.util.Comparator;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import java.util.Comparator;
+import org.w3c.dom.Node;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,10 +21,10 @@
package org.richfaces.cdk.xmlutils.dtd;
+import java.net.URL;
+
import org.richfaces.cdk.xmlutils.dtd.wutka.WutkaDefinitionFactory;
-import java.net.URL;
-
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,27 +21,30 @@
package org.richfaces.cdk.xmlutils.dtd.wutka;
-import com.wutka.dtd.DTD;
-import com.wutka.dtd.DTDAttribute;
-import com.wutka.dtd.DTDElement;
-import com.wutka.dtd.DTDParser;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.Attribute;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
import org.richfaces.cdk.xmlutils.dtd.Element;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
+import com.google.inject.Inject;
+import com.wutka.dtd.DTD;
+import com.wutka.dtd.DTDAttribute;
+import com.wutka.dtd.DTDElement;
+import com.wutka.dtd.DTDParser;
/**
* @author Maksim Kaszynski
*/
public class WutkaDefinitionFactory extends DocumentDefinitionFactory {
- private final Logger log = LoggerFactory.getLogger();
+
+ @Inject
+ private Logger log;
private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,6 +23,11 @@
package org.richfaces.cdk.xmlutils.dtd.xerces;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.xerces.impl.Constants;
import org.apache.xerces.parsers.XMLGrammarPreparser;
import org.apache.xerces.xni.XNIException;
@@ -32,14 +37,10 @@
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xs.XSModel;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -102,7 +103,9 @@
// feature: continue-after-fatal-error
public static final String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX
+ Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
- private final Logger log = LoggerFactory.getLogger();
+
+ @Inject
+ private Logger log;
private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
@Override
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/As.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/As.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/As.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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 As {
+ public Class<?> value();
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,42 @@
+/*
+ * $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;
+
+import com.google.inject.Provider;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface AsProvider {
+ public Class<? extends Provider<?>> value();
+}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -29,11 +29,14 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.Collections;
+import java.util.Locale;
import java.util.logging.LogManager;
import org.junit.After;
@@ -41,20 +44,26 @@
import org.richfaces.cdk.annotations.Component;
import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Module;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public abstract class CdkTestBase {
+public abstract class CdkTestBase implements Module {
protected Iterable<File> testSourceDirectory;
+
+ protected File tempDir;
@Before
public void setUpSourceDirectory() throws Exception {
- testSourceDirectory = Collections.singleton(getJavaFile("test.source.properties").getParentFile());
+ testSourceDirectory = Collections.singleton(getLibraryFile("test.source.properties"));
+ this.tempDir = File.createTempFile("cdk", "test");
+
InputStream stream = this.getClass().getResourceAsStream("logging.properties");
if (null != stream) {
@@ -78,6 +87,12 @@
public void tearDownSourceDirectory() {
testSourceDirectory = null;
}
+
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(Locale.class).toInstance(Locale.getDefault());
+ binder.bind(Charset.class).toInstance(Charset.defaultCharset());
+ }
protected File getJavaFile(String name) throws URISyntaxException {
ClassLoader classLoader = this.getClass().getClassLoader();
@@ -114,7 +129,11 @@
return getLibraryFile(clazz.getName().replaceAll("\\.", "/")+".class");
}
- protected CdkClassLoader createClassLoader() throws Exception {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null);
+ protected CdkClassLoader createClassLoader(){
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,223 @@
+/*
+ * $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.runner.notification.RunNotifier;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.FrameworkMethod;
+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.ImplementedBy;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.ProvidedBy;
+import com.google.inject.Provider;
+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 void runChild(FrameworkMethod method, RunNotifier notifier) {
+ super.runChild(method, notifier);
+ }
+
+ @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,Binding> 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() ) {
+ Binding binding = fieldValues.get(field);
+ field.setAccessible(true);
+ if ( null != binding.value && field.get(test) == null ) {
+ field.set(test, binding.value);
+ }
+ }
+
+ return test;
+ }
+
+ private Object createTest(Class<?> testClass, Map<Field, Binding> 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,Binding> fields;
+
+ public FieldModule(Map<Field,Binding> 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);
+ }
+ }
+ }
+ Binding binding = fields.get(field);
+ if(null != binding.value){
+ builder.toInstance(binding.value);
+ } else if (null != binding.implementation) {
+ builder.to(binding.implementation);
+ } else if (null != binding.provider) {
+ builder.toProvider(binding.provider);
+ }
+ }
+ }
+ }
+
+ private static class Binding {
+ private Object value;
+ private Class<?> implementation;
+ private Class<? extends Provider<?>> provider;
+ }
+
+ private Map<Field, Binding> getMockValues(Set<Field> testFields) {
+ Map<Field,Binding> mocksAndStubs = new HashMap<Field,Binding>();
+
+ for ( Field field : testFields ) {
+ if ( field.getAnnotation(Mock.class) != null ) {
+ Binding bind = new Binding();
+ bind.value = EasyMock.createStrictMock(field.getType());
+ mocksAndStubs.put(field, bind);
+ } else if ( field.getAnnotation(Stub.class) != null ) {
+ Binding bind = new Binding();
+ bind.value = EasyMock.createNiceMock(field.getType());
+ mocksAndStubs.put(field, bind);
+ } else if (null != field.getAnnotation(As.class)) {
+ Binding bind = new Binding();
+ bind.implementation = field.getAnnotation(As.class).value();
+ mocksAndStubs.put(field, bind);
+ } else if (null != field.getAnnotation(AsProvider.class)) {
+ Binding bind = new Binding();
+ bind.provider = field.getAnnotation(AsProvider.class).value();
+ mocksAndStubs.put(field, bind);
+ }
+ }
+
+ return mocksAndStubs;
+ }
+
+
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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) {
+
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -28,14 +28,8 @@
* @author asmirnov
*
*/
-(a)RunWith(Parameterized.class)
-public class LibraryBuilderTest {
- private String param;
+public class LibraryBuilderTest extends CdkTestBase {
- public LibraryBuilderTest(String param) {
- this.param = param;
- }
-
/**
* @throws java.lang.Exception
*/
@@ -50,15 +44,15 @@
/**
* Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
+ * @throws Exception
*/
@Test
- public void createInstance() {
-
-// assertEquals("Parameter match","Two", param);
+ public void testInit() throws Exception {
+ Generator generator = new Generator();
+ // setup CDK configuration.
+ generator.setLoader(createClassLoader());
+ // Test dependencies tree.
+ generator.init();
}
- @Parameters
- public static Collection<String[]> values() {
- return Arrays.asList(new String[] {"One"}, new String[] {"Two"}, new String[] {"Tree"});
- }
}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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 {
+
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,37 @@
+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);
+ }
+
+ @Test
+ public void easyMockInjections2() throws Exception {
+ assertNotNull(log);
+ assertNotNull(sources);
+ replay(log,sources);
+ verify(log,sources);
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -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 {
+
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,70 +21,74 @@
package org.richfaces.cdk.apt;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.ELContext;
+import javax.faces.component.UIComponent;
+
+import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.SourceFileManager;
+import org.richfaces.cdk.SourceImpl;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.RichFacesConventions;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.Stub;
import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+
import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
-import javax.el.ELContext;
-import javax.faces.component.UIComponent;
-
/**
* @author akolonitsky
* @since Jan 14, 2010
*/
public abstract class AnnotationProcessorTest extends CdkTestBase {
+
+ @Inject
+ @Source(StandardSources.JAVA_SOURCES)
+ protected FileManager sources;
- protected ComponentLibrary prepareMockCompilationContext(String javaFilePath) throws Exception {
- CdkContext cdkContext = createMockContext();
- CdkProcessor processor = new CdkProcessor();
- AptBuilder compiler = new AptBuilder();
+ @Mock
+ protected Logger log;
- compiler.init(cdkContext);
- processor.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(javaFilePath)), processor);
-
- return cdkContext.getLibrary();
- }
-
- protected CdkContext createMockContext() throws Exception {
- CdkContextBase baseContext = new CdkContextBase(createClassLoader());
- baseContext.setSourceFolders(StandardSources.JAVA_SOURCES, testSourceDirectory);
- RichFacesConventions richFacesConventions = new RichFacesConventions();
- baseContext.setWorker(NamingConventions.class, richFacesConventions);
- baseContext.setWorker(ModelValidator.class, new ModelValidator() {
-
- @Override
- public void init(CdkContext context) {
-
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader cdkClassLoader = createClassLoader();
+ binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
+ List<File> sourceFiles = new ArrayList<File>();
+ for (String src : sources()) {
+ sourceFiles.add(getJavaFile(src));
}
+ binder.bind(FileManager.class).annotatedWith(new SourceImpl(StandardSources.JAVA_SOURCES)).toInstance(new SourceFileManager(sourceFiles, this.testSourceDirectory));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
- @Override
- public void verify(ComponentLibrary library) throws CdkException {
- }
- });
- baseContext.sendError(new CdkProcessingException());
-
- return baseContext;
}
+ protected abstract Iterable<String> sources();
+
@Override
- protected CdkClassLoader createClassLoader() throws Exception {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class),
- getLibraryFile(ELContext.class),
- getLibraryFile(Family.class),
- getLibraryFile(UIComponent.class)),
- this.getClass().getClassLoader());
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(ComponentModel.class),
+ getLibraryFile(ELContext.class),
+ getLibraryFile(Family.class),
+ getLibraryFile(UIComponent.class)),
+ this.getClass().getClassLoader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,22 +23,33 @@
package org.richfaces.cdk.apt;
import static org.junit.Assert.assertEquals;
+
+import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import com.google.inject.Inject;
+
import java.util.Collection;
+import java.util.Collections;
/**
* @author akolonitsky
* @since Jan 21, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class BehaviorProcessorTest extends AnnotationProcessorTest {
private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
+ @Inject
+ private ComponentLibrary library;
+
@Test
+ @Ignore
public void testProcess() throws Exception {
- ComponentLibrary library = prepareMockCompilationContext(BEHAVIOR_CLASS_JAVA);
Collection<BehaviorModel> behaviors = library.getBehaviors();
assertEquals(2, behaviors.size());
@@ -50,4 +61,10 @@
}
}
}
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(BEHAVIOR_CLASS_JAVA);
+ }
+
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -27,48 +27,40 @@
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import static javax.lang.model.util.ElementFilter.*;
-
-import java.io.File;
-
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-
+import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.Set;
-import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-
-import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.ModelValidator;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.CdkContext.OutputType;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
-
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import static org.junit.Assert.*;
+
+
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -76,225 +68,96 @@
* @author asmirnov(a)exadel.com
*
*/
-public class CdkProcessorTest extends CdkTestBase {
+(a)RunWith(CdkTestRunner.class)
+public class CdkProcessorTest extends AnnotationProcessorTest {
private static final String ANNOTATION2 = TestAnnotation2.class.getName();
private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
private static final ImmutableSet<String> PROCESS_ANNOTATIONS = ImmutableSet.of(TestAnnotation.class.getName());
- private ClassLoader testLoader;
+
+ @Inject
+ private CdkProcessor processor;
+
+
+
+ @Stub
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES)
+ private FileManager output;
+
+ @Inject
+ private CdkAnnotationProcessor cdkProcessor;
+
+ @Mock
+ private RoundEnvironment roundEnv;
+
+ @Mock
+ private TypeElement element;
+
+ @Mock
+ private LibraryBuilder builder;
+
+ @Mock
+ private ModelValidator validator;
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkProcessor.class).in(Singleton.class);
+ binder.bind(Processor.class).to(CdkProcessor.class);
+ CdkAnnotationProcessor cdkProcessor = createMock(CdkAnnotationProcessor.class);
+ binder.bind(CdkAnnotationProcessor.class).toInstance(cdkProcessor);
+ binder.bind(new TypeLiteral<Set<CdkAnnotationProcessor>>(){}).toInstance(ImmutableSet.of(cdkProcessor));
+ binder.bind(new TypeLiteral<Set<ModelBuilder>>(){}).toInstance(Collections.<ModelBuilder>emptySet());
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return ImmutableList.of(CLASS_JAVA,INTERFACE_JAVA,SUB_CLASS_JAVA);
+ }
+
@Test
public void testProcess() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
-
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- Processor processor = createMock(Processor.class);
-
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
-
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>();
-
- expect(processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of("*"));
- expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
- replay(processor);
-
- AptBuilder compiler = new AptBuilder();
-
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
+ expect(roundEnv.processingOver()).andReturn(false);
+ expect((Class<TestAnnotation2>)cdkProcessor.getProcessedAnnotation()).andStubReturn(TestAnnotation2.class);
+ expect((Set<TypeElement>)roundEnv.getElementsAnnotatedWith(TestAnnotation2.class)).andReturn(Collections.singleton(element));
+ expect(element.getKind()).andReturn(ElementKind.CLASS);
+ cdkProcessor.process(element);expectLastCall();
+ validator.verify();expectLastCall();
+ replay(element,roundEnv,builder,validator,cdkProcessor);
+ processor.process(Collections.singleton(element), roundEnv);
+ verify(element,roundEnv,builder,validator,cdkProcessor);
}
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
+
@Test
- public void testProcessSubClass() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
-
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- Processor processor = createMock(Processor.class);
-
- processor.init((ProcessingEnvironment) anyObject());
- expect(processor.getSupportedOptions()).andReturn(ImmutableSet.<String>of());
-
- // processor.process(null,null);
- Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(CaptureType.FIRST);
-
- expect(processor.process(capture(capturedTypes),
- capture(new Capture<RoundEnvironment>()))).andReturn(true).times(2);
- expect(processor.getSupportedAnnotationTypes()).andReturn(ImmutableSet.of(TestAnnotation2.class.getName()));
- expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
- replay(processor);
-
- AptBuilder compiler = new AptBuilder();
-
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(SUB_CLASS_JAVA), getJavaFile(CLASS_JAVA)), processor);
- verify(cdkContext, processor);
-
- Set<? extends TypeElement> elements = capturedTypes.getValue();
-
- assertFalse(elements.isEmpty());
- assertEquals("TestAnnotation2", elements.iterator().next().getSimpleName().toString());
+ public void testProcessOver() throws Exception {
+ expect(roundEnv.processingOver()).andReturn(true);
+ expect(log.getErrorCount()).andReturn(0);
+ builder.generate();expectLastCall();
+ replay(log,element,roundEnv,builder,validator,cdkProcessor);
+ processor.process(Collections.singleton(element), roundEnv);
+ verify(log,element,roundEnv,builder,validator,cdkProcessor);
}
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
- * .
- *
- * @throws Exception
- */
+
@Test
- public void testGetClassesAnnotatedWith() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
-
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- TestProcessor processor = new TestProcessor() {
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- this.numOfComponents = roundEnv.getElementsAnnotatedWith(Component.class).size();
- }
-
- return true;
- }
- };
-
- processor.init(cdkContext);
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
-
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
+ public void testProcessOver2() throws Exception {
+ expect(roundEnv.processingOver()).andReturn(true);
+ expect(log.getErrorCount()).andReturn(1);
+ replay(log,element,roundEnv,builder,validator,cdkProcessor);
+ processor.process(Collections.singleton(element), roundEnv);
+ verify(log,element,roundEnv,builder,validator,cdkProcessor);
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#getClassesAnnotatedWith(RoundEnvironment, Class)}
- * .
- *
- * @throws Exception
- */
@Test
- public void testGetPropertiesAnnotatedWith() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMock(CdkContext.class);
-
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- TestProcessor processor = new TestProcessor() {
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!roundEnv.processingOver()) {
- SourceUtils utils = new SourceUtils(processingEnv,roundEnv);
- utils.init(getContext());
- TypeElement typeElement = utils.getClassesAnnotatedWith(Component.class).iterator().next();
- Set<BeanProperty> beanProperties = utils.getBeanPropertiesAnnotatedWith(Attribute.class, typeElement);
-
- assertEquals(3, beanProperties.size());
-
- BeanProperty property = Iterables.get(beanProperties, 2);
-
- assertEquals("foo", property.getName());
- assertEquals("int", property.getType().toString());
- assertNull(property.getDocComment());
- property = Iterables.get(beanProperties, 1);
- assertEquals("testValue", property.getName());
- assertEquals("java.util.List<java.lang.String>", property.getType().toString());
- assertEquals(" Test Attribute\n", property.getDocComment());
- property = Iterables.get(beanProperties, 0);
- assertEquals("barValue", property.getName());
- assertEquals("java.util.List<M>", property.getType().toString());
- assertEquals(" Bar Attribute\n", property.getDocComment());
-
-// assertEquals("<M>" ,property.getTypeParameters());
- numOfComponents++;
- }
-
- return true;
- }
- };
- processor.init(cdkContext);
-
- // ComponentLibrary library = new
- // ComponentLibrary("org.richfaces.cdk.test");
- // processor.library = library;
- AptBuilder compiler = new AptBuilder();
-
- compiler.init(cdkContext);
- compiler.process(ImmutableList.of(getJavaFile(COMPONENT_CLASS_JAVA)), processor);
- verify(cdkContext);
- assertTrue(processor.isInitialized());
- assertEquals(1, processor.numOfComponents);
+ public void testProcess3() throws Exception {
+ expect(roundEnv.processingOver()).andReturn(false);
+ expect((Class<TestAnnotation>)cdkProcessor.getProcessedAnnotation()).andStubReturn(TestAnnotation.class);
+ expect((Set<TypeElement>)roundEnv.getElementsAnnotatedWith(TestAnnotation.class)).andReturn(Collections.<TypeElement>emptySet());
+ validator.verify();expectLastCall();
+ replay(element,roundEnv,builder,validator,cdkProcessor);
+ processor.process(Collections.singleton(element), roundEnv);
+ verify(element,roundEnv,builder,validator,cdkProcessor);
}
- private abstract static class TestProcessor extends CdkProcessor {
- protected int numOfComponents;
-
- public TestProcessor() {
- }
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv) {
- super.init(processingEnv);
- }
-
- @Override
- public synchronized boolean isInitialized() {
- return super.isInitialized();
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
-
- // Process all annotations
- return ImmutableSet.of("*");
- }
- }
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -26,18 +26,31 @@
package org.richfaces.cdk.apt;
import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+import java.lang.annotation.Annotation;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
+import javax.lang.model.element.TypeElement;
+
+import org.junit.Ignore;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.Stub;
+import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.xmlconfig.JAXB;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
/**
* <p class="changed_added_4_0">
@@ -46,10 +59,29 @@
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class ComponentProcessorTest extends AnnotationProcessorTest {
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
+ @Inject
+ private ComponentProcessor processor;
+
+ @Inject
+ private ComponentLibrary library;
+
+
+ @Mock
+ private SourceUtils utils;
+
+ @Mock
+ private TypeElement componentElement;
+
+ @Mock
+ private JAXB jaxb;
+
+ @Mock
+ private NamingConventions conventions;
/**
* Test method for
* {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
@@ -58,8 +90,23 @@
* @throws Exception
*/
@Test
+ @Ignore
public void testProcess() throws Exception {
- ComponentLibrary library = prepareMockCompilationContext(COMPONENT_CLASS_JAVA);
+ expect(componentElement.getAnnotation(Component.class)).andReturn(new Component() {
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Component.class;
+ }
+
+ @Override
+ public String value() {
+ return "foo.Bar";
+ }
+ });
+ replay(log,utils,componentElement,jaxb,conventions);
+ processor.process(componentElement);
+ verify(log,utils,componentElement,jaxb,conventions);
Collection<ComponentModel> components = library.getComponents();
assertEquals(1, components.size());
@@ -70,24 +117,10 @@
assertEquals(3, attributes.size());
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)}
- * .
- *
- * @throws Exception
- */
- @Test
- public void testProcessFacesComponent() throws Exception {
- ComponentLibrary library = prepareMockCompilationContext(FACES_COMPONENT_CLASS_JAVA);
- Collection<ComponentModel> components = library.getComponents();
- assertEquals(1, components.size());
-
- ComponentModel component = Iterables.get(components, 0);
- Map<String, Property> attributes = component.getAttributes();
-
- assertEquals(0, attributes.size());
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(COMPONENT_CLASS_JAVA);
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,40 +21,36 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.junit.Ignore;
import org.junit.Test;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.RichFacesConventions;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.annotations.Family;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.ConverterModel;
-import org.richfaces.cdk.model.ClassDescription;
-import javax.el.ELContext;
-import javax.faces.component.UIComponent;
-import java.util.Collection;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 14, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ConverterProcessorTest extends AnnotationProcessorTest {
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/MyConverter.java";
+ @Inject
+ private ComponentLibrary library;
+
@Test
+ @Ignore
public void testProcess() throws Exception {
- ComponentLibrary library = prepareMockCompilationContext(COMPONENT_CLASS_JAVA);
Collection<ConverterModel> converters = library.getConverters();
assertEquals(3, converters.size());
@@ -65,4 +61,9 @@
assertEquals(Integer.class.getName(), forClass.getName());
}
}
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(COMPONENT_CLASS_JAVA);
+ }
}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java (from rev 16419, root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -0,0 +1,122 @@
+/*
+ * $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.apt;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.Set;
+
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import org.easymock.Capture;
+import org.easymock.CaptureType;
+import org.easymock.EasyMock;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.Stub;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public class TaskFactoryTest extends AnnotationProcessorTest {
+
+ private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
+ private static final String SUB_CLASS_JAVA = "org/richfaces/cdk/apt/TestSubClass.java";
+ private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
+
+
+ @Inject
+ private TaskFactoryImpl factory;
+
+
+ @Mock
+ Processor processor;
+
+ @Stub
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES)
+ private FileManager output;
+
+ /**
+ * Test method for {@link org.richfaces.cdk.apt.TaskFactoryImpl#get()}.
+ * @throws Exception
+ * @throws AptException
+ */
+ @Test
+ public void testGetTask() throws AptException, Exception {
+ expect(output.getFolders()).andReturn(null);
+ replay(log,processor,output);
+ CompilationTask task = factory.get();
+ assertNotNull(task);
+ verify(log,processor,output);
+ }
+
+ @Test
+ public void testTask() throws AptException, Exception {
+ expect(output.getFolders()).andReturn(null);
+ processor.init((ProcessingEnvironment) anyObject());expectLastCall();
+ expect(processor.getSupportedSourceVersion()).andReturn(SourceVersion.RELEASE_6);
+ expect(processor.getSupportedAnnotationTypes()).andReturn(Collections.singleton("*"));
+ expect(processor.getSupportedOptions()).andReturn(Collections.<String>emptySet());
+ // processor.process(null,null);
+ Capture<Set<? extends TypeElement>> capturedTypes = new Capture<Set<? extends TypeElement>>(CaptureType.FIRST);
+
+ expect(processor.process(capture(capturedTypes),
+ EasyMock.<RoundEnvironment>anyObject())).andReturn(true).times(2);
+ replay(log,processor,output);
+ CompilationTask task = factory.get();
+ assertTrue(task.call());
+ Set<? extends TypeElement> elements = capturedTypes.getValue();
+
+ assertFalse(elements.isEmpty());
+ assertEquals("TestAnnotation2", elements.iterator().next().getSimpleName().toString());
+ verify(log,processor,output);
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return ImmutableList.of(CLASS_JAVA,SUB_CLASS_JAVA);
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,17 +23,24 @@
import org.easymock.EasyMock;
import org.junit.Assert;
+import org.junit.Ignore;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.annotations.JsfValidator;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
+import com.google.inject.Inject;
+
import javax.lang.model.element.Modifier;
import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -41,12 +48,20 @@
* @author akolonitsky
* @since Jan 14, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ValidatorProcessorTest extends AnnotationProcessorTest {
private static final String VALIDATOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyValidator.java";
+ @Inject
+ private ComponentLibrary library;
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(VALIDATOR_CLASS_JAVA);
+ }
+
@Test
+ @Ignore
public void testProcess() throws Exception {
- ComponentLibrary library = prepareMockCompilationContext(VALIDATOR_CLASS_JAVA);
Collection<ValidatorModel> validators = library.getValidators();
assertEquals(2, validators.size());
@@ -60,6 +75,7 @@
}
@Test
+ @Ignore
public void testSetNames() {
ValidatorModel model;
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,19 +1,13 @@
package org.richfaces.cdk.freemarker;
-import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
import java.io.StringWriter;
-import java.io.Writer;
+import org.junit.Ignore;
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.CdkContext.OutputType;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.Visitable;
public class FreeMarkerRendererTest extends CdkTestBase {
@Test
@@ -23,46 +17,11 @@
}
@Test
+ @Ignore
public void testProcessComponent() throws Exception {
final StringWriter output = new StringWriter();
ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.Bar"));
- FreeMarkerRenderer<ComponentModel, Boolean> renderer = new FreeMarkerRenderer<ComponentModel, Boolean>() {
- @Override
- protected String getOutputFile(ComponentModel c) {
- return null;
- }
- @Override
- protected Writer getOutput(ComponentModel c) throws CdkException {
- return output;
- }
- @Override
- protected String getTemplateName() {
- return "testComponent.ftl";
- }
- @Override
- protected boolean isMyComponent(Visitable c) {
- return true;
- }
- @Override
- protected OutputType getOutputType() {
- return null;
- }
- };
- CdkContext cdkContext = createMockContext();
- renderer.init(cdkContext);
- renderer.processComponent(component, Boolean.TRUE);
assertEquals("foo.Bar", output.toString());
}
-
- private CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
-
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- return cdkContext;
- }
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,55 +22,81 @@
package org.richfaces.cdk.freemarker;
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+import java.util.Set;
+
+import javax.faces.component.UIOutput;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
-import static org.easymock.EasyMock.*;
import org.junit.Assert;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.ext.EntityResolver2;
-import javax.faces.component.UIOutput;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.ImplementedBy;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+import freemarker.template.ObjectWrapper;
+
/**
* @author akolonitsky
* @since Jan 18, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ValidatorTaglibGeneratorTest extends CdkTestBase {
+ @Inject
+ private ValidatorTaglibGenerator generator;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @As(CdkConfiguration.class)
+ private Configuration configuration;
+
+ @Inject
+ @As(LibraryModelWrapper.class)
+ ObjectWrapper wrapper;
+
+ @Mock
+ private EntityResolver2 resolver;
+
+ @Mock
+ @OutputFolder(StandardOutputFolders.RESOURCES)
+ private FileManager output;
+
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ValidatorTaglibGenerator generator = new ValidatorTaglibGenerator() {
- @Override
- protected Writer getOutput(ValidatorModel c) throws CdkException {
- return output;
- }
- };
+ final StringWriter outputWriter = new StringWriter();
- CdkContext mockContext = createMockContext();
- generator.init(mockContext);
ValidatorModel validator = new ValidatorModel("foo.bar", new ClassDescription(UIOutput.class));
validator.setGenerate(true);
@@ -83,14 +109,15 @@
eventNames.add(getEvent("id", false));
eventNames.add(getEvent("action", true));
- ComponentLibrary library = new ComponentLibrary();
library.getValidators().add(validator);
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output,resolver);
generator.visit(validator, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output,resolver);
- checkXmlStructure(output);
+ checkXmlStructure(outputWriter);
// TODO validate xml by xsd
// validateXml(output);
@@ -110,24 +137,13 @@
return attribute;
}
- private CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- return cdkContext;
- }
-
// TODO move it in other class
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
InputSource is = new InputSource(new StringReader(facesConfig.toString()));
Validator validator = new Validator(is);
validator.useXMLSchema(true);
- InputSource source = new CdkEntityResolver(null)
- .resolveEntity(null, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
+ InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facelettaglibrary_2_0.xsd").toURI().toString());
validator.setJAXP12SchemaSource(source);
validator.assertIsValid();
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,19 +22,6 @@
package org.richfaces.cdk.generate.java;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import org.junit.Assert;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -43,21 +30,48 @@
import java.io.StringReader;
import java.io.StringWriter;
+import org.junit.Assert;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.freemarker.CdkConfiguration;
+import org.richfaces.cdk.freemarker.LibraryModelWrapper;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+
+import com.google.inject.Inject;
+
+import freemarker.template.Configuration;
+import freemarker.template.ObjectWrapper;
+
/**
* @author akolonitsky
* @since Jan 20, 2010
*/
public abstract class AbstractClassGeneratorTest extends CdkTestBase {
- protected CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
+
+ @Inject
+ protected ComponentLibrary library;
+
+ @Inject
+ @As(CdkConfiguration.class)
+ protected Configuration configuration;
+
+ @Inject
+ @As(LibraryModelWrapper.class)
+ ObjectWrapper wrapper;
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
+
+ @Mock
+ @OutputFolder(StandardOutputFolders.RESOURCES)
+ protected FileManager output;
- return cdkContext;
- }
protected static Property addAttribute(ModelElementBase model, String attributeName, Class<?> type, boolean generate) {
@@ -86,7 +100,8 @@
protected static void compareTextFiles(Reader reference, Reader output) throws IOException {
LineNumberReader ref = new LineNumberReader(reference);
LineNumberReader out = new LineNumberReader(output);
- String refLine = "", outLine = "";
+ String refLine = "";
+ String outLine = "";
while (refLine != null || outLine != null) {
if (refLine == null) {
Assert.fail("Output text is longer than reference text");
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,43 +22,40 @@
package org.richfaces.cdk.generate.java;
-import org.junit.Test;
-import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkContext;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
import java.io.StringWriter;
-import java.io.Writer;
import java.util.Set;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
+
+import com.google.inject.Inject;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class BehaviorClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private BehaviorClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileBehavior() throws Exception {
- final StringWriter output = new StringWriter();
- BehaviorClassGenerator generator = new BehaviorClassGenerator() {
- @Override
- protected Writer getOutput(BehaviorModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
BehaviorModel behavior = new BehaviorModel();
behavior.setBehaviorId("foo.bar");
behavior.setClassNames("org.richfaces.cdk.generate.java.GeneratedBehavior", "Object");
@@ -76,9 +73,9 @@
library.getBehaviors().add(behavior);
generator.visit(behavior, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output);
- compare(output, "GeneratedBehavior.java");
+ compare(outputWriter, "GeneratedBehavior.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -28,26 +28,30 @@
import static org.easymock.EasyMock.*;
import java.io.StringWriter;
-import java.io.Writer;
import java.util.Set;
import javax.faces.component.UIOutput;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class ComponentClassGeneratorTest extends AbstractClassGeneratorTest {
+
+ @Inject
+ private ComponentClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
@@ -55,18 +59,10 @@
*/
@Test
public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ComponentClassGenerator generator = new ComponentClassGenerator() {
- @Override
- protected Writer getOutput(ComponentModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
- ComponentLibrary library = new ComponentLibrary();
ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.bar"));
library.getComponents().add(component);
component.setGenerate(true);
@@ -89,9 +85,9 @@
attribute.setGenerate(false);
generator.visit(component, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output);
- compare(output, "GeneratedComponent.java");
+ compare(outputWriter, "GeneratedComponent.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,42 +22,40 @@
package org.richfaces.cdk.generate.java;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 20, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ConverterClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private ConverterClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileValidator() throws Exception {
- final StringWriter output = new StringWriter();
- ConverterClassGenerator generator = new ConverterClassGenerator() {
- @Override
- protected Writer getOutput(ConverterModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
ConverterModel converter = new ConverterModel();
converter.setConverterId("foo.bar");
converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverter", "Object");
@@ -75,10 +73,10 @@
library.getConverters().add(converter);
generator.visit(converter, library);
- System.out.println(output);
+ System.out.println(outputWriter);
- verify(mockContext);
+ verify(output);
- compare(output, "GeneratedConverter.java");
+ compare(outputWriter, "GeneratedConverter.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -22,48 +22,40 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.StandardSources;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
-import org.junit.Test;
-import static org.easymock.EasyMock.verify;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.replay;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 15, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ValidatorClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private ValidatorClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileValidator() throws Exception {
- final StringWriter output = new StringWriter();
- ValidatorClassGenerator generator = new ValidatorClassGenerator() {
- @Override
- protected Writer getOutput(ValidatorModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
ValidatorModel validator = new ValidatorModel();
validator.setValidatorId("foo.bar");
validator.setClassNames("org.richfaces.cdk.generate.java.GeneratedClass", "Object");
@@ -81,11 +73,11 @@
library.getValidators().add(validator);
generator.visit(validator, library);
- System.out.println(output);
+ System.out.println(outputWriter);
- verify(mockContext);
+ verify(output);
- compare(output, "GeneratedClass.java");
+ compare(outputWriter, "GeneratedClass.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,12 +21,8 @@
*/
package org.richfaces.cdk.templatecompiler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,34 +35,60 @@
import javax.faces.render.RenderKitFactory;
import javax.faces.validator.Validator;
-import org.junit.After;
-import org.junit.Before;
+import org.easymock.EasyMock;
+import org.junit.Ignore;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.RenderKitModel.Id;
import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXB;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.xml.sax.ext.EntityResolver2;
import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* @author Nick Belaevski
*
*/
+(a)RunWith(CdkTestRunner.class)
public class RendererTemplateParserTest extends CdkTestBase {
+ @Inject
private RendererTemplateParser parser;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @As(JAXBBinding.class)
+ private JAXB binding;
+
+ @Mock
+ private EntityResolver2 resolver;
- private CdkContext cdkContext;
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
private RenderKitModel getRenderkitFromModel(String renderkitId) {
- Map<Id, RenderKitModel> renderKits = cdkContext.getLibrary().getRenderKits();
+ Map<Id, RenderKitModel> renderKits = library.getRenderKits();
assertNotNull(renderKits);
RenderKitModel renderKit = renderKits.get(new RenderKitModel.Id(renderkitId));
@@ -245,22 +267,10 @@
}
- @Before
- public void setUp() throws Exception {
- parser = new RendererTemplateParser();
- cdkContext = new CdkContextBase(createClassLoader());
- parser.init(cdkContext);
- }
- @After
- public void tearDown() throws Exception {
- parser = null;
- cdkContext = null;
- }
-
@Test
public void basicComponentTest() throws Exception {
- Template template = parser.parseTemplate("urn:resource:org/richfaces/cdk/templatecompiler/basic.template.xml");
+ Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/basic.template.xml"));
assertNotNull(template);
parser.mergeTemplateIntoModel(template);
@@ -274,8 +284,13 @@
}
@Test
+ @Ignore // TODO - fix import-attributes.
public void dummyComponentTest() throws Exception {
- Template template = parser.parseTemplate("urn:resource:org/richfaces/cdk/templatecompiler/dummy.template.xml");
+ expect(resolver.getExternalSubset(eq("cdk:root"), EasyMock.<String>anyObject())).andReturn(null).atLeastOnce();
+// expect(resolver.getExternalSubset("cdk:root", null)).andReturn(null).atLeastOnce();
+ replay(resolver,templatesSource);
+ Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/dummy.template.xml"));
+ verify(resolver,templatesSource);
assertNotNull(template);
parser.mergeTemplateIntoModel(template);
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -1,95 +1,101 @@
package org.richfaces.cdk.xmlconfig;
-import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.annotations.Component;
import org.xml.sax.InputSource;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
public class CdkResolverTest extends CdkTestBase {
+
+ private static final String TEST_HTML = "org/richfaces/cdk/apt/test.html";
+
+ @Inject
+ private CdkEntityResolver entityResolver;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager facesConfigSource;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader classLoader = new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null){
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ if ("foo/bar.xml".equals(name)) {
+ return new ByteArrayInputStream("baz".getBytes());
+ } else {
+ return super.getResourceAsStream(name);
+ }
+ }
+
+ };
+ binder.bind(CdkClassLoader.class).toInstance(classLoader);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
@Test
public void testResolveSystemIdSystem() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
+ replay(facesConfigSource,templatesSource);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
@Test
public void testResolveSystemIdResource() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- CdkClassLoader loader = new CdkClassLoader(CdkEntityResolver.class.getClassLoader()) {
- @Override
- public InputStream getResourceAsStream(String name) {
- if ("foo/bar.xml".equals(name)) {
- return new ByteArrayInputStream("baz".getBytes());
- } else {
- return super.getResourceAsStream(name);
- }
- }
- };
-
- expect(cdkContext.getLoader()).andStubReturn(loader);
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ replay(facesConfigSource,templatesSource);
InputSource input = entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
@Test
public void testResolveSystemIdAttributes() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ replay(facesConfigSource,templatesSource);
InputSource input = entityResolver.resolveSystemId("urn:attributes:test-props.xml");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType) anyObject())).andStubReturn(null);
-
- return cdkContext;
- }
-
@Test
public void testGetProjectInputSource() throws Exception {
- CdkContext cdkContext = createMockContext();
-
- 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");
-
+ expect(facesConfigSource.getFile(TEST_HTML)).andReturn(getJavaFile(TEST_HTML));
+ replay(facesConfigSource,templatesSource);
+ InputSource input = entityResolver.getProjectInputSource(facesConfigSource,
+ TEST_HTML);
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
- verify(cdkContext);
}
}
Modified: 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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -29,18 +29,27 @@
import java.util.Map;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
import org.richfaces.cdk.xmlconfig.model.RenderKitBean;
+import org.xml.sax.ext.EntityResolver2;
import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -49,11 +58,36 @@
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class FacesConfigTest extends CdkTestBase {
+
+ @Inject
+ FragmentParser parser;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB jaxbBinding;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
@Test
public void testComponentUnmarshal() throws Exception {
- JAXBBinding jaxbBinding = createJAXB();
-
FacesConfigBean library = jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
@@ -83,7 +117,6 @@
@Test
public void testRenderKitUnmarshall() throws Exception {
- JAXBBinding jaxbBinding = createJAXB();
FacesConfigBean library = jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/renderkit.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
@@ -92,19 +125,4 @@
assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKits.get(0).getKey());
assertEquals(new RenderKitModel.Id("RDFa"), renderKits.get(1).getKey());
}
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return
- * @throws Exception
- */
- protected JAXBBinding createJAXB() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
-
- jaxbBinding.init(contextBase);
- return jaxbBinding;
- }
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -27,33 +27,63 @@
import static org.junit.Assert.*;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
+import org.xml.sax.ext.EntityResolver2;
-import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class FragmentParserTest extends CdkTestBase {
+
+ @Inject
+ FragmentParser parser;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB binder;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
@Test
public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
@@ -62,11 +92,7 @@
@Test
public void xincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
assertEquals(2, properties.size());
@@ -74,11 +100,7 @@
@Test
public void nestedXincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
@@ -87,11 +109,7 @@
@Test
public void propertyTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -5,23 +5,28 @@
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
public class JaxbMarshalTest extends JaxbTestBase {
+
+ @Mock
+ JAXB jaxbBinding;
+
+ @Inject
+ ComponentLibrary library;
+
@Test
public void testMarshalResultStringT() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
-
- jaxbBinding.init(contextBase);
-
- ComponentLibrary library = new ComponentLibrary();
ComponentModel component = new ComponentModel( new ComponentModel.Type("foo.bar"));
library.getComponents().add(component);
RenderKitModel renderKit = library.addRenderKit("HTML");
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -25,6 +25,8 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import org.w3c.dom.Element;
+
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +36,6 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
-import org.dom4j.Element;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -21,39 +21,75 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+
+import javax.xml.transform.stream.StreamResult;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
import org.junit.Assert;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
+import org.richfaces.cdk.xmlconfig.JAXB;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import org.richfaces.cdk.xmlconfig.JaxbTestBase;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
+import org.xml.sax.ext.EntityResolver2;
-import javax.xml.transform.stream.StreamResult;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.StringReader;
-import java.io.InputStreamReader;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 13, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public abstract class ModelBeanTest extends JaxbTestBase {
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB binding;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
InputSource is = new InputSource(new StringReader(facesConfig.toString()));
Validator validator = new Validator(is);
validator.useXMLSchema(true);
- InputSource source = new CdkEntityResolver(null)
- .resolveEntity(null, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
+ InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facesconfig_2_0.xsd").toURI().toString());
validator.setJAXP12SchemaSource(source);
validator.assertIsValid();
@@ -77,9 +113,7 @@
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(new CdkContextBase(createClassLoader()));
- jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
+ binding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
new FacesConfigAdapter().marshal(library));
return writer;
}
Property changes on: root/cdk/trunk/plugins/maven-cdk-plugin
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -33,6 +33,8 @@
*/
public class MavenLogger implements Logger {
private Log log;
+
+ private int errorCount;
/**
* @param log
@@ -74,6 +76,7 @@
*/
public void error(CharSequence content, Throwable error) {
log.error(content, error);
+ errorCount++;
}
/**
@@ -82,6 +85,7 @@
*/
public void error(CharSequence content) {
log.error(content);
+ errorCount++;
}
/**
@@ -90,6 +94,7 @@
*/
public void error(Throwable error) {
log.error(error);
+ errorCount++;
}
/**
@@ -173,4 +178,9 @@
public void warn(Throwable error) {
log.warn(error);
}
+
+ @Override
+ public int getErrorCount() {
+ return errorCount;
+ }
}
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 2010-02-05 16:20:43 UTC (rev 16421)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-02-05 18:42:09 UTC (rev 16422)
@@ -23,6 +23,16 @@
package org.richfaces.builder.mojo;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
@@ -32,30 +42,12 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.richfaces.builder.maven.MavenLogger;
import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.Generator;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.ValidatorImpl;
-import org.richfaces.cdk.apt.AptBuilder;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -190,10 +182,11 @@
}
// Setup logger.
- LoggerFactory.setLogger(new MavenLogger(getLog()));
+ Logger logger = new MavenLogger(getLog());
- CdkContextBase context = new CdkContextBase(this.createProjectClassLoader(project));
-
+ Generator generator = new Generator();
+ generator.setLog(logger);
+ generator.setLoader(createProjectClassLoader(project));
// Set source folders.
ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
@@ -205,93 +198,37 @@
}
}
- context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- // Non-java sources.
- context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
- context.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles());
- context.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles());
+ generator.addSources(StandardSources.JAVA_SOURCES, findJavaFiles(), folders);
+ // TODO - detect templates and configs directories.
+ generator.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles(), null);
+ generator.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles(), null);
+
// Setup output folders.
- setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
- setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
- setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
- setOutput(context, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
+ setOutput(generator, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
+ setOutput(generator, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
+ setOutput(generator, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
+ setOutput(generator, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
// configure CDK workers.
- boolean namingConventionsConfigured = false;
- boolean validatorConfigured = false;
+ setupPlugins(generator);
- if (null != workers) {
- for (Entry<String, String> workerEntry : workers.entrySet()) {
- try {
- Class<CdkWorker> workerClass =
- (Class<CdkWorker>) Class.forName(workerEntry.getKey()).asSubclass(CdkWorker.class);
- Class<? extends CdkWorker> workerImplementationClass =
- Class.forName(workerEntry.getValue()).asSubclass(CdkWorker.class);
- CdkWorker workerInstance = workerImplementationClass.newInstance();
-
- workerInstance.init(context);
- context.setWorker(workerClass, workerInstance);
-
- if (NamingConventions.class.equals(workerClass)) {
- namingConventionsConfigured = true;
- }
-
- if (ModelValidator.class.equals(workerClass)) {
- validatorConfigured = true;
- }
- } catch (ClassNotFoundException e) {
- throw new MojoFailureException("Worker class not found", e);
- } catch (InstantiationException e) {
- throw new MojoFailureException("Worker instance can't be created", e);
- } catch (IllegalAccessException e) {
- throw new MojoFailureException("Worker instance can't be created", e);
- } catch (CdkException e) {
- throw new MojoFailureException("Worker initialization error", e);
- }
- }
- }
-
- // Set default naming conventions if it was not configured.
- if (!namingConventionsConfigured) {
- RichFacesConventions facesConventions = new RichFacesConventions();
-
- try {
- facesConventions.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException("Naming conventions initialization error", e);
- }
-
- context.setWorker(NamingConventions.class, facesConventions);
- }
-
- // Set default model validator if it was not configured.
- if (!validatorConfigured) {
- ValidatorImpl validatorImpl = new ValidatorImpl();
-
- try {
- validatorImpl.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException("RichFaces Validator initialization error", e);
- }
-
- context.setWorker(ModelValidator.class, validatorImpl);
- }
-
if (null != options) {
// TODO make it type safe.
- context.setOptions(options);
+ generator.setOptions(options);
}
try {
// Build JSF library.
// LibraryBuilder builder = LibraryBuilder.createInstance(context);
- ModelBuilder builder = context.getWorker(AptBuilder.class);
- builder.build();
-
+ generator.init();
+ generator.execute();
+ if(logger.getErrorCount()>0){
+ throw new MojoFailureException("Errors occurred while JSF library was built");
+ }
// Tell project about generated files.
project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
@@ -311,19 +248,28 @@
}
/**
+ * <p class="changed_added_4_0"></p>
+ * @param generator
+ * @throws MojoFailureException
+ */
+ private void setupPlugins(Generator generator) throws MojoFailureException {
+ // TODO - get additional modules, as Maven components ?
+ }
+
+ /**
* <p class="changed_added_4_0">This utility method sets output directory for particular type.
* I such directory does not exist, it is created.</p>
*
- * @param context
+ * @param generator
* @param directory
* @param type
*/
- private static void setOutput(CdkContextBase context, File directory, StandardOutputFolders type) {
+ private static void setOutput(Generator generator, File directory, StandardOutputFolders type) {
if (!directory.exists()) {
directory.mkdirs();
}
- context.setOutputFolder(type, directory);
+ generator.addOutputFolder(type, directory);
}
/**
14 years, 3 months
JBoss Rich Faces SVN: r16421 - in root/ui-sandbox/trunk/components/tables/ui/src/main: resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-02-05 11:20:43 -0500 (Fri, 05 Feb 2010)
New Revision: 16421
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-7868 RF-7869
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-02-05 05:51:52 UTC (rev 16420)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-02-05 16:20:43 UTC (rev 16421)
@@ -46,7 +46,7 @@
import org.richfaces.component.util.HtmlUtil;
@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "jquery.position.js"), @ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "extendedDataTable.js"), @ResourceDependency(name = "extendedDataTable.css") })
public class ExtendedDataTableRenderer extends AbstractTableRenderer {
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-02-05 05:51:52 UTC (rev 16420)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-02-05 16:20:43 UTC (rev 16421)
@@ -140,7 +140,7 @@
};
var drag = function(event) {
- dragElement.style.left = (Math.max(resizeData.left + MIN_WIDTH, event.pageX) - jQuery(dragElement).offsetParent().offset().left) + "px";
+ jQuery(dragElement).setPosition({left:Math.max(resizeData.left + MIN_WIDTH, event.pageX)});
return false;
};
var beginResize = function(event) {
@@ -151,8 +151,7 @@
left : thisElement.parent().offset().left
};
dragElement.style.height = element.clientHeight + "px";
- dragElement.style.top = thisElement.offset().top - thisElement.offsetParent().offset().top + "px";
- dragElement.style.left = (event.pageX - jQuery(element).offsetParent().offset().left) + "px";
+ jQuery(dragElement).setPosition({top:thisElement.offset().top, left:event.pageX});
dragElement.style.display = "block";
jQuery(document).bind("mousemove", drag);
jQuery(document).one("mouseup", endResize);
@@ -176,9 +175,8 @@
};
var reorder = function(event) {
+ jQuery(reorderElement).setPosition(event, {offset:[5,5]});
reorderElement.style.display = "block";
- reorderElement.style.top = (event.pageY - jQuery(reorderElement).offsetParent().offset().top) + "px";
- reorderElement.style.left = (event.pageX - jQuery(reorderElement).offsetParent().offset().left + 20) + "px";
return false;
};
14 years, 3 months
JBoss Rich Faces SVN: r16420 - in root/docs/trunk: Component_Reference/en-US and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-02-05 00:51:52 -0500 (Fri, 05 Feb 2010)
New Revision: 16420
Modified:
root/docs/trunk/Component_Development_Kit_Guide/en-US/Book_Info.xml
root/docs/trunk/Component_Development_Kit_Guide/en-US/Component_Development_Kit_Guide.ent
root/docs/trunk/Component_Reference/en-US/Book_Info.xml
root/docs/trunk/Component_Reference/en-US/Component_Reference.ent
root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Introduction.xml
root/docs/trunk/Developer_Guide/en-US/Author_Group.xml
root/docs/trunk/Developer_Guide/en-US/Book_Info.xml
root/docs/trunk/Developer_Guide/en-US/Developer_Guide.ent
root/docs/trunk/Developer_Guide/en-US/Developer_Guide.xml
root/docs/trunk/Developer_Guide/en-US/Preface.xml
root/docs/trunk/Developer_Guide/en-US/Revision_History.xml
root/docs/trunk/Developer_Guide/en-US/appe-Developer_Guide-Resources.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Basic_concepts.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Introduction.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Skinning_and_theming.xml
root/docs/trunk/Developer_Guide/en-US/fallback_content/Conventions.xml
root/docs/trunk/Developer_Guide/en-US/fallback_content/Feedback.xml
root/docs/trunk/Developer_Guide/en-US/fallback_content/Legal_Notice.xml
root/docs/trunk/Developer_Guide/publican.cfg
root/docs/trunk/Migration_Guide/en-US/Book_Info.xml
root/docs/trunk/Migration_Guide/en-US/Migration_Guide.ent
Log:
Worked on Developer Guide
Modified: root/docs/trunk/Component_Development_Kit_Guide/en-US/Book_Info.xml
===================================================================
--- root/docs/trunk/Component_Development_Kit_Guide/en-US/Book_Info.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Component_Development_Kit_Guide/en-US/Book_Info.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -6,7 +6,7 @@
<bookinfo id="book-Component_Development_Kit_Guide-Component_Development_Kit_Guide">
<title>Component Development Kit Guide</title>
- <subtitle>Developing custom components for use in RichFaces &VERSION_LONG;<remark> (draft)</remark>
+ <subtitle>Developing custom components for use in RichFaces &VERSIONLONG;<remark> (draft)</remark>
projects</subtitle>
<productname>RichFaces</productname>
<productnumber>4.0</productnumber>
Modified: root/docs/trunk/Component_Development_Kit_Guide/en-US/Component_Development_Kit_Guide.ent
===================================================================
--- root/docs/trunk/Component_Development_Kit_Guide/en-US/Component_Development_Kit_Guide.ent 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Component_Development_Kit_Guide/en-US/Component_Development_Kit_Guide.ent 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,6 +1,6 @@
<!ENTITY PRODUCT "RichFaces">
<!ENTITY VERSION "4.0">
-<!ENTITY VERSION_LONG "4.0.0.ALPHA2">
+<!ENTITY VERSIONLONG "4.0.0.ALPHA2">
<!ENTITY BOOKID "Component_Development_Kit_Guide">
<!ENTITY HOLDER "Red Hat">
<!ENTITY YEAR "2009">
Modified: root/docs/trunk/Component_Reference/en-US/Book_Info.xml
===================================================================
--- root/docs/trunk/Component_Reference/en-US/Book_Info.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Component_Reference/en-US/Book_Info.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -3,7 +3,7 @@
]>
<bookinfo id="book-Component_Reference-Component_Reference">
<title>Component Reference</title>
- <subtitle>A reference guide to the components of the RichFaces &VERSION_LONG;<remark> (draft)</remark>
+ <subtitle>A reference guide to the components of the RichFaces &VERSIONLONG;<remark> (draft)</remark>
framework</subtitle>
<productname>RichFaces</productname>
<productnumber>4.0</productnumber>
Modified: root/docs/trunk/Component_Reference/en-US/Component_Reference.ent
===================================================================
--- root/docs/trunk/Component_Reference/en-US/Component_Reference.ent 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Component_Reference/en-US/Component_Reference.ent 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,6 +1,6 @@
<!ENTITY PRODUCT "RichFaces">
<!ENTITY VERSION "4.0">
-<!ENTITY VERSION_LONG "4.0.0.ALPHA2">
+<!ENTITY VERSIONLONG "4.0.0.ALPHA2">
<!ENTITY BOOKID "Component_Reference">
<!ENTITY HOLDER "Red Hat">
<!ENTITY YEAR "2009">
Modified: root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Introduction.xml
===================================================================
--- root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Introduction.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Component_Reference/en-US/chap-Component_Reference-Introduction.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -12,7 +12,7 @@
<section id="sect-Component_Reference-Introduction-Libraries">
<title>Libraries</title>
<para>
- The RichFaces framework as it now stands is made up of two tag libraries: the <classname>a4j</classname> library and the <classname>rich</classname> library. The <classname>a4j</classname> tag library represents Ajax4jsf, which provides page-level Ajax support with core Ajax components. This allows developers to make use of custom Ajax behavior with existing components. The <classname>rich</classname> tag library provides Ajax support at the component level instead, and includes ready-made, self-contained components. These components don't require additional configuration in order to send requests or update.
+ The RichFaces framework is made up of two tag libraries: the <classname>a4j</classname> library and the <classname>rich</classname> library. The <classname>a4j</classname> tag library represents Ajax4jsf, which provides page-level Ajax support with core Ajax components. This allows developers to make use of custom Ajax behavior with existing components. The <classname>rich</classname> tag library provides Ajax support at the component level instead, and includes ready-made, self-contained components. These components don't require additional configuration in order to send requests or update.
</para>
<note>
<title>Ajax support</title>
Modified: root/docs/trunk/Developer_Guide/en-US/Author_Group.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Author_Group.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Author_Group.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE authorgroup PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<authorgroup>
<author>
<firstname>Sean</firstname>
Modified: root/docs/trunk/Developer_Guide/en-US/Book_Info.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Book_Info.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Book_Info.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,27 +1,26 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE bookinfo PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<bookinfo id="book-Developer_Guide-Developer_Guide">
<title>Developer Guide</title>
- <subtitle>Developing projects using RichFaces &VERSION_LONG;<remark> (draft)</remark>
+ <subtitle>Developing projects using RichFaces &VERSIONLONG;<remark> (draft)</remark>
</subtitle>
<productname>RichFaces</productname>
<productnumber>4.0</productnumber>
<edition>0</edition>
<pubsnumber>1</pubsnumber>
<abstract>
- <para>Read this book for a comprehensive guide to getting started and
+ <para>
+Read this book for a comprehensive guide to getting started and
working with RichFaces &VERSION;. It includes details of the
-architecture, the framework's use in different applications,
-and skinning implementations.</para>
+architecture, the framework's use in different applications,
+and skinning implementations.
+</para>
</abstract>
<corpauthor>
<inlinemediaobject>
<imageobject>
- <imagedata fileref="./images/rf_logo.png" format="PNG" />
+ <imagedata fileref="./images/rf_logo.png" format="PNG" width="444" />
</imageobject>
<textobject>
<phrase>Logo</phrase>
@@ -32,14 +31,9 @@
<year>&YEAR;</year>
<holder>&HOLDER;</holder>
</copyright>
-
- <!--FOR PUBLICAN -->
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="Common_Content/Legal_Notice.xml">
- <!--FOR JDOCBOOK:-->
- <xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude">
- <xi:include href="fallback_content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </xi:fallback>
+ <!-- FOR PUBLICAN --><xi:include href="Common_Content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude"><!-- FOR JDOCBOOK: --><xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="fallback_content/Legal_Notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </xi:fallback>
</xi:include>
- <xi:include href="Author_Group.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
+ <xi:include href="Author_Group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</bookinfo>
-
+
Modified: root/docs/trunk/Developer_Guide/en-US/Developer_Guide.ent
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Developer_Guide.ent 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Developer_Guide.ent 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,6 +1,6 @@
<!ENTITY PRODUCT "RichFaces">
<!ENTITY VERSION "4.0">
-<!ENTITY VERSION_LONG "4.0.0.ALPHA2">
+<!ENTITY VERSIONLONG "4.0.0.ALPHA2">
<!ENTITY BOOKID "Developer_Guide">
<!ENTITY HOLDER "Red Hat">
<!ENTITY YEAR "2009">
Modified: root/docs/trunk/Developer_Guide/en-US/Developer_Guide.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Developer_Guide.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Developer_Guide.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,19 +1,15 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<book status="draft">
- <xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <!--<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>-->
- <xi:include href="chap-Developer_Guide-Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="chap-Developer_Guide-Getting_started_with_RichFaces.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="chap-Developer_Guide-RichFaces_overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="chap-Developer_Guide-Basic_concepts.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="chap-Developer_Guide-Advanced_features.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="chap-Developer_Guide-Skinning_and_theming.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="appe-Developer_Guide-Resources.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
+ <xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <!-- <xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include> --><xi:include href="chap-Developer_Guide-Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="chap-Developer_Guide-Getting_started_with_RichFaces.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="chap-Developer_Guide-RichFaces_overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="chap-Developer_Guide-Basic_concepts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="chap-Developer_Guide-Advanced_features.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="chap-Developer_Guide-Skinning_and_theming.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="appe-Developer_Guide-Resources.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
Modified: root/docs/trunk/Developer_Guide/en-US/Preface.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Preface.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Preface.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,28 +1,15 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<preface id="pref-Developer_Guide-Preface">
<title>Preface</title>
- <!--FOR JDOCBOOK-->
- <xi:include href="Common_Content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude">
- <!--FOR PUBLICAN-->
- <xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude">
- <xi:include href="fallback_content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </xi:fallback>
+ <!-- FOR JDOCBOOK --><xi:include href="Common_Content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude"><!-- FOR PUBLICAN --><xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="fallback_content/Conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </xi:fallback>
</xi:include>
-
- <!--PUBLICAN'S ORIGINAL XINCLUDES-->
- <xi:include href="Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude">
- <xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude">
- <xi:include href="Common_Content/Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude">
- <!--FOR JDOCBOOK-->
- <xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude">
- <xi:include href="fallback_content/Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </xi:fallback>
- </xi:include>
- </xi:fallback>
+ <!-- PUBLICAN'S ORIGINAL XINCLUDES --><xi:include href="Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude"><xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="Common_Content/Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude"><!-- FOR JDOCBOOK --><xi:fallback xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include href="fallback_content/Feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </xi:fallback>
</xi:include>
+ </xi:fallback>
+ </xi:include>
</preface>
+
Modified: root/docs/trunk/Developer_Guide/en-US/Revision_History.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/Revision_History.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/Revision_History.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<appendix id="appe-Developer_Guide-Revision_History">
<title>Revision History</title>
<simpara>
Modified: root/docs/trunk/Developer_Guide/en-US/appe-Developer_Guide-Resources.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/appe-Developer_Guide-Resources.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/appe-Developer_Guide-Resources.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<appendix id="appe-Developer_Guide-Resources">
<title>Resources</title>
<para>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-Advanced_features">
<title>Advanced features</title>
<para>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Basic_concepts.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Basic_concepts.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Basic_concepts.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-Basic_concepts">
<title>Basic concepts</title>
<para>
@@ -12,36 +9,78 @@
<section id="sect-Developer_Guide-Basic_concepts-Sending_an_Ajax_request">
<title>Sending an Ajax request</title>
<para>
- Incomplete
+ Many of the tags in the <classname>a4j</classname> and <classname>rich</classname> tag libraries are capable of sending Ajax requests from a JavaServer Faces (JSF) page. RichFaces tags hide the usual JavaScript activities that are required for an XMHTTPRequest object building and an Ajax request sending. Additionally the tags can determine which components of a JSF page are to be re-rendered as a result of the Ajax response; refer to <xref linkend="sect-Developer_Guide-Basic_concepts-Partial_page_updates" /> for details.
</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ The <sgmltag><a4j:commandButton></sgmltag> and <sgmltag><a4j:commandLink></sgmltag> tags are used to send an Ajax request on the <varname>onclick</varname> JavaScript event.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <sgmltag><a4j:poll></sgmltag> tag is used to send an Ajax request periodically using a timer.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <sgmltag><a4j:ajax></sgmltag> tag allows you to add Ajax functionality to standard JSF components and send Ajax request on a chosen JavaScript event, such as <varname>onkeyup</varname> or <varname>onmouseover</varname>, for example.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Most components in the <lassname>rich</lassname> tag library have built-in Ajax support. Refer to the <citetitle>RichFaces Component Reference</citetitle> for details on the use of each component.
+ </para>
+ </listitem>
+ </itemizedlist>
+
</section>
<section id="sect-Developer_Guide-Basic_concepts-Receiving_events_and_updates">
<title>Receiving events and updates</title>
<para>
- Incomplete
+ If no specific regions are specified, the whole page is updated when an Ajax response is received.
</para>
+ <note>
+ <title>Rendering outside the active region</title>
+ <para>
+ If the content of an Ajax response needs to be rendered outside the active region, then the value of the <varname>renderRegionOnly</varname> attribute should be set to <literal>false</literal>. Otherwise, your Ajax updates are limited to elements of the active region. If not defined, the default setting is <code>renderRegionOnly="false"</code>.
+ </para>
+ </note>
+
+ <section id="sect-Developer_Guide-Basic_concepts-Partial_page_updates">
+ <title>Partial page updates</title>
+ <para>
+ Specific regions of a page can be defined through the use of container components such as <sgmltag><a4j:region></sgmltag>. These regions can then be specified with their <varname>id</varname> identifiers in the <varname>render</varname> attribute of a component so that when the component sends an Ajax request, only the specified regions are updated. In this way you can control which part of the JSF View is decoded on the server side when the Ajax request is sent. Multiple regions can be defined and sent, and regions can be nested inside other regions.
+ </para>
+ <para>
+ Additionally, regions can be wrapped with the <sgmltag><a4j:outputPanel ajaxRendered="true"></sgmltag> tag. This causes all contents of the region to be updated on every Ajax response, even if not explicitly listed in the requesting component's <varname>render</varname> attribute.
+ </para>
+ <para>
+ Setting the <varname>limitRender</varname> attribute to <literal>true</literal> will cause <emphasis>only</emphasis> those regions listed in the requesting component's <varname>render</varname> attribute to be updated. This overrides any regions with the <sgmltag><a4j:outputPanel ajaxRendered="true"></sgmltag> tag.
+ </para>
+ <para>
+ Refer to the <citetitle>RichFaces Component Reference</citetitle> for further details on the common Ajax attributes used for partial page updates.
+ </para>
+ </section>
+
</section>
- <section id="sect-Developer_Guide-Basic_concepts-Ajax_attributes">
- <title>Ajax attributes</title>
+ <section id="sect-Developer_Guide-Basic_concepts-Processing_data_on_the_server">
+ <title>Processing data on the server</title>
<para>
- Incomplete
+ Use the <varname>process</varname> attribute to list the <varname>id</varname> identifiers of components that need to be processed together with a requesting component. This can be useful if more than one component needs to be processed, but not the entire view. Alternatively if only one component needs to be processed instead of the entire view, <code>process="@this"</code> can be specified.
</para>
</section>
- <section id="sect-Developer_Guide-Basic_concepts-Ajax_containers">
- <title>Ajax containers</title>
- <para>
- Incomplete
- </para>
- </section>
-
<section id="sect-Developer_Guide-Basic_concepts-Component_overview">
<title>Component overview</title>
<para>
- Incomplete
+ The RichFaces framework is made up of two tag libraries: the <classname>a4j</classname> library and the <classname>rich</classname> library. The <classname>a4j</classname> tag library represents <emphasis>Ajax4jsf</emphasis>, which provides page-level Ajax support with core Ajax components. This allows developers to make use of custom Ajax behavior with existing components. The <classname>rich</classname> tag library provides Ajax support at the component level instead, and includes ready-made, self-contained components. These components don't require additional configuration in order to send requests or update.
</para>
+ <para>
+ For details on the use of the various components, refer to <citetitle>RichFaces Component Reference</citetitle>.
+ </para>
</section>
</chapter>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,24 +1,21 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-Getting_started_with_RichFaces">
<title>Getting started with RichFaces</title>
<para>
- Follow the instructions in this chapter to install and configure RichFaces for development. If you have existing projects that use an previous version of RichFaces, refer to the <citetitle>RichFaces 4.0 Migration Guide</citetitle>.
+ Follow the instructions in this chapter to install and configure RichFaces for development. If you have existing projects that use an previous version of RichFaces, refer to the <citetitle>RichFaces Migration Guide</citetitle>.
</para>
<section id="sect-Developer_Guide-Getting_started_with_RichFaces-Technical_Requirements">
<title>Technical Requirements</title>
<para>
- RichFaces has been developed with an open architecture to be compatible with a wide variety of environments. In addition to the RichFaces framework, you need the following frameworks, environments, and applications installed on your computer to start developing with RichFaces:
+ RichFaces has been developed with an open architecture to be compatible with a wide variety of environments. In addition to the RichFaces framework, you need the following frameworks, environments, and applications installed on your computer to start developing with RichFaces:
<variablelist>
<varlistentry>
<term>Java Development Kit (<acronym>JDK</acronym>)</term>
<listitem>
<para>
- RichFaces supports the following JDK versions:
+ RichFaces supports the following JDK versions:
<itemizedlist>
<listitem>
<para>
@@ -33,7 +30,7 @@
<term>JavaServer Faces (<acronym>JSF</acronym>)</term>
<listitem>
<para>
- RichFaces supports the following JSF implementations and frameworks:
+ RichFaces supports the following JSF implementations and frameworks:
<itemizedlist>
<listitem>
<para>
@@ -63,7 +60,7 @@
<term>A Java application server or servlet container</term>
<listitem>
<para>
- RichFaces supports the following servers:
+ RichFaces supports the following servers:
<itemizedlist>
<listitem>
<para>
@@ -118,8 +115,8 @@
<term>A web browser</term>
<listitem>
<para>
- RichFaces supports the following web browsers:
- <itemizedlist>
+ RichFaces supports the following web browsers:
+ <itemizedlist id="item-Developer_Guide-Technical_Requirements-Linux_environments">
<title>Linux environments</title>
<listitem>
<para>
@@ -137,7 +134,7 @@
</para>
</listitem>
</itemizedlist>
- <itemizedlist>
+ <itemizedlist id="item-Developer_Guide-Technical_Requirements-Mac_OS_environments">
<title>Mac OS environments</title>
<listitem>
<para>
@@ -155,7 +152,7 @@
</para>
</listitem>
</itemizedlist>
- <itemizedlist>
+ <itemizedlist id="item-Developer_Guide-Technical_Requirements-Microsoft_Windows_environments">
<title>Microsoft Windows environments</title>
<listitem>
<para>
@@ -195,7 +192,7 @@
<para>
Follow the instructions in this section to install the RichFaces framework on your computer.
</para>
- <section id="sect-Developer_Guide-Getting_started_with_RichFaces-Downloading_RichFaces">
+ <section id="sect-Developer_Guide-Installing_RichFaces-Downloading_RichFaces">
<title>Downloading RichFaces</title>
<para>
Download RichFaces from the JBoss RichFaces Downloads area at <ulink url="http://www.jboss.org/richfaces/download.html">http://www.jboss.org/richfaces/download.html</ulink>. The binary files (available in <filename class="extension">.bin.zip</filename> or <filename class="extension">.bin.tar.gz</filename> archives) contain a compiled, ready-to-use version of RichFaces with a set of basic skins.
@@ -203,14 +200,15 @@
<para>
Create a new directory named <filename>RichFaces</filename>, then unzip the archive containing the binaries there.
</para>
- <section id="sect-Developer_Guide-Getting_started_with_RichFaces-Compiling_the_source">
+ <section id="sect-Developer_Guide-Downloading_RichFaces-Compiling_the_source">
<title>Compiling the source</title>
<para>
Instead of downloading the pre-compiled binaries, you can download the source files and compile them yourself. Download the source files (also available in <filename class="extension">.bin.zip</filename> or <filename class="extension">.bin.tar.gz</filename> archives) from the JBoss RichFaces Downloads area at <ulink url="http://www.jboss.org/richfaces/download.html">http://www.jboss.org/richfaces/download.html</ulink>.
</para>
</section>
+
</section>
-
+
</section>
<section id="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project">
@@ -219,13 +217,13 @@
Follow the procedure in this section to create a new RichFaces application with <application>JBoss Tools</application>.
</para>
<procedure>
- <step>
+ <step id="step-Developer_Guide-Creating_a_project-Create_a_new_project">
<title>Create a new project</title>
<para>
- In <application>JBoss Tools</application>, select <menuchoice><guimenu>File</guimenu><guimenu>New</guimenu><guimenuitem>JSF Project</guimenuitem></menuchoice> from the menu. Name the project, select <guilabel>JSF 2</guilabel> from the <guilabel>JSF Environment</guilabel> drop-down box, and click the <guibutton>Finish</guibutton> button to create the project.
+ In <application>JBoss Tools</application>, select <menuchoice><guimenu>File</guimenu><guimenuitem>New</guimenuitem><guimenuitem>JSF Project</guimenuitem></menuchoice> from the menu. Name the project, select <guilabel>JSF 2</guilabel> from the <guilabel>JSF Environment</guilabel> drop-down box, and click the <guibutton>Finish</guibutton> button to create the project.
</para>
</step>
- <step>
+ <step id="step-Developer_Guide-Creating_a_project-Add_the_RichFaces_libraries_to_the_project">
<title>Add the RichFaces libraries to the project</title>
<para>
Add <filename>core-ui.jar</filename>, <filename>richfaces-api.jar</filename>, and <filename>richfaces-impl.jar</filename> into your project by dragging them from the location where you unzipped the RichFaces archive to the <filename>WebContent/WEB-INF/lib/</filename> directory of your project in <application>JBoss Tools</application>.
@@ -233,7 +231,7 @@
<note>
<title>Other required libraries</title>
<para>
- RichFaces also requires the following libraries to be referenced in your project. Typically they are already included when creating a JSF project in <application>JBoss Tools</application>.
+ RichFaces also requires the following libraries to be referenced in your project. Typically they are already included when creating a JSF project in <application>JBoss Tools</application>.
<itemizedlist>
<listitem>
<para>
@@ -264,13 +262,16 @@
</para>
</note>
</step>
- <step>
+ <step id="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries">
<title>Reference the tag libraries</title>
- <para>The RichFaces tag libraries need to be referenced on each JSP and XHTML page in your project.</para>
+ <para>
+ The RichFaces tag libraries need to be referenced on each JSP and XHTML page in your project.
+ </para>
<variablelist>
<varlistentry>
<term>Referencing in JSP pages</term>
<listitem>
+
<programlisting language="XML" role="XML"><%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
</programlisting>
@@ -279,6 +280,7 @@
<varlistentry>
<term>Referencing in XHTML pages</term>
<listitem>
+
<programlisting language="XML" role="XML"><ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
@@ -291,10 +293,249 @@
</variablelist>
</step>
</procedure>
+
<para>
- You are now ready to begin building your RichFaces applications.
+ You are now ready to begin constructing your RichFaces applications.
</para>
</section>
+
+ <section id="sect-Developer_Guide-Getting_started_with_RichFaces-Using_RichFaces_with_Maven">
+ <title>Using RichFaces with Maven</title>
+ <para>
+ Maven is a build automation and project management tool for Java projects. Follow the instructions in this section to integrate RichFaces into a Maven project.
+ </para>
+ <procedure>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories">
+ <title>Add required repositories</title>
+ <para>
+ A structure for the Maven project with minimal content can be created with the Maven archetype named <filename>maven-archetype-jsfwebapp</filename> included as part of the RichFaces Component Development Kit (<acronym>CDK</acronym>). The archetype and the project itself require extra repositories to be provided, namely <filename>http://snapshots.jboss.org/maven2/</filename> and <filename>http://repository.jboss.com/maven2/</filename>. To make the repositories accessible to Maven, add a profile in the <filename>maven_installation_folder/conf/settings.xml</filename> file under the <sgmltag><profiles></sgmltag> element:
+<programlisting language="XML" role="XML"><profiles>
+ <profile>
+ <id>jsf-app-profile</id>
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <id>snapshots.jboss.org</id>
+ <name>Snapshot Jboss Repository for Maven</name>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven</name>
+ <url>http://repository.jboss.com/maven2/</url>
+ <layout>default</layout>
+ </repository>
+ </repositories>
+ </profile>
+ ...
+</profiles>
+</programlisting>
+ </para>
+ <para>
+ The profile then needs to be activated in the <sgmltag><activeProfiles></sgmltag> element:
+<programlisting language="XML" role="XML"><activeProfiles>
+ <activeProfile>jsf-app-profile</activeProfile>
+</activeProfiles>
+</programlisting>
+ </para>
+ </step>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Generate_project_from_archetype">
+ <title>Generate project from archetype</title>
+ <para>
+ The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> archetype. Create a new directory for your project, then run the following Maven command:
+<screen>
+mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=4.0.0-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable>
+</screen>
+ </para>
+ <para>
+ The following parameters can be used to customize your project:
+ <variablelist>
+ <varlistentry>
+ <term><command>-DgroupId</command></term>
+ <listitem>
+ <para>
+ Defines the package for the Managed Beans
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><command>-DartifactId</command></term>
+ <listitem>
+ <para>
+ Defines the name of the project
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ <para>
+ The command generates a JSF project with the following structure:
+<screen><replaceable>jsf-app</replaceable>
+├── pom.xml
+└── src
+ ├── main
+ │ ├── java
+ │ │ └── org
+ │ │ └── docs
+ │ │ └── richfaces
+ │ │ └── Bean.java
+ │ ├── resources
+ │ └── webapp
+ │ ├── WEB-INF
+ │ │ ├── faces-config.xml
+ │ │ └── web.xml
+ │ ├── index.jsp
+ │ └── pages
+ │ ├── index.jsp
+ │ └── index.xhtml
+ └── test
+ └── java
+ └── org
+ └── docs
+ └── richfaces
+ └── BeanTest.java
+</screen>
+ </para>
+ </step>
+ <step>
+ <title></title>
+ <para>
+ The <filename>jsf-app</filename> directory contains a project descriptor file, <filename>pom.xml</filename>. To add RichFaces libraries to your project, edit the project descriptor to add dependencies to the <sgmltag><dependencies></sgmltag> element as follows:
+<programlisting language="XML" role="XML"><dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_12</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_12</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>el-impl</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <!-- RichFaces libraries -->
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-api</artifactId>
+ <version>3.3.3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.3.3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui</artifactId>
+ <version>3.3.3-SNAPSHOT</version>
+ </dependency>
+</dependencies>
+</programlisting>
+ </para>
+ </step>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Build_the_project">
+ <title>Build the project</title>
+ <stepalternatives>
+ <step id="step-Developer_Guide-Build_the_project-Standard_building">
+ <title>Standard building</title>
+ <para>
+ Build the project from the command line by entering the <command>mvn install</command> command.
+ </para>
+ <para>
+ The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into an IDE (integrated development environment) and run on a server.
+ </para>
+ </step>
+ <step id="step-Developer_Guide-Build_the_project-Building_for_Eclipse_and_JBoss_Tools">
+ <title>Building for <program>Eclipse</program> and <program>JBoss Tools</program></title>
+ <para>
+ To build the project for <program>Eclipse</program> and <program>JBoss Tools</program>, enter the following command at the command line:
+<screen>mvn eclipse:eclipse -Dwtpversion=2.0
+</screen>
+ </para>
+ <para>
+ The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into <program>Eclipse</program>.
+ </para>
+ </step>
+ </stepalternatives>
+ </step>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_tag_library_references">
+ <title>Add tag library references</title>
+ <para>
+ After importing, edit the <filename><replaceable>jsf-app</replaceable>/src/main/webapp/pages/index.jsp</filename> file to include the tag library declaration as described in <xref linkend="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries" />
+ </para>
+ </step>
+ </procedure>
+
+ <para>
+ Your project is now ready to use. Once components and functionality have been added, you can run the application on a server and access it through a web browser at the address <filename>http://localhost:8080/<replaceable>jsf-app</replaceable>/</filename>.
+ </para>
+ </section>
+
+ <section id="sect-Developer_Guide-Getting_started_with_RichFaces-Using_RichFaces_in_existing_JSF2_projects">
+ <title>Using RichFaces in existing JSF2 projects</title>
+ <para>
+ RichFaces can be added to existing JSF2 projects by adding references to the RichFaces libraries. Refer to <xref linkend="step-Developer_Guide-Creating_a_project-Add_the_RichFaces_libraries_to_the_project" /> and <xref linkend="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries" /> for details.
+ </para>
+ </section>
</chapter>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Introduction.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Introduction.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Introduction.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-Introduction">
<title>Introduction</title>
<para>
@@ -13,7 +10,7 @@
RichFaces leverages several parts of the JSF2 framework including lifecycle, validation, conversion facilities, and management of static and dynamic resources. The RichFaces framework includes components with built-in Ajax support and a customizable look-and-feel that can be incorporated into JSF applications.
</para>
<para>
- RichFaces provides a number of advantages for enterprise web application development:
+ RichFaces provides a number of advantages for enterprise web application development:
<itemizedlist>
<listitem>
<para>
@@ -42,7 +39,7 @@
</listitem>
<listitem>
<para>
- Generate binary resources on the fly. The resource framework can generate images, sounds, Microsoft <application>Excel</application> spreadsheets, and more during run-time.
+ Generate binary resources on the fly. The resource framework can generate images, sounds, <application>Microsoft Excel</application> spreadsheets, and more during run-time.
</para>
</listitem>
<listitem>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-RichFaces_overview">
<title>RichFaces overview</title>
<para>
@@ -16,7 +13,7 @@
<title>Request processing flow</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/figu-Developer_Guide-RichFaces_overview-Request_processing_flow.png" format="PNG" />
+ <imagedata contentwidth="660" fileref="images/figu-Developer_Guide-RichFaces_overview-Request_processing_flow.png" format="PNG" width="444" />
</imageobject>
<textobject>
<para>
@@ -31,7 +28,7 @@
<section id="sect-Developer_Guide-RichFaces_overview-Architecture">
<title>Architecture</title>
<para>
- The important elements of the RichFaces framework are as follows:
+ The important elements of the RichFaces framework are as follows:
<itemizedlist>
<listitem>
<para>
@@ -59,18 +56,18 @@
</para>
</listitem>
</itemizedlist>
- Read this section for details on each element.
+ Read this section for details on each element.
</para>
- <section id="sect-Developer_Guide-RichFaces_overview-Ajax_Filter">
+ <section id="sect-Developer_Guide-Architecture-Ajax_Filter">
<title>Ajax Filter</title>
<para>
- To get all benefits of RichFaces, a filter should be registered in the <filename>web.xml</filename> file of your application. The filter recognizes multiple request types. Filter configuration is covered in detail in <xref linkend="sect-Developer_Guide-Advanced_features-Filters" />. <xref linkend="figu-Developer_Guide-RichFaces_overview-Request_processing_sequences" /> shows the difference between processing a regular JSF request and an Ajax request with a filter. With the regular JSF request, the whole JSF tree is encoded. With the Ajax request, the filter parses the content of an Ajax response before sending it to the client side, and encoding depends on the size of the Ajax region.
+ To get all benefits of RichFaces, a filter should be registered in the <filename>web.xml</filename> file of your application. The filter recognizes multiple request types. Filter configuration is covered in detail in <xref linkend="sect-Developer_Guide-Advanced_features-Filters" />. <xref linkend="figu-Developer_Guide-Ajax_Filter-Request_processing_sequences" /> shows the difference between processing a regular JSF request and an Ajax request with a filter. With the regular JSF request, the whole JSF tree is encoded. With the Ajax request, the filter parses the content of an Ajax response before sending it to the client side, and encoding depends on the size of the Ajax region.
</para>
- <figure id="figu-Developer_Guide-RichFaces_overview-Request_processing_sequences">
+ <figure id="figu-Developer_Guide-Ajax_Filter-Request_processing_sequences">
<title>Request processing sequences</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/figu-Developer_Guide-RichFaces_overview-Request_processing_sequences.png" format="PNG" />
+ <imagedata contentwidth="660" fileref="images/figu-Developer_Guide-RichFaces_overview-Request_processing_sequences.png" format="PNG" width="444" />
</imageobject>
<textobject>
<para>
@@ -80,13 +77,13 @@
</mediaobject>
</figure>
<para>
- Both with and without a filter, the required static or dynamic resources that your application requests are registered in the <classname>ResourseBuilder</classname> class. <xref linkend="figu-Developer_Guide-RichFaces_overview-Resource_request_sequence" /> shows the differences in resource requests for a regular JSF request and an Ajax request with a filter. When a request for a resource occurs, the RichFaces filter checks the <classname>ResourceCache</classname> for the resource. If the resource is in the cache, it is sent to the client. Otherwise, the filter searches for the resource among those that are registered by the <classname>ResourceBuilder</classname>. If the resource is registered, the RichFaces filter will send a request to the <classname>ResourceBuilder</classname> to deliver the resource.
+ Both with and without a filter, the required static or dynamic resources that your application requests are registered in the <classname>ResourseBuilder</classname> class. <xref linkend="figu-Developer_Guide-Ajax_Filter-Resource_request_sequence" /> shows the differences in resource requests for a regular JSF request and an Ajax request with a filter. When a request for a resource occurs, the RichFaces filter checks the <classname>ResourceCache</classname> for the resource. If the resource is in the cache, it is sent to the client. Otherwise, the filter searches for the resource among those that are registered by the <classname>ResourceBuilder</classname>. If the resource is registered, the RichFaces filter will send a request to the <classname>ResourceBuilder</classname> to deliver the resource.
</para>
- <figure id="figu-Developer_Guide-RichFaces_overview-Resource_request_sequence">
+ <figure id="figu-Developer_Guide-Ajax_Filter-Resource_request_sequence">
<title>Resource request sequence</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/figu-Developer_Guide-RichFaces_overview-Resource_request_sequence.png" format="PNG" />
+ <imagedata contentwidth="660" fileref="images/figu-Developer_Guide-RichFaces_overview-Resource_request_sequence.png" format="PNG" width="444" />
</imageobject>
<textobject>
<para>
@@ -96,30 +93,38 @@
</mediaobject>
</figure>
</section>
- <section id="sect-Developer_Guide-RichFaces_overview-Ajax_Action_Components">
+
+ <section id="sect-Developer_Guide-Architecture-Ajax_Action_Components">
<title>Ajax Action Components</title>
<para>
The RichFaces framework includes several Ajax Action Components: <sgmltag><a4j:commandButton></sgmltag>, <sgmltag><a4j:commandLink></sgmltag>, <sgmltag><a4j:poll></sgmltag>, <sgmltag><a4j:ajax></sgmltag>, and more. Use Ajax Action Components to send Ajax requests from the client side.
</para>
</section>
- <section id="sect-Developer_Guide-RichFaces_overview-Ajax_Containers">
+
+ <section id="sect-Developer_Guide-Architecture-Ajax_Containers">
<title>Ajax Containers</title>
<para>
<classname>AjaxContainer</classname> is an interface that describes an area on a JSF page that is decoded during an Ajax request. <classname>AjaxViewRoot</classname> and <classname>AjaxRegion</classname> are implementations of this interface.
</para>
</section>
- <section id="sect-Developer_Guide-RichFaces_overview-Skins_and_Theming">
- <title>Skins and Theming</title>
+
+ <section id="sect-Developer_Guide-Architecture-Skins_and_theming">
+ <title>Skins and theming</title>
<para>
-
+ RichFaces includes extensive support for application skinning. Skinning is a high-level extension to traditional <acronym>CSS</acronym> (Cascading Style Sheets) which allows the color scheme and appearance of an application to be easily managed. The skins simplify look-and-feel design by allowing multiple elements of the interface to be handled as manageable features, which have associated color palettes and styling. Application skins can additionally be changed on the fly during run-time, allowing user experiences to be personalized and customized.
</para>
+ <para>
+ For full details on skinning and how to create skins for the components in your application, refer to <xref linkend="chap-Developer_Guide-Skinning_and_theming" />.
+ </para>
</section>
- <section id="sect-Developer_Guide-RichFaces_overview-RichFaces_JavaScript_Engine">
+
+ <section id="sect-Developer_Guide-Architecture-RichFaces_JavaScript_Engine">
<title>RichFaces JavaScript Engine</title>
<para>
The RichFaces JavaScript Engine runs on the client side. It can update different areas on a JSF page based on an Ajax response. It is not necessary to use the JavaScript code directly, as it is available automatically.
</para>
</section>
+
</section>
<section id="sect-Developer_Guide-RichFaces_overview-Technologies">
@@ -139,7 +144,7 @@
<section id="sect-Developer_Guide-RichFaces_overview-Restrictions">
<title>Restrictions</title>
<para>
- The following restrictions apply to applications implementing the RichFaces framework:
+ The following restrictions apply to applications implementing the RichFaces framework:
<itemizedlist>
<listitem>
<para>
@@ -169,20 +174,6 @@
</itemizedlist>
</para>
</section>
-
- <section id="sect-Developer_Guide-RichFaces_overview-Using_RichFaces_with_Maven">
- <title>Using RichFaces with Maven</title>
- <para>
- Incomplete
- </para>
- </section>
-
- <section id="sect-Developer_Guide-RichFaces_overview-Using_RichFaces_in_existing_JSF_projects">
- <title>Using RichFaces in existing JSF projects</title>
- <para>
- Incomplete
- </para>
- </section>
</chapter>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Skinning_and_theming.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Skinning_and_theming.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Skinning_and_theming.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<chapter id="chap-Developer_Guide-Skinning_and_theming">
<title>Skinning and theming</title>
<para>
Modified: root/docs/trunk/Developer_Guide/en-US/fallback_content/Conventions.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/fallback_content/Conventions.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/fallback_content/Conventions.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,12 +1,7 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "../Developer_Guide.ent">
-%BOOK_ENTITIES;
-<!ENTITY % BOOK_ENTITIES SYSTEM "Common_Content.ent">
-%BOOK_ENTITIES;
]>
-
-<section>
+<section id="sect-Developer_Guide-Document_Conventions">
<title>Document Conventions</title>
<para>
This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information.
@@ -14,7 +9,7 @@
<para>
In PDF and paper editions, this manual uses typefaces drawn from the <ulink url="https://fedorahosted.org/liberation-fonts/">Liberation Fonts</ulink> set. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.
</para>
- <section>
+ <section id="sect-Developer_Guide-Document_Conventions-Typographic_Conventions">
<title>Typographic Conventions</title>
<para>
Four typographic conventions are used to call attention to specific words and phrases. These conventions, and the circumstances they apply to, are as follows.
@@ -73,7 +68,7 @@
The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in Proportional Bold and all distinguishable by context.
</para>
<para>
- Note the <guimenu>></guimenu> shorthand used to indicate traversal through a menu and its sub-menus. This is to avoid the difficult-to-follow 'Select <guimenuitem>Mouse</guimenuitem> from the <guimenu>Preferences</guimenu> sub-menu in the <guimenu>System</guimenu> menu of the main menu bar' approach.
+ Note the <guimenu>></guimenu> shorthand used to indicate traversal through a menu and its sub-menus. This is to avoid the difficult-to-follow 'Select <guimenuitem>Mouse</guimenuitem> from the <guimenu>Preferences</guimenu> sub-menu in the <guimenu>System</guimenu> menu of the main menu bar' approach.
</para>
<para>
<command><replaceable>Mono-spaced Bold Italic</replaceable></command> or <application><replaceable>Proportional Bold Italic</replaceable></application>
@@ -105,7 +100,7 @@
</blockquote>
</section>
- <section>
+ <section id="sect-Developer_Guide-Document_Conventions-Pull_quote_Conventions">
<title>Pull-quote Conventions</title>
<para>
Two, commonly multi-line, data types are set off visually from the surrounding text.
@@ -139,14 +134,14 @@
System.out.println("Created Echo");
- System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
+ System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
}
}
</programlisting>
</section>
- <section>
+ <section id="sect-Developer_Guide-Document_Conventions-Notes_and_Warnings">
<title>Notes and Warnings</title>
<para>
Finally, we use three visual styles to draw attention to information that might otherwise be overlooked.
@@ -160,7 +155,7 @@
<important>
<title>Important</title>
<para>
- Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring Important boxes won't cause data loss but may cause irritation and frustration.
+ Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring Important boxes won't cause data loss but may cause irritation and frustration.
</para>
</important>
<warning>
Modified: root/docs/trunk/Developer_Guide/en-US/fallback_content/Feedback.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/fallback_content/Feedback.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/fallback_content/Feedback.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,10 +1,7 @@
-<?xml version='1.0'?>
+<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "../Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
-<section>
+<section id="sect-Developer_Guide-We_Need_Feedback">
<title>We Need Feedback!</title>
<indexterm>
<primary>feedback</primary>
@@ -14,7 +11,7 @@
If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in Bugzilla: <ulink url="http://bugzilla.redhat.com/bugzilla/">http://bugzilla.redhat.com/bugzilla/</ulink> against the product <application>&PRODUCT;.</application>
</para>
<para>
- When submitting a bug report, be sure to mention the manual's identifier: <citetitle>&BOOKID;</citetitle>
+ When submitting a bug report, be sure to mention the manual's identifier: <citetitle>&BOOKID;</citetitle>
</para>
<para>
If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.
Modified: root/docs/trunk/Developer_Guide/en-US/fallback_content/Legal_Notice.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/fallback_content/Legal_Notice.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/en-US/fallback_content/Legal_Notice.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,18 +1,15 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE legalnotice PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % BOOK_ENTITIES SYSTEM "../Developer_Guide.ent">
-%BOOK_ENTITIES;
]>
-
<legalnotice>
<para>
Copyright <trademark class="copyright"></trademark> &YEAR; &HOLDER;. This material may only be distributed subject to the terms and conditions set forth in the Open Publication License, V1.0, (the latest version is presently available at <ulink url="http://www.opencontent.org/openpub/">http://www.opencontent.org/openpub/</ulink>).
</para>
<para>
- Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
+ Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
</para>
<para>
- <trademark class="registered">Linux</trademark> is the registered trademark of Linus Torvalds in the United States and other countries.
+ <trademark class="registered">Linux</trademark> is the registered trademark of Linus Torvalds in the United States and other countries.
</para>
<para>
All other trademarks are the property of their respective owners.
Modified: root/docs/trunk/Developer_Guide/publican.cfg
===================================================================
--- root/docs/trunk/Developer_Guide/publican.cfg 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Developer_Guide/publican.cfg 2010-02-05 05:51:52 UTC (rev 16420)
@@ -4,4 +4,3 @@
show_remarks: 1
debug: 1
xml_lang: en-US
-
Modified: root/docs/trunk/Migration_Guide/en-US/Book_Info.xml
===================================================================
--- root/docs/trunk/Migration_Guide/en-US/Book_Info.xml 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Migration_Guide/en-US/Book_Info.xml 2010-02-05 05:51:52 UTC (rev 16420)
@@ -5,7 +5,7 @@
]>
<bookinfo id="book-Migration_Guide-Migration_Guide">
<title>Migration Guide</title>
- <subtitle>Migrating existing projects to RichFaces &VERSION_LONG;<remark> (draft)</remark>
+ <subtitle>Migrating existing projects to RichFaces &VERSIONLONG;<remark> (draft)</remark>
</subtitle>
<productname>RichFaces</productname>
<productnumber>4.0</productnumber>
Modified: root/docs/trunk/Migration_Guide/en-US/Migration_Guide.ent
===================================================================
--- root/docs/trunk/Migration_Guide/en-US/Migration_Guide.ent 2010-02-05 00:09:13 UTC (rev 16419)
+++ root/docs/trunk/Migration_Guide/en-US/Migration_Guide.ent 2010-02-05 05:51:52 UTC (rev 16420)
@@ -1,6 +1,6 @@
<!ENTITY PRODUCT "RichFaces">
<!ENTITY VERSION "4.0">
-<!ENTITY VERSION_LONG "4.0.0.ALPHA2">
+<!ENTITY VERSIONLONG "4.0.0.ALPHA2">
<!ENTITY BOOKID "Migration_Guide">
<!ENTITY HOLDER "Red Hat Inc.">
<!ENTITY YEAR "2009">
14 years, 3 months
JBoss Rich Faces SVN: r16419 - in root/cdk/branches/guice/plugins/generator/src: main/java/org/richfaces/cdk and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-02-04 19:09:13 -0500 (Thu, 04 Feb 2010)
New Revision: 16419
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
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/Logger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.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/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/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/LibraryModelWrapper.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.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/model/ClassDescription.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.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/FreeMarkerRenderer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.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/VisitorFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.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/JAXB.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/xmlconfig/model/BehaviorBean.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.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
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
Log:
fix checkstyle errors
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/builder/model/MethodBodyStatementsContainer.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,11 +21,11 @@
package org.richfaces.builder.model;
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
import java.util.ArrayList;
import java.util.List;
+import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
+
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -22,16 +22,8 @@
package org.richfaces.cdk;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.*;
-import org.richfaces.cdk.apt.AptModule;
-import org.richfaces.cdk.freemarker.FreeMakerModule;
-import org.richfaces.cdk.generate.java.ClassGeneratorModule;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ModelModule;
-import org.richfaces.cdk.templatecompiler.TemplateModule;
-import org.richfaces.cdk.xmlconfig.XmlModule;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -41,16 +33,18 @@
import java.util.Locale;
import java.util.Map;
-import javax.annotation.Nullable;
+import org.richfaces.cdk.apt.AptModule;
+import org.richfaces.cdk.freemarker.FreeMakerModule;
+import org.richfaces.cdk.generate.java.ClassGeneratorModule;
+import org.richfaces.cdk.model.ModelModule;
+import org.richfaces.cdk.templatecompiler.TemplateModule;
+import org.richfaces.cdk.xmlconfig.XmlModule;
import com.google.common.collect.Maps;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
import com.google.inject.Stage;
-import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,11 +25,8 @@
package org.richfaces.cdk;
-import com.google.inject.Inject;
-import org.richfaces.cdk.model.ComponentLibrary;
-
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -22,7 +22,6 @@
package org.richfaces.cdk;
import com.google.inject.ImplementedBy;
-import com.google.inject.Singleton;
/**
* That interface hides current logging system from generator classes.
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -30,8 +30,6 @@
import java.io.Writer;
import java.util.Collections;
-import org.richfaces.cdk.model.ComponentLibrary;
-
/**
* <p class="changed_added_4_0">
* </p>
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -26,7 +26,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-
import com.google.inject.BindingAnnotation;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,13 +25,13 @@
package org.richfaces.cdk;
+import java.util.Collection;
+
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
-import java.util.Collection;
-
import com.google.inject.Inject;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -47,7 +47,7 @@
public class AptBuilder implements LibraryBuilder {
@Inject
- private Logger LOG ;
+ private Logger log;
@Inject
private CompilationTaskFactory taskFactory;
@@ -74,4 +74,4 @@
}
}
- }
+}
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.freemarker;
+import org.richfaces.cdk.Logger;
+
import com.google.inject.Inject;
-import org.richfaces.cdk.Logger;
-
import freemarker.template.Configuration;
import freemarker.template.ObjectWrapper;
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,24 +25,19 @@
package org.richfaces.cdk.freemarker;
-import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.OutputFolder;
-import org.richfaces.cdk.OutputType;
-import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,11 +25,12 @@
package org.richfaces.cdk.freemarker;
+import org.richfaces.cdk.model.ModelElementBase;
+
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.cdk.model.ModelElementBase;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,23 +25,25 @@
package org.richfaces.cdk.freemarker;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -30,7 +30,6 @@
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
-
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -24,18 +24,16 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.OutputFolder;
-import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputFolders;
-import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -24,8 +24,6 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
@@ -36,6 +34,8 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -27,8 +27,6 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
@@ -39,6 +37,8 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -24,8 +24,6 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
@@ -36,6 +34,8 @@
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -24,20 +24,18 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.OutputFolder;
-import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputFolders;
-import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
+import com.google.inject.Inject;
+
import freemarker.template.Configuration;
/**
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+
import com.google.common.collect.ImmutableMap;
-import java.io.Serializable;
-
/**
* <p class="changed_added_4_0">
* Tthat class represents information about Jsf object class.
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,11 +25,6 @@
package org.richfaces.cdk.model;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.model.RenderKitModel.Id;
-
-import com.google.inject.Singleton;
-
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -40,6 +35,11 @@
import java.util.Map;
import java.util.NoSuchElementException;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.model.RenderKitModel.Id;
+
+import com.google.inject.Singleton;
+
/**
* <p class="changed_added_4_0">
* That class contains model of all JSF components asscoiated with that project
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,10 +1,10 @@
package org.richfaces.cdk.model;
-import org.richfaces.cdk.CdkException;
-
import java.util.Collection;
import java.util.Map;
+import org.richfaces.cdk.CdkException;
+
/**
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -24,11 +24,12 @@
package org.richfaces.cdk.model;
-import org.w3c.dom.Element;
+import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
-import java.util.List;
+import org.w3c.dom.Element;
+
/**
* <p class="changed_added_4_0">That class represents all faces-config "extension" fields.</p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/EventName.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,9 +23,10 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
+
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
-import java.io.Serializable;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Properties.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.model;
+import java.util.List;
+
import com.google.common.collect.Lists;
-import java.util.List;
-
/**
* <p class="changed_added_4_0">That class contains properties collection from standard include file.</p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,13 +23,13 @@
package org.richfaces.cdk.model;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Set;
import org.richfaces.cdk.CdkException;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
/**
* That class represents JSF component property.
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,9 +23,9 @@
package org.richfaces.cdk.model;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.io.Serializable;
/**
* <p class="changed_added_4_0">That bean represents whole tag library.</p>
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,11 +21,6 @@
*/
package org.richfaces.cdk.parser.el.types;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.JavaLogger;
-import org.richfaces.cdk.parser.el.Type;
-import org.richfaces.cdk.util.ArrayUtils;
-
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.text.MessageFormat;
@@ -40,6 +35,12 @@
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+
+import org.richfaces.cdk.JavaLogger;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.util.ArrayUtils;
+
import com.google.inject.Inject;
/**
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/FreeMarkerRenderer.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,10 +1,10 @@
package org.richfaces.cdk.templatecompiler;
-import freemarker.template.TemplateException;
-
import java.io.IOException;
import java.io.Writer;
+import freemarker.template.TemplateException;
+
public interface FreeMarkerRenderer {
public void writeSnippet(String templateName, Object object, Writer writer)
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,10 +1,11 @@
package org.richfaces.cdk.templatecompiler;
+import org.richfaces.builder.model.MethodBodyStatement;
+
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.builder.model.MethodBodyStatement;
public class JavaClassModelWrapper extends BeansWrapper implements ObjectWrapper {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,11 @@
package org.richfaces.cdk.templatecompiler;
+import org.richfaces.builder.model.MethodBodyStatement;
+
import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import org.richfaces.builder.model.MethodBodyStatement;
/**
* <p class="changed_added_4_0"></p>
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,13 +23,9 @@
package org.richfaces.cdk.templatecompiler;
-import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
import java.io.Writer;
-import com.google.inject.Inject;
-
import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
@@ -42,6 +38,8 @@
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.model.Template;
+import com.google.inject.Inject;
+
import freemarker.template.TemplateException;
/**
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -38,7 +38,6 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
-import com.google.inject.Inject;
import javax.xml.namespace.QName;
import org.richfaces.builder.model.Argument;
@@ -75,9 +74,9 @@
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;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -32,8 +32,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Logger;
@@ -54,6 +52,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
Modified: 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 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,15 +23,13 @@
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;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,12 +23,13 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.Map;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.namespace.QName;
-import java.util.Map;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.templatecompiler.model;
+import javax.xml.bind.annotation.XmlRootElement;
+
import org.richfaces.cdk.CdkException;
-import javax.xml.bind.annotation.XmlRootElement;
-
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,11 +23,11 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
-
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkChooseElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,13 +21,14 @@
*/
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
-import java.util.List;
+import org.richfaces.cdk.CdkException;
+
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkForEachElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,11 +21,11 @@
*/
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
-
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import org.richfaces.cdk.CdkException;
+
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkIfElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,10 +21,10 @@
*/
package org.richfaces.cdk.templatecompiler.model;
+import javax.xml.bind.annotation.XmlRootElement;
+
import org.richfaces.cdk.CdkException;
-import javax.xml.bind.annotation.XmlRootElement;
-
/**
* @author Nick Belaevski
* @since 4.0
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,11 +23,6 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import javax.xml.XMLConstants;
import javax.xml.bind.JAXB;
import javax.xml.bind.ValidationEventHandler;
@@ -40,6 +35,11 @@
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,8 +1,9 @@
package org.richfaces.cdk.templatecompiler.model;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
-import java.util.List;
public interface LeafModelElement extends ModelElement {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.templatecompiler.model;
+import java.util.List;
+
import com.google.common.collect.Lists;
-import java.util.List;
-
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,12 +1,13 @@
package org.richfaces.cdk.templatecompiler.model;
-import org.richfaces.cdk.CdkException;
+import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlSeeAlso;
-import java.util.List;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0">All classes that are used in template bodey should be presented
* in the {@link XmlSeeAlso} annotation </p>
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -30,18 +30,16 @@
import java.io.InputStream;
import java.net.URI;
-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;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
import com.google.common.collect.ImmutableMap;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,20 +25,18 @@
package org.richfaces.cdk.xmlconfig;
-import java.io.File;
import java.io.Writer;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.OutputFolder;
import org.richfaces.cdk.StandardOutputFolders;
-import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+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/xmlconfig/FacesConfigParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -25,8 +25,6 @@
import java.io.File;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.ModelBuilder;
@@ -36,6 +34,8 @@
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
+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/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -26,8 +26,6 @@
import java.util.Collections;
import java.util.Map;
-import com.google.inject.Inject;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
@@ -35,6 +33,8 @@
import org.richfaces.cdk.xmlconfig.model.ComponentAdapter;
import org.richfaces.cdk.xmlconfig.model.Fragment;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* That class parses xml document with fragment of faces-config ( eg, standard component attributes )
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -1,12 +1,12 @@
package org.richfaces.cdk.xmlconfig;
-import org.richfaces.cdk.CdkException;
-
import java.io.File;
import java.io.Writer;
import javax.xml.transform.Result;
+import org.richfaces.cdk.CdkException;
+
public interface JAXB {
public abstract <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException;
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -30,7 +30,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
@@ -40,7 +39,6 @@
import java.net.URISyntaxException;
import java.util.Collection;
-import com.google.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -63,6 +61,7 @@
import org.xml.sax.helpers.XMLReaderFactory;
import com.google.common.collect.ImmutableSet;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -22,17 +22,18 @@
package org.richfaces.cdk.xmlconfig.model;
-import com.google.common.collect.Lists;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.List;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import com.google.common.collect.Lists;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,16 +23,16 @@
import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import com.google.common.collect.Lists;
-import javax.xml.bind.annotation.XmlElements;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
/**
* @author akolonitsky
* @since Jan 6, 2010
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -31,14 +31,14 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.Extensible;
-import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.BehaviorModel;
import com.google.common.collect.Lists;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,15 +21,16 @@
package org.richfaces.cdk.xmlconfig.model;
-import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.ComponentLibrary;
+import java.util.List;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import java.util.List;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+
import com.google.common.collect.Lists;
/**
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/NamesListComparator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,10 +21,10 @@
package org.richfaces.cdk.xmlutils;
+import java.util.Comparator;
+
import org.w3c.dom.Node;
-import java.util.Comparator;
-
/**
* @author Nick Belaevski
* @since 3.2.2
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBody.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,6 +21,20 @@
package org.richfaces.cdk.xmlutils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
@@ -30,19 +44,6 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
class ArrayNodeList implements NodeList {
private Node[] nodes;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodyMerge.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,15 +21,6 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -37,6 +28,16 @@
import java.util.List;
import java.util.Set;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XMLBodySerializer.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,9 +21,7 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.NodeList;
+import java.io.StringWriter;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Transformer;
@@ -31,8 +29,11 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.StringWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/XPathComparator.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,13 +21,14 @@
package org.richfaces.cdk.xmlutils;
-import org.w3c.dom.Node;
+import java.util.Comparator;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import java.util.Comparator;
+import org.w3c.dom.Node;
+
/**
* @author Maksim Kaszynski
*/
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/DocumentDefinitionFactory.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,10 +21,10 @@
package org.richfaces.cdk.xmlutils.dtd;
+import java.net.URL;
+
import org.richfaces.cdk.xmlutils.dtd.wutka.WutkaDefinitionFactory;
-import java.net.URL;
-
/**
* @author Maksim Kaszynski
*/
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -21,19 +21,18 @@
package org.richfaces.cdk.xmlutils.dtd.wutka;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.xmlutils.dtd.Attribute;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
import org.richfaces.cdk.xmlutils.dtd.Element;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
import com.google.inject.Inject;
-
import com.wutka.dtd.DTD;
import com.wutka.dtd.DTDAttribute;
import com.wutka.dtd.DTDElement;
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-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -23,6 +23,11 @@
package org.richfaces.cdk.xmlutils.dtd.xerces;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.xerces.impl.Constants;
import org.apache.xerces.parsers.XMLGrammarPreparser;
import org.apache.xerces.xni.XNIException;
@@ -35,11 +40,6 @@
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
import com.google.inject.Inject;
/**
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-05 00:09:13 UTC (rev 16419)
@@ -101,7 +101,8 @@
protected static void compareTextFiles(Reader reference, Reader output) throws IOException {
LineNumberReader ref = new LineNumberReader(reference);
LineNumberReader out = new LineNumberReader(output);
- String refLine = "", outLine = "";
+ String refLine = "";
+ String outLine = "";
while (refLine != null || outLine != null) {
if (refLine == null) {
Assert.fail("Output text is longer than reference text");
14 years, 3 months
JBoss Rich Faces SVN: r16418 - in root/cdk/branches/guice/plugins: generator/src/main/java/org/richfaces/cdk/apt and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-02-04 18:57:31 -0500 (Thu, 04 Feb 2010)
New Revision: 16418
Added:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.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/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/model/ComponentLibrary.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/RendererClassVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.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/apt/AnnotationProcessorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
https://jira.jboss.org/jira/browse/RF-8288 finished dependency injection transition
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -51,6 +51,7 @@
import com.google.inject.Singleton;
import com.google.inject.Stage;
import com.google.inject.TypeLiteral;
+import com.google.inject.name.Names;
/**
* @author asmirnov
@@ -69,11 +70,13 @@
private Charset charset = Charset.defaultCharset();
- private Map<StandardOutputFolders, FileManager> outputFolders = Maps.newHashMap();
+ private Map<StandardOutputFolders, FileManager> outputFolders = Maps.newEnumMap(StandardOutputFolders.class);
- private Map<StandardSources,FileManager> sources = Maps.newHashMap();
+ private Map<StandardSources,FileManager> sources = Maps.newEnumMap(StandardSources.class);
private LibraryBuilder libraryBuilder;
+
+ private Map<String, String> options = Maps.newHashMap();
public Generator() {
@@ -104,6 +107,12 @@
this.sources.put(type, new SourceFileManager(files, folders));
}
+ public void setOptions(Map<String, String> options) {
+ this.options = options;
+
+ }
+
+
public void init(){
injector = Guice.createInjector(Stage.PRODUCTION,new CdkConfigurationModule(),new AptModule(),new ModelModule(),
new ClassGeneratorModule(),new FreeMakerModule(),new TemplateModule(),new XmlModule());
@@ -154,6 +163,8 @@
}
bind(NamingConventions.class).to(RichFacesConventions.class);
bind(ModelValidator.class).to(ValidatorImpl.class);
+
+ Names.bindProperties(binder(), options);
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -30,7 +30,7 @@
*
* @author asmirnov(a)exadel.com
*/
-class JavaLogger implements Logger {
+public class JavaLogger implements Logger {
public static final String CDK_LOG = "org.richfaces.cdk";
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -45,8 +45,9 @@
*
*/
public class AptBuilder implements LibraryBuilder {
+
@Inject
- private static Logger LOG ;
+ private Logger LOG ;
@Inject
private CompilationTaskFactory taskFactory;
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -55,7 +55,7 @@
*/
final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
@Inject
- private static Logger LOG;
+ private Logger LOG;
// private final BiMap<FileObjectKey, FileObject> classPathFiles;
// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -38,7 +38,8 @@
public class CdkConfiguration extends Configuration {
private static final String TEMPLATES = "/META-INF/templates";
- private final Logger log;
+
+ private Logger log;
@Inject
public CdkConfiguration(ObjectWrapper wrapper,Logger log) {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -28,6 +28,8 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.RenderKitModel.Id;
+import com.google.inject.Singleton;
+
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -50,6 +52,7 @@
* @author asmirnov(a)exadel.com
*
*/
+@Singleton
public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>, Trackable {
public static final String CDK_EXTENSIONS_NAMESPACE = "http://richfaces.org/cdk/extensions";
public static final String FACES_CONFIG_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,6 +22,7 @@
package org.richfaces.cdk.parser.el.types;
import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.JavaLogger;
import org.richfaces.cdk.parser.el.Type;
import org.richfaces.cdk.util.ArrayUtils;
@@ -48,7 +49,7 @@
public final class TypesFactory {
@Inject
- private static Logger LOG;
+ private static Logger LOG = new JavaLogger();
private static final Map<java.lang.reflect.Type, Type> REFLECTION_TYPES_CACHE = Collections
.synchronizedMap(new HashMap<java.lang.reflect.Type, Type>());
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -118,7 +118,7 @@
private static final String PASS_THROUGH_ATTRIBUTES_FIELD_NAME = "PASS_THROUGH_ATTRIBUTES";
@Inject
- private static Logger LOG;
+ private Logger LOG;
private static final Set<String> DEFAULT_NAMESPACES = new HashSet<String>();
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-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -230,7 +230,7 @@
File configFile = folders.getFile(path);
- if (configFile.exists()) {
+ if (null != configFile && configFile.exists()) {
InputStream inputStream = new FileInputStream(configFile);
entity = new InputSource(inputStream);
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -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 As {
+ public Class<?> value();
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/As.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -0,0 +1,42 @@
+/*
+ * $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;
+
+import com.google.inject.Provider;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface AsProvider {
+ public Class<? extends Provider<?>> value();
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/AsProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -128,7 +129,11 @@
return getLibraryFile(clazz.getName().replaceAll("\\.", "/")+".class");
}
- protected CdkClassLoader createClassLoader() throws Exception {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null);
+ protected CdkClassLoader createClassLoader(){
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
Modified: 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 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -41,8 +41,11 @@
import com.google.inject.AbstractModule;
import com.google.inject.BindingAnnotation;
import com.google.inject.Guice;
+import com.google.inject.ImplementedBy;
import com.google.inject.Injector;
import com.google.inject.Module;
+import com.google.inject.ProvidedBy;
+import com.google.inject.Provider;
import com.google.inject.TypeLiteral;
import com.google.inject.binder.AnnotatedBindingBuilder;
@@ -97,7 +100,7 @@
// throw new IncompatibleAnnotationException(Unit.class, Mock.class);
// }
//
- final Map<Field,Object> fieldValues = getMockValues(testFields);
+ final Map<Field,Binding> fieldValues = getMockValues(testFields);
// if ( fieldValues.containsKey(unitField)) {
// throw new IncompatibleAnnotationException(Unit.class, unitField.getType());
// }
@@ -106,16 +109,17 @@
// any field values created by AtUnit but not injected by the container are injected here.
for ( Field field : fieldValues.keySet() ) {
+ Binding binding = fieldValues.get(field);
field.setAccessible(true);
- if ( field.get(test) == null ) {
- field.set(test, fieldValues.get(field));
+ if ( null != binding.value && field.get(test) == null ) {
+ field.set(test, binding.value);
}
}
return test;
}
- private Object createTest(Class<?> testClass, Map<Field, Object> fieldValues) throws Exception {
+ private Object createTest(Class<?> testClass, Map<Field, Binding> fieldValues) throws Exception {
FieldModule fields = new FieldModule(fieldValues);
Injector injector;
@@ -129,9 +133,9 @@
protected class FieldModule extends AbstractModule {
- final Map<Field,Object> fields;
+ final Map<Field,Binding> fields;
- public FieldModule(Map<Field,Object> fields) {
+ public FieldModule(Map<Field,Binding> fields) {
this.fields = fields;
}
@@ -171,23 +175,49 @@
}
}
}
- builder.toInstance(fields.get(field));
+ Binding binding = fields.get(field);
+ if(null != binding.value){
+ builder.toInstance(binding.value);
+ } else if (null != binding.implementation) {
+ builder.to(binding.implementation);
+ } else if (null != binding.provider) {
+ builder.toProvider(binding.provider);
+ }
}
}
}
+
+ private static class Binding {
+ private Object value;
+ private Class<?> implementation;
+ private Class<? extends Provider<?>> provider;
+ }
- private Map<Field, Object> getMockValues(Set<Field> testFields) {
- Map<Field,Object> mocksAndStubs = new HashMap<Field,Object>();
+ private Map<Field, Binding> getMockValues(Set<Field> testFields) {
+ Map<Field,Binding> mocksAndStubs = new HashMap<Field,Binding>();
for ( Field field : testFields ) {
if ( field.getAnnotation(Mock.class) != null ) {
- mocksAndStubs.put(field, EasyMock.createStrictMock(field.getType()));
+ Binding bind = new Binding();
+ bind.value = EasyMock.createStrictMock(field.getType());
+ mocksAndStubs.put(field, bind);
} else if ( field.getAnnotation(Stub.class) != null ) {
- mocksAndStubs.put(field, EasyMock.createNiceMock(field.getType()));
+ Binding bind = new Binding();
+ bind.value = EasyMock.createNiceMock(field.getType());
+ mocksAndStubs.put(field, bind);
+ } else if (null != field.getAnnotation(As.class)) {
+ Binding bind = new Binding();
+ bind.implementation = field.getAnnotation(As.class).value();
+ mocksAndStubs.put(field, bind);
+ } else if (null != field.getAnnotation(AsProvider.class)) {
+ Binding bind = new Binding();
+ bind.provider = field.getAnnotation(AsProvider.class).value();
+ mocksAndStubs.put(field, bind);
}
}
return mocksAndStubs;
}
+
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,6 +22,7 @@
package org.richfaces.cdk.apt;
import java.io.File;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
@@ -78,12 +79,16 @@
protected abstract Iterable<String> sources();
@Override
- protected CdkClassLoader createClassLoader() throws Exception {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class),
- getLibraryFile(ELContext.class),
- getLibraryFile(Family.class),
- getLibraryFile(UIComponent.class)),
- this.getClass().getClassLoader());
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(ComponentModel.class),
+ getLibraryFile(ELContext.class),
+ getLibraryFile(Family.class),
+ getLibraryFile(UIComponent.class)),
+ this.getClass().getClassLoader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,56 +22,81 @@
package org.richfaces.cdk.freemarker;
+import static org.easymock.EasyMock.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+import java.util.Set;
+
+import javax.faces.component.UIOutput;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
-import static org.easymock.EasyMock.*;
import org.junit.Assert;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.OutputType;
-import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.ext.EntityResolver2;
-import javax.faces.component.UIOutput;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.ImplementedBy;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+import freemarker.template.ObjectWrapper;
+
/**
* @author akolonitsky
* @since Jan 18, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ValidatorTaglibGeneratorTest extends CdkTestBase {
+ @Inject
+ private ValidatorTaglibGenerator generator;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @As(CdkConfiguration.class)
+ private Configuration configuration;
+
+ @Inject
+ @As(LibraryModelWrapper.class)
+ ObjectWrapper wrapper;
+
+ @Mock
+ private EntityResolver2 resolver;
+
+ @Mock
+ @OutputFolder(StandardOutputFolders.RESOURCES)
+ private FileManager output;
+
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ValidatorTaglibGenerator generator = new ValidatorTaglibGenerator() {
- @Override
- protected Writer getOutput(ValidatorModel c) throws CdkException {
- return output;
- }
- };
+ final StringWriter outputWriter = new StringWriter();
- CdkContext mockContext = createMockContext();
- generator.init(mockContext);
ValidatorModel validator = new ValidatorModel("foo.bar", new ClassDescription(UIOutput.class));
validator.setGenerate(true);
@@ -84,14 +109,15 @@
eventNames.add(getEvent("id", false));
eventNames.add(getEvent("action", true));
- ComponentLibrary library = new ComponentLibrary();
library.getValidators().add(validator);
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output,resolver);
generator.visit(validator, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output,resolver);
- checkXmlStructure(output);
+ checkXmlStructure(outputWriter);
// TODO validate xml by xsd
// validateXml(output);
@@ -111,24 +137,13 @@
return attribute;
}
- private CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- return cdkContext;
- }
-
// TODO move it in other class
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
InputSource is = new InputSource(new StringReader(facesConfig.toString()));
Validator validator = new Validator(is);
validator.useXMLSchema(true);
- InputSource source = new CdkEntityResolver(null)
- .resolveEntity(null, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
+ InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facelettaglibrary_2_0.xsd").toURI().toString());
validator.setJAXP12SchemaSource(source);
validator.assertIsValid();
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,20 +22,6 @@
package org.richfaces.cdk.generate.java;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import org.junit.Assert;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.OutputType;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -44,21 +30,49 @@
import java.io.StringReader;
import java.io.StringWriter;
+import org.junit.Assert;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.freemarker.CdkConfiguration;
+import org.richfaces.cdk.freemarker.LibraryModelWrapper;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+import org.xml.sax.ext.EntityResolver2;
+
+import com.google.inject.Inject;
+
+import freemarker.template.Configuration;
+import freemarker.template.ObjectWrapper;
+
/**
* @author akolonitsky
* @since Jan 20, 2010
*/
public abstract class AbstractClassGeneratorTest extends CdkTestBase {
- protected CdkContext createMockContext() throws Exception {
- CdkContext cdkContext = createMock(CdkContext.class);
+
+ @Inject
+ protected ComponentLibrary library;
+
+ @Inject
+ @As(CdkConfiguration.class)
+ protected Configuration configuration;
+
+ @Inject
+ @As(LibraryModelWrapper.class)
+ ObjectWrapper wrapper;
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType) anyObject())).andStubReturn(null);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
+
+ @Mock
+ @OutputFolder(StandardOutputFolders.RESOURCES)
+ protected FileManager output;
- return cdkContext;
- }
protected static Property addAttribute(ModelElementBase model, String attributeName, Class<?> type, boolean generate) {
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,43 +22,40 @@
package org.richfaces.cdk.generate.java;
-import org.junit.Test;
-import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkContext;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
import java.io.StringWriter;
-import java.io.Writer;
import java.util.Set;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
+
+import com.google.inject.Inject;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class BehaviorClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private BehaviorClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileBehavior() throws Exception {
- final StringWriter output = new StringWriter();
- BehaviorClassGenerator generator = new BehaviorClassGenerator() {
- @Override
- protected Writer getOutput(BehaviorModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
BehaviorModel behavior = new BehaviorModel();
behavior.setBehaviorId("foo.bar");
behavior.setClassNames("org.richfaces.cdk.generate.java.GeneratedBehavior", "Object");
@@ -76,9 +73,9 @@
library.getBehaviors().add(behavior);
generator.visit(behavior, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output);
- compare(output, "GeneratedBehavior.java");
+ compare(outputWriter, "GeneratedBehavior.java");
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -28,26 +28,30 @@
import static org.easymock.EasyMock.*;
import java.io.StringWriter;
-import java.io.Writer;
import java.util.Set;
import javax.faces.component.UIOutput;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class ComponentClassGeneratorTest extends AbstractClassGeneratorTest {
+
+ @Inject
+ private ComponentClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
@@ -55,18 +59,10 @@
*/
@Test
public void testGetOutputFileComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ComponentClassGenerator generator = new ComponentClassGenerator() {
- @Override
- protected Writer getOutput(ComponentModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
- ComponentLibrary library = new ComponentLibrary();
ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.bar"));
library.getComponents().add(component);
component.setGenerate(true);
@@ -89,9 +85,9 @@
attribute.setGenerate(false);
generator.visit(component, library);
- System.out.println(output);
- verify(mockContext);
+ System.out.println(outputWriter);
+ verify(output);
- compare(output, "GeneratedComponent.java");
+ compare(outputWriter, "GeneratedComponent.java");
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,42 +22,40 @@
package org.richfaces.cdk.generate.java;
-import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 20, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ConverterClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private ConverterClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileValidator() throws Exception {
- final StringWriter output = new StringWriter();
- ConverterClassGenerator generator = new ConverterClassGenerator() {
- @Override
- protected Writer getOutput(ConverterModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
ConverterModel converter = new ConverterModel();
converter.setConverterId("foo.bar");
converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverter", "Object");
@@ -75,10 +73,10 @@
library.getConverters().add(converter);
generator.visit(converter, library);
- System.out.println(output);
+ System.out.println(outputWriter);
- verify(mockContext);
+ verify(output);
- compare(output, "GeneratedConverter.java");
+ compare(outputWriter, "GeneratedConverter.java");
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -22,48 +22,40 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.StandardSources;
+import static org.easymock.EasyMock.*;
+
+import java.io.StringWriter;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
-import org.junit.Test;
-import static org.easymock.EasyMock.verify;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.replay;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Set;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 15, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public class ValidatorClassGeneratorTest extends AbstractClassGeneratorTest {
+ @Inject
+ private ValidatorClassGenerator generator;
/**
* Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
* @throws Exception
*/
@Test
public void testGetOutputFileValidator() throws Exception {
- final StringWriter output = new StringWriter();
- ValidatorClassGenerator generator = new ValidatorClassGenerator() {
- @Override
- protected Writer getOutput(ValidatorModel c) throws CdkException {
- return output;
- }
- };
- CdkContext mockContext = createMockContext();
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
+ replay(output);
- generator.init(mockContext);
-
ValidatorModel validator = new ValidatorModel();
validator.setValidatorId("foo.bar");
validator.setClassNames("org.richfaces.cdk.generate.java.GeneratedClass", "Object");
@@ -81,11 +73,11 @@
library.getValidators().add(validator);
generator.visit(validator, library);
- System.out.println(output);
+ System.out.println(outputWriter);
- verify(mockContext);
+ verify(output);
- compare(output, "GeneratedClass.java");
+ compare(outputWriter, "GeneratedClass.java");
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -21,12 +21,8 @@
*/
package org.richfaces.cdk.templatecompiler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,34 +35,60 @@
import javax.faces.render.RenderKitFactory;
import javax.faces.validator.Validator;
-import org.junit.After;
-import org.junit.Before;
+import org.easymock.EasyMock;
+import org.junit.Ignore;
import org.junit.Test;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.RenderKitModel.Id;
import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXB;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.xml.sax.ext.EntityResolver2;
import com.google.common.collect.Lists;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* @author Nick Belaevski
*
*/
+(a)RunWith(CdkTestRunner.class)
public class RendererTemplateParserTest extends CdkTestBase {
+ @Inject
private RendererTemplateParser parser;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @As(JAXBBinding.class)
+ private JAXB binding;
+
+ @Mock
+ private EntityResolver2 resolver;
- private CdkContext cdkContext;
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
private RenderKitModel getRenderkitFromModel(String renderkitId) {
- Map<Id, RenderKitModel> renderKits = cdkContext.getLibrary().getRenderKits();
+ Map<Id, RenderKitModel> renderKits = library.getRenderKits();
assertNotNull(renderKits);
RenderKitModel renderKit = renderKits.get(new RenderKitModel.Id(renderkitId));
@@ -245,22 +267,10 @@
}
- @Before
- public void setUp() throws Exception {
- parser = new RendererTemplateParser();
- cdkContext = new CdkContextBase(createClassLoader());
- parser.init(cdkContext);
- }
- @After
- public void tearDown() throws Exception {
- parser = null;
- cdkContext = null;
- }
-
@Test
public void basicComponentTest() throws Exception {
- Template template = parser.parseTemplate("urn:resource:org/richfaces/cdk/templatecompiler/basic.template.xml");
+ Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/basic.template.xml"));
assertNotNull(template);
parser.mergeTemplateIntoModel(template);
@@ -273,8 +283,13 @@
}
@Test
+ @Ignore // TODO - fix import-attributes.
public void dummyComponentTest() throws Exception {
- Template template = parser.parseTemplate("urn:resource:org/richfaces/cdk/templatecompiler/dummy.template.xml");
+ expect(resolver.getExternalSubset(eq("cdk:root"), EasyMock.<String>anyObject())).andReturn(null).atLeastOnce();
+// expect(resolver.getExternalSubset("cdk:root", null)).andReturn(null).atLeastOnce();
+ replay(resolver,templatesSource);
+ Template template = parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/dummy.template.xml"));
+ verify(resolver,templatesSource);
assertNotNull(template);
parser.mergeTemplateIntoModel(template);
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -1,96 +1,101 @@
package org.richfaces.cdk.xmlconfig;
-import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.OutputType;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.annotations.Component;
import org.xml.sax.InputSource;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
public class CdkResolverTest extends CdkTestBase {
+
+ private static final String TEST_HTML = "org/richfaces/cdk/apt/test.html";
+
+ @Inject
+ private CdkEntityResolver entityResolver;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager facesConfigSource;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader classLoader = new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),getLibraryFile(Component.class)), null){
+ @Override
+ public InputStream getResourceAsStream(String name) {
+ if ("foo/bar.xml".equals(name)) {
+ return new ByteArrayInputStream("baz".getBytes());
+ } else {
+ return super.getResourceAsStream(name);
+ }
+ }
+
+ };
+ binder.bind(CdkClassLoader.class).toInstance(classLoader);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
@Test
public void testResolveSystemIdSystem() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
+ replay(facesConfigSource,templatesSource);
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
InputSource input = entityResolver.resolveSystemId("http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
@Test
public void testResolveSystemIdResource() throws Exception {
-
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- CdkClassLoader loader = new CdkClassLoader(CdkEntityResolver.class.getClassLoader()) {
- @Override
- public InputStream getResourceAsStream(String name) {
- if ("foo/bar.xml".equals(name)) {
- return new ByteArrayInputStream("baz".getBytes());
- } else {
- return super.getResourceAsStream(name);
- }
- }
- };
-
- expect(cdkContext.getLoader()).andStubReturn(loader);
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ replay(facesConfigSource,templatesSource);
InputSource input = entityResolver.resolveSystemId("urn:resource:foo/bar.xml");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
@Test
public void testResolveSystemIdAttributes() throws Exception {
- // Prepare Mock compilation context.
- CdkContext cdkContext = createMockContext();
- expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
- replay(cdkContext);
-
- CdkEntityResolver entityResolver = new CdkEntityResolver(cdkContext);
+ replay(facesConfigSource,templatesSource);
InputSource input = entityResolver.resolveSystemId("urn:attributes:test-props.xml");
-
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
}
- private CdkContext createMockContext() {
- CdkContext cdkContext = createMock(CdkContext.class);
- expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType) anyObject())).andStubReturn(null);
-
- return cdkContext;
- }
-
@Test
public void testGetProjectInputSource() throws Exception {
- CdkContext cdkContext = createMockContext();
-
- 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");
-
+ expect(facesConfigSource.getFile(TEST_HTML)).andReturn(getJavaFile(TEST_HTML));
+ replay(facesConfigSource,templatesSource);
+ InputSource input = entityResolver.getProjectInputSource(facesConfigSource,
+ TEST_HTML);
+ verify(facesConfigSource,templatesSource);
assertNotNull(input);
- verify(cdkContext);
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -29,18 +29,27 @@
import java.util.Map;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigBean;
import org.richfaces.cdk.xmlconfig.model.RenderKitBean;
+import org.xml.sax.ext.EntityResolver2;
import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
@@ -49,11 +58,36 @@
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class FacesConfigTest extends CdkTestBase {
+
+ @Inject
+ FragmentParser parser;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB jaxbBinding;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
@Test
public void testComponentUnmarshal() throws Exception {
- JAXBBinding jaxbBinding = createJAXB();
-
FacesConfigBean library = jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
@@ -83,7 +117,6 @@
@Test
public void testRenderKitUnmarshall() throws Exception {
- JAXBBinding jaxbBinding = createJAXB();
FacesConfigBean library = jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/renderkit.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
@@ -92,19 +125,4 @@
assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKits.get(0).getKey());
assertEquals(new RenderKitModel.Id("RDFa"), renderKits.get(1).getKey());
}
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return
- * @throws Exception
- */
- protected JAXBBinding createJAXB() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
-
- jaxbBinding.init(contextBase);
- return jaxbBinding;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -27,33 +27,63 @@
import static org.junit.Assert.*;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
+import org.xml.sax.ext.EntityResolver2;
-import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
+(a)RunWith(CdkTestRunner.class)
public class FragmentParserTest extends CdkTestBase {
+
+ @Inject
+ FragmentParser parser;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB binder;
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ private FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
@Test
public void parserTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
@@ -62,11 +92,7 @@
@Test
public void xincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties = parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
assertEquals(2, properties.size());
@@ -74,11 +100,7 @@
@Test
public void nestedXincludeTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
@@ -87,11 +109,7 @@
@Test
public void propertyTest() throws Exception {
- FragmentParser parser = new FragmentParser();
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- parser.init(contextBase);
-
Map<String, Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -5,23 +5,28 @@
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
-
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import com.google.inject.Inject;
+
+(a)RunWith(CdkTestRunner.class)
public class JaxbMarshalTest extends JaxbTestBase {
+
+ @Mock
+ JAXB jaxbBinding;
+
+ @Inject
+ ComponentLibrary library;
+
@Test
public void testMarshalResultStringT() throws Exception {
- CdkContextBase contextBase = new CdkContextBase(createClassLoader());
- JAXBBinding jaxbBinding = new JAXBBinding();
-
- jaxbBinding.init(contextBase);
-
- ComponentLibrary library = new ComponentLibrary();
ComponentModel component = new ComponentModel( new ComponentModel.Type("foo.bar"));
library.getComponents().add(component);
RenderKitModel renderKit = library.addRenderKit("HTML");
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -21,39 +21,75 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URISyntaxException;
+
+import javax.xml.transform.stream.StreamResult;
+
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
import org.junit.Assert;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContextBase;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
+import org.richfaces.cdk.xmlconfig.JAXB;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import org.richfaces.cdk.xmlconfig.JaxbTestBase;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
+import org.xml.sax.ext.EntityResolver2;
-import javax.xml.transform.stream.StreamResult;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.StringReader;
-import java.io.InputStreamReader;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
/**
* @author akolonitsky
* @since Jan 13, 2010
*/
+(a)RunWith(CdkTestRunner.class)
public abstract class ModelBeanTest extends JaxbTestBase {
- protected void validateXml(StringWriter facesConfig) throws SAXException, IOException {
+ @Inject
+ @As(JAXBBinding.class)
+ JAXB binding;
+
+ @Inject
+ @As(CdkEntityResolver.class)
+ EntityResolver2 resolver;
+
+
+ @Mock
+ @Source(StandardSources.RENDERER_TEMPLATES)
+ FileManager templatesSource;
+
+ @Mock
+ @Source(StandardSources.FACES_CONFIGS)
+ FileManager configSource;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkClassLoader.class).toInstance(createClassLoader());
+ }
+
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException, URISyntaxException {
InputSource is = new InputSource(new StringReader(facesConfig.toString()));
Validator validator = new Validator(is);
validator.useXMLSchema(true);
- InputSource source = new CdkEntityResolver(null)
- .resolveEntity(null, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
+ InputSource source = new InputSource(getJavaFile("META-INF/schema/web-facesconfig_2_0.xsd").toURI().toString());
validator.setJAXP12SchemaSource(source);
validator.assertIsValid();
@@ -77,9 +113,7 @@
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
- JAXBBinding jaxbBinding = new JAXBBinding();
- jaxbBinding.init(new CdkContextBase(createClassLoader()));
- jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
+ binding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
new FacesConfigAdapter().marshal(library));
return writer;
}
Modified: root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
===================================================================
--- root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -33,6 +33,8 @@
*/
public class MavenLogger implements Logger {
private Log log;
+
+ private int errorCount;
/**
* @param log
@@ -74,6 +76,7 @@
*/
public void error(CharSequence content, Throwable error) {
log.error(content, error);
+ errorCount++;
}
/**
@@ -82,6 +85,7 @@
*/
public void error(CharSequence content) {
log.error(content);
+ errorCount++;
}
/**
@@ -90,6 +94,7 @@
*/
public void error(Throwable error) {
log.error(error);
+ errorCount++;
}
/**
@@ -173,4 +178,9 @@
public void warn(Throwable error) {
log.warn(error);
}
+
+ @Override
+ public int getErrorCount() {
+ return errorCount;
+ }
}
Modified: root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-02-04 18:20:16 UTC (rev 16417)
+++ root/cdk/branches/guice/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2010-02-04 23:57:31 UTC (rev 16418)
@@ -23,6 +23,16 @@
package org.richfaces.builder.mojo;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
@@ -32,30 +42,12 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.richfaces.builder.maven.MavenLogger;
import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.Generator;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.ValidatorImpl;
-import org.richfaces.cdk.apt.AptBuilder;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -190,10 +182,11 @@
}
// Setup logger.
- LoggerFactory.setLogger(new MavenLogger(getLog()));
+ Logger logger = new MavenLogger(getLog());
- CdkContextBase context = new CdkContextBase(this.createProjectClassLoader(project));
-
+ Generator generator = new Generator();
+ generator.setLog(logger);
+ generator.setLoader(createProjectClassLoader(project));
// Set source folders.
ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
@@ -205,93 +198,37 @@
}
}
- context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- // Non-java sources.
- context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
- context.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles());
- context.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles());
+ generator.addSources(StandardSources.JAVA_SOURCES, findJavaFiles(), folders);
+ // TODO - detect templates and configs directories.
+ generator.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles(), null);
+ generator.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles(), null);
+
// Setup output folders.
- setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
- setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
- setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
- setOutput(context, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
+ setOutput(generator, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
+ setOutput(generator, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
+ setOutput(generator, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
+ setOutput(generator, outputTestResourcesDirectory, StandardOutputFolders.TEST_RESOURCES);
// configure CDK workers.
- boolean namingConventionsConfigured = false;
- boolean validatorConfigured = false;
+ setupPlugins(generator);
- if (null != workers) {
- for (Entry<String, String> workerEntry : workers.entrySet()) {
- try {
- Class<CdkWorker> workerClass =
- (Class<CdkWorker>) Class.forName(workerEntry.getKey()).asSubclass(CdkWorker.class);
- Class<? extends CdkWorker> workerImplementationClass =
- Class.forName(workerEntry.getValue()).asSubclass(CdkWorker.class);
- CdkWorker workerInstance = workerImplementationClass.newInstance();
-
- workerInstance.init(context);
- context.setWorker(workerClass, workerInstance);
-
- if (NamingConventions.class.equals(workerClass)) {
- namingConventionsConfigured = true;
- }
-
- if (ModelValidator.class.equals(workerClass)) {
- validatorConfigured = true;
- }
- } catch (ClassNotFoundException e) {
- throw new MojoFailureException("Worker class not found", e);
- } catch (InstantiationException e) {
- throw new MojoFailureException("Worker instance can't be created", e);
- } catch (IllegalAccessException e) {
- throw new MojoFailureException("Worker instance can't be created", e);
- } catch (CdkException e) {
- throw new MojoFailureException("Worker initialization error", e);
- }
- }
- }
-
- // Set default naming conventions if it was not configured.
- if (!namingConventionsConfigured) {
- RichFacesConventions facesConventions = new RichFacesConventions();
-
- try {
- facesConventions.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException("Naming conventions initialization error", e);
- }
-
- context.setWorker(NamingConventions.class, facesConventions);
- }
-
- // Set default model validator if it was not configured.
- if (!validatorConfigured) {
- ValidatorImpl validatorImpl = new ValidatorImpl();
-
- try {
- validatorImpl.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException("RichFaces Validator initialization error", e);
- }
-
- context.setWorker(ModelValidator.class, validatorImpl);
- }
-
if (null != options) {
// TODO make it type safe.
- context.setOptions(options);
+ generator.setOptions(options);
}
try {
// Build JSF library.
// LibraryBuilder builder = LibraryBuilder.createInstance(context);
- ModelBuilder builder = context.getWorker(AptBuilder.class);
- builder.build();
-
+ generator.init();
+ generator.execute();
+ if(logger.getErrorCount()>0){
+ throw new MojoFailureException("Errors occurred while JSF library was built");
+ }
// Tell project about generated files.
project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
@@ -311,19 +248,28 @@
}
/**
+ * <p class="changed_added_4_0"></p>
+ * @param generator
+ * @throws MojoFailureException
+ */
+ private void setupPlugins(Generator generator) throws MojoFailureException {
+ // TODO - get additional modules, as Maven components ?
+ }
+
+ /**
* <p class="changed_added_4_0">This utility method sets output directory for particular type.
* I such directory does not exist, it is created.</p>
*
- * @param context
+ * @param generator
* @param directory
* @param type
*/
- private static void setOutput(CdkContextBase context, File directory, StandardOutputFolders type) {
+ private static void setOutput(Generator generator, File directory, StandardOutputFolders type) {
if (!directory.exists()) {
directory.mkdirs();
}
- context.setOutputFolder(type, directory);
+ generator.addOutputFolder(type, directory);
}
/**
14 years, 3 months
JBoss Rich Faces SVN: r16417 - root.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-02-04 13:20:16 -0500 (Thu, 04 Feb 2010)
New Revision: 16417
Modified:
root/pom.xml
Log:
change url for sonar db connection
Modified: root/pom.xml
===================================================================
--- root/pom.xml 2010-02-04 17:45:58 UTC (rev 16416)
+++ root/pom.xml 2010-02-04 18:20:16 UTC (rev 16417)
@@ -121,7 +121,7 @@
<activeByDefault>true</activeByDefault>
</activation>
<properties>
- <sonar.jdbc.url>jdbc:mysql://192.168.0.241:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
+ <sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
14 years, 3 months
JBoss Rich Faces SVN: r16416 - root.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-02-04 12:45:58 -0500 (Thu, 04 Feb 2010)
New Revision: 16416
Modified:
root/pom.xml
Log:
add sonar profile
Modified: root/pom.xml
===================================================================
--- root/pom.xml 2010-02-04 16:57:43 UTC (rev 16415)
+++ root/pom.xml 2010-02-04 17:45:58 UTC (rev 16416)
@@ -114,5 +114,20 @@
</plugins>
</build>
</profile>
+
+ <profile>
+ <id>sonar</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <properties>
+ <sonar.jdbc.url>jdbc:mysql://192.168.0.241:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
+ <sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
+ <sonar.jdbc.username>sonar</sonar.jdbc.username>
+ <sonar.jdbc.password>sonar</sonar.jdbc.password>
+
+ <sonar.host.url>http://localhost:9000</sonar.host.url>
+ </properties>
+ </profile>
</profiles>
</project>
\ No newline at end of file
14 years, 3 months
JBoss Rich Faces SVN: r16415 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-02-04 11:57:43 -0500 (Thu, 04 Feb 2010)
New Revision: 16415
Modified:
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/FacesConfigAdapter.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - fix compilation error for sonar
Modified: 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 2010-02-04 16:14:47 UTC (rev 16414)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-02-04 16:57:43 UTC (rev 16415)
@@ -25,13 +25,11 @@
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.ComponentModel.Type;
+import org.richfaces.cdk.model.FacetModel;
+import org.richfaces.cdk.model.Property;
-import java.util.Map;
-
/**
* <p class="changed_added_4_0"></p>
*
@@ -68,8 +66,8 @@
model.setType(new Type(type.trim()));
}
// Copy properties/attributes
- model.getAttributes().putAll((Map<String,Property>) unmarshalMap(bean.getAttributes(), ATTRIBUTE_ADAPTER));
- model.getFacets().putAll((Map<String, FacetModel>) unmarshalMap(bean.getFacets(), FACET_ADAPTER));
+ model.getAttributes().putAll(this.<String, PropertyBase, Property>unmarshalMap(bean.getAttributes(), ATTRIBUTE_ADAPTER));
+ model.getFacets().putAll(this.<String, FacetBean, FacetModel>unmarshalMap(bean.getFacets(), FACET_ADAPTER));
// model.getFacets().putAll(unmarshalMap(bean.getExtension().getRendererTypes(), FACET_ADAPTER));
}
}
Modified: 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 2010-02-04 16:14:47 UTC (rev 16414)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2010-02-04 16:57:43 UTC (rev 16415)
@@ -26,8 +26,6 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
-import java.util.Map;
-
/**
* <p class="changed_added_4_0"></p>
*
@@ -54,6 +52,6 @@
@Override
protected void postUnmarshal(FacesConfigBean bean, ComponentLibrary model) {
- model.getRenderKits().putAll((Map<RenderKitModel.Id, RenderKitModel>)unmarshalMap(bean.getRenderKits(), ADAPTER));
+ model.getRenderKits().putAll(this.<RenderKitModel.Id, RenderKitBean, RenderKitModel>unmarshalMap(bean.getRenderKits(), ADAPTER));
}
}
14 years, 3 months
JBoss Rich Faces SVN: r16414 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-02-04 11:14:47 -0500 (Thu, 04 Feb 2010)
New Revision: 16414
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.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/FacesConfigAdapter.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - fix compilation error for sonar
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-02-04 15:29:22 UTC (rev 16413)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-02-04 16:14:47 UTC (rev 16414)
@@ -23,29 +23,27 @@
package org.richfaces.cdk.xmlconfig.model;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ModelElement;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import java.util.List;
+import java.util.Map;
/**
* <p class="changed_added_4_0"></p>
*
* @author asmirnov(a)exadel.com
*/
-public abstract class AdapterBase<K,V> extends XmlAdapter<K, V> {
+public abstract class AdapterBase<K, V> extends XmlAdapter<K, V> {
@Override
public K marshal(V model) throws CdkException {
K bean = JAXBBinding.createAdapter(getBeanClass(model), model);
- postMarshal(model,bean);
+ postMarshal(model, bean);
return bean;
}
@@ -58,7 +56,7 @@
@Override
public V unmarshal(K bean) throws CdkException {
V model = JAXBBinding.createModelElement(getModelClass(bean), bean);
- postUnmarshal(bean,model);
+ postUnmarshal(bean, model);
return model;
}
@@ -68,10 +66,11 @@
protected abstract Class<? extends V> getModelClass(K bean);
- protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>> List<B> marshalMap(Map<K,M> map,
+ protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>> List<B> marshalMap(Map<K, M> map,
AdapterBase<B, M> adapter) throws CdkException {
+
List<B> result = Lists.newArrayList();
- if(null != map && map.size()>0){
+ if (null != map && map.size() > 0) {
for (Map.Entry<K, M> entry : map.entrySet()) {
B bean = adapter.marshal(entry.getValue());
bean.setKey(entry.getKey());
@@ -81,10 +80,11 @@
return result;
}
- protected <K,B extends MapEntry<K>, M extends ModelElement<? super M>> Map<K,M> unmarshalMap(List<B> list,
- AdapterBase<B, M> adapter) throws CdkException {
- Map<K,M> map = Maps.newHashMap();
- if(null != list && list.size()>0){
+ protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>> Map<K, M> unmarshalMap(
+ List<B> list, AdapterBase<B, M> adapter) throws CdkException {
+
+ Map<K, M> map = Maps.newHashMap();
+ if (null != list && list.size() > 0) {
for (B bean : list) {
M model = adapter.unmarshal(bean);
map.put(bean.getKey(), model);
Modified: 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 2010-02-04 15:29:22 UTC (rev 16413)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-02-04 16:14:47 UTC (rev 16414)
@@ -25,9 +25,13 @@
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.ComponentModel.Type;
+import java.util.Map;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -64,7 +68,8 @@
model.setType(new Type(type.trim()));
}
// Copy properties/attributes
- model.getAttributes().putAll(unmarshalMap(bean.getAttributes(), ATTRIBUTE_ADAPTER));
- model.getFacets().putAll(unmarshalMap(bean.getFacets(), FACET_ADAPTER));
+ model.getAttributes().putAll((Map<String,Property>) unmarshalMap(bean.getAttributes(), ATTRIBUTE_ADAPTER));
+ model.getFacets().putAll((Map<String, FacetModel>) unmarshalMap(bean.getFacets(), FACET_ADAPTER));
+// model.getFacets().putAll(unmarshalMap(bean.getExtension().getRendererTypes(), FACET_ADAPTER));
}
}
Modified: 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 2010-02-04 15:29:22 UTC (rev 16413)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigAdapter.java 2010-02-04 16:14:47 UTC (rev 16414)
@@ -24,7 +24,10 @@
package org.richfaces.cdk.xmlconfig.model;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.RenderKitModel;
+import java.util.Map;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -51,6 +54,6 @@
@Override
protected void postUnmarshal(FacesConfigBean bean, ComponentLibrary model) {
- model.getRenderKits().putAll(unmarshalMap(bean.getRenderKits(), ADAPTER));
+ model.getRenderKits().putAll((Map<RenderKitModel.Id, RenderKitModel>)unmarshalMap(bean.getRenderKits(), ADAPTER));
}
}
14 years, 3 months