You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by th...@apache.org on 2014/12/21 20:56:36 UTC
[10/35] tapestry-5 git commit: Third pass creating the BeanModel and
Commons packages.
Third pass creating the BeanModel and Commons packages.
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/dd958465
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/dd958465
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/dd958465
Branch: refs/heads/master
Commit: dd9584659823c87f014a1cf57c7be592eedfa4c6
Parents: c9e97d6
Author: Thiago H. de Paula Figueiredo <th...@apache.org>
Authored: Sat Dec 6 17:33:54 2014 -0200
Committer: Thiago H. de Paula Figueiredo <th...@apache.org>
Committed: Sat Dec 6 17:33:54 2014 -0200
----------------------------------------------------------------------
.../tapestry5/internal/BeanModelUtils.java | 145 ------------
.../internal/InternalBeanModelUtils.java | 145 ++++++++++++
.../internal/beaneditor/BeanModelUtils.java | 120 ++++++++++
.../internal/beaneditor/PropertyModelImpl.java | 6 +-
.../internal/services/BeanModelSourceImpl.java | 222 +++++++++++++++++++
.../services/PropertyConduitSourceImpl.java | 4 +-
.../tapestry5/services/DataTypeAnalyzer.java | 48 ++++
.../internal/TapestryInternalUtils.java | 8 +-
.../internal/beaneditor/BeanModelUtils.java | 119 ----------
.../internal/services/BeanModelSourceImpl.java | 222 -------------------
.../tapestry5/services/DataTypeAnalyzer.java | 48 ----
.../annotations/UsesMappedConfiguration.java | 41 ----
.../annotations/UsesOrderedConfiguration.java | 33 ---
.../ioc/internal/util/InternalUtils.java | 6 +-
.../annotations/UsesMappedConfiguration.java | 41 ++++
.../annotations/UsesOrderedConfiguration.java | 33 +++
16 files changed, 621 insertions(+), 620 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/BeanModelUtils.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/BeanModelUtils.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/BeanModelUtils.java
deleted file mode 100644
index 08cb88a..0000000
--- a/beanmodel/src/main/java/org/apache/tapestry5/internal/BeanModelUtils.java
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2007, 2008 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package org.apache.tapestry5.internal;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.regex.Pattern;
-
-import org.apache.tapestry5.ioc.AnnotationProvider;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.internal.NullAnnotationProvider;
-import org.apache.tapestry5.ioc.internal.util.InternalStringUtils;
-
-/**
- * Some methods broken off tapestry-core's InternalUtils to avoid bringing the whole class
- * plus its multiple dependencies to the BeanModel package.
- */
-public class BeanModelUtils {
-
- public static final Pattern NON_WORD_PATTERN = Pattern.compile("[^\\w]");
-
- /**
- * @since 5.3
- */
- private final static AnnotationProvider NULL_ANNOTATION_PROVIDER = new NullAnnotationProvider();
-
-
- /**
- * Used to convert a property expression into a key that can be used to locate various resources (Blocks, messages,
- * etc.). Strips out any punctuation characters, leaving just words characters (letters, number and the
- * underscore).
- *
- * @param expression a property expression
- * @return the expression with punctuation removed
- */
- public static String extractIdFromPropertyExpression(String expression)
- {
- return replace(expression, NON_WORD_PATTERN, "");
- }
-
- public static String replace(String input, Pattern pattern, String replacement)
- {
- return pattern.matcher(input).replaceAll(replacement);
- }
-
- /**
- * Looks for a label within the messages based on the id. If found, it is used, otherwise the name is converted to a
- * user presentable form.
- */
- public static String defaultLabel(String id, Messages messages, String propertyExpression)
- {
- String key = id + "-label";
-
- if (messages.contains(key))
- return messages.get(key);
-
- return toUserPresentable(extractIdFromPropertyExpression(InternalStringUtils.lastTerm(propertyExpression)));
- }
-
- /**
- * Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case
- * characters). Thus "userId" becomes "User Id", etc. Also, converts underscore into space (and capitalizes the
- * following word), thus "user_id" also becomes "User Id".
- */
- public static String toUserPresentable(String id)
- {
- StringBuilder builder = new StringBuilder(id.length() * 2);
-
- char[] chars = id.toCharArray();
- boolean postSpace = true;
- boolean upcaseNext = true;
-
- for (char ch : chars)
- {
- if (upcaseNext)
- {
- builder.append(Character.toUpperCase(ch));
- upcaseNext = false;
-
- continue;
- }
-
- if (ch == '_')
- {
- builder.append(' ');
- upcaseNext = true;
- continue;
- }
-
- boolean upperCase = Character.isUpperCase(ch);
-
- if (upperCase && !postSpace)
- builder.append(' ');
-
- builder.append(ch);
-
- postSpace = upperCase;
- }
-
- return builder.toString();
- }
-
- /**
- * @since 5.3
- */
- public static AnnotationProvider toAnnotationProvider(final Class element)
- {
- return new AnnotationProvider()
- {
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
- {
- return annotationClass.cast(element.getAnnotation(annotationClass));
- }
- };
- }
-
- public static AnnotationProvider toAnnotationProvider(final Method element)
- {
- if (element == null)
- return NULL_ANNOTATION_PROVIDER;
-
- return new AnnotationProvider()
- {
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
- {
- return element.getAnnotation(annotationClass);
- }
- };
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/InternalBeanModelUtils.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/InternalBeanModelUtils.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/InternalBeanModelUtils.java
new file mode 100644
index 0000000..88f4c7f
--- /dev/null
+++ b/beanmodel/src/main/java/org/apache/tapestry5/internal/InternalBeanModelUtils.java
@@ -0,0 +1,145 @@
+// Copyright 2007, 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.internal;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.regex.Pattern;
+
+import org.apache.tapestry5.ioc.AnnotationProvider;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.internal.NullAnnotationProvider;
+import org.apache.tapestry5.ioc.internal.util.InternalStringUtils;
+
+/**
+ * Some methods broken off tapestry-core's InternalUtils to avoid bringing the whole class
+ * plus its multiple dependencies to the BeanModel package.
+ */
+public class InternalBeanModelUtils {
+
+ public static final Pattern NON_WORD_PATTERN = Pattern.compile("[^\\w]");
+
+ /**
+ * @since 5.3
+ */
+ private final static AnnotationProvider NULL_ANNOTATION_PROVIDER = new NullAnnotationProvider();
+
+
+ /**
+ * Used to convert a property expression into a key that can be used to locate various resources (Blocks, messages,
+ * etc.). Strips out any punctuation characters, leaving just words characters (letters, number and the
+ * underscore).
+ *
+ * @param expression a property expression
+ * @return the expression with punctuation removed
+ */
+ public static String extractIdFromPropertyExpression(String expression)
+ {
+ return replace(expression, NON_WORD_PATTERN, "");
+ }
+
+ public static String replace(String input, Pattern pattern, String replacement)
+ {
+ return pattern.matcher(input).replaceAll(replacement);
+ }
+
+ /**
+ * Looks for a label within the messages based on the id. If found, it is used, otherwise the name is converted to a
+ * user presentable form.
+ */
+ public static String defaultLabel(String id, Messages messages, String propertyExpression)
+ {
+ String key = id + "-label";
+
+ if (messages.contains(key))
+ return messages.get(key);
+
+ return toUserPresentable(extractIdFromPropertyExpression(InternalStringUtils.lastTerm(propertyExpression)));
+ }
+
+ /**
+ * Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case
+ * characters). Thus "userId" becomes "User Id", etc. Also, converts underscore into space (and capitalizes the
+ * following word), thus "user_id" also becomes "User Id".
+ */
+ public static String toUserPresentable(String id)
+ {
+ StringBuilder builder = new StringBuilder(id.length() * 2);
+
+ char[] chars = id.toCharArray();
+ boolean postSpace = true;
+ boolean upcaseNext = true;
+
+ for (char ch : chars)
+ {
+ if (upcaseNext)
+ {
+ builder.append(Character.toUpperCase(ch));
+ upcaseNext = false;
+
+ continue;
+ }
+
+ if (ch == '_')
+ {
+ builder.append(' ');
+ upcaseNext = true;
+ continue;
+ }
+
+ boolean upperCase = Character.isUpperCase(ch);
+
+ if (upperCase && !postSpace)
+ builder.append(' ');
+
+ builder.append(ch);
+
+ postSpace = upperCase;
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * @since 5.3
+ */
+ public static AnnotationProvider toAnnotationProvider(final Class element)
+ {
+ return new AnnotationProvider()
+ {
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+ {
+ return annotationClass.cast(element.getAnnotation(annotationClass));
+ }
+ };
+ }
+
+ public static AnnotationProvider toAnnotationProvider(final Method element)
+ {
+ if (element == null)
+ return NULL_ANNOTATION_PROVIDER;
+
+ return new AnnotationProvider()
+ {
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+ {
+ return element.getAnnotation(annotationClass);
+ }
+ };
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
new file mode 100644
index 0000000..154ee79
--- /dev/null
+++ b/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
@@ -0,0 +1,120 @@
+// Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.beaneditor;
+
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.ioc.internal.util.InternalStringUtils;
+
+/**
+ * Utilities used in a few places to modify an existing {@link BeanModel}.
+ */
+public final class BeanModelUtils
+{
+
+ final private static String[] EMPTY_STRING_ARRAY = new String[0];
+
+ /**
+ * Performs standard set of modifications to a {@link org.apache.tapestry5.beaneditor.BeanModel}
+ * . First new
+ * properties may be added, then properties removed, then properties reordered.
+ *
+ * @param model to modifiy
+ * @param addPropertyNames comma seperated list of property names to add, or null
+ * @param includePropertyNames comma seperated list of property names to include
+ * @param excludePropertyNames comma seperated list of property names to exclude, or null
+ * @param reorderPropertyNames comma seperated list of property names to reorder, or null
+ */
+ public static void modify(BeanModel model, String addPropertyNames,
+ String includePropertyNames, String excludePropertyNames, String reorderPropertyNames)
+ {
+ if (addPropertyNames != null)
+ add(model, addPropertyNames);
+
+ if (includePropertyNames != null)
+ include(model, join(includePropertyNames, addPropertyNames));
+
+ if (excludePropertyNames != null)
+ exclude(model, excludePropertyNames);
+
+ if (reorderPropertyNames != null)
+ reorder(model, reorderPropertyNames);
+ }
+
+ private static final String join(String firstList, String optionalSecondList)
+ {
+ if (InternalStringUtils.isBlank(optionalSecondList))
+ return firstList;
+
+ return firstList + "," + optionalSecondList;
+ }
+
+ /**
+ * Adds empty properties to the bean model. New properties are added with a <em>null</em>
+ * {@link org.apache.tapestry5.PropertyConduit}. `
+ *
+ * @param model to be modified
+ * @param propertyNames comma-separated list of property names
+ * @see BeanModel#addEmpty(String)
+ */
+ public static void add(BeanModel model, String propertyNames)
+ {
+ for (String name : split(propertyNames))
+ {
+ model.addEmpty(name);
+ }
+ }
+
+ /**
+ * Removes properties from the bean model.
+ *
+ * @param model
+ * @param propertyNames comma-separated list of property names
+ * @see BeanModel#exclude(String...)
+ */
+ public static void exclude(BeanModel model, String propertyNames)
+ {
+ model.exclude(split(propertyNames));
+ }
+
+ /**
+ * Selects a subset of the properties to keep, and reorders them.
+ */
+ public static void include(BeanModel model, String propertyNames)
+ {
+ model.include(split(propertyNames));
+ }
+
+ /**
+ * Reorders properties within the bean model.
+ *
+ * @param model
+ * @param propertyNames comma-separated list of property names
+ * @see BeanModel#reorder(String...)
+ */
+ public static void reorder(BeanModel model, String propertyNames)
+ {
+ model.reorder(split(propertyNames));
+ }
+
+ static String[] split(String propertyNames)
+ {
+ String trimmed = propertyNames.trim();
+
+ if (trimmed.length() == 0)
+ return EMPTY_STRING_ARRAY;
+
+ return trimmed.split("\\s*,\\s*");
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/PropertyModelImpl.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/PropertyModelImpl.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/PropertyModelImpl.java
index b21e5bb..4632818 100644
--- a/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/PropertyModelImpl.java
+++ b/beanmodel/src/main/java/org/apache/tapestry5/internal/beaneditor/PropertyModelImpl.java
@@ -20,7 +20,7 @@ import org.apache.tapestry5.PropertyConduit;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.beaneditor.PropertyModel;
import org.apache.tapestry5.beaneditor.Sortable;
-import org.apache.tapestry5.internal.BeanModelUtils;
+import org.apache.tapestry5.internal.InternalBeanModelUtils;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.internal.util.InternalStringUtils;
import org.apache.tapestry5.plastic.PlasticUtils;
@@ -48,9 +48,9 @@ public class PropertyModelImpl implements PropertyModel
this.name = name;
this.conduit = conduit;
- id = BeanModelUtils.extractIdFromPropertyExpression(name);
+ id = InternalBeanModelUtils.extractIdFromPropertyExpression(name);
- label = BeanModelUtils.defaultLabel(id, messages, name);
+ label = InternalBeanModelUtils.defaultLabel(id, messages, name);
// TAP5-2305
if (conduit != null)
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
new file mode 100644
index 0000000..bb20de0
--- /dev/null
+++ b/beanmodel/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
@@ -0,0 +1,222 @@
+// Copyright 2007, 2008, 2010, 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.services;
+
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.beaneditor.NonVisual;
+import org.apache.tapestry5.beaneditor.ReorderProperties;
+import org.apache.tapestry5.internal.beaneditor.BeanModelImpl;
+import org.apache.tapestry5.internal.beaneditor.BeanModelUtils;
+import org.apache.tapestry5.ioc.Location;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.ObjectLocator;
+import org.apache.tapestry5.ioc.annotations.Primary;
+import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry5.ioc.services.*;
+import org.apache.tapestry5.services.BeanModelSource;
+import org.apache.tapestry5.services.ComponentLayer;
+import org.apache.tapestry5.services.DataTypeAnalyzer;
+import org.apache.tapestry5.services.PropertyConduitSource;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.List;
+
+public class BeanModelSourceImpl implements BeanModelSource
+{
+ private final TypeCoercer typeCoercer;
+
+ private final PropertyAccess propertyAccess;
+
+ private final PropertyConduitSource propertyConduitSource;
+
+ private final PlasticProxyFactory proxyFactory;
+
+ private final DataTypeAnalyzer dataTypeAnalyzer;
+
+ private final ObjectLocator locator;
+
+ private static class PropertyOrder implements Comparable<PropertyOrder>
+ {
+ final String propertyName;
+
+ final int classDepth;
+
+ final int sortKey;
+
+ public PropertyOrder(final String propertyName, int classDepth, int sortKey)
+ {
+ this.propertyName = propertyName;
+ this.classDepth = classDepth;
+ this.sortKey = sortKey;
+ }
+
+ public int compareTo(PropertyOrder o)
+ {
+ int result = classDepth - o.classDepth;
+
+ if (result == 0)
+ result = sortKey - o.sortKey;
+
+ if (result == 0)
+ result = propertyName.compareTo(o.propertyName);
+
+ return result;
+ }
+ }
+
+ /**
+ * @param classAdapter defines the bean that contains the properties
+ * @param propertyNames the initial set of property names, which will be rebuilt in the correct order
+ */
+ private void orderProperties(ClassPropertyAdapter classAdapter, List<String> propertyNames)
+ {
+ List<PropertyOrder> properties = CollectionFactory.newList();
+
+ for (String name : propertyNames)
+ {
+ PropertyAdapter pa = classAdapter.getPropertyAdapter(name);
+
+ Method readMethod = pa.getReadMethod();
+
+ Location location = readMethod == null ? null : proxyFactory.getMethodLocation(readMethod);
+
+ int line = location == null ? -1 : location.getLine();
+
+ properties.add(new PropertyOrder(name, computeDepth(pa), line));
+ }
+
+ Collections.sort(properties);
+
+ propertyNames.clear();
+
+ for (PropertyOrder po : properties)
+ {
+ propertyNames.add(po.propertyName);
+ }
+ }
+
+ private static int computeDepth(PropertyAdapter pa)
+ {
+ int depth = 0;
+ Class c = pa.getDeclaringClass();
+
+ // When the method originates in an interface, the parent may be null, not Object.
+
+ while (c != null && c != Object.class)
+ {
+ depth++;
+ c = c.getSuperclass();
+ }
+
+ return depth;
+ }
+
+ public BeanModelSourceImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess,
+ PropertyConduitSource propertyConduitSource,
+ @ComponentLayer
+ PlasticProxyFactory proxyFactory,
+ @Primary
+ DataTypeAnalyzer dataTypeAnalyzer, ObjectLocator locator)
+ {
+ this.typeCoercer = typeCoercer;
+ this.propertyAccess = propertyAccess;
+ this.propertyConduitSource = propertyConduitSource;
+ this.proxyFactory = proxyFactory;
+ this.dataTypeAnalyzer = dataTypeAnalyzer;
+ this.locator = locator;
+ }
+
+ public <T> BeanModel<T> createDisplayModel(Class<T> beanClass, Messages messages)
+ {
+ return create(beanClass, false, messages);
+ }
+
+ public <T> BeanModel<T> createEditModel(Class<T> beanClass, Messages messages)
+ {
+ return create(beanClass, true, messages);
+ }
+
+ public <T> BeanModel<T> create(Class<T> beanClass, boolean filterReadOnlyProperties, Messages messages)
+ {
+ assert beanClass != null;
+ assert messages != null;
+ ClassPropertyAdapter adapter = propertyAccess.getAdapter(beanClass);
+
+ BeanModel<T> model = new BeanModelImpl<T>(beanClass, propertyConduitSource, typeCoercer, messages, locator);
+
+ for (final String propertyName : adapter.getPropertyNames())
+ {
+ PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);
+
+ if (!pa.isRead())
+ {
+ continue;
+ }
+
+ if (isStaticFieldProperty(pa))
+ {
+ continue;
+ }
+
+ if (pa.getAnnotation(NonVisual.class) != null)
+ {
+ continue;
+ }
+
+ if (filterReadOnlyProperties && !pa.isUpdate())
+ {
+ continue;
+ }
+
+ final String dataType = dataTypeAnalyzer.identifyDataType(pa);
+
+ // If an unregistered type, then ignore the property.
+
+ if (dataType == null)
+ {
+ continue;
+ }
+
+ model.add(propertyName).dataType(dataType);
+ }
+
+ // First, order the properties based on the location of the getter method
+ // within the class.
+
+ List<String> propertyNames = model.getPropertyNames();
+
+ orderProperties(adapter, propertyNames);
+
+ model.reorder(propertyNames.toArray(new String[propertyNames.size()]));
+
+ // Next, check for an annotation with specific ordering information.
+
+ ReorderProperties reorderAnnotation = beanClass.getAnnotation(ReorderProperties.class);
+
+ if (reorderAnnotation != null)
+ {
+ BeanModelUtils.reorder(model, reorderAnnotation.value());
+ }
+
+ return model;
+ }
+
+ private boolean isStaticFieldProperty(PropertyAdapter adapter)
+ {
+ return adapter.isField() && Modifier.isStatic(adapter.getField().getModifiers());
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/beanmodel/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
----------------------------------------------------------------------
diff --git a/beanmodel/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java b/beanmodel/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
index 83f67fa..4ce072e 100644
--- a/beanmodel/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
+++ b/beanmodel/src/main/java/org/apache/tapestry5/internal/services/PropertyConduitSourceImpl.java
@@ -19,7 +19,7 @@ import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.tree.Tree;
import org.apache.tapestry5.PropertyConduit;
import org.apache.tapestry5.PropertyConduit2;
-import org.apache.tapestry5.internal.BeanModelUtils;
+import org.apache.tapestry5.internal.InternalBeanModelUtils;
import org.apache.tapestry5.internal.InternalPropertyConduit;
import org.apache.tapestry5.internal.antlr.PropertyExpressionLexer;
import org.apache.tapestry5.internal.antlr.PropertyExpressionParser;
@@ -1260,7 +1260,7 @@ public class PropertyConduitSourceImpl implements PropertyConduitSource
Type returnType = GenericsUtils.extractActualType(activeType, method);
- return new Term(returnType, toUniqueId(method), BeanModelUtils.toAnnotationProvider(method), new InstructionBuilderCallback()
+ return new Term(returnType, toUniqueId(method), InternalBeanModelUtils.toAnnotationProvider(method), new InstructionBuilderCallback()
{
public void doBuild(InstructionBuilder builder)
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/commons/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java b/commons/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
new file mode 100644
index 0000000..ba7e995
--- /dev/null
+++ b/commons/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
@@ -0,0 +1,48 @@
+// Copyright 2007, 2008, 2011 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.services;
+
+import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
+import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
+import org.apache.tapestry5.ioc.services.PropertyAdapter;
+
+/**
+ * Used by {@link BeanModelSource} to identify the type of data associated with a particular property (represented as a
+ * {@link PropertyAdapter}). The data type is a string used to determine what kind of interface to use for displaying
+ * the value of the property, or what kind of interface to use for editing the value of the property. Common property
+ * types are "text", "enum", "checkbox", but the list is extensible.
+ * <p/>
+ * Different strategies for identifying the data type are encapsulated in the DataTypeAnalyzer service, forming a
+ * chain of command.
+ * <p/>
+ * The DefaultDataTypeAnalyzer service maps property types to data type names.
+ * <p/>
+ * The DataTypeAnalyzer service is an extensible {@linkplain org.apache.tapestry5.ioc.services.ChainBuilder chain of
+ * command}), that (by default) includes {@link org.apache.tapestry5.internal.services.AnnotationDataTypeAnalyzer} and
+ * the {@link org.apache.tapestry5.internal.services.DefaultDataTypeAnalyzer} service (ordered last). It uses an ordered configuration.
+ *
+ * @see org.apache.tapestry5.corelib.components.Grid
+ * @see org.apache.tapestry5.corelib.components.BeanEditForm
+ * @see BeanBlockSource
+ */
+@UsesOrderedConfiguration(DataTypeAnalyzer.class)
+@UsesMappedConfiguration(key = Class.class, value = String.class)
+public interface DataTypeAnalyzer
+{
+ /**
+ * Identifies the data type, if known, or returns null if not known.
+ */
+ String identifyDataType(PropertyAdapter adapter);
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
index aba7225..e69377f 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
@@ -59,7 +59,7 @@ public class TapestryInternalUtils
*/
public static String toUserPresentable(String id)
{
- return BeanModelUtils.toUserPresentable(id);
+ return InternalBeanModelUtils.toUserPresentable(id);
}
public static Map<String, String> mapFromKeysAndValues(String... keysAndValues)
@@ -228,7 +228,7 @@ public class TapestryInternalUtils
*/
public static String extractIdFromPropertyExpression(String expression)
{
- return BeanModelUtils.extractIdFromPropertyExpression(expression);
+ return InternalBeanModelUtils.extractIdFromPropertyExpression(expression);
}
/**
@@ -237,7 +237,7 @@ public class TapestryInternalUtils
*/
public static String defaultLabel(String id, Messages messages, String propertyExpression)
{
- return BeanModelUtils.defaultLabel(id, messages, propertyExpression);
+ return InternalBeanModelUtils.defaultLabel(id, messages, propertyExpression);
}
/**
@@ -304,7 +304,7 @@ public class TapestryInternalUtils
private static String replace(String input, Pattern pattern, String replacement)
{
- return BeanModelUtils.replace(input, pattern, replacement);
+ return InternalBeanModelUtils.replace(input, pattern, replacement);
}
/**
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
deleted file mode 100644
index 6a79b6e..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.internal.beaneditor;
-
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.internal.InternalConstants;
-import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-
-/**
- * Utilities used in a few places to modify an existing {@link BeanModel}.
- */
-public final class BeanModelUtils
-{
-
- /**
- * Performs standard set of modifications to a {@link org.apache.tapestry5.beaneditor.BeanModel}
- * . First new
- * properties may be added, then properties removed, then properties reordered.
- *
- * @param model to modifiy
- * @param addPropertyNames comma seperated list of property names to add, or null
- * @param includePropertyNames comma seperated list of property names to include
- * @param excludePropertyNames comma seperated list of property names to exclude, or null
- * @param reorderPropertyNames comma seperated list of property names to reorder, or null
- */
- public static void modify(BeanModel model, String addPropertyNames,
- String includePropertyNames, String excludePropertyNames, String reorderPropertyNames)
- {
- if (addPropertyNames != null)
- add(model, addPropertyNames);
-
- if (includePropertyNames != null)
- include(model, join(includePropertyNames, addPropertyNames));
-
- if (excludePropertyNames != null)
- exclude(model, excludePropertyNames);
-
- if (reorderPropertyNames != null)
- reorder(model, reorderPropertyNames);
- }
-
- private static final String join(String firstList, String optionalSecondList)
- {
- if (InternalUtils.isBlank(optionalSecondList))
- return firstList;
-
- return firstList + "," + optionalSecondList;
- }
-
- /**
- * Adds empty properties to the bean model. New properties are added with a <em>null</em>
- * {@link org.apache.tapestry5.PropertyConduit}. `
- *
- * @param model to be modified
- * @param propertyNames comma-separated list of property names
- * @see BeanModel#addEmpty(String)
- */
- public static void add(BeanModel model, String propertyNames)
- {
- for (String name : split(propertyNames))
- {
- model.addEmpty(name);
- }
- }
-
- /**
- * Removes properties from the bean model.
- *
- * @param model
- * @param propertyNames comma-separated list of property names
- * @see BeanModel#exclude(String...)
- */
- public static void exclude(BeanModel model, String propertyNames)
- {
- model.exclude(split(propertyNames));
- }
-
- /**
- * Selects a subset of the properties to keep, and reorders them.
- */
- public static void include(BeanModel model, String propertyNames)
- {
- model.include(split(propertyNames));
- }
-
- /**
- * Reorders properties within the bean model.
- *
- * @param model
- * @param propertyNames comma-separated list of property names
- * @see BeanModel#reorder(String...)
- */
- public static void reorder(BeanModel model, String propertyNames)
- {
- model.reorder(split(propertyNames));
- }
-
- static String[] split(String propertyNames)
- {
- String trimmed = propertyNames.trim();
-
- if (trimmed.length() == 0)
- return InternalConstants.EMPTY_STRING_ARRAY;
-
- return trimmed.split("\\s*,\\s*");
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
deleted file mode 100644
index bb20de0..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright 2007, 2008, 2010, 2011 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.internal.services;
-
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.beaneditor.NonVisual;
-import org.apache.tapestry5.beaneditor.ReorderProperties;
-import org.apache.tapestry5.internal.beaneditor.BeanModelImpl;
-import org.apache.tapestry5.internal.beaneditor.BeanModelUtils;
-import org.apache.tapestry5.ioc.Location;
-import org.apache.tapestry5.ioc.Messages;
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.annotations.Primary;
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.services.*;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.apache.tapestry5.services.ComponentLayer;
-import org.apache.tapestry5.services.DataTypeAnalyzer;
-import org.apache.tapestry5.services.PropertyConduitSource;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.List;
-
-public class BeanModelSourceImpl implements BeanModelSource
-{
- private final TypeCoercer typeCoercer;
-
- private final PropertyAccess propertyAccess;
-
- private final PropertyConduitSource propertyConduitSource;
-
- private final PlasticProxyFactory proxyFactory;
-
- private final DataTypeAnalyzer dataTypeAnalyzer;
-
- private final ObjectLocator locator;
-
- private static class PropertyOrder implements Comparable<PropertyOrder>
- {
- final String propertyName;
-
- final int classDepth;
-
- final int sortKey;
-
- public PropertyOrder(final String propertyName, int classDepth, int sortKey)
- {
- this.propertyName = propertyName;
- this.classDepth = classDepth;
- this.sortKey = sortKey;
- }
-
- public int compareTo(PropertyOrder o)
- {
- int result = classDepth - o.classDepth;
-
- if (result == 0)
- result = sortKey - o.sortKey;
-
- if (result == 0)
- result = propertyName.compareTo(o.propertyName);
-
- return result;
- }
- }
-
- /**
- * @param classAdapter defines the bean that contains the properties
- * @param propertyNames the initial set of property names, which will be rebuilt in the correct order
- */
- private void orderProperties(ClassPropertyAdapter classAdapter, List<String> propertyNames)
- {
- List<PropertyOrder> properties = CollectionFactory.newList();
-
- for (String name : propertyNames)
- {
- PropertyAdapter pa = classAdapter.getPropertyAdapter(name);
-
- Method readMethod = pa.getReadMethod();
-
- Location location = readMethod == null ? null : proxyFactory.getMethodLocation(readMethod);
-
- int line = location == null ? -1 : location.getLine();
-
- properties.add(new PropertyOrder(name, computeDepth(pa), line));
- }
-
- Collections.sort(properties);
-
- propertyNames.clear();
-
- for (PropertyOrder po : properties)
- {
- propertyNames.add(po.propertyName);
- }
- }
-
- private static int computeDepth(PropertyAdapter pa)
- {
- int depth = 0;
- Class c = pa.getDeclaringClass();
-
- // When the method originates in an interface, the parent may be null, not Object.
-
- while (c != null && c != Object.class)
- {
- depth++;
- c = c.getSuperclass();
- }
-
- return depth;
- }
-
- public BeanModelSourceImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess,
- PropertyConduitSource propertyConduitSource,
- @ComponentLayer
- PlasticProxyFactory proxyFactory,
- @Primary
- DataTypeAnalyzer dataTypeAnalyzer, ObjectLocator locator)
- {
- this.typeCoercer = typeCoercer;
- this.propertyAccess = propertyAccess;
- this.propertyConduitSource = propertyConduitSource;
- this.proxyFactory = proxyFactory;
- this.dataTypeAnalyzer = dataTypeAnalyzer;
- this.locator = locator;
- }
-
- public <T> BeanModel<T> createDisplayModel(Class<T> beanClass, Messages messages)
- {
- return create(beanClass, false, messages);
- }
-
- public <T> BeanModel<T> createEditModel(Class<T> beanClass, Messages messages)
- {
- return create(beanClass, true, messages);
- }
-
- public <T> BeanModel<T> create(Class<T> beanClass, boolean filterReadOnlyProperties, Messages messages)
- {
- assert beanClass != null;
- assert messages != null;
- ClassPropertyAdapter adapter = propertyAccess.getAdapter(beanClass);
-
- BeanModel<T> model = new BeanModelImpl<T>(beanClass, propertyConduitSource, typeCoercer, messages, locator);
-
- for (final String propertyName : adapter.getPropertyNames())
- {
- PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);
-
- if (!pa.isRead())
- {
- continue;
- }
-
- if (isStaticFieldProperty(pa))
- {
- continue;
- }
-
- if (pa.getAnnotation(NonVisual.class) != null)
- {
- continue;
- }
-
- if (filterReadOnlyProperties && !pa.isUpdate())
- {
- continue;
- }
-
- final String dataType = dataTypeAnalyzer.identifyDataType(pa);
-
- // If an unregistered type, then ignore the property.
-
- if (dataType == null)
- {
- continue;
- }
-
- model.add(propertyName).dataType(dataType);
- }
-
- // First, order the properties based on the location of the getter method
- // within the class.
-
- List<String> propertyNames = model.getPropertyNames();
-
- orderProperties(adapter, propertyNames);
-
- model.reorder(propertyNames.toArray(new String[propertyNames.size()]));
-
- // Next, check for an annotation with specific ordering information.
-
- ReorderProperties reorderAnnotation = beanClass.getAnnotation(ReorderProperties.class);
-
- if (reorderAnnotation != null)
- {
- BeanModelUtils.reorder(model, reorderAnnotation.value());
- }
-
- return model;
- }
-
- private boolean isStaticFieldProperty(PropertyAdapter adapter)
- {
- return adapter.isField() && Modifier.isStatic(adapter.getField().getModifiers());
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-core/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
deleted file mode 100644
index ba7e995..0000000
--- a/tapestry-core/src/main/java/org/apache/tapestry5/services/DataTypeAnalyzer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2007, 2008, 2011 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.services;
-
-import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration;
-import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
-import org.apache.tapestry5.ioc.services.PropertyAdapter;
-
-/**
- * Used by {@link BeanModelSource} to identify the type of data associated with a particular property (represented as a
- * {@link PropertyAdapter}). The data type is a string used to determine what kind of interface to use for displaying
- * the value of the property, or what kind of interface to use for editing the value of the property. Common property
- * types are "text", "enum", "checkbox", but the list is extensible.
- * <p/>
- * Different strategies for identifying the data type are encapsulated in the DataTypeAnalyzer service, forming a
- * chain of command.
- * <p/>
- * The DefaultDataTypeAnalyzer service maps property types to data type names.
- * <p/>
- * The DataTypeAnalyzer service is an extensible {@linkplain org.apache.tapestry5.ioc.services.ChainBuilder chain of
- * command}), that (by default) includes {@link org.apache.tapestry5.internal.services.AnnotationDataTypeAnalyzer} and
- * the {@link org.apache.tapestry5.internal.services.DefaultDataTypeAnalyzer} service (ordered last). It uses an ordered configuration.
- *
- * @see org.apache.tapestry5.corelib.components.Grid
- * @see org.apache.tapestry5.corelib.components.BeanEditForm
- * @see BeanBlockSource
- */
-@UsesOrderedConfiguration(DataTypeAnalyzer.class)
-@UsesMappedConfiguration(key = Class.class, value = String.class)
-public interface DataTypeAnalyzer
-{
- /**
- * Identifies the data type, if known, or returns null if not known.
- */
- String identifyDataType(PropertyAdapter adapter);
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
deleted file mode 100644
index a336365..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.ioc.annotations;
-
-import java.lang.annotation.*;
-
-/**
- * A documentation-only interface placed on service interfaces for services which have a {@linkplain
- * org.apache.tapestry5.ioc.MappedConfiguration mapped configuration}, to identify the type of key (often, a String),
- * and type ofcontribution.
- * <p/>
- * Remember that when the key type is String, the map will be case-insensitive.
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-@Documented
-@UseWith(AnnotationUseContext.SERVICE)
-public @interface UsesMappedConfiguration
-{
- /**
- * The type of key used to identify contribution values.
- */
- Class key() default String.class;
-
- /**
- * The type of object which may be contributed into the service's configuration.
- */
- Class value();
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
deleted file mode 100644
index 7c608f6..0000000
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2008, 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package org.apache.tapestry5.ioc.annotations;
-
-import java.lang.annotation.*;
-
-/**
- * A documentation-only interface placed on service interfaces for services which have an {@linkplain
- * org.apache.tapestry5.ioc.OrderedConfiguration ordered configuration}, to identify the type of contribution.
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-@Documented
-@UseWith(AnnotationUseContext.SERVICE)
-public @interface UsesOrderedConfiguration
-{
- /**
- * The type of object which may be contributed into the service's configuration.
- */
- Class value();
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
----------------------------------------------------------------------
diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
index a40f984..8f1f7b6 100644
--- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
+++ b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
@@ -17,7 +17,7 @@ package org.apache.tapestry5.ioc.internal.util;
import org.apache.tapestry5.func.F;
import org.apache.tapestry5.func.Mapper;
import org.apache.tapestry5.func.Predicate;
-import org.apache.tapestry5.internal.BeanModelUtils;
+import org.apache.tapestry5.internal.InternalBeanModelUtils;
import org.apache.tapestry5.internal.plastic.PlasticInternalUtils;
import org.apache.tapestry5.ioc.*;
import org.apache.tapestry5.ioc.annotations.*;
@@ -777,7 +777,7 @@ public class InternalUtils
*/
public static AnnotationProvider toAnnotationProvider(final Class element)
{
- return BeanModelUtils.toAnnotationProvider(element);
+ return InternalBeanModelUtils.toAnnotationProvider(element);
}
/**
@@ -1404,7 +1404,7 @@ public class InternalUtils
public static AnnotationProvider toAnnotationProvider(final Method element)
{
- return BeanModelUtils.toAnnotationProvider(element);
+ return InternalBeanModelUtils.toAnnotationProvider(element);
}
public static <T> ObjectCreator<T> createConstructorConstructionPlan(final OperationTracker tracker, final ObjectLocator locator,
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
----------------------------------------------------------------------
diff --git a/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
new file mode 100644
index 0000000..a336365
--- /dev/null
+++ b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesMappedConfiguration.java
@@ -0,0 +1,41 @@
+// Copyright 2008, 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.ioc.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * A documentation-only interface placed on service interfaces for services which have a {@linkplain
+ * org.apache.tapestry5.ioc.MappedConfiguration mapped configuration}, to identify the type of key (often, a String),
+ * and type ofcontribution.
+ * <p/>
+ * Remember that when the key type is String, the map will be case-insensitive.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.CLASS)
+@Documented
+@UseWith(AnnotationUseContext.SERVICE)
+public @interface UsesMappedConfiguration
+{
+ /**
+ * The type of key used to identify contribution values.
+ */
+ Class key() default String.class;
+
+ /**
+ * The type of object which may be contributed into the service's configuration.
+ */
+ Class value();
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/dd958465/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
----------------------------------------------------------------------
diff --git a/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
new file mode 100644
index 0000000..7c608f6
--- /dev/null
+++ b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesOrderedConfiguration.java
@@ -0,0 +1,33 @@
+// Copyright 2008, 2009 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.ioc.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * A documentation-only interface placed on service interfaces for services which have an {@linkplain
+ * org.apache.tapestry5.ioc.OrderedConfiguration ordered configuration}, to identify the type of contribution.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.CLASS)
+@Documented
+@UseWith(AnnotationUseContext.SERVICE)
+public @interface UsesOrderedConfiguration
+{
+ /**
+ * The type of object which may be contributed into the service's configuration.
+ */
+ Class value();
+}