JBoss Rich Faces SVN: r16383 - in root: cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-01-31 18:27:26 -0500 (Sun, 31 Jan 2010)
New Revision: 16383
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.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/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/CdkCallElement.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
Log:
https://jira.jboss.org/jira/browse/RF-7732
https://jira.jboss.org/jira/browse/RF-8309
https://jira.jboss.org/jira/browse/RFPL-364
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -86,15 +86,17 @@
return result.toString();
}
- public static String getEscapedStringsArray(String... strings) {
+ public static String getEscapedStringsArray(Iterable<String> strings) {
StringBuilder sb = new StringBuilder();
- for (String string : strings) {
- if (sb.length() > 0) {
- sb.append(", ");
+ if (strings != null) {
+ for (String string : strings) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(getEscapedString(string));
}
-
- sb.append(getEscapedString(string));
}
return sb.toString();
@@ -138,4 +140,5 @@
public static boolean isdigit(char c) {
return (c >= '0') && (c <= '9');
}
+
}
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-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -31,10 +31,15 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.faces.event.FacesEvent;
+import javax.faces.model.DataModel;
+import javax.faces.render.Renderer;
+import javax.faces.validator.Validator;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.LoggerFactory;
@@ -95,7 +100,9 @@
private static final String[] GUESS_PACKAGES;
static {
- Class<?>[] guessPackagesClasses = { UIComponent.class, Behavior.class, Converter.class, FacesContext.class,
+ Class<?>[] guessPackagesClasses = {
+ UIComponent.class, Behavior.class, Converter.class, Validator.class,
+ FacesContext.class, Application.class, FacesEvent.class, DataModel.class, Renderer.class,
Collection.class, Object.class };
GUESS_PACKAGES = new String[guessPackagesClasses.length];
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-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -26,6 +26,8 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Map;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.cdk.CdkContext;
@@ -33,17 +35,21 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import com.google.common.collect.Maps;
+
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassGenerator implements CdkWriter {
@@ -59,12 +65,26 @@
this.context = context;
}
+ private ComponentModel findComponentByRenderer(RendererModel renderer) {
+ Collection<ComponentModel> components = context.getLibrary().getComponents();
+ if (components != null) {
+ for (ComponentModel component : components) {
+ Collection<RendererModel> renderers = component.getRenderers();
+ if (renderers != null) {
+ if (renderers.contains(renderer)) {
+ return component;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
/*
* (non-Javadoc)
*
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary )
*/
@Override
public void render() throws CdkException {
@@ -73,9 +93,18 @@
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- RendererClassVisitor visitor = new RendererClassVisitor(
- template.getInterface(), context.getLoader(), context.getWorker(JAXBBinding.class));
+ Map<String, Property> attributesMap = Maps.newHashMap();
+ ComponentModel component = findComponentByRenderer(renderer);
+ if (component != null) {
+ attributesMap.putAll(component.getAttributes());
+ }
+
+ attributesMap.putAll(renderer.getAttributes());
+
+ RendererClassVisitor visitor = new RendererClassVisitor(template.getInterface(),
+ attributesMap, context.getLoader(), context.getWorker(JAXBBinding.class));
+
try {
// TODO - put real parameters.
visitor.preProcess();
@@ -84,13 +113,12 @@
} finally {
RendererClassVisitor.clearCaches();
}
-
+
JavaClass javaClass = visitor.getGeneratedClass();
String fullName = javaClass.getName();
- File outFile = context.createOutputFile(
- StandardOutputs.RENDERER_CLASSES, fullName.replace(
- '.', '/')
- + ".java", library.lastModified());
+ File outFile = context.createOutputFile(StandardOutputs.RENDERER_CLASSES, fullName
+ .replace('.', '/')
+ + ".java", library.lastModified());
if (null != outFile) {
PrintWriter outputWriter = null;
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-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -53,6 +53,8 @@
import org.richfaces.cdk.attributes.Element;
import org.richfaces.cdk.attributes.Schema;
import org.richfaces.cdk.attributes.SchemaSet;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.parser.el.ELParserUtils;
import org.richfaces.cdk.parser.el.ELVisitor;
import org.richfaces.cdk.parser.el.ParsingException;
@@ -74,6 +76,8 @@
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
/**
@@ -138,9 +142,12 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
+ private Map<String, Property> attributes;
- public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader classLoader, JAXBBinding jaxbBinding) {
+ public RendererClassVisitor(CompositeInterface compositeInterface, Map<String, Property> attributes,
+ ClassLoader classLoader, JAXBBinding jaxbBinding) {
this.compositeInterface = compositeInterface;
+ this.attributes = attributes;
this.classLoader = classLoader;
// TODO - cache unmarshalled data (as CDKWorker?)
@@ -260,9 +267,8 @@
return result;
}
- private String createPassThroughAttributeCode(String htmlAttributeName, Attribute componentAttribute,
- String[] eventNames) {
-
+ private String createPassThroughAttributeCode(String htmlAttributeName, String componentAttributeName) {
+
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
StringBuilder sb = new StringBuilder();
@@ -272,20 +278,36 @@
sb.append(")");
- String componentAttributeName = componentAttribute.getComponentAttributeName();
+ String attributeName;
if (!StringUtils.isEmpty(componentAttributeName)) {
+ attributeName = componentAttributeName;
+
sb.append(".setComponentAttributeName(");
sb.append(StringUtils.getEscapedString(componentAttributeName));
sb.append(")");
+ } else {
+ attributeName = htmlAttributeName;
}
- if (eventNames != null && eventNames.length != 0) {
- sb.append(".setEventNames(");
- sb.append("new String[] {");
+ Property property = attributes.get(attributeName);
+ if (property != null) {
+ Set<EventName> eventNames = property.getEventNames();
+ if (eventNames != null && !eventNames.isEmpty()) {
+ sb.append(".setEventNames(");
+ sb.append("new String[] {");
- sb.append(StringUtils.getEscapedStringsArray(eventNames));
+ Collection<String> eventNamesStrings = Collections2.transform(eventNames,
+ new Function<EventName, String>() {
+ @Override
+ public String apply(EventName from) {
+ return from.getName();
+ }
+ });
- sb.append("})");
+ sb.append(StringUtils.getEscapedStringsArray(eventNamesStrings));
+
+ sb.append("})");
+ }
}
return sb.toString();
@@ -322,7 +344,9 @@
}
// TODO behaviors data
- fieldValue.append(createPassThroughAttributeCode(entry.getKey(), entry.getValue(), null));
+ String htmlAttributeName = entry.getKey();
+ String componentAttributeName = entry.getValue().getComponentAttributeName();
+ fieldValue.append(createPassThroughAttributeCode(htmlAttributeName, componentAttributeName));
}
fieldValue.append("))");
@@ -539,7 +563,12 @@
*/
@Override
public void visitElement(CdkCallElement cdkCallElement) throws CdkException {
- currentStatement.addStatement(cdkCallElement.getExpression() + ";");
+ String expression = cdkCallElement.getExpression();
+ if (Strings.isEmpty(expression)) {
+ expression = cdkCallElement.getBodyValue();
+ }
+
+ currentStatement.addStatement(expression + ";");
}
/*
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-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -140,7 +140,6 @@
RenderKitModel renderKit = library.addRenderKit(compositeInterface.getRenderKitId());
RendererModel renderer = new RendererModel(new RendererModel.Type(compositeInterface.getRendererType()));
renderKit.getRenderers().add(renderer);
- String componentType = compositeInterface.getComponentType();
// component.getRenderers().add(renderer);
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-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -27,6 +27,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
/**
* <p class="changed_added_4_0"></p>
@@ -38,6 +39,9 @@
private String expression;
+ @XmlValue
+ private String bodyValue;
+
public CdkCallElement() {
}
@@ -60,6 +64,24 @@
this.expression = expression;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the bodyValue
+ */
+ public String getBodyValue() {
+ return bodyValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param bodyValue the bodyValue to set
+ */
+ public void setBodyValue(String bodyValue) {
+ this.bodyValue = bodyValue;
+ }
+
@Override
public void visit(TemplateVisitor visitor) throws CdkException {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -41,8 +41,6 @@
private static final long serialVersionUID = -5578359507253872500L;
- private String componentType;
-
private String componentFamily;
private List<Attribute> attributes;
@@ -64,25 +62,6 @@
/**
* <p class="changed_added_4_0"></p>
*
- * @return the componentType
- */
- @XmlElement(name = "component-type", namespace = Template.CDK_NAMESPACE)
- public String getComponentType() {
- return this.componentType;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param componentType the componentType to set
- */
- public void setComponentType(String componentType) {
- this.componentType = componentType;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
* @return the family
*/
@XmlElement(name = "component-family", namespace = Template.CDK_NAMESPACE)
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-composite.xsd 2010-01-31 23:27:26 UTC (rev 16383)
@@ -1,39 +1,32 @@
<?xml version = "1.0" encoding = "UTF-8"?>
-<!--
-JBoss, Home of Professional Open Source
-Copyright ${year}, Red Hat, Inc. and individual contributors
-by the @authors tag. See the copyright.txt in the distribution for a
-full listing of individual contributors.
+ <!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+ -->
-
-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.
--->
-
<xs:schema targetNamespace="http://richfaces.org/cdk/jsf/composite"
xmlns:cc="http://richfaces.org/cdk/jsf/composite" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xml="http://www.w3.org/XML/1998/namespace" elementFormDefault="qualified"
- attributeFormDefault="unqualified">
+ xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:cdk="http://richfaces.org/cdk/core"
+ elementFormDefault="qualified" attributeFormDefault="unqualified">
+ <xs:import schemaLocation="cdk-template.xsd" namespace="http://richfaces.org/cdk/core" />
+
<xs:annotation>
<xs:documentation>
- NB: this schema covers only subset of elements supported by RichFaces CDK and therefore it
- shouldn't be used as a reference document for development of composite components.
+ Subset of JSF 2.0 composite tags supported by RichFaces CDK.
</xs:documentation>
</xs:annotation>
@@ -77,14 +70,7 @@
</xs:attributeGroup>
<xs:complexType name="attributeExtensionType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:element ref="cc:attribute" />
- <xs:element ref="cc:extension" />
- <xs:element ref="cc:clientBehavior" />
- <xs:any processContents="lax" namespace="##other" />
- </xs:choice>
- </xs:sequence>
+ <xs:group ref="cc:compositeTagsGroup" />
<xs:attribute name="name" use="required">
<xs:annotation>
<xs:documentation>
@@ -103,7 +89,7 @@
present, must be ignored as its value is derived as
described in
retargetMethodExpressions().
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="targets">
@@ -111,20 +97,22 @@
<xs:documentation>
If this element has a method-signature attribute, the value of the
targets attribute must be interpreted as a space (not tab)
- separated list of client ids (relative to the top level component)
+ separated list of client ids (relative to the top level
+ component)
of components within the
<composite:implementation> section. Space is used as the delimiter
- for compatibility with the IDREFS and NMTOKENS data types from the
- XML Schema. Each entry in the list must be interpreted as the id
- of an inner component to which the MethodExpression from the
- composite component tag in the using page must be applied. If this
- element has a method-signature attribute, but no targets
- attribute, the value of the name attribute is used as the single
- entry in the list. If the value of the name attribute is not one
- of the special values listed in the description of the name
- attribute, targets (or its derived value) need not correspond to
- the id of an inner component.
- </xs:documentation>
+ for compatibility with the IDREFS and NMTOKENS data types from the
+ XML Schema. Each entry in the list must be interpreted as the id
+ of an inner component to which the MethodExpression from the
+ composite component tag in the using page must be applied. If
+ this
+ element has a method-signature attribute, but no targets
+ attribute, the value of the name attribute is used as the single
+ entry in the list. If the value of the name attribute is not one
+ of the special values listed in the description of the name
+ attribute, targets (or its derived value) need not correspond to
+ the id of an inner component.
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="default">
@@ -133,15 +121,16 @@
If this attribute is not required, and a value is
not supplied by the
page author, use this as the default value.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="required" type="xs:boolean" default="false">
+ <xs:attribute name="required" type="xs:boolean"
+ default="false">
<xs:annotation>
<xs:documentation>
True if the page author must supply a value for
this attribute.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="method-signature">
@@ -200,7 +189,7 @@
Example:
java.lang.String nickName(java.lang.String, int)
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type">
@@ -217,7 +206,7 @@
attribute. If both attributes are present, the
"method-signature"
attribute is ignored.
- </xs:documentation>
+ </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup ref="cc:beanDescriptorAttributes" />
@@ -227,7 +216,7 @@
<xs:attribute name="event">
<xs:annotation>
<xs:documentation>
- Names of the logical event supported by the component
+ Names of the logical event supported by the component
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -235,7 +224,8 @@
<xs:attribute name="default" type="xs:boolean">
<xs:annotation>
<xs:documentation>
- Boolean attribute defining whether the specified logical event is the default component event
+ Boolean attribute defining whether the specified logical event is the
+ default component event
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -247,12 +237,27 @@
</xs:sequence>
</xs:complexType>
- <xs:complexType name="compositeInterfaceType">
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:any namespace="##any" processContents="lax" />
+ <xs:group name="compositeTagsGroup">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="attribute" type="cc:attributeExtensionType" />
+ <xs:element name="extension" type="cc:compositeExtensionType" />
+ <xs:element name="clientBehavior" type="cc:clientBehaviorExtensionType" />
</xs:choice>
</xs:sequence>
+ </xs:group>
+
+ <xs:group name="compositeTagsGroupWithAny">
+ <xs:sequence>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:group ref="cc:compositeTagsGroup" />
+ <xs:any processContents="lax" namespace="##other " />
+ </xs:choice>
+ </xs:sequence>
+ </xs:group>
+
+ <xs:complexType name="compositeInterfaceType">
+ <xs:group ref="cc:compositeTagsGroupWithAny" />
<xs:attribute type="xs:string" name="name">
<xs:annotation>
<xs:documentation>
@@ -271,7 +276,8 @@
<xs:documentation>
The component-type of the UIComponent that will
serve as the composite
- component root for this composite component.
+ component root for this composite
+ component.
The declared
component-family for this component must be
javax.faces.NamingContainer.
@@ -290,8 +296,5 @@
<xs:element name="interface" type="cc:compositeInterfaceType" />
<xs:element name="implementation" type="cc:compositeImplementationType" />
- <xs:element name="extension" type="cc:compositeExtensionType" />
- <xs:element name="attribute" type="cc:attributeExtensionType" />
- <xs:element name="clientBehavior" type="cc:clientBehaviorExtensionType" />
</xs:schema>
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-jstl-core.xsd 2010-01-31 23:27:26 UTC (rev 16383)
@@ -31,8 +31,7 @@
<xs:annotation>
<xs:documentation>
- NB: this schema covers only subset of elements supported by RichFaces CDK and therefore it
- shouldn't be used as a reference document for development of application pages.
+ Subset of JSTL core tags supported by RichFaces CDK.
</xs:documentation>
</xs:annotation>
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-31 23:27:26 UTC (rev 16383)
@@ -30,6 +30,12 @@
xmlns:xhtml="http://richfaces.org/cdk/xhtml-el" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:c="http://richfaces.org/cdk/jstl/core" xmlns:cc="http://richfaces.org/cdk/jsf/composite">
+ <xs:annotation>
+ <xs:documentation>
+ RichFaces CDK core tags and attributes.
+ </xs:documentation>
+ </xs:annotation>
+
<xs:import schemaLocation="web-facesuicomponent_2_0.xsd" namespace="http://java.sun.com/xml/ns/javaee" />
<xs:import schemaLocation="cdk-composite.xsd" namespace="http://richfaces.org/cdk/jsf/composite" />
<xs:import schemaLocation="cdk-jstl-core.xsd" namespace="http://richfaces.org/cdk/jstl/core" />
@@ -57,19 +63,6 @@
<xs:restriction base="xs:string" />
</xs:simpleType>
- <xs:attributeGroup name="core.attrs">
- <xs:attribute name="passThroughWithExclusions" type="xs:NMTOKENS" form="qualified" />
- </xs:attributeGroup>
-
- <xs:element name="root">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="cc:interface" />
- <xs:element ref="cc:implementation" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
<xs:simpleType name="resourceDependencyTargets">
<xs:restriction base="xs:string">
<xs:enumeration value="body" />
@@ -78,49 +71,301 @@
</xs:restriction>
</xs:simpleType>
- <xs:complexType name="resource-dependenciesComplexType">
+ <xs:complexType name="resourceDependenciesType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="resource-dependency" type="resourceDependencyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="resourceDependencyType">
- <xs:attribute name="name" use="required" form="unqualified" />
- <xs:attribute name="library" form="unqualified" />
+ <xs:attribute name="name" use="required" form="unqualified">
+ <xs:annotation>
+ <xs:documentation><p>The resourceName of the resource pointed to by this ResourceDependency.</p></xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="library" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>The libraryName in which the resource pointed to by this ResourceDependency resides.
+ If not specified, defaults to the empty string.
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="target" form="unqualified"
- type="resourceDependencyTargets" />
+ type="resourceDependencyTargets">
+ <xs:annotation>
+ <xs:documentation>
+ <p>The value given for this attribute will be passed as the "target" argument to
+ <code>javax.faces.component.UIViewRoot.addComponentResource(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String).</code>
+ </p>
+ <p>
+ If this attribute is specified, <code>javax.faces.component.UIViewRoot.addComponentResource(javax.faces.context.FacesContext, javax.faces.component.UIComponent)</code>
+ must be called instead, as described above.
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:element name="resource-dependencies">
+
+ <xs:attribute name="passThroughWithExclusions">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Enables pass-through rendering of attributes. Allows to define whitespace-separated list of attributes
+ to exclude from pass-through encoding or empty string "" if all attributes should be encoded.</p>
+ <p>
+ Examples:
+
+ <ul>
+ <li><code><![CDATA[<div cdk:passThroughWithExclusions="title style"></code>]]></code></li>
+ <li><code><![CDATA[<div cdk:passThroughWithExclusions="">]]></code></li>
+ </ul>
+
+ <span class="usage">
+ Attributes already defined on the tag are automatically excluded from pass-through
+ rendering.
+ </span>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:restriction>
+ <xs:simpleType>
+ <xs:list>
+ <xs:simpleType>
+ <xs:restriction base="xs:NMTOKEN" />
+ </xs:simpleType>
+ </xs:list>
+ </xs:simpleType>
+ <xs:minLength value="0" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attributeGroup name="core.attrs">
+ <xs:attribute ref="passThroughWithExclusions" />
+ </xs:attributeGroup>
+
+ <xs:element name="root">
+ <xs:annotation>
+ <xs:documentation><p>Root template tag containing cc:interface & cc:implementation tags.</p></xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:choice>
- <xs:element name="resource-dependency" type="resourceDependencyType" />
- </xs:choice>
+ <xs:sequence>
+ <xs:element ref="cc:interface" />
+ <xs:element ref="cc:implementation" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="class" type="javaee:fully-qualified-classType" />
- <xs:element name="superclass" type="javaee:fully-qualified-classType" />
- <xs:element name="component-class" type="javaee:fully-qualified-classType" />
+ <xs:element name="resource-dependencies" type="resource-dependenciesComplexType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>
+ Container tag to specify multiple <code><![CDATA[<resource-dependency>]]></code> tags
+ on a single class.
+ </p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
- <xs:element name="component-type" />
+ <xs:element name="class" type="javaee:fully-qualified-classType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Fully-qualified name of the generated renderer class.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
- <xs:element name="renderkit-id" />
- <xs:element name="component-family" />
- <xs:element name="renderer-type" />
- <xs:element name="renders-children" type="xs:boolean" />
+ <xs:element name="superclass" type="javaee:fully-qualified-classType">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Fully-qualified name of the renderer superclass.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element name="renderkit-id">
+ <xs:annotation>
+ <xs:documentation>
+ <p>ID of the renderkit to include this renderer to. Defaults to 'HTML_BASIC'.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="component-family">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Family of the component to be rendered by this renderer.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="renderer-type">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Renderer type identifier for this renderer.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="renders-children" type="xs:boolean">
+ <xs:annotation>
+ <xs:documentation>
+ <p><span class="usage">Should be used within cc:interface element.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="import-attributes">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Defines fragment of faces configuration file to import attributes from.</p>
+ <p><span class="usage">Should be used within cc:interface element.</span></p></xs:documentation>
+ </xs:annotation>
<xs:complexType>
- <xs:attribute use="required" name="src" type="xs:anyURI" form="unqualified" />
+ <xs:attribute use="required" name="src" type="xs:anyURI" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ URI of the file to import. Any URI supported by CDK is allowed to be used here.
+ Imported file should have <code><![CDATA[<cdk:properties>]]></code> tag as root element.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
<xs:group name="structural">
<xs:choice>
<xs:element name="body">
+ <xs:annotation>
+ <xs:documentation>
+ <p>
+ Template body marker tag. <span class="usage">Should be used only once in template document.</span>
+ Component renderers in JSF define three methods for content rendering, so the following
+ rules are applied for <code><![CDATA[<cc:implementation>]]></code> part of template document:
+
+ <ul>
+ <li>
+ all content declared before <code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeBegin(...)</code> method
+ </li>
+ <li>
+ all content declared inside <code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeChildren(...)</code> method.
+ </li>
+ <li>
+ all content declared before <code><![CDATA[<cdk:body>]]></code> tag is compiled into
+ statements of <code>encodeEnd(...)</code> method
+ </li>
+ </ul>
+
+ If there are no compiled statements for one of the aforementioned methods, then definition
+ for this method is not created in the generated file.<br />
+ If template document doesn't declare <code><![CDATA[<cdk:body>]]></code> tag, then contents
+ of <code><![CDATA[<cc:implementation>]]></code> part is compiled into statements of
+ <code>encodeEnd(...)</code> method.
+ </p>
+ <p>
+ Examples:<br /><br />
+
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ <cdk:body>
+ <span>Component content</span>
+ </cdk:body>
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeBegin(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeAttribute("id", "myId", null);
+ }
+
+ encodeChildren(...) {
+ ...
+ writer.startElement("span", cc);
+ writer.writeText("Component content", null);
+ writer.endlement("span");
+ }
+
+ encodeEnd(...) {
+ ...
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+
+ <br /><br />
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ <cdk:body />
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeBegin(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeAttribute("id", "myId", null);
+ }
+
+ encodeEnd(...) {
+ ...
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+
+ <br /><br />
+ The following code snippet:
+ <pre><![CDATA[
+ ...
+ <cc:implementation>
+ <div id="myId">
+ Some text
+ </div>
+ </cc:implementation>
+ ...
+ ]]></pre>
+ produces the following code (unsignificant details are ommitted):
+ <pre><![CDATA[
+ ...
+
+ encodeEnd(...) {
+ ...
+ writer.startElement("div", cc);
+ writer.writeText("Some text", null);
+ writer.endElement("div");
+ }
+
+ ...
+ ]]></pre>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
<xs:complexType mixed="true">
<xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" />
@@ -134,27 +379,139 @@
</xs:group>
<xs:element name="call">
- <xs:complexType>
- <xs:attribute name="expression" form="unqualified" />
+ <xs:annotation>
+ <xs:documentation>
+ <p>Arbitrary method invocation statement. Should be used within cc:implementation element.</p>
+ <p><span class="usage">Note: method return value is ignored.</span></p>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType mixed="true">
+ <xs:attribute name="expression" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Method invocation expression. If this attribute is ommitted, body of the tag is used instead.</p>
+ <p>Examples:
+
+ <ul>
+ <li><code><![CDATA[<cdk:call expression="responseWriter.writeAttribute("id", clientId, "id")" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:call>responseWriter.writeAttribute("id", clientId, "id")</cdk:call>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
</xs:element>
+
<xs:element name="object">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Introduces new variable. Variable's scope is limited to the context of the current method,
+ i.e. variables defined before <cdk:body> are not available after it.</p>
+
+ <p><span class="usage">Should be used within cc:implementation element.</span></p>
+ <p>Usage example:
+ <ul>
+ <li>
+ <code><![CDATA[<cdk:object name="children" type="List" type-arguments="UIComponent" value="#{cc.children}" />]]></code>
+ </li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="xs:string">
- <xs:attribute name="name" form="unqualified" type="literalExpression" use="required" />
- <xs:attribute name="value" form="unqualified" />
- <xs:attribute name="type" form="unqualified" />
- <xs:attribute name="type-arguments" form="unqualified" />
+ <xs:attribute name="name" form="unqualified" type="literalExpression" use="required">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Name of the variable, corresponding to Java identifier syntax.</p>
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object name="children" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object name="myVariable" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object name="_children0" ...>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="value" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>EL-expression specifying initial value of the variable. If this attribute
+ is ommitted, body of the tag is used instead.</p>
+
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object value="#{cc.rendered}" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object value="#{myObject} ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object value="#{getSubmittedValue(facesContext, cc)} ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object ...>#{cc.getClientId(facesContext)}</cdk:object>]]></code></li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Variable type name. CDK automatically resolves simple names for primitive types,
+ JSF API classes and objects from java.lang.* or java.util.*.</p>
+ <p>Examples:
+ <ul>
+ <li><code><![CDATA[<cdk:object type="java.lang.String" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="float" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="List" ...>]]></code></li>
+ <li><code><![CDATA[<cdk:object type="UIComponent" ...>]]></code></li>
+ </ul>
+ </p>
+ <p>If type is not defined explicitly, CDK will try to infer variable type
+ from its value.</p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type-arguments" form="unqualified">
+ <xs:annotation>
+ <xs:documentation>
+ <p>Comma-separated list of generic type arguments for usage with types like
+ java.util.List or java.util.Map.</p>
+ <p>Examples:
+ <ul>
+ <li>
+ <code><![CDATA[<cdk:object name="map" type="Map" type-arguments="String, Object" />]]></code>
+ </li>
+ <li>
+ <code><![CDATA[<cdk:object name="list" type="List" type-arguments="UIComponent" />]]></code>
+ </li>
+ </ul>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
- <xs:element name="clientId">
- <xs:complexType>
- <xs:attribute name="var" type="literalExpression" default="clientId" />
- </xs:complexType>
- </xs:element>
-
+ <xs:complexType name="resource-dependenciesComplexType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:element name="resource-dependency"
+ type="resourceDependencyType">
+
+ <xs:annotation>
+ <xs:documentation>
+ <p>Resource dependency tag. Defines dependent resource for the renderer
+ (see documentation for @ResourceDependency annotation for more information).
+ </p>
+ <p>
+ <span class="warning">Support for this tag is not currently implemented.</span>
+ </p>
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -160,7 +160,6 @@
"<cdk:class>org.richfaces.renderkit.html.TreeRenderer</cdk:class>" +
"<cdk:superclass>org.richfaces.renderkit.TreeRendererBase</cdk:superclass>" +
"<cdk:component-family>org.richfaces.TreeFamily</cdk:component-family>" +
- "<cdk:component-type>org.richfaces.Tree</cdk:component-type>" +
"<cdk:renderer-type>org.richfaces.TreeRenderer</cdk:renderer-type>" +
"<cdk:renderkit-id>RF4_XHTML</cdk:renderkit-id>" +
"<cdk:renders-children>false</cdk:renders-children>" +
@@ -172,7 +171,6 @@
assertEquals("org.richfaces.renderkit.html.TreeRenderer", interfaceSection.getJavaClass());
assertEquals("org.richfaces.renderkit.TreeRendererBase", interfaceSection.getBaseClass());
assertEquals("org.richfaces.TreeFamily", interfaceSection.getComponentFamily());
- assertEquals("org.richfaces.Tree", interfaceSection.getComponentType());
assertEquals("org.richfaces.TreeRenderer", interfaceSection.getRendererType());
assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
assertFalse(interfaceSection.isRendersChildren());
Modified: root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -47,7 +47,7 @@
Map<String,ComponentAttribute> result = new TreeMap<String, ComponentAttribute>();
for (ComponentAttribute componentAttribute : attributes) {
- result.put(componentAttribute.getHtmlAttributeName(), componentAttribute);
+ result.put(componentAttribute.getComponentAttributeName(), componentAttribute);
}
return result;
Modified: root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-30 00:19:36 UTC (rev 16382)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-31 23:27:26 UTC (rev 16383)
@@ -287,7 +287,7 @@
ComponentAttribute knownAttribute = knownAttributesMap.get(attributeName);
if (knownAttribute != null) {
- handledAttributes.add(attributeName);
+ handledAttributes.add(knownAttribute.getHtmlAttributeName());
// TODO check for disabled component
renderAttributeAndBehaviors(context, component, knownAttribute);
@@ -295,8 +295,7 @@
}
// render attributes that haven't been processed yet - there can be behaviors
- for (Map.Entry<String, ComponentAttribute> knownAttributesMapEntry : knownAttributesMap.entrySet()) {
- ComponentAttribute knownAttribute = knownAttributesMapEntry.getValue();
+ for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {
if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
continue;
14 years, 10 months
JBoss Rich Faces SVN: r16382 - in root/cdk/branches/guice/plugins/generator: src/main/java/org/richfaces/cdk and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-29 19:19:36 -0500 (Fri, 29 Jan 2010)
New Revision: 16382
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
Modified:
root/cdk/branches/guice/plugins/generator/pom.xml
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
Log:
https://jira.jboss.org/jira/browse/RF-8288 template compiler converted to dependency injection
Modified: root/cdk/branches/guice/plugins/generator/pom.xml
===================================================================
--- root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-30 00:19:36 UTC (rev 16382)
@@ -202,13 +202,13 @@
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
- </dependency>
+ </dependency><!--
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
- <dependency>
+ --><dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0</version>
@@ -224,11 +224,11 @@
<version>2.0</version>
</dependency>
- <!--
<dependency>
<groupId>com.sun.xsom</groupId>
<artifactId>xsom</artifactId>
</dependency>
+ <!--
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,44 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@Target(ANNOTATION_TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface Implementation {
+ public Class<? extends Annotation> value();
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Implementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
package org.richfaces.cdk;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.model.ComponentLibrary;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -22,10 +22,8 @@
package org.richfaces.cdk;
-import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
import com.google.inject.BindingAnnotation;
@@ -36,7 +34,6 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
-(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
public @interface OutputFolder {
public StandardOutputFolders value();
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -7,6 +7,10 @@
private final StandardOutputFolders value;
+ public OutputFolderImpl(OutputFolder value) {
+ this.value = value.value();
+ }
+
public OutputFolderImpl(StandardOutputFolders value) {
this.value = value;
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -22,11 +22,11 @@
package org.richfaces.cdk;
-import java.lang.annotation.ElementType;
+import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+
import com.google.inject.BindingAnnotation;
/**
@@ -34,9 +34,10 @@
* @version $Id$
*
*/
+@Documented
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
-(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+(a)Implementation(SourceImpl.class)
public @interface Source {
public StandardSources value();
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -7,6 +7,10 @@
private final StandardSources value;
+ public SourceImpl(Source value) {
+ this.value = value.value();
+ }
+
public SourceImpl(StandardSources value) {
this.value = value;
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*/
public enum StandardSources implements SourceType {
- JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES,JAVA_SOURCE_FOLDERS,FACES_CONFIG_FOLDERS,TEMPLATE_FOLDERS;
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
@Override
public String getName() {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -32,7 +32,7 @@
import java.util.Collection;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -29,7 +29,7 @@
import java.util.Arrays;
import javax.annotation.processing.Processor;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.JavaCompiler.CompilationTask;
import org.richfaces.cdk.CdkException;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
import java.lang.annotation.Annotation;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -28,7 +28,7 @@
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -2,7 +2,7 @@
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.NamingConventions;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -29,7 +29,7 @@
import java.util.Collections;
import java.util.Locale;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -42,6 +42,7 @@
import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.OutputFolder;
import org.richfaces.cdk.Source;
@@ -100,11 +101,11 @@
@Inject
@OutputFolder(StandardOutputFolders.JAVA_CLASSES)
- private File outputFolder;
+ private FileManager outputFolder;
@Inject
@Source(StandardSources.JAVA_SOURCES)
- private Iterable<File> sourceFolders;
+ private FileManager sourceFolders;
private JavaCompiler javaCompiler;
@@ -133,11 +134,11 @@
try {
fileManager.setLocation(StandardLocation.CLASS_PATH, classPathLoader.getFiles());
if (null != outputFolder) {
- fileManager.setLocation(StandardLocation.SOURCE_OUTPUT,Collections.singleton(outputFolder));
+ fileManager.setLocation(StandardLocation.SOURCE_OUTPUT,outputFolder.getFolders());
}
- if (null != sourceFolders && sourceFolders.iterator().hasNext()) {
- fileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders);
+ if (null != sourceFolders ) {
+ fileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders.getFolders());
}
} catch (IOException e) {
throw new CdkException("Cannot configure JavaFileManager for compilator",e);
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -34,7 +34,7 @@
import java.util.List;
import java.util.Set;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileManager;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.freemarker;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.Logger;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -30,7 +30,7 @@
import java.io.IOException;
import java.io.Writer;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -27,7 +27,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -24,7 +24,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -39,7 +39,7 @@
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* @author Nick Belaevski
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassConfiguration.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -29,46 +29,30 @@
import java.util.HashMap;
import java.util.Map;
-import org.richfaces.cdk.CdkContext;
-
-import freemarker.ext.beans.BeanModel;
-import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0"></p>
- *
+ * TODO: injection.
* @author asmirnov(a)exadel.com
*/
public class JavaClassConfiguration extends Configuration implements FreeMarkerRenderer {
private static final String TEMPLATES = "/META-INF/templates/java";
- private final CdkContext context;
- public JavaClassConfiguration(CdkContext context) {
- super();
- this.context = context;
+ public JavaClassConfiguration(){
// TODO set proper template loader.
- setClassForTemplateLoading(context.getClass(), TEMPLATES);
+ setClassForTemplateLoading(this.getClass(), TEMPLATES);
// TODO create an object wrapper for library model.
setObjectWrapper(new JavaClassModelWrapper(this));
// Add context variables
- this.setSharedVariable("context", new BeanModel(context, new BeansWrapper()));
+// this.setSharedVariable("context", new BeanModel(context, new BeansWrapper()));
}
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
-
/* (non-Javadoc)
* @see org.richfaces.cdk.templatecompiler.FreeMarkerRenderer#writeSnippet(java.lang.String, java.lang.Object, java.io.Writer)
*/
@@ -100,12 +84,6 @@
} catch (TemplateException e) {
// TODO: handle exception
return e.getMessage();
- } finally {
- try {
- writer.close();
- } catch (IOException e) {
- //do nothing
- }
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -27,91 +27,95 @@
import java.io.IOException;
import java.io.PrintWriter;
+import com.google.inject.Inject;
+
import org.richfaces.builder.model.JavaClass;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.StandardOutputFolders;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassGenerator implements CdkWriter {
- private CdkContext context;
+ private ComponentLibrary library;
+ private FileManager output;
+ private Logger log;
+ private TemplateVisitorFactory<RendererClassVisitor> visitorFactory;
+ private FreeMarkerRenderer renderer;
- /*
- * (non-Javadoc)
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
*
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ * @param library
+ * @param output
+ * @param log
+ * @param visitorFactory
*/
- @Override
- public void init(CdkContext context) {
- this.context = context;
+ @Inject
+ public RendererClassGenerator(ComponentLibrary library,
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES) FileManager output, Logger log,
+ TemplateVisitorFactory<RendererClassVisitor> visitorFactory, FreeMarkerRenderer renderer) {
+ this.library = library;
+ this.output = output;
+ this.log = log;
+ this.visitorFactory = visitorFactory;
+ this.renderer = renderer;
}
/*
* (non-Javadoc)
*
- * @see
- * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
- * )
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary )
*/
@Override
public void render() throws CdkException {
- ComponentLibrary library = context.getLibrary();
for (RenderKitModel renderKit : library.getRenderKits().values()) {
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- RendererClassVisitor visitor = new RendererClassVisitor(
- template.getInterface(), context.getLoader(), context.getWorker(JAXBBinding.class));
+ RendererClassVisitor visitor = visitorFactory.createVisitor(template.getInterface());
try {
// TODO - put real parameters.
- visitor.preProcess();
template.getImplementation().visit(visitor);
- visitor.postProcess();
} finally {
RendererClassVisitor.clearCaches();
}
-
+
JavaClass javaClass = visitor.getGeneratedClass();
String fullName = javaClass.getName();
- File outFile = context.createOutputFile(
- StandardOutputs.RENDERER_CLASSES, fullName.replace(
- '.', '/')
- + ".java", library.lastModified());
+ try {
+ File outFile = output.createFile(fullName.replace('.', '/') + ".java", library.lastModified());
- if (null != outFile) {
- PrintWriter outputWriter = null;
+ if (null != outFile) {
+ PrintWriter outputWriter = null;
- try {
outputWriter = new PrintWriter(outFile);
- JavaClassConfiguration cdkConfiguration = new JavaClassConfiguration(context);
- cdkConfiguration.writeSnippet("class", javaClass, outputWriter);
- } catch (IOException e) {
- throw new CdkException(e);
- } catch (TemplateException e) {
- throw new CdkException(e);
- } finally {
- if (outputWriter != null) {
- outputWriter.close();
- }
+ this.renderer.writeSnippet("class", javaClass, outputWriter);
+ outputWriter.close();
}
+ } catch (IOException e) {
+ throw new CdkException(e);
+ } catch (TemplateException e) {
+ throw new CdkException(e);
}
+ }
- }
}
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -38,7 +38,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.xml.namespace.QName;
import org.richfaces.builder.model.Argument;
@@ -69,10 +69,12 @@
import org.richfaces.cdk.templatecompiler.model.CdkObjectElement;
import org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement;
import org.richfaces.cdk.templatecompiler.model.CdkWhenElement;
+import org.richfaces.cdk.templatecompiler.model.CompositeImplementation;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
import org.richfaces.cdk.util.Strings;
+import org.richfaces.cdk.xmlconfig.JAXB;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import com.google.common.collect.Lists;
@@ -141,11 +143,11 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
- public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader classLoader, JAXBBinding jaxbBinding) {
+ public RendererClassVisitor(CompositeInterface compositeInterface, ClassLoader classLoader, JAXB jaxbBinding, Logger log) {
this.compositeInterface = compositeInterface;
this.classLoader = classLoader;
-
- // TODO - cache unmarshalled data (as CDKWorker?)
+ this.LOG = log;
+ // TODO - cache unmarshalled data (as injection)
SchemaSet schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
this.attributesSchema = schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
}
@@ -714,7 +716,8 @@
/**
*
*/
- public void preProcess() {
+ @Override
+ public void preProcess(CompositeImplementation implementation) {
initializeJavaClass();
passThroughCounter = -1;
}
@@ -722,7 +725,8 @@
/**
*
*/
- public void postProcess() {
+ @Override
+ public void postProcess(CompositeImplementation implementation) {
flushToEncodeMethod("encodeEnd");
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -32,9 +32,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.richfaces.cdk.CdkContext;
+import com.google.inject.Inject;
+
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.Source;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -46,7 +50,7 @@
import org.richfaces.cdk.templatecompiler.model.ClientBehavior;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -64,9 +68,30 @@
private static final Pattern COMMA_SEPARATED_PATTERN = Pattern.compile("\\s*,\\s*", Pattern.COMMENTS);
- private CdkContext context;
+ private ComponentLibrary library;
+
+ private JAXB jaxbBinding;
+
+ private Logger log;
+
+ private FileManager sources;
+
+
- private JAXBBinding jaxbBinding;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param library
+ * @param jaxbBinding
+ * @param log
+ * @param sources
+ */
+ @Inject
+ public RendererTemplateParser(ComponentLibrary library, JAXB jaxbBinding, Logger log, @Source(StandardSources.RENDERER_TEMPLATES) FileManager sources) {
+ this.library = library;
+ this.jaxbBinding = jaxbBinding;
+ this.log = log;
+ this.sources = sources;
+ }
private Set<EventName> convert(Collection<ClientBehavior> clientBehaviors) {
if (clientBehaviors == null || clientBehaviors.isEmpty()) {
@@ -122,7 +147,7 @@
*/
@Override
public void build() throws CdkException {
- Iterable<File> sources = getContext().getSources(StandardSources.RENDERER_TEMPLATES);
+ Iterable<File> sources = this.sources.getFiles();
if (null != sources) {
for (File file : sources) {
Template template = parseTemplate(file);
@@ -132,7 +157,6 @@
}
protected void mergeTemplateIntoModel(Template template) throws CdkException {
- ComponentLibrary library = context.getLibrary();
CompositeInterface compositeInterface = template.getInterface();
// TODO - infer values ?
RenderKitModel renderKit = library.addRenderKit(compositeInterface.getRenderKitId());
@@ -208,13 +232,4 @@
*
* @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
*/
- @Override
- public void init(CdkContext context) {
- this.context = context;
- jaxbBinding = context.getWorker(JAXBBinding.class);
- }
-
- public CdkContext getContext() {
- return context;
- }
}
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface TemplateVisitorFactory <T extends TemplateVisitor> {
+
+ public T createVisitor(CompositeInterface composite);
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler;
+
+import com.google.inject.Inject;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import org.richfaces.cdk.xmlconfig.JAXB;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class VisitorFactoryImpl implements TemplateVisitorFactory<RendererClassVisitor> {
+
+ private CdkClassLoader classLoader;
+ private JAXB jaxbBinding;
+ private Logger log;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param classLoader
+ * @param jaxbBinding
+ * @param log
+ */
+ @Inject
+ public VisitorFactoryImpl(CdkClassLoader classLoader, JAXB jaxbBinding, Logger log) {
+ this.classLoader = classLoader;
+ this.jaxbBinding = jaxbBinding;
+ this.log = log;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.TemplateVisitorFactory#createVisitor(org.richfaces.cdk.templatecompiler.model.CompositeInterface)
+ */
+ @Override
+ public RendererClassVisitor createVisitor(CompositeInterface composite) {
+ return new RendererClassVisitor(composite, classLoader, jaxbBinding,log);
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -27,6 +27,8 @@
import javax.xml.bind.annotation.XmlRootElement;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -36,4 +38,14 @@
public class CompositeImplementation extends ModelFragment implements Serializable {
private static final long serialVersionUID = -3046226976516170979L;
+
+ @Override
+ public void beforeVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.preProcess(this);
+ }
+
+ @Override
+ public void afterVisit(TemplateVisitor visitor) throws CdkException {
+ visitor.postProcess(this);
+ }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/TemplateVisitor.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -66,4 +66,8 @@
void endElement(CdkForEachElement cdkForEachElement);
+ void preProcess(CompositeImplementation compositeImplementation);
+
+ void postProcess(CompositeImplementation compositeImplementation);
+
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -30,9 +30,10 @@
import java.io.InputStream;
import java.net.URI;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.SourceType;
import org.richfaces.cdk.StandardSources;
@@ -94,10 +95,10 @@
@Inject
private CdkClassLoader loader;
- @Inject @Source(StandardSources.FACES_CONFIG_FOLDERS)
- private Iterable<File> facesConfigFolders;
- @Inject @Source(StandardSources.TEMPLATE_FOLDERS)
- private Iterable<File> rendererTemplatesFolders;
+ @Inject @Source(StandardSources.FACES_CONFIGS)
+ private FileManager facesConfigFolders;
+ @Inject @Source(StandardSources.RENDERER_TEMPLATES)
+ private FileManager rendererTemplatesFolders;
/*
* (non-Javadoc)
@@ -223,22 +224,17 @@
return entity;
}
- protected InputSource getProjectInputSource(Iterable<File> folders, String path) throws FileNotFoundException {
+ protected InputSource getProjectInputSource(FileManager folders, String path) throws FileNotFoundException {
InputSource entity = null;
- for (File folder : folders) {
- if (folder.exists() && folder.isDirectory()) {
- File configFile = new File(folder, path);
+ File configFile = folders.getFile(path);
- if (configFile.exists()) {
- InputStream inputStream = new FileInputStream(configFile);
+ if (configFile.exists()) {
+ InputStream inputStream = new FileInputStream(configFile);
- entity = new InputSource(inputStream);
+ entity = new InputSource(inputStream);
- break;
- }
- }
}
return entity;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -27,7 +27,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -25,7 +25,7 @@
import java.io.File;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.ModelBuilder;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -26,7 +26,7 @@
import java.util.Collections;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -39,7 +39,7 @@
import java.net.URISyntaxException;
import java.util.Collection;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -32,7 +32,7 @@
import java.util.HashMap;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
import com.wutka.dtd.DTD;
import com.wutka.dtd.DTDAttribute;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-29 13:12:29 UTC (rev 16381)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -40,7 +40,7 @@
import java.util.HashMap;
import java.util.Map;
-import javax.inject.Inject;
+import com.google.inject.Inject;
/**
* <p class="changed_added_4_0">
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,186 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.easymock.EasyMock;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+import com.google.common.collect.Sets;
+import com.google.inject.AbstractModule;
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
+import com.google.inject.binder.AnnotatedBindingBuilder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CdkTestRunner extends BlockJUnit4ClassRunner {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param klass
+ * @throws InitializationError
+ * @throws InitializationError
+ */
+ public CdkTestRunner(Class<?> klass) throws InitializationError {
+ super(klass);
+ }
+
+ /**
+ * Gets all declared fields and all inherited fields.
+ */
+ protected Set<Field> getFields(Class<?> c) {
+ Set<Field> fields = Sets.newHashSet(c.getDeclaredFields());
+ while ( (c = c.getSuperclass()) != null ) {
+ for ( Field f : c.getDeclaredFields() ) {
+ if ( !Modifier.isStatic(f.getModifiers())
+ && !Modifier.isPrivate(f.getModifiers())
+ ) {
+ fields.add(f);
+ }
+ }
+ }
+ return fields;
+ }
+
+ @Override
+ protected Object createTest() throws Exception {
+ Class<?> c = getTestClass().getJavaClass();
+ Set<Field> testFields = getFields(c);
+
+
+ // make sure we have one (and only one) @Unit field
+// Field unitField = getUnitField(testFields);
+// if ( unitField.getAnnotation(Mock.class) != null ) {
+// throw new IncompatibleAnnotationException(Unit.class, Mock.class);
+// }
+//
+ final Map<Field,Object> fieldValues = getMockValues(testFields);
+// if ( fieldValues.containsKey(unitField)) {
+// throw new IncompatibleAnnotationException(Unit.class, unitField.getType());
+// }
+
+ Object test = createTest(c, fieldValues);
+
+ // any field values created by AtUnit but not injected by the container are injected here.
+ for ( Field field : fieldValues.keySet() ) {
+ field.setAccessible(true);
+ if ( field.get(test) == null ) {
+ field.set(test, fieldValues.get(field));
+ }
+ }
+
+ return test;
+ }
+
+ private Object createTest(Class<?> testClass, Map<Field, Object> fieldValues) throws Exception {
+ FieldModule fields = new FieldModule(fieldValues);
+
+ Injector injector;
+ if ( Module.class.isAssignableFrom(testClass)) {
+ injector = Guice.createInjector(fields, (Module)testClass.newInstance() );
+ } else {
+ injector = Guice.createInjector(fields);
+ }
+ return injector.getInstance(testClass);
+ }
+
+
+ protected class FieldModule extends AbstractModule {
+ final Map<Field,Object> fields;
+
+ public FieldModule(Map<Field,Object> fields) {
+ this.fields = fields;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void configure() {
+
+ // map field values by type
+ for ( Field field : fields.keySet() ) {
+ TypeLiteral literal = TypeLiteral.get(field.getGenericType());
+ AnnotatedBindingBuilder builder = bind(literal);
+ // Check field annotations.
+ Annotation[] fieldAnnotations = field.getAnnotations();
+ for (Annotation annotation : fieldAnnotations) {
+ Class<? extends Annotation> annotationType = annotation.annotationType();
+ if(/*annotationType.isAnnotationPresent(Qualifier.class)||*/ annotationType.isAnnotationPresent(BindingAnnotation.class)){
+ Implementation implementation = annotationType.getAnnotation(Implementation.class);
+ if(null != implementation){
+ try {
+ Annotation value = implementation.value().getConstructor(annotationType).newInstance(annotation);
+ builder.annotatedWith(value);
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ builder.annotatedWith(annotationType);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ builder.annotatedWith(annotationType);
+ }
+ }
+ }
+ builder.toInstance(fields.get(field));
+ }
+ }
+ }
+
+ private Map<Field, Object> getMockValues(Set<Field> testFields) {
+ Map<Field,Object> mocksAndStubs = new HashMap<Field,Object>();
+
+ for ( Field field : testFields ) {
+ if ( field.getAnnotation(Mock.class) != null ) {
+ mocksAndStubs.put(field, EasyMock.createStrictMock(field.getType()));
+ } else if ( field.getAnnotation(Stub.class) != null ) {
+ mocksAndStubs.put(field, EasyMock.createNiceMock(field.getType()));
+ }
+ }
+
+ return mocksAndStubs;
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestRunner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,41 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+/**
+ * <p class="changed_added_4_0">This application should create GraphVis .dot file with Cdk dependencies</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class DependenciesGraph {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/DependenciesGraph.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,40 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface Mock {
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Mock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,28 @@
+package org.richfaces.cdk;
+
+import static org.junit.Assert.*;
+import static org.easymock.EasyMock.*;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+(a)RunWith(CdkTestRunner.class)
+public class RunnerTest {
+
+ @Mock
+ private Logger log;
+
+ @Stub
+ @Source(StandardSources.JAVA_SOURCES)
+ FileManager sources;
+
+
+ @Test
+ public void easyMockInjections() throws Exception {
+ assertNotNull(log);
+ assertNotNull(sources);
+ replay(log,sources);
+ verify(log,sources);
+ }
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/RunnerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java 2010-01-30 00:19:36 UTC (rev 16382)
@@ -0,0 +1,40 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.FIELD})
+public @interface Stub {
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/Stub.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 10 months
JBoss Rich Faces SVN: r16381 - in branches/community/3.3.X/examples/photoalbum/source: ear/src/main/application and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-01-29 08:12:29 -0500 (Fri, 29 Jan 2010)
New Revision: 16381
Added:
branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/
branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/application.xml
branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/jboss-app.xml
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/META-INF/MANIFEST.MF
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/components.properties
branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/META-INF/MANIFEST.MF
Removed:
branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources-filtered/
Modified:
branches/community/3.3.X/examples/photoalbum/source/ear/pom.xml
branches/community/3.3.X/examples/photoalbum/source/ejb/pom.xml
branches/community/3.3.X/examples/photoalbum/source/web/pom.xml
branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/WEB-INF/components.xml
Log:
Fix RF-8331
Modified: branches/community/3.3.X/examples/photoalbum/source/ear/pom.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ear/pom.xml 2010-01-29 01:31:27 UTC (rev 16380)
+++ branches/community/3.3.X/examples/photoalbum/source/ear/pom.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -8,7 +8,7 @@
</parent>
<groupId>org.richfaces.examples</groupId>
- <artifactId>${projectName}-ear</artifactId>
+ <artifactId>photoalbum-ear</artifactId>
<name>${appName} EAR module</name>
<packaging>ear</packaging>
@@ -61,7 +61,7 @@
</dependency>
</dependencies>
<build>
- <finalName>${projectName}-ear-${project.version}</finalName>
+ <finalName>photoalbum-ear</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -78,15 +78,18 @@
<generateApplicationXml>true</generateApplicationXml>
<includeJar>false</includeJar>
<defaultLibBundleDir>lib</defaultLibBundleDir>
+ <version>5</version>
<modules>
<webModule>
<groupId>org.richfaces.examples</groupId>
- <artifactId>${projectName}-web</artifactId>
- <contextRoot>/${projectName}</contextRoot>
+ <artifactId>photoalbum-web</artifactId>
+ <contextRoot>/photoalbum-web</contextRoot>
+ <bundleFileName>photoalbum-web.war</bundleFileName>
</webModule>
<ejbModule>
<groupId>org.richfaces.examples</groupId>
- <artifactId>${projectName}-ejb</artifactId>
+ <artifactId>photoalbum-ejb</artifactId>
+ <bundleFileName>photoalbum-ejb.jar</bundleFileName>
</ejbModule>
<ejbModule>
<groupId>org.jboss.seam</groupId>
Added: branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/application.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/application.xml (rev 0)
+++ branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/application.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
+ <display-name>photoalbum-ear</display-name>
+ <module>
+ <ejb>photoalbum-ejb.jar</ejb>
+ </module>
+ <module>
+ <ejb>jboss-seam-2.1.1.GA.jar</ejb>
+ </module>
+ <module>
+ <web>
+ <web-uri>photoalbum-web.war</web-uri>
+ <context-root>/photoalbum-web</context-root>
+ </web>
+ </module>
+ <library-directory>lib</library-directory>
+</application>
Added: branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/jboss-app.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/jboss-app.xml (rev 0)
+++ branches/community/3.3.X/examples/photoalbum/source/ear/src/main/application/META-INF/jboss-app.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-app
+ PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
+
+<jboss-app>
+ <module-order>strict</module-order>
+ <loader-repository>
+ seam.jboss.org:loader=photoalbum-ear.ear
+ </loader-repository>
+</jboss-app>
Modified: branches/community/3.3.X/examples/photoalbum/source/ejb/pom.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ejb/pom.xml 2010-01-29 01:31:27 UTC (rev 16380)
+++ branches/community/3.3.X/examples/photoalbum/source/ejb/pom.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -10,7 +10,7 @@
</parent>
<groupId>org.richfaces.examples</groupId>
- <artifactId>${projectName}-ejb</artifactId>
+ <artifactId>photoalbum-ejb</artifactId>
<name>${appName} EJB module</name>
<packaging>ejb</packaging>
@@ -89,37 +89,17 @@
<resource>
<directory>src/main/resources</directory>
</resource>
+
<resource>
- <directory>${project.build.directory}/resources-filtered</directory>
- </resource>
- <resource>
<directory>sql/${imageset}</directory>
</resource>
+
</resources>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.3</version>
- <executions>
- <execution>
- <id>copy-resources</id>
- <!-- here the phase you need -->
- <phase>validate</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/resources-filtered</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources-filtered</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
+ <version>2.3</version>
</plugin>
<plugin>
Added: branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/META-INF/MANIFEST.MF
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/META-INF/MANIFEST.MF (rev 0)
+++ branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/META-INF/MANIFEST.MF 2010-01-29 13:12:29 UTC (rev 16381)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/components.properties
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/components.properties (rev 0)
+++ branches/community/3.3.X/examples/photoalbum/source/ejb/src/main/resources/components.properties 2010-01-29 13:12:29 UTC (rev 16381)
@@ -0,0 +1,4 @@
+#
+#Mon Sep 15 14:29:32 EEST 2008
+jndiPattern=photoalbum-ear/#{ejbName}/local
+embeddedEjb=false
Modified: branches/community/3.3.X/examples/photoalbum/source/web/pom.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/web/pom.xml 2010-01-29 01:31:27 UTC (rev 16380)
+++ branches/community/3.3.X/examples/photoalbum/source/web/pom.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -10,7 +10,7 @@
</parent>
<groupId>org.richfaces.examples</groupId>
- <artifactId>${projectName}-web</artifactId>
+ <artifactId>photoalbum-web</artifactId>
<name>${appName} WAR module</name>
<packaging>war</packaging>
Added: branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/META-INF/MANIFEST.MF 2010-01-29 13:12:29 UTC (rev 16381)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Modified: branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/WEB-INF/components.xml
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/WEB-INF/components.xml 2010-01-29 01:31:27 UTC (rev 16380)
+++ branches/community/3.3.X/examples/photoalbum/source/web/src/main/webapp/WEB-INF/components.xml 2010-01-29 13:12:29 UTC (rev 16381)
@@ -10,17 +10,17 @@
xmlns:transaction="http://jboss.com/products/seam/transaction"
xmlns:web="http://jboss.com/products/seam/web"
xsi:schemaLocation=
- "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.0.xsd
- http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.0.xsd
- http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.0.xsd
- http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.0.xsd
- http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.0.xsd
- http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.0.xsd
- http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.0.xsd
- http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.0.xsd
- http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.0.xsd">
+ "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd
+ http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd
+ http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.1.xsd
+ http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd
+ http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
+ http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
+ http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
+ http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
+ http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
- <core:init transaction-management-enabled="false" debug="${environment.debug}" jndi-pattern="@jndiPattern@"/>
+ <core:init transaction-management-enabled="false" debug="true" jndi-pattern="@jndiPattern@"/>
<core:manager concurrent-request-timeout="20000"
conversation-timeout="200000"
conversation-id-parameter="cid"
14 years, 11 months
JBoss Rich Faces SVN: r16380 - in root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk: apt and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-28 20:31:27 -0500 (Thu, 28 Jan 2010)
New Revision: 16380
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.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/SourceFileManager.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/LibraryBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.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/FreeMakerModule.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/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/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/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
Log:
https://jira.jboss.org/jira/browse/RF-8288 all but template compiler converted to dependency injection
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -0,0 +1,45 @@
+/*
+ * $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;
+
+/**
+ * <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 File createFile(String path, long lastModified) throws IOException;
+
+ public abstract Iterable<File> getFolders();
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/FileManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -33,6 +33,8 @@
import org.richfaces.cdk.xmlconfig.XmlModule;
import java.io.File;
+import java.nio.charset.Charset;
+import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
@@ -57,9 +59,14 @@
private Injector injector;
- private Map<StandardOutputFolders, File> outputFolders;
+ private Locale locale = Locale.getDefault();
+
+ private Charset charset = Charset.defaultCharset();
+
+ private Map<StandardOutputFolders, FileManager> outputFolders = Maps.newHashMap();
- private Map<StandardSources, Iterable<File>> sources;
+ private Map<StandardSources,FileManager> sources = Maps.newHashMap();
+
public void setLoader(CdkClassLoader loader) {
this.loader = loader;
@@ -69,10 +76,14 @@
this.log = log;
}
- public void setOutputFolders(Map<StandardOutputFolders, File> outputFolders) {
- this.outputFolders = outputFolders;
+ 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 init(){
checkNotNull(loader, "classLoader");
injector = Guice.createInjector(new CdkConfigurationModule(),new AptModule(),new ModelModule(),
@@ -90,11 +101,13 @@
protected void configure() {
bind(CdkClassLoader.class).toInstance(loader);
bind(Logger.class).toInstance(log);
- for (Map.Entry<StandardOutputFolders, File> entry : outputFolders.entrySet()) {
- bind(File.class).annotatedWith(new OutputFolderImpl(entry.getKey())).toInstance(entry.getValue());
+ 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, Iterable<File>> entry : sources.entrySet()) {
- bind(new TypeLiteral<Iterable<File>>(){}).annotatedWith(new SourceImpl(entry.getKey())).toInstance(entry.getValue());
+ for (Map.Entry<StandardSources, FileManager> entry : sources.entrySet()) {
+ bind(FileManager.class).annotatedWith(new SourceImpl(entry.getKey())).toInstance(entry.getValue());
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -82,7 +82,7 @@
builder.build();
}
- getValidator().verify(library);
+ getValidator().verify();
generate();
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -23,7 +23,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.model.ComponentLibrary;
/**
* <p class="changed_added_4_0">Interface for CDK library model verifier.</p>
@@ -38,5 +37,5 @@
* @param library
* @throws CdkException
*/
- public void verify(ComponentLibrary library) throws CdkException;
+ public void verify() throws CdkException;
}
Added: 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 (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -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.IOException;
+import java.util.Collections;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <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 File createFile(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 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;
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFileManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -0,0 +1,103 @@
+/*
+ * $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;
+
+/**
+ * <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 File createFile(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;
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceFileManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*/
public enum StandardSources implements SourceType {
- JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES,JAVA_SOURCE_FOLDERS,FACES_CONFIG_FOLDERS,TEMPLATE_FOLDERS;
@Override
public String getName() {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -50,7 +50,6 @@
@Inject
public ValidatorImpl(ComponentLibrary library, NamingConventions namingConventions) {
this.library = library;
- // TODO Auto-generated constructor stub
this.namingConventions = namingConventions;
}
/*
@@ -58,9 +57,9 @@
* @see org.richfaces.cdk.ValidatorModel#verify(org.richfaces.cdk.model.ComponentLibrary)
*/
@Override
- public void verify(ComponentLibrary library) throws CdkException {
+ public void verify() throws CdkException {
verifyRenderers();
- verifyComponents(library);
+ verifyComponents();
// After all, merge all similar elements.
compact(library.getComponents());
@@ -82,8 +81,7 @@
}
}
- protected void verifyComponents(ComponentLibrary library) throws CdkException {
- NamingConventions namingConventions = getNamingConventions();
+ protected void verifyComponents() throws CdkException {
for (ComponentModel component : library.getComponents()) {
@@ -101,10 +99,6 @@
}
}
- private NamingConventions getNamingConventions() throws CdkException {
- return namingConventions;
- }
-
protected void compact(Collection<?> collection) {
// if (collection instanceof ModelCollection) {
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -25,18 +25,20 @@
import java.lang.annotation.Annotation;
+import javax.inject.Inject;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.CdkWorker;
+import org.richfaces.cdk.xmlconfig.FragmentParser;
/**
* <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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -28,20 +28,17 @@
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
+import javax.inject.Inject;
import javax.lang.model.SourceVersion;
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.CdkWriter;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.OutputType;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
-import com.google.common.collect.ImmutableList;
-
/**
* <p class="changed_added_4_0">
* Base class for all CDK Annotation processors. That class provides access to current CDK context and utility methods
@@ -51,70 +48,61 @@
* @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 Iterable<CdkAnnotationProcessor> processors;
- /**
- * <p class="changed_added_4_0">
- * CDK context.
- * </p>
- */
- private CdkContext context;
+ @Inject
+ private Iterable<ModelBuilder> builders;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- * current CDK context
- * @throws CdkException
- */
- @Override
- public void init(CdkContext context) throws CdkException {
- this.context = context;
- }
+ @Inject
+ private Iterable<CdkWriter> generators;
+
+ @Inject
+ private SourceUtils sourceUtils;
+
+ @Inject
+ private ModelValidator validator;
+
+
@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);
+ sourceUtils.setup(this.processingEnv, roundEnv);
if (!roundEnv.processingOver()) {
// Process annotations.
- for (Class<? extends CdkAnnotationProcessor> process : PROCESSORS) {
+ for (CdkAnnotationProcessor process : processors) {
processAnnotation(process);
}
// 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()) {
+ for (ModelBuilder builder : builders) {
+ builder.build();
+ }
+ validator.verify();
+ } else if (0 == log.getErrorCount()) {
// processing over, generate files.
- for (OutputType type : StandardOutputs.values()) {
- getContext().getGeneratorFor(type).render();
+ for (CdkWriter generator : generators) {
+ generator.render();
}
}
- getContext().setWorker(SourceUtils.class, null);
+ sourceUtils.release();
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());
+ protected void processAnnotation(CdkAnnotationProcessor processor) {
+ Set<? extends TypeElement> annotatedWith = sourceUtils
+ .getClassesAnnotatedWith(processor.getProcessedAnnotation());
for (TypeElement typeElement : annotatedWith) {
try {
- cdkAnnotationProcessor.process(typeElement);
+ processor.process(typeElement);
} catch (CdkProcessingException e) {
sendError(typeElement, e);
}
@@ -124,19 +112,8 @@
protected void sendError(TypeElement 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;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -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;
@@ -79,6 +78,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 +102,6 @@
return explicitType;
}
- private NamingConventions getNamingConventions() {
- return getContext().getWorker(NamingConventions.class);
- }
private void setComponentProperties(TypeElement componentElement, ComponentModel component)
@@ -124,7 +121,7 @@
}
private void processFacets(TypeElement componentElement, ComponentModel component) {
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
+ SourceUtils sourceUtils = getSourceUtils();
Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
// TODO - encapsulate attribute builder into utility class.
@@ -176,7 +173,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(componentElement, "COMPONENT_FAMILY");
if (null != value) {
component.setFamily(value.toString());
}
@@ -240,7 +237,7 @@
}
}
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
+ SourceUtils sourceUtils = getSourceUtils();
sourceUtils.visitSupertypes(componentElement.asType(), new SuperTypeVisitor() {
@Override
@@ -342,10 +339,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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -1,20 +1,60 @@
package org.richfaces.cdk.apt;
+import java.util.Map;
+
+import javax.inject.Inject;
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.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 {
+public class ProcessorBase {
- private CdkContext context;
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ private 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;
+ }
+
+ /**
+ * <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,25 +73,13 @@
}
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));
@@ -68,4 +96,8 @@
}
}
+ protected Map<String, Property> parseProperties(String attributesConfig) {
+ return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES +attributesConfig+".xml");
+ }
+
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -22,13 +22,11 @@
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;
@@ -38,8 +36,6 @@
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,11 +69,6 @@
return componentElement.getAnnotation(Component.class).value();
}
- private NamingConventions getNamingConventions() {
- return getContext().getWorker(NamingConventions.class);
- }
-
-
private void setRendererProperties(TypeElement componentElement, RendererModel renderer)
throws CdkException {
@@ -96,7 +87,7 @@
private void setRendererDescription(TypeElement componentElement, RendererModel component) {
- SourceUtils sourceUtils = getContext().getWorker(SourceUtils.class);
+ SourceUtils sourceUtils = getSourceUtils();
// JavaDoc comments
component.setDescription(sourceUtils.getDocComment(componentElement));
@@ -122,7 +113,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(rendererElement, "COMPONENT_FAMILY");
if (null != value) {
renderer.setFamily(value.toString());
}
@@ -170,10 +161,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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -39,8 +39,6 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkWorker;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
@@ -52,7 +50,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class SourceUtils implements CdkWorker {
+public class SourceUtils {
@@ -66,22 +64,22 @@
}
- private CdkContext context;
- private final ProcessingEnvironment processingEnv;
- private final RoundEnvironment roundEnvironment;
+ private ProcessingEnvironment processingEnv;
+ private RoundEnvironment roundEnvironment;
- public SourceUtils(ProcessingEnvironment processingEnv, RoundEnvironment roundEnv) {
+ public void setup(ProcessingEnvironment processingEnv, RoundEnvironment roundEnv) {
this.processingEnv = processingEnv;
this.roundEnvironment = roundEnv;
}
+ public void release() {
+ this.processingEnv = null;
+ this.roundEnvironment = null;
+ }
+
/* (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.
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -23,10 +23,12 @@
package org.richfaces.cdk.freemarker;
-import freemarker.ext.beans.BeanModel;
-import freemarker.ext.beans.BeansWrapper;
+import javax.inject.Inject;
+
+import org.richfaces.cdk.Logger;
+
import freemarker.template.Configuration;
-import org.richfaces.cdk.CdkContext;
+import freemarker.template.ObjectWrapper;
/**
* <p class="changed_added_4_0"></p>
@@ -34,21 +36,22 @@
* @author asmirnov(a)exadel.com
*/
public class CdkConfiguration extends Configuration {
+
private static final String TEMPLATES = "/META-INF/templates";
- private final CdkContext context;
+ private final 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 +59,4 @@
*
* @return the context
*/
- protected CdkContext getContext() {
- return context;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -25,6 +25,9 @@
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
@@ -37,8 +40,8 @@
*/
@Override
protected void configure() {
- // TODO Auto-generated method stub
-
+ bind(Configuration.class).to(CdkConfiguration.class);
+ bind(ObjectWrapper.class).to(LibraryModelWrapper.class);
}
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -25,21 +25,27 @@
package org.richfaces.cdk.freemarker;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.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 java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
+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>
@@ -47,15 +53,21 @@
*
*/
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 +77,7 @@
@Override
public void render() throws CdkException {
- context.getLibrary().accept(this, getVisitorParameter());
+ library.accept(this, getVisitorParameter());
}
private P getVisitorParameter() {
@@ -109,9 +121,8 @@
lastModified = trackuble.lastModified();
}
- File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c), lastModified);
-
try {
+ File sourceOutput = output.createFile(getOutputFile(c), lastModified);
return new FileWriter(sourceOutput);
} catch (IOException e) {
throw new CdkException(e);
@@ -123,14 +134,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/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-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -37,6 +37,7 @@
*
*/
public class LibraryModelWrapper extends BeansWrapper implements ObjectWrapper {
+
public LibraryModelWrapper() {
super();
setStrict(true);
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -22,14 +22,21 @@
package org.richfaces.cdk.freemarker;
+import java.io.File;
+
+import javax.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 java.io.File;
+import freemarker.template.Configuration;
/**
* @author akolonitsky
@@ -37,6 +44,11 @@
*/
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 +63,4 @@
protected String getTemplateName() {
return "taglib/validator.ftl";
}
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.TAG_LIBRARY;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -22,17 +22,21 @@
package org.richfaces.cdk.generate.java;
+import java.io.File;
+
+import javax.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.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.OutputType;
-import org.richfaces.cdk.StandardOutputs;
-import java.io.File;
+import freemarker.template.Configuration;
/**
* @author akolonitsky
@@ -44,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
@@ -68,8 +72,4 @@
return "behavior.ftl";
}
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.BEHAVIOR_CLASSES;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -25,17 +25,21 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
+import javax.inject.Inject;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.OutputType;
-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.ComponentModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Visitable;
-import java.io.File;
+import freemarker.template.Configuration;
/**
* <p class="changed_added_4_0"></p>
@@ -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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -22,28 +22,33 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
+import javax.inject.Inject;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.OutputType;
-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 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
protected boolean isMyComponent(Visitable visitable) {
if (visitable instanceof ConverterModel) {
@@ -62,9 +67,4 @@
protected String getTemplateName() {
return "converter.ftl";
}
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.CONVERTER_CLASSES;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -22,26 +22,33 @@
package org.richfaces.cdk.generate.java;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
+import javax.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 java.io.File;
+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
@@ -62,9 +69,4 @@
protected String getTemplateName() {
return "validator.ftl";
}
-
- @Override
- protected OutputType getOutputType() {
- return StandardOutputs.VALIDATOR_CLASSES;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -38,6 +38,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
+import javax.inject.Inject;
import javax.xml.namespace.QName;
import org.richfaces.builder.model.Argument;
@@ -49,7 +50,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;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -23,14 +23,6 @@
package org.richfaces.cdk.xmlconfig;
-import com.google.common.collect.ImmutableMap;
-import org.richfaces.cdk.CdkContext;
-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 java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -38,6 +30,18 @@
import java.io.InputStream;
import java.net.URI;
+import javax.inject.Inject;
+
+import org.richfaces.cdk.CdkClassLoader;
+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;
+
/**
* <p class="changed_added_4_0">
* That class resolves entities used by CDK ( standard JSF schemas, extensions,
@@ -87,11 +91,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_CONFIG_FOLDERS)
+ private Iterable<File> facesConfigFolders;
+ @Inject @Source(StandardSources.TEMPLATE_FOLDERS)
+ private Iterable<File> rendererTemplatesFolders;
/*
* (non-Javadoc)
@@ -178,7 +184,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 +195,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 +207,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,8 +223,8 @@
return entity;
}
- protected InputSource getProjectInputSource(SourceType type, String path) throws FileNotFoundException {
- Iterable<File> folders = getContext().getSourceFolders(type);
+ protected InputSource getProjectInputSource(Iterable<File> folders, String path) throws FileNotFoundException {
+
InputSource entity = null;
for (File folder : folders) {
@@ -238,13 +244,4 @@
return entity;
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -27,9 +27,13 @@
import java.io.File;
-import org.richfaces.cdk.CdkContext;
+import javax.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;
@@ -47,19 +51,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 +74,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 {
+ File facesConfigXml = outputFileManager.createFile(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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -23,16 +23,18 @@
package org.richfaces.cdk.xmlconfig;
-import org.richfaces.cdk.CdkContext;
+import java.io.File;
+
+import javax.inject.Inject;
+
import org.richfaces.cdk.CdkException;
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;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -44,18 +46,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 Iterable<File> configFiles;
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the context
- */
- public CdkContext getContext() {
- return context;
- }
/*
* (non-Javadoc)
@@ -64,11 +61,9 @@
*/
@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) {
+
+ if (null != configFiles) {
+ for (File file : configFiles) {
FacesConfigBean unmarshal = unmarshalFacesConfig(file);
if (null != unmarshal) {
ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
@@ -90,15 +85,4 @@
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/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -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 javax.inject.Inject;
+
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;
/**
* <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);
- }
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-28 22:28:32 UTC (rev 16379)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-29 01:31:27 UTC (rev 16380)
@@ -39,6 +39,7 @@
import java.net.URISyntaxException;
import java.util.Collection;
+import javax.inject.Inject;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
@@ -51,14 +52,13 @@
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;
@@ -70,12 +70,12 @@
* @author asmirnov(a)exadel.com
*
*/
-public class JAXBBinding implements CdkWorker, JAXB {
+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,10 +85,6 @@
*
* @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)
@@ -112,7 +108,12 @@
*/
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);
@@ -121,7 +122,7 @@
T unmarshal = unmarshal(schemaLocation, bindClass, inputSource);
return unmarshal;
- } catch (FileNotFoundException e) {
+ } catch (IOException e) {
throw new CdkException("XML file not found", e);
}
}
14 years, 11 months
JBoss Rich Faces SVN: r16379 - root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-01-28 17:28:32 -0500 (Thu, 28 Jan 2010)
New Revision: 16379
Modified:
root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
Log:
Unit test failure fixed
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-01-28 19:40:06 UTC (rev 16378)
+++ root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-01-28 22:28:32 UTC (rev 16379)
@@ -143,7 +143,7 @@
assertEquals("img", restoredImgElement.getName());
assertEquals("img", restoredImgElement.getKey());
Map<String, Attribute> restoredImgAttributes = restoredImgElement.getAttributes();
- assertEquals(3, restoredImgAttributes.size());
+ assertEquals(4, restoredImgAttributes.size());
Attribute restoredAltAttribute = restoredImgAttributes.get("alt");
assertNotNull(restoredAltAttribute);
14 years, 11 months
JBoss Rich Faces SVN: r16378 - in root/cdk/branches/guice/plugins/generator: src/main/java/org/richfaces/cdk/parser/el and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-28 14:40:06 -0500 (Thu, 28 Jan 2010)
New Revision: 16378
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java
root/cdk/branches/guice/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml
root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml
Modified:
root/cdk/branches/guice/plugins/generator/
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.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/model/CompositeInterface.java
root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
root/cdk/branches/guice/plugins/generator/src/main/script/SchemaProcessor.groovy
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml
Log:
merge with 16377 from trunk
Property changes on: root/cdk/branches/guice/plugins/generator
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -56,7 +56,6 @@
public static final String LEFT_SQUARE_BRACKET = "[";
public static final String NEGATIVE = "-";
public static final String QUESTION_SIGN = " ? ";
- public static final String QUOTE = "\"";
public static final String RIGHT_BRACKET = ")";
public static final String RIGHT_SQUARE_BRACKET = "]";
public static final String THIS_PREFIX = "this";
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -53,6 +53,7 @@
public static String getEscapedString(String s) {
StringBuilder result = new StringBuilder();
+ result.append('"');
char[] chars = s.toCharArray();
@@ -80,9 +81,29 @@
}
}
+ result.append('"');
+
return result.toString();
}
+ public static String getEscapedStringsArray(String... strings) {
+ StringBuilder sb = new StringBuilder();
+
+ for (String string : strings) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(getEscapedString(string));
+ }
+
+ return sb.toString();
+ }
+
+ public static boolean isEmpty(String s) {
+ return s == null || s.length() == 0;
+ }
+
/**
* Returns true if the char isalpha() or isdigit().
*/
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -26,7 +26,6 @@
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.StringUtils;
@@ -47,9 +46,7 @@
@Override
public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
if (getNode().getImage() != null) {
- sb.append(ELNodeConstants.QUOTE);
sb.append(StringUtils.getEscapedString(getNode().getImage()));
- sb.append(ELNodeConstants.QUOTE);
visitor.setVariableType(TypesFactory.getType(String.class));
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -27,7 +27,6 @@
import org.jboss.el.parser.AstString;
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.StringUtils;
@@ -47,9 +46,7 @@
@Override
public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
- sb.append(ELNodeConstants.QUOTE);
sb.append(StringUtils.getEscapedString(((AstString) getNode()).getString()));
- sb.append(ELNodeConstants.QUOTE);
visitor.setVariableType(TypesFactory.getType(String.class));
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -23,6 +23,23 @@
package org.richfaces.cdk.templatecompiler;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+import javax.xml.namespace.QName;
+
import org.richfaces.builder.model.Argument;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.model.JavaField;
@@ -32,6 +49,7 @@
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;
@@ -57,23 +75,6 @@
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.annotation.Generated;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import javax.inject.Inject;
-import javax.xml.namespace.QName;
-
import com.google.common.collect.Lists;
/**
@@ -144,7 +145,7 @@
this.compositeInterface = compositeInterface;
this.classLoader = classLoader;
- //TODO - cache unmarshalled data
+ // 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);
}
@@ -158,9 +159,10 @@
this.generatedClass.addImport(ResponseWriter.class);
this.generatedClass.addImport(UIComponent.class);
- this.generatedClass.addAnnotation(Generated.class, "\"RichFaces CDK\"");
+ // TODO - make this JavaDoc - Generated annotation is present since JDK6
+ // this.generatedClass.addAnnotation(Generated.class, "\"RichFaces CDK\"");
// TODO remove this after improving Java model
- this.generatedClass.addImport(Generated.class);
+ // this.generatedClass.addImport(Generated.class);
this.createMethodContext();
}
@@ -260,37 +262,33 @@
return result;
}
- private String createPassThroughAttributeCode(String attributeName, String[] eventNames) {
+ private String createPassThroughAttributeCode(String htmlAttributeName, Attribute componentAttribute,
+ String[] eventNames) {
+
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
StringBuilder sb = new StringBuilder();
sb.append("new ComponentAttribute(");
- sb.append('"');
- sb.append(StringUtils.getEscapedString(attributeName));
- sb.append('"');
+ sb.append(StringUtils.getEscapedString(htmlAttributeName));
- boolean isFirstEventName = true;
+ sb.append(")");
+
+ String componentAttributeName = componentAttribute.getComponentAttributeName();
+ if (!StringUtils.isEmpty(componentAttributeName)) {
+ sb.append(".setComponentAttributeName(");
+ sb.append(StringUtils.getEscapedString(componentAttributeName));
+ sb.append(")");
+ }
+
if (eventNames != null && eventNames.length != 0) {
- sb.append(", ");
+ sb.append(".setEventNames(");
sb.append("new String[] {");
- for (String eventName : eventNames) {
- if (isFirstEventName) {
- isFirstEventName = false;
- } else {
- sb.append(", ");
- }
+ sb.append(StringUtils.getEscapedStringsArray(eventNames));
- sb.append('"');
- sb.append(StringUtils.getEscapedString(eventName));
- sb.append('"');
- }
-
- sb.append("}");
+ sb.append("})");
}
-
- sb.append(")");
return sb.toString();
}
@@ -310,12 +308,13 @@
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
-
- //TODO - get rid of FQNs for classes via imports
+ generatedClass.addImport(Collections.class);
+
+ // TODO - get rid of FQNs for classes via imports
passThroughField.setGenericArguments(new JavaClass[] { new JavaClass(String.class),
new JavaClass("org.richfaces.renderkit.ComponentAttribute") });
- StringBuilder fieldValue = new StringBuilder("ComponentAttribute.createMap(");
+ StringBuilder fieldValue = new StringBuilder("Collections.unmodifiableMap(ComponentAttribute.createMap(");
boolean isFirstArgument = true;
for (Map.Entry<String, Attribute> entry : attributesMap.entrySet()) {
if (isFirstArgument) {
@@ -325,13 +324,13 @@
}
// TODO behaviors data
- fieldValue.append(createPassThroughAttributeCode(entry.getKey(), null));
+ fieldValue.append(createPassThroughAttributeCode(entry.getKey(), entry.getValue(), null));
}
- fieldValue.append(")");
-
+ fieldValue.append("))");
+
passThroughField.setValue(fieldValue.toString());
-
+
return passThroughField;
}
@@ -470,7 +469,7 @@
} else {
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
- //TODO externalize
+ // TODO externalize
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
currentStatement.addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
attributeValue.toString(), String.class)));
@@ -498,7 +497,7 @@
if (!actualAttributesMap.isEmpty()) {
JavaField passThroughField = createPassThroughField(actualAttributesMap);
generatedClass.addField(passThroughField);
- //TODO externalize
+ // TODO externalize
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
currentStatement.addStatement(new WriteAttributesSetStatement(passThroughField.getName()));
}
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -49,6 +49,8 @@
private List<ResourceDependency> resourceDependencies;
+ private List<ImportAttributes> attributesImports;
+
private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
private String javaClass;
@@ -230,4 +232,24 @@
public void setRendersChildren(boolean rendersChildren) {
this.rendersChildren = rendersChildren;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the attributesImports
+ */
+ @XmlElement(name = "import-attributes", namespace = Template.CDK_NAMESPACE)
+ public List<ImportAttributes> getAttributesImports() {
+ return attributesImports;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param attributesImports the attributesImports to set
+ */
+ public void setAttributesImports(List<ImportAttributes> attributesImports) {
+ this.attributesImports = attributesImports;
+ }
+
}
Copied: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java (from rev 16377, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java)
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -0,0 +1,49 @@
+/*
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ImportAttributes {
+
+ private String source;
+
+ /**
+ * @return the source
+ */
+ @XmlAttribute(name = "src")
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * @param source the source to set
+ */
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+}
Modified: root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-28 19:40:06 UTC (rev 16378)
@@ -111,6 +111,12 @@
<xs:element name="component-family" />
<xs:element name="renderer-type" />
<xs:element name="renders-children" type="xs:boolean" />
+
+ <xs:element name="import-attributes">
+ <xs:complexType>
+ <xs:attribute use="required" name="src" type="xs:anyURI" form="unqualified" />
+ </xs:complexType>
+ </xs:element>
<xs:group name="structural">
<xs:choice>
Modified: root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-01-28 19:40:06 UTC (rev 16378)
@@ -468,6 +468,14 @@
</xs:documentation>
</xs:annotation>
+ <xs:attribute name="class" type="NMTOKENS">
+ <xs:annotation>
+ <xs:appinfo>
+ <cdk-addinfo:component-attribute-name>styleClass</cdk-addinfo:component-attribute-name>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:attribute>
+
<xs:attributeGroup name="coreattrs">
<xs:annotation>
<xs:documentation>
@@ -481,7 +489,7 @@
</xs:documentation>
</xs:annotation>
<xs:attribute name="id" type="ID" />
- <xs:attribute name="class" type="NMTOKENS" />
+ <xs:attribute ref="class" />
<xs:attribute name="style" type="StyleSheet" />
<xs:attribute name="title" type="Text" />
</xs:attributeGroup>
@@ -3026,11 +3034,11 @@
<xs:group ref="map.children" />
<xs:attributeGroup ref="i18n"></xs:attributeGroup>
<xs:attributeGroup ref="events"></xs:attributeGroup>
- <xs:attribute use="required" name="id" type="ID"></xs:attribute>
- <xs:attribute name="class" type="xs:anySimpleType"></xs:attribute>
- <xs:attribute name="style" type="StyleSheet"></xs:attribute>
- <xs:attribute name="title" type="Text"></xs:attribute>
- <xs:attribute name="name" type="xs:anySimpleType"></xs:attribute>
+ <xs:attribute use="required" name="id" type="ID" />
+ <xs:attribute ref="class" />
+ <xs:attribute name="style" type="StyleSheet" />
+ <xs:attribute name="title" type="Text" />
+ <xs:attribute name="name" type="xs:anySimpleType" />
<xs:attributeGroup ref="cdk:core.attrs" />
</xs:complexType>
Modified: root/cdk/branches/guice/plugins/generator/src/main/script/SchemaProcessor.groovy
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/script/SchemaProcessor.groovy 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/main/script/SchemaProcessor.groovy 2010-01-28 19:40:06 UTC (rev 16378)
@@ -64,7 +64,7 @@
return xPath;
}
- private String getDefaultValue(XSAttributeUse attributeUse) throws XPathExpressionException {
+ private String getAdditionalInfo(XSAttributeUse attributeUse, String elementName) throws XPathExpressionException {
String defaultValue = null;
XSAttributeDecl attributeDecl = attributeUse.getDecl();
@@ -73,7 +73,7 @@
Object annotationElement = annotation.getAnnotation();
if (annotationElement != null) {
XPath xPath = createXPath();
- Node node = (Node) xPath.evaluate("xs:appinfo/cdk-schema-info:default-value", annotationElement,
+ Node node = (Node) xPath.evaluate("xs:appinfo/cdk-schema-info:" + elementName, annotationElement,
XPathConstants.NODE);
if (node != null) {
defaultValue = xPath.evaluate("text()", node);
@@ -84,6 +84,14 @@
return defaultValue;
}
+ private String getComponentAttributeName(XSAttributeUse attributeUse) throws XPathExpressionException {
+ return getAdditionalInfo(attributeUse, "component-attribute-name");
+ }
+
+ private String getDefaultValue(XSAttributeUse attributeUse) throws XPathExpressionException {
+ return getAdditionalInfo(attributeUse, "default-value");
+ }
+
private boolean isGenericKind(Attribute.Kind attributeKind) {
return Kind.GENERIC.equals(attributeKind);
}
@@ -173,6 +181,7 @@
modelAttribute.setKind(getAttributeKind(attributeDecl.getType()));
modelAttribute.setRequired(xsAttributeUse.isRequired());
modelAttribute.setDefaultValue(getDefaultValue(xsAttributeUse));
+ modelAttribute.setComponentAttributeName(getComponentAttributeName(xsAttributeUse));
}
}
}
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-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-01-28 19:40:06 UTC (rev 16378)
@@ -234,6 +234,15 @@
assertEquals("Required Attribute", requiredAttribute.getDisplayname());
}
+ private void checkDummyComponentImportedAttribute(Property importedAttribute, Class<?> type) {
+ assertNotNull(importedAttribute);
+ assertNoEventNames(importedAttribute);
+ assertNoSignature(importedAttribute);
+ assertNoDefaultValue(importedAttribute);
+ assertFalse(importedAttribute.isRequired());
+
+ assertEquals(type.getName(), importedAttribute.getType().getName());
+ }
@Before
@@ -290,7 +299,12 @@
checkDummyComponentIntegerAttribute(attributes.get("integerAttribute"));
checkDummyComponentRequiredAttribute(attributes.get("requiredAttribute"));
- assertEquals(7, attributes.size());
+ checkDummyComponentImportedAttribute(attributes.get("anotherImportedStringProperty"), String.class);
+ checkDummyComponentImportedAttribute(attributes.get("anotherImportedProperty"), Object.class);
+ checkDummyComponentImportedAttribute(attributes.get("importedBooleanProperty"), boolean.class);
+ checkDummyComponentImportedAttribute(attributes.get("importedIntegerProperty"), Integer.class);
+
+ assertEquals(11, attributes.size());
}
}
Copied: root/cdk/branches/guice/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml (from rev 16377, root/cdk/trunk/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml)
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml 2010-01-28 19:40:06 UTC (rev 16378)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+-->
+<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <property>
+ <property-name>importedBooleanProperty</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <property-name>importedIntegerProperty</property-name>
+ <property-class>java.lang.Integer</property-class>
+ </property>
+
+</cdk:properties>
\ No newline at end of file
Copied: root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml (from rev 16377, root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml)
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml 2010-01-28 19:40:06 UTC (rev 16378)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+-->
+<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <property>
+ <property-name>anotherImportedStringProperty</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>anotherImportedProperty</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+
+</cdk:properties>
\ No newline at end of file
Modified: root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml 2010-01-28 19:07:27 UTC (rev 16377)
+++ root/cdk/branches/guice/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml 2010-01-28 19:40:06 UTC (rev 16378)
@@ -28,6 +28,9 @@
<cc:attribute name="integerAttribute" type="java.lang.Integer" default="-1" />
<cc:attribute name="requiredAttribute" shortDescription="That's a required attribute"
displayName="Required Attribute" required="true" />
+
+ <cdk:import-attributes src="urn:resource:org/richfaces/cdk/templatecompiler/dummy-attributes.xml" />
+ <cdk:import-attributes src="urn:attributes:dummy-template-props.xml" />
</cc:interface>
<cc:implementation />
14 years, 11 months
JBoss Rich Faces SVN: r16377 - in root: cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-01-28 14:07:27 -0500 (Thu, 28 Jan 2010)
New Revision: 16377
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java
root/cdk/trunk/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml
Modified:
root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java
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/StringUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.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/CompositeInterface.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
root/cdk/trunk/plugins/generator/src/main/script/SchemaProcessor.groovy
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Log:
https://jira.jboss.org/jira/browse/RF-8309
https://jira.jboss.org/jira/browse/RF-8325
https://jira.jboss.org/jira/browse/RF-7732
Modified: root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/attributes/src/main/java/org/richfaces/cdk/attributes/Attribute.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -61,6 +61,8 @@
private String defaultValue;
+ private String componentAttributeName;
+
private Kind kind = Kind.GENERIC;
public Attribute() {
@@ -137,6 +139,21 @@
this.kind = kind;
}
+ /**
+ * @return the componentAttributeName
+ */
+ @XmlElement(name = "component-attribute-name")
+ public String getComponentAttributeName() {
+ return componentAttributeName;
+ }
+
+ /**
+ * @param componentAttributeName the componentAttributeName to set
+ */
+ public void setComponentAttributeName(String componentAttributeName) {
+ this.componentAttributeName = componentAttributeName;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
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-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/attributes/src/test/java/org/richfaces/cdk/attributes/AttributesTest.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -94,6 +94,10 @@
Attribute dirAttribute = new Attribute("dir");
dirAttribute.setDefaultValue("ltr");
imgElement.addAttribute(dirAttribute);
+
+ Attribute classAttribute = new Attribute("class");
+ classAttribute.setComponentAttributeName("styleClass");
+ imgElement.addAttribute(classAttribute);
}
public void tearDown() {
@@ -155,5 +159,10 @@
assertNotNull(restoredDirAttribute);
assertEquals("dir", restoredDirAttribute.getName());
assertEquals("ltr", restoredDirAttribute.getDefaultValue());
+
+ Attribute restoredClassAttribute = restoredImgAttributes.get("class");
+ assertNotNull(restoredClassAttribute);
+ assertEquals("class", restoredClassAttribute.getName());
+ assertEquals("styleClass", restoredClassAttribute.getComponentAttributeName());
}
}
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-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/ELNodeConstants.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -56,7 +56,6 @@
public static final String LEFT_SQUARE_BRACKET = "[";
public static final String NEGATIVE = "-";
public static final String QUESTION_SIGN = " ? ";
- public static final String QUOTE = "\"";
public static final String RIGHT_BRACKET = ")";
public static final String RIGHT_SQUARE_BRACKET = "]";
public static final String THIS_PREFIX = "this";
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/StringUtils.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -53,6 +53,7 @@
public static String getEscapedString(String s) {
StringBuilder result = new StringBuilder();
+ result.append('"');
char[] chars = s.toCharArray();
@@ -80,9 +81,29 @@
}
}
+ result.append('"');
+
return result.toString();
}
+ public static String getEscapedStringsArray(String... strings) {
+ StringBuilder sb = new StringBuilder();
+
+ for (String string : strings) {
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+
+ sb.append(getEscapedString(string));
+ }
+
+ return sb.toString();
+ }
+
+ public static boolean isEmpty(String s) {
+ return s == null || s.length() == 0;
+ }
+
/**
* Returns true if the char isalpha() or isdigit().
*/
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstLiteralTreeNode.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -26,7 +26,6 @@
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.StringUtils;
@@ -47,9 +46,7 @@
@Override
public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
if (getNode().getImage() != null) {
- sb.append(ELNodeConstants.QUOTE);
sb.append(StringUtils.getEscapedString(getNode().getImage()));
- sb.append(ELNodeConstants.QUOTE);
visitor.setVariableType(TypesFactory.getType(String.class));
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/node/AstStringTreeNode.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -27,7 +27,6 @@
import org.jboss.el.parser.AstString;
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.StringUtils;
@@ -47,9 +46,7 @@
@Override
public void visit(StringBuilder sb, Map<String, Type> context, ELVisitor visitor) throws ParsingException {
- sb.append(ELNodeConstants.QUOTE);
sb.append(StringUtils.getEscapedString(((AstString) getNode()).getString()));
- sb.append(ELNodeConstants.QUOTE);
visitor.setVariableType(TypesFactory.getType(String.class));
}
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-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -32,7 +33,6 @@
import java.util.Set;
import java.util.TreeMap;
-import javax.annotation.Generated;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -143,7 +143,7 @@
this.compositeInterface = compositeInterface;
this.classLoader = classLoader;
- //TODO - cache unmarshalled data
+ // 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);
}
@@ -157,9 +157,10 @@
this.generatedClass.addImport(ResponseWriter.class);
this.generatedClass.addImport(UIComponent.class);
- this.generatedClass.addAnnotation(Generated.class, "\"RichFaces CDK\"");
+ // TODO - make this JavaDoc - Generated annotation is present since JDK6
+ // this.generatedClass.addAnnotation(Generated.class, "\"RichFaces CDK\"");
// TODO remove this after improving Java model
- this.generatedClass.addImport(Generated.class);
+ // this.generatedClass.addImport(Generated.class);
this.createMethodContext();
}
@@ -259,37 +260,33 @@
return result;
}
- private String createPassThroughAttributeCode(String attributeName, String[] eventNames) {
+ private String createPassThroughAttributeCode(String htmlAttributeName, Attribute componentAttribute,
+ String[] eventNames) {
+
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
StringBuilder sb = new StringBuilder();
sb.append("new ComponentAttribute(");
- sb.append('"');
- sb.append(StringUtils.getEscapedString(attributeName));
- sb.append('"');
+ sb.append(StringUtils.getEscapedString(htmlAttributeName));
- boolean isFirstEventName = true;
+ sb.append(")");
+
+ String componentAttributeName = componentAttribute.getComponentAttributeName();
+ if (!StringUtils.isEmpty(componentAttributeName)) {
+ sb.append(".setComponentAttributeName(");
+ sb.append(StringUtils.getEscapedString(componentAttributeName));
+ sb.append(")");
+ }
+
if (eventNames != null && eventNames.length != 0) {
- sb.append(", ");
+ sb.append(".setEventNames(");
sb.append("new String[] {");
- for (String eventName : eventNames) {
- if (isFirstEventName) {
- isFirstEventName = false;
- } else {
- sb.append(", ");
- }
+ sb.append(StringUtils.getEscapedStringsArray(eventNames));
- sb.append('"');
- sb.append(StringUtils.getEscapedString(eventName));
- sb.append('"');
- }
-
- sb.append("}");
+ sb.append("})");
}
-
- sb.append(")");
return sb.toString();
}
@@ -309,12 +306,13 @@
generatedClass.addImport("org.richfaces.renderkit.ComponentAttribute");
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
-
- //TODO - get rid of FQNs for classes via imports
+ generatedClass.addImport(Collections.class);
+
+ // TODO - get rid of FQNs for classes via imports
passThroughField.setGenericArguments(new JavaClass[] { new JavaClass(String.class),
new JavaClass("org.richfaces.renderkit.ComponentAttribute") });
- StringBuilder fieldValue = new StringBuilder("ComponentAttribute.createMap(");
+ StringBuilder fieldValue = new StringBuilder("Collections.unmodifiableMap(ComponentAttribute.createMap(");
boolean isFirstArgument = true;
for (Map.Entry<String, Attribute> entry : attributesMap.entrySet()) {
if (isFirstArgument) {
@@ -324,13 +322,13 @@
}
// TODO behaviors data
- fieldValue.append(createPassThroughAttributeCode(entry.getKey(), null));
+ fieldValue.append(createPassThroughAttributeCode(entry.getKey(), entry.getValue(), null));
}
- fieldValue.append(")");
-
+ fieldValue.append("))");
+
passThroughField.setValue(fieldValue.toString());
-
+
return passThroughField;
}
@@ -469,7 +467,7 @@
} else {
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
- //TODO externalize
+ // TODO externalize
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
currentStatement.addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
attributeValue.toString(), String.class)));
@@ -497,7 +495,7 @@
if (!actualAttributesMap.isEmpty()) {
JavaField passThroughField = createPassThroughField(actualAttributesMap);
generatedClass.addField(passThroughField);
- //TODO externalize
+ // TODO externalize
generatedClass.addImport("org.richfaces.renderkit.RenderKitUtils");
currentStatement.addStatement(new WriteAttributesSetStatement(passThroughField.getName()));
}
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-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -45,7 +45,9 @@
import org.richfaces.cdk.templatecompiler.model.Attribute;
import org.richfaces.cdk.templatecompiler.model.ClientBehavior;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
+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 com.google.common.collect.Lists;
@@ -142,6 +144,7 @@
// component.getRenderers().add(renderer);
+ //TODO set default values according to template name
String family = compositeInterface.getComponentFamily();
if (null != family) {
@@ -153,6 +156,17 @@
Map<String, Property> rendererAttributes = renderer.getAttributes();
+ List<ImportAttributes> attributesImports = compositeInterface.getAttributesImports();
+ if (attributesImports != null) {
+ for (ImportAttributes attributesImport : attributesImports) {
+ String importURI = attributesImport.getSource();
+ Map<String, Property> properties = getContext().getWorker(FragmentParser.class).parseProperties(importURI);
+ if (properties != null) {
+ rendererAttributes.putAll(properties);
+ }
+ }
+ }
+
List<Attribute> templateAttributes = compositeInterface.getAttributes();
if (templateAttributes != null) {
for (Attribute templateAttribute : templateAttributes) {
@@ -168,6 +182,7 @@
rendererProperty.getEventNames().addAll(eventNamesSet);
}
+ //TODO handle attributes - add extensions to schema & handling for them
// rendererProperty.setAliases(aliases)
// rendererProperty.setExtension(extension)
// rendererProperty.setGenerate(exists)
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -49,6 +49,8 @@
private List<ResourceDependency> resourceDependencies;
+ private List<ImportAttributes> attributesImports;
+
private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
private String javaClass;
@@ -230,4 +232,24 @@
public void setRendersChildren(boolean rendersChildren) {
this.rendersChildren = rendersChildren;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the attributesImports
+ */
+ @XmlElement(name = "import-attributes", namespace = Template.CDK_NAMESPACE)
+ public List<ImportAttributes> getAttributesImports() {
+ return attributesImports;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param attributesImports the attributesImports to set
+ */
+ public void setAttributesImports(List<ImportAttributes> attributesImports) {
+ this.attributesImports = attributesImports;
+ }
+
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -0,0 +1,49 @@
+/*
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ImportAttributes {
+
+ private String source;
+
+ /**
+ * @return the source
+ */
+ @XmlAttribute(name = "src")
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * @param source the source to set
+ */
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+}
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/cdk-template.xsd 2010-01-28 19:07:27 UTC (rev 16377)
@@ -111,6 +111,12 @@
<xs:element name="component-family" />
<xs:element name="renderer-type" />
<xs:element name="renders-children" type="xs:boolean" />
+
+ <xs:element name="import-attributes">
+ <xs:complexType>
+ <xs:attribute use="required" name="src" type="xs:anyURI" form="unqualified" />
+ </xs:complexType>
+ </xs:element>
<xs:group name="structural">
<xs:choice>
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/schema/xhtml-el.xsd 2010-01-28 19:07:27 UTC (rev 16377)
@@ -468,6 +468,14 @@
</xs:documentation>
</xs:annotation>
+ <xs:attribute name="class" type="NMTOKENS">
+ <xs:annotation>
+ <xs:appinfo>
+ <cdk-addinfo:component-attribute-name>styleClass</cdk-addinfo:component-attribute-name>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:attribute>
+
<xs:attributeGroup name="coreattrs">
<xs:annotation>
<xs:documentation>
@@ -481,7 +489,7 @@
</xs:documentation>
</xs:annotation>
<xs:attribute name="id" type="ID" />
- <xs:attribute name="class" type="NMTOKENS" />
+ <xs:attribute ref="class" />
<xs:attribute name="style" type="StyleSheet" />
<xs:attribute name="title" type="Text" />
</xs:attributeGroup>
@@ -3026,11 +3034,11 @@
<xs:group ref="map.children" />
<xs:attributeGroup ref="i18n"></xs:attributeGroup>
<xs:attributeGroup ref="events"></xs:attributeGroup>
- <xs:attribute use="required" name="id" type="ID"></xs:attribute>
- <xs:attribute name="class" type="xs:anySimpleType"></xs:attribute>
- <xs:attribute name="style" type="StyleSheet"></xs:attribute>
- <xs:attribute name="title" type="Text"></xs:attribute>
- <xs:attribute name="name" type="xs:anySimpleType"></xs:attribute>
+ <xs:attribute use="required" name="id" type="ID" />
+ <xs:attribute ref="class" />
+ <xs:attribute name="style" type="StyleSheet" />
+ <xs:attribute name="title" type="Text" />
+ <xs:attribute name="name" type="xs:anySimpleType" />
<xs:attributeGroup ref="cdk:core.attrs" />
</xs:complexType>
Modified: root/cdk/trunk/plugins/generator/src/main/script/SchemaProcessor.groovy
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/script/SchemaProcessor.groovy 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/main/script/SchemaProcessor.groovy 2010-01-28 19:07:27 UTC (rev 16377)
@@ -64,7 +64,7 @@
return xPath;
}
- private String getDefaultValue(XSAttributeUse attributeUse) throws XPathExpressionException {
+ private String getAdditionalInfo(XSAttributeUse attributeUse, String elementName) throws XPathExpressionException {
String defaultValue = null;
XSAttributeDecl attributeDecl = attributeUse.getDecl();
@@ -73,7 +73,7 @@
Object annotationElement = annotation.getAnnotation();
if (annotationElement != null) {
XPath xPath = createXPath();
- Node node = (Node) xPath.evaluate("xs:appinfo/cdk-schema-info:default-value", annotationElement,
+ Node node = (Node) xPath.evaluate("xs:appinfo/cdk-schema-info:" + elementName, annotationElement,
XPathConstants.NODE);
if (node != null) {
defaultValue = xPath.evaluate("text()", node);
@@ -84,6 +84,14 @@
return defaultValue;
}
+ private String getComponentAttributeName(XSAttributeUse attributeUse) throws XPathExpressionException {
+ return getAdditionalInfo(attributeUse, "component-attribute-name");
+ }
+
+ private String getDefaultValue(XSAttributeUse attributeUse) throws XPathExpressionException {
+ return getAdditionalInfo(attributeUse, "default-value");
+ }
+
private boolean isGenericKind(Attribute.Kind attributeKind) {
return Kind.GENERIC.equals(attributeKind);
}
@@ -173,6 +181,7 @@
modelAttribute.setKind(getAttributeKind(attributeDecl.getType()));
modelAttribute.setRequired(xsAttributeUse.isRequired());
modelAttribute.setDefaultValue(getDefaultValue(xsAttributeUse));
+ modelAttribute.setComponentAttributeName(getComponentAttributeName(xsAttributeUse));
}
}
}
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-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -234,6 +234,15 @@
assertEquals("Required Attribute", requiredAttribute.getDisplayname());
}
+ private void checkDummyComponentImportedAttribute(Property importedAttribute, Class<?> type) {
+ assertNotNull(importedAttribute);
+ assertNoEventNames(importedAttribute);
+ assertNoSignature(importedAttribute);
+ assertNoDefaultValue(importedAttribute);
+ assertFalse(importedAttribute.isRequired());
+
+ assertEquals(type.getName(), importedAttribute.getType().getName());
+ }
@Before
@@ -290,7 +299,12 @@
checkDummyComponentIntegerAttribute(attributes.get("integerAttribute"));
checkDummyComponentRequiredAttribute(attributes.get("requiredAttribute"));
- assertEquals(7, attributes.size());
+ checkDummyComponentImportedAttribute(attributes.get("anotherImportedStringProperty"), String.class);
+ checkDummyComponentImportedAttribute(attributes.get("anotherImportedProperty"), Object.class);
+ checkDummyComponentImportedAttribute(attributes.get("importedBooleanProperty"), boolean.class);
+ checkDummyComponentImportedAttribute(attributes.get("importedIntegerProperty"), Integer.class);
+
+ assertEquals(11, attributes.size());
}
}
Added: root/cdk/trunk/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/META-INF/cdk/attributes/dummy-template-props.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+-->
+<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <property>
+ <property-name>importedBooleanProperty</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <property-name>importedIntegerProperty</property-name>
+ <property-class>java.lang.Integer</property-class>
+ </property>
+
+</cdk:properties>
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy-attributes.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, Home of Professional Open Source Copyright ${year}, 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.
+-->
+<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <property>
+ <property-name>anotherImportedStringProperty</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>anotherImportedProperty</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+
+</cdk:properties>
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/templatecompiler/dummy.template.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -28,6 +28,9 @@
<cc:attribute name="integerAttribute" type="java.lang.Integer" default="-1" />
<cc:attribute name="requiredAttribute" shortDescription="That's a required attribute"
displayName="Required Attribute" required="true" />
+
+ <cdk:import-attributes src="urn:resource:org/richfaces/cdk/templatecompiler/dummy-attributes.xml" />
+ <cdk:import-attributes src="urn:attributes:dummy-template-props.xml" />
</cc:interface>
<cc:implementation />
Modified: root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit;
-import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
@@ -31,47 +30,71 @@
*/
public class ComponentAttribute implements Comparable<ComponentAttribute> {
- private final String name;
+ private final String htmlAttributeName;
- private final String[] eventNames;
+ private String componentAttributeName;
+ private String[] eventNames;
+
//TODO handling for aliases: "styleClass" -> "class"
- public ComponentAttribute(String name) {
- this(name, null);
- }
-
- public ComponentAttribute(String name, String[] eventNames) {
+ public ComponentAttribute(String htmlAttributeName) {
super();
- this.name = name;
- this.eventNames = eventNames;
+ this.htmlAttributeName = htmlAttributeName;
}
public static final Map<String, ComponentAttribute> createMap(ComponentAttribute... attributes) {
Map<String,ComponentAttribute> result = new TreeMap<String, ComponentAttribute>();
for (ComponentAttribute componentAttribute : attributes) {
- result.put(componentAttribute.getName(), componentAttribute);
+ result.put(componentAttribute.getHtmlAttributeName(), componentAttribute);
}
- return Collections.unmodifiableMap(result);
+ return result;
}
/**
* @return the name
*/
- public String getName() {
- return name;
+ public String getHtmlAttributeName() {
+ return htmlAttributeName;
}
/**
+ * @return the componentAttributeName
+ */
+ public String getComponentAttributeName() {
+ return (componentAttributeName == null) ? htmlAttributeName : componentAttributeName;
+ }
+
+ /**
+ * @param componentAttributeName the componentAttributeName to set
+ * @return
+ */
+ public ComponentAttribute setComponentAttributeName(String componentAttributeName) {
+ this.componentAttributeName = componentAttributeName;
+
+ return this;
+ }
+
+ /**
* @return the eventNames
*/
public String[] getEventNames() {
return eventNames;
}
-
+
+ /**
+ * @param eventNames the eventNames to set
+ * @return
+ */
+ public ComponentAttribute setEventNames(String[] eventNames) {
+ this.eventNames = eventNames;
+
+ return this;
+ }
+
public int compareTo(ComponentAttribute o) {
- return getName().compareTo(o.getName());
+ return getHtmlAttributeName().compareTo(o.getHtmlAttributeName());
}
}
Modified: root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/framework/trunk/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -164,6 +164,7 @@
return result.toString();
}
+ //TODO filter out empty strings
static boolean shouldRenderAttribute(Object attributeValue) {
if (attributeValue == null) {
return false;
@@ -216,15 +217,15 @@
String prefixedAttributeName = prefixAttributeName(attributeName, writer);
if (Arrays.binarySearch(URI_ATTRIBUTE_NAMES, attributeName) >= 0) {
- writer.writeURIAttribute(prefixedAttributeName, attributeValue, attributeName);
+ writer.writeURIAttribute(prefixedAttributeName, attributeValue, null);
} else if (Arrays.binarySearch(BOOLEAN_ATTRIBUTE_NAMES, attributeName) >= 0) {
boolean booleanAttributeValue = Boolean.valueOf(String.valueOf(attributeValue));
if (booleanAttributeValue) {
// TODO - is passing in Boolean.TRUE value documented somewhere?
- writer.writeAttribute(prefixedAttributeName, Boolean.TRUE, attributeName);
+ writer.writeAttribute(prefixedAttributeName, Boolean.TRUE, null);
}
} else {
- writer.writeAttribute(prefixedAttributeName, attributeValue, attributeName);
+ writer.writeAttribute(prefixedAttributeName, attributeValue, null);
}
}
@@ -243,8 +244,9 @@
throw new NullPointerException("componentAttribute");
}
- String attributeName = componentAttribute.getName();
- Object attributeValue = component.getAttributes().get(attributeName);
+ String htmlAttributeName = componentAttribute.getHtmlAttributeName();
+ String componentAttributeName = componentAttribute.getComponentAttributeName();
+ Object attributeValue = component.getAttributes().get(componentAttributeName);
Map<String, List<ClientBehavior>> behaviorsMap = getClientBehaviorsMap(component);
if (behaviorsMap != null) {
@@ -266,7 +268,7 @@
}
}
- renderAttribute(facesContext, attributeName, attributeValue);
+ renderAttribute(facesContext, htmlAttributeName, attributeValue);
}
public static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
@@ -296,7 +298,7 @@
for (Map.Entry<String, ComponentAttribute> knownAttributesMapEntry : knownAttributesMap.entrySet()) {
ComponentAttribute knownAttribute = knownAttributesMapEntry.getValue();
- if (handledAttributes.contains(knownAttribute.getName())) {
+ if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
continue;
}
Modified: root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
===================================================================
--- root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/framework/trunk/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-01-28 19:07:27 UTC (rev 16377)
@@ -162,6 +162,7 @@
knownAttributes.put("style", new ComponentAttribute("style"));
knownAttributes.put("src", new ComponentAttribute("src"));
knownAttributes.put("lang", new ComponentAttribute("lang"));
+ knownAttributes.put("class", new ComponentAttribute("class").setComponentAttributeName("styleClass"));
Map<String, Object> componentAttributes = new HashMap<String, Object>();
componentAttributes.put("disabled", Boolean.TRUE);
@@ -170,16 +171,18 @@
componentAttributes.put("src", "urn:abc");
componentAttributes.put("facelets.Mark", 123);
componentAttributes.put("lang", "ru");
+ componentAttributes.put("styleClass", "rich-component");
UIComponent component = FacesMock.createMock(UIComponent.class);
expect(component.getAttributes()).andReturn(componentAttributes).anyTimes();
- responseWriter.writeAttribute(eq("disabled"), eq(Boolean.TRUE), eq("disabled"));
+ responseWriter.writeAttribute(eq("disabled"), eq(Boolean.TRUE), EasyMock.<String>isNull());
// checked attribute shouldn't be rendered - it's 'false'
- responseWriter.writeAttribute(eq("style"), eq("color:red"), eq("style"));
- responseWriter.writeURIAttribute(eq("src"), eq("urn:abc"), eq("src"));
+ responseWriter.writeAttribute(eq("style"), eq("color:red"), EasyMock.<String>isNull());
+ responseWriter.writeURIAttribute(eq("src"), eq("urn:abc"), EasyMock.<String>isNull());
// facelets.Mark shouldn't be rendered - it's unknown
- responseWriter.writeAttribute(eq("xml:lang"), eq("ru"), eq("lang"));
+ responseWriter.writeAttribute(eq("xml:lang"), eq("ru"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("class"), eq("rich-component"), EasyMock.<String>isNull());
FacesMock.replay(facesEnvironment, component, responseWriter);
@@ -190,7 +193,7 @@
private ClientBehavior createClientBehavior(String handlerData, Set<ClientBehaviorHint> hints) {
ClientBehavior behavior = FacesMock.createMock(ClientBehavior.class);
- expect(behavior.getScript(EasyMock.<ClientBehaviorContext>notNull())).andReturn(
+ expect(behavior.getScript(EasyMock.<ClientBehaviorContext> notNull())).andReturn(
MessageFormat.format("prompt({0})", handlerData)).anyTimes();
expect(behavior.getHints()).andReturn(hints).anyTimes();
@@ -200,10 +203,14 @@
@Test
public void testBehaviors() throws Exception {
Map<String, ComponentAttribute> knownAttributes = new HashMap<String, ComponentAttribute>();
- knownAttributes.put("onclick", new ComponentAttribute("onclick", new String[] { "click", "action" }));
- knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove", new String[] { "mousemove" }));
- knownAttributes.put("onkeypress", new ComponentAttribute("onkeypress", new String[] { "keypress" }));
- knownAttributes.put("oncontextmenu", new ComponentAttribute("oncontextmenu", new String[] { "contextmenu" }));
+ knownAttributes.put("onclick", new ComponentAttribute("onclick")
+ .setEventNames(new String[] { "click", "action" }));
+ knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
+ .setEventNames(new String[] { "mousemove" }));
+ knownAttributes.put("onkeypress", new ComponentAttribute("onkeypress")
+ .setEventNames(new String[] { "keypress" }));
+ knownAttributes.put("oncontextmenu", new ComponentAttribute("oncontextmenu")
+ .setEventNames(new String[] { "contextmenu" }));
Map<String, Object> componentAttributes = new HashMap<String, Object>();
componentAttributes.put("onkeypress", "alert(keypress)");
@@ -214,7 +221,7 @@
Set<ClientBehaviorHint> submittingHintsSet = EnumSet.of(ClientBehaviorHint.SUBMITTING);
Map<String, List<ClientBehavior>> behaviorsMap = new HashMap<String, List<ClientBehavior>>();
-
+
ClientBehavior keypressBehavior = createClientBehavior("keypress", emptyHintsSet);
ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
ClientBehavior actionBehavior2 = createClientBehavior("action2", submittingHintsSet);
@@ -233,18 +240,18 @@
Arrays.asList("click", "action", "mousemove", "keypress", "blur", "contextmenu")).anyTimes();
responseWriter.writeAttribute(eq("onkeypress"), eq("jsf.util.chain('alert(keypress)','prompt(keypress)')"),
- eq("onkeypress"));
+ EasyMock.<String>isNull());
responseWriter.writeAttribute(eq("onclick"),
- eq("jsf.util.chain('alert(click)','prompt(action1)','prompt(action2)')"), eq("onclick"));
- responseWriter.writeAttribute(eq("onmousemove"), eq("alert(mousemove)"), eq("onmousemove"));
- responseWriter.writeAttribute(eq("oncontextmenu"), eq("prompt(contextmenu)"), eq("oncontextmenu"));
+ eq("jsf.util.chain('alert(click)','prompt(action1)','prompt(action2)')"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("onmousemove"), eq("alert(mousemove)"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("oncontextmenu"), eq("prompt(contextmenu)"), EasyMock.<String>isNull());
- FacesMock.replay(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1, actionBehavior2,
- actionBehavior3, contextmenuBehavior);
+ FacesMock.replay(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1,
+ actionBehavior2, actionBehavior3, contextmenuBehavior);
RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- FacesMock.verify(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1, actionBehavior2,
- actionBehavior3, contextmenuBehavior);
+ FacesMock.verify(component, facesEnvironment, responseWriter, keypressBehavior, actionBehavior1,
+ actionBehavior2, actionBehavior3, contextmenuBehavior);
}
}
\ No newline at end of file
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/button.template.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -14,8 +14,8 @@
<cc:implementation>
<input id="#{clientId}" name="#{clientId}"
- cdk:passThroughWithExclusions="name onclick type id class" onclick="#{this.getOnClick(facesContext,cc)}"
- value="#{cc.attributes['value']}" class="#{cc.attributes['styleClass']}">
+ cdk:passThroughWithExclusions="type" onclick="#{this.getOnClick(facesContext,cc)}"
+ value="#{cc.attributes['value']}">
<cdk:call expression="encodeTypeAndImage(facesContext,cc);" />
</input>
</cc:implementation>
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/link.template.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -13,8 +13,8 @@
<cc:implementation>
<a id="#{clientId}" name="#{clientId}"
- cdk:passThroughWithExclusions="value name onclick href id" onclick="#{this.getOnClick(facesContext, cc)}"
- href="#" class="#{cc.attributes['styleClass']}">
+ cdk:passThroughWithExclusions="value" onclick="#{this.getOnClick(facesContext, cc)}"
+ href="#">
#{cc.attributes['value']}
<cdk:body>
<cdk:call expression="renderChildren(facesContext, cc);" />
Modified: root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-01-28 14:08:02 UTC (rev 16376)
+++ root/ui/trunk/components/core/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-01-28 19:07:27 UTC (rev 16377)
@@ -27,8 +27,7 @@
LOG.LEVEL = LOG.#{component.attributes["level"]}; </script> </div>
</cdk:otherwise> </cdk:choose
-->
- <div id="richfaces.log" class="rich-log #{cc.attributes['styleClass']}"
- cdk:passThroughWithExclusions="id class">
+ <div id="richfaces.log" class="rich-log #{cc.attributes['styleClass']}">
<script type="text/javascript">
RichFaces.log.setLevel("#{cc.attributes['level']}");
</script>
14 years, 11 months
JBoss Rich Faces SVN: r16376 - in branches/community/3.3.X: samples and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-01-28 09:08:02 -0500 (Thu, 28 Jan 2010)
New Revision: 16376
Modified:
branches/community/3.3.X/framework/pom.xml
branches/community/3.3.X/samples/pom.xml
branches/community/3.3.X/samples/richfaces-demo/pom.xml
branches/community/3.3.X/ui/pom.xml
Log:
RFPL-329
Modified: branches/community/3.3.X/framework/pom.xml
===================================================================
--- branches/community/3.3.X/framework/pom.xml 2010-01-28 12:16:40 UTC (rev 16375)
+++ branches/community/3.3.X/framework/pom.xml 2010-01-28 14:08:02 UTC (rev 16376)
@@ -16,12 +16,12 @@
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
Modified: branches/community/3.3.X/samples/pom.xml
===================================================================
--- branches/community/3.3.X/samples/pom.xml 2010-01-28 12:16:40 UTC (rev 16375)
+++ branches/community/3.3.X/samples/pom.xml 2010-01-28 14:08:02 UTC (rev 16376)
@@ -30,12 +30,12 @@
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
Modified: branches/community/3.3.X/samples/richfaces-demo/pom.xml
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/pom.xml 2010-01-28 12:16:40 UTC (rev 16375)
+++ branches/community/3.3.X/samples/richfaces-demo/pom.xml 2010-01-28 14:08:02 UTC (rev 16376)
@@ -219,12 +219,12 @@
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
</dependency>
</dependencies>
<properties>
Modified: branches/community/3.3.X/ui/pom.xml
===================================================================
--- branches/community/3.3.X/ui/pom.xml 2010-01-28 12:16:40 UTC (rev 16375)
+++ branches/community/3.3.X/ui/pom.xml 2010-01-28 14:08:02 UTC (rev 16376)
@@ -86,13 +86,13 @@
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>2.0.1</version>
+ <version>2.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
14 years, 11 months
JBoss Rich Faces SVN: r16375 - branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-01-28 07:16:40 -0500 (Thu, 28 Jan 2010)
New Revision: 16375
Modified:
branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js
Log:
Fix RF-8275
Modified: branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
--- branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2010-01-28 12:14:59 UTC (rev 16374)
+++ branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2010-01-28 12:16:40 UTC (rev 16375)
@@ -39,7 +39,8 @@
destroy: function() {
//remove listeners
- this.selectionManager.removeListeners();
+ this.selectionManager.destroy();
+
if (this.header) {
this.header.removeListeners();
}
@@ -55,7 +56,6 @@
}
//null all references to DOM elements
- delete this.selectionManager;
delete this.header;
delete this.footer;
@@ -71,6 +71,7 @@
this.scrollingDiv = null;
this.groupRows = null;
this.groups = null;
+ this.selectionManager = null;
Event.stopObserving(window, 'resize', this.eventContainerResize);
},
Modified: branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js
===================================================================
--- branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js 2010-01-28 12:14:59 UTC (rev 16374)
+++ branches/community/3.3.X/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableSelection.js 2010-01-28 12:16:40 UTC (rev 16375)
@@ -246,7 +246,10 @@
},
-
+ destroy: function(){
+ this.removeListeners();
+ this.gridElement = null;
+ },
refreshEvents: function() {
this.setListeners();
if(this.options.selectionMode != "none") {
14 years, 11 months
JBoss Rich Faces SVN: r16374 - branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/modifiableModel.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-01-28 07:14:59 -0500 (Thu, 28 Jan 2010)
New Revision: 16374
Modified:
branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/modifiableModel/BaseModifiableHibernateDataModel.java
Log:
Fix RF-8327
Modified: branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/modifiableModel/BaseModifiableHibernateDataModel.java
===================================================================
--- branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/modifiableModel/BaseModifiableHibernateDataModel.java 2010-01-28 12:14:01 UTC (rev 16373)
+++ branches/community/3.3.X/samples/richfaces-demo/src/main/java/org/richfaces/demo/modifiableModel/BaseModifiableHibernateDataModel.java 2010-01-28 12:14:59 UTC (rev 16374)
@@ -86,7 +86,7 @@
Order order = Ordering.ASCENDING.equals(ordering) ?
Order.asc(propertyName) : Order.desc(propertyName);
- criteria.addOrder(order.ignoreCase());
+ criteria.addOrder(order);
}
}
}
14 years, 11 months