JBoss Rich Faces SVN: r18274 - root/docs/trunk/Component_Reference/src/main/docbook/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-07-29 01:15:57 -0400 (Thu, 29 Jul 2010)
New Revision: 18274
Modified:
root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Actions.xml
root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Containers.xml
root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Layout_and_appearance.xml
root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Resources.xml
root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
Log:
Excluded sections on incomplete components RF-8987
Modified: root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Actions.xml
===================================================================
--- root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Actions.xml 2010-07-28 23:37:47 UTC (rev 18273)
+++ root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Actions.xml 2010-07-29 05:15:57 UTC (rev 18274)
@@ -74,7 +74,8 @@
</para>
</section>
- <!-- TODO NOT IN A2 -->
+ <!-- FIXME not in M2 -->
+ <!--
<section id="sect-Component_Reference-Actions-a4jajaxListener">
<title><sgmltag><a4j:ajaxListener></sgmltag></title>
<itemizedlist>
@@ -104,6 +105,7 @@
The <sgmltag><a4j:ajaxListener></sgmltag> component is not invoked for non-Ajax requests, or when the RichFaces works in the <emphasis>Ajax request generates non-Ajax response</emphasis> mode, so the <sgmltag><a4j:ajaxListener></sgmltag> invocation is a good indicator that an Ajax response is going to be processed.
</para>
</section>
+ -->
<section id="sect-Component_Reference-Actions-a4jcommandButton">
<title><sgmltag><a4j:commandButton></sgmltag></title>
@@ -201,7 +203,6 @@
</para>
</section>
- <!-- FIXME this is really rich:componentControl -->
<section id="sect-Component_Reference-Actions-richcomponentControl">
<title><sgmltag><rich:componentControl></sgmltag></title>
<remark>The following reference data is taken from the old <sgmltag><rich:componentControl></sgmltag> reference. The details may be different now that the component is part of the <classname>a4j</classname> tag library.</remark>
@@ -322,13 +323,18 @@
</variablelist>
</section>
+ <!-- TODO not in M2 -->
+ <!--
<section id="sect-Component_Reference-Actions-a4jhashParam">
<title><sgmltag><a4j:hashParam></sgmltag></title>
<para>
Incomplete
</para>
</section>
+ -->
+ <!-- FIXME not in M2 -->
+ <!--
<section id="sect-Component_Reference-Actions-a4jhtmlCommandLink">
<title><sgmltag><a4j:htmlCommandLink></sgmltag></title>
<itemizedlist>
@@ -360,6 +366,7 @@
When using the standard component, hidden fields were not rendered to child elements if they were deemed unnecessary, so command links relating to content on the initial page could become broken if they were later updated through Ajax. The <sgmltag><a4j:htmlCommandLink></sgmltag> component addresses this by always rendering all hidden fields.
</para>
</section>
+ -->
<section id="sect-Component_Reference-Actions-a4jjsFunction">
<title><sgmltag><a4j:jsFunction></sgmltag></title>
@@ -479,52 +486,6 @@
</para>
</section>
- <section id="sect-Component_Reference-Actions-a4jrepeat">
- <title><sgmltag><a4j:repeat></sgmltag></title>
- <itemizedlist>
- <listitem>
- <para>
- component-type: <classname>org.ajax4jsf.Repeat</classname>
- </para>
- </listitem>
- <listitem>
- <para>
- component-family: <classname>javax.faces.Data</classname>
- </para>
- </listitem>
- <listitem>
- <para>
- component-class: <classname>org.ajax4jsf.component.html.HtmlAjaxRepeat</classname>
- </para>
- </listitem>
- <listitem>
- <para>
- renderer-type: <classname>org.ajax4jsf.components.RepeatRenderer</classname>
- </para>
- </listitem>
- </itemizedlist>
- <!-- FIXME Move a4j:repeat -->
- <para>
- REVIEW COMMENT - a4j:repeat is not an action, should be moved. The <sgmltag><a4j:repeat></sgmltag> component is used to iterate changes through a repeated collection of components. It allows specific rows of items to be updated without sending Ajax requests for the entire collection. The <sgmltag><a4j:repeat></sgmltag> component forms the basis for many of the tabular components detailed in <xref linkend="chap-Component_Reference-Tables_and_grids" />.
- </para>
- <para>
- The contents of the collection are determined using Expression Language (<acronym>EL</acronym>). The data model for the contents is specified with the <varname>value</varname> attribute. The <varname>var</varname> attribute names the object to use when iterating through the collection. This object is then referenced in the relevant child components. After an Ajax request, only the rows specified with the <varname>ajaxKeys</varname> attribute are updated rather than the entire collection. <xref linkend="exam-Component_Reference-a4jrepeat-a4jrepeat_example" /> shows how to use <sgmltag><a4j:repeat></sgmltag> to maintain a simple table.
- </para>
- <example id="exam-Component_Reference-a4jrepeat-a4jrepeat_example">
- <title><sgmltag><a4j:repeat></sgmltag> example</title>
-
-<programlisting language="XML" role="XML"><xi:include href="extras/exam-Component_Reference-Tables_and_grids-a4jrepeat_example.xml_sample" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" />
-</programlisting>
- <para>
- Each row of a table contains two cells: one showing the item code, and the other showing the item price. The table is generated by iterating through items in the <code>repeatBeans.items</code> data model.
- </para>
- </example>
- <para>
- The <sgmltag><a4j:repeat></sgmltag> component uses other attributes common to iteration components, such as the <varname>first</varname> attribute for specifying the first item for iteration, and the <varname>rows</varname> attribute for specifying the number of rows of items to display.
- </para>
- </section>
-
- <!-- FIXME - a4j:support is now a4j:ajax in 4.0 -->
<section id="sect-Component_Reference-Actions-a4jajax">
<title><sgmltag><a4j:ajax></sgmltag></title>
<itemizedlist>
@@ -550,7 +511,7 @@
</listitem>
</itemizedlist>
<para>
- REVIEW COMMENT: a4j:support is a4j:ajax in 4.0, paths need to be updated. The <sgmltag><a4j:ajax></sgmltag> component allows Ajax capability to be added to any non-Ajax component. It is placed as a direct child to the component that requires Ajax support. The <sgmltag><a4j:ajax></sgmltag> component uses the common attributes listed in <xref linkend="chap-Component_Reference-Common_Ajax_attributes" />.
+ The <sgmltag><a4j:ajax></sgmltag> component allows Ajax capability to be added to any non-Ajax component. It is placed as a direct child to the component that requires Ajax support. The <sgmltag><a4j:ajax></sgmltag> component uses the common attributes listed in <xref linkend="chap-Component_Reference-Common_Ajax_attributes" />.
</para>
<note>
<title>Attaching JavaScript functions</title>
Modified: root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Containers.xml
===================================================================
--- root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Containers.xml 2010-07-28 23:37:47 UTC (rev 18273)
+++ root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Containers.xml 2010-07-29 05:15:57 UTC (rev 18274)
@@ -6,7 +6,8 @@
<para>
This chapter details those components in the <classname>a4j</classname> tag library which define an area used as a container or wrapper for other components.
</para>
- <!-- FIXME NOT IN A2 -->
+ <!-- FIXME NOT IN M2 -->
+ <!--
<section id="sect-Component_Reference-Containers-a4jform">
<title><sgmltag><a4j:form></sgmltag></title>
<itemizedlist>
@@ -53,6 +54,7 @@
</para>
</important>
</section>
+ -->
<section id="sect-Component_Reference-Containers-a4jinclude">
<title><sgmltag><a4j:include></sgmltag></title>
@@ -162,7 +164,8 @@
</para>
</section>
- <!-- FIXME NOT IN A2 -->
+ <!-- FIXME not in M2 -->
+ <!--
<section id="sect-Component_Reference-Containers-a4jpage">
<title><sgmltag><a4j:page></sgmltag></title>
<itemizedlist>
@@ -217,6 +220,7 @@
do not have this problem, and as such do not require the use of the <sgmltag><a4j:page></sgmltag> component.
</para>
</section>
+ -->
<section id="sect-Component_Reference-Containers-a4jregion">
<title><sgmltag><a4j:region></sgmltag></title>
Modified: root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Layout_and_appearance.xml
===================================================================
--- root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Layout_and_appearance.xml 2010-07-28 23:37:47 UTC (rev 18273)
+++ root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Layout_and_appearance.xml 2010-07-29 05:15:57 UTC (rev 18274)
@@ -16,7 +16,7 @@
<section id="sect-Component_Reference-Layout_and_appearance-richjQuery">
<title><sgmltag><rich:jQuery></sgmltag></title>
<para>
- Incomplete
+ Milestone2
</para>
</section>
Modified: root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Resources.xml
===================================================================
--- root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Resources.xml 2010-07-28 23:37:47 UTC (rev 18273)
+++ root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Resources.xml 2010-07-29 05:15:57 UTC (rev 18274)
@@ -6,7 +6,9 @@
<para>
This chapter covers those components used to handle and manage resources and beans.
</para>
- <!-- FIXME NOT IN A2 -->
+
+ <!-- FIXME not in M2 -->
+ <!--
<section id="sect-Component_Reference-Resources-a4jloadBundle">
<title><sgmltag><a4j:loadBundle></sgmltag></title>
<itemizedlist>
@@ -182,6 +184,7 @@
</programlisting>
</example>
</section>
+ -->
<section id="sect-Component_Reference-Resources-a4jkeepAlive">
<title><sgmltag><a4j:keepAlive></sgmltag></title>
Modified: root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
===================================================================
--- root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-07-28 23:37:47 UTC (rev 18273)
+++ root/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-07-29 05:15:57 UTC (rev 18274)
@@ -14,6 +14,51 @@
<para>
This chapter covers all components related to the display of tables and grids.
</para>
+
+ <section id="sect-Component_Reference-Actions-a4jrepeat">
+ <title><sgmltag><a4j:repeat></sgmltag></title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ component-type: <classname>org.ajax4jsf.Repeat</classname>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ component-family: <classname>javax.faces.Data</classname>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ component-class: <classname>org.ajax4jsf.component.html.HtmlAjaxRepeat</classname>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ renderer-type: <classname>org.ajax4jsf.components.RepeatRenderer</classname>
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ The <sgmltag><a4j:repeat></sgmltag> component is used to iterate changes through a repeated collection of components. It allows specific rows of items to be updated without sending Ajax requests for the entire collection. The <sgmltag><a4j:repeat></sgmltag> component forms the basis for many of the tabular components detailed in <xref linkend="chap-Component_Reference-Tables_and_grids" />.
+ </para>
+ <para>
+ The contents of the collection are determined using Expression Language (<acronym>EL</acronym>). The data model for the contents is specified with the <varname>value</varname> attribute. The <varname>var</varname> attribute names the object to use when iterating through the collection. This object is then referenced in the relevant child components. After an Ajax request, only the rows specified with the <varname>ajaxKeys</varname> attribute are updated rather than the entire collection. <xref linkend="exam-Component_Reference-a4jrepeat-a4jrepeat_example" /> shows how to use <sgmltag><a4j:repeat></sgmltag> to maintain a simple table.
+ </para>
+ <example id="exam-Component_Reference-a4jrepeat-a4jrepeat_example">
+ <title><sgmltag><a4j:repeat></sgmltag> example</title>
+
+<programlisting language="XML" role="XML"><xi:include href="extras/exam-Component_Reference-Tables_and_grids-a4jrepeat_example.xml_sample" parse="text" xmlns:xi="http://www.w3.org/2001/XInclude" />
+</programlisting>
+ <para>
+ Each row of a table contains two cells: one showing the item code, and the other showing the item price. The table is generated by iterating through items in the <code>repeatBeans.items</code> data model.
+ </para>
+ </example>
+ <para>
+ The <sgmltag><a4j:repeat></sgmltag> component uses other attributes common to iteration components, such as the <varname>first</varname> attribute for specifying the first item for iteration, and the <varname>rows</varname> attribute for specifying the number of rows of items to display.
+ </para>
+ </section>
+
<section id="sect-Component_Reference-Tables_and_grids-richcolumn">
<title><sgmltag><rich:column></sgmltag></title>
<itemizedlist>
@@ -332,6 +377,8 @@
</para>
</section>
+ <!-- TODO not in M2 -->
+ <!--
<section id="sect-Component_Reference-Tables_and_grids-richdataDefinitionList">
<title><sgmltag><rich:dataDefinitionList></sgmltag></title>
<itemizedlist>
@@ -389,7 +436,10 @@
</blockquote>
</example>
</section>
+ -->
+ <!-- TODO not in M2 -->
+ <!--
<section id="sect-Component_Reference-Tables_and_grids-richdataFilterSlider">
<title><sgmltag><rich:dataFilterSlider></sgmltag></title>
<itemizedlist>
@@ -453,6 +503,7 @@
</blockquote>
</example>
</section>
+ -->
<section id="sect-Component_Reference-Tables_and_grids-richdataGrid">
<title><sgmltag><rich:dataGrid></sgmltag></title>
@@ -545,6 +596,8 @@
</example>
</section>
+ <!-- TODO not in M2 -->
+ <!--
<section id="sect-Component_Reference-Tables_and_grids-richdataList">
<title><sgmltag><rich:dataList></sgmltag></title>
<itemizedlist>
@@ -734,8 +787,10 @@
</blockquote>
</example>
</section>
+ -->
- <!-- TODO
+ <!-- TODO not in M2 -->
+ <!--
<section id="sect-Component_Reference-Tables_and_grids-richdataScroller">
<title><sgmltag><rich:dataScroller></sgmltag></title>
<itemizedlist>
@@ -769,7 +824,8 @@
Incomplete
</para>
</section>
- -->
+ -->
+
<section id="sect-Component_Reference-Tables_and_grids-richdataTable">
<title><sgmltag><rich:dataTable></sgmltag></title>
<itemizedlist>
14 years, 7 months
JBoss Rich Faces SVN: r18273 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk: apt/processors and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-28 19:37:47 -0400 (Wed, 28 Jul 2010)
New Revision: 18273
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java
Log:
https://jira.jboss.org/browse/RF-8907
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:37:47 UTC (rev 18273)
@@ -1,5 +1,6 @@
package org.richfaces.cdk.apt;
+import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
@@ -307,6 +308,34 @@
return processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
}
+ /**
+ * <p class="changed_added_4_0">Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.</p>
+ * @param model Model object.
+ * @param annotation annotation to copy property from.
+ * @param modelProperty bean attribute name in the model and annotation.
+ */
+ @Override
+ public void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty) {
+ setModelProperty(model, annotation, modelProperty, modelProperty);
+ }
+
+ /**
+ * <p class="changed_added_4_0">Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.</p>
+ * @param model Model object.
+ * @param annotation annotation to copy property from.
+ * @param modelProperty bean attribute name in model.
+ * @param annotationAttribute annotation attribute name.
+ */
+ @Override
+ public void setModelProperty(Object model, AnnotationMirror annotation,
+ String modelProperty, String annotationAttribute) {
+ if (!isDefaultValue(annotation, annotationAttribute)) {
+ PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(model, modelProperty);
+ PropertyUtils.setPropertyValue(model, modelProperty, getAnnotationValue(annotation,
+ annotationAttribute, propertyDescriptor.getPropertyType()));
+ }
+ }
+
public Object getConstant(TypeElement componentElement, String name) {
List<VariableElement> fieldsIn =
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:37:47 UTC (rev 18273)
@@ -118,5 +118,11 @@
return false;
}
+ public void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty, String annotationAttribute) {
+ }
+ public void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty) {
+ }
+
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:37:47 UTC (rev 18273)
@@ -218,4 +218,8 @@
public abstract boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName);
+ public abstract void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty, String annotationAttribute);
+
+ public abstract void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty);
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-07-28 23:37:31 UTC (rev 18272)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-07-28 23:37:47 UTC (rev 18273)
@@ -2,18 +2,15 @@
import java.io.FileNotFoundException;
import java.util.Collection;
-import java.util.List;
import java.util.Set;
+import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
@@ -22,11 +19,10 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.MethodSignature;
import org.richfaces.cdk.model.PropertyBase;
-import org.richfaces.cdk.util.Strings;
+import org.richfaces.cdk.util.JavaUtils;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -42,7 +38,7 @@
private static final ClassName SIGNATURE_NONE_CLASS_NAME = ClassName.get(Signature.NONE.class);
- private static final String STRING_NAME = String.class.getName();
+ private static final ClassName STRING_TYPE = ClassName.get(String.class);
@Inject
private Logger log;
@@ -73,7 +69,7 @@
attribute.setType(beanProperty.getType());
- Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
+ AnnotationMirror attributeAnnotarion = beanProperty.getAnnotationMirror(Attribute.class);
if (attributeAnnotarion == null) {
attribute.setGenerate(!beanProperty.isExists());
attribute.setDescription(beanProperty.getDocComment());
@@ -86,44 +82,44 @@
}
}
} else {
- attribute.setHidden(attributeAnnotarion.hidden());
- attribute.setLiteral(attributeAnnotarion.literal());
- attribute.setPassThrough(attributeAnnotarion.passThrough());
- attribute.setRequired(attributeAnnotarion.required());
- attribute.setReadOnly(attributeAnnotarion.readOnly());
- attribute.setGenerate(attributeAnnotarion.generate() || !beanProperty.isExists());
+ SourceUtils utils = utilsProvider.get();
+ utils.setModelProperty(attribute, attributeAnnotarion, "hidden");
+ utils.setModelProperty(attribute, attributeAnnotarion, "literal");
+ utils.setModelProperty(attribute, attributeAnnotarion, "passThrough");
+ utils.setModelProperty(attribute, attributeAnnotarion, "required");
+ utils.setModelProperty(attribute, attributeAnnotarion, "readOnly");
+ utils.setModelProperty(attribute, attributeAnnotarion, "generate");
- descriptionProcessor.processDescription(attribute, attributeAnnotarion.description(), beanProperty
+ descriptionProcessor.processDescription(attribute, beanProperty.getAnnotation(Attribute.class).description(), beanProperty
.getDocComment());
setDefaultValue(attribute, attributeAnnotarion);
- String suggestedValue = attributeAnnotarion.suggestedValue();
- if (!Strings.isEmpty(suggestedValue)) {
- attribute.setSuggestedValue(suggestedValue);
- }
+ utils.setModelProperty(attribute, attributeAnnotarion, "suggestedValue");
// MethodExpression call signature.
- attribute.setSignature(getSignature(attributeAnnotarion.signature()));
+ attribute.setSignature(getSignature(attributeAnnotarion));
- for (EventName event : attributeAnnotarion.events()) {
+ for (AnnotationMirror event : utils.getAnnotationValues(attributeAnnotarion, "events", AnnotationMirror.class)){
setBehaviorEvent(attribute, event);
}
}
}
- private void setDefaultValue(PropertyBase attribute, Attribute attributeAnnotarion) {
- String defaultValue = attributeAnnotarion.defaultValue();
- if (Strings.isEmpty(defaultValue)) {
+
+ private void setDefaultValue(PropertyBase attribute, AnnotationMirror attributeAnnotarion) {
+ SourceUtils utils = utilsProvider.get();
+ String defaultValue;
+ // TODO - move to model validator.
+ if (utils.isDefaultValue(attributeAnnotarion, "defaultValue")) {
if (attribute.getType().isPrimitive()) {
String pimitiveDefaultValue = getPimitiveDefaultValue(attribute.getType().getName());
- if (pimitiveDefaultValue != null) {
- attribute.setDefaultValue(pimitiveDefaultValue);
- }
+ attribute.setDefaultValue(pimitiveDefaultValue);
}
} else {
- if (STRING_NAME.equals(attribute.getType().toString())) {
- defaultValue = "\"" + defaultValue + "\"";
+ defaultValue = utils.getAnnotationValue(attributeAnnotarion, "defaultValue", String.class);
+ if (STRING_TYPE.equals(attribute.getType())) {
+ defaultValue = JavaUtils.getEscapedString(defaultValue);
}
attribute.setDefaultValue(defaultValue);
}
@@ -154,51 +150,33 @@
return byteClass.getSimpleName().equals(typeName);
}
- private MethodSignature getSignature(Signature signature) {
+ private MethodSignature getSignature(AnnotationMirror attributeAnnotarion) {
- ClassName returnType;
+ SourceUtils utils = utilsProvider.get();
- try {
- returnType = ClassName.get(signature.returnType());
- } catch (MirroredTypeException e) {
- TypeMirror returnTypeMirror = e.getTypeMirror();
- returnType = ClassName.get(returnTypeMirror.toString());
- }
+ if (!utils.isDefaultValue(attributeAnnotarion, "signature")) {
+ AnnotationMirror signatureAnnotation =
+ utils.getAnnotationValue(attributeAnnotarion, "signature", AnnotationMirror.class);
+ ClassName returnType = utils.getAnnotationValue(signatureAnnotation, "returnType", ClassName.class);
- if (!SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
- MethodSignature methodSignature = new MethodSignature();
- methodSignature.setParameters(getSignatureParams(signature));
- methodSignature.setReturnType(returnType);
- return methodSignature;
+ if (!SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
+ MethodSignature methodSignature = new MethodSignature();
+ methodSignature.setParameters(utils.getAnnotationValues(signatureAnnotation, "parameters",
+ ClassName.class));
+ methodSignature.setReturnType(returnType);
+ return methodSignature;
+ }
}
-
return null;
}
- private List<ClassName> getSignatureParams(Signature signature) {
- List<ClassName> parameters = Lists.newArrayList();
- try {
- for (Class<?> parameterType : signature.parameters()) {
- parameters.add(ClassName.get(parameterType));
- }
- } catch (MirroredTypeException e) {
- parameters.add(ClassName.get(e.getTypeMirror().toString()));
- } catch (MirroredTypesException e) {
- for (TypeMirror parameterType : e.getTypeMirrors()) {
- parameters.add(new ClassName(parameterType.toString()));
- }
- }
-
- return parameters;
- }
-
- private void setBehaviorEvent(PropertyBase attribute, EventName eventName) {
- if (null != eventName) {
+ private void setBehaviorEvent(PropertyBase attribute, AnnotationMirror eventMirror) {
+ if (null != eventMirror) {
+ SourceUtils utils = utilsProvider.get();
org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
-
- event.setName(eventName.value());
- event.setDefaultEvent(eventName.defaultEvent());
+ utils.setModelProperty(event, eventMirror, "name", "value");
+ utils.setModelProperty(event, eventMirror, "defaultEvent");
attribute.getEventNames().add(event);
}
}
@@ -223,7 +201,7 @@
} catch (CdkException e) {
log.error(e);
} catch (FileNotFoundException e) {
- log.debug("No properties description found at "+uri);
+ log.debug("No properties description found at " + uri);
}
}
@@ -255,7 +233,7 @@
} catch (CdkException e) {
log.error(e);
} catch (FileNotFoundException e) {
- log.debug("No properties description found at "+attributes);
+ log.debug("No properties description found at " + attributes);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/PropertyUtils.java 2010-07-28 23:37:47 UTC (rev 18273)
@@ -23,6 +23,12 @@
package org.richfaces.cdk.util;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.NoSuchElementException;
+
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.InvalidNameException;
/**
@@ -47,4 +53,33 @@
throw new InvalidNameException("Method name " + methodName + " is not valid bean property getter or setter");
}
+
+ public static void setPropertyValue(Object bean,String propertyName,Object newValue){
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor(bean, propertyName);
+ if(null != propertyDescriptor.getWriteMethod()){
+ try {
+ propertyDescriptor.getWriteMethod().invoke(bean, newValue);
+ } catch (Exception e) {
+ throw new CdkException("Cannot set new value for bean property "+bean.getClass().getName()+"#"+propertyName,e);
+ }
+ } else {
+ throw new CdkException("Bean property not writable "+bean.getClass().getName()+"#"+propertyName);
+
+ }
+ }
+
+ public static PropertyDescriptor getPropertyDescriptor(Object bean,String propertyName){
+ PropertyDescriptor[] properties;
+ try {
+ properties = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors();
+ } catch (IntrospectionException e) {
+ throw new CdkException(e);
+ }
+ for (PropertyDescriptor propertyDescriptor : properties) {
+ if(propertyName.equals(propertyDescriptor.getName())){
+ return propertyDescriptor;
+ }
+ }
+ throw new NoSuchElementException("Bean property "+propertyName+" not found in class "+bean.getClass().getName());
+ }
}
14 years, 7 months
JBoss Rich Faces SVN: r18272 - in root/cdk/trunk/plugins/generator/src: test/java/org/richfaces/cdk/apt and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-28 19:37:31 -0400 (Wed, 28 Jul 2010)
New Revision: 18272
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
Log:
AptSourceUtils passed all annotation tests
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -7,7 +7,9 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.Map.Entry;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
@@ -22,11 +24,15 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import com.google.inject.Inject;
public class AptSourceUtils implements SourceUtils {
@@ -235,39 +241,72 @@
return null != element.getAnnotation(annotationType);
}
+
@Override
+ public boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName){
+ return Iterables.any(getAnnotationValuesMap(annotation).entrySet(), new AnnotationAttributePredicate(propertyName));
+ }
+
+ @Override
public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
- // TODO Auto-generated method stub
- return false;
+ Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
+ findAnnotationProperty(annotation, propertyName);
+ return !annotation.getElementValues().containsKey(attributeEntry.getKey());
}
+ @SuppressWarnings("unchecked")
@Override
public <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
- Map<? extends ExecutableElement, ? extends AnnotationValue> elements = processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry : elements.entrySet()) {
- if(attributeEntry.getKey().getSimpleName().toString().equals(propertyName)){
- AnnotationValue annotationValue = attributeEntry.getValue();
- if(Enum.class.isAssignableFrom(expectedType)){
- VariableElement variable = (VariableElement) annotationValue.getValue();
- Object constantValue = variable.getConstantValue();
- // TODO - properly convert into enum value.
- return (T) Enum.valueOf((Class<? extends Enum>) expectedType, (String)constantValue);
- } else if(ClassName.class.equals(expectedType)){
- TypeMirror value = (TypeMirror) annotationValue.getValue();
- return (T) ClassName.get(value.toString());
- }
- return (T) annotationValue.getValue();
- }
+ Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
+ findAnnotationProperty(annotation, propertyName);
+ AnnotationValue annotationValue = attributeEntry.getValue();
+ return convertAnnotationValue(expectedType, annotationValue);
+ }
+
+ private <T> T convertAnnotationValue(Class<T> expectedType, AnnotationValue annotationValue) {
+ if (Enum.class.isAssignableFrom(expectedType)) {
+ VariableElement variable = (VariableElement) annotationValue.getValue();
+ return (T) Enum.valueOf((Class<? extends Enum>) expectedType, variable.getSimpleName().toString());
+ } else if (ClassName.class.equals(expectedType)) {
+ TypeMirror value = (TypeMirror) annotationValue.getValue();
+ return (T) ClassName.get(value.toString());
+ } else if (AnnotationMirror.class.isAssignableFrom(expectedType)) {
+ AnnotationMirror value = (AnnotationMirror) annotationValue.getValue();
+ return (T) value;
+ } else {
+ // TODO - check value for expected type.
+ return (T) annotationValue.getValue();
}
- return null;
}
+ @SuppressWarnings("unchecked")
@Override
public <T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
- // TODO Auto-generated method stub
- return null;
+ Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
+ findAnnotationProperty(annotation, propertyName);
+ List<? extends AnnotationValue>annotationValues = (List<? extends AnnotationValue>) attributeEntry.getValue().getValue();
+ List<T> values = Lists.newArrayList();
+ for (AnnotationValue annotationValue : annotationValues) {
+ values.add(convertAnnotationValue(expectedType, annotationValue));
+ }
+ return values;
}
+ private Entry<? extends ExecutableElement, ? extends AnnotationValue> findAnnotationProperty(
+ AnnotationMirror annotation, final String propertyName) {
+ try {
+ return Iterables.find(getAnnotationValuesMap(annotation).entrySet(),
+ new AnnotationAttributePredicate(propertyName));
+ } catch (NoSuchElementException e) {
+ throw new CdkException("Attribute " + propertyName + " not found for annotation "
+ + annotation.getAnnotationType().toString());
+ }
+ }
+
+ private Map<? extends ExecutableElement, ? extends AnnotationValue> getAnnotationValuesMap(AnnotationMirror annotation) {
+ return processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
+ }
+
public Object getConstant(TypeElement componentElement, String name) {
List<VariableElement> fieldsIn =
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
@@ -310,6 +349,21 @@
}
}
+ private static final class AnnotationAttributePredicate implements
+ Predicate<Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> {
+ private final String propertyName;
+
+ private AnnotationAttributePredicate(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ @Override
+ public boolean apply(Entry<? extends ExecutableElement, ? extends AnnotationValue> input) {
+
+ return this.propertyName.equals(input.getKey().getSimpleName().toString());
+ }
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -114,5 +114,9 @@
return false;
}
+ public boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName) {
+ return false;
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -216,4 +216,6 @@
*/
TypeElement asTypeElement(ClassName type);
+ public abstract boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName);
+
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -2,12 +2,16 @@
import static org.junit.Assert.*;
+import java.util.List;
import java.util.Set;
import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import org.junit.Test;
+import org.richfaces.cdk.apt.TestAnnotation.TestEnum;
+import org.richfaces.cdk.model.ClassName;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
@@ -23,36 +27,138 @@
@Test
public void testGetAnnotationMirror() {
- fail("Not yet implemented");
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ assertNotNull(annotationMirror);
+ assertEquals(TestAnnotation.class.getName(), annotationMirror.getAnnotationType().toString());
+ }
+ });
}
@Test
public void testIsAnnotationPresent() {
- setCallback(new SourceUtilsCallback() {
-
+ execute(new SourceUtilsCallback() {
@Override
public void process(SourceUtils utils, RoundEnvironment roundEnv) {
assertTrue(utils.isAnnotationPresent(findElement(roundEnv, ANNOTATIONS_TEST_CLASS), TestAnnotation.class));
}
});
- execute();
}
@Test
public void testIsDefaultValue() {
- fail("Not yet implemented");
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ assertTrue(utils.isDefaultValue(annotationMirror, "withDefault"));
+ }
+ });
}
@Test
- public void testGetAnnotationValue() {
- fail("Not yet implemented");
+ public void testNotIsDefaultValue() {
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ assertFalse(utils.isDefaultValue(annotationMirror, "value"));
+ }
+ });
}
@Test
+ public void testIsAnnotationPropertyPresent() {
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ assertTrue(utils.isAnnotationPropertyPresent(annotationMirror, "value"));
+ }
+ });
+ }
+
+ @Test
+ public void testNotIsAnnotationPropertyPresent() {
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ assertFalse(utils.isAnnotationPropertyPresent(annotationMirror, "notExistedProperty"));
+ }
+ });
+ }
+
+ @Test
+ public void testGetStringAnnotationValue() {
+ getAndCompareAnnotationValue("value", String.class, "foo");
+ }
+
+ @Test
+ public void testGetBooleanAnnotationValue() {
+ getAndCompareAnnotationValue("booleanProperty", Boolean.class, Boolean.TRUE);
+ }
+
+ @Test
+ public void testGetEnumAnnotationValue() {
+ getAndCompareAnnotationValue("enumProperty", TestAnnotation.TestEnum.class, TestEnum.BAR);
+ }
+
+ @Test
+ public void testGetClassAnnotationValue() {
+ getAndCompareAnnotationValue("typeProperty", ClassName.class, ClassName.get(PACKAGE_PATH.replace('/', '.')+ANNOTATIONS_TEST_SUB_CLASS));
+ }
+
+ @Test
+ public void testGetDefaultStringAnnotationValue() {
+ getAndCompareAnnotationValue("withDefault", String.class, "FOO");
+ }
+
+ public <T> void getAndCompareAnnotationValue(final String propertyName,final Class<T> type, final Object expected) {
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ T annotationValue = utils.getAnnotationValue(annotationMirror, propertyName, type);
+ assertEquals("Annotation value is different from expected",expected, annotationValue);
+ }
+ });
+ }
+
+ public <T> void getAndCompareAnnotationValues(final String propertyName,final Class<T> type, final Object ... expected) {
+ execute(new SourceUtilsCallback() {
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
+ AnnotationMirror annotationMirror = utils.getAnnotationMirror(element, TestAnnotation.class);
+ List<T> annotationValues = utils.getAnnotationValues(annotationMirror, propertyName, type);
+ assertEquals("Annotation values size is different from expected",expected.length, annotationValues.size());
+ for (int i = 0; i < expected.length; i++) {
+ Object expectedValue = expected[i];
+ assertEquals("Annotation value at position "+i+" is different from expected",expectedValue, annotationValues.get(i));
+ }
+ }
+ });
+ }
+
+ @Test
public void testGetAnnotationValues() {
- fail("Not yet implemented");
+ getAndCompareAnnotationValues("emptyStrings", String.class);
}
+ @Test
+ public void testGetClassAnnotationValues() {
+ getAndCompareAnnotationValues("types", ClassName.class,ClassName.get(String.class),ClassName.get(Object.class));
+ }
+
@Override
protected Iterable<String> sources() {
return ImmutableList.of(CLASS_JAVA, SUB_CLASS_JAVA);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -71,11 +71,9 @@
binder.bind(CdkProcessor.class).to(TestProcessor.class).in(Singleton.class);
}
- protected void setCallback(SourceUtilsCallback callback){
- ((TestProcessor)processor).callback = callback;
- }
- protected void execute(){
+ protected void execute(SourceUtilsCallback callback){
+ ((TestProcessor)processor).callback = callback;
assertTrue("Compilation error",factory.get().call());
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TestAnnotation.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -39,5 +39,23 @@
@Documented
@Target(ElementType.TYPE)
public @interface TestAnnotation {
- public String value();
+
+ public enum TestEnum {
+ FOO,
+ BAR
+ }
+
+ String value();
+
+ String withDefault() default "FOO";
+
+ boolean booleanProperty() default true;
+
+ TestEnum enumProperty() default TestEnum.BAR;
+
+ Class<?> typeProperty();
+
+ String[] emptyStrings() default {};
+
+ Class<?>[] types() default {String.class,Object.class};
}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java 2010-07-28 23:37:11 UTC (rev 18271)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java 2010-07-28 23:37:31 UTC (rev 18272)
@@ -30,5 +30,5 @@
* @author asmirnov(a)exadel.com
*
*/
-@TestAnnotation("foo")
+@TestAnnotation(value="foo",typeProperty=AnnotationsTestSubClass.class)
public class AnnotationsTestClass {}
14 years, 7 months
JBoss Rich Faces SVN: r18271 - in root/cdk/trunk/plugins/generator/src: test/java/org/richfaces/cdk/apt and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-28 19:37:11 -0400 (Wed, 28 Jul 2010)
New Revision: 18271
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java
Removed:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
Log:
https://jira.jboss.org/browse/RF-8975
work in progress: unit tests
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -236,6 +236,12 @@
}
@Override
+ public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
public <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
Map<? extends ExecutableElement, ? extends AnnotationValue> elements = processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry : elements.entrySet()) {
@@ -246,6 +252,9 @@
Object constantValue = variable.getConstantValue();
// TODO - properly convert into enum value.
return (T) Enum.valueOf((Class<? extends Enum>) expectedType, (String)constantValue);
+ } else if(ClassName.class.equals(expectedType)){
+ TypeMirror value = (TypeMirror) annotationValue.getValue();
+ return (T) ClassName.get(value.toString());
}
return (T) annotationValue.getValue();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -108,5 +108,11 @@
return null;
}
+ @Override
+ public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -172,6 +172,13 @@
<T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType);
/**
+ * <p class="changed_added_4_0">Check annotation proprrty for default value.</p>
+ * @param annotation
+ * @param propertyName
+ * @return true if property has its default value.
+ */
+ boolean isDefaultValue(AnnotationMirror annotation, String propertyName);
+ /**
* <p class="changed_added_4_0">
* </p>
*
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java (from rev 18270, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTestBase.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -0,0 +1,151 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.apt;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.ELContext;
+import javax.faces.component.UIComponent;
+import javax.lang.model.element.Name;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Generator;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.MockController;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.SourceFileManagerImpl;
+import org.richfaces.cdk.SourceImpl;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.apt.processors.ComponentProcessor;
+import org.richfaces.cdk.model.ComponentModel;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+public abstract class AnnotationProcessorTestBase extends CdkTestBase {
+
+ protected static final class TestName implements Name {
+
+ private final String name;
+
+ public TestName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public char charAt(int index) {
+ return name.charAt(index);
+ }
+
+ @Override
+ public boolean contentEquals(CharSequence cs) {
+ // TODO Auto-generated method stub
+ return name.equals(cs);
+ }
+
+ @Override
+ public int length() {
+ return name.length();
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return name.substring(start, end);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ protected static final String FOO_BAR = "foo.Bar";
+
+ @Inject
+ protected Logger log;
+
+ @Inject
+ @Source(Sources.JAVA_SOURCES)
+ protected FileManager sources;
+
+ @Inject
+ protected MockController mockController;
+
+ @Inject
+ private Injector injector;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader cdkClassLoader = createClassLoader();
+ binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
+ List<File> sourceFiles = new ArrayList<File>();
+ for (String src : sources()) {
+ sourceFiles.add(getJavaFile(src));
+ }
+ binder.bind(FileManager.class).annotatedWith(new SourceImpl(Sources.JAVA_SOURCES)).toInstance(
+ new SourceFileManagerImpl(sourceFiles, this.testSourceDirectory));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ @Override
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class),
+ getLibraryFile(JsfComponent.class), getLibraryFile(UIComponent.class)), this.getClass()
+ .getClassLoader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void process(String javaFilePath) throws Exception {
+ Generator generator = new Generator();
+ generator.setLoader(createClassLoader());
+ generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
+
+ generator.init();
+ injector.injectMembers(new ComponentProcessor());
+
+ LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
+ builder.build();
+ }
+
+ protected abstract Iterable<String> sources();
+}
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -0,0 +1,71 @@
+package org.richfaces.cdk.apt;
+
+import static org.junit.Assert.*;
+
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+
+import org.junit.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class AptSourceUtilsAnnotationsTest extends SourceUtilsTestBase {
+
+ private static final String ANNOTATIONS_TEST_SUB_CLASS = "AnnotationsTestSubClass";
+ private static final String ANNOTATIONS_TEST_CLASS = "AnnotationsTestClass";
+ private static final String PACKAGE_PATH = "org/richfaces/cdk/apt/";
+ private static final String CLASS_JAVA = PACKAGE_PATH + ANNOTATIONS_TEST_CLASS + ".java";
+ private static final String SUB_CLASS_JAVA = PACKAGE_PATH + ANNOTATIONS_TEST_SUB_CLASS + ".java";
+
+ @Test
+ public void testGetAnnotationMirror() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testIsAnnotationPresent() {
+ setCallback(new SourceUtilsCallback() {
+
+ @Override
+ public void process(SourceUtils utils, RoundEnvironment roundEnv) {
+ assertTrue(utils.isAnnotationPresent(findElement(roundEnv, ANNOTATIONS_TEST_CLASS), TestAnnotation.class));
+ }
+ });
+ execute();
+ }
+
+ @Test
+ public void testIsDefaultValue() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testGetAnnotationValue() {
+ fail("Not yet implemented");
+ }
+
+ @Test
+ public void testGetAnnotationValues() {
+ fail("Not yet implemented");
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return ImmutableList.of(CLASS_JAVA, SUB_CLASS_JAVA);
+ }
+
+ private Element findElement(RoundEnvironment roundEnvironment, final String name){
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
+ return Iterables.find(elements, new Predicate<Element>() {
+
+ @Override
+ public boolean apply(Element input) {
+ return name.equals(input.getSimpleName().toString());
+ }
+ });
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -44,7 +44,6 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -63,7 +62,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class CdkProcessorTest extends AnnotationProcessorTest {
+public class CdkProcessorTest extends AnnotationProcessorTestBase {
private static final String ANNOTATION2 = TestAnnotation2.class.getName();
private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -0,0 +1,126 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.apt;
+
+import static junit.framework.Assert.*;
+
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Output;
+import org.richfaces.cdk.Outputs;
+import org.richfaces.cdk.Stub;
+
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public abstract class SourceUtilsTestBase extends AnnotationProcessorTestBase {
+
+ @Inject
+ protected CdkProcessor processor;
+
+ @Inject
+ protected TaskFactoryImpl factory;
+
+ @Stub
+ @Output(Outputs.JAVA_CLASSES)
+ protected FileManager output;
+
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(CdkProcessor.class).to(TestProcessor.class).in(Singleton.class);
+ }
+
+ protected void setCallback(SourceUtilsCallback callback){
+ ((TestProcessor)processor).callback = callback;
+ }
+
+ protected void execute(){
+ assertTrue("Compilation error",factory.get().call());
+ }
+
+ /**
+ * <p class="changed_added_4_0">Interface to call back test method from APT</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public interface SourceUtilsCallback {
+ void process(SourceUtils utils, RoundEnvironment roundEnv);
+ }
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SupportedSourceVersion(SourceVersion.RELEASE_6)
+ @SupportedAnnotationTypes("*")
+ public static class TestProcessor extends AbstractProcessor implements CdkProcessor {
+
+ @Inject
+ protected SourceUtilsProvider sourceUtilsProvider;
+
+ SourceUtilsCallback callback;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ sourceUtilsProvider.setProcessingEnv(processingEnv);
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if(!roundEnv.processingOver()){
+ callback.process(sourceUtilsProvider.get(), roundEnv);
+ }
+ return false;
+ }
+
+ @Override
+ public void processNonJavaSources() {
+ // do nothing
+ }
+
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -46,7 +46,6 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
-import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
@@ -59,7 +58,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class TaskFactoryTest extends AnnotationProcessorTest {
+public class TaskFactoryTest extends AnnotationProcessorTestBase {
private static final String CLASS_JAVA = "org/richfaces/cdk/apt/TestClass.java";
private static final String INTERFACE_JAVA = "org/richfaces/cdk/apt/TestInterface.java";
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -1,146 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.apt.processors;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.el.ELContext;
-import javax.faces.component.UIComponent;
-import javax.lang.model.element.Name;
-
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Generator;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.SourceFileManagerImpl;
-import org.richfaces.cdk.SourceImpl;
-import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.model.ComponentModel;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-
-/**
- * @author akolonitsky
- * @since Jan 14, 2010
- */
-public abstract class AnnotationProcessorTest extends CdkTestBase {
-
- protected static final class TestName implements Name {
-
- private final String name;
-
- public TestName(String name) {
- this.name = name;
- }
-
- @Override
- public char charAt(int index) {
- return name.charAt(index);
- }
-
- @Override
- public boolean contentEquals(CharSequence cs) {
- // TODO Auto-generated method stub
- return name.equals(cs);
- }
-
- @Override
- public int length() {
- return name.length();
- }
-
- @Override
- public CharSequence subSequence(int start, int end) {
- return name.substring(start, end);
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
- protected static final String FOO_BAR = "foo.Bar";
-
- @Inject
- protected Logger log;
-
- @Inject
- @Source(Sources.JAVA_SOURCES)
- protected FileManager sources;
-
- @Inject
- private Injector injector;
-
- @Override
- public void configure(Binder binder) {
- super.configure(binder);
- try {
- CdkClassLoader cdkClassLoader = createClassLoader();
- binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
- List<File> sourceFiles = new ArrayList<File>();
- for (String src : sources()) {
- sourceFiles.add(getJavaFile(src));
- }
- binder.bind(FileManager.class).annotatedWith(new SourceImpl(Sources.JAVA_SOURCES)).toInstance(
- new SourceFileManagerImpl(sourceFiles, this.testSourceDirectory));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-
- @Override
- protected CdkClassLoader createClassLoader() {
- try {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class),
- getLibraryFile(JsfComponent.class), getLibraryFile(UIComponent.class)), this.getClass()
- .getClassLoader());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void process(String javaFilePath) throws Exception {
- Generator generator = new Generator();
- generator.setLoader(createClassLoader());
- generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
-
- generator.init();
- injector.injectMembers(new ComponentProcessor());
-
- LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
- builder.build();
- }
-
- protected abstract Iterable<String> sources();
-}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -36,8 +36,8 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.MockController;
import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
@@ -58,7 +58,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class AttributesProcessorTest extends AnnotationProcessorTest {
+public class AttributesProcessorTest extends AnnotationProcessorTestBase {
private static final String FOO = "foo";
@@ -68,9 +68,6 @@
private DescriptionProcessor descriptionProcessor;
@Inject
- private MockController mockController;
-
- @Inject
private AttributesProcessorImpl processor;
@Mock
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -43,6 +43,7 @@
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
@@ -58,7 +59,7 @@
* @since Jan 21, 2010
*/
@RunWith(CdkTestRunner.class)
-public class BehaviorProcessorTest extends AnnotationProcessorTest {
+public class BehaviorProcessorTest extends AnnotationProcessorTestBase {
private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
private static final String MY_BEHAVIOR = "my_behavior";
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -43,6 +43,7 @@
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.annotations.Facet;
import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -62,7 +63,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class ComponentProcessorTest extends AnnotationProcessorTest {
+public class ComponentProcessorTest extends AnnotationProcessorTestBase {
public static final String LARGE_GIF = "/icons/Large.gif";
public static final String SMALL_JPG = "/icons/Small.jpg";
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -30,6 +30,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
@@ -42,7 +43,7 @@
* @since Jan 14, 2010
*/
@RunWith(CdkTestRunner.class)
-public class ConverterProcessorTest extends AnnotationProcessorTest {
+public class ConverterProcessorTest extends AnnotationProcessorTestBase {
private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/MyConverter.java";
@Inject
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -31,8 +31,8 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.MockController;
import org.richfaces.cdk.annotations.Description;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.DescriptionGroup;
import com.google.inject.Inject;
@@ -45,7 +45,7 @@
*
*/
@RunWith(CdkTestRunner.class)
-public class DescriptionProcessorTest extends AnnotationProcessorTest {
+public class DescriptionProcessorTest extends AnnotationProcessorTestBase {
private static final String FOO_BAR_ELEMENT = "Foo bar element";
@@ -60,9 +60,6 @@
@Inject
private DescriptionProcessorImpl descriptionProcessor;
- @Inject
- private MockController mockController;
-
/**
* Test method for
* {@link org.richfaces.cdk.apt.processors.DescriptionProcessorImpl#processDescription(org.richfaces.cdk.model.DescriptionGroup, org.richfaces.cdk.annotations.Description, java.lang.String)}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-07-28 23:36:46 UTC (rev 18270)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -39,6 +39,7 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.annotations.JsfValidator;
+import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
@@ -50,7 +51,7 @@
* @since Jan 14, 2010
*/
@RunWith(CdkTestRunner.class)
-public class ValidatorProcessorTest extends AnnotationProcessorTest {
+public class ValidatorProcessorTest extends AnnotationProcessorTestBase {
private static class MyName implements Name {
private final String toString;
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestClass.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.cdk.apt;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@TestAnnotation("foo")
+public class AnnotationsTestClass {}
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/apt/AnnotationsTestSubClass.java 2010-07-28 23:37:11 UTC (rev 18271)
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.cdk.apt;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@TestAnnotation2("subclass")
+public class AnnotationsTestSubClass extends TestClass implements TestInterface {
+
+ private String value;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param value the value to set
+ */
+ @TestMethodAnnotation("setter")
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+}
14 years, 7 months
JBoss Rich Faces SVN: r18270 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-28 19:36:46 -0400 (Wed, 28 Jul 2010)
New Revision: 18270
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
Log:
https://jira.jboss.org/browse/RF-8975
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:02:49 UTC (rev 18269)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
@@ -11,6 +11,7 @@
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
@@ -215,6 +216,49 @@
return this.processingEnv.getElementUtils().getDocComment(componentElement);
}
+ @Override
+ public AnnotationMirror getAnnotationMirror(Element element, Class<? extends Annotation> annotationType) {
+ List<? extends AnnotationMirror> annotationMirrors =
+ processingEnv.getElementUtils().getAllAnnotationMirrors(element);
+ TypeMirror annotationTypeMirror =
+ processingEnv.getElementUtils().getTypeElement(annotationType.getName()).asType();
+ for (AnnotationMirror annotationMirror : annotationMirrors) {
+ if (processingEnv.getTypeUtils().isSameType(annotationTypeMirror, annotationMirror.getAnnotationType())) {
+ return annotationMirror;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Element element, Class<? extends Annotation> annotationType) {
+ return null != element.getAnnotation(annotationType);
+ }
+
+ @Override
+ public <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
+ Map<? extends ExecutableElement, ? extends AnnotationValue> elements = processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry : elements.entrySet()) {
+ if(attributeEntry.getKey().getSimpleName().toString().equals(propertyName)){
+ AnnotationValue annotationValue = attributeEntry.getValue();
+ if(Enum.class.isAssignableFrom(expectedType)){
+ VariableElement variable = (VariableElement) annotationValue.getValue();
+ Object constantValue = variable.getConstantValue();
+ // TODO - properly convert into enum value.
+ return (T) Enum.valueOf((Class<? extends Enum>) expectedType, (String)constantValue);
+ }
+ return (T) annotationValue.getValue();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public <T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
public Object getConstant(TypeElement componentElement, String name) {
List<VariableElement> fieldsIn =
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(componentElement));
@@ -362,8 +406,8 @@
return exists;
}
- public List<? extends AnnotationMirror> getAnnotationMirrors() {
- return element.getAnnotationMirrors();
+ public AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType) {
+ return AptSourceUtils.this.getAnnotationMirror(element, annotationType);
}
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:02:49 UTC (rev 18269)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
@@ -24,8 +24,10 @@
package org.richfaces.cdk.apt;
import java.lang.annotation.Annotation;
+import java.util.List;
import java.util.Set;
+import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
@@ -82,5 +84,29 @@
}
+ @Override
+ public AnnotationMirror getAnnotationMirror(Element element, Class<? extends Annotation> annotationType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ @Override
+ public boolean isAnnotationPresent(Element element, Class<? extends Annotation> annotationType) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:02:49 UTC (rev 18269)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-07-28 23:36:46 UTC (rev 18270)
@@ -37,118 +37,176 @@
import com.google.inject.ProvidedBy;
/**
- * <p class="changed_added_4_0">This class provides utility methods to analayze java classes. This implementation uses APT API to get
- * information about Java code.</p>
+ * <p class="changed_added_4_0">
+ * This class provides utility methods to analayze java classes. This implementation uses APT API to get information
+ * about Java code.
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
@ProvidedBy(SourceUtilsProvider.class)
-public interface SourceUtils {
-
-
+public interface SourceUtils {
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface SuperTypeVisitor {
- public void visit(TypeMirror type);
+ void visit(TypeMirror type);
}
-
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public interface BeanProperty {
-
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the name
*/
- public String getName();
-
+ String getName();
+
/**
- * <p class="changed_added_4_0">Get JavaDoc comment of appropriate bean property element.</p>
+ * <p class="changed_added_4_0">
+ * Get JavaDoc comment of appropriate bean property element.
+ * </p>
+ *
* @return
*/
- public String getDocComment();
-
- public ClassName getType();
-
+ String getDocComment();
+
+ ClassName getType();
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the exists
*/
- public boolean isExists();
+ boolean isExists();
- public List<? extends AnnotationMirror> getAnnotationMirrors();
+ AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType);
- public <T extends Annotation> T getAnnotation(Class<T> annotationType);
+ <T extends Annotation> T getAnnotation(Class<T> annotationType);
}
-
/**
* <p class="changed_added_4_0">
- * Get all fields and bean properties that are annotated with given
- * annotation.
+ * Get all fields and bean properties that are annotated with given annotation.
* </p>
- *
+ *
* @param annotation
* @param type
* @return
*/
- public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
- TypeElement type);
+ Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation, TypeElement type);
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param type
* @return
*/
- public Set<BeanProperty> getAbstractBeanProperties(TypeElement type);
+ Set<BeanProperty> getAbstractBeanProperties(TypeElement type);
/**
- * <p class="changed_added_4_0">Get JavaDoc comments associated with given element.</p>
+ * <p class="changed_added_4_0">
+ * Get JavaDoc comments associated with given element.
+ * </p>
+ *
* @param componentElement
* @return
*/
- public String getDocComment(Element element);
+ String getDocComment(Element element);
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * Check model element for presense of annotation.
+ * </p>
+ *
+ * @param element
+ * @param annotationType
+ * @return
+ */
+ boolean isAnnotationPresent(Element element, Class<? extends Annotation> annotationType);
+
+ /**
+ * <p class="changed_added_4_0">
+ * Get model representation of the annotation for given model element
+ * </p>
+ *
+ * @param annotationType
+ * @return
+ */
+ AnnotationMirror getAnnotationMirror(Element element, Class<? extends Annotation> annotationType);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param annotation
+ * @param propertyName
+ * @return
+ */
+ <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param annotation
+ * @param propertyName
+ * @return
+ */
+ <T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param componentElement
* @param name
* @return
*/
- public Object getConstant(TypeElement element, String name);
-
-
+ Object getConstant(TypeElement element, String name);
+
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param type
* @param visitor
*/
- public void visitSupertypes(TypeElement type, SuperTypeVisitor visitor);
+ void visitSupertypes(TypeElement type, SuperTypeVisitor visitor);
/**
- * <p class="changed_added_4_0">Converts TypeMirror into corresponding TypeElement</p>
+ * <p class="changed_added_4_0">
+ * Converts TypeMirror into corresponding TypeElement
+ * </p>
+ *
* @param mirror
* @return
*/
- public TypeElement asTypeElement(TypeMirror mirror);
+ TypeElement asTypeElement(TypeMirror mirror);
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param type
* @return
*/
- public TypeElement asTypeElement(ClassName type);
-
+ TypeElement asTypeElement(ClassName type);
+
}
14 years, 7 months
JBoss Rich Faces SVN: r18269 - in root/examples-sandbox/trunk/richfaces-showcase-gae: src/main/webapp/WEB-INF and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-28 19:02:49 -0400 (Wed, 28 Jul 2010)
New Revision: 18269
Modified:
root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml
Log:
Added missing dependencies
Enabled sessions
Copied web.xml from richfaces-showcase
Modified: root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml 2010-07-28 23:01:27 UTC (rev 18268)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml 2010-07-28 23:02:49 UTC (rev 18269)
@@ -141,6 +141,18 @@
<version>4.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ <type>jar</type>
+ </dependency>
</dependencies>
<!-- Build Settings -->
Modified: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml 2010-07-28 23:01:27 UTC (rev 18268)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml 2010-07-28 23:02:49 UTC (rev 18269)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>richfaces-showcase-gae</application>
- <version>3</version>
+ <version>4</version>
+ <sessions-enabled>true</sessions-enabled>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties"/>
Modified: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml 2010-07-28 23:01:27 UTC (rev 18268)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml 2010-07-28 23:02:49 UTC (rev 18269)
@@ -1,12 +1,73 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version="2.5">
-
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
-
-</web-app>
+<?xml version="1.0" encoding="utf-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <context-param>
+ <param-name>org.richfaces.enableControlSkinning</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.enableControlSkinningClasses</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.skin</param-name>
+ <param-value>#{skinBean.skin}</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <description>
+ Set this flag to true if you want the JavaServer Faces
+ Reference Implementation to validate the XML in your
+ faces-config.xml resources against the DTD. Default
+ value is false.
+ </description>
+ <param-name>com.sun.faces.validateXml</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <!-- ***** Accommodate Single-Threaded Requirement of Google AppEngine -->
+ <context-param>
+ <description>
+ When enabled, the runtime initialization and default ResourceHandler
+ implementation will use threads to perform their functions. Set this
+ value to false if threads aren't desired (as in the case of running
+ within the Google Application Engine).
+
+ Note that when this option is disabled, the ResourceHandler will not
+ pick up new versions of resources when ProjectStage is development.
+ </description>
+ <param-name>com.sun.faces.enableThreading</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.expressionFactory</param-name>
+ <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
14 years, 7 months
JBoss Rich Faces SVN: r18268 - in root/cdk-sandbox/trunk/dynamic-resources-prerenderer: src/it/richfaces-application and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-28 19:01:27 -0400 (Wed, 28 Jul 2010)
New Revision: 18268
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/config/
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResource.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
Log:
Dynamic resources prerenderer: added filtering by content types
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-28 23:01:27 UTC (rev 18268)
@@ -73,6 +73,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
+ <version>r06</version>
</dependency>
<dependency>
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/it/richfaces-application/pom.xml 2010-07-28 23:01:27 UTC (rev 18268)
@@ -25,10 +25,27 @@
<skins>
<skin>blueSky</skin>
<skin>classic</skin>
+ <skin>deepMarine</skin>
+ <skin>emeraldTown</skin>
+ <skin>japanCherry</skin>
<skin>ruby</skin>
- <skin>emeraldTown</skin>
<skin>wine</skin>
</skins>
+ <includedContentTypes>
+ <include>text/javascript</include>
+ <include>text/css</include>
+ <include>image/.+</include>
+ </includedContentTypes>
+ <fileNameMappings>
+ <property>
+ <name>^org\.richfaces\.renderkit\.html\.(images\.)?</name>
+ <value>org.richfaces/images/</value>
+ </property>
+ <property>
+ <name>^css/</name>
+ <value>org.richfaces/css/</value>
+ </property>
+ </fileNameMappings>
</configuration>
</execution>
</executions>
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-07-28 23:01:27 UTC (rev 18268)
@@ -25,14 +25,19 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import javax.faces.application.Resource;
+
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -45,6 +50,11 @@
import org.richfaces.cdk.resource.ResourcesScannerImpl;
import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+
/**
* @goal process
* @requiresDependencyResolution compile
@@ -52,28 +62,80 @@
*/
public class ProcessMojo extends AbstractMojo {
+ private static final Function<String, Predicate<CharSequence>> REGEX_CONTAINS_BUILDER_FUNCTION = new Function<String, Predicate<CharSequence>>() {
+ public Predicate<CharSequence> apply(String from) {
+ return Predicates.containsPattern(from);
+ };
+ };
+
+ private static final Function<Resource, String> CONTENT_TYPE_FUNCTION = new Function<Resource, String>() {
+ public String apply(Resource from) {
+ return from.getContentType();
+ };
+ };
+
/**
* @parameter
* @required
*/
private String outputDir;
-
+
/**
* @parameter
* @required
*/
+ // TODO handle base skins
private String[] skins;
-
+
/**
* @parameter expression="${project}"
* @readonly
*/
private MavenProject project;
-
+
+ /**
+ * @parameter
+ */
+ private List<String> includedContentTypes;
+
+ /**
+ * @parameter
+ */
+ private List<String> excludedContentTypes;
+
+ /**
+ * @parameter
+ */
+ // TODO review usage of properties?
+ private Properties fileNameMappings;
+
+ // TODO executor parameters
private static ExecutorService createExecutorService() {
return Executors.newSingleThreadExecutor();
}
+ private Predicate<Resource> createResourcesFilter() {
+ List<Predicate<CharSequence>> contentTypePredicates = new ArrayList<Predicate<CharSequence>>();
+
+ if (includedContentTypes != null && !includedContentTypes.isEmpty()) {
+ Collection<Predicate<CharSequence>> predicates = Collections2.transform(includedContentTypes, REGEX_CONTAINS_BUILDER_FUNCTION);
+
+ //hack for JDK - the code doesn't compile without this variable
+ Predicate<CharSequence> predicate = Predicates.or(predicates);
+ contentTypePredicates.add(predicate);
+ }
+ if (excludedContentTypes != null && !excludedContentTypes.isEmpty()) {
+ Collection<Predicate<CharSequence>> predicates = Collections2.transform(excludedContentTypes, REGEX_CONTAINS_BUILDER_FUNCTION);
+
+ //hack for JDK - the code doesn't compile without this variable
+ Predicate<CharSequence> predicate = Predicates.or(predicates);
+ predicate = Predicates.not(predicate);
+ contentTypePredicates.add(predicate);
+ }
+
+ return Predicates.compose(Predicates.and(contentTypePredicates), CONTENT_TYPE_FUNCTION);
+ }
+
protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@@ -85,7 +147,7 @@
urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<?> iter = compileClasspathElements.iterator(); iter.hasNext(); ) {
+ for (Iterator<?> iter = compileClasspathElements.iterator(); iter.hasNext();) {
String element = (String) iter.next();
urls[i++] = new File(element).toURI().toURL();
@@ -110,24 +172,24 @@
ClassLoader cCL = Thread.currentThread().getContextClassLoader();
Faces faces = null;
ExecutorService executorService = null;
-
+
try {
ClassLoader projectCL = createProjectClassLoader(project, true);
Thread.currentThread().setContextClassLoader(projectCL);
-
+
File outputDirFile = new File(outputDir);
if (!outputDirFile.exists()) {
outputDirFile = new File(project.getBuild().getOutputDirectory(), outputDir);
}
-
+
ResourceWriterImpl resourceWriter = new ResourceWriterImpl(outputDirFile);
ResourceTaskFactoryImpl taskFactory = new ResourceTaskFactoryImpl();
taskFactory.setResourceWriter(resourceWriter);
// TODO set webroot
- faces = new FacesImpl(null, new FileNameMapperImpl(), taskFactory);
+ faces = new FacesImpl(null, new FileNameMapperImpl(fileNameMappings), taskFactory);
faces.start();
-
+
ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
resourcesScanner.scan();
@@ -136,6 +198,7 @@
taskFactory.setCompletionService(completionService);
taskFactory.setSkins(skins);
taskFactory.setLog(getLog());
+ taskFactory.setFilter(createResourcesFilter());
for (ResourceInfo resourceInfo : resourcesScanner.getResources()) {
taskFactory.submit(resourceInfo);
}
@@ -157,7 +220,7 @@
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
- //TODO review finally block
+ // TODO review finally block
if (executorService != null) {
executorService.shutdown();
}
@@ -167,5 +230,4 @@
Thread.currentThread().setContextClassLoader(cCL);
}
}
-
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-28 23:01:27 UTC (rev 18268)
@@ -23,6 +23,10 @@
import java.util.concurrent.CompletionService;
+import javax.faces.application.Resource;
+
+import com.google.common.base.Predicate;
+
/**
* @author Nick Belaevski
*
@@ -37,6 +41,8 @@
public void setResourceWriter(ResourceWriter resourceWriter);
+ public void setFilter(Predicate<Resource> filter);
+
public void submit(ResourceInfo info);
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-07-28 23:01:27 UTC (rev 18268)
@@ -21,8 +21,9 @@
*/
package org.richfaces.cdk.naming;
-import java.util.Map;
+import java.util.List;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -31,7 +32,7 @@
import org.richfaces.cdk.FileNameMapper;
import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
+import com.google.common.collect.Lists;
/**
* @author Nick Belaevski
@@ -39,12 +40,46 @@
*/
public class FileNameMapperImpl implements FileNameMapper {
- private Map<String, String> mappedPackages = Maps.newLinkedHashMap();
+ private static final class Mapping {
+
+ private Pattern pattern;
+
+ private String replacement;
+
+ public Mapping(Pattern pattern, String replacement) {
+ super();
+ this.pattern = pattern;
+ this.replacement = replacement;
+ }
+
+ public Pattern getPattern() {
+ return pattern;
+ }
+
+ public String getReplacement() {
+ return replacement;
+ }
+ }
- {
- mappedPackages.put("^org\\.richfaces\\.renderkit\\.html\\.(images\\.)?", "org.richfaces/images/");
- mappedPackages.put("^css/", "org/richfaces/css/");
+ private List<Mapping> fileNameMappings;
+
+ public FileNameMapperImpl(Properties fileNameMappings) {
+ super();
+ this.fileNameMappings = compileMappings(fileNameMappings);
}
+
+ private static List<Mapping> compileMappings(Properties properties) {
+ List<Mapping> result = Lists.newArrayList();
+
+ for (Entry<Object, Object> entry: properties.entrySet()) {
+ Pattern pattern = Pattern.compile((String) entry.getKey());
+ String replacement = (String) entry.getValue();
+
+ result.add(new Mapping(pattern, replacement));
+ }
+
+ return result;
+ }
private String stripContentClassifier(String mimeType) {
if (mimeType == null) {
@@ -64,10 +99,10 @@
return name;
}
- for (Entry<String, String> mapping : mappedPackages.entrySet()) {
- Matcher matcher = Pattern.compile(mapping.getKey()).matcher(name);
+ for (Mapping mapping : fileNameMappings) {
+ Matcher matcher = mapping.getPattern().matcher(name);
if (matcher.find()) {
- return matcher.replaceAll(mapping.getValue());
+ return matcher.replaceAll(mapping.getReplacement());
}
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResource.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResource.java 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResource.java 2010-07-28 23:01:27 UTC (rev 18268)
@@ -26,6 +26,8 @@
import java.net.URL;
import java.util.Map;
+import javax.activation.FileTypeMap;
+import javax.activation.MimetypesFileTypeMap;
import javax.faces.application.Resource;
import javax.faces.context.FacesContext;
@@ -68,4 +70,14 @@
public boolean userAgentNeedsUpdate(FacesContext context) {
throw new UnsupportedOperationException();
}
+
+ /* (non-Javadoc)
+ * @see javax.faces.application.Resource#getContentType()
+ */
+ @Override
+ public String getContentType() {
+ FileTypeMap typeMap = MimetypesFileTypeMap.getDefaultFileTypeMap();
+
+ return typeMap.getContentType(resourceUrl.getFile());
+ }
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28 20:02:51 UTC (rev 18267)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-28 23:01:27 UTC (rev 18268)
@@ -38,6 +38,8 @@
import org.richfaces.cdk.faces.CurrentResourceContext;
import org.richfaces.resource.StateHolderResource;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
import com.google.common.collect.Maps;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -76,6 +78,10 @@
return;
}
+ if (!filter.apply(resource)) {
+ return;
+ }
+
CurrentResourceContext.getInstance(facesContext).setResource(resource);
if (resource instanceof StateHolderResource) {
@@ -121,6 +127,8 @@
private String[] skins = new String[0];
+ private Predicate<Resource> filter = Predicates.alwaysTrue();
+
public void setLog(Log log) {
this.log = log;
}
@@ -141,6 +149,10 @@
this.completionService = completionService;
}
+ public void setFilter(Predicate<Resource> filter) {
+ this.filter = filter;
+ }
+
@Override
public void submit(ResourceInfo info) {
if (submittedResources.putIfAbsent(info, Boolean.TRUE) == null) {
14 years, 7 months
JBoss Rich Faces SVN: r18267 - in root/tests/metamer/trunk: ftest-source and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-28 16:02:51 -0400 (Wed, 28 Jul 2010)
New Revision: 18267
Modified:
root/tests/metamer/trunk/application/pom.xml
root/tests/metamer/trunk/ftest-source/pom.xml
Log:
proper generation of metamer classes to separate jar; dependency on this jar for ftest-source
Modified: root/tests/metamer/trunk/application/pom.xml
===================================================================
--- root/tests/metamer/trunk/application/pom.xml 2010-07-28 19:23:56 UTC (rev 18266)
+++ root/tests/metamer/trunk/application/pom.xml 2010-07-28 20:02:51 UTC (rev 18267)
@@ -125,6 +125,12 @@
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.18</version>
Modified: root/tests/metamer/trunk/ftest-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-28 19:23:56 UTC (rev 18266)
+++ root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-28 20:02:51 UTC (rev 18267)
@@ -58,6 +58,7 @@
<groupId>org.richfaces.tests</groupId>
<artifactId>metamer</artifactId>
<version>${project.version}</version>
+ <classifier>classes</classifier>
</dependency>
</dependencies>
14 years, 7 months
JBoss Rich Faces SVN: r18266 - in root/examples-sandbox/trunk: richfaces-showcase-gae and 20 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-28 15:23:56 -0400 (Wed, 28 Jul 2010)
New Revision: 18266
Added:
root/examples-sandbox/trunk/richfaces-showcase-gae/
root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/assembly/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/assembly/assembly.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/config/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/config/WebConfiguration.java
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/examples/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/examples/App.java
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/jdoconfig.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/persistence.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/ant-macros.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/log4j.properties
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/logging.properties
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml
root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/index.jsp
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/AppBaseTest.java
root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/TestEnvironment.java
Log:
richfaces-showcase-gae stub initial check-in
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/pom.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>examples-sandbox</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- The Basics -->
+ <groupId>org.richfaces.examples-sandbox</groupId>
+ <artifactId>richfaces-showcase-gae</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <properties>
+ <gae.version>1.3.2</gae.version>
+ <project_charset>UTF-8</project_charset>
+ </properties>
+
+ <dependencies>
+ <!--unit test related dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.appengine</groupId>
+ <artifactId>appengine-api-1.0-labs</artifactId>
+ <version>${gae.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.appengine</groupId>
+ <artifactId>appengine-api-1.0-stubs</artifactId>
+ <version>${gae.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.appengine</groupId>
+ <artifactId>appengine-api-1.0-runtime</artifactId>
+ <version>${gae.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.appengine</groupId>
+ <artifactId>appengine-tools-sdk</artifactId>
+ <version>${gae.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!--servlet and jsp api -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--app engine related dependencies -->
+ <dependency>
+ <groupId>com.google.appengine</groupId>
+ <artifactId>appengine-api-1.0-sdk</artifactId>
+ <version>${gae.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.appengine.orm</groupId>
+ <artifactId>datanucleus-appengine</artifactId>
+ <version>1.0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_3.0_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jdo</groupId>
+ <artifactId>jdo2-api</artifactId>
+ <version>2.3-eb</version>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ <version>1.1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-jpa</artifactId>
+ <version>1.1.5</version>
+ </dependency>
+ <!--jstl -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <version>2.0.2.CR1</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <type>jar</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>richfaces-showcase</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>war</type>
+ </dependency>
+ </dependencies>
+
+ <!-- Build Settings -->
+ <build>
+ <finalName>richfaces-showcase-gae</finalName>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/assembly/assembly.xml</descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <configuration>
+ <outputEncoding>${project_charset}</outputEncoding>
+ <inputEncoding>${project_charset}</inputEncoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.kindleit</groupId>
+ <artifactId>maven-gae-plugin</artifactId>
+ <version>0.5.6</version>
+ <configuration>
+ <port>81</port>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>mvnsearch</id>
+ <url>http://www.mvnsearch.org/maven2</url>
+ </repository>
+ <repository>
+ <id>datanucleus</id>
+ <url>http://www.datanucleus.org/downloads/maven2</url>
+ </repository>
+ <repository>
+ <id>gae-plugin</id>
+ <url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>datanucleus</id>
+ <url>http://www.datanucleus.org/downloads/maven2</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>gae-plugin</id>
+ <url>http://maven-gae-plugin.googlecode.com/svn/repository</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>mvnsearch</id>
+ <url>http://www.mvnsearch.org/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/assembly/assembly.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/assembly/assembly.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/assembly/assembly.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,11 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>*:war</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+</assembly>
\ No newline at end of file
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/config/WebConfiguration.java
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/config/WebConfiguration.java (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/com/sun/faces/config/WebConfiguration.java 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,1109 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.faces.config;
+
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+
+import javax.faces.application.ResourceHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIInput;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.BeanValidator;
+import javax.faces.view.facelets.ResourceResolver;
+import javax.servlet.ServletContext;
+
+import com.sun.faces.util.FacesLogger;
+import com.sun.faces.util.Util;
+
+/** Class Documentation */
+public class WebConfiguration
+{
+
+ // Log instance for this class
+ private static final Logger LOGGER = FacesLogger.CONFIG.getLogger();
+
+ // A Simple regular expression of allowable boolean values
+ private static final Pattern ALLOWABLE_BOOLEANS = Pattern
+ .compile("true|false");
+
+ // Key under which we store our WebConfiguration instance.
+ private static final String WEB_CONFIG_KEY = "com.sun.faces.config.WebConfiguration";
+
+ // Logging level. Defaults to FINE
+ private Level loggingLevel = Level.FINE;
+
+ private Map<BooleanWebContextInitParameter, Boolean> booleanContextParameters = new EnumMap<BooleanWebContextInitParameter, Boolean>(
+ BooleanWebContextInitParameter.class);
+
+ private Map<WebContextInitParameter, String> contextParameters = new EnumMap<WebContextInitParameter, String>(
+ WebContextInitParameter.class);
+
+ private Map<WebEnvironmentEntry, String> envEntries = new EnumMap<WebEnvironmentEntry, String>(
+ WebEnvironmentEntry.class);
+
+ private Map<WebContextInitParameter, String[]> cachedListParams;
+
+ private List<String> setParams = new ArrayList<String>();
+
+ private ServletContext servletContext;
+
+ // ------------------------------------------------------------ Constructors
+
+ private WebConfiguration(ServletContext servletContext)
+ {
+
+ this.servletContext = servletContext;
+
+ String contextName = getServletContextName();
+
+ initSetList(servletContext);
+ processBooleanParameters(servletContext, contextName);
+ processInitParameters(servletContext, contextName);
+ if (canProcessJndiEntries())
+ {
+ processJndiEntries(contextName);
+ }
+
+ // build the cache of list type params
+ cachedListParams = new HashMap<WebContextInitParameter, String[]>(3);
+ getOptionValue(WebContextInitParameter.ResourceExcludes, " ");
+ getOptionValue(WebContextInitParameter.DefaultSuffix, " ");
+ getOptionValue(WebContextInitParameter.FaceletsViewMappings, ";");
+
+ }
+
+ // ---------------------------------------------------------- Public Methods
+
+ /**
+ * Return the WebConfiguration instance for this application passing the
+ * result of FacesContext.getCurrentInstance().getExternalContext() to
+ * {@link #getInstance(javax.faces.context.ExternalContext)}.
+ *
+ * @return the WebConfiguration for this application or <code>null</code> if
+ * no FacesContext is available.
+ */
+ public static WebConfiguration getInstance()
+ {
+
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return getInstance(facesContext.getExternalContext());
+
+ }
+
+ /**
+ * Return the WebConfiguration instance for this application.
+ *
+ * @param extContext
+ * the ExternalContext for this request
+ * @return the WebConfiguration for this application
+ */
+ public static WebConfiguration getInstance(ExternalContext extContext)
+ {
+
+ WebConfiguration config = (WebConfiguration) extContext
+ .getApplicationMap().get(WEB_CONFIG_KEY);
+ if (config == null)
+ {
+ return getInstance((ServletContext) extContext.getContext());
+ }
+ else
+ {
+ return config;
+ }
+
+ }
+
+ /**
+ * Return the WebConfiguration instance for this application.
+ *
+ * @param servletContext
+ * the ServletContext
+ * @return the WebConfiguration for this application or <code>null</code> if
+ * no WebConfiguration could be located
+ */
+ public static WebConfiguration getInstance(ServletContext servletContext)
+ {
+
+ WebConfiguration webConfig = (WebConfiguration) servletContext
+ .getAttribute(WEB_CONFIG_KEY);
+
+ if (webConfig == null)
+ {
+ webConfig = new WebConfiguration(servletContext);
+ servletContext.setAttribute(WEB_CONFIG_KEY, webConfig);
+ }
+ return webConfig;
+
+ }
+
+ /**
+ * @return The <code>ServletContext</code> originally used to construct this
+ * WebConfiguration instance
+ */
+ public ServletContext getServletContext()
+ {
+
+ return servletContext;
+
+ }
+
+ /**
+ * Obtain the value of the specified boolean parameter
+ *
+ * @param param
+ * the parameter of interest
+ * @return the value of the specified boolean parameter
+ */
+ public boolean isOptionEnabled(BooleanWebContextInitParameter param)
+ {
+
+ if (booleanContextParameters.get(param) != null)
+ {
+ return booleanContextParameters.get(param);
+ }
+ else
+ {
+ return param.getDefaultValue();
+ }
+
+ }
+
+ /**
+ * Obtain the value of the specified parameter
+ *
+ * @param param
+ * the parameter of interest
+ * @return the value of the specified parameter
+ */
+ public String getOptionValue(WebContextInitParameter param)
+ {
+ String result = contextParameters.get(param);
+
+ if (null == result)
+ {
+ WebContextInitParameter alternate = param.getAlternate();
+ if (null != alternate)
+ {
+ result = contextParameters.get(alternate);
+ }
+ }
+
+ return result;
+
+ }
+
+ public String[] getOptionValue(WebContextInitParameter param, String sep)
+ {
+ String[] result;
+
+ assert (null != cachedListParams);
+ if (null == (result = cachedListParams.get(param)))
+ {
+ String value = getOptionValue(param);
+ if (null == value)
+ {
+ result = new String[0];
+ }
+ else
+ {
+ result = Util.split(value, sep);
+ }
+ cachedListParams.put(param, result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Obtain the value of the specified env-entry
+ *
+ * @param entry
+ * the env-entry of interest
+ * @return the value of the specified env-entry
+ */
+ public String getEnvironmentEntry(WebEnvironmentEntry entry)
+ {
+
+ return envEntries.get(entry);
+
+ }
+
+ /**
+ * @param param
+ * the init parameter of interest
+ * @return <code>true</code> if the parameter was explicitly set, otherwise,
+ * <code>false</code>
+ */
+ public boolean isSet(WebContextInitParameter param)
+ {
+
+ return isSet(param.getQualifiedName());
+
+ }
+
+ /**
+ * @param param
+ * the init parameter of interest
+ * @return <code>true</code> if the parameter was explicitly set, otherwise,
+ * <code>false</code>
+ */
+ public boolean isSet(BooleanWebContextInitParameter param)
+ {
+
+ return isSet(param.getQualifiedName());
+
+ }
+
+ /**
+ * @return the name of this application
+ */
+ public String getServletContextName()
+ {
+
+ if (servletContext.getMajorVersion() == 2
+ && servletContext.getMinorVersion() <= 4)
+ {
+ return servletContext.getServletContextName();
+ }
+ else
+ {
+ return servletContext.getContextPath();
+ }
+
+ }
+
+ public void overrideContextInitParameter(
+ BooleanWebContextInitParameter param, boolean value)
+ {
+
+ if (param == null) { return; }
+ boolean oldVal = booleanContextParameters.put(param, value);
+ if (LOGGER.isLoggable(Level.FINE) && oldVal != value)
+ {
+ LOGGER
+ .log(
+ Level.FINE,
+ "Overriding init parameter {0}. Changing from {1} to {2}.",
+ new Object[]
+ {
+ param.getQualifiedName(), oldVal, value
+ });
+ }
+
+ }
+
+ public void overrideContextInitParameter(WebContextInitParameter param,
+ String value)
+ {
+
+ if (param == null || value == null || value.length() == 0) { return; }
+ value = value.trim();
+ String oldVal = contextParameters.put(param, value);
+ cachedListParams.remove(param);
+ if (oldVal != null)
+ {
+ if (LOGGER.isLoggable(Level.FINE) && !(oldVal.equals(value)))
+ {
+ LOGGER
+ .log(
+ Level.FINE,
+ "Overriding init parameter {0}. Changing from {1} to {2}.",
+ new Object[]
+ {
+ param.getQualifiedName(), oldVal, value
+ });
+ }
+ }
+
+ }
+
+ // ------------------------------------------------- Package Private Methods
+
+ static void clear(ServletContext servletContext)
+ {
+
+ servletContext.removeAttribute(WEB_CONFIG_KEY);
+
+ }
+
+ // --------------------------------------------------------- Private Methods
+
+ /**
+ * <p>
+ * Is the configured value valid against the default boolean pattern.
+ * </p>
+ *
+ * @param param
+ * the boolean parameter
+ * @param value
+ * the configured value
+ * @return <code>true</code> if the value is valid, otherwise
+ * <code>false</code>
+ */
+ private boolean isValueValid(BooleanWebContextInitParameter param,
+ String value)
+ {
+
+ if (!ALLOWABLE_BOOLEANS.matcher(value).matches())
+ {
+ if (LOGGER.isLoggable(Level.WARNING))
+ {
+ LOGGER.log(Level.WARNING,
+ "jsf.config.webconfig.boolconfig.invalidvalue",
+ new Object[]
+ {
+ value, param.getQualifiedName(), "true|false"
+ });
+ }
+ return false;
+ }
+
+ return true;
+
+ }
+
+ /**
+ * <p>
+ * Process all boolean context initialization parameters.
+ * </p>
+ *
+ * @param servletContext
+ * the ServletContext of interest
+ * @param contextName
+ * the context name
+ */
+ private void processBooleanParameters(ServletContext servletContext,
+ String contextName)
+ {
+
+ // process boolean contxt parameters
+ for (BooleanWebContextInitParameter param : BooleanWebContextInitParameter
+ .values())
+ {
+ String strValue = servletContext.getInitParameter(param
+ .getQualifiedName());
+ boolean value;
+
+ if (strValue != null && strValue.length() > 0
+ && param.isDeprecated())
+ {
+ BooleanWebContextInitParameter alternate = param.getAlternate();
+ if (LOGGER.isLoggable(Level.WARNING))
+ {
+ if (alternate != null)
+ {
+ LOGGER.log(Level.WARNING,
+ "jsf.config.webconfig.param.deprecated",
+ new Object[]
+ {
+ contextName, param.getQualifiedName(),
+ alternate.getQualifiedName()
+ });
+ }
+ else
+ {
+ LOGGER
+ .log(
+ Level.WARNING,
+ "jsf.config.webconfig.param.deprecated.no_replacement",
+ new Object[]
+ {
+ contextName,
+ param.getQualifiedName()
+ });
+ }
+ }
+
+ if (alternate != null)
+ {
+ if (isValueValid(param, strValue))
+ {
+ value = Boolean.valueOf(strValue);
+ }
+ else
+ {
+ value = param.getDefaultValue();
+ }
+
+ if (LOGGER.isLoggable(Level.INFO) && alternate != null)
+ {
+ LOGGER
+ .log(
+ Level.INFO,
+ ((value) ? "jsf.config.webconfig.configinfo.reset.enabled"
+ : "jsf.config.webconfig.configinfo.reset.disabled"),
+ new Object[]
+ {
+ contextName,
+ alternate.getQualifiedName()
+ });
+ }
+
+ booleanContextParameters.put(alternate, value);
+ }
+ continue;
+ }
+
+ if (!param.isDeprecated())
+ {
+ if (strValue == null)
+ {
+ value = param.getDefaultValue();
+ }
+ else
+ {
+ if (isValueValid(param, strValue))
+ {
+ value = Boolean.valueOf(strValue);
+ }
+ else
+ {
+ value = param.getDefaultValue();
+ }
+ }
+
+ // first param processed should be
+ // com.sun.faces.displayConfiguration
+ if (BooleanWebContextInitParameter.DisplayConfiguration
+ .equals(param)
+ && value)
+ {
+ loggingLevel = Level.INFO;
+ }
+
+ if (LOGGER.isLoggable(loggingLevel))
+ {
+ LOGGER
+ .log(
+ loggingLevel,
+ ((value) ? "jsf.config.webconfig.boolconfiginfo.enabled"
+ : "jsf.config.webconfig.boolconfiginfo.disabled"),
+ new Object[]
+ {
+ contextName,
+ param.getQualifiedName()
+ });
+ }
+
+ booleanContextParameters.put(param, value);
+ }
+
+ }
+
+ }
+
+ /**
+ * Adds all com.sun.faces init parameter names to a list. This allows
+ * callers to determine if a parameter was explicitly set.
+ *
+ * @param servletContext
+ * the ServletContext of interest
+ */
+ private void initSetList(ServletContext servletContext)
+ {
+
+ for (Enumeration e = servletContext.getInitParameterNames(); e
+ .hasMoreElements();)
+ {
+ String name = e.nextElement().toString();
+ if (name.startsWith("com.sun.faces"))
+ {
+ setParams.add(name);
+ }
+ }
+
+ }
+
+ /**
+ * @param name
+ * the param name
+ * @return <code>true</code> if the name was explicitly specified
+ */
+ private boolean isSet(String name)
+ {
+
+ return setParams.contains(name);
+
+ }
+
+ /**
+ * <p>
+ * Process all non-boolean context initialization parameters.
+ * </p>
+ *
+ * @param servletContext
+ * the ServletContext of interest
+ * @param contextName
+ * the context name
+ */
+ private void processInitParameters(ServletContext servletContext,
+ String contextName)
+ {
+
+ for (WebContextInitParameter param : WebContextInitParameter.values())
+ {
+ String value = servletContext.getInitParameter(param
+ .getQualifiedName());
+
+ if (value != null && value.length() > 0 && param.isDeprecated())
+ {
+ WebContextInitParameter alternate = param.getAlternate();
+ if (LOGGER.isLoggable(Level.WARNING))
+ {
+ if (alternate != null)
+ {
+ LOGGER.log(Level.WARNING,
+ "jsf.config.webconfig.param.deprecated",
+ new Object[]
+ {
+ contextName, param.getQualifiedName(),
+ alternate.getQualifiedName()
+ });
+ }
+ else
+ {
+ LOGGER
+ .log(
+ Level.WARNING,
+ "jsf.config.webconfig.param.deprecated.no_replacement",
+ new Object[]
+ {
+ contextName,
+ param.getQualifiedName()
+ });
+ }
+ }
+
+ if (alternate != null)
+ {
+ if (LOGGER.isLoggable(Level.INFO))
+ {
+ LOGGER.log(Level.INFO,
+ "jsf.config.webconfig.configinfo.reset",
+ new Object[]
+ {
+ contextName,
+ alternate.getQualifiedName(), value
+ });
+ }
+
+ contextParameters.put(alternate, value);
+ }
+ continue;
+ }
+
+ if ((value == null || value.length() == 0) && !param.isDeprecated())
+ {
+ value = param.getDefaultValue();
+ }
+ if (value == null || value.length() == 0)
+ {
+ continue;
+ }
+
+ if (value.length() > 0)
+ {
+ if (LOGGER.isLoggable(loggingLevel))
+ {
+ LOGGER.log(loggingLevel, "jsf.config.webconfig.configinfo",
+ new Object[]
+ {
+ contextName, param.getQualifiedName(),
+ value
+ });
+
+ }
+ contextParameters.put(param, value);
+ }
+ else
+ {
+ if (LOGGER.isLoggable(loggingLevel))
+ {
+ LOGGER.log(loggingLevel,
+ "jsf.config.webconfig.option.notconfigured",
+ new Object[]
+ {
+ contextName, param.getQualifiedName()
+ });
+ }
+ }
+
+ }
+
+ }
+
+ /**
+ * <p>
+ * Process all JNDI entries.
+ * </p>
+ *
+ * @param contextName
+ * the context name
+ */
+ private void processJndiEntries(String contextName)
+ {
+/*
+ * This section has been disabled due to incompatibilities with Google App Engine 1.2.6.
+ Context initialContext = null;
+ try
+ {
+ initialContext = new InitialContext();
+ }
+ catch (NamingException ne)
+ {
+ if (LOGGER.isLoggable(Level.WARNING))
+ {
+ LOGGER.log(Level.WARNING, ne.toString(), ne);
+ }
+ }
+
+ if (initialContext != null)
+ {
+ // process environment entries
+ for (WebEnvironmentEntry entry : WebEnvironmentEntry.values())
+ {
+ String entryName = entry.getQualifiedName();
+ String value = null;
+
+ try
+ {
+ value = (String) initialContext.lookup(entryName);
+ }
+ catch (NamingException root)
+ {
+ if (LOGGER.isLoggable(Level.FINE))
+ {
+ LOGGER.fine(root.toString());
+ }
+ }
+
+ if (value != null)
+ {
+ if (LOGGER.isLoggable(Level.INFO))
+ {
+ // special logic for ClientStateSavingPassword
+ if (!entry
+ .equals(WebEnvironmentEntry.ClientStateSavingPassword))
+ {
+ if (LOGGER.isLoggable(loggingLevel))
+ {
+ LOGGER.log(loggingLevel,
+ "jsf.config.webconfig.enventryinfo",
+ new Object[]
+ {
+ contextName, entryName, value
+ });
+ }
+ }
+ else
+ {
+ if (LOGGER.isLoggable(loggingLevel))
+ {
+ LOGGER
+ .log(
+ loggingLevel,
+ "jsf.config.webconfig.enventry.clientencrypt",
+ contextName);
+ }
+ }
+ }
+ envEntries.put(entry, value);
+ }
+ }
+ }
+*/
+ }
+
+ private boolean canProcessJndiEntries()
+ {
+
+ /*
+ * This section has been disabled due to incompatibilities with Google App Engine 1.2.6
+ try
+ {
+ Util.getCurrentLoader(this)
+ .loadClass("javax.naming.InitialContext");
+ }
+ catch (Exception e)
+ {
+ */
+ if (LOGGER.isLoggable(Level.FINE))
+ {
+ LOGGER
+ .fine("javax.naming is forced unavailable. JNDI entries related to Mojarra configuration will not be processed.");
+ }
+ return false;
+ /*
+ }
+ return true;
+ */
+
+ }
+
+ // ------------------------------------------------------------------- Enums
+
+ /**
+ * <p>
+ * An <code>enum</code> of all non-boolean context initalization parameters
+ * recognized by the implementation.
+ * </p>
+ */
+ public enum WebContextInitParameter
+ {
+
+ // implementation note:
+ // if a parameter is to be deprecated,
+ // then the <name>Deprecated enum element
+ // *must* appear after the one that is taking
+ // its place. The reporting logic depends on this
+
+ ManagedBeanFactoryDecorator(
+ "com.sun.faces.managedBeanFactoryDecoratorClass", ""), StateSavingMethod(
+ "javax.faces.STATE_SAVING_METHOD", "server"), FaceletsSuffix(
+ ViewHandler.FACELETS_SUFFIX_PARAM_NAME,
+ ViewHandler.DEFAULT_FACELETS_SUFFIX), DefaultSuffix(
+ ViewHandler.DEFAULT_SUFFIX_PARAM_NAME,
+ ViewHandler.DEFAULT_SUFFIX), JavaxFacesConfigFiles(
+ "javax.faces.CONFIG_FILES", ""), JavaxFacesProjectStage(
+ "javax.faces.PROJECT_STAGE", "Production"), AlternateLifecycleId(
+ "javax.faces.LIFECYCLE_ID", ""), ResourceExcludes(
+ ResourceHandler.RESOURCE_EXCLUDES_PARAM_NAME,
+ ResourceHandler.RESOURCE_EXCLUDES_DEFAULT_VALUE + " .groovy"), NumberOfViews(
+ "com.sun.faces.numberOfViewsInSession", "15"), NumberOfViewsDeprecated(
+ "com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION", "15", true,
+ NumberOfViews), NumberOfLogicalViews(
+ "com.sun.faces.numberOfLogicalViews", "15"), NumberOfLogicalViewsDeprecated(
+ "com.sun.faces.NUMBER_OF_VIEWS_IN_LOGICAL_VIEW_IN_SESSION",
+ "15", true, NumberOfLogicalViews), NumberOfConcurrentFlashUsers(
+ "com.sun.faces.numberOfConcerrentFlashUsers", "5000"), NumberOfFlashesBetweenFlashReapings(
+ "com.sun.faces.numberOfFlashesBetweenFlashReapings", "5000"), InjectionProviderClass(
+ "com.sun.faces.injectionProvider", ""), SerializationProviderClass(
+ "com.sun.faces.serializationProvider", ""), ResponseBufferSize(
+ "com.sun.faces.responseBufferSize", "1024"), FaceletsBufferSize(
+ "javax.faces.FACELETS_BUFFER_SIZE", "1024", true,
+ ResponseBufferSize), FaceletsBufferSizeDeprecated(
+ "facelets.BUFFER_SIZE", "1024", true, FaceletsBufferSize), ClientStateWriteBufferSize(
+ "com.sun.faces.clientStateWriteBufferSize", "8192"), ResourceBufferSize(
+ "com.sun.faces.resourceBufferSize", "2048"), ExpressionFactory(
+ "com.sun.faces.expressionFactory",
+ "com.sun.el.ExpressionFactoryImpl"), ClientStateTimeout(
+ "com.sun.faces.clientStateTimeout", ""), DefaultResourceMaxAge(
+ "com.sun.faces.defaultResourceMaxAge", "604800"), ResourceUpdateCheckPeriod(
+ "com.sun.faces.resourceUpdateCheckPeriod", "5" // in minutes
+ ), CompressableMimeTypes("com.sun.faces.compressableMimeTypes", ""), DisableUnicodeEscaping(
+ "com.sun.faces.disableUnicodeEscaping", "auto"), FaceletsDefaultRefreshPeriod(
+ "javax.faces.FACELETS_REFRESH_PERIOD", "2"), FaceletsDefaultRefreshPeriodDeprecated(
+ "facelets.REFRESH_PERIOD", "2", true,
+ FaceletsDefaultRefreshPeriod), FaceletsResourceResolver(
+ ResourceResolver.FACELETS_RESOURCE_RESOLVER_PARAM_NAME, ""), FaceletsResourceResolverDeprecated(
+ "facelets.RESOURCE_RESOLVER", "", true,
+ FaceletsResourceResolver), FaceletsViewMappings(
+ ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME, ""), FaceletsViewMappingsDeprecated(
+ "facelets.VIEW_MAPPINGS", "", true, FaceletsViewMappings), FaceletsLibraries(
+ "javax.faces.FACELETS_LIBRARIES", ""), FaceletsLibrariesDeprecated(
+ "facelets.LIBRARIES", "", true, FaceletsLibraries), FaceletsDecorators(
+ "javax.faces.FACELETS_DECORATORS", ""), FaceletsDecoratorsDeprecated(
+ "facelets.DECORATORS", "", true, FaceletsDecorators), DuplicateJARPattern(
+ "com.sun.faces.duplicateJARPattern", ""), ValidateEmptyFields(
+ UIInput.VALIDATE_EMPTY_FIELDS_PARAM_NAME, "auto"), FullStateSavingViewIds(
+ StateManager.FULL_STATE_SAVING_VIEW_IDS_PARAM_NAME, ""), AnnotationScanPackages(
+ "com.sun.faces.annotationScanPackages", ""), FaceletFactory(
+ "com.sun.faces.faceletFactory", "");
+
+ private String defaultValue;
+ private String qualifiedName;
+ private WebContextInitParameter alternate;
+ private boolean deprecated;
+
+ // ---------------------------------------------------------- Public
+ // Methods
+
+ public String getDefaultValue()
+ {
+
+ return defaultValue;
+
+ }
+
+ public String getQualifiedName()
+ {
+
+ return qualifiedName;
+
+ }
+
+ // ------------------------------------------------- Package Private
+ // Methods
+
+ WebContextInitParameter(String qualifiedName, String defaultValue)
+ {
+
+ this(qualifiedName, defaultValue, false, null);
+
+ }
+
+ WebContextInitParameter(String qualifiedName, String defaultValue,
+ boolean deprecated, WebContextInitParameter alternate)
+ {
+
+ this.qualifiedName = qualifiedName;
+ this.defaultValue = defaultValue;
+ this.deprecated = deprecated;
+ this.alternate = alternate;
+
+ }
+
+ // --------------------------------------------------------- Private
+ // Methods
+
+ private WebContextInitParameter getAlternate()
+ {
+
+ return alternate;
+
+ }
+
+ private boolean isDeprecated()
+ {
+
+ return deprecated;
+
+ }
+
+ }
+
+ /**
+ * <p>
+ * An <code>enum</code> of all boolean context initalization parameters
+ * recognized by the implementation.
+ * </p>
+ */
+ public enum BooleanWebContextInitParameter
+ {
+
+ // implementation note:
+ // if a parameter is to be deprecated,
+ // then the <name>Deprecated enum element
+ // *must* appear after the one that is taking
+ // its place. The reporting logic depends on this
+
+ DisplayConfiguration("com.sun.faces.displayConfiguration", false), ValidateFacesConfigFiles(
+ "com.sun.faces.validateXml", false), VerifyFacesConfigObjects(
+ "com.sun.faces.verifyObjects", false), ForceLoadFacesConfigFiles(
+ "com.sun.faces.forceLoadConfiguration", false), DisableArtifactVersioning(
+ "com.sun.faces.disableVersionTracking", false, true, null), EnableHtmlTagLibraryValidator(
+ "com.sun.faces.enableHtmlTagLibValidator", false), EnableCoreTagLibraryValidator(
+ "com.sun.faces.enableCoreTagLibValidator", false), PreferXHTMLContentType(
+ "com.sun.faces.preferXHTML", false), PreferXHTMLContextTypeDeprecated(
+ "com.sun.faces.PreferXHTML", false, true,
+ PreferXHTMLContentType), CompressViewState(
+ "com.sun.faces.compressViewState", true), CompressViewStateDeprecated(
+ "com.sun.faces.COMPRESS_STATE", true, true, CompressViewState), CompressJavaScript(
+ "com.sun.faces.compressJavaScript", true), ExternalizeJavaScriptDeprecated(
+ "com.sun.faces.externalizeJavaScript", true, true, null), SendPoweredByHeader(
+ "com.sun.faces.sendPoweredByHeader", true), EnableJSStyleHiding(
+ "com.sun.faces.enableJSStyleHiding", false), EnableScriptInAttributeValue(
+ "com.sun.faces.enableScriptsInAttributeValues", true), WriteStateAtFormEnd(
+ "com.sun.faces.writeStateAtFormEnd", true), EnableLazyBeanValidation(
+ "com.sun.faces.enableLazyBeanValidation", true), EnableLoadBundle11Compatibility(
+ "com.sun.faces.enabledLoadBundle11Compatibility", false), EnableRestoreView11Compatibility(
+ "com.sun.faces.enableRestoreView11Compatibility", false), SerializeServerState(
+ "com.sun.faces.serializeServerState", false), EnableViewStateIdRendering(
+ "com.sun.faces.enableViewStateIdRendering", true), RegisterConverterPropertyEditors(
+ "com.sun.faces.registerConverterPropertyEditors", false), EnableGroovyScripting(
+ "com.sun.faces.enableGroovyScripting", false), DisableFaceletJSFViewHandler(
+ "javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER", false), DisableDefaultBeanValidator(
+ BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME, false), DateTimeConverterUsesSystemTimezone(
+ "javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE",
+ false), FaceletsSkipComments(
+ "javax.faces.FACELETS_SKIP_COMMENTS", false), FaceletsSkipCommentsDeprecated(
+ "facelets.SKIP_COMMENTS", false, true, FaceletsSkipComments), PartialStateSaving(
+ StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, true), GenerateUniqueServerStateIds(
+ "com.sun.faces.generateUniqueServerStateIds", true), AutoCompleteOffOnViewState(
+ "com.sun.faces.autoCompleteOffOnViewState", true), EnableThreading(
+ "com.sun.faces.enableThreading", true), AllowTextChildren(
+ "com.sun.faces.allowTextChildren", false);
+
+ private BooleanWebContextInitParameter alternate;
+
+ private String qualifiedName;
+ private boolean defaultValue;
+ private boolean deprecated;
+
+ // ---------------------------------------------------------- Public
+ // Methods
+
+ public boolean getDefaultValue()
+ {
+
+ return defaultValue;
+
+ }
+
+ public String getQualifiedName()
+ {
+
+ return qualifiedName;
+
+ }
+
+ // ------------------------------------------------- Package Private
+ // Methods
+
+ BooleanWebContextInitParameter(String qualifiedName,
+ boolean defaultValue)
+ {
+
+ this(qualifiedName, defaultValue, false, null);
+
+ }
+
+ BooleanWebContextInitParameter(String qualifiedName,
+ boolean defaultValue, boolean deprecated,
+ BooleanWebContextInitParameter alternate)
+ {
+
+ this.qualifiedName = qualifiedName;
+ this.defaultValue = defaultValue;
+ this.deprecated = deprecated;
+ this.alternate = alternate;
+
+ }
+
+ // --------------------------------------------------------- Private
+ // Methods
+
+ private BooleanWebContextInitParameter getAlternate()
+ {
+
+ return alternate;
+
+ }
+
+ private boolean isDeprecated()
+ {
+
+ return deprecated;
+
+ }
+
+ }
+
+ /**
+ * <p>
+ * An <code>enum</code> of all environment entries (specified in the
+ * web.xml) recognized by the implemenetation.
+ * </p>
+ */
+ public enum WebEnvironmentEntry
+ {
+
+ ClientStateSavingPassword("ClientStateSavingPassword"), ProjectStage(
+ javax.faces.application.ProjectStage.PROJECT_STAGE_JNDI_NAME);
+
+ private static final String JNDI_PREFIX = "java:comp/env/";
+ private String qualifiedName;
+
+ // ---------------------------------------------------------- Public
+ // Methods
+
+ public String getQualifiedName()
+ {
+
+ return qualifiedName;
+
+ }
+
+ // ------------------------------------------------- Package Private
+ // Methods
+
+ WebEnvironmentEntry(String qualifiedName)
+ {
+
+ if (qualifiedName.startsWith(JNDI_PREFIX))
+ {
+ this.qualifiedName = qualifiedName;
+ }
+ else
+ {
+ this.qualifiedName = JNDI_PREFIX + qualifiedName;
+ }
+
+ }
+
+ }
+
+ /**
+ * <p>
+ * An <code>enum</code> of all possible values for the
+ * <code>disableUnicodeEscaping</code> configuration parameter.
+ * </p>
+ */
+ public enum DisableUnicodeEscaping
+ {
+ True("true"), False("false"), Auto("auto");
+
+ private final String value;
+
+ DisableUnicodeEscaping(String value)
+ {
+ this.value = value;
+ }
+
+ public static DisableUnicodeEscaping getByValue(String value)
+ {
+ for (DisableUnicodeEscaping disableUnicodeEscaping : DisableUnicodeEscaping
+ .values())
+ {
+ if (disableUnicodeEscaping.value.equals(value)) { return disableUnicodeEscaping; }
+ }
+
+ return null;
+ }
+ }
+
+} // END WebConfiguration
\ No newline at end of file
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/examples/App.java
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/examples/App.java (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/java/org/richfaces/examples/App.java 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,13 @@
+package org.richfaces.examples;
+
+/**
+ * Hello world!
+ *
+ */
+public class App
+{
+ public static void main( String[] args )
+ {
+ System.out.println( "Hello World!" );
+ }
+}
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/jdoconfig.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/jdoconfig.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/jdoconfig.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
+
+ <persistence-manager-factory name="transactions-optional">
+ <property name="javax.jdo.PersistenceManagerFactoryClass"
+ value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
+ <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
+ <property name="javax.jdo.option.NontransactionalRead" value="true"/>
+ <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
+ <property name="javax.jdo.option.RetainValues" value="true"/>
+ <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
+ </persistence-manager-factory>
+</jdoconfig>
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/persistence.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/persistence.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/META-INF/persistence.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="transactions-optional">
+ <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider>
+ <properties>
+ <property name="datanucleus.NontransactionalRead" value="true"/>
+ <property name="datanucleus.NontransactionalWrite" value="true"/>
+ <property name="datanucleus.ConnectionURL" value="appengine"/>
+ </properties>
+ </persistence-unit>
+
+</persistence>
\ No newline at end of file
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/ant-macros.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/ant-macros.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/ant-macros.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,106 @@
+<!--
+ This file contains useful Ant definitions for users of App Engine.
+ To use these macrodefs and taskdefs, import the file into your own build.xml:
+
+ <property name="appengine.sdk.dir" location="/some_dir/appengine-java-sdk-trunk"/>
+ <import file="${appengine.sdk.dir}/config/user/ant-macros.xml"/>
+
+ For example uses of the macros, see the template project's build.xml.
+ -->
+<project name="appengine-ant-macros">
+
+ <property name="appengine.sdk.home" location="${ant.file.appengine-ant-macros}../../../.."/>
+ <property name="appengine.tools.classpath"
+ location="${appengine.sdk.home}/lib/appengine-tools-api.jar"/>
+
+ <!--
+ A macrodef for dev_appserver. Use like:
+
+ <dev_appserver war="${war}"/>
+ -->
+ <macrodef name="dev_appserver" description="Runs the App Engine Development App Server">
+ <attribute name="war" description="The exploded war directory containing the application"/>
+ <attribute name="port" default="8080" description="The port the server starts on"/>
+ <attribute name="address" default="localhost" description="The interface the server binds to"/>
+ <element name="options" optional="true" description="Additional options for dev_appserver"/>
+ <element name="args" optional="true" description="Additional arguments for the java task"/>
+
+ <sequential>
+ <java classname="com.google.appengine.tools.KickStart"
+ classpath="${appengine.tools.classpath}"
+ fork="true">
+ <arg value="com.google.appengine.tools.development.DevAppServerMain"/>
+ <arg value="--port=@{port}"/>
+ <arg value="--address=@{address}"/>
+ <options/>
+ <arg value="@{war}"/>
+ <args/>
+ </java>
+ </sequential>
+ </macrodef>
+
+ <!--
+ A macrodef for appcfg. Use like:
+
+ <appcfg action="update" war="${war}"/>
+
+ -->
+ <macrodef name="appcfg" description="Manages an application">
+ <attribute name="war" description="The exploded war directory containing the application"/>
+ <attribute name="action" description="One of (update, rollback, update_indexes, request_logs)"/>
+ <element name="options" optional="true" description="Options for appcfg (such as --server, --num_days, etc...)"/>
+ <element name="args" optional="true" description="Additional arguments for the java task"/>
+
+ <sequential>
+ <java classname="com.google.appengine.tools.admin.AppCfg"
+ classpath="${appengine.tools.classpath}"
+ fork="true">
+ <arg value="--disable_prompt"/>
+ <options/>
+ <arg value="@{action}"/>
+ <arg value="@{war}"/>
+ <args/>
+ </java>
+ </sequential>
+ </macrodef>
+
+ <!--
+ A taskdef for ORM enhancement. Use like:
+
+ <enhance failonerror="true">
+ <classpath>
+ <pathelement path="${appengine.tools.classpath}"/>
+ <pathelement path="@{war}/WEB-INF/classes"/>
+ <fileset dir="@{war}/WEB-INF/lib" includes="*.jar"/>
+ </classpath>
+ <fileset dir="@{war}/WEB-INF/classes" includes="**/*.class"/>
+ </enhance>
+
+ Alternatively, use the <enhance_war/> macrodef below.
+ -->
+ <taskdef name="enhance"
+ classpath="${appengine.tools.classpath}"
+ classname="com.google.appengine.tools.enhancer.EnhancerTask"/>
+
+ <!--
+ A macrodef for ORM enhancement for a war. Use like:
+
+ <enhance_war war="${war}"/>
+ -->
+ <macrodef name="enhance_war" description="Run the ORM enhancer on an exploded war">
+ <attribute name="war" description="The exploded war directory containing the application"/>
+ <element name="args" optional="true" description="Additional arguments to the enhancer"/>
+ <sequential>
+ <enhance failonerror="true">
+ <args/>
+ <classpath>
+ <pathelement path="${appengine.tools.classpath}"/>
+ <pathelement path="@{war}/WEB-INF/classes"/>
+ <fileset dir="@{war}/WEB-INF/lib" includes="*.jar"/>
+ </classpath>
+ <fileset dir="@{war}/WEB-INF/classes" includes="**/*.class"/>
+ </enhance>
+ </sequential>
+ </macrodef>
+
+</project>
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/log4j.properties
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/log4j.properties (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/log4j.properties 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,24 @@
+# A default log4j configuration for log4j users.
+#
+# To use this configuration, deploy it into your application's WEB-INF/classes
+# directory. You are also encouraged to edit it as you like.
+
+# Configure the console as our one appender
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n
+
+# tighten logging on the DataNucleus Categories
+log4j.category.DataNucleus.JDO=WARN, A1
+log4j.category.DataNucleus.Persistence=WARN, A1
+log4j.category.DataNucleus.Cache=WARN, A1
+log4j.category.DataNucleus.MetaData=WARN, A1
+log4j.category.DataNucleus.General=WARN, A1
+log4j.category.DataNucleus.Utility=WARN, A1
+log4j.category.DataNucleus.Transaction=WARN, A1
+log4j.category.DataNucleus.Datastore=WARN, A1
+log4j.category.DataNucleus.ClassLoading=WARN, A1
+log4j.category.DataNucleus.Plugin=WARN, A1
+log4j.category.DataNucleus.ValueGeneration=WARN, A1
+log4j.category.DataNucleus.Enhancer=WARN, A1
+log4j.category.DataNucleus.SchemaTool=WARN, A1
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/logging.properties
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/logging.properties (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/resources/logging.properties 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,28 @@
+# A default java.util.logging configuration.
+# (All App Engine logging is through java.util.logging by default).
+#
+# To use this configuration, copy it into your application's WEB-INF
+# folder and add the following to your appengine-web.xml:
+#
+# <system-properties>
+# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
+# </system-properties>
+#
+
+# Set the default logging level for all loggers to WARNING
+.level = WARNING
+
+# Set the default logging level for ORM, specifically, to WARNING
+DataNucleus.JDO.level=WARNING
+DataNucleus.Persistence.level=WARNING
+DataNucleus.Cache.level=WARNING
+DataNucleus.MetaData.level=WARNING
+DataNucleus.General.level=WARNING
+DataNucleus.Utility.level=WARNING
+DataNucleus.Transaction.level=WARNING
+DataNucleus.Datastore.level=WARNING
+DataNucleus.ClassLoading.level=WARNING
+DataNucleus.Plugin.level=WARNING
+DataNucleus.ValueGeneration.level=WARNING
+DataNucleus.Enhancer.level=WARNING
+DataNucleus.SchemaTool.level=WARNING
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/appengine-web.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
+ <application>richfaces-showcase-gae</application>
+ <version>3</version>
+
+ <system-properties>
+ <property name="java.util.logging.config.file" value="WEB-INF/classes/logging.properties"/>
+ </system-properties>
+
+</appengine-web-app>
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/WEB-INF/web.xml 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
+</web-app>
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/index.jsp
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/index.jsp (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/main/webapp/index.jsp 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,9 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Welcome</title>
+</head>
+<body>
+Welcome to Google App Engine for Java!
+</body>
+</html>
\ No newline at end of file
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/AppBaseTest.java
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/AppBaseTest.java (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/AppBaseTest.java 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,38 @@
+package org.richfaces.examples;
+
+//import com.google.appengine.tools.development.ApiProxyLocalImpl;
+import com.google.apphosting.api.ApiProxy;
+import junit.framework.TestCase;
+
+import java.io.File;
+
+/**
+ * local service test
+ */
+public class AppBaseTest extends TestCase {
+
+ /**
+ * setup env
+ *
+ * @throws Exception exception
+ */
+ @Override
+ public void setUp() throws Exception {
+// ApiProxy.setEnvironmentForCurrentThread(new TestEnvironment());
+// ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")) {
+// });
+ }
+
+ /**
+ * cleanup
+ *
+ * @throws Exception exception
+ */
+ @Override
+ public void tearDown() throws Exception {
+// ApiProxy.setDelegate(null);
+// ApiProxy.setEnvironmentForCurrentThread(null);
+ }
+
+
+}
\ No newline at end of file
Added: root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/TestEnvironment.java
===================================================================
--- root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/TestEnvironment.java (rev 0)
+++ root/examples-sandbox/trunk/richfaces-showcase-gae/src/test/java/org/richfaces/examples/TestEnvironment.java 2010-07-28 19:23:56 UTC (rev 18266)
@@ -0,0 +1,59 @@
+package org.richfaces.examples;
+
+import com.google.apphosting.api.ApiProxy;
+
+import java.util.Map;
+
+/**
+ * project test environment
+ */
+class TestEnvironment implements ApiProxy.Environment {
+ /**
+ * get GAE app id
+ *
+ * @return app id
+ */
+ public String getAppId() {
+ return "gae-showcase";
+ }
+
+ /**
+ * get version id
+ *
+ * @return version
+ */
+ public String getVersionId() {
+ return "4.0.0-SNAPSHOT";
+ }
+
+ public void setDefaultNamespace(String s) {
+ }
+
+ public String getRequestNamespace() {
+ return null;
+ }
+
+ public String getDefaultNamespace() {
+ return null;
+ }
+
+ public String getAuthDomain() {
+ return null;
+ }
+
+ public boolean isLoggedIn() {
+ return false;
+ }
+
+ public String getEmail() {
+ return null;
+ }
+
+ public boolean isAdmin() {
+ return false;
+ }
+
+ public Map<String, Object> getAttributes() {
+ return null;
+ }
+}
14 years, 7 months
JBoss Rich Faces SVN: r18265 - in root/ui-sandbox/inputs/trunk/inputnumberslider/src/main: resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-07-28 15:12:48 -0400 (Wed, 28 Jul 2010)
New Revision: 18265
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderSelectedArrowBottom.java
Modified:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
Log:
RF-8983
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2010-07-28 17:14:35 UTC (rev 18264)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2010-07-28 19:12:48 UTC (rev 18265)
@@ -50,22 +50,18 @@
private Dimension dimension = new Dimension(7, 7);
private int color;
- private final String colorName;
+ private String colorName = Skin.GENERAL_TEXT_COLOR;
- public SliderArrowBase() {
- this(Skin.GENERAL_TEXT_COLOR);
- }
-
- public SliderArrowBase(String colorName) {
- this.colorName = colorName;
- }
-
private void initialize() {
FacesContext context = FacesContext.getCurrentInstance();
Skin skin = SkinFactory.getInstance(context).getSkin(context);
this.color = skin.getColorParameter(context, colorName);
}
+ protected final void setColorName(String colorName) {
+ this.colorName = colorName;
+ }
+
public Dimension getDimension() {
return dimension;
}
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderSelectedArrowBottom.java
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderSelectedArrowBottom.java (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderSelectedArrowBottom.java 2010-07-28 19:12:48 UTC (rev 18265)
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderSelectedArrowBottom extends SliderArrowBottom {
+
+ public SliderSelectedArrowBottom() {
+ setColorName("tipBorderColor");
+ }
+}
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28 17:14:35 UTC (rev 18264)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-07-28 19:12:48 UTC (rev 18265)
@@ -84,6 +84,10 @@
background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderArrowBottom']}");
}
+.rf-ins-h-s {
+ background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderSelectedArrowBottom']}");
+}
+
.rf-ins-db {
background-image: url("#{resource['org.richfaces.renderkit.html.images.SliderArrowLeft']}");
}
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28 17:14:35 UTC (rev 18264)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-28 19:12:48 UTC (rev 18265)
@@ -98,6 +98,7 @@
var jQueryDocument = jQuery(document);
jQueryDocument.mousemove(jQuery.proxy(this.__mousemoveHandler, this));
jQueryDocument.one("mouseup", jQuery.proxy(this.__mouseupHandler, this));
+ this.handle.addClass("rf-ins-h-s");
this.tooltip.show();
event.preventDefault();
},
@@ -109,6 +110,7 @@
},
__mouseupHandler: function () {
+ this.handle.removeClass("rf-ins-h-s");
this.tooltip.hide();
jQuery(document).unbind("mousemove", this.__mousemoveHandler);
}
14 years, 7 months