incubator-deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [1/4] git commit: DELTASPIKE-85 cleanup
Date Wed, 21 Mar 2012 13:49:08 GMT
Updated Branches:
  refs/heads/master 73c8359c0 -> 2e1f60ec8


DELTASPIKE-85 cleanup


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/2e1f60ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/2e1f60ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/2e1f60ec

Branch: refs/heads/master
Commit: 2e1f60ec82fb61d0080186addef8381f2e55e193
Parents: ccb8cb0
Author: gpetracek <gpetracek@apache.org>
Authored: Wed Mar 21 14:39:02 2012 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Wed Mar 21 14:39:02 2012 +0100

----------------------------------------------------------------------
 .../api/metadata/builder/InjectableMethod.java     |    9 +-
 .../core/spi/activation/Deactivatable.java         |    2 +-
 .../org/apache/deltaspike/core/util/BeanUtils.java |  114 +--
 .../deltaspike/core/util/ClassDeactivation.java    |  176 ---
 .../core/util/ClassDeactivationUtils.java          |  176 +++
 .../deltaspike/core/util/ExceptionUtils.java       |   86 ++
 .../deltaspike/core/util/HierarchyDiscovery.java   |    1 +
 .../deltaspike/core/util/ReflectionUtils.java      | 1017 +--------------
 .../org/apache/deltaspike/core/util/Types.java     |  102 --
 .../deltaspike/test/api/util/CustomException.java  |   34 +
 .../test/api/util/ExceptionUtilsTest.java          |  117 ++
 .../test/api/util/IncompatibleCustomException.java |   38 +
 .../config/injectable/ConfigPropertyExtension.java |    4 +-
 .../core/impl/exclude/ExcludeExtension.java        |    6 +-
 .../impl/activation/TestClassDeactivation.java     |    6 +-
 .../core/impl/activation/TestClassDeactivator.java |    2 +-
 .../security/impl/SecurityExtension.java           |    4 +-
 17 files changed, 515 insertions(+), 1379 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/metadata/builder/InjectableMethod.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/metadata/builder/InjectableMethod.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/metadata/builder/InjectableMethod.java
index e5be6a9..b3cfc2d 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/metadata/builder/InjectableMethod.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/metadata/builder/InjectableMethod.java
@@ -31,7 +31,6 @@ import javax.enterprise.inject.spi.InjectionPoint;
 import org.apache.deltaspike.core.api.metadata.builder.ParameterValueRedefiner.ParameterValue;
 
 import static org.apache.deltaspike.core.util.BeanUtils.createInjectionPoints;
-import static org.apache.deltaspike.core.util.ReflectionUtils.EMPTY_OBJECT_ARRAY;
 import static org.apache.deltaspike.core.util.ReflectionUtils.invokeMethod;
 
 /**
@@ -50,7 +49,6 @@ import static org.apache.deltaspike.core.util.ReflectionUtils.invokeMethod;
  */
 public class InjectableMethod<X>
 {
-
     private final AnnotatedMethod<X> method;
     private final List<InjectionPoint> parameters;
     private final BeanManager beanManager;
@@ -186,9 +184,9 @@ public class InjectableMethod<X>
 
         try
         {
-            @SuppressWarnings("unchecked")
-            T result = (T) invokeMethod(true, method.getJavaMember(), receiver, parameterValues
-                    .toArray(EMPTY_OBJECT_ARRAY));
+            @SuppressWarnings({ "unchecked", "UnnecessaryLocalVariable" })
+            T result =
+                    (T) invokeMethod(receiver, method.getJavaMember(), Object.class, true, parameterValues.toArray());
             return result;
         }
         catch (RuntimeException e)
@@ -204,5 +202,4 @@ public class InjectableMethod<X>
             throw e;
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/activation/Deactivatable.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/activation/Deactivatable.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/activation/Deactivatable.java
index df68350..3a7f63c 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/activation/Deactivatable.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/activation/Deactivatable.java
@@ -29,7 +29,7 @@ package org.apache.deltaspike.core.spi.activation;
  * used for other Extension libraries as well.</p>
  *
  * <p><b>Note:</b> It is suggested that the implementations
- * use the {@link org.apache.deltaspike.core.util.ClassDeactivation} for implementing the lookup</p>
+ * use the {@link org.apache.deltaspike.core.util.ClassDeactivationUtils} for implementing the lookup</p>
  */
 public interface Deactivatable
 {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanUtils.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanUtils.java
index b2bc597..9281141 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanUtils.java
@@ -18,38 +18,32 @@
  */
 package org.apache.deltaspike.core.util;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.apache.deltaspike.core.api.metadata.builder.ImmutableInjectionPoint;
 
-import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Inject;
-
-import org.apache.deltaspike.core.api.metadata.builder.ImmutableInjectionPoint;
-
-import static org.apache.deltaspike.core.util.ReflectionUtils.isSerializable;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * A set of utility methods for working with beans.
  *
  * @author Pete Muir
  */
-public class BeanUtils
+@Typed()
+public abstract class BeanUtils
 {
 
     private BeanUtils()
     {
+        // prevent instantiation
     }
 
     /**
@@ -60,34 +54,20 @@ public class BeanUtils
      * @param annotations the annotations to check
      * @return any qualifiers present in <code>annotations</code>
      */
-    public static Set<Annotation> getQualifiers(BeanManager beanManager, Iterable<Annotation>... annotations)
+    @SuppressWarnings("unchecked")
+    public static Set<Annotation> getQualifiers(BeanManager beanManager, Iterable<Annotation> annotations)
     {
         Set<Annotation> qualifiers = new HashSet<Annotation>();
-        for (Iterable<Annotation> annotationSet : annotations)
+
+        for (Annotation annotation : annotations)
         {
-            for (Annotation annotation : annotationSet)
+            if (beanManager.isQualifier(annotation.annotationType()))
             {
-                if (beanManager.isQualifier(annotation.annotationType()))
-                {
-                    qualifiers.add(annotation);
-                }
+                qualifiers.add(annotation);
             }
         }
-        return qualifiers;
-    }
 
-    /**
-     * Extract the qualifiers from a set of annotations.
-     *
-     * @param beanManager the beanManager to use to determine if an annotation is
-     *                    a qualifier
-     * @param annotations the annotations to check
-     * @return any qualifiers present in <code>annotations</code>
-     */
-    @SuppressWarnings("unchecked")
-    public static Set<Annotation> getQualifiers(BeanManager beanManager, Iterable<Annotation> annotations)
-    {
-        return getQualifiers(beanManager, new Iterable[]{annotations});
+        return qualifiers;
     }
 
     /**
@@ -114,63 +94,6 @@ public class BeanUtils
         return qualifiers;
     }
 
-    public static void checkReturnValue(Object instance, Bean<?> bean, InjectionPoint injectionPoint,
-                                        BeanManager beanManager)
-    {
-        if (instance == null && !Dependent.class.equals(bean.getScope()))
-        {
-            throw new IllegalStateException("Cannot return null from a non-dependent producer method: " + bean);
-        }
-        else if (instance != null)
-        {
-            boolean passivating = beanManager.isPassivatingScope(bean.getScope());
-            boolean instanceSerializable = isSerializable(instance.getClass());
-            if (passivating && !instanceSerializable)
-            {
-                throw new IllegalStateException(
-                        "Producers cannot declare passivating scope and return a non-serializable class: " + bean);
-            }
-            if (injectionPoint != null && injectionPoint.getBean() != null)
-            {
-                if (!instanceSerializable && beanManager.isPassivatingScope(injectionPoint.getBean().getScope()))
-                {
-                    if (injectionPoint.getMember() instanceof Field)
-                    {
-                        if (!injectionPoint.isTransient() && instance != null && !instanceSerializable)
-                        {
-                            throw new IllegalStateException(
-                                    "Producers cannot produce non-serializable instances for injection into " +
-                                            "non-transient fields of passivating beans. Producer " +
-                                            bean + "at injection point " + injectionPoint);
-                        }
-                    }
-                    else if (injectionPoint.getMember() instanceof Method)
-                    {
-                        Method method = (Method) injectionPoint.getMember();
-                        if (method.isAnnotationPresent(Inject.class))
-                        {
-                            throw new IllegalStateException("Producers cannot produce non-serializable instances for " +
-                                    "injection into parameters of initializers of beans declaring passivating scope. " +
-                                    "Producer " + bean + "at injection point " + injectionPoint);
-                        }
-                        if (method.isAnnotationPresent(Produces.class))
-                        {
-                            throw new IllegalStateException("Producers cannot produce non-serializable instances for " +
-                                    "injection into parameters of producer methods declaring passivating scope. " +
-                                    "Producer " + bean + "at injection point " + injectionPoint);
-                        }
-                    }
-                    else if (injectionPoint.getMember() instanceof Constructor<?>)
-                    {
-                        throw new IllegalStateException("Producers cannot produce non-serializable instances for " +
-                                "injection into parameters of constructors of beans declaring passivating scope. " +
-                                "Producer " + bean + "at injection point " + injectionPoint);
-                    }
-                }
-            }
-        }
-    }
-
     /**
      * Given a method, and the bean on which the method is declared, create a
      * collection of injection points representing the parameters of the method.
@@ -194,5 +117,4 @@ public class BeanUtils
         }
         return injectionPoints;
     }
-
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivation.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivation.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivation.java
deleted file mode 100644
index ba6c9c1..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivation.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.deltaspike.core.util;
-
-import org.apache.deltaspike.core.api.config.ConfigResolver;
-import org.apache.deltaspike.core.spi.activation.ClassDeactivator;
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-
-import javax.enterprise.inject.Typed;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-/**
- * Helper methods for {@link ClassDeactivator}
- */
-@Typed()
-public abstract class ClassDeactivation
-{
-    private static final Logger LOG = Logger.getLogger(ClassDeactivation.class.getName());
-
-    /**
-     * This Map holds the ClassLoader as first level to make it possible to have different configurations per 
-     * WebApplication in an EAR or other Multi-ClassLoader scenario.
-     * 
-     * The Map then contains a List of {@link ClassDeactivator}s in order of their configured ordinal.
-     */
-    private static Map<ClassLoader, List<ClassDeactivator>> classDeactivatorMap
-        = new ConcurrentHashMap<ClassLoader, List<ClassDeactivator>>();
-
-    /**
-     * Cache for the result. It won't contain many classes but it might be accessed frequently.
-     * Valid entries are only true or false. If an entry isn't available or null, it gets calculated.
-     */
-    private static Map<Class<? extends Deactivatable>, Boolean> activationStatusCache
-        = new ConcurrentHashMap<Class<? extends Deactivatable>, Boolean>();
-    
-    private ClassDeactivation()
-    {
-        // prevent instantiation
-    }
-
-    /**
-     * Evaluates if the given {@link Deactivatable} is active.
-     *
-     * @param targetClass {@link Deactivatable} under test.
-     * @return <code>true</code> if it is active, <code>false</code> otherwise
-     */
-    public static boolean isActivated(Class<? extends Deactivatable> targetClass)
-    {
-        Boolean activatedClassCacheEntry = activationStatusCache.get(targetClass);
-
-        if (activatedClassCacheEntry == null)
-        {
-            initDeactivatableCacheFor(targetClass);
-            activatedClassCacheEntry = activationStatusCache.get(targetClass);
-        }
-        return activatedClassCacheEntry;
-    }
-
-    private static synchronized void initDeactivatableCacheFor(Class<? extends Deactivatable> targetClass)
-    {
-        Boolean activatedClassCacheEntry = activationStatusCache.get(targetClass);
-
-        if (activatedClassCacheEntry != null) //double-check
-        {
-            return;
-        }
-
-        List<ClassDeactivator> classDeactivators = getClassDeactivators();
-
-        Boolean isActivated = Boolean.TRUE;
-        Class<? extends ClassDeactivator> deactivatedBy = null;
-
-        LOG.fine("start evaluation if " + targetClass.getName() + " is de-/activated");
-
-        // we get the classActivators ordered by it's ordinal
-        // thus the last one which returns != null 'wins' ;)
-        for (ClassDeactivator classDeactivator : classDeactivators)
-        {
-            Boolean isLocallyActivated = classDeactivator.isActivated(targetClass);
-
-            if (isLocallyActivated != null)
-            {
-                isActivated = isLocallyActivated;
-
-                /*
-                * Check and log the details across class-deactivators
-                */
-                if (!isActivated)
-                {
-                    deactivatedBy = classDeactivator.getClass();
-                    LOG.fine("Deactivating class " + targetClass);
-                }
-                else if (deactivatedBy != null)
-                {
-                    LOG.fine("Reactivation of: " + targetClass.getName() + " by " +
-                            classDeactivator.getClass().getName() +
-                            " - original deactivated by: " + deactivatedBy.getName() + ".\n" +
-                            "If that isn't the intended behaviour, you have to use a higher ordinal for " +
-                            deactivatedBy.getName());
-                }
-            }
-        }
-
-        cacheResult(targetClass, isActivated);
-    }
-
-    private static void cacheResult(Class<? extends Deactivatable> targetClass, Boolean activated)
-    {
-        activationStatusCache.put(targetClass, activated);
-        LOG.info("class: " + targetClass.getName() + " activated=" + activated);
-    }
-
-    /**
-     * @return the List of configured @{link ClassDeactivator}s for the current context ClassLoader.
-     */
-    private static List<ClassDeactivator> getClassDeactivators()
-    {
-        ClassLoader classLoader = ClassUtils.getClassLoader(null);
-        List<ClassDeactivator> classDeactivators = classDeactivatorMap.get(classLoader);
-
-        if (classDeactivators == null)
-        {
-            return initConfiguredClassDeactivators(classLoader);
-        }
-
-        return classDeactivators;
-    }
-
-    //synchronized isn't needed - #initDeactivatableCacheFor is already synchronized
-    private static List<ClassDeactivator> initConfiguredClassDeactivators(ClassLoader classLoader)
-    {
-        List<String> classDeactivatorClassNames = ConfigResolver.getAllPropertyValues(ClassDeactivator.class.getName());
-
-        List<ClassDeactivator> classDeactivators = new ArrayList<ClassDeactivator>();
-
-        for (String classDeactivatorClassName : classDeactivatorClassNames)
-        {
-            LOG.fine("processing ClassDeactivator: " + classDeactivatorClassName);
-
-            try
-            {
-                ClassDeactivator currentClassDeactivator =
-                        (ClassDeactivator) ClassUtils.instantiateClassForName(classDeactivatorClassName);
-                classDeactivators.add(currentClassDeactivator);
-            }
-            catch (Exception e)
-            {
-                LOG.warning(classDeactivatorClassName + " can't be instantiated");
-                throw new IllegalStateException(e);
-            }
-        }
-
-        classDeactivatorMap.put(classLoader, classDeactivators);
-        return classDeactivators;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivationUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivationUtils.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivationUtils.java
new file mode 100644
index 0000000..a69f730
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ClassDeactivationUtils.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.core.util;
+
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.core.spi.activation.ClassDeactivator;
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+
+import javax.enterprise.inject.Typed;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+/**
+ * Helper methods for {@link ClassDeactivator}
+ */
+@Typed()
+public abstract class ClassDeactivationUtils
+{
+    private static final Logger LOG = Logger.getLogger(ClassDeactivationUtils.class.getName());
+
+    /**
+     * This Map holds the ClassLoader as first level to make it possible to have different configurations per 
+     * WebApplication in an EAR or other Multi-ClassLoader scenario.
+     * 
+     * The Map then contains a List of {@link ClassDeactivator}s in order of their configured ordinal.
+     */
+    private static Map<ClassLoader, List<ClassDeactivator>> classDeactivatorMap
+        = new ConcurrentHashMap<ClassLoader, List<ClassDeactivator>>();
+
+    /**
+     * Cache for the result. It won't contain many classes but it might be accessed frequently.
+     * Valid entries are only true or false. If an entry isn't available or null, it gets calculated.
+     */
+    private static Map<Class<? extends Deactivatable>, Boolean> activationStatusCache
+        = new ConcurrentHashMap<Class<? extends Deactivatable>, Boolean>();
+    
+    private ClassDeactivationUtils()
+    {
+        // prevent instantiation
+    }
+
+    /**
+     * Evaluates if the given {@link Deactivatable} is active.
+     *
+     * @param targetClass {@link Deactivatable} under test.
+     * @return <code>true</code> if it is active, <code>false</code> otherwise
+     */
+    public static boolean isActivated(Class<? extends Deactivatable> targetClass)
+    {
+        Boolean activatedClassCacheEntry = activationStatusCache.get(targetClass);
+
+        if (activatedClassCacheEntry == null)
+        {
+            initDeactivatableCacheFor(targetClass);
+            activatedClassCacheEntry = activationStatusCache.get(targetClass);
+        }
+        return activatedClassCacheEntry;
+    }
+
+    private static synchronized void initDeactivatableCacheFor(Class<? extends Deactivatable> targetClass)
+    {
+        Boolean activatedClassCacheEntry = activationStatusCache.get(targetClass);
+
+        if (activatedClassCacheEntry != null) //double-check
+        {
+            return;
+        }
+
+        List<ClassDeactivator> classDeactivators = getClassDeactivators();
+
+        Boolean isActivated = Boolean.TRUE;
+        Class<? extends ClassDeactivator> deactivatedBy = null;
+
+        LOG.fine("start evaluation if " + targetClass.getName() + " is de-/activated");
+
+        // we get the classActivators ordered by it's ordinal
+        // thus the last one which returns != null 'wins' ;)
+        for (ClassDeactivator classDeactivator : classDeactivators)
+        {
+            Boolean isLocallyActivated = classDeactivator.isActivated(targetClass);
+
+            if (isLocallyActivated != null)
+            {
+                isActivated = isLocallyActivated;
+
+                /*
+                * Check and log the details across class-deactivators
+                */
+                if (!isActivated)
+                {
+                    deactivatedBy = classDeactivator.getClass();
+                    LOG.fine("Deactivating class " + targetClass);
+                }
+                else if (deactivatedBy != null)
+                {
+                    LOG.fine("Reactivation of: " + targetClass.getName() + " by " +
+                            classDeactivator.getClass().getName() +
+                            " - original deactivated by: " + deactivatedBy.getName() + ".\n" +
+                            "If that isn't the intended behaviour, you have to use a higher ordinal for " +
+                            deactivatedBy.getName());
+                }
+            }
+        }
+
+        cacheResult(targetClass, isActivated);
+    }
+
+    private static void cacheResult(Class<? extends Deactivatable> targetClass, Boolean activated)
+    {
+        activationStatusCache.put(targetClass, activated);
+        LOG.info("class: " + targetClass.getName() + " activated=" + activated);
+    }
+
+    /**
+     * @return the List of configured @{link ClassDeactivator}s for the current context ClassLoader.
+     */
+    private static List<ClassDeactivator> getClassDeactivators()
+    {
+        ClassLoader classLoader = ClassUtils.getClassLoader(null);
+        List<ClassDeactivator> classDeactivators = classDeactivatorMap.get(classLoader);
+
+        if (classDeactivators == null)
+        {
+            return initConfiguredClassDeactivators(classLoader);
+        }
+
+        return classDeactivators;
+    }
+
+    //synchronized isn't needed - #initDeactivatableCacheFor is already synchronized
+    private static List<ClassDeactivator> initConfiguredClassDeactivators(ClassLoader classLoader)
+    {
+        List<String> classDeactivatorClassNames = ConfigResolver.getAllPropertyValues(ClassDeactivator.class.getName());
+
+        List<ClassDeactivator> classDeactivators = new ArrayList<ClassDeactivator>();
+
+        for (String classDeactivatorClassName : classDeactivatorClassNames)
+        {
+            LOG.fine("processing ClassDeactivator: " + classDeactivatorClassName);
+
+            try
+            {
+                ClassDeactivator currentClassDeactivator =
+                        (ClassDeactivator) ClassUtils.instantiateClassForName(classDeactivatorClassName);
+                classDeactivators.add(currentClassDeactivator);
+            }
+            catch (Exception e)
+            {
+                LOG.warning(classDeactivatorClassName + " can't be instantiated");
+                throw new IllegalStateException(e);
+            }
+        }
+
+        classDeactivatorMap.put(classLoader, classDeactivators);
+        return classDeactivators;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ExceptionUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ExceptionUtils.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ExceptionUtils.java
new file mode 100644
index 0000000..051631a
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ExceptionUtils.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.core.util;
+
+import javax.enterprise.inject.Typed;
+import java.lang.reflect.Constructor;
+
+@Typed()
+public abstract class ExceptionUtils
+{
+    private ExceptionUtils()
+    {
+        // prevent instantiation
+    }
+
+    public static void changeAndThrowException(Throwable throwable, String customMessage)
+    {
+        Throwable newThrowable = createNewException(throwable, customMessage);
+        //helper which allows to
+        new ExceptionHelper<RuntimeException>().throwException(newThrowable);
+    }
+
+    private static Throwable createNewException(Throwable throwable, String message)
+    {
+        Class<? extends Throwable> throwableClass = throwable.getClass();
+
+        try
+        {
+            Constructor<? extends Throwable> constructor = throwableClass.getDeclaredConstructor(String.class);
+            constructor.setAccessible(true);
+            Throwable result = constructor.newInstance(message);
+            result.initCause(throwable.getCause());
+            return result;
+        }
+        catch (Exception e)
+        {
+            //use the original exception if there is any issue
+            return throwable;
+        }
+    }
+
+    @SuppressWarnings({ "unchecked" })
+    private static class ExceptionHelper<T extends Throwable>
+    {
+        private void throwException(Throwable exception) throws T
+        {
+            try
+            {
+                //exception-type is only checked at compile-time
+                throw (T) exception;
+            }
+            catch (ClassCastException e)
+            {
+                //doesn't happen with existing JVMs! - if that changes the local ClassCastException needs to be ignored
+                //-> throw original exception
+                if (e.getStackTrace()[0].toString().contains(getClass().getName()))
+                {
+                    if (exception instanceof RuntimeException)
+                    {
+                        throw (RuntimeException) exception;
+                    }
+                    throw new RuntimeException(exception);
+                }
+                //if the exception to throw is a ClassCastException, throw it
+                throw e;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/HierarchyDiscovery.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/HierarchyDiscovery.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/HierarchyDiscovery.java
index 1163162..2d7bb8c 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/HierarchyDiscovery.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/HierarchyDiscovery.java
@@ -35,6 +35,7 @@ import java.util.logging.Logger;
  */
 //X TODO: Look at merging this with ClassUtils perhaps
 //X TODO: JavaDoc
+//X TODO review
 @Typed()
 public class HierarchyDiscovery
 {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ReflectionUtils.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ReflectionUtils.java
index 24c0a83..94337b0 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ReflectionUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ReflectionUtils.java
@@ -22,33 +22,20 @@ package org.apache.deltaspike.core.util;
 import javax.enterprise.inject.Typed;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Qualifier;
-import java.beans.Introspector;
 import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
 import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
 import java.lang.reflect.WildcardType;
 import java.security.AccessController;
-import java.util.Arrays;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
-//import java.util.Arrays;
-
 /**
  * Utilities for common reflection based actions. Some are basic Java Reflection based, others are CDI based.
  */
@@ -58,12 +45,6 @@ import java.util.Set;
 public abstract class ReflectionUtils
 {
     /**
-     * An empty array of type {@link Annotation}, useful converting lists to
-     * arrays.
-     */
-    public static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
-    /**
      * An empty array of type {@link Object}, useful for converting lists to
      * arrays.
      */
@@ -71,8 +52,6 @@ public abstract class ReflectionUtils
 
     public static final Type[] EMPTY_TYPES = {};
 
-    public static final Class<?>[] EMPTY_CLASSES = new Class<?>[0];
-
     private ReflectionUtils()
     {
         // prevent instantiation
@@ -112,10 +91,7 @@ public abstract class ReflectionUtils
         HashSet<Field> fields = new HashSet<Field>();
         for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
         {
-            for (Field a : c.getDeclaredFields())
-            {
-                fields.add(a);
-            }
+            Collections.addAll(fields, c.getDeclaredFields());
         }
         return fields;
     }
@@ -129,7 +105,7 @@ public abstract class ReflectionUtils
      * @param name  The name of the field to search for
      * @return The field found, or null if no field is found
      */
-    public static Field findDeclaredField(Class<?> clazz, String name)
+    public static Field tryToFindDeclaredField(Class<?> clazz, String name)
     {
         for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
         {
@@ -167,72 +143,6 @@ public abstract class ReflectionUtils
     }
 
     /**
-     * Search for annotations with the specified meta annotation type
-     *
-     * @param annotations        The annotation set to search
-     * @param metaAnnotationType The type of the meta annotation to search for
-     * @return The set of annotations with the specified meta annotation, or an
-     *         empty set if none are found
-     */
-    public static Set<Annotation> getAnnotationsWithMetaAnnotation(Set<Annotation> annotations,
-                                                                   Class<? extends Annotation> metaAnnotationType)
-    {
-        Set<Annotation> set = new HashSet<Annotation>();
-        for (Annotation annotation : annotations)
-        {
-            if (annotation.annotationType().isAnnotationPresent(metaAnnotationType))
-            {
-                set.add(annotation);
-            }
-        }
-        return set;
-    }
-
-    /**
-     * Extract any qualifiers from the set of annotations
-     *
-     * @param annotations The set of annotations to search
-     * @param beanManager The beanManager to use to establish if an annotation is
-     *                    a qualifier
-     * @return The qualifiers present in the set, or an empty set if there are
-     *         none
-     */
-    public static Set<Annotation> getQualifiers(Set<Annotation> annotations, BeanManager beanManager)
-    {
-        Set<Annotation> set = new HashSet<Annotation>();
-        for (Annotation annotation : annotations)
-        {
-            if (beanManager.isQualifier(annotation.annotationType()))
-            {
-                set.add(annotation);
-            }
-        }
-        return set;
-    }
-
-    /**
-     * Determine if a method exists in a specified class hierarchy
-     *
-     * @param clazz The class to search
-     * @param name  The name of the method
-     * @return true if a method is found, otherwise false
-     */
-    public static boolean methodExists(Class<?> clazz, String name)
-    {
-        for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
-        {
-            for (Method m : c.getDeclaredMethods())
-            {
-                if (m.getName().equals(name))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
      * Get all the declared methods on the class hierarchy. This <b>will</b>
      * return overridden methods.
      *
@@ -244,186 +154,20 @@ public abstract class ReflectionUtils
         HashSet<Method> methods = new HashSet<Method>();
         for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
         {
-            for (Method a : c.getDeclaredMethods())
-            {
-                methods.add(a);
-            }
+            Collections.addAll(methods, c.getDeclaredMethods());
         }
         return methods;
     }
 
-    /**
-     * Search the class hierarchy for a method with the given name and arguments.
-     * Will return the nearest match, starting with the class specified and
-     * searching up the hierarchy.
-     *
-     * @param clazz The class to search
-     * @param name  The name of the method to search for
-     * @param args  The arguments of the method to search for
-     * @return The method found, or null if no method is found
-     */
-    public static Method findDeclaredMethod(Class<?> clazz, String name, Class<?>... args)
-    {
-        for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
-        {
-            try
-            {
-                return c.getDeclaredMethod(name, args);
-            }
-            catch (NoSuchMethodException e)
-            {
-                // No-op, continue the search
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Search the class hierarchy for a constructor with the given arguments.
-     * Will return the nearest match, starting with the class specified and
-     * searching up the hierarchy.
-     *
-     * @param clazz The class to search
-     * @param args  The arguments of the constructor to search for
-     * @return The constructor found, or null if no constructor is found
-     */
-    public static Constructor<?> findDeclaredConstructor(Class<?> clazz, Class<?>... args)
-    {
-        for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
-        {
-            try
-            {
-                return c.getDeclaredConstructor(args);
-            }
-            catch (NoSuchMethodException e)
-            {
-                // No-op, continue the search
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Get all the declared constructors on the class hierarchy. This <b>will</b>
-     * return overridden constructors.
-     *
-     * @param clazz The class to search
-     * @return the set of all declared constructors or an empty set if there are
-     *         none
-     */
-    public static Set<Constructor<?>> getAllDeclaredConstructors(Class<?> clazz)
-    {
-        HashSet<Constructor<?>> constructors = new HashSet<Constructor<?>>();
-        for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass())
-        {
-            for (Constructor<?> constructor : c.getDeclaredConstructors())
-            {
-                constructors.add(constructor);
-            }
-        }
-        return constructors;
-    }
-
-    /**
-     * Get the type of the member
-     *
-     * @param member The member
-     * @return The type of the member
-     * @throws UnsupportedOperationException if the member is not a field,
-     *                                       method, or constructor
-     */
-    public static Class<?> getMemberType(Member member)
-    {
-        if (member instanceof Field)
-        {
-            return ((Field) member).getType();
-        }
-        else if (member instanceof Method)
-        {
-            return ((Method) member).getReturnType();
-        }
-        else if (member instanceof Constructor<?>)
-        {
-            return ((Constructor<?>) member).getDeclaringClass();
-        }
-        else
-        {
-            throw new UnsupportedOperationException("Cannot operate on a member of type " + member.getClass());
-        }
-    }
-
-    /**
-     * <p>
-     * Loads and initializes a class for the given name.
-     * </p>
-     * <p/>
-     * <p>
-     * If the Thread Context Class Loader is available, it will be used,
-     * otherwise the classloader used to load {@link ReflectionUtils} will be used
-     * </p>
-     * <p/>
-     * <p>
-     * It is also possible to specify additional classloaders to attempt to load
-     * the class with. If the first attempt fails, then these additional loaders
-     * are tried in order.
-     * </p>
-     *
-     * @param name    the name of the class to load
-     * @param loaders additional classloaders to use to attempt to load the class
-     * @return the class object
-     * @throws ClassNotFoundException if the class cannot be found
-     * @deprecated move/merge with ClassUtils
-     */
-    public static Class<?> classForName(String name, ClassLoader... loaders) throws ClassNotFoundException
-    {
-        try
-        {
-            if (Thread.currentThread().getContextClassLoader() != null)
-            {
-                return Class.forName(name, true, Thread.currentThread().getContextClassLoader());
-            }
-            else
-            {
-                return Class.forName(name);
-            }
-        }
-        catch (ClassNotFoundException e)
-        {
-            for (ClassLoader l : loaders)
-            {
-                try
-                {
-                    return Class.forName(name, true, l);
-                }
-                catch (ClassNotFoundException ex)
-                {
-
-                }
-            }
-        }
-        if (Thread.currentThread().getContextClassLoader() != null)
-        {
-            throw new ClassNotFoundException(String.format(
-                "Could not load class %s with the context class loader %s or any of the additional ClassLoaders: %s",
-                name, Thread.currentThread().getContextClassLoader(), loaders));
-        }
-        else
-        {
-            throw new ClassNotFoundException("Could not load class " + name +
-                    " using Class.forName or using any of the additional ClassLoaders: " + Arrays.toString(loaders));
-        }
-    }
-
     private static String buildInvokeMethodErrorMessage(Method method, Object obj, Object... args)
     {
         StringBuilder message = new StringBuilder(String.format(
-                "Exception invoking method [%s] on object [%s], using arguments [", method.getName(), obj));
+                "Details: Exception invoking method [%s] on object [%s], using arguments [", method.getName(), obj));
         if (args != null)
         {
             for (int i = 0; i < args.length; i++)
             {
-                message.append(i > 0 ? "," : "")
-                       .append(args[i]);
+                message.append(i > 0 ? ", " : "").append(args[i]);
             }
         }
         message.append("]");
@@ -439,6 +183,7 @@ public abstract class ReflectionUtils
      * @param member the accessible object
      * @return the accessible object after the accessible flag has been altered
      */
+    @Deprecated //X TODO use SecurityService of OWB
     public static <A extends AccessibleObject> A setAccessible(A member)
     {
         AccessController.doPrivileged(new SetAccessiblePrivilegedAction(member));
@@ -447,67 +192,6 @@ public abstract class ReflectionUtils
 
     /**
      * <p>
-     * Invoke the specified method on the provided instance, passing any additional
-     * arguments included in this method as arguments to the specified method.
-     * </p>
-     * <p/>
-     * <p>This method provides the same functionality and throws the same exceptions as
-     * {@link ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)}, with the
-     * expected return type set to {@link Object} and no change to the method's accessibility.</p>
-     *
-     * @see ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)
-     * @see Method#invoke(Object, Object...)
-     */
-    public static Object invokeMethod(Method method, Object instance, Object... args)
-    {
-        return invokeMethod(false, method, Object.class, instance, args);
-    }
-
-    /**
-     * <p>
-     * Invoke the specified method on the provided instance, passing any additional
-     * arguments included in this method as arguments to the specified method.
-     * </p>
-     * <p/>
-     * <p>
-     * This method attempts to set the accessible flag of the method in a
-     * {@link java.security.PrivilegedAction} before invoking the method if the first argument
-     * is true.
-     * </p>
-     * <p/>
-     * <p>This method provides the same functionality and throws the same exceptions as
-     * {@link ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)}, with the
-     * expected return type set to {@link Object}.</p>
-     *
-     * @see ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)
-     * @see Method#invoke(Object, Object...)
-     */
-    public static Object invokeMethod(boolean setAccessible, Method method, Object instance, Object... args)
-    {
-        return invokeMethod(setAccessible, method, Object.class, instance, args);
-    }
-
-    /**
-     * <p>
-     * Invoke the specified method on the provided instance, passing any additional
-     * arguments included in this method as arguments to the specified method.
-     * </p>
-     * <p/>
-     * <p>This method provides the same functionality and throws the same exceptions as
-     * {@link ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)}, with the
-     * expected return type set to {@link Object} and honoring the accessibility of
-     * the method.</p>
-     *
-     * @see ReflectionUtils#invokeMethod(boolean, Method, Class, Object, Object...)
-     * @see Method#invoke(Object, Object...)
-     */
-    public static <T> T invokeMethod(Method method, Class<T> expectedReturnType, Object instance, Object... args)
-    {
-        return invokeMethod(false, method, expectedReturnType, instance, args);
-    }
-
-    /**
-     * <p>
      * Invoke the method on the instance, with any arguments specified, casting
      * the result of invoking the method to the expected return type.
      * </p>
@@ -550,9 +234,10 @@ public abstract class ReflectionUtils
      *                                     method fails.
      * @see Method#invoke(Object, Object...)
      */
-    public static <T> T invokeMethod(boolean setAccessible,
+    public static <T> T invokeMethod(Object instance, 
                                      Method method, Class<T> expectedReturnType,
-                                     Object instance, Object... args)
+                                     boolean setAccessible,
+                                     Object... args)
     {
         if (setAccessible && !method.isAccessible())
         {
@@ -563,171 +248,18 @@ public abstract class ReflectionUtils
         {
             return expectedReturnType.cast(method.invoke(instance, args));
         }
-        catch (IllegalAccessException ex)
-        {
-            throw new RuntimeException(buildInvokeMethodErrorMessage(method, instance, args), ex);
-        }
-        catch (IllegalArgumentException ex)
-        {
-            throw new IllegalArgumentException(buildInvokeMethodErrorMessage(method, instance, args), ex);
-        }
-        catch (InvocationTargetException ex)
-        {
-            throw new RuntimeException(buildInvokeMethodErrorMessage(method, instance, args), ex.getCause());
-        }
-        catch (NullPointerException ex)
-        {
-            NullPointerException ex2 = new NullPointerException(buildInvokeMethodErrorMessage(method, instance, args));
-            ex2.initCause(ex.getCause());
-            throw ex2;
-        }
-        catch (ExceptionInInitializerError e)
-        {
-            ExceptionInInitializerError e2 =
-                    new ExceptionInInitializerError(buildInvokeMethodErrorMessage(method, instance, args));
-            e2.initCause(e.getCause());
-            throw e2;
-        }
-    }
-
-    /**
-     * <p>
-     * Set the value of a field on the instance to the specified value.
-     * </p>
-     * <p/>
-     * <p>This method provides the same functionality and throws the same exceptions as
-     * {@link ReflectionUtils#setFieldValue(boolean, Field, Object, Object)}, honoring
-     * the accessibility of the field.</p>
-     */
-    public static void setFieldValue(Field field, Object instance, Object value)
-    {
-        setFieldValue(false, field, instance, value);
-    }
-
-    /**
-     * <p>
-     * Sets the value of a field on the instance to the specified value.
-     * </p>
-     * <p/>
-     * <p>
-     * This method wraps {@link Field#set(Object, Object)}, converting the
-     * checked exceptions that {@link Field#set(Object, Object)} specifies to
-     * runtime exceptions.
-     * </p>
-     * <p/>
-     * <p>
-     * If instructed, this method attempts to set the accessible flag of the method in a
-     * {@link java.security.PrivilegedAction} before invoking the method.
-     * </p>
-     *
-     * @param field    the field on which to operate, or null if the field is static
-     * @param instance the instance on which the field value should be set upon
-     * @param value    the value to set the field to
-     * @throws RuntimeException            if the underlying field is inaccessible.
-     * @throws IllegalArgumentException    if the specified <code>instance</code> is not an
-     *                                     instance of the class or interface declaring the underlying
-     *                                     field (or a subclass or implementor thereof), or if an
-     *                                     unwrapping conversion fails.
-     * @throws NullPointerException        if the specified <code>instance</code> is null and the field
-     *                                     is an instance field.
-     * @throws ExceptionInInitializerError if the initialization provoked by this
-     *                                     method fails.
-     * @see Field#set(Object, Object)
-     */
-    public static void setFieldValue(boolean setAccessible, Field field, Object instance, Object value)
-    {
-        if (setAccessible && !field.isAccessible())
-        {
-            setAccessible(field);
-        }
-
-        try
-        {
-            field.set(instance, value);
-        }
-        catch (IllegalAccessException e)
+        catch (Exception e)
         {
-            throw new RuntimeException(buildSetFieldValueErrorMessage(field, instance, value), e);
-        }
-        catch (NullPointerException ex)
-        {
-            NullPointerException ex2 = new NullPointerException(buildSetFieldValueErrorMessage(field, instance, value));
-            ex2.initCause(ex.getCause());
-            throw ex2;
-        }
-        catch (ExceptionInInitializerError e)
-        {
-            ExceptionInInitializerError e2 =
-                    new ExceptionInInitializerError(buildSetFieldValueErrorMessage(field, instance, value));
-            e2.initCause(e.getCause());
-            throw e2;
+            String customMessage = createCustomMessage(e, method, instance, args);
+            ExceptionUtils.changeAndThrowException(e, customMessage);
+            //won't happen
+            return null;
         }
     }
 
-    private static String buildSetFieldValueErrorMessage(Field field, Object obj, Object value)
-    {
-        return String.format("Exception setting [%s] field on object [%s] to value [%s]", field.getName(), obj, value);
-    }
-
-    private static String buildGetFieldValueErrorMessage(Field field, Object obj)
-    {
-        return String.format("Exception reading [%s] field from object [%s].", field.getName(), obj);
-    }
-
-    public static Object getFieldValue(Field field, Object instance)
-    {
-        return getFieldValue(field, instance, Object.class);
-    }
-
-    /**
-     * <p>
-     * Get the value of the field, on the specified instance, casting the value
-     * of the field to the expected type.
-     * </p>
-     * <p/>
-     * <p>
-     * This method wraps {@link Field#get(Object)}, converting the checked
-     * exceptions that {@link Field#get(Object)} specifies to runtime exceptions.
-     * </p>
-     *
-     * @param <T>          the type of the field's value
-     * @param field        the field to operate on
-     * @param instance     the instance from which to retrieve the value
-     * @param expectedType the expected type of the field's value
-     * @return the value of the field
-     * @throws RuntimeException            if the underlying field is inaccessible.
-     * @throws IllegalArgumentException    if the specified <code>instance</code> is not an
-     *                                     instance of the class or interface declaring the underlying
-     *                                     field (or a subclass or implementor thereof).
-     * @throws NullPointerException        if the specified <code>instance</code> is null and the field
-     *                                     is an instance field.
-     * @throws ExceptionInInitializerError if the initialization provoked by this
-     *                                     method fails.
-     */
-    public static <T> T getFieldValue(Field field, Object instance, Class<T> expectedType)
+    private static String createCustomMessage(Exception e, Method method, Object targetObject, Object... arguments)
     {
-        try
-        {
-            //<T> needed to bypass an issue with old jdk versions
-            return ReflectionUtils.<T>cast(field.get(instance));
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new RuntimeException(buildGetFieldValueErrorMessage(field, instance), e);
-        }
-        catch (NullPointerException ex)
-        {
-            NullPointerException ex2 = new NullPointerException(buildGetFieldValueErrorMessage(field, instance));
-            ex2.initCause(ex.getCause());
-            throw ex2;
-        }
-        catch (ExceptionInInitializerError e)
-        {
-            ExceptionInInitializerError e2 =
-                    new ExceptionInInitializerError(buildGetFieldValueErrorMessage(field, instance));
-            e2.initCause(e.getCause());
-            throw e2;
-        }
+        return e.getMessage() + buildInvokeMethodErrorMessage(method, targetObject, arguments);
     }
 
     /**
@@ -738,7 +270,7 @@ public abstract class ReflectionUtils
      * @return the raw type, or null if the raw type cannot be determined.
      */
     @SuppressWarnings("unchecked")
-    public static <T> Class<T> getRawType(Type type)
+    private static <T> Class<T> getRawType(Type type)
     {
         if (type instanceof Class<?>)
         {
@@ -755,110 +287,24 @@ public abstract class ReflectionUtils
      * Check if a class is serializable.
      *
      * @param clazz The class to check
-     * @return true if the class implements serializable or is a primitive
+     * @return true if the class implements serializable or is a primitive (needed for type {@link Void}
      */
     public static boolean isSerializable(Class<?> clazz)
     {
         return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz);
     }
 
-
-    public static Map<Class<?>, Type> buildTypeMap(Set<Type> types)
-    {
-        Map<Class<?>, Type> map = new HashMap<Class<?>, Type>();
-        for (Type type : types)
-        {
-            if (type instanceof Class<?>)
-            {
-                map.put((Class<?>) type, type);
-            }
-            else if (type instanceof ParameterizedType)
-            {
-                if (((ParameterizedType) type).getRawType() instanceof Class<?>)
-                {
-                    map.put((Class<?>) ((ParameterizedType) type).getRawType(), type);
-                }
-            }
-        }
-        return map;
-    }
-
-    public static boolean isCacheable(Set<Annotation> annotations)
-    {
-        for (Annotation qualifier : annotations)
-        {
-            Class<?> clazz = qualifier.getClass();
-            if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz)))
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public static boolean isCacheable(Annotation[] annotations)
-    {
-        for (Annotation qualifier : annotations)
-        {
-            Class<?> clazz = qualifier.getClass();
-            if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz)))
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Gets the property name from a getter method.
-     * <p/>
-     * We extend JavaBean conventions, allowing the getter method to have parameters
-     *
-     * @param method The getter method
-     * @return The name of the property. Returns null if method wasn't JavaBean
-     *         getter-styled
-     */
-    public static String getPropertyName(Method method)
-    {
-        String methodName = method.getName();
-        if (methodName.matches("^(get).*"))
-        {
-            return Introspector.decapitalize(methodName.substring(3));
-        }
-        else if (methodName.matches("^(is).*"))
-        {
-            return Introspector.decapitalize(methodName.substring(2));
-        }
-        else
-        {
-            return null;
-        }
-
-    }
-
-    /**
-     * Checks if class is final
-     *
-     * @param clazz The class to check
-     * @return True if final, false otherwise
-     */
-    public static boolean isFinal(Class<?> clazz)
+    /**
+     * Checks if class is final
+     *
+     * @param clazz The class to check
+     * @return True if final, false otherwise
+     */
+    public static boolean isFinal(Class<?> clazz)
     {
         return Modifier.isFinal(clazz.getModifiers());
     }
 
-    public static int getNesting(Class<?> clazz)
-    {
-        if (clazz.isMemberClass() && !isStatic(clazz))
-        {
-            return 1 + getNesting(clazz.getDeclaringClass());
-        }
-        else
-        {
-            return 0;
-        }
-    }
-
     /**
      * Checks if member is final
      *
@@ -881,33 +327,6 @@ public abstract class ReflectionUtils
         return Modifier.isPrivate(member.getModifiers());
     }
 
-    /**
-     * Checks if type or member is final
-     *
-     * @param type Type or member
-     * @return True if final, false otherwise
-     */
-    public static boolean isTypeOrAnyMethodFinal(Class<?> type)
-    {
-        return getNonPrivateFinalMethodOrType(type) != null;
-    }
-
-    public static Object getNonPrivateFinalMethodOrType(Class<?> type)
-    {
-        if (isFinal(type))
-        {
-            return type;
-        }
-        for (Method method : type.getDeclaredMethods())
-        {
-            if (isFinal(method) && !isPrivate(method))
-            {
-                return method;
-            }
-        }
-        return null;
-    }
-
     public static boolean isPackagePrivate(int mod)
     {
         return !(Modifier.isPrivate(mod) || Modifier.isProtected(mod) || Modifier.isPublic(mod));
@@ -957,7 +376,7 @@ public abstract class ReflectionUtils
      * @param clazz The class to examine
      * @return The type arguments
      */
-    public static Type[] getActualTypeArguments(Class<?> clazz)
+    public static Type[] getTypeArguments(Class<?> clazz)
     {
         Type type = new HierarchyDiscovery(clazz).getResolvedType();
         if (type instanceof ParameterizedType)
@@ -976,7 +395,7 @@ public abstract class ReflectionUtils
      * @param type The type to examine
      * @return The type arguments
      */
-    public static Type[] getActualTypeArguments(Type type)
+    public static Type[] getTypeArguments(Type type)
     {
         Type resolvedType = new HierarchyDiscovery(type).getResolvedType();
         if (resolvedType instanceof ParameterizedType)
@@ -1011,7 +430,7 @@ public abstract class ReflectionUtils
         return type.getTypeParameters().length > 0;
     }
 
-    public static boolean isParamerterizedTypeWithWildcard(Class<?> type)
+    public static boolean isParameterizedTypeWithWildcard(Class<?> type)
     {
         if (isParameterizedType(type))
         {
@@ -1023,7 +442,7 @@ public abstract class ReflectionUtils
         }
     }
 
-    public static boolean containsWildcards(Type[] types)
+    private static boolean containsWildcards(Type[] types)
     {
         for (Type type : types)
         {
@@ -1035,382 +454,6 @@ public abstract class ReflectionUtils
         return false;
     }
 
-    /**
-     * Checks the bindingType to make sure the annotation was declared properly
-     * as a binding type (annotated with @BindingType) and that it has a runtime
-     * retention policy.
-     *
-     * @param binding The binding type to check
-     * @return true only if the annotation is really a binding type
-     */
-    @Deprecated
-    // TODO Replace usage of this with metadatacache
-    public static boolean isBindings(Annotation binding)
-    {
-        boolean isBindingAnnotation = false;
-        if (binding.annotationType().isAnnotationPresent(Qualifier.class)
-                && binding.annotationType().isAnnotationPresent(Retention.class)
-                && binding.annotationType().getAnnotation(Retention.class).value().equals(RetentionPolicy.RUNTIME))
-        {
-            isBindingAnnotation = true;
-        }
-        return isBindingAnnotation;
-    }
-
-    /**
-     * Check the assignability of one type to another, taking into account the
-     * actual type arguements
-     *
-     * @param rawType1             the raw type of the class to check
-     * @param actualTypeArguments1 the actual type arguements to check, or an
-     *                             empty array if not a parameterized type
-     * @param rawType2             the raw type of the class to check
-     * @param actualTypeArguments2 the actual type arguements to check, or an
-     *                             empty array if not a parameterized type
-     * @return
-     */
-    public static boolean isAssignableFrom(Class<?> rawType1,
-                                           Type[] actualTypeArguments1,
-                                           Class<?> rawType2,
-                                           Type[] actualTypeArguments2)
-    {
-        return Types.boxedClass(rawType1).isAssignableFrom(Types.boxedClass(rawType2)) &&
-                isAssignableFrom(actualTypeArguments1, actualTypeArguments2);
-    }
-
-    public static boolean matches(Class<?> rawType1,
-                                  Type[] actualTypeArguments1,
-                                  Class<?> rawType2,
-                                  Type[] actualTypeArguments2)
-    {
-        return Types.boxedClass(rawType1).equals(Types.boxedClass(rawType2)) &&
-                isAssignableFrom(actualTypeArguments1, actualTypeArguments2);
-    }
-
-    public static boolean isAssignableFrom(Type[] actualTypeArguments1, Type[] actualTypeArguments2)
-    {
-        for (int i = 0; i < actualTypeArguments1.length; i++)
-        {
-            Type type1 = actualTypeArguments1[i];
-            Type type2 = Object.class;
-            if (actualTypeArguments2.length > i)
-            {
-                type2 = actualTypeArguments2[i];
-            }
-            if (!isAssignableFrom(type1, type2))
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public static boolean isAssignableFrom(Type type1, Set<? extends Type> types2)
-    {
-        for (Type type2 : types2)
-        {
-            if (isAssignableFrom(type1, type2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean matches(Type type1, Set<? extends Type> types2)
-    {
-        for (Type type2 : types2)
-        {
-            if (matches(type1, type2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean isAssignableFrom(Type type1, Type[] types2)
-    {
-        for (Type type2 : types2)
-        {
-            if (isAssignableFrom(type1, type2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean isAssignableFrom(Type type1, Type type2)
-    {
-        if (type1 instanceof Class<?>)
-        {
-            Class<?> clazz = (Class<?>) type1;
-            if (isAssignableFrom(clazz, EMPTY_TYPES, type2))
-            {
-                return true;
-            }
-        }
-        if (type1 instanceof ParameterizedType)
-        {
-            ParameterizedType parameterizedType1 = (ParameterizedType) type1;
-            if (parameterizedType1.getRawType() instanceof Class<?>)
-            {
-                if (isAssignableFrom((Class<?>) parameterizedType1.getRawType(),
-                                     parameterizedType1.getActualTypeArguments(),
-                                     type2))
-                {
-                    return true;
-                }
-            }
-        }
-        if (type1 instanceof WildcardType)
-        {
-            WildcardType wildcardType = (WildcardType) type1;
-            if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds()))
-            {
-                return true;
-            }
-        }
-        if (type2 instanceof WildcardType)
-        {
-            WildcardType wildcardType = (WildcardType) type2;
-            if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds()))
-            {
-                return true;
-            }
-        }
-        if (type1 instanceof TypeVariable<?>)
-        {
-            TypeVariable<?> typeVariable = (TypeVariable<?>) type1;
-            if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds()))
-            {
-                return true;
-            }
-        }
-        if (type2 instanceof TypeVariable<?>)
-        {
-            TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
-            if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean matches(Type type1, Type type2)
-    {
-        if (type1 instanceof Class<?>)
-        {
-            Class<?> clazz = (Class<?>) type1;
-            if (matches(clazz, EMPTY_TYPES, type2))
-            {
-                return true;
-            }
-        }
-        if (type1 instanceof ParameterizedType)
-        {
-            ParameterizedType parameterizedType1 = (ParameterizedType) type1;
-            if (parameterizedType1.getRawType() instanceof Class<?>)
-            {
-                if (matches((Class<?>) parameterizedType1.getRawType(),
-                        parameterizedType1.getActualTypeArguments(),
-                        type2))
-                {
-                    return true;
-                }
-            }
-        }
-        if (type1 instanceof WildcardType)
-        {
-            WildcardType wildcardType = (WildcardType) type1;
-            if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds()))
-            {
-                return true;
-            }
-        }
-        if (type2 instanceof WildcardType)
-        {
-            WildcardType wildcardType = (WildcardType) type2;
-            if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds()))
-            {
-                return true;
-            }
-        }
-        if (type1 instanceof TypeVariable<?>)
-        {
-            TypeVariable<?> typeVariable = (TypeVariable<?>) type1;
-            if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds()))
-            {
-                return true;
-            }
-        }
-        if (type2 instanceof TypeVariable<?>)
-        {
-            TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
-            if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds)
-    {
-        if (lowerBounds.length > 0)
-        {
-            if (!isAssignableFrom(type, lowerBounds))
-            {
-                return false;
-            }
-        }
-        if (upperBounds.length > 0)
-        {
-            if (!isAssignableFrom(upperBounds, type))
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
-    {
-        if (type2 instanceof ParameterizedType)
-        {
-            ParameterizedType parameterizedType = (ParameterizedType) type2;
-            if (parameterizedType.getRawType() instanceof Class<?>)
-            {
-                if (isAssignableFrom(
-                        rawType1,
-                        actualTypeArguments1,
-                        (Class<?>) parameterizedType.getRawType(),
-                        parameterizedType.getActualTypeArguments()))
-                {
-                    return true;
-                }
-            }
-        }
-        else if (type2 instanceof Class<?>)
-        {
-            Class<?> clazz = (Class<?>) type2;
-            if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES))
-            {
-                return true;
-            }
-        }
-        else if (type2 instanceof TypeVariable<?>)
-        {
-            TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
-            if (isTypeBounded(rawType1, actualTypeArguments1, typeVariable.getBounds()))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean matches(Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
-    {
-        if (type2 instanceof ParameterizedType)
-        {
-            ParameterizedType parameterizedType = (ParameterizedType) type2;
-            if (parameterizedType.getRawType() instanceof Class<?>)
-            {
-                if (matches(
-                        rawType1,
-                        actualTypeArguments1,
-                        (Class<?>) parameterizedType.getRawType(),
-                        parameterizedType.getActualTypeArguments()))
-                {
-                    return true;
-                }
-            }
-        }
-        else if (type2 instanceof Class<?>)
-        {
-            Class<?> clazz = (Class<?>) type2;
-            if (matches(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check the assiginability of a set of <b>flattened</b> types. This
-     * algorithm will check whether any of the types1 matches a type in types2
-     *
-     * @param types1
-     * @param types2
-     * @return
-     */
-    public static boolean isAssignableFrom(Set<Type> types1, Set<Type> types2)
-    {
-        for (Type type : types1)
-        {
-            if (isAssignableFrom(type, types2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check whether whether any of the types1 matches a type in types2
-     *
-     * @param types1
-     * @param types2
-     * @return
-     */
-    public static boolean matches(Set<Type> types1, Set<Type> types2)
-    {
-        for (Type type : types1)
-        {
-            if (matches(type, types2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check the assiginability of a set of <b>flattened</b> types. This
-     * algorithm will check whether any of the types1 matches a type in types2
-     *
-     * @param types1
-     * @param type2
-     * @return
-     */
-    public static boolean isAssignableFrom(Set<Type> types1, Type type2)
-    {
-        for (Type type : types1)
-        {
-            if (isAssignableFrom(type, type2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static boolean isAssignableFrom(Type[] types1, Type type2)
-    {
-        for (Type type : types1)
-        {
-            if (isAssignableFrom(type, type2))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
     public static boolean isPrimitive(Type type)
     {
         Class<?> rawType = getRawType(type);

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/Types.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/Types.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/Types.java
deleted file mode 100644
index ac76796..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/Types.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.deltaspike.core.util;
-
-import javax.enterprise.inject.Typed;
-import java.lang.reflect.Type;
-
-/**
- * Utilities for Types.
- */
-@Typed()
-public abstract class Types
-{
-    private Types()
-    {
-        // prevent instantiation
-    }
-
-    /**
-     * Gets the boxed type of a class
-     *
-     * @param type The type
-     * @return The boxed type
-     */
-    public static Type boxedType(Type type)
-    {
-        if (type instanceof Class<?>)
-        {
-            return boxedClass((Class<?>) type);
-        }
-        else
-        {
-            return type;
-        }
-    }
-
-    public static Class<?> boxedClass(Class<?> type)
-    {
-        if (!type.isPrimitive())
-        {
-            return type;
-        }
-        else if (type.equals(Boolean.TYPE))
-        {
-            return Boolean.class;
-        }
-        else if (type.equals(Character.TYPE))
-        {
-            return Character.class;
-        }
-        else if (type.equals(Byte.TYPE))
-        {
-            return Byte.class;
-        }
-        else if (type.equals(Short.TYPE))
-        {
-            return Short.class;
-        }
-        else if (type.equals(Integer.TYPE))
-        {
-            return Integer.class;
-        }
-        else if (type.equals(Long.TYPE))
-        {
-            return Long.class;
-        }
-        else if (type.equals(Float.TYPE))
-        {
-            return Float.class;
-        }
-        else if (type.equals(Double.TYPE))
-        {
-            return Double.class;
-        }
-        else if (type.equals(Void.TYPE))
-        {
-            return Void.class;
-        }
-        else
-        {
-            // Vagaries of if/else statement, can't be reached ;-)
-            return type;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/CustomException.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/CustomException.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/CustomException.java
new file mode 100644
index 0000000..894c7ee
--- /dev/null
+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/CustomException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.test.api.util;
+
+class CustomException extends Exception
+{
+    private static final long serialVersionUID = 6197126259870336328L;
+
+    CustomException(String message)
+    {
+        super(message);
+    }
+
+    CustomException(String message, Throwable cause)
+    {
+        super(message, cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/ExceptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/ExceptionUtilsTest.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/ExceptionUtilsTest.java
new file mode 100644
index 0000000..a59d878
--- /dev/null
+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/ExceptionUtilsTest.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.test.api.util;
+
+import org.apache.deltaspike.core.util.ExceptionUtils;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ExceptionUtilsTest
+{
+    private static final String FIELD_DOES_NOT_EXIST = "field does not exist - custom message";
+
+    @Test
+    public void changeMessageOfCustomException()
+    {
+        try
+        {
+            ExceptionUtils.changeAndThrowException(
+                    new CustomException("old", new Exception("original")), "new");
+        }
+        catch (RuntimeException e)
+        {
+            Assert.fail();
+        }
+        catch (Exception e)
+        {
+            Assert.assertEquals("original", e.getCause().getMessage());
+            Assert.assertEquals("new", e.getMessage());
+            Assert.assertEquals(CustomException.class, e.getClass());
+            return;
+        }
+        Assert.fail();
+    }
+
+    @Test
+    public void changeMessageOfInvalidCustomException()
+    {
+        try
+        {
+            ExceptionUtils.changeAndThrowException(
+                    new IncompatibleCustomException("old", new Exception("original"), 1), "new");
+        }
+        catch (RuntimeException e)
+        {
+            Assert.fail();
+        }
+        catch (Exception e)
+        {
+            Assert.assertEquals("original", e.getCause().getMessage());
+            Assert.assertEquals("old", e.getMessage());
+            Assert.assertEquals(IncompatibleCustomException.class, e.getClass());
+            Assert.assertEquals(1, ((IncompatibleCustomException) e).getCustomParameter());
+            return;
+        }
+        Assert.fail();
+    }
+
+    @Test
+    public void rethrowCheckedException()
+    {
+        try
+        {
+            invalidOperation();
+        }
+        catch (NoSuchFieldException e)
+        {
+            Assert.assertEquals(FIELD_DOES_NOT_EXIST, e.getMessage());
+            Assert.assertEquals(null, e.getCause());
+            return;
+        }
+        Assert.fail();
+    }
+
+    @Test
+    public void rethrowUncheckedException()
+    {
+        try
+        {
+            ExceptionUtils.changeAndThrowException(new ClassCastException(), "custom");
+        }
+        catch (ClassCastException e)
+        {
+            Assert.assertEquals("custom", e.getMessage());
+            Assert.assertEquals(null, e.getCause());
+            return;
+        }
+        Assert.fail();
+    }
+
+    private void invalidOperation() throws NoSuchFieldException
+    {
+        try
+        {
+            getClass().getDeclaredField("virtualField");
+        }
+        catch (NoSuchFieldException e)
+        {
+            ExceptionUtils.changeAndThrowException(e, FIELD_DOES_NOT_EXIST);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/IncompatibleCustomException.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/IncompatibleCustomException.java b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/IncompatibleCustomException.java
new file mode 100644
index 0000000..82222f9
--- /dev/null
+++ b/deltaspike/core/api/src/test/java/org/apache/deltaspike/test/api/util/IncompatibleCustomException.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.test.api.util;
+
+import java.io.Serializable;
+
+class IncompatibleCustomException extends Exception
+{
+    private static final long serialVersionUID = 6197126259870336328L;
+    private Serializable customParameter;
+
+    IncompatibleCustomException(String message, Throwable cause, Serializable customParameter)
+    {
+        super(message, cause);
+        this.customParameter = customParameter;
+    }
+
+    Object getCustomParameter()
+    {
+        return customParameter;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
index 0fb01f4..ff3e3aa 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
@@ -21,7 +21,7 @@ package org.apache.deltaspike.core.impl.config.injectable;
 import org.apache.deltaspike.core.api.config.ConfigProperty;
 import org.apache.deltaspike.core.api.config.ConfigResolver;
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassDeactivation;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
@@ -109,7 +109,7 @@ public class ConfigPropertyExtension implements Extension, Deactivatable
     {
         if (this.isActivated == null)
         {
-            this.isActivated = ClassDeactivation.isActivated(getClass());
+            this.isActivated = ClassDeactivationUtils.isActivated(getClass());
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/2e1f60ec/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
index b6e906c..c2fdee1 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
@@ -25,7 +25,7 @@ import org.apache.deltaspike.core.api.exclude.Exclude;
 import org.apache.deltaspike.core.api.interpreter.ExpressionInterpreter;
 import org.apache.deltaspike.core.api.projectstage.ProjectStage;
 import org.apache.deltaspike.core.impl.interpreter.PropertyExpressionInterpreter;
-import org.apache.deltaspike.core.util.ClassDeactivation;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.core.util.ProjectStageProducer;
 
@@ -494,8 +494,8 @@ public class ExcludeExtension implements Extension, Deactivatable
     {
         if (isActivated == null)
         {
-            isActivated = ClassDeactivation.isActivated(getClass());
-            isGlobalAlternativeActivated = ClassDeactivation.isActivated(GlobalAlternative.class);
+            isActivated = ClassDeactivationUtils.isActivated(getClass());
+            isGlobalAlternativeActivated = ClassDeactivationUtils.isActivated(GlobalAlternative.class);
         }
     }
 


Mime
View raw message