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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sat Nov 7 19:05:24 EST 2009


Author: dallen6
Date: 2009-11-07 19:05:24 -0500 (Sat, 07 Nov 2009)
New Revision: 4763

Added:
   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/InvalidOperationException.java
   core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractFacade.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorFactoryBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/PrincipalBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/UserTransactionBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseBeanProxyMethodHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
Log:
Changed some of the exception messages to resource bundles

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-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/DefinitionException.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,6 +16,9 @@
  */
 package org.jboss.weld;
 
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import ch.qos.cal10n.IMessageConveyor;
+
 /**
  * Thrown if the definition of a bean is incorrect
  * 
@@ -25,11 +28,24 @@
 {
    private static final long serialVersionUID = 8014646336322875707L;
 
+   // Exception messages
+   private static final IMessageConveyor messageConveyer  = loggerFactory().getMessageConveyor();
+
    public DefinitionException()
    {
       super();
    }
 
+   public <E extends Enum<?>> DefinitionException(E key, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args));
+   }
+
+   public <E extends Enum<?>> DefinitionException(E key, Throwable throwable, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args), throwable);
+   }
+
    public DefinitionException(String message, Throwable throwable)
    {
       super(message, throwable);

Added: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld;
+
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import ch.qos.cal10n.IMessageConveyor;
+
+/**
+ * This exception is used when the specification calls for an
+ * {@link java.lang.IllegalArgumentException}.
+ * 
+ * @author David Allen
+ */
+public class ForbiddenArgumentException extends IllegalArgumentException
+{
+
+   private static final long serialVersionUID = 1L;
+
+   // Exception messages
+   private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
+
+   public <E extends Enum<?>> ForbiddenArgumentException(E key, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args));
+   }
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenArgumentException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld;
+
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import ch.qos.cal10n.IMessageConveyor;
+
+/**
+ * This exception is used when the specification calls for an
+ * {@link java.lang.IllegalStateException}.
+ * 
+ * @author David Allen
+ */
+public class ForbiddenStateException extends IllegalStateException
+{
+   private static final long             serialVersionUID = 1L;
+
+   // Exception messages
+   private static final IMessageConveyor messageConveyer  = loggerFactory().getMessageConveyor();
+
+   public <E extends Enum<?>> ForbiddenStateException(E key, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args));
+   }
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/ForbiddenStateException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld;
+
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import ch.qos.cal10n.IMessageConveyor;
+
+/**
+ * An exception used for unsupported operations or invocations of operations
+ * that are invalid in certain contexts.
+ * 
+ * @author David Allen
+ *
+ */
+public class InvalidOperationException extends UnsupportedOperationException
+{
+
+   private static final long serialVersionUID = 1L;
+
+   // Exception messages
+   private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
+
+   public <E extends Enum<?>> InvalidOperationException(E key, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args));
+   }
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/InvalidOperationException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, 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.weld;
+
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import ch.qos.cal10n.IMessageConveyor;
+
+/**
+ * A general run-time exception used by the JSR-299 reference implementation Weld.
+ * 
+ * @author David Allen
+ */
+public class WeldException extends RuntimeException
+{
+   private static final long             serialVersionUID = 1L;
+
+   // Exception messages
+   private static final IMessageConveyor messageConveyer  = loggerFactory().getMessageConveyor();
+
+   public <E extends Enum<?>> WeldException(E key, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args));
+   }
+
+   public <E extends Enum<?>> WeldException(E key, Throwable throwable, Object... args)
+   {
+      super(messageConveyer.getMessage(key, args), throwable);
+   }
+
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/WeldException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -19,7 +19,11 @@
 import static org.jboss.weld.logging.Category.BEAN;
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
 import static org.jboss.weld.logging.messages.BeanMessage.CREATING_BEAN;
+import static org.jboss.weld.logging.messages.BeanMessage.DELEGATE_NOT_ON_DECORATOR;
+import static org.jboss.weld.logging.messages.BeanMessage.MULTIPLE_SCOPES_FOUND_FROM_STEREOTYPES;
+import static org.jboss.weld.logging.messages.BeanMessage.NAME_NOT_ALLOWED_ON_SPECIALIZATION;
 import static org.jboss.weld.logging.messages.BeanMessage.QUALIFIERS_USED;
+import static org.jboss.weld.logging.messages.BeanMessage.TYPED_CLASS_NOT_IN_HIERARCHY;
 import static org.jboss.weld.logging.messages.BeanMessage.USING_DEFAULT_NAME;
 import static org.jboss.weld.logging.messages.BeanMessage.USING_DEFAULT_QUALIFIER;
 import static org.jboss.weld.logging.messages.BeanMessage.USING_NAME;
@@ -154,7 +158,7 @@
    {
       if (this.delegateInjectionPoints.size() > 0)
       {
-         throw new DefinitionException("Cannot place @Decorates at an injection point which is not on a Decorator " + this);
+         throw new DefinitionException(DELEGATE_NOT_ON_DECORATOR, this);
       }
    }
    
@@ -210,7 +214,7 @@
       {
          if (!typeClosure.containsKey(specifiedClass))
          {
-            throw new DefinitionException("@Typed class " + specifiedClass.getName() + " is not present in the type hierarchy " + rawType);
+            throw new DefinitionException(TYPED_CLASS_NOT_IN_HIERARCHY, specifiedClass.getName(), rawType);
          }
          else
          {
@@ -337,7 +341,7 @@
       }
       else if (possibleScopeTypes.size() > 1)
       {
-         throw new DefinitionException("All stereotypes must specify the same scope OR a scope must be specified on " + getAnnotatedItem());
+         throw new DefinitionException(MULTIPLE_SCOPES_FOUND_FROM_STEREOTYPES, getAnnotatedItem());
       }
       else
       {
@@ -349,7 +353,7 @@
    {
       if (getAnnotatedItem().isAnnotationPresent(Named.class) && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
       {
-         throw new DefinitionException("Cannot put name on specializing and specialized class " + getAnnotatedItem());
+         throw new DefinitionException(NAME_NOT_ALLOWED_ON_SPECIALIZATION, getAnnotatedItem());
       }
       this.bindings.addAll(getSpecializedBean().getQualifiers());
       if (isSpecializing() && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -18,6 +18,9 @@
 
 import static org.jboss.weld.logging.Category.BEAN;
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.BeanMessage.NON_CONTAINER_DECORATOR;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_BEAN_ACCESS_FAILED;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_FAILED;
 import static org.jboss.weld.logging.messages.BeanMessage.USING_DEFAULT_SCOPE;
 import static org.jboss.weld.logging.messages.BeanMessage.USING_SCOPE;
 
@@ -49,9 +52,14 @@
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DefinitionException;
 import org.jboss.weld.DeploymentException;
+import org.jboss.weld.ForbiddenStateException;
+import org.jboss.weld.WeldException;
 import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.context.SerializableContextualImpl;
+import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
+import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
+import org.jboss.weld.context.SerializableContextualImpl;
 import org.jboss.weld.context.SerializableContextualInstanceImpl;
 import org.jboss.weld.ejb.EJBApiAbstraction;
 import org.jboss.weld.injection.FieldInjectionPoint;
@@ -198,7 +206,7 @@
             ip = Beans.getDelegateInjectionPoint(decorator);
             if (ip == null)
             {
-               throw new IllegalStateException("Cannot operate on non container provided decorator " + decorator);
+               throw new ForbiddenStateException(NON_CONTAINER_DECORATOR, decorator);
             }
          }
       }
@@ -220,11 +228,11 @@
       }
       catch (InstantiationException e)
       {
-         throw new RuntimeException("Could not instantiate decorator proxy for " + toString(), e);
+         throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
       }
       catch (IllegalAccessException e)
       {
-         throw new RuntimeException("Could not access bean correctly when creating decorator proxy for " + toString(), e);
+         throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
       }
       finally
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractFacade.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractFacade.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractFacade.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,6 +16,8 @@
  */
 package org.jboss.weld.bean.builtin;
 
+import static org.jboss.weld.logging.messages.BeanMessage.TYPE_PARAMETER_MUST_BE_CONCRETE;
+
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
@@ -25,6 +27,7 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 
 /**
  * Common implementation for binding-type-based helpers
@@ -45,7 +48,7 @@
       }
       else
       {
-         throw new IllegalStateException("Must have concrete type argument " + injectionPoint);
+         throw new ForbiddenStateException(TYPE_PARAMETER_MUST_BE_CONCRETE, injectionPoint);
       }
    }
 

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,10 +16,13 @@
  */
 package org.jboss.weld.bean.builtin.ee;
 
+import static org.jboss.weld.logging.messages.BeanMessage.VALIDATION_SERVICE_NOT_AVAILABLE;
+
 import javax.validation.Validator;
 
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.Container;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.validation.spi.ValidationServices;
 
 /**
@@ -47,7 +50,7 @@
          }
          else
          {
-            throw new IllegalStateException("ValidationServices not available");
+            throw new ForbiddenStateException(VALIDATION_SERVICE_NOT_AVAILABLE);
          }
       }
       

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorFactoryBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorFactoryBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/DefaultValidatorFactoryBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,9 +16,12 @@
  */
 package org.jboss.weld.bean.builtin.ee;
 
+import static org.jboss.weld.logging.messages.BeanMessage.VALIDATION_SERVICE_NOT_AVAILABLE;
+
 import javax.validation.ValidatorFactory;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.validation.spi.ValidationServices;
 
 /**
@@ -46,7 +49,7 @@
          }
          else
          {
-            throw new IllegalStateException("ValidationServices not available");
+            throw new ForbiddenStateException(VALIDATION_SERVICE_NOT_AVAILABLE);
          }
       }
       

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,12 +16,15 @@
  */
 package org.jboss.weld.bean.builtin.ee;
 
+import static org.jboss.weld.logging.messages.BeanMessage.INVALID_RESOURCE_PRODUCER_FIELD;
+
 import java.io.Serializable;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.Container;
 import org.jboss.weld.bean.AbstractClassBean;
 import org.jboss.weld.bean.ProducerField;
@@ -142,7 +145,7 @@
       WSApiAbstraction wsApiAbstraction = manager.getServices().get(WSApiAbstraction.class);
       if (!(getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || getAnnotatedItem().isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS)) || getAnnotatedItem().isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS))
       {
-         throw new IllegalStateException("Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present " + getAnnotatedItem());
+         throw new ForbiddenStateException(INVALID_RESOURCE_PRODUCER_FIELD, getAnnotatedItem());
       }
    }
    

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/PrincipalBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/PrincipalBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/PrincipalBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,9 +16,12 @@
  */
 package org.jboss.weld.bean.builtin.ee;
 
+import static org.jboss.weld.logging.messages.BeanMessage.SECURITY_SERVICES_NOT_AVAILABLE;
+
 import java.security.Principal;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.security.spi.SecurityServices;
 
 /**
@@ -46,7 +49,7 @@
          }
          else
          {
-            throw new IllegalStateException("SecurityServices not available");
+            throw new ForbiddenStateException(SECURITY_SERVICES_NOT_AVAILABLE);
          }
       }
       

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/UserTransactionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/UserTransactionBean.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/UserTransactionBean.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,9 +16,12 @@
  */
 package org.jboss.weld.bean.builtin.ee;
 
+import static org.jboss.weld.logging.messages.BeanMessage.TRANSACTION_SERVICES_NOT_AVAILABLE;
+
 import javax.transaction.UserTransaction;
 
 import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.transaction.spi.TransactionServices;
 
 /**
@@ -46,7 +49,7 @@
          }
          else
          {
-            throw new IllegalStateException("TransactionServices not available");
+            throw new ForbiddenStateException(TRANSACTION_SERVICES_NOT_AVAILABLE);
          }
       }
       

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/InterceptorBindingsAdapter.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -17,17 +17,24 @@
 
 package org.jboss.weld.bean.interceptor;
 
+import static org.jboss.weld.logging.messages.BeanMessage.INTERCEPTION_MODEL_NULL;
+import static org.jboss.weld.logging.messages.BeanMessage.INTERCEPTION_TYPE_LIFECYCLE;
+import static org.jboss.weld.logging.messages.BeanMessage.INTERCEPTION_TYPE_NOT_LIFECYCLE;
+import static org.jboss.weld.logging.messages.BeanMessage.INTERCEPTION_TYPE_NULL;
+import static org.jboss.weld.logging.messages.BeanMessage.METHOD_NULL;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.ArrayList;
-import java.lang.reflect.Method;
 
+import javax.enterprise.inject.spi.InterceptionType;
 import javax.enterprise.inject.spi.Interceptor;
-import javax.enterprise.inject.spi.InterceptionType;
 
+import org.jboss.interceptor.model.InterceptionModel;
+import org.jboss.weld.ForbiddenArgumentException;
 import org.jboss.weld.ejb.spi.InterceptorBindings;
 import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
-import org.jboss.interceptor.model.InterceptionModel;
 
 /**
  * @author Marius Bogoevici
@@ -41,7 +48,7 @@
    {
       if (interceptionModel == null)
       {
-         throw new IllegalArgumentException("Interception model must not be null");
+         throw new ForbiddenArgumentException(INTERCEPTION_MODEL_NULL);
       }
       this.interceptionModel = interceptionModel;
    }
@@ -56,19 +63,19 @@
    {
       if (interceptionType == null)
       {
-         throw new IllegalArgumentException("InterceptionType must not be null");
+         throw new ForbiddenArgumentException(INTERCEPTION_TYPE_NULL);
       }
 
       if (method == null)
       {
-         throw new IllegalArgumentException("Method must not be null");
+         throw new ForbiddenArgumentException(METHOD_NULL);
       }
 
       org.jboss.interceptor.model.InterceptionType internalInterceptionType = org.jboss.interceptor.model.InterceptionType.valueOf(interceptionType.name());
 
       if (internalInterceptionType.isLifecycleCallback())
       {
-         throw new IllegalArgumentException("Interception type must not be lifecycle, but it is " + interceptionType.name());
+         throw new ForbiddenArgumentException(INTERCEPTION_TYPE_LIFECYCLE, interceptionType.name());
       }
 
       return toInterceptorList(interceptionModel.getInterceptors(internalInterceptionType, method));
@@ -79,14 +86,14 @@
    {
       if (interceptionType == null)
       {
-         throw new IllegalArgumentException("InterceptionType must not be null");
+         throw new ForbiddenArgumentException(INTERCEPTION_TYPE_NULL);
       }
 
       org.jboss.interceptor.model.InterceptionType internalInterceptionType = org.jboss.interceptor.model.InterceptionType.valueOf(interceptionType.name());
 
       if (!internalInterceptionType.isLifecycleCallback())
       {
-         throw new IllegalArgumentException("Interception type must be lifecycle, but it is " + interceptionType.name());
+         throw new ForbiddenArgumentException(INTERCEPTION_TYPE_NOT_LIFECYCLE, interceptionType.name());
       }
 
       return toInterceptorList(interceptionModel.getInterceptors(internalInterceptionType, null));

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,6 +16,9 @@
  */
 package org.jboss.weld.bean.proxy;
 
+import static org.jboss.weld.logging.messages.BeanMessage.BEAN_ID_CREATION_FAILED;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_FAILED;
+
 import java.io.Serializable;
 import java.util.concurrent.Callable;
 
@@ -24,6 +27,8 @@
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.Container;
 import org.jboss.weld.DefinitionException;
+import org.jboss.weld.WeldException;
+import org.jboss.weld.logging.messages.BeanMessage;
 import org.jboss.weld.serialization.spi.ContextualStore;
 import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.Proxies.TypeInfo;
@@ -76,11 +81,11 @@
       }
       catch (InstantiationException e)
       {
-         throw new RuntimeException("Could not instantiate client proxy for " + bean, e);
+         throw new WeldException(PROXY_INSTANTIATION_FAILED, e, bean);
       }
       catch (IllegalAccessException e)
       {
-         throw new RuntimeException("Could not access bean correctly when creating client proxy for " + bean, e);
+         throw new WeldException(BeanMessage.PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, bean);
       }
    }
 
@@ -103,7 +108,7 @@
             String id = Container.instance().deploymentServices().get(ContextualStore.class).putIfAbsent(bean);
             if (id == null)
             {
-               throw new DefinitionException("There was an error creating an id for " + bean);
+               throw new DefinitionException(BEAN_ID_CREATION_FAILED, bean);
             }
             return createClientProxy(bean, manager, id);
          }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -16,6 +16,7 @@
  */
 package org.jboss.weld.bean.proxy;
 
+import static org.jboss.weld.logging.messages.BeanMessage.UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR;
 import static org.jboss.weld.util.Reflections.ensureAccessible;
 
 import java.lang.reflect.Method;
@@ -24,6 +25,7 @@
 import javax.enterprise.inject.spi.Decorator;
 
 import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
+import org.jboss.weld.ForbiddenStateException;
 import org.jboss.weld.bean.AnnotatedItemProvidingDecoratorWrapper;
 import org.jboss.weld.bean.DecoratorImpl;
 import org.jboss.weld.introspector.MethodSignature;
@@ -90,7 +92,7 @@
          }
          else
          {
-            throw new IllegalStateException("Unexpected unwrapped custom decorator instance: " + beanInstance.getContextual().get());
+            throw new ForbiddenStateException(UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR, beanInstance.getContextual().get());
          }
          if (decoratorMethod != null)
          {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-11-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseBeanProxyMethodHandler.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -20,6 +20,7 @@
 import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
 import static org.jboss.weld.logging.messages.BeanMessage.CALL_PROXIED_METHOD;
 import static org.jboss.weld.logging.messages.BeanMessage.CREATED_SESSION_BEAN_PROXY;
+import static org.jboss.weld.logging.messages.BeanMessage.INVALID_REMOVE_METHOD_INVOCATION;
 
 import java.io.Serializable;
 import java.lang.reflect.Method;
@@ -29,6 +30,7 @@
 
 import javax.enterprise.context.spi.CreationalContext;
 
+import org.jboss.weld.InvalidOperationException;
 import org.jboss.weld.bean.SessionBean;
 import org.jboss.weld.ejb.api.SessionObjectReference;
 import org.jboss.weld.introspector.MethodSignature;
@@ -112,7 +114,7 @@
          MethodSignature methodSignature = new MethodSignatureImpl(method);
          if (removeMethodSignatures.contains(methodSignature))
          {
-            throw new UnsupportedOperationException("Cannot call EJB remove method directly on non-dependent scoped bean " + method );
+            throw new InvalidOperationException(INVALID_REMOVE_METHOD_INVOCATION, method );
          }
       }
       Class<?> businessInterface = getBusinessInterface(method);

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-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java	2009-11-08 00:05:24 UTC (rev 4763)
@@ -38,6 +38,28 @@
    @MessageId("000017") USING_DEFAULT_SCOPE,
    @MessageId("000018") CIRCULAR_CALL,
    @MessageId("000019") ERROR_DESTROYING,
-   @MessageId("000020") DELEGATE_INJECTION_POINT_NOT_FOUND
+   @MessageId("000020") DELEGATE_INJECTION_POINT_NOT_FOUND,
+   @MessageId("000021") ANNOTATION_NOT_BINDING,
+   @MessageId("000022") DUPLICATE_BINDING,
+   @MessageId("000023") TYPE_PARAMETER_MUST_BE_CONCRETE,
+   @MessageId("000024") VALIDATION_SERVICE_NOT_AVAILABLE,
+   @MessageId("000025") INVALID_RESOURCE_PRODUCER_FIELD,
+   @MessageId("000026") SECURITY_SERVICES_NOT_AVAILABLE,
+   @MessageId("000027") TRANSACTION_SERVICES_NOT_AVAILABLE,
+   @MessageId("000028") INTERCEPTION_MODEL_NULL,
+   @MessageId("000029") INTERCEPTION_TYPE_NULL,
+   @MessageId("000030") METHOD_NULL,
+   @MessageId("000031") INTERCEPTION_TYPE_LIFECYCLE,
+   @MessageId("000032") INTERCEPTION_TYPE_NOT_LIFECYCLE,
+   @MessageId("000033") PROXY_INSTANTIATION_FAILED,
+   @MessageId("000034") PROXY_INSTANTIATION_BEAN_ACCESS_FAILED,
+   @MessageId("000035") BEAN_ID_CREATION_FAILED,
+   @MessageId("000036") UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR,
+   @MessageId("000037") INVALID_REMOVE_METHOD_INVOCATION,
+   @MessageId("000038") DELEGATE_NOT_ON_DECORATOR,
+   @MessageId("000039") TYPED_CLASS_NOT_IN_HIERARCHY,
+   @MessageId("000040") MULTIPLE_SCOPES_FOUND_FROM_STEREOTYPES,
+   @MessageId("000041") NAME_NOT_ALLOWED_ON_SPECIALIZATION,
+   @MessageId("000042") NON_CONTAINER_DECORATOR
    
 }

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-07 23:55:17 UTC (rev 4762)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties	2009-11-08 00:05:24 UTC (rev 4763)
@@ -19,3 +19,25 @@
 CIRCULAR_CALL=Executing producer field or method {0} on incomplete declaring bean {1} due to circular injection
 ERROR_DESTROYING=Error destroying an instance {0} of {1}
 DELEGATE_INJECTION_POINT_NOT_FOUND=Delegate injection point not found on decorator {0}
+ANNOTATION_NOT_BINDING=The annotation {0} is not a binding for {1}
+DUPLICATE_BINDING=The annotation {0} is already present in the bindings list for {1}
+TYPE_PARAMETER_MUST_BE_CONCRETE=Type parameter must be a concrete type\:  {0}
+VALIDATION_SERVICE_NOT_AVAILABLE=ValidationServices are not available
+INVALID_RESOURCE_PRODUCER_FIELD=Tried to create an EEResourceProducerField, but no @Resource, @PersistenceContext, @PersistenceUnit, @WebServiceRef or @EJB is present {0}
+SECURITY_SERVICES_NOT_AVAILABLE=SecurityServices not available
+TRANSACTION_SERVICES_NOT_AVAILABLE=TransactionServices not available
+INTERCEPTION_MODEL_NULL=Interception model must not be null
+INTERCEPTION_TYPE_NULL=InterceptionType must not be null
+METHOD_NULL=Method must not be null
+INTERCEPTION_TYPE_LIFECYCLE=InterceptionType must not be lifecycle, but it is {0}
+PROXY_INSTANTIATION_FAILED=Could not instantiate client proxy for {0}
+PROXY_INSTANTIATION_BEAN_ACCESS_FAILED=Could not access bean correctly when creating client proxy for {0}
+BEAN_ID_CREATION_FAILED=There was an error creating an id for {0}
+UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR=Unexpected unwrapped custom decorator instance\: {0}
+INVALID_REMOVE_METHOD_INVOCATION=Cannot call EJB remove method directly on non-dependent scoped bean {0}
+DELEGATE_NOT_ON_DECORATOR=Cannot place @Delegate at an injection point which is not on a Decorator\: {0}
+TYPED_CLASS_NOT_IN_HIERARCHY=@Typed class {0} is not present in the type hierarchy {1}
+MULTIPLE_SCOPES_FOUND_FROM_STEREOTYPES=All stereotypes must specify the same scope OR a scope must be specified on {0}
+NON_CONTAINER_DECORATOR=Cannot operate on non container provided decorator {0}
+NAME_NOT_ALLOWED_ON_SPECIALIZATION=Cannot put name on specializing and specialized class {0}
+INTERCEPTION_TYPE_NOT_LIFECYCLE=InterceptionType must be lifecycle, but it is {0}



More information about the weld-commits mailing list