[weld-commits] Weld SVN: r5177 - in core/trunk/impl/src/main: java/org/jboss/weld/bean and 8 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Nov 30 10:42:10 EST 2009


Author: dallen6
Date: 2009-11-30 10:42:09 -0500 (Mon, 30 Nov 2009)
New Revision: 5177

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java
   core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java
   core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
   core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
   core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
   core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
   core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
   core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/ApiAbstraction.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/DeploymentStructures.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Observers.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ConcurrentCache.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/serviceProvider/DefaultServiceLoader.java
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties
Log:
Additional exception message conversions for localization

Modified: core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -17,6 +17,9 @@
 package org.jboss.weld;
 
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+
+import java.util.List;
+
 import ch.qos.cal10n.IMessageConveyor;
 
 /**
@@ -31,6 +34,8 @@
    // Exception messages
    private static final IMessageConveyor messageConveyer  = loggerFactory().getMessageConveyor();
 
+   private String message = null;
+
    public DefinitionException()
    {
       super();
@@ -38,27 +43,60 @@
 
    public <E extends Enum<?>> DefinitionException(E key, Object... args)
    {
-      super(messageConveyer.getMessage(key, args));
+      super();
+      this.message = messageConveyer.getMessage(key, args);
    }
 
    public <E extends Enum<?>> DefinitionException(E key, Throwable throwable, Object... args)
    {
-      super(messageConveyer.getMessage(key, args), throwable);
+      super(throwable);
+      this.message = messageConveyer.getMessage(key, args);
    }
 
    public DefinitionException(String message, Throwable throwable)
    {
-      super(message, throwable);
+      super(throwable);
+      this.message = message;
    }
 
    public DefinitionException(String message)
    {
-      super(message);
+      super();
+      this.message = message;
    }
 
    public DefinitionException(Throwable throwable)
    {
       super(throwable);
+      this.message = throwable.getLocalizedMessage();
    }
    
+   public DefinitionException(List<Throwable> errors)
+   {
+      super();
+      StringBuilder errorMessage = new StringBuilder();
+      boolean firstError = true;
+      for (Throwable throwable : errors)
+      {
+         if (!firstError)
+         {
+            errorMessage.append('\n');
+         }
+         errorMessage.append(throwable.getLocalizedMessage());
+      }
+      message = errorMessage.toString();
+   }
+
+   @Override
+   public String getLocalizedMessage()
+   {
+      return getMessage();
+   }
+
+   @Override
+   public String getMessage()
+   {
+      return message;
+   }
+   
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/DeploymentException.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -17,6 +17,9 @@
 package org.jboss.weld;
 
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+
+import java.util.List;
+
 import ch.qos.cal10n.IMessageConveyor;
 
 /**
@@ -31,6 +34,8 @@
    // Exception messages
    private static final IMessageConveyor messageConveyer  = loggerFactory().getMessageConveyor();
 
+   private String message = null;
+
    public DeploymentException()
    {
       super();
@@ -38,27 +43,60 @@
 
    public <E extends Enum<?>> DeploymentException(E key, Object... args)
    {
-      super(messageConveyer.getMessage(key, args));
+      super();
+      this.message = messageConveyer.getMessage(key, args);
    }
 
    public <E extends Enum<?>> DeploymentException(E key, Throwable throwable, Object... args)
    {
-      super(messageConveyer.getMessage(key, args), throwable);
+      super(throwable);
+      this.message = messageConveyer.getMessage(key, args);
    }
 
    public DeploymentException(String message, Throwable throwable)
    {
-      super(message, throwable);
+      super(throwable);
+      this.message = message;
    }
 
    public DeploymentException(String message)
    {
-      super(message);
+      super();
+      this.message = message;
    }
 
    public DeploymentException(Throwable throwable)
    {
       super(throwable);
+      this.message = throwable.getLocalizedMessage();
    }
    
+   public DeploymentException(List<Throwable> errors)
+   {
+      super();
+      StringBuilder errorMessage = new StringBuilder();
+      boolean firstError = true;
+      for (Throwable throwable : errors)
+      {
+         if (!firstError)
+         {
+            errorMessage.append('\n');
+         }
+         errorMessage.append(throwable.getLocalizedMessage());
+      }
+      message = errorMessage.toString();
+   }
+
+   @Override
+   public String getLocalizedMessage()
+   {
+      return getMessage();
+   }
+
+   @Override
+   public String getMessage()
+   {
+      return message;
+   }
+   
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -34,6 +34,11 @@
    // Exception messages
    private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
 
+   public ForbiddenArgumentException(Throwable throwable)
+   {
+      super(throwable.getLocalizedMessage(), throwable);
+   }
+
    public <E extends Enum<?>> ForbiddenArgumentException(E key, Object... args)
    {
       super(messageConveyer.getMessage(key, args));

Modified: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -37,4 +37,9 @@
    {
       super(messageConveyer.getMessage(key, args));
    }
+   
+   public ForbiddenStateException(Throwable cause)
+   {
+      super(cause.getLocalizedMessage(), cause);
+   }
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -34,7 +34,7 @@
 
    public WeldException(Throwable throwable)
    {
-      super(throwable);
+      super(throwable.getLocalizedMessage(), throwable);
    }
 
    public <E extends Enum<?>> WeldException(E key, Object... args)

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -33,8 +33,8 @@
 import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DeploymentException;
+import org.jboss.weld.WeldException;
 import org.jboss.weld.introspector.WeldClass;
-import org.jboss.weld.logging.messages.BeanMessage;
 import org.jboss.weld.util.Beans;
 
 /**
@@ -83,7 +83,7 @@
          return new DirectClassInterceptionHandler(instance, getType()).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
       } catch (Exception e)
       {
-         throw new RuntimeException(e);
+         throw new WeldException(e);
       }
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDefinitionContainerEvent.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -39,8 +39,7 @@
       super.fire();
       if (!getErrors().isEmpty())
       {
-         // FIXME communicate all the captured definition errors in this exception
-         throw new DefinitionException(getErrors().get(0));
+         throw new DefinitionException(getErrors());
       }
    }
    

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractDeploymentContainerEvent.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -39,8 +39,7 @@
       super.fire();
       if (!getErrors().isEmpty())
       {
-         // FIXME communicate all the captured deployment errors in this exception
-         throw new DeploymentException(getErrors().get(0));
+         throw new DeploymentException(getErrors());
       }
    }
    

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -23,6 +23,7 @@
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.InvalidOperationException;
 import org.jboss.weld.bootstrap.BeanDeployment;
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
 import org.jboss.weld.bootstrap.spi.Deployment;
@@ -68,7 +69,7 @@
 
    public void addStereotype(Class<? extends Annotation> stereotype, Annotation... stereotypeDef)
    {
-      throw new UnsupportedOperationException();
+      throw new InvalidOperationException();
    }
 
    public void addAnnotatedType(AnnotatedType<?> type)

Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -38,6 +38,7 @@
 
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.InvalidObjectException;
+import org.jboss.weld.InvalidOperationException;
 import org.jboss.weld.introspector.ConstructorSignature;
 import org.jboss.weld.introspector.ForwardingWeldConstructor;
 import org.jboss.weld.introspector.WeldClass;
@@ -150,7 +151,7 @@
 
    public void inject(Object declaringInstance, Object value)
    {
-      throw new UnsupportedOperationException();
+      throw new InvalidOperationException();
    }
 
    /**

Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,7 +16,11 @@
  */
 package org.jboss.weld.injection;
 
-import java.io.InvalidObjectException;
+import static org.jboss.weld.logging.messages.BeanMessage.CANNOT_READ_OBJECT;
+import static org.jboss.weld.logging.messages.BeanMessage.IP_NOT_CONSTRUCTOR_OR_METHOD;
+import static org.jboss.weld.logging.messages.BeanMessage.PARAM_NOT_IN_PARAM_LIST;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_REQUIRED;
+
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
@@ -32,6 +36,9 @@
 import javax.enterprise.inject.spi.Decorator;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
+import org.jboss.weld.InvalidObjectException;
+import org.jboss.weld.InvalidOperationException;
 import org.jboss.weld.introspector.ConstructorSignature;
 import org.jboss.weld.introspector.ForwardingWeldParameter;
 import org.jboss.weld.introspector.MethodSignature;
@@ -84,7 +91,7 @@
 
    public void inject(Object declaringInstance, Object value)
    {
-      throw new UnsupportedOperationException();
+      throw new InvalidOperationException();
    }
 
    @SuppressWarnings("unchecked")
@@ -128,7 +135,7 @@
    
    private void readObject(ObjectInputStream stream) throws InvalidObjectException
    {
-      throw new InvalidObjectException("Proxy required");
+      throw new InvalidObjectException(PROXY_REQUIRED);
    }
    
    private static class SerializationProxy<T> extends WeldInjectionPointSerializationProxy<T, Object>
@@ -156,7 +163,7 @@
          }
          else
          {
-            throw new IllegalStateException("Cannot handle injection point as neither constructor or method. Injection Point: " + injectionPoint);
+            throw new ForbiddenStateException(IP_NOT_CONSTRUCTOR_OR_METHOD, injectionPoint);
          }
       }
       
@@ -181,7 +188,7 @@
             }
             else
             {
-               throw new IllegalStateException("Parameter not in list. Parameter position: " + parameterPosition + "; Parameters: " + method.getParameters());
+               throw new ForbiddenStateException(PARAM_NOT_IN_PARAM_LIST, parameterPosition, method.getParameters());
             }
          }
          else if (constructorSignature != null)
@@ -198,12 +205,12 @@
             }
             else
             {
-               throw new IllegalStateException("Parameter not in list. Parameter position: " + parameterPosition + "; Parameters: " + constructor.getParameters());
+               throw new ForbiddenStateException(PARAM_NOT_IN_PARAM_LIST, parameterPosition, constructor.getParameters());
             }
          }
          else
          {
-            throw new IllegalStateException("Cannot read object");
+            throw new ForbiddenStateException(CANNOT_READ_OBJECT);
          }
          
       }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -108,6 +108,9 @@
    @MessageId("000087") MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED,
    @MessageId("000088") OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS,
    @MessageId("000089") TOO_MANY_EJBS_FOR_CLASS,
-   @MessageId("000090") ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE;
+   @MessageId("000090") ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE,
+   @MessageId("000091") IP_NOT_CONSTRUCTOR_OR_METHOD,
+   @MessageId("000092") PARAM_NOT_IN_PARAM_LIST,
+   @MessageId("000093") CANNOT_READ_OBJECT;
    
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/UtilMessage.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -21,6 +21,31 @@
 {
 
    @MessageId("000800") SERVICE_LOADER_LOADING_ERROR,
-   @MessageId("000801") SECURITY_EXCEPTION_SCANNING;
+   @MessageId("000801") SECURITY_EXCEPTION_SCANNING,
+   @MessageId("000802") XML_DOM_READONLY,
+   @MessageId("000803") DECLARED_EXTENSION_DOES_NOT_IMPLEMENT_EXTENSION,
+   @MessageId("000804") CLASS_NOT_ENUM,
+   @MessageId("000805") TOO_MANY_POST_CONSTRUCT_METHODS,
+   @MessageId("000806") TOO_MANY_PRE_DESTROY_METHODS,
+   @MessageId("000807") INITIALIZER_CANNOT_BE_PRODUCER,
+   @MessageId("000808") INITIALIZER_CANNOT_BE_DISPOSAL_METHOD,
+   @MessageId("000809") INITIALIZER_CANNOT_BE_OBSERVER,
+   @MessageId("000810") QUALIFIER_ON_FINAL_FIELD,
+   @MessageId("000811") TOO_MANY_INITIALIZERS,
+   @MessageId("000812") AMBIGUOUS_CONSTRUCTOR,
+   @MessageId("000813") INVALID_QUANTITY_INJECTABLE_FIELDS_AND_INITIALIZER_METHODS,
+   @MessageId("000814") ANNOTATION_NOT_QUALIFIER,
+   @MessageId("000815") REDUNDANT_QUALIFIER,
+   @MessageId("000816") UNABLE_TO_FIND_CONSTRUCTOR,
+   @MessageId("000817") UNABLE_TO_FIND_BEAN_DEPLOYMENT_ARCHIVE,
+   @MessageId("000818") EVENT_TYPE_NOT_ALLOWED,
+   @MessageId("000819") TYPE_PARAMETER_NOT_ALLOWED_IN_EVENT_TYPE,
+   @MessageId("000820") CANNOT_PROXY_NON_CLASS_TYPE,
+   @MessageId("000821") INSTANCE_NOT_A_PROXY,
+   @MessageId("000822") ACCESS_ERROR_ON_CONSTRUCTOR,
+   @MessageId("000823") ERROR_INVOKING_METHOD,
+   @MessageId("000824") ACCESS_ERROR_ON_FIELD,
+   @MessageId("000825") NO_SUCH_METHOD,
+   @MessageId("000826") ANNOTATION_VALUES_INACCESSIBLE;
    
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/ApiAbstraction.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/ApiAbstraction.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/ApiAbstraction.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,8 +16,11 @@
  */
 package org.jboss.weld.util;
 
+import static org.jboss.weld.logging.messages.UtilMessage.CLASS_NOT_ENUM;
+
 import java.lang.annotation.Annotation;
 
+import org.jboss.weld.ForbiddenArgumentException;
 import org.jboss.weld.resources.spi.ResourceLoader;
 import org.jboss.weld.resources.spi.ResourceLoadingException;
 
@@ -112,7 +115,7 @@
    {
       if (!clazz.isEnum())
       {
-         throw new IllegalArgumentException(clazz + " is not an enum!");
+         throw new ForbiddenArgumentException(CLASS_NOT_ENUM, clazz);
       }
       try
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -25,6 +25,17 @@
 import static org.jboss.weld.logging.messages.BeanMessage.FOUND_ONE_PRE_DESTROY_METHOD;
 import static org.jboss.weld.logging.messages.BeanMessage.FOUND_POST_CONSTRUCT_METHODS;
 import static org.jboss.weld.logging.messages.BeanMessage.FOUND_PRE_DESTROY_METHODS;
+import static org.jboss.weld.logging.messages.UtilMessage.AMBIGUOUS_CONSTRUCTOR;
+import static org.jboss.weld.logging.messages.UtilMessage.ANNOTATION_NOT_QUALIFIER;
+import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_DISPOSAL_METHOD;
+import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_OBSERVER;
+import static org.jboss.weld.logging.messages.UtilMessage.INITIALIZER_CANNOT_BE_PRODUCER;
+import static org.jboss.weld.logging.messages.UtilMessage.INVALID_QUANTITY_INJECTABLE_FIELDS_AND_INITIALIZER_METHODS;
+import static org.jboss.weld.logging.messages.UtilMessage.QUALIFIER_ON_FINAL_FIELD;
+import static org.jboss.weld.logging.messages.UtilMessage.REDUNDANT_QUALIFIER;
+import static org.jboss.weld.logging.messages.UtilMessage.TOO_MANY_POST_CONSTRUCT_METHODS;
+import static org.jboss.weld.logging.messages.UtilMessage.TOO_MANY_PRE_DESTROY_METHODS;
+import static org.jboss.weld.logging.messages.UtilMessage.UNABLE_TO_FIND_CONSTRUCTOR;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
@@ -57,6 +68,7 @@
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.Container;
 import org.jboss.weld.DefinitionException;
+import org.jboss.weld.ForbiddenArgumentException;
 import org.jboss.weld.bean.DecoratorImpl;
 import org.jboss.weld.bean.RIBean;
 import org.jboss.weld.bean.SessionBean;
@@ -192,7 +204,7 @@
       log.trace(FOUND_POST_CONSTRUCT_METHODS, postConstructMethods, type);
       if (postConstructMethods.size() > 1)
       {
-         throw new DefinitionException("Cannot have more than one post construct method annotated with @PostConstruct for " + type);
+         throw new DefinitionException(TOO_MANY_POST_CONSTRUCT_METHODS, type);
       }
       else if (postConstructMethods.size() == 1)
       {
@@ -214,7 +226,7 @@
       {
          // TODO actually this is wrong, in EJB you can have @PreDestroy methods
          // on the superclass, though the CDI spec is silent on the issue
-         throw new DefinitionException("Cannot have more than one pre destroy method annotated with @PreDestroy for " + type);
+         throw new DefinitionException(TOO_MANY_PRE_DESTROY_METHODS, type);
       }
       else if (preDestroyMethods.size() == 1)
       {
@@ -349,15 +361,15 @@
             {
                if (method.getAnnotation(Produces.class) != null)
                {
-                  throw new DefinitionException("Initializer method " + method.toString() + " cannot be annotated @Produces on " + type);
+                  throw new DefinitionException(INITIALIZER_CANNOT_BE_PRODUCER, method, type);
                }
                else if (method.getAnnotatedWBParameters(Disposes.class).size() > 0)
                {
-                  throw new DefinitionException("Initializer method " + method.toString() + " cannot have parameters annotated @Disposes on " + type);
+                  throw new DefinitionException(INITIALIZER_CANNOT_BE_DISPOSAL_METHOD, method, type);
                }
                else if (method.getAnnotatedWBParameters(Observes.class).size() > 0)
                {
-                  throw new DefinitionException("Initializer method " + method.toString() + " cannot be annotated @Observes on " + type);
+                  throw new DefinitionException(INITIALIZER_CANNOT_BE_OBSERVER, method, type);
                }
                else
                {
@@ -433,7 +445,7 @@
       {
          if (annotatedField.isFinal())
          {
-            throw new DefinitionException("Don't place binding annotations on final fields " + annotatedField);
+            throw new DefinitionException(QUALIFIER_ON_FINAL_FIELD, annotatedField);
          }
          FieldInjectionPoint<?, ?> fieldInjectionPoint = FieldInjectionPoint.of(declaringBean, annotatedField);
          injectableFields.add(fieldInjectionPoint);
@@ -628,7 +640,7 @@
       {
          if (initializerAnnotatedConstructors.size() > 1)
          {
-            throw new DefinitionException("Cannot have more than one constructor annotated with @Initializer for " + type);
+            throw new DefinitionException(AMBIGUOUS_CONSTRUCTOR, type);
          }
       }
       else if (initializerAnnotatedConstructors.size() == 1)
@@ -645,7 +657,7 @@
       
       if (constructor == null)
       {
-         throw new DefinitionException("Cannot determine constructor to use for " + type);
+         throw new DefinitionException(UNABLE_TO_FIND_CONSTRUCTOR, type);
       }
       else
       {
@@ -732,7 +744,7 @@
    {
       if (injectableFields.size() != initializerMethods.size())
       {
-         throw new IllegalArgumentException("injectableFields and initializerMethods must have the same size. InjectableFields: " + injectableFields + "; InitializerMethods: " + initializerMethods);  
+         throw new ForbiddenArgumentException(INVALID_QUANTITY_INJECTABLE_FIELDS_AND_INITIALIZER_METHODS, injectableFields, initializerMethods);  
       }
       for (int i = 0; i < injectableFields.size(); i++)
       {
@@ -773,11 +785,11 @@
       {
          if (!Container.instance().deploymentServices().get(MetaAnnotationStore.class).getBindingTypeModel(qualifier.annotationType()).isValid())
          {
-            throw new IllegalArgumentException("Annotation is not a qualifier. Qualifier: " + qualifier);
+            throw new ForbiddenArgumentException(ANNOTATION_NOT_QUALIFIER, qualifier);
          }
          if (checkedNewQualifiers.contains(qualifier))
          {
-            throw new IllegalArgumentException("Qualifier is already present. Qualifier: " + qualifier + "; All qualifiers: " + Arrays.asList(newQualifiers));
+            throw new ForbiddenArgumentException(REDUNDANT_QUALIFIER, qualifier, Arrays.asList(newQualifiers));
          }
          checkedNewQualifiers.add(qualifier);
       }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/DeploymentStructures.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/DeploymentStructures.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/DeploymentStructures.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -1,8 +1,11 @@
 package org.jboss.weld.util;
 
+import static org.jboss.weld.logging.messages.UtilMessage.UNABLE_TO_FIND_BEAN_DEPLOYMENT_ARCHIVE;
+
 import java.util.Map;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.bootstrap.BeanDeployment;
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
 import org.jboss.weld.bootstrap.spi.Deployment;
@@ -17,7 +20,7 @@
       BeanDeploymentArchive beanDeploymentArchive = deployment.loadBeanDeploymentArchive(clazz);
       if (beanDeploymentArchive == null)
       {
-         throw new IllegalStateException("Unable to find Bean Deployment Archive for " + clazz);
+         throw new ForbiddenStateException(UNABLE_TO_FIND_BEAN_DEPLOYMENT_ARCHIVE, clazz);
       }
       else
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Observers.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Observers.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Observers.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,10 +16,15 @@
  */
 package org.jboss.weld.util;
 
+import static org.jboss.weld.logging.messages.UtilMessage.EVENT_TYPE_NOT_ALLOWED;
+import static org.jboss.weld.logging.messages.UtilMessage.TYPE_PARAMETER_NOT_ALLOWED_IN_EVENT_TYPE;
+
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 
+import org.jboss.weld.ForbiddenArgumentException;
+
 /**
  * @author pmuir
  *
@@ -41,13 +46,13 @@
       }
       else
       {
-         throw new IllegalArgumentException("Event type " + resolvedType + " is not allowed");
+         throw new ForbiddenArgumentException(EVENT_TYPE_NOT_ALLOWED, resolvedType);
       }
       for (Type type : types)
       {
          if (type instanceof TypeVariable<?>)
          {
-            throw new IllegalArgumentException("Cannot provide an event type parameterized with a type parameter " + resolvedType);
+            throw new ForbiddenArgumentException(TYPE_PARAMETER_NOT_ALLOWED_IN_EVENT_TYPE, resolvedType);
          }
       }
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,6 +16,9 @@
  */
 package org.jboss.weld.util;
 
+import static org.jboss.weld.logging.messages.UtilMessage.CANNOT_PROXY_NON_CLASS_TYPE;
+import static org.jboss.weld.logging.messages.UtilMessage.INSTANCE_NOT_A_PROXY;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
@@ -28,6 +31,8 @@
 import javassist.util.proxy.ProxyFactory;
 import javassist.util.proxy.ProxyObject;
 
+import org.jboss.weld.ForbiddenArgumentException;
+
 /**
  * Utilties for working with Javassist proxies
  * 
@@ -109,7 +114,7 @@
          }
          else
          {
-            throw new IllegalArgumentException("Cannot proxy non-Class Type " + type);
+            throw new ForbiddenArgumentException(CANNOT_PROXY_NON_CLASS_TYPE, type);
          }
          return this;
       }
@@ -257,7 +262,7 @@
       }
       else
       {
-         throw new IllegalArgumentException("Instance not a proxy. Instance: " + instance);
+         throw new ForbiddenArgumentException(INSTANCE_NOT_A_PROXY, instance);
       }
       
    }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -18,6 +18,11 @@
 
 import static org.jboss.weld.logging.Category.UTIL;
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.UtilMessage.ACCESS_ERROR_ON_CONSTRUCTOR;
+import static org.jboss.weld.logging.messages.UtilMessage.ACCESS_ERROR_ON_FIELD;
+import static org.jboss.weld.logging.messages.UtilMessage.ANNOTATION_VALUES_INACCESSIBLE;
+import static org.jboss.weld.logging.messages.UtilMessage.ERROR_INVOKING_METHOD;
+import static org.jboss.weld.logging.messages.UtilMessage.NO_SUCH_METHOD;
 import static org.jboss.weld.logging.messages.UtilMessage.SECURITY_EXCEPTION_SCANNING;
 
 import java.beans.Introspector;
@@ -45,6 +50,8 @@
 import javax.inject.Qualifier;
 
 import org.jboss.weld.DeploymentException;
+import org.jboss.weld.ForbiddenArgumentException;
+import org.jboss.weld.WeldException;
 import org.jboss.weld.util.reflection.ParameterizedTypeImpl;
 import org.slf4j.cal10n.LocLogger;
 import org.slf4j.ext.XLogger;
@@ -443,7 +450,7 @@
       }
       catch (Exception e)
       {
-         throw new RuntimeException("Error accessing constructor (with parameters " + Arrays.toString(parameterTypes) + ") of " + clazz, e);
+         throw new WeldException(ACCESS_ERROR_ON_CONSTRUCTOR, e, clazz);
       }
    }
 
@@ -529,15 +536,15 @@
       }
       catch (IllegalArgumentException e)
       {
-         throw new RuntimeException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
+         throw new WeldException(ERROR_INVOKING_METHOD, e, method.getName(), method.getDeclaringClass());
       }
       catch (IllegalAccessException e)
       {
-         throw new RuntimeException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
+         throw new WeldException(ERROR_INVOKING_METHOD, e, method.getName(), method.getDeclaringClass());
       }
       catch (InvocationTargetException e)
       {
-         throw new RuntimeException("Error invoking method " + method.getName() + " on " + method.getDeclaringClass(), e);
+         throw new WeldException(ERROR_INVOKING_METHOD, e, method.getName(), method.getDeclaringClass());
       }
    }
 
@@ -554,11 +561,11 @@
       }
       catch (SecurityException e)
       {
-         throw new RuntimeException("Error invoking method " + methodName + " on " + instance.getClass(), e);
+         throw new WeldException(ERROR_INVOKING_METHOD, e, methodName, instance.getClass());
       }
       catch (NoSuchMethodException e)
       {
-         throw new RuntimeException("Error invoking method " + methodName + " on " + instance.getClass(), e);
+         throw new WeldException(ERROR_INVOKING_METHOD, e, methodName, instance.getClass());
       }
    }
 
@@ -577,11 +584,11 @@
       }
       catch (IllegalArgumentException e)
       {
-         throw new RuntimeException("Error getting field " + field.getName() + " on " + field.getDeclaringClass(), e);
+         throw new WeldException(ACCESS_ERROR_ON_FIELD, e, field.getName(), field.getDeclaringClass());
       }
       catch (IllegalAccessException e)
       {
-         throw new RuntimeException("Error getting field " + field.getName() + " on " + field.getDeclaringClass(), e);
+         throw new WeldException(ACCESS_ERROR_ON_FIELD, e, field.getName(), field.getDeclaringClass());
       }
    }
 
@@ -593,11 +600,11 @@
       }
       catch (SecurityException e)
       {
-         throw new RuntimeException("Error getting field " + fieldName + " on " + target.getClass(), e);
+         throw new WeldException(ACCESS_ERROR_ON_FIELD, e, fieldName, target.getClass());
       }
       catch (NoSuchFieldException e)
       {
-         throw new RuntimeException("Error getting field " + fieldName + " on " + target.getClass(), e);
+         throw new WeldException(ACCESS_ERROR_ON_FIELD, e, fieldName, target.getClass());
       }
    }
 
@@ -617,7 +624,7 @@
       }
       catch (NoSuchMethodException e)
       {
-         throw new IllegalArgumentException(e);
+         throw new ForbiddenArgumentException(e);
       }
    }
 
@@ -663,7 +670,7 @@
             // Expected, nothing to see here.
          }
       }
-      throw new NoSuchMethodException("Method " + methodName + Arrays.asList(parameterTypes).toString().replace("[", "(").replace("]", ")") + " not implemented by instance " + c.getName());
+      throw new WeldException(NO_SUCH_METHOD, methodName + Arrays.asList(parameterTypes).toString().replace("[", "(").replace("]", ")"), c.getName());
    }
 
    /**
@@ -1067,7 +1074,7 @@
       }
       catch (Exception e)
       {
-         throw new DeploymentException("Cannot access values() on annotation", e);
+         throw new DeploymentException(ANNOTATION_VALUES_INACCESSIBLE, e);
       }
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ConcurrentCache.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ConcurrentCache.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ConcurrentCache.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -23,6 +23,8 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
+import org.jboss.weld.ForbiddenStateException;
+
 import com.google.common.collect.ForwardingMap;
 
 /**
@@ -180,7 +182,7 @@
       }
       else
       {
-         throw new IllegalStateException(e.getCause());
+         throw new ForbiddenStateException(e.getCause());
       }
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/dom/NodeListIterator.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,8 +16,11 @@
  */
 package org.jboss.weld.util.dom;
 
+import static org.jboss.weld.logging.messages.UtilMessage.XML_DOM_READONLY;
+
 import java.util.Iterator;
 
+import org.jboss.weld.InvalidOperationException;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -46,7 +49,7 @@
 
    public void remove()
    {
-      throw new UnsupportedOperationException("XML DOM is readonly");
+      throw new InvalidOperationException(XML_DOM_READONLY);
    }
    
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/serviceProvider/DefaultServiceLoader.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/serviceProvider/DefaultServiceLoader.java	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/serviceProvider/DefaultServiceLoader.java	2009-11-30 15:42:09 UTC (rev 5177)
@@ -16,6 +16,8 @@
  */
 package org.jboss.weld.util.serviceProvider;
 
+import static org.jboss.weld.logging.messages.UtilMessage.DECLARED_EXTENSION_DOES_NOT_IMPLEMENT_EXTENSION;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -27,6 +29,8 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.jboss.weld.ForbiddenStateException;
+import org.jboss.weld.InvalidOperationException;
 import org.jboss.weld.util.Reflections;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -129,7 +133,7 @@
     */
    public static <S> DefaultServiceLoader<S> loadInstalled(Class<S> service)
    {
-      throw new UnsupportedOperationException();
+      throw new InvalidOperationException();
    }
    
    private final String serviceFile;
@@ -206,7 +210,7 @@
                            }
                            catch (ClassCastException e)
                            {
-                              throw new IllegalStateException("Extension " + line + " does not implement Extension");
+                              throw new ForbiddenStateException(DECLARED_EXTENSION_DOES_NOT_IMPLEMENT_EXTENSION, line);
                            }
                            Constructor<? extends S> constructor = Reflections.ensureAccessible(serviceClass.getConstructor());
                            S instance = constructor.newInstance();

Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties	2009-11-30 15:42:09 UTC (rev 5177)
@@ -89,3 +89,6 @@
 OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS=Observer method must be static or business method\:  {0} on {1}
 TOO_MANY_EJBS_FOR_CLASS=Unable to determine EJB for {0}, multiple EJBs with that class\:  {1}
 ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE=Method {0} defined on {1} does not match a method on decorated type {2} 
+IP_NOT_CONSTRUCTOR_OR_METHOD=Cannot handle injection point as a constructor or method\:  {0}
+PARAM_NOT_IN_PARAM_LIST=Parameter position {0} is not in the parameter list\:  {1}
+CANNOT_READ_OBJECT=Cannot read object

Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties	2009-11-30 14:07:40 UTC (rev 5176)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/util_en.properties	2009-11-30 15:42:09 UTC (rev 5177)
@@ -1,2 +1,27 @@
 SERVICE_LOADER_LOADING_ERROR=Error loading service {0}
 SECURITY_EXCEPTION_SCANNING=Security exception scanning {0}
+XML_DOM_READONLY=XML DOM is readonly
+DECLARED_EXTENSION_DOES_NOT_IMPLEMENT_EXTENSION=Extension {0} does not implement Extension
+CLASS_NOT_ENUM={0} is not an enum
+TOO_MANY_POST_CONSTRUCT_METHODS=Cannot have more than one post construct method annotated with @PostConstruct for {0}
+TOO_MANY_PRE_DESTROY_METHODS=Cannot have more than one pre destroy method annotated @PreDestroy for {0}
+INITIALIZER_CANNOT_BE_PRODUCER=Initializer method {0} cannot be annotated @Produces on {1}
+INITIALIZER_CANNOT_BE_DISPOSAL_METHOD=Initializer method {0} cannot have parameters annotated @Disposes on {1}
+INITIALIZER_CANNOT_BE_OBSERVER=Initializer method {0} cannot be annotated @Observes on {1}
+QUALIFIER_ON_FINAL_FIELD=Cannot place qualifiers on final fields\:  {0}
+TOO_MANY_INITIALIZERS=Cannot have more than one constructor annotated with @Initializer for {0}
+AMBIGUOUS_CONSTRUCTOR=Cannot determine constructor to use for {0}
+INVALID_QUANTITY_INJECTABLE_FIELDS_AND_INITIALIZER_METHODS=injectableFields and initializerMethods must have the same size.\\n\\nInjectable Fields\:  {0}\\nInitializerMethods\:  {1}
+ANNOTATION_NOT_QUALIFIER=Annotation {0} is not a qualifier
+REDUNDANT_QUALIFIER=Qualifier {0} is already present in the set {1}
+UNABLE_TO_FIND_CONSTRUCTOR=Cannot determine constructor to use for {0}
+UNABLE_TO_FIND_BEAN_DEPLOYMENT_ARCHIVE=Unable to find Bean Deployment Archive for {0}
+EVENT_TYPE_NOT_ALLOWED=Event type {0} is not allowed
+TYPE_PARAMETER_NOT_ALLOWED_IN_EVENT_TYPE=Cannot provide an event type parameterized with a type parameter {0}
+CANNOT_PROXY_NON_CLASS_TYPE=Cannot proxy non-Class Type {0}
+INSTANCE_NOT_A_PROXY=Instance {0} is not a proxy
+ACCESS_ERROR_ON_CONSTRUCTOR=Error accessing constructor of {0} with parameters {1}
+ERROR_INVOKING_METHOD=Error invoking method {0} on {1}
+ACCESS_ERROR_ON_FIELD=Error getting field {0} on {1}
+NO_SUCH_METHOD=Method {0} not implemented by instance {1}
+ANNOTATION_VALUES_INACCESSIBLE=Cannot access values() on annotation



More information about the weld-commits mailing list