You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/02/19 17:14:47 UTC
svn commit: r509234 - in /tapestry/tapestry5/tapestry-ioc/trunk/src: images/
main/java/org/apache/tapestry/ioc/
main/java/org/apache/tapestry/ioc/internal/
main/java/org/apache/tapestry/ioc/internal/services/
main/java/org/apache/tapestry/ioc/internal/...
Author: hlship
Date: Mon Feb 19 08:14:45 2007
New Revision: 509234
URL: http://svn.apache.org/viewvc?view=rev&rev=509234
Log:
Add an explain() method to TypeCoercer.
Add a Float --> Double coercion.
Change the descriptions of coercions and tuples to omit "java.lang".
Remove a few other warnings.
Modified:
tapestry/tapestry5/tapestry-ioc/trunk/src/images/type-coercer.graffle
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassFactoryClassPool.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/ClasspathResource.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/MethodSignature.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TypeCoercer.java
tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt
tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/type-coercer.png
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImplTest.java
tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/util/CaseInsensitiveMapTest.java
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/images/type-coercer.graffle
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/images/type-coercer.graffle?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/images/type-coercer.graffle (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/images/type-coercer.graffle Mon Feb 19 08:14:45 2007
@@ -30,6 +30,158 @@
<key>GraphicsList</key>
<array>
<dict>
+ <key>Bounds</key>
+ <string>{{69, 472.8}, {61, 36}}</string>
+ <key>Class</key>
+ <string>ShapedGraphic</string>
+ <key>ID</key>
+ <integer>61</integer>
+ <key>Shape</key>
+ <string>RoundRect</string>
+ <key>Style</key>
+ <dict>
+ <key>fill</key>
+ <dict>
+ <key>Color</key>
+ <dict>
+ <key>b</key>
+ <string>0.8</string>
+ <key>g</key>
+ <string>0.8</string>
+ <key>r</key>
+ <string>0.8</string>
+ </dict>
+ </dict>
+ </dict>
+ <key>Text</key>
+ <dict>
+ <key>Text</key>
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
+
+\f0\fs24 \cf0 null}</string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Bounds</key>
+ <string>{{54.5, 174.8}, {90, 36}}</string>
+ <key>Class</key>
+ <string>ShapedGraphic</string>
+ <key>FontInfo</key>
+ <dict>
+ <key>Color</key>
+ <dict>
+ <key>b</key>
+ <string>0</string>
+ <key>g</key>
+ <string>0</string>
+ <key>r</key>
+ <string>0</string>
+ </dict>
+ </dict>
+ <key>ID</key>
+ <integer>59</integer>
+ <key>Shape</key>
+ <string>RoundRect</string>
+ <key>Style</key>
+ <dict>
+ <key>fill</key>
+ <dict>
+ <key>Color</key>
+ <dict>
+ <key>b</key>
+ <string>0.0941176</string>
+ <key>g</key>
+ <string>0.917647</string>
+ <key>r</key>
+ <string>1</string>
+ </dict>
+ </dict>
+ </dict>
+ <key>Text</key>
+ <dict>
+ <key>Text</key>
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
+
+\f0\fs24 \cf0 Collection}</string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Bounds</key>
+ <string>{{65.5, 676}, {68, 36}}</string>
+ <key>Class</key>
+ <string>ShapedGraphic</string>
+ <key>ID</key>
+ <integer>54</integer>
+ <key>Shape</key>
+ <string>RoundRect</string>
+ <key>Style</key>
+ <dict>
+ <key>fill</key>
+ <dict>
+ <key>Color</key>
+ <dict>
+ <key>b</key>
+ <string>0.0941176</string>
+ <key>g</key>
+ <string>0.917647</string>
+ <key>r</key>
+ <string>1</string>
+ </dict>
+ </dict>
+ </dict>
+ <key>Text</key>
+ <dict>
+ <key>Text</key>
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
+
+\f0\fs24 \cf0 Object[]}</string>
+ </dict>
+ </dict>
+ <dict>
+ <key>Bounds</key>
+ <string>{{69, 595}, {61, 36}}</string>
+ <key>Class</key>
+ <string>ShapedGraphic</string>
+ <key>ID</key>
+ <integer>52</integer>
+ <key>Shape</key>
+ <string>RoundRect</string>
+ <key>Style</key>
+ <dict>
+ <key>fill</key>
+ <dict>
+ <key>Color</key>
+ <dict>
+ <key>b</key>
+ <string>0.0941176</string>
+ <key>g</key>
+ <string>0.917647</string>
+ <key>r</key>
+ <string>1</string>
+ </dict>
+ </dict>
+ </dict>
+ <key>Text</key>
+ <dict>
+ <key>Text</key>
+ <string>{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural
+
+\f0\fs24 \cf0 List}</string>
+ </dict>
+ </dict>
+ <dict>
<key>Class</key>
<string>LineGraphic</string>
<key>Head</key>
@@ -176,8 +328,8 @@
<integer>47</integer>
<key>Points</key>
<array>
- <string>{313.545, 368.916}</string>
- <string>{226.411, 374.998}</string>
+ <string>{314.779, 357.228}</string>
+ <string>{131.494, 288.923}</string>
</array>
<key>Style</key>
<dict>
@@ -201,7 +353,7 @@
</dict>
<dict>
<key>Bounds</key>
- <string>{{158, 359.4}, {68, 36}}</string>
+ <string>{{65.5, 259}, {68, 36}}</string>
<key>Class</key>
<string>ShapedGraphic</string>
<key>ID</key>
@@ -236,7 +388,7 @@
</dict>
<dict>
<key>Bounds</key>
- <string>{{446, 333.5}, {61, 36}}</string>
+ <string>{{442.5, 333}, {61, 36}}</string>
<key>Class</key>
<string>ShapedGraphic</string>
<key>FontInfo</key>
@@ -326,7 +478,7 @@
</dict>
<dict>
<key>Bounds</key>
- <string>{{449.5, 259}, {54, 36}}</string>
+ <string>{{446, 259}, {54, 36}}</string>
<key>Class</key>
<string>ShapedGraphic</string>
<key>ID</key>
@@ -431,7 +583,7 @@
</dict>
<dict>
<key>Bounds</key>
- <string>{{43, 259}, {90, 36}}</string>
+ <string>{{149.5, 349}, {90, 36}}</string>
<key>Class</key>
<string>ShapedGraphic</string>
<key>FontInfo</key>
@@ -625,8 +777,8 @@
<integer>43</integer>
<key>Points</key>
<array>
- <string>{192, 472.3}</string>
- <string>{192, 395.9}</string>
+ <string>{184.014, 472.341}</string>
+ <string>{107.486, 295.459}</string>
</array>
<key>Style</key>
<dict>
@@ -660,8 +812,8 @@
<integer>41</integer>
<key>Points</key>
<array>
- <string>{473.465, 472.3}</string>
- <string>{476.035, 370}</string>
+ <string>{473, 472.3}</string>
+ <string>{473, 369.5}</string>
</array>
<key>Style</key>
<dict>
@@ -672,7 +824,7 @@
<key>LineType</key>
<integer>1</integer>
<key>TailArrow</key>
- <string>0</string>
+ <string>FilledArrow</string>
<key>Width</key>
<real>4</real>
</dict>
@@ -765,8 +917,8 @@
<integer>36</integer>
<key>Points</key>
<array>
- <string>{364.541, 351.364}</string>
- <string>{452.96, 292.636}</string>
+ <string>{364.333, 351.091}</string>
+ <string>{449.667, 292.909}</string>
</array>
<key>Style</key>
<dict>
@@ -870,8 +1022,8 @@
<integer>31</integer>
<key>Points</key>
<array>
- <string>{128.297, 291.335}</string>
- <string>{314.667, 357.632}</string>
+ <string>{240, 367}</string>
+ <string>{313.5, 367}</string>
</array>
<key>Style</key>
<dict>
@@ -905,8 +1057,8 @@
<integer>29</integer>
<key>Points</key>
<array>
- <string>{183.025, 472.35}</string>
- <string>{96.9745, 295.45}</string>
+ <string>{192.374, 472.3}</string>
+ <string>{194.126, 385.5}</string>
</array>
<key>Style</key>
<dict>
@@ -953,7 +1105,7 @@
<key>LineType</key>
<integer>1</integer>
<key>TailArrow</key>
- <string>FilledArrow</string>
+ <string>0</string>
<key>Width</key>
<real>4</real>
</dict>
@@ -1035,6 +1187,216 @@
<integer>4</integer>
</dict>
</dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>52</integer>
+ </dict>
+ <key>ID</key>
+ <integer>53</integer>
+ <key>Points</key>
+ <array>
+ <string>{163.096, 587.562}</string>
+ <string>{128.404, 601.438}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>48</integer>
+ </dict>
+ </dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>52</integer>
+ </dict>
+ <key>ID</key>
+ <integer>55</integer>
+ <key>Points</key>
+ <array>
+ <string>{99.5, 675.5}</string>
+ <string>{99.5, 631.5}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>54</integer>
+ </dict>
+ </dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>42</integer>
+ </dict>
+ <key>ID</key>
+ <integer>60</integer>
+ <key>Points</key>
+ <array>
+ <string>{99.5, 211.3}</string>
+ <string>{99.5, 258.5}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>59</integer>
+ </dict>
+ </dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>42</integer>
+ </dict>
+ <key>ID</key>
+ <integer>62</integer>
+ <key>Points</key>
+ <array>
+ <string>{99.5, 472.3}</string>
+ <string>{99.5, 295.5}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>61</integer>
+ </dict>
+ </dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>4</integer>
+ </dict>
+ <key>ID</key>
+ <integer>63</integer>
+ <key>Points</key>
+ <array>
+ <string>{130.5, 490.8}</string>
+ <string>{164.5, 490.8}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>61</integer>
+ </dict>
+ </dict>
+ <dict>
+ <key>Class</key>
+ <string>LineGraphic</string>
+ <key>Head</key>
+ <dict>
+ <key>ID</key>
+ <integer>52</integer>
+ </dict>
+ <key>ID</key>
+ <integer>64</integer>
+ <key>Points</key>
+ <array>
+ <string>{99.5, 509.3}</string>
+ <string>{99.5, 594.5}</string>
+ </array>
+ <key>Style</key>
+ <dict>
+ <key>stroke</key>
+ <dict>
+ <key>HeadArrow</key>
+ <string>FilledArrow</string>
+ <key>LineType</key>
+ <integer>1</integer>
+ <key>TailArrow</key>
+ <string>0</string>
+ <key>Width</key>
+ <real>4</real>
+ </dict>
+ </dict>
+ <key>Tail</key>
+ <dict>
+ <key>ID</key>
+ <integer>61</integer>
+ </dict>
+ </dict>
</array>
<key>GridInfo</key>
<dict/>
@@ -1135,7 +1497,7 @@
</dict>
</array>
<key>ModificationDate</key>
- <string>2007-02-11 10:11:41 -0800</string>
+ <string>2007-02-19 08:06:00 -0800</string>
<key>Modifier</key>
<string>Howard Lewis Ship</string>
<key>NotesVisible</key>
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -16,7 +16,6 @@
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -14,7 +14,7 @@
package org.apache.tapestry.ioc.internal;
-import static org.apache.tapestry.ioc.IOCUtilities.toQualifiedId;
+import static org.apache.tapestry.ioc.IOCUtilities.toQualifiedId;
import static org.apache.tapestry.ioc.internal.ConfigurationType.MAPPED;
import static org.apache.tapestry.ioc.internal.ConfigurationType.ORDERED;
import static org.apache.tapestry.ioc.internal.ConfigurationType.UNORDERED;
@@ -24,33 +24,32 @@
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.Configuration;
-import org.apache.tapestry.ioc.IOCConstants;
-import org.apache.tapestry.ioc.IOCUtilities;
-import org.apache.tapestry.ioc.MappedConfiguration;
-import org.apache.tapestry.ioc.OrderedConfiguration;
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.EagerLoad;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.Lifecycle;
-import org.apache.tapestry.ioc.annotations.Match;
-import org.apache.tapestry.ioc.annotations.Order;
-import org.apache.tapestry.ioc.annotations.Private;
-import org.apache.tapestry.ioc.def.ContributionDef;
-import org.apache.tapestry.ioc.def.DecoratorDef;
-import org.apache.tapestry.ioc.def.ModuleDef;
-import org.apache.tapestry.ioc.def.ServiceDef;
-import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.IOCConstants;
+import org.apache.tapestry.ioc.IOCUtilities;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.annotations.Contribute;
+import org.apache.tapestry.ioc.annotations.EagerLoad;
+import org.apache.tapestry.ioc.annotations.Id;
+import org.apache.tapestry.ioc.annotations.Lifecycle;
+import org.apache.tapestry.ioc.annotations.Match;
+import org.apache.tapestry.ioc.annotations.Order;
+import org.apache.tapestry.ioc.annotations.Private;
+import org.apache.tapestry.ioc.def.ContributionDef;
+import org.apache.tapestry.ioc.def.DecoratorDef;
+import org.apache.tapestry.ioc.def.ModuleDef;
+import org.apache.tapestry.ioc.def.ServiceDef;
/**
* Starting from the Class for a module builder, identifies all the services (service builder
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -119,6 +119,7 @@
{ List.class }, null, builder.toString());
}
+ @SuppressWarnings("unchecked")
private <T> T createInstance(Class<T> instanceClass, List<T> commands)
{
try
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassFactoryClassPool.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassFactoryClassPool.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassFactoryClassPool.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ClassFactoryClassPool.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -18,10 +18,8 @@
import java.util.Set;
-import javassist.CannotCompileException;
import javassist.ClassPath;
import javassist.ClassPool;
-import javassist.CtClass;
import javassist.LoaderClassPath;
/**
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java Mon Feb 19 08:14:45 2007
@@ -19,6 +19,7 @@
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
import java.util.Collection;
import java.util.LinkedList;
@@ -26,7 +27,6 @@
import java.util.Map;
import java.util.Set;
-import org.apache.tapestry.ioc.internal.util.Defense;
import org.apache.tapestry.ioc.internal.util.InheritanceSearch;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
import org.apache.tapestry.ioc.services.ClassFabUtils;
@@ -89,6 +89,12 @@
{
return null;
}
+
+ @Override
+ public String toString()
+ {
+ return "null --> null";
+ }
};
public TypeCoercerImpl(Collection<CoercionTuple> tuples)
@@ -119,7 +125,7 @@
@SuppressWarnings("unchecked")
public Object coerce(Object input, Class targetType)
{
- Defense.notNull(targetType, "targetType");
+ notNull(targetType, "targetType");
// Treat null as void in terms of locating a coercion.
@@ -155,6 +161,24 @@
// Double check that the coercer provided a result of the correct type
return effectiveTargetType.cast(result);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <S, T> String explain(Class<S> inputType, Class<T> targetType)
+ {
+ notNull(inputType, "inputType");
+ notNull(targetType, "targetType");
+
+ Class effectiveTargetType = ClassFabUtils.getWrapperType(targetType);
+
+ // Is a coercion even necessary? Not if the target type is assignable from the
+ // input value.
+
+ if (effectiveTargetType.isAssignableFrom(inputType)) return "";
+
+ Coercion coercion = findCoercion(inputType, effectiveTargetType);
+
+ return coercion.toString();
}
private Coercion findCoercion(Class sourceType, Class targetType)
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/ClasspathResource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/ClasspathResource.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/ClasspathResource.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/ClasspathResource.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -17,7 +17,6 @@
import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
import java.net.URL;
-import java.util.Locale;
import org.apache.tapestry.ioc.Resource;
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/CoercionTuple.java Mon Feb 19 08:14:45 2007
@@ -39,27 +39,40 @@
* Wraps an arbitrary coercion with an implementation of toString() that identifies the source
* and target types.
*/
- private class CoercionWrapper<S, T> implements Coercion<S, T>
+ private class CoercionWrapper<WS, WT> implements Coercion<WS, WT>
{
- private final Coercion<S, T> _coercion;
+ private final Coercion<WS, WT> _coercion;
- public CoercionWrapper(Coercion<S, T> coercion)
+ public CoercionWrapper(Coercion<WS, WT> coercion)
{
_coercion = coercion;
}
- public T coerce(S input)
+ public WT coerce(WS input)
{
return _coercion.coerce(input);
}
public String toString()
{
- return String.format(
- "%s --> %s",
- ClassFabUtils.getJavaClassName(_sourceType),
- ClassFabUtils.getJavaClassName(_targetType));
+ return String.format("%s --> %s", convert(_sourceType), convert(_targetType));
}
+ }
+
+ private String convert(Class type)
+ {
+ if (void.class.equals(type)) return "null";
+
+ String name = ClassFabUtils.getJavaClassName(type);
+
+ int dotx = name.lastIndexOf('.');
+
+ // Strip off a package name of "java.lang"
+
+ if (dotx > 0 && name.substring(0, dotx).equals("java.lang"))
+ return name.substring(dotx + 1);
+
+ return name;
}
/**
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/MethodSignature.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/MethodSignature.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/MethodSignature.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/MethodSignature.java Mon Feb 19 08:14:45 2007
@@ -129,19 +129,15 @@
@Override
public boolean equals(Object o)
{
- if (o == null || !(o instanceof MethodSignature))
- return false;
+ if (o == null || !(o instanceof MethodSignature)) return false;
MethodSignature ms = (MethodSignature) o;
- if (_returnType != ms._returnType)
- return false;
+ if (_returnType != ms._returnType) return false;
- if (!_name.equals(ms._name))
- return false;
+ if (!_name.equals(ms._name)) return false;
- if (mismatch(_parameterTypes, ms._parameterTypes))
- return false;
+ if (mismatch(_parameterTypes, ms._parameterTypes)) return false;
return !mismatch(_exceptionTypes, ms._exceptionTypes);
}
@@ -151,16 +147,14 @@
int a1Count = size(a1);
int a2Count = size(a2);
- if (a1Count != a2Count)
- return true;
+ if (a1Count != a2Count) return true;
// Hm. What if order is important (for exceptions)? We're really saying here that they
// were derived from the name Method.
for (int i = 0; i < a1Count; i++)
{
- if (a1[i] != a2[i])
- return true;
+ if (a1[i] != a2[i]) return true;
}
return false;
@@ -178,8 +172,7 @@
for (int i = 0; i < size(_parameterTypes); i++)
{
- if (i > 0)
- buffer.append(", ");
+ if (i > 0) buffer.append(", ");
buffer.append(ClassFabUtils.getJavaClassName(_parameterTypes[i]));
}
@@ -214,8 +207,7 @@
for (int i = 0; i < size(_parameterTypes); i++)
{
- if (i > 0)
- buffer.append(",");
+ if (i > 0) buffer.append(",");
buffer.append(ClassFabUtils.getJavaClassName(_parameterTypes[i]));
}
@@ -233,14 +225,11 @@
public boolean isOverridingSignatureOf(MethodSignature ms)
{
- if (_returnType != ms._returnType)
- return false;
+ if (_returnType != ms._returnType) return false;
- if (!_name.equals(ms._name))
- return false;
+ if (!_name.equals(ms._name)) return false;
- if (mismatch(_parameterTypes, ms._parameterTypes))
- return false;
+ if (mismatch(_parameterTypes, ms._parameterTypes)) return false;
return exceptionsEncompass(ms._exceptionTypes);
}
@@ -250,6 +239,7 @@
* this signature's.
*/
+ @SuppressWarnings("unchecked")
private boolean exceptionsEncompass(Class[] otherExceptions)
{
int ourCount = size(_exceptionTypes);
@@ -258,8 +248,7 @@
// If we have no exceptions, then ours encompass theirs only if they
// have no exceptions, either.
- if (ourCount == 0)
- return otherCount == 0;
+ if (ourCount == 0) return otherCount == 0;
boolean[] matched = new boolean[otherCount];
int unmatched = otherCount;
@@ -270,8 +259,7 @@
{
// Ignore exceptions that have already been matched
- if (matched[j])
- continue;
+ if (matched[j]) continue;
// When one of our exceptions is a super-class of one of their exceptions,
// then their exceptions is matched.
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java Mon Feb 19 08:14:45 2007
@@ -213,6 +213,7 @@
* <li>Long to Integer</li>
* <li>Double to Long</li>
* <li>Double to Float</li>
+ * <li>Float to Double</li>
* <li>Long to Double</li>
* <li>String to Boolean ("false" is always false, other non-blank strings are true)</li>
* <li>Long to Boolean (true if long value is non zero)</li>
@@ -404,6 +405,13 @@
}
});
+ add(configuration, Float.class, Double.class, new Coercion<Float, Double>()
+ {
+ public Double coerce(Float input)
+ {
+ return input.doubleValue();
+ }
+ });
}
private static <S, T> void add(Configuration<CoercionTuple> configuration, Class<S> sourceType,
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TypeCoercer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TypeCoercer.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TypeCoercer.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TypeCoercer.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -12,34 +12,50 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc.services;
-
-/**
- * Makes use of {@link Coercion}s (via {@link CoercionTuple}s) to convert between an input value
- * (of some specific type) and a desired output type. Smart about coercing, even if it requires
- * multiple coercing steps (i.e., via an intermediate type, such as String).
- *
- *
- */
-public interface TypeCoercer
-{
- /**
- * Performs a coercion from an input type to a desired output type. When the target type is a
- * primitive, the actual conversion will be to the equivalent wrapper type. In some cases, the
- * TypeCoercer will need to search for an appropriate coercion, and may even combine existing
- * coercions to form new ones; in those cases, the results of the search are cached.
- *
- * @param <S>
- * source type (input)
- * @param <T>
- * target type (output)
- * @param input
- * @param targetType
- * defines the target type
- * @return
- */
- <S, T> T coerce(S input, Class<T> targetType);
-
- /** Clears cached information stored by the TypeCoercer. */
- void clearCache();
-}
+package org.apache.tapestry.ioc.services;
+
+/**
+ * Makes use of {@link Coercion}s (via {@link CoercionTuple}s) to convert between an input value
+ * (of some specific type) and a desired output type. Smart about coercing, even if it requires
+ * multiple coercing steps (i.e., via an intermediate type, such as String).
+ */
+public interface TypeCoercer
+{
+ /**
+ * Performs a coercion from an input type to a desired output type. When the target type is a
+ * primitive, the actual conversion will be to the equivalent wrapper type. In some cases, the
+ * TypeCoercer will need to search for an appropriate coercion, and may even combine existing
+ * coercions to form new ones; in those cases, the results of the search are cached.
+ *
+ * @param <S>
+ * source type (input)
+ * @param <T>
+ * target type (output)
+ * @param input
+ * @param targetType
+ * defines the target type
+ * @return the coerced value
+ */
+ <S, T> T coerce(S input, Class<T> targetType);
+
+ /**
+ * Used primarily inside test suites, this method performs the same steps as
+ * {@link #coerce(Object, Class)}, but returns a string describing the series of coercision,
+ * such as "Object --> String --> Long --> Integer".
+ *
+ * @param <S>
+ * source type (input)
+ * @param <T>
+ * target type (output)
+ * @param inputType
+ * the source coercion type (use void.class for coercions from null)
+ * @param targetType
+ * defines the target type
+ * @return a string identifying the series of coercions, or the empty string if no coercion is
+ * necessary
+ */
+ <S, T> String explain(Class<S> inputType, Class<T> targetType);
+
+ /** Clears cached information stored by the TypeCoercer. */
+ void clearCache();
+}
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt Mon Feb 19 08:14:45 2007
@@ -15,21 +15,21 @@
{{{apidocs/org/apache/tapestry/ioc/services/TypeCoercer.html}tapestry.ioc.TypeCoercer}} service. Its configuration consists
of a number of
{{{apidocs/org/apache/tapestry/ioc/services/CoercionTuple.html}CoercionTuple}}s. Each tuple defines how to coerce from one type to another.
+ The initial set of coercions is focused primarily on coercions between different numeric types:
- There's a large number of built-in coercions, the most common are shown in the following diagram:
-
-[images/type-coercer.png] Basic Type Coercions
+[images/type-coercer.png] Default Type Coercions
- This diagram omits a number of coercions related to nulls and collection types.
+ There's a few special coercions related to null there; Object --\>List wraps a lone object as a singleton list, we then need
+ null --\>List to ensure that null stays null (rather than a singleton list whose lone element is a null).
Tapestry can <interpolate> necessary coercions. For example, say it is necessary to coerce a StringBuffer to an Integer; the
TypeCoercer will chain together a series of coercions:
* Object --\> String
- * String --> Long
+ * String --\> Long
- * Long --> Integer
+ * Long --\> Integer
[]
@@ -58,4 +58,17 @@
Further, since TypeCoercer knows how to convert Double to BigDecimal, or even Integer (to Long to Double) to BigDecimal, all of those coercions would
work as well.
+
+ When creating a coercion from null, use Void.class as the source type. For example, the builtin coercion from null to Boolean is implemented as:
+
++----+
+ configuration.add(new CoercionTuple(void.class, Boolean.class,
+ new Coercion<Void, Boolean>()
+ {
+ public Boolean coerce(Void input)
+ {
+ return false;
+ }
+ }));
++---+
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/type-coercer.png
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/resources/images/type-coercer.png?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
Binary files - no diff available.
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -12,114 +12,114 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.ioc;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.tapestry.ioc.annotations.Id;
+package org.apache.tapestry.ioc;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tapestry.ioc.annotations.Id;
import org.apache.tapestry.ioc.internal.util.CollectionFactory;
-
-/**
- *
- */
-@Id("static")
-public class StaticModule
-{
- private static boolean _instantiated;
-
- private static boolean _fredRan;
-
- private static boolean _decoratorRan;
-
- public StaticModule()
- {
- setInstantiated(true);
- }
-
- public static Runnable buildFred()
- {
- return new Runnable()
- {
- public void run()
- {
- setFredRan(true);
- }
- };
- }
-
- public static Runnable buildBarney()
- {
- return new Runnable()
- {
- public void run()
- {
- }
- };
- }
-
- public static Runnable decorateBarney(final Object delegate)
- {
- return new Runnable()
- {
- public void run()
- {
- setDecoratorRan(true);
-
- ((Runnable) delegate).run();
- }
- };
- }
-
- public static synchronized void setFredRan(boolean fredRan)
- {
- _fredRan = fredRan;
- }
-
- public static synchronized boolean getFredRan()
- {
- return _fredRan;
- }
-
- public static synchronized void setInstantiated(boolean instantiated)
- {
- _instantiated = instantiated;
- }
-
- public static synchronized boolean isInstantiated()
- {
- return _instantiated;
- }
-
- public static synchronized void setDecoratorRan(boolean decoratorRan)
- {
- _decoratorRan = decoratorRan;
- }
-
- public static synchronized boolean getDecoratorRan()
- {
- return _decoratorRan;
- }
-
- public static NameListHolder buildNames(final Collection<String> configuration)
- {
- return new NameListHolder()
- {
- public List<String> getNames()
- {
- List result = CollectionFactory.newList(configuration);
-
- Collections.sort(result);
-
- return result;
- }
- };
- }
-
- public static void contributeNames(Configuration<String> configuration)
- {
- configuration.add("Fred");
- }
-
-}
+
+/**
+ *
+ */
+@Id("static")
+public class StaticModule
+{
+ private static boolean _instantiated;
+
+ private static boolean _fredRan;
+
+ private static boolean _decoratorRan;
+
+ public StaticModule()
+ {
+ setInstantiated(true);
+ }
+
+ public static Runnable buildFred()
+ {
+ return new Runnable()
+ {
+ public void run()
+ {
+ setFredRan(true);
+ }
+ };
+ }
+
+ public static Runnable buildBarney()
+ {
+ return new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+ }
+
+ public static Runnable decorateBarney(final Object delegate)
+ {
+ return new Runnable()
+ {
+ public void run()
+ {
+ setDecoratorRan(true);
+
+ ((Runnable) delegate).run();
+ }
+ };
+ }
+
+ public static synchronized void setFredRan(boolean fredRan)
+ {
+ _fredRan = fredRan;
+ }
+
+ public static synchronized boolean getFredRan()
+ {
+ return _fredRan;
+ }
+
+ public static synchronized void setInstantiated(boolean instantiated)
+ {
+ _instantiated = instantiated;
+ }
+
+ public static synchronized boolean isInstantiated()
+ {
+ return _instantiated;
+ }
+
+ public static synchronized void setDecoratorRan(boolean decoratorRan)
+ {
+ _decoratorRan = decoratorRan;
+ }
+
+ public static synchronized boolean getDecoratorRan()
+ {
+ return _decoratorRan;
+ }
+
+ public static NameListHolder buildNames(final Collection<String> configuration)
+ {
+ return new NameListHolder()
+ {
+ public List<String> getNames()
+ {
+ List<String> result = CollectionFactory.newList(configuration);
+
+ Collections.sort(result);
+
+ return result;
+ }
+ };
+ }
+
+ public static void contributeNames(Configuration<String> configuration)
+ {
+ configuration.add("Fred");
+ }
+
+}
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java Mon Feb 19 08:14:45 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -26,11 +26,8 @@
import org.apache.tapestry.ioc.def.DecoratorDef;
import org.apache.tapestry.ioc.def.ModuleDef;
import org.apache.tapestry.ioc.def.ServiceDef;
-import org.apache.tapestry.ioc.internal.DefaultModuleDefImpl;
-import org.apache.tapestry.ioc.internal.IOCMessages;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
import org.apache.tapestry.ioc.test.IOCTestCase;
-import org.apache.tapestry.ioc.test.TestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImplTest.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImplTest.java Mon Feb 19 08:14:45 2007
@@ -114,7 +114,7 @@
assertTrue(ex
.getMessage()
.contains(
- "Coercion of {} to type java.lang.Float (via java.lang.Object --> java.lang.String, java.lang.String --> java.lang.Double, java.lang.Double --> java.lang.Float) failed"));
+ "Coercion of {} to type java.lang.Float (via Object --> String, String --> Double, Double --> Float) failed"));
assertTrue(ex.getCause() instanceof NumberFormatException);
}
}
@@ -138,6 +138,7 @@
// Over time, some of these may evolve from testing specific tuples to
// compound tuples (built around specific tuples).
+ Float floatValue = new Float(31.14);
return new Object[][]
{
// There's a lot of these!
@@ -160,6 +161,7 @@
{ new Integer(33), Long.class, new Long(33) },
{ new Integer(22), Float.class, new Float(22) },
{ new Integer(1234), Double.class, new Double(1234) },
+ { floatValue, Double.class, floatValue.doubleValue() },
{ Collections.EMPTY_LIST, Boolean.class, false },
{ Collections.singleton(this), Boolean.class, true },
{ bigDecimalValue, BigDecimal.class, new BigDecimal(bigDecimalValue) },
@@ -180,6 +182,29 @@
// null to arbitrary object is still null
{ null, XMLReader.class, null } };
+ }
+
+ @Test(dataProvider = "explain_inputs")
+ public <S, T> void explain(Class<S> inputType, Class<T> outputType, String expected)
+ {
+ assertEquals(_coercer.explain(inputType, outputType), expected);
+ }
+
+ @DataProvider(name = "explain_inputs")
+ public Object[][] explain_inputs()
+ {
+ return new Object[][]
+ {
+ { StringBuffer.class, Integer.class,
+ "Object --> String, String --> Long, Long --> Integer" },
+ { void.class, Map.class, "null --> null" },
+ { void.class, Boolean.class, "null --> Boolean" },
+ { String[].class, List.class, "Object[] --> java.util.List" },
+ { Float.class, Double.class, "Float --> Double" },
+ { Double.class, BigDecimal.class,
+ "Object --> String, String --> java.math.BigDecimal" },
+
+ };
}
}
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/util/CaseInsensitiveMapTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/util/CaseInsensitiveMapTest.java?view=diff&rev=509234&r1=509233&r2=509234
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/util/CaseInsensitiveMapTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/util/CaseInsensitiveMapTest.java Mon Feb 19 08:14:45 2007
@@ -311,6 +311,7 @@
assertEquals(keys, Arrays.asList("barney", "betty", "fred", "wilma"));
}
+ @SuppressWarnings("unchecked")
private <K, V> Map.Entry<K, V> newMapEntry(final K key, final V value)
{
return new Map.Entry()