tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r917695 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/ tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/main/java/org/apache/tapestry5/services/ tape...
Date Mon, 01 Mar 2010 20:28:57 GMT
Author: hlship
Date: Mon Mar  1 20:28:56 2010
New Revision: 917695

URL: http://svn.apache.org/viewvc?rev=917695&view=rev
Log:
TAP5-1035: Add ObjectRenderer for the AvailableValues type, make use of UnknownValueException inside ComponentClassResolverImpl

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java   (with props)
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java   (contents, props changed)
      - copied, changed from r917694, tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/PossibleValues.java
Removed:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/PossibleValues.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/util/StringToEnumCoercion.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/UnknownValueException.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java?rev=917695&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java Mon Mar  1 20:28:56 2010
@@ -0,0 +1,52 @@
+// Copyright 2010 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.renderers;
+
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ioc.internal.util.AvailableValues;
+import org.apache.tapestry5.services.ObjectRenderer;
+
+/**
+ * Renders out a {@link AvailableValues} instance as a <div> enclosing a <ul>.
+ * 
+ * @since 5.2.0
+ */
+public class AvailableValuesRenderer implements ObjectRenderer<AvailableValues>
+{
+    public void render(AvailableValues values, MarkupWriter writer)
+    {
+        writer.element("div", "class", "t-available-values");
+
+        writer.element("p");
+
+        writer.writef("Available %s:", values.getValueType());
+
+        writer.end();
+
+        writer.element("ul");
+
+        for (String value : values.getValues())
+        {
+            writer.element("li");
+            writer.write(value);
+            writer.end();
+        }
+
+        writer.end();
+
+        writer.end(); // div
+    }
+
+}

Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/AvailableValuesRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentClassResolverImpl.java Mon Mar  1 20:28:56 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 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
+// 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,
@@ -21,6 +21,8 @@
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.internal.util.AvailableValues;
+import org.apache.tapestry5.ioc.internal.util.UnknownValueException;
 import org.apache.tapestry5.ioc.services.ClassNameLocator;
 import org.apache.tapestry5.services.ComponentClassResolver;
 import org.apache.tapestry5.services.InvalidationListener;
@@ -77,7 +79,6 @@
      */
     private final Map<String, String> pageClassNameToLogicalName = CollectionFactory.newMap();
 
-
     /**
      * Used to convert a logical page name to the canonical form of the page name; this ensures that uniform case for
      * page names is used.
@@ -94,14 +95,15 @@
 
     public ComponentClassResolverImpl(Logger logger,
 
-                                      ComponentInstantiatorSource componentInstantiatorSource,
+    ComponentInstantiatorSource componentInstantiatorSource,
 
-                                      ClassNameLocator classNameLocator,
+    ClassNameLocator classNameLocator,
 
-                                      @Inject @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
-                                      String appRootPackage,
+    @Inject
+    @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
+    String appRootPackage,
 
-                                      Collection<LibraryMapping> mappings)
+    Collection<LibraryMapping> mappings)
     {
         this.logger = logger;
         this.componentInstantiatorSource = componentInstantiatorSource;
@@ -173,7 +175,8 @@
      */
     private void rebuild()
     {
-        if (!needsRebuild) return;
+        if (!needsRebuild)
+            return;
 
         barrier.withWrite(new Runnable()
         {
@@ -209,7 +212,6 @@
                 rebuild(folder, packageName);
         }
 
-
         showChanges("pages", savedPages, pageToClassName);
         showChanges("components", savedComponents, componentToClassName);
         showChanges("mixins", savedMixins, mixinToClassName);
@@ -219,7 +221,8 @@
 
     private void showChanges(String title, Map<String, String> savedMap, Map<String, String> newMap)
     {
-        if (savedMap.equals(newMap)) return;
+        if (savedMap.equals(newMap))
+            return;
 
         Map<String, String> core = CollectionFactory.newMap();
         Map<String, String> nonCore = CollectionFactory.newMap();
@@ -267,7 +270,8 @@
         {
             String className = core.get(name);
 
-            if (name.equals("")) name = "(blank)";
+            if (name.equals(""))
+                name = "(blank)";
 
             f.format(formatString, name, className);
         }
@@ -283,7 +287,7 @@
     }
 
     private void fillNameToClassNameMap(String pathPrefix, String rootPackage, String subPackage,
-                                        Map<String, String> logicalNameToClassName)
+            Map<String, String> logicalNameToClassName)
     {
         String searchPackage = rootPackage + "." + subPackage;
         boolean isPage = subPackage.equals(InternalConstants.PAGES_SUBPACKAGE);
@@ -323,15 +327,17 @@
         }
     }
 
-
     /**
      * Converts a fully qualified class name to a logical name
-     *
-     * @param className  fully qualified class name
-     * @param pathPrefix prefix to be placed on the logical name (to identify the library from in which the class
-     *                   lives)
-     * @param startPos   start position within the class name to extract the logical name (i.e., after the final '.' in
-     *                   "rootpackage.pages.").
+     * 
+     * @param className
+     *            fully qualified class name
+     * @param pathPrefix
+     *            prefix to be placed on the logical name (to identify the library from in which the class
+     *            lives)
+     * @param startPos
+     *            start position within the class name to extract the logical name (i.e., after the final '.' in
+     *            "rootpackage.pages.").
      * @param stripTerms
      * @return a short logical name in folder format ('.' replaced with '/')
      */
@@ -357,10 +363,12 @@
 
             sep = "/";
 
-            if (stripTerms) logicalName = stripTerm(term, logicalName);
+            if (stripTerms)
+                logicalName = stripTerm(term, logicalName);
         }
 
-        if (logicalName.equals("")) logicalName = unstripped;
+        if (logicalName.equals(""))
+            logicalName = unstripped;
 
         builder.append(sep);
         builder.append(logicalName);
@@ -372,7 +380,8 @@
     {
         for (String term : splitter.split(input))
         {
-            if (term.equals("")) continue;
+            if (term.equals(""))
+                continue;
 
             terms.add(term);
         }
@@ -400,8 +409,7 @@
 
     private boolean isCaselessSuffix(String suffix, String string)
     {
-        return string.regionMatches(true, string.length() - suffix.length(), suffix, 0, suffix
-                .length());
+        return string.regionMatches(true, string.length() - suffix.length(), suffix, 0, suffix.length());
     }
 
     public String resolvePageNameToClassName(final String pageName)
@@ -412,8 +420,9 @@
             {
                 String result = locate(pageName, pageToClassName);
 
-                if (result == null) throw new IllegalArgumentException(
-                        ServicesMessages.couldNotResolvePageName(pageName, presentableNames(pageToClassName)));
+                if (result == null)
+                    throw new UnknownValueException(String.format("Unable to resolve '%s' to a page class name.",
+                            pageName), new AvailableValues("page names", presentableNames(pageToClassName)));
 
                 return result;
             }
@@ -456,8 +465,10 @@
             {
                 String result = locate(componentType, componentToClassName);
 
-                if (result == null) throw new IllegalArgumentException(ServicesMessages
-                        .couldNotResolveComponentType(componentType, presentableNames(componentToClassName)));
+                if (result == null)
+                    throw new UnknownValueException(String.format("Unable to resolve '%s' to a component class name.",
+                            componentType), new AvailableValues("component types",
+                            presentableNames(componentToClassName)));
 
                 return result;
             }
@@ -491,8 +502,9 @@
             {
                 String result = locate(mixinType, mixinToClassName);
 
-                if (result == null) throw new IllegalArgumentException(
-                        ServicesMessages.couldNotResolveMixinType(mixinType, presentableNames(mixinToClassName)));
+                if (result == null)
+                    throw new UnknownValueException(String.format("Unable to resolve '%s' to a mixin class name.",
+                            mixinType), new AvailableValues("mixin types", presentableNames(mixinToClassName)));
 
                 return result;
             }
@@ -502,9 +514,11 @@
     /**
      * Locates a class name within the provided map, given its logical name. If not found naturally, a search inside the
      * "core" library is included.
-     *
-     * @param logicalName            name to search for
-     * @param logicalNameToClassName mapping from logical name to class name
+     * 
+     * @param logicalName
+     *            name to search for
+     * @param logicalNameToClassName
+     *            mapping from logical name to class name
      * @return the located class name or null
      */
     private String locate(String logicalName, Map<String, String> logicalNameToClassName)
@@ -516,7 +530,8 @@
         // If not found, see if it exists under the core package. In this way,
         // anything in core is "inherited" (but overridable) by the application.
 
-        if (result == null) result = logicalNameToClassName.get(CORE_LIBRARY_PREFIX + logicalName);
+        if (result == null)
+            result = logicalNameToClassName.get(CORE_LIBRARY_PREFIX + logicalName);
 
         return result;
     }
@@ -531,8 +546,8 @@
 
                 String result = pageClassNameToLogicalName.get(pageClassName);
 
-                if (result == null) throw new IllegalArgumentException(ServicesMessages
-                        .pageNameUnresolved(pageClassName));
+                if (result == null)
+                    throw new IllegalArgumentException(ServicesMessages.pageNameUnresolved(pageClassName));
 
                 return result;
             }
@@ -547,8 +562,9 @@
             {
                 String result = locate(pageName, pageNameToCanonicalPageName);
 
-                if (result == null) throw new IllegalArgumentException(ServicesMessages
-                        .couldNotCanonicalizePageName(pageName, presentableNames(pageNameToCanonicalPageName)));
+                if (result == null)
+                    throw new UnknownValueException(String.format("Unable to resolve '%s' to a known page name.",
+                            pageName), new AvailableValues("page names", presentableNames(pageNameToCanonicalPageName)));
 
                 return result;
             }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServicesMessages.java Mon Mar  1 20:28:56 2010
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -104,8 +104,7 @@
 
     static String exceptionInMethodParameter(String methodDescription, int index, Throwable cause)
     {
-        return MESSAGES
-                .format("exception-in-method-parameter", methodDescription, index + 1, cause);
+        return MESSAGES.format("exception-in-method-parameter", methodDescription, index + 1, cause);
     }
 
     static String componentEventIsAborted(String methodDescription)
@@ -119,30 +118,6 @@
                 .joinSorted(strategyNames));
     }
 
-    static String couldNotResolvePageName(String pageName, Collection<String> pageNames)
-    {
-        return MESSAGES.format("could-not-resolve-page-name", pageName, InternalUtils
-                .joinSorted(pageNames));
-    }
-
-    static String couldNotCanonicalizePageName(String pageName, Collection<String> pageNames)
-    {
-        return MESSAGES.format("could-not-canonicalize-page-name", pageName, InternalUtils
-                .joinSorted(pageNames));
-    }
-
-    static String couldNotResolveComponentType(String componentType, Collection<String> componentTypes)
-    {
-        return MESSAGES.format("could-not-resolve-component-type", componentType, InternalUtils
-                .joinSorted(componentTypes));
-    }
-
-    static String couldNotResolveMixinType(String mixinType, Collection<String> mixinTypes)
-    {
-        return MESSAGES.format("could-not-resolve-mixin-type", mixinType, InternalUtils
-                .joinSorted(mixinTypes));
-    }
-
     static String parameterNameMustBeUnique(String parameterName, String parameterValue)
     {
         return MESSAGES.format("parameter-name-must-be-unique", parameterName, parameterValue);
@@ -155,8 +130,7 @@
 
     static String componentInstanceIsNotAPage(Component result)
     {
-        return MESSAGES.format("component-instance-is-not-a-page", result.getComponentResources()
-                .getCompleteId());
+        return MESSAGES.format("component-instance-is-not-a-page", result.getComponentResources().getCompleteId());
     }
 
     static String failureReadingMessages(Resource url, Throwable cause)
@@ -179,23 +153,20 @@
         return MESSAGES.format("wrong-asset-digest", resource.getPath());
     }
 
-
     static String unknownValidatorType(String validatorType, List<String> knownValidatorTypes)
     {
-        return MESSAGES.format("unknown-validator-type", validatorType, InternalUtils
-                .join(knownValidatorTypes));
+        return MESSAGES.format("unknown-validator-type", validatorType, InternalUtils.join(knownValidatorTypes));
     }
 
     static String unknownTranslatorType(String translatorType, List<String> knownTranslatorTypes)
     {
-        return MESSAGES.format("unknown-translator-type", translatorType, InternalUtils
-                .join(knownTranslatorTypes));
+        return MESSAGES.format("unknown-translator-type", translatorType, InternalUtils.join(knownTranslatorTypes));
     }
 
     static String validatorSpecificationParseError(int cursor, String specification)
     {
         return MESSAGES.format("validator-specification-parse-error", specification.charAt(cursor), cursor + 1,
-                               specification);
+                specification);
     }
 
     static String mixinsInvalidWithoutIdOrType(String elementName)
@@ -210,12 +181,10 @@
         for (Class c : availableTypes)
             types.add(c.getName());
 
-        return MESSAGES.format("missing-from-environment", type.getName(), InternalUtils
-                .joinSorted(types));
+        return MESSAGES.format("missing-from-environment", type.getName(), InternalUtils.joinSorted(types));
     }
 
-    static String invalidComponentEventResult(Object result,
-                                              Collection<Class> configuredResultTypes)
+    static String invalidComponentEventResult(Object result, Collection<Class> configuredResultTypes)
     {
         List<String> classNames = CollectionFactory.newList();
 
@@ -238,8 +207,8 @@
 
     static String missingApplicationStatePersistenceStrategy(String name, Collection<String> availableNames)
     {
-        return MESSAGES.format("missing-application-state-persistence-strategy", name,
-                               InternalUtils.joinSorted(availableNames));
+        return MESSAGES.format("missing-application-state-persistence-strategy", name, InternalUtils
+                .joinSorted(availableNames));
     }
 
     static String methodIsVoid(String methodName, Class inClass, String propertyExpression)
@@ -253,10 +222,10 @@
     }
 
     static String noSuchProperty(Class targetClass, String propertyName, String propertyExpression,
-                                 Collection<String> propertyNames)
+            Collection<String> propertyNames)
     {
         return MESSAGES.format("no-such-property", targetClass.getName(), propertyName, propertyExpression,
-                               InternalUtils.joinSorted(propertyNames));
+                InternalUtils.joinSorted(propertyNames));
     }
 
     static String writeOnlyProperty(String propertyName, Class clazz, String propertyExpression)
@@ -274,7 +243,6 @@
         return MESSAGES.format("component-recursion", componentClassName);
     }
 
-
     static String clientStateMustBeSerializable(Object newValue)
     {
         return MESSAGES.format("client-state-must-be-serializable", newValue);
@@ -301,10 +269,10 @@
     }
 
     static String missingValidatorConstraint(String validatorType, Class type, String perFormMessageKey,
-                                             String generalMessageKey)
+            String generalMessageKey)
     {
         return MESSAGES.format("missing-validator-constraint", validatorType, type.getName(), perFormMessageKey,
-                               generalMessageKey);
+                generalMessageKey);
     }
 
     static String resourcesAccessForbidden(String URI)
@@ -344,8 +312,8 @@
 
     public static String noTranslatorForType(Class valueType, Collection<String> typeNames)
     {
-        return MESSAGES.format("no-translator-for-type", ClassFabUtils.toJavaClassName(valueType),
-                               InternalUtils.joinSorted(typeNames));
+        return MESSAGES.format("no-translator-for-type", ClassFabUtils.toJavaClassName(valueType), InternalUtils
+                .joinSorted(typeNames));
     }
 
     static String emptyBinding(String parameterName)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Mon Mar  1 20:28:56 2010
@@ -65,6 +65,7 @@
 import org.apache.tapestry5.internal.grid.CollectionGridDataSource;
 import org.apache.tapestry5.internal.grid.NullDataSource;
 import org.apache.tapestry5.internal.gzip.GZipFilter;
+import org.apache.tapestry5.internal.renderers.AvailableValuesRenderer;
 import org.apache.tapestry5.internal.renderers.ComponentResourcesRenderer;
 import org.apache.tapestry5.internal.renderers.EventContextRenderer;
 import org.apache.tapestry5.internal.renderers.ListRenderer;
@@ -83,6 +84,7 @@
 import org.apache.tapestry5.internal.validator.ValidatorMacroImpl;
 import org.apache.tapestry5.ioc.*;
 import org.apache.tapestry5.ioc.annotations.*;
+import org.apache.tapestry5.ioc.internal.util.AvailableValues;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.IdAllocator;
 import org.apache.tapestry5.ioc.services.*;
@@ -1805,8 +1807,11 @@
     /**
      * Contributes a default object renderer for type Object, plus specialized
      * renderers for {@link org.apache.tapestry5.services.Request}, {@link org.apache.tapestry5.ioc.Location},
-     * {@link org.apache.tapestry5.ComponentResources}, {@link org.apache.tapestry5.EventContext}, List, and Object[].
+     * {@link org.apache.tapestry5.ComponentResources}, {@link org.apache.tapestry5.EventContext},
+     * {@link AvailableValues},
+     * List, and Object[].
      */
+    @SuppressWarnings("unchecked")
     public void contributeObjectRenderer(MappedConfiguration<Class, ObjectRenderer> configuration,
 
     @InjectService("LocationRenderer")
@@ -1836,6 +1841,7 @@
         configuration.addInstance(Object[].class, ObjectArrayRenderer.class);
         configuration.addInstance(ComponentResources.class, ComponentResourcesRenderer.class);
         configuration.addInstance(EventContext.class, EventContextRenderer.class);
+        configuration.add(AvailableValues.class, new AvailableValuesRenderer());
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/util/StringToEnumCoercion.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/util/StringToEnumCoercion.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/util/StringToEnumCoercion.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/util/StringToEnumCoercion.java Mon Mar  1 20:28:56 2010
@@ -1,10 +1,10 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2010 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
+// 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,
@@ -14,18 +14,21 @@
 
 package org.apache.tapestry5.util;
 
+import java.util.Map;
+
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.internal.util.AvailableValues;
+import org.apache.tapestry5.ioc.internal.util.UnknownValueException;
 import org.apache.tapestry5.ioc.services.Coercion;
 
-import java.util.Map;
-
 /**
  * A {@link org.apache.tapestry5.ioc.services.Coercion} for converting strings into an instance of a particular
  * enumerated type. The {@link Enum#name() name} is used as the key to identify the enum instance, in a case-insensitive
  * fashion.
- *
- * @param <T> the type of enumeration
+ * 
+ * @param <T>
+ *            the type of enumeration
  */
 public final class StringToEnumCoercion<T extends Enum> implements Coercion<String, T>
 {
@@ -54,15 +57,13 @@
         T result = stringToEnum.get(input);
 
         if (result == null)
-            throw new RuntimeException(PublicUtilMessages.missingEnumValue(
-                    input,
-                    enumClass,
-                    stringToEnum.keySet()));
+            throw new UnknownValueException(PublicUtilMessages
+                    .missingEnumValue(input, enumClass, stringToEnum.keySet()), new AvailableValues(enumClass.getName()
+                    + " enum constants", stringToEnum));
 
         return result;
     }
 
-
     public static <T extends Enum> StringToEnumCoercion<T> create(Class<T> enumClass)
     {
         return new StringToEnumCoercion<T>(enumClass);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/default.css Mon Mar  1 20:28:56 2010
@@ -469,4 +469,10 @@
   font-weight: bold;
   font: italic;
   color: red;
+}
+
+DIV.t-available-values UL LI
+{
+  list-style-type : disc;
+  margin-left: 0px;
 }
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/ServicesStrings.properties Mon Mar  1 20:28:56 2010
@@ -32,10 +32,7 @@
 exception-in-method-parameter=Exception in method %s, parameter #%d: %s
 component-event-is-aborted=Can not store result from invoking method %s, because an event result value has already been obtained from some other event handler method.
 unknown-persistent-field-strategy='%s' is not a defined persistent strategy.  Defined strategies: %s.
-could-not-resolve-page-name=Unable to resolve '%s' to a page class name.  Available page names: %s.
 could-not-canonicalize-page-name=Unable to resolve '%s' to a known page name. Available page names: %s.
-could-not-resolve-component-type=Unable to resolve '%s' to a component class name.  Available component types: %s.
-could-not-resolve-mixin-type=Unable to resolve '%s' to a mixin class name.  Available mixin types: %s.
 parameter-name-must-be-unique=Parameter names are required to be unique.  Parameter '%s' already has the value '%s'.
 page-is-dirty=Page %s is dirty, and will be discarded (rather than returned to the page pool).
 component-instance-is-not-a-page=Component %s was returned from an event handler method, but is not a page component. The page containing the component will render the client response.

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentClassResolverImplTest.java Mon Mar  1 20:28:56 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010 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
+// 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,
@@ -15,6 +15,7 @@
 package org.apache.tapestry5.internal.services;
 
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
+import org.apache.tapestry5.ioc.internal.util.UnknownValueException;
 import org.apache.tapestry5.ioc.services.ClassNameLocator;
 import org.apache.tapestry5.services.ComponentClassResolver;
 import org.apache.tapestry5.services.LibraryMapping;
@@ -41,7 +42,7 @@
     private static final String LIB_ROOT_PACKAGE = "org.example.lib";
 
     private ComponentClassResolverImpl create(Logger logger, ComponentInstantiatorSource source,
-                                              ClassNameLocator locator, LibraryMapping... mappings)
+            ClassNameLocator locator, LibraryMapping... mappings)
     {
         List<LibraryMapping> list = Arrays.asList(mappings);
 
@@ -93,12 +94,9 @@
 
         train_for_app_packages(source);
 
-
-        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages",
-                                        APP_ROOT_PACKAGE + ".pages.SimplePage",
-                                        APP_ROOT_PACKAGE + ".pages.nested.Other",
-                                        APP_ROOT_PACKAGE + ".pages.nested.NestedPage",
-                                        APP_ROOT_PACKAGE + ".pages.nested.NestedIndex");
+        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE + ".pages.SimplePage",
+                APP_ROOT_PACKAGE + ".pages.nested.Other", APP_ROOT_PACKAGE + ".pages.nested.NestedPage",
+                APP_ROOT_PACKAGE + ".pages.nested.NestedIndex");
 
         replay();
 
@@ -136,7 +134,6 @@
         verify();
     }
 
-
     @Test
     public void canonicalize_existing_page_name()
     {
@@ -259,24 +256,24 @@
         train_for_app_packages(source);
 
         train_locateComponentClassNames(locator, CORE_ROOT_PACKAGE + ".pages", CORE_ROOT_PACKAGE + ".pages.Fred",
-                                        CORE_ROOT_PACKAGE + ".pages.Barney");
+                CORE_ROOT_PACKAGE + ".pages.Barney");
         train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE + ".pages.Wilma",
-                                        APP_ROOT_PACKAGE + ".pages.Betty");
+                APP_ROOT_PACKAGE + ".pages.Betty");
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         try
         {
             resolver.resolvePageNameToClassName("Unknown");
             unreachable();
         }
-        catch (RuntimeException ex)
+        catch (UnknownValueException ex)
         {
-            assertEquals(ex.getMessage(),
-                         "Unable to resolve \'Unknown\' to a page class name.  Available page names: Barney, Betty, Fred, Wilma.");
+            assertEquals(ex.getMessage(), "Unable to resolve \'Unknown\' to a page class name.");
+            assertEquals(ex.getAvailableValues().toString(), "AvailableValues[page names: Barney, Betty, Fred, Wilma]");
         }
 
         verify();
@@ -345,8 +342,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         // Can look like an application page, but still resolves to the core library class name.
 
@@ -378,7 +375,7 @@
     }
 
     protected final void train_locateComponentClassNames(ClassNameLocator locator, String packageName,
-                                                         String... classNames)
+            String... classNames)
     {
         expect(locator.locateClassNames(packageName)).andReturn(Arrays.asList(classNames));
     }
@@ -467,8 +464,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("MyCorePage"), className);
 
@@ -491,8 +488,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageClassNameToPageName(className), "core/MyCorePage");
 
@@ -516,9 +513,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(LIB_PREFIX,
+                LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/MyLibPage"), className);
 
@@ -542,9 +538,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping("/" + LIB_PREFIX + "/", LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping("/" + LIB_PREFIX + "/",
+                LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/MyLibPage"), className);
 
@@ -568,9 +563,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(LIB_PREFIX,
+                LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/MyLibPage"), className);
 
@@ -594,9 +588,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(LIB_PREFIX,
+                LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/Page"), className);
 
@@ -622,9 +615,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(libPrefix, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(libPrefix,
+                LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/deep/Page"), className);
         assertEquals(resolver.resolvePageNameToClassName("lib/deep/LibDeepPage"), className);
@@ -632,7 +624,6 @@
         verify();
     }
 
-
     @Test
     public void class_name_does_not_resolve_to_page_name()
     {
@@ -645,8 +636,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         String className = LIB_ROOT_PACKAGE + ".pages.LibPage";
 
@@ -678,18 +669,17 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         try
         {
             resolver.canonicalizePageName("MissingPage");
             unreachable();
         }
-        catch (IllegalArgumentException ex)
+        catch (UnknownValueException ex)
         {
-            assertEquals(ex.getMessage(),
-                         "Unable to resolve \'MissingPage\' to a known page name. Available page names: Start.");
+            assertEquals(ex.getMessage(), "Unable to resolve 'MissingPage' to a known page name.");
         }
 
         verify();
@@ -707,8 +697,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         String className = CORE_ROOT_PACKAGE + ".foo.CorePage";
 
@@ -744,10 +734,9 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(LIB_PREFIX, secondaryLibPackage),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(LIB_PREFIX,
+                LIB_ROOT_PACKAGE), new LibraryMapping(LIB_PREFIX, secondaryLibPackage), new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/MyLibPage"), className);
 
@@ -773,15 +762,14 @@
         replay();
 
         ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping("lib/deep", deepPackage),
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+                new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE), new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
             resolver.resolvePageNameToClassName("lib/deep/DeepPage");
             unreachable();
         }
-        catch (IllegalArgumentException ex)
+        catch (UnknownValueException ex)
         {
             assertMessageContains(ex, "Unable to resolve 'lib/deep/DeepPage' to a page class name.");
         }
@@ -861,15 +849,15 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         try
         {
             resolver.resolveMixinTypeToClassName("SimpleMixin");
             unreachable();
         }
-        catch (IllegalArgumentException ex)
+        catch (UnknownValueException ex)
         {
             assertMessageContains(ex, "Unable to resolve 'SimpleMixin' to a mixin class name.");
         }
@@ -889,15 +877,15 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(logger, source, locator,
-                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping(CORE_PREFIX,
+                CORE_ROOT_PACKAGE));
 
         try
         {
             resolver.resolveComponentTypeToClassName("SimpleComponent");
             unreachable();
         }
-        catch (IllegalArgumentException ex)
+        catch (UnknownValueException ex)
         {
             assertTrue(ex.getMessage().contains("Unable to resolve 'SimpleComponent' to a component class name."));
         }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCMessages.java Mon Mar  1 20:28:56 2010
@@ -235,11 +235,6 @@
         return MESSAGES.format("service-construction-failed", serviceDef.getServiceId(), cause);
     }
 
-    static String noSuchService(String serviceId, Collection<String> serviceIds)
-    {
-        return MESSAGES.format("no-such-service", serviceId, InternalUtils.joinSorted(serviceIds));
-    }
-
     static String serviceIdConflict(String serviceId, ServiceDef existing, ServiceDef conflicting)
     {
         return MESSAGES.format("service-id-conflict", serviceId, existing, conflicting);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java Mon Mar  1 20:28:56 2010
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -73,8 +73,7 @@
      */
     private final Map<String, Module> serviceIdToModule = CollectionFactory.newCaseInsensitiveMap();
 
-    private final Map<String, ServiceLifecycle2> lifecycles = CollectionFactory
-            .newCaseInsensitiveMap();
+    private final Map<String, ServiceLifecycle2> lifecycles = CollectionFactory.newCaseInsensitiveMap();
 
     private final PerthreadManager perthreadManager;
 
@@ -105,8 +104,7 @@
      * @param loggerSource
      *            used to obtain Logger instances
      */
-    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory,
-            LoggerSource loggerSource)
+    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, LoggerSource loggerSource)
     {
         this.loggerSource = loggerSource;
 
@@ -169,8 +167,7 @@
             moduleToServiceDefs.put(module, moduleServiceDefs);
         }
 
-        addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID, ServiceActivityScoreboard.class,
-                scoreboardAndTracker);
+        addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID, ServiceActivityScoreboard.class, scoreboardAndTracker);
         addBuiltin(LOGGER_SOURCE_SERVICE_ID, LoggerSource.class, this.loggerSource);
         addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, this.classFactory);
         addBuiltin(PERTHREAD_MANAGER_SERVICE_ID, PerthreadManager.class, perthreadManager);
@@ -199,9 +196,8 @@
         {
             String serviceId = cd.getServiceId();
 
-            if (!serviceIdToModule.containsKey(serviceId)) { throw new IllegalArgumentException(
-                    String.format("Contribution %s is for service '%s', which does not exist.", cd,
-                            serviceId)); }
+            if (!serviceIdToModule.containsKey(serviceId)) { throw new IllegalArgumentException(String.format(
+                    "Contribution %s is for service '%s', which does not exist.", cd, serviceId)); }
         }
     }
 
@@ -338,8 +334,8 @@
         }
         catch (ClassCastException ex)
         {
-            throw new RuntimeException(IOCMessages.serviceWrongInterface(serviceId, builtinTypes
-                    .get(serviceId), serviceInterface));
+            throw new RuntimeException(IOCMessages.serviceWrongInterface(serviceId, builtinTypes.get(serviceId),
+                    serviceInterface));
         }
     }
 
@@ -355,8 +351,8 @@
         Module module = serviceIdToModule.get(serviceId);
 
         if (module == null)
-            throw new RuntimeException(IOCMessages.noSuchService(serviceId, serviceIdToModule
-                    .keySet()));
+            throw new UnknownValueException(String.format("Service id '%s' is not defined by any module.", serviceId),
+                    new AvailableValues("service ids", serviceIdToModule));
 
         return module;
     }
@@ -382,8 +378,7 @@
         Logger logger = getServiceLogger(serviceId);
 
         Orderer<T> orderer = new Orderer<T>(logger);
-        Map<String, OrderedConfigurationOverride<T>> overrides = CollectionFactory
-                .newCaseInsensitiveMap();
+        Map<String, OrderedConfigurationOverride<T>> overrides = CollectionFactory.newCaseInsensitiveMap();
 
         for (Module m : moduleToServiceDefs.keySet())
             addToOrderedConfiguration(orderer, overrides, objectType, serviceDef, m);
@@ -395,8 +390,7 @@
         {
             ObjectProvider contribution = new ObjectProvider()
             {
-                public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
-                        ObjectLocator locator)
+                public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
                 {
                     return findServiceByMarkerAndType(objectType, annotationProvider, null);
                 }
@@ -411,8 +405,7 @@
         return orderer.getOrdered();
     }
 
-    public <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType,
-            Class<V> objectType)
+    public <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType, Class<V> objectType)
     {
         lock.check();
 
@@ -423,8 +416,7 @@
         Map<K, MappedConfigurationOverride<K, V>> overrides = newConfigurationMap(keyType);
 
         for (Module m : moduleToServiceDefs.keySet())
-            addToMappedConfiguration(result, overrides, keyToContribution, keyType, objectType,
-                    serviceDef, m);
+            addToMappedConfiguration(result, overrides, keyToContribution, keyType, objectType, serviceDef, m);
 
         for (MappedConfigurationOverride<K, V> override : overrides.values())
         {
@@ -447,10 +439,9 @@
         return CollectionFactory.newMap();
     }
 
-    private <K, V> void addToMappedConfiguration(Map<K, V> map,
-            Map<K, MappedConfigurationOverride<K, V>> overrides,
-            Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType,
-            ServiceDef serviceDef, final Module module)
+    private <K, V> void addToMappedConfiguration(Map<K, V> map, Map<K, MappedConfigurationOverride<K, V>> overrides,
+            Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType, ServiceDef serviceDef,
+            final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
@@ -462,14 +453,12 @@
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
-                classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
-            final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(
-                    map, overrides, serviceId, def, keyClass, valueType, keyToContribution,
-                    resources);
+            final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(map, overrides,
+                    serviceId, def, keyClass, valueType, keyToContribution, resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -486,8 +475,8 @@
         }
     }
 
-    private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType,
-            ServiceDef serviceDef, final Module module)
+    private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType, ServiceDef serviceDef,
+            final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
@@ -499,13 +488,12 @@
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
-                classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
-            final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(collection,
-                    serviceId, valueType, resources);
+            final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(collection, serviceId, valueType,
+                    resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -523,8 +511,8 @@
     }
 
     private <T> void addToOrderedConfiguration(Orderer<T> orderer,
-            Map<String, OrderedConfigurationOverride<T>> overrides, Class<T> valueType,
-            ServiceDef serviceDef, final Module module)
+            Map<String, OrderedConfigurationOverride<T>> overrides, Class<T> valueType, ServiceDef serviceDef,
+            final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
@@ -535,13 +523,12 @@
         Logger logger = getServiceLogger(serviceId);
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
-                classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
-            final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(
-                    orderer, overrides, def, serviceId, valueType, resources);
+            final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(orderer, overrides,
+                    def, serviceId, valueType, resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -584,8 +571,7 @@
 
                 Collections.sort(serviceIds);
 
-                throw new RuntimeException(IOCMessages.manyServiceMatches(serviceInterface,
-                        serviceIds));
+                throw new RuntimeException(IOCMessages.manyServiceMatches(serviceInterface, serviceIds));
         }
     }
 
@@ -615,8 +601,7 @@
 
         if (result == null)
         {
-            ServiceLifecycleSource source = getService("ServiceLifecycleSource",
-                    ServiceLifecycleSource.class);
+            ServiceLifecycleSource source = getService("ServiceLifecycleSource", ServiceLifecycleSource.class);
 
             result = source.get(scope);
         }
@@ -644,16 +629,13 @@
             if (decoratorDefs.isEmpty())
                 continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
-                    classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
 
             for (DecoratorDef decoratorDef : decoratorDefs)
             {
                 ServiceDecorator decorator = decoratorDef.createDecorator(module, resources);
 
-                orderer
-                        .add(decoratorDef.getDecoratorId(), decorator, decoratorDef
-                                .getConstraints());
+                orderer.add(decoratorDef.getDecoratorId(), decorator, decoratorDef.getConstraints());
             }
         }
 
@@ -677,8 +659,7 @@
             if (advisorDefs.isEmpty())
                 continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
-                    classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
 
             for (AdvisorDef advisorDef : advisorDefs)
             {
@@ -698,8 +679,8 @@
         return classFactory.newClass(serviceInterface);
     }
 
-    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider,
-            ObjectLocator locator, Module localModule)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator,
+            Module localModule)
     {
         lock.check();
 
@@ -716,14 +697,13 @@
         if (result != null)
             return result;
 
-        MasterObjectProvider masterProvider = getService(
-                IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID, MasterObjectProvider.class);
+        MasterObjectProvider masterProvider = getService(IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID,
+                MasterObjectProvider.class);
 
         return masterProvider.provide(objectType, effectiveProvider, locator, true);
     }
 
-    private Collection<ServiceDef2> filterByType(Class<?> objectType,
-            Collection<ServiceDef2> serviceDefs)
+    private Collection<ServiceDef2> filterByType(Class<?> objectType, Collection<ServiceDef2> serviceDefs)
     {
         Collection<ServiceDef2> result = CollectionFactory.newSet();
 
@@ -739,8 +719,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    private <T> T findServiceByMarkerAndType(Class<T> objectType, AnnotationProvider provider,
-            Module localModule)
+    private <T> T findServiceByMarkerAndType(Class<T> objectType, AnnotationProvider provider, Module localModule)
     {
         if (provider == null)
             return null;
@@ -749,8 +728,7 @@
 
         Set<ServiceDef2> matches = CollectionFactory.newSet();
 
-        matches.addAll(filterByType(objectType, localOnly ? moduleToServiceDefs.get(localModule)
-                : allServiceDefs));
+        matches.addAll(filterByType(objectType, localOnly ? moduleToServiceDefs.get(localModule) : allServiceDefs));
 
         List<Class> markers = CollectionFactory.newList();
 
@@ -796,8 +774,7 @@
                 throw new RuntimeException(IOCMessages.noServicesMatchMarker(objectType, markers));
 
             default:
-                throw new RuntimeException(IOCMessages.manyServicesMatchMarker(objectType, markers,
-                        matches));
+                throw new RuntimeException(IOCMessages.manyServicesMatchMarker(objectType, markers, matches));
         }
     }
 
@@ -900,8 +877,8 @@
                 {
                     InternalUtils.validateConstructorForAutobuild(constructor);
 
-                    Object[] parameters = InternalUtils.calculateParametersForConstructor(
-                            constructor, locator, resources, tracker);
+                    Object[] parameters = InternalUtils.calculateParametersForConstructor(constructor, locator,
+                            resources, tracker);
 
                     Object result = constructor.newInstance(parameters);
 
@@ -920,8 +897,7 @@
 
                 String description = classFactory.getConstructorLocation(constructor).toString();
 
-                throw new RuntimeException(IOCMessages.autobuildConstructorError(description,
-                        failure), failure);
+                throw new RuntimeException(IOCMessages.autobuildConstructorError(description, failure), failure);
             }
         };
 
@@ -963,8 +939,8 @@
 
         ClassFab cf = classFactory.newClass(interfaceClass);
 
-        String description = String.format("<Autobuild proxy %s(%s)>", implementationClass
-                .getName(), interfaceClass.getName());
+        String description = String.format("<Autobuild proxy %s(%s)>", implementationClass.getName(), interfaceClass
+                .getName());
 
         return ClassFabUtils.createObjectCreatorProxy(cf, interfaceClass, justInTime, description);
     }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java Mon Mar  1 20:28:56 2010
@@ -25,7 +25,7 @@
 import org.apache.tapestry5.ioc.internal.util.Defense;
 import org.apache.tapestry5.ioc.internal.util.InheritanceSearch;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.internal.util.PossibleValues;
+import org.apache.tapestry5.ioc.internal.util.AvailableValues;
 import org.apache.tapestry5.ioc.internal.util.UnknownValueException;
 import org.apache.tapestry5.ioc.services.ClassFabUtils;
 import org.apache.tapestry5.ioc.services.Coercion;
@@ -292,7 +292,7 @@
      * alphabetically.
      */
     @SuppressWarnings("unchecked")
-    private PossibleValues buildCoercionCatalog()
+    private AvailableValues buildCoercionCatalog()
     {
         List<CoercionTuple> masterList = CollectionFactory.newList();
 
@@ -301,7 +301,7 @@
             masterList.addAll(list);
         }
 
-        return new PossibleValues("coercions", masterList);
+        return new AvailableValues("coercions", masterList);
     }
 
     /**

Copied: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java (from r917694, tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/PossibleValues.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java?p2=tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java&p1=tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/PossibleValues.java&r1=917694&r2=917695&rev=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/PossibleValues.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java Mon Mar  1 20:28:56 2010
@@ -25,7 +25,7 @@
  * 
  * @since 5.2.0
  */
-public class PossibleValues
+public class AvailableValues
 {
     private final String valueType;
 
@@ -38,13 +38,13 @@
      *            a set of objects defining the values; the values will be converted to strings and sorted into
      *            ascending order
      */
-    public PossibleValues(String valueType, Collection<?> values)
+    public AvailableValues(String valueType, Collection<?> values)
     {
         this.valueType = valueType;
         this.values = sortValues(values);
     }
 
-    public PossibleValues(String valueType, Map<?, ?> map)
+    public AvailableValues(String valueType, Map<?, ?> map)
     {
         this(valueType, map.keySet());
     }
@@ -58,6 +58,8 @@
             result.add(String.valueOf(v));
         }
 
+        Collections.sort(result);
+
         return Collections.unmodifiableList(result);
     }
 
@@ -76,7 +78,7 @@
     @Override
     public String toString()
     {
-        return String.format("PossibleValues[%s: %s]", valueType, InternalUtils.join(values));
+        return String.format("AvailableValues[%s: %s]", valueType, InternalUtils.join(values));
     }
 
 }

Propchange: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/AvailableValues.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/UnknownValueException.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/UnknownValueException.java?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/UnknownValueException.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/UnknownValueException.java Mon Mar  1 20:28:56 2010
@@ -16,7 +16,7 @@
 
 /**
  * Special exception used when a value (typically from a map) is referenced that does not exist. Uses a
- * {@link PossibleValues} object
+ * {@link AvailableValues} object
  * to track what the known values are.
  * 
  * @since 5.2.0
@@ -25,23 +25,23 @@
 {
     private static final long serialVersionUID = -8131503136299055706L;
 
-    private final PossibleValues possibleValues;
+    private final AvailableValues availableValues;
 
-    public UnknownValueException(String message, PossibleValues values)
+    public UnknownValueException(String message, AvailableValues availableValues)
     {
-        this(message, null, null, values);
+        this(message, null, null, availableValues);
     }
 
-    public UnknownValueException(String message, Object location, Throwable cause, PossibleValues values)
+    public UnknownValueException(String message, Object location, Throwable cause, AvailableValues availableValues)
     {
         super(message, location, cause);
 
-        this.possibleValues = values;
+        this.availableValues = availableValues;
     }
 
-    public PossibleValues getPossibleValues()
+    public AvailableValues getAvailableValues()
     {
-        return possibleValues;
+        return availableValues;
     }
 
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties?rev=917695&r1=917694&r2=917695&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/resources/org/apache/tapestry5/ioc/internal/IOCStrings.properties Mon Mar  1 20:28:56 2010
@@ -68,7 +68,6 @@
   The constructor, %s, is in some way is triggering a service builder, decorator or contribution method within the class.
 constructed-configuration=Constructed configuration: %s
 service-construction-failed=Construction of service %s failed: %s
-no-such-service=Service id '%s' is not defined by any module.  Defined services: %s.
 service-id-conflict=Service id '%s' has already been defined by %s and may not be redefined by %s. \
  You should rename one of the service builder methods.
 no-constructor=Class %s (implementation of service '%s') does not contain any public constructors.



Mime
View raw message