[jboss-svn-commits] JBoss Common SVN: r4447 - shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 26 13:03:27 EDT 2010
Author: ALRubinger
Date: 2010-05-26 13:03:27 -0400 (Wed, 26 May 2010)
New Revision: 4447
Modified:
shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/UnknownExtensionTypeException.java
Log:
[SHRINKWRAP-163] Improve the durability of the error message in unconfigured mappings
Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/UnknownExtensionTypeException.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/UnknownExtensionTypeException.java 2010-05-26 16:51:40 UTC (rev 4446)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/UnknownExtensionTypeException.java 2010-05-26 17:03:27 UTC (rev 4447)
@@ -16,6 +16,10 @@
*/
package org.jboss.shrinkwrap.api;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
/**
* Indicates that a default name cannot be generated for
* a given type because no extension mapping has been configured
@@ -36,19 +40,45 @@
*/
private static final long serialVersionUID = 1L;
+ /**
+ * Method used in the error message instructing a developer how to add new extension
+ * mappings
+ */
+ private static final Method GET_EXTENSION_MAPPING;
+ static
+ {
+ GET_EXTENSION_MAPPING = AccessController.doPrivileged(new PrivilegedAction<Method>()
+ {
+
+ @Override
+ public Method run()
+ {
+ try
+ {
+ return Configuration.class.getMethod("getExtensionMappings", new Class<?>[]
+ {});
+ }
+ catch (final NoSuchMethodException e)
+ {
+ throw new RuntimeException(
+ "Incorrect extension mappings method defined for error message; development error in ShrinkWrap");
+ }
+ }
+ });
+ }
+
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * Creates a new instance with message indicating the missing type
+ * Creates a new instance with message indicating the missing type
*/
private <T extends Assignable> UnknownExtensionTypeException(final Class<T> type)
{
- super(
- "The current configuration has no mapping for type "
- + type.getCanonicalName()
- + ", unable to determine extension. Either add a mapping via Configuration.getExtensionMapping or manually assign a name.");
+ super("The current configuration has no mapping for type " + type.getCanonicalName()
+ + ", unable to determine extension. Either add a mapping via " + GET_EXTENSION_MAPPING.toString()
+ + " or manually assign a name.");
}
//-------------------------------------------------------------------------------------||
More information about the jboss-svn-commits
mailing list