/*
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat Middleware LLC, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * 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.jboss.shrinkwrap.api;

/**
 * Indicates that a default name cannot be generated for
 * a given type because no extension mapping has been configured
 * via {@link Configuration#getExtensionMappings()}.  
 * 
 * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
 * @version $Revision: $
 */
public class UnknownExtensionTypeException extends RuntimeException
{

   //-------------------------------------------------------------------------------------||
   // Class Members ----------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * serialVersionUID
    */
   private static final long serialVersionUID = 1L;

   //-------------------------------------------------------------------------------------||
   // Constructor ------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * 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.");
   }

   //-------------------------------------------------------------------------------------||
   // Factory ----------------------------------------------------------------------------||
   //-------------------------------------------------------------------------------------||

   /**
    * Creates a new {@link UnknownExtensionTypeException} for the specified type
    * 
    * @throws IllegalArgumentException If the type is not specified
    */
   static <T extends Assignable> UnknownExtensionTypeException newInstance(final Class<T> type)
         throws IllegalArgumentException
   {
      // Precondition checks
      if (type == null)
      {
         throw new IllegalArgumentException("type must be specified");
      }

      // Create new
      return new UnknownExtensionTypeException(type);
   }
}

@@ -813,16 +813,128 @@
 p.api;%0A%0A
+import java.lang.reflect.Method;%0Aimport java.security.AccessController;%0Aimport java.security.PrivilegedAction;%0A%0A
 /**%0A * I
@@ -1642,16 +1642,784 @@
  = 1L;%0A%0A
+   /**%0A    * Method used in the error message instructing a developer how to add new extension%0A    * mappings%0A    */%0A   private static final Method GET_EXTENSION_MAPPING;%0A   static%0A   %7B%0A      GET_EXTENSION_MAPPING = AccessController.doPrivileged(new PrivilegedAction%3CMethod%3E()%0A      %7B%0A%0A         @Override%0A         public Method run()%0A         %7B%0A            try%0A            %7B%0A               return Configuration.class.getMethod(%22getExtensionMappings%22, new Class%3C?%3E%5B%5D%0A               %7B%7D);%0A            %7D%0A            catch (final NoSuchMethodException e)%0A            %7B%0A               throw new RuntimeException(%0A                     %22Incorrect extension mappings method defined for error message; development error in ShrinkWrap%22);%0A            %7D%0A         %7D%0A      %7D);%0A   %7D%0A%0A
    //---
@@ -2762,24 +2762,25 @@
 missing type
+ 
 %0A    */%0A   p
@@ -2877,29 +2877,16 @@
   super(
-%0A            
 %22The cur
@@ -2929,34 +2929,16 @@
 r type %22
-%0A                 
  + type.
@@ -2956,22 +2956,16 @@
 lName()%0A
-      
         
@@ -3033,41 +3033,60 @@
 via 
-Configuration.getExtensionMapping
+%22 + GET_EXTENSION_MAPPING.toString()%0A            + %22
  or 

Improve the durability of the error message in unconfigured mappings