You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/04/05 23:37:07 UTC

git commit: DELTASPIKE-146 cleanup

Updated Branches:
  refs/heads/master 3c04cb5e3 -> 84ce67928


DELTASPIKE-146 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/84ce6792
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/84ce6792
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/84ce6792

Branch: refs/heads/master
Commit: 84ce6792897d35ec2608107a17616b590e1f4d11
Parents: 3c04cb5
Author: gpetracek <gp...@apache.org>
Authored: Thu Apr 5 23:29:16 2012 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Thu Apr 5 23:34:52 2012 +0200

----------------------------------------------------------------------
 .../core/api/literal/MessageBundleLiteral.java     |    3 +-
 .../apache/deltaspike/core/api/message/Cause.java  |   40 ----
 .../deltaspike/core/api/message/Message.java       |    7 -
 .../core/impl/message/AbstractImmutableBean.java   |  110 +++++-----
 .../deltaspike/core/impl/message/Arrays2.java      |   54 -----
 .../core/impl/message/ImmutableBeanWrapper.java    |  124 +++++++++++
 .../core/impl/message/ImmutableNarrowingBean.java  |  128 -----------
 .../core/impl/message/MessageBundleExtension.java  |   57 ++++--
 .../message/MessageBundleInvocationHandler.java    |   74 +------
 .../core/impl/message/MessageFactory.java          |   51 -----
 .../core/impl/message/NarrowingBeanBuilder.java    |  168 ++++++---------
 .../deltaspike/core/impl/message/ProxyUtils.java   |   47 ++++
 .../impl/message/TypedMessageBundleProducer.java   |    6 +-
 .../deltaspike/core/impl/util/ArraysUtils.java     |   56 +++++
 .../test/core/api/message/BirdMessages.java        |    7 +-
 .../deltaspike/test/core/api/message/Jay.java      |   17 +-
 .../test/core/api/message/MessageTest.java         |   46 ++--
 17 files changed, 441 insertions(+), 554 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/MessageBundleLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/MessageBundleLiteral.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/MessageBundleLiteral.java
index 03b73bc..e2a3aff 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/MessageBundleLiteral.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/literal/MessageBundleLiteral.java
@@ -25,8 +25,7 @@ import org.apache.deltaspike.core.api.message.MessageBundle;
 /**
  * Literal for {@link MessageBundle}
  */
-public class MessageBundleLiteral extends AnnotationLiteral<MessageBundle>
-        implements MessageBundle
+public class MessageBundleLiteral extends AnnotationLiteral<MessageBundle> implements MessageBundle
 {
     private static final long serialVersionUID = 5116646785333766333L;
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Cause.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Cause.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Cause.java
deleted file mode 100644
index de23600..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Cause.java
+++ /dev/null
@@ -1,40 +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.api.message;
-
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Mark a parameter as being the "exception cause" parameter rather than a
- * positional format parameter.
- * 
- * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
- */
-@Retention(CLASS)
-@Target(PARAMETER)
-@Documented
-public @interface Cause
-{
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Message.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Message.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Message.java
index fac3dda..95980cd 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Message.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/Message.java
@@ -30,7 +30,6 @@ import java.lang.annotation.Target;
 @Documented
 public @interface Message
 {
-
     /**
      * The default format string of this message.
      *
@@ -50,7 +49,6 @@ public @interface Message
      */
     enum Format
     {
-
         /**
          * A {@link java.util.Formatter}-type format string.
          */
@@ -59,10 +57,5 @@ public @interface Message
          * A {@link java.text.MessageFormat}-type format string.
          */
         MESSAGE_FORMAT,
-        /**
-         * An expression language type format string.
-         */
-        EXP_LANG
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/AbstractImmutableBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/AbstractImmutableBean.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/AbstractImmutableBean.java
index 58d1875..a2dd7cb 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/AbstractImmutableBean.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/AbstractImmutableBean.java
@@ -23,13 +23,13 @@ import java.lang.reflect.Type;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.logging.Logger;
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.deltaspike.core.api.literal.DefaultLiteral;
+import org.apache.deltaspike.core.impl.util.ArraysUtils;
 
 /**
  * <p>
@@ -41,15 +41,11 @@ import org.apache.deltaspike.core.api.literal.DefaultLiteral;
  * <p>
  * This class does not provide any bean lifecycle operations
  * </p>
- * 
- * @see ImmutableBean
- * @see ImmutableNarrowingBean
+ *
+ * @see ImmutableBeanWrapper
  */
 abstract class AbstractImmutableBean<T> implements Bean<T>
 {
-    private transient Logger log = Logger.getLogger(AbstractImmutableBean.class
-            .getName());
-
     private final Class<?> beanClass;
     private final String name;
     private final Set<Annotation> qualifiers;
@@ -64,87 +60,89 @@ abstract class AbstractImmutableBean<T> implements Bean<T>
     /**
      * Create a new, immutable bean. All arguments passed as collections are
      * defensively copied.
-     * 
-     * @param beanClass
-     *            The Bean class, may not be null
-     * @param name
-     *            The bean name
-     * @param qualifiers
-     *            The bean's qualifiers, if null, a singleton set of
-     *            {@link Default} is used
-     * @param scope
-     *            The bean's scope, if null, the default scope of
-     *            {@link Dependent} is used
-     * @param stereotypes
-     *            The bean's stereotypes, if null, an empty set is used
-     * @param types
-     *            The bean's types, if null, the beanClass and {@link Object}
-     *            will be used
-     * @param alternative
-     *            True if the bean is an alternative
-     * @param nullable
-     *            True if the bean is nullable
-     * @param injectionPoints
-     *            the bean's injection points, if null an empty set is used
-     * @param beanLifecycle
-     *            Handler for {@link #create(CreationalContext)} and
-     *            {@link #destroy(Object, CreationalContext)}
-     * @throws IllegalArgumentException
-     *             if the beanClass is null
+     *
+     * @param beanClass       The Bean class, may not be null
+     * @param name            The bean name
+     * @param qualifiers      The bean's qualifiers, if null, a singleton set of
+     *                        {@link javax.enterprise.inject.Default} is used
+     * @param scope           The bean's scope, if null, the default scope of
+     *                        {@link Dependent} is used
+     * @param stereotypes     The bean's stereotypes, if null, an empty set is used
+     * @param types           The bean's types, if null, the beanClass and {@link Object}
+     *                        will be used
+     * @param alternative     True if the bean is an alternative
+     * @param nullable        True if the bean is nullable
+     * @param injectionPoints the bean's injection points, if null an empty set is used
+     * @throws IllegalArgumentException if the beanClass is null
      */
-    public AbstractImmutableBean(Class<?> beanClass, String name,
-            Set<Annotation> qualifiers, Class<? extends Annotation> scope,
-            Set<Class<? extends Annotation>> stereotypes, Set<Type> types,
-            boolean alternative, boolean nullable,
-            Set<InjectionPoint> injectionPoints, String toString)
+    public AbstractImmutableBean(Class<?> beanClass,
+                                 String name,
+                                 Set<Annotation> qualifiers,
+                                 Class<? extends Annotation> scope,
+                                 Set<Class<? extends Annotation>> stereotypes,
+                                 Set<Type> types,
+                                 boolean alternative,
+                                 boolean nullable,
+                                 Set<InjectionPoint> injectionPoints,
+                                 String toString)
     {
         if (beanClass == null)
         {
             throw new IllegalArgumentException("beanClass cannot be null");
         }
+
         this.beanClass = beanClass;
         this.name = name;
+
         if (qualifiers == null)
         {
-            this.qualifiers = Collections
-                    .<Annotation> singleton(new DefaultLiteral());
-            log.finest("No qualifers provided for bean class " + beanClass
-                    + ", using singleton set of @Default");
+            this.qualifiers = Collections.<Annotation>singleton(new DefaultLiteral());
+
+            //X TODO re-visit after the logging discussion
+            //LOG.finest("No qualifers provided for bean class " + beanClass + ", using singleton set of @Default");
         }
         else
         {
             this.qualifiers = new HashSet<Annotation>(qualifiers);
         }
+
         if (scope == null)
         {
             this.scope = Dependent.class;
-            log.finest("No scope provided for bean class " + beanClass
-                    + ", using @Dependent");
+
+            //X TODO re-visit after the logging discussion
+            //LOG.finest("No scope provided for bean class " + beanClass + ", using @Dependent");
         }
         else
         {
             this.scope = scope;
         }
+
         if (stereotypes == null)
         {
             this.stereotypes = Collections.emptySet();
         }
         else
         {
-            this.stereotypes = new HashSet<Class<? extends Annotation>>(
-                    stereotypes);
+            this.stereotypes = new HashSet<Class<? extends Annotation>>(stereotypes);
         }
+
         if (types == null)
         {
-            this.types = Arrays2.<Type> asSet(Object.class, beanClass);
-            log.finest("No types provided for bean class " + beanClass
+            this.types = ArraysUtils.<Type>asSet(Object.class, beanClass);
+
+            //X TODO re-visit after the logging discussion
+            /*
+            LOG.finest("No types provided for bean class " + beanClass
                     + ", using [java.lang.Object.class, " + beanClass.getName()
                     + ".class]");
+            */
         }
         else
         {
             this.types = new HashSet<Type>(types);
         }
+
         if (injectionPoints == null)
         {
             this.injectionPoints = Collections.emptySet();
@@ -153,59 +151,69 @@ abstract class AbstractImmutableBean<T> implements Bean<T>
         {
             this.injectionPoints = new HashSet<InjectionPoint>(injectionPoints);
         }
+
         this.alternative = alternative;
         this.nullable = nullable;
+
         if (toString != null)
         {
             this.toString = toString;
         }
         else
         {
-            this.toString = "Custom Bean with bean class " + beanClass
-                    + " and qualifiers " + qualifiers;
+            this.toString = "Custom Bean with bean class " + beanClass + " and qualifiers " + qualifiers;
         }
     }
 
+    @Override
     public Class<?> getBeanClass()
     {
         return beanClass;
     }
 
+    @Override
     public Set<InjectionPoint> getInjectionPoints()
     {
         return injectionPoints;
     }
 
+    @Override
     public String getName()
     {
         return name;
     }
 
+    @Override
     public Set<Annotation> getQualifiers()
     {
         return Collections.unmodifiableSet(qualifiers);
     }
 
+    @Override
     public Class<? extends Annotation> getScope()
     {
         return scope;
     }
 
+    @Override
     public Set<Class<? extends Annotation>> getStereotypes()
     {
         return Collections.unmodifiableSet(stereotypes);
     }
 
+    @Override
     public Set<Type> getTypes()
     {
         return Collections.unmodifiableSet(types);
     }
 
+    @Override
     public boolean isAlternative()
     {
         return alternative;
     }
 
+    @Override
     public boolean isNullable()
     {
         return nullable;

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/Arrays2.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/Arrays2.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/Arrays2.java
deleted file mode 100644
index 2c8a715..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/Arrays2.java
+++ /dev/null
@@ -1,54 +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.impl.message;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A collection of utilities for working with Arrays that goes beyond that in
- * the JDK.
- */
-class Arrays2
-{
-
-    private Arrays2()
-    {
-    }
-
-    /**
-     * Create a set from an array. If the array contains duplicate objects, the
-     * last object in the array will be placed in resultant set.
-     * 
-     * @param <T>
-     *            the type of the objects in the set
-     * @param array
-     *            the array from which to create the set
-     * @return the created sets
-     */
-    public static <T> Set<T> asSet(T... array)
-    {
-        Set<T> result = new HashSet<T>();
-        for (T a : array)
-        {
-            result.add(a);
-        }
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableBeanWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableBeanWrapper.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableBeanWrapper.java
new file mode 100644
index 0000000..bf40c45
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableBeanWrapper.java
@@ -0,0 +1,124 @@
+/*
+ * 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.impl.message;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.deltaspike.core.util.ReflectionUtils;
+
+/**
+ * <p>
+ * This bean-wrapper allows you to build a general purpose bean (likely a
+ * producer method), and register it for a narrowed type (or qualifiers). For
+ * example, you could create a producer method which uses an a String ID to
+ * located an object (the object can have any class):
+ * </p>
+ * <p/>
+ * <p/>
+ * <pre>
+ * &#064;Produces
+ * // Use some synthetic scope to prevent this from interfering with other
+ * // resolutions
+ * &#064;MyProducer
+ * Object produce(InjectionPoint ip)
+ * {
+ *     String id = ip.getAnnotated().getAnnotation(Id.class).value();
+ *     // Lookup and return the object for the id
+ * }
+ * </pre>
+ * <p/>
+ * <p>
+ * The wrapped bean <em>must</em> return an object which can be cast to the
+ * type <code>T</code>, otherwise a {@link ClassCastException} will be thrown at
+ * runtime when the bean is created.
+ * </p>
+ * <p/>
+ * <p>
+ * You can then register a narrowing bean for each type you need:
+ * </p>
+ * <p/>
+ * <p/>
+ * <pre>
+ * event.addBean(new NarrowingBeanBuilder&lt;T&gt;(delegateBean).readFromType(type)
+ *         .create());
+ * </pre>
+ * <p/>
+ * <p>
+ * {@link ImmutableBeanWrapper} will use the annotations on
+ * <code>defininingType</code> to discover the qualifiers, types, scope,
+ * stereotypes of the bean, as well as determine it's name (if any) and whether
+ * it is an alternative.
+ * </p>
+ * <p/>
+ * <p>
+ * The attributes are immutable, and collections are defensively copied on
+ * instantiation. It uses the defaults from the specification for properties if
+ * not specified.
+ * </p>
+ *
+ * @see NarrowingBeanBuilder
+ */
+class ImmutableBeanWrapper<T> extends AbstractImmutableBean<T>
+{
+    private final Bean<T> wrapped;
+
+    /**
+     * Instantiate a new {@link ImmutableBeanWrapper}.
+     *
+     * @param bean        the bean to wrapped the lifecycle to
+     * @param name        the name of the bean
+     * @param qualifiers  the qualifiers of the bean
+     * @param scope       the scope of the bean
+     * @param stereotypes the bean's stereotypes
+     * @param types       the types of the bean
+     * @param alternative whether the bean is an alternative
+     */
+    public ImmutableBeanWrapper(Bean<T> bean,
+                                String name,
+                                Set<Annotation> qualifiers,
+                                Class<? extends Annotation> scope,
+                                Set<Class<? extends Annotation>> stereotypes,
+                                Set<Type> types,
+                                boolean alternative,
+                                boolean nullable,
+                                String toString)
+    {
+        super(bean.getBeanClass(), name, qualifiers, scope, stereotypes,
+            types, alternative, nullable, bean.getInjectionPoints(), toString);
+
+        this.wrapped = bean;
+    }
+
+    @Override
+    public T create(CreationalContext<T> creationalContext)
+    {
+        return ReflectionUtils.cast(wrapped.create(creationalContext));
+    }
+
+    @Override
+    public void destroy(T instance, CreationalContext<T> creationalContext)
+    {
+        wrapped.destroy(instance, creationalContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableNarrowingBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableNarrowingBean.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableNarrowingBean.java
deleted file mode 100644
index 6c302cf..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ImmutableNarrowingBean.java
+++ /dev/null
@@ -1,128 +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.impl.message;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-
-import org.apache.deltaspike.core.util.ReflectionUtils;
-
-/**
- * <p>
- * A narrowing bean allows you to build a general purpose bean (likely a
- * producer method), and register it for a narrowed type (or qualifiers). For
- * example, you could create a producer method which uses an a String ID to
- * located an object (the object can have any class):
- * </p>
- * <p/>
- * 
- * <pre>
- * &#064;Produces
- * // Use some synthetic scope to prevent this from interfering with other
- * // resolutions
- * &#064;MyProducer
- * Object produce(InjectionPoint ip)
- * {
- *     String id = ip.getAnnotated().getAnnotation(Id.class).value();
- *     // Lookup and return the object for the id
- * }
- * </pre>
- * <p/>
- * <p>
- * The delegate bean <em>must</em> return an object which can be cast to the
- * type <code>T</code>, otherwise a {@link ClassCastException} will be thrown at
- * runtime when the bean is created.
- * </p>
- * <p/>
- * <p>
- * You can then register a narrowing bean for each type you need:
- * </p>
- * <p/>
- * 
- * <pre>
- * event.addBean(new NarrowingBeanBuilder&lt;T&gt;(delegateBean).readFromType(type)
- *         .create());
- * </pre>
- * <p/>
- * <p>
- * {@link ImmutableNarrowingBean} will use the annotations on
- * <code>defininingType</code> to discover the qualifiers, types, scope,
- * stereotypes of the bean, as well as determine it's name (if any) and whether
- * it is an alternative.
- * </p>
- * <p/>
- * <p>
- * The attributes are immutable, and collections are defensively copied on
- * instantiation. It uses the defaults from the specification for properties if
- * not specified.
- * </p>
- * 
- * @see NarrowingBeanBuilder
- * @see ImmutablePassivationCapableNarrowingBean
- */
-class ImmutableNarrowingBean<T> extends AbstractImmutableBean<T>
-{
-
-    private final Bean<Object> delegate;
-
-    /**
-     * Instantiate a new {@link ImmutableNarrowingBean}.
-     * 
-     * @param delegate
-     *            the bean to delegate the lifecycle to
-     * @param name
-     *            the name of the bean
-     * @param qualifiers
-     *            the qualifiers of the bean
-     * @param scope
-     *            the scope of the bean
-     * @param stereotypes
-     *            the bean's stereotypes
-     * @param types
-     *            the types of the bean
-     * @param alternative
-     *            whether the bean is an alternative
-     */
-    public ImmutableNarrowingBean(Bean<Object> delegate, String name,
-            Set<Annotation> qualifiers, Class<? extends Annotation> scope,
-            Set<Class<? extends Annotation>> stereotypes, Set<Type> types,
-            boolean alternative, boolean nullable, String toString)
-    {
-        super(delegate.getBeanClass(), name, qualifiers, scope, stereotypes,
-                types, alternative, nullable, delegate.getInjectionPoints(),
-                toString);
-        this.delegate = delegate;
-    }
-
-    public T create(CreationalContext<T> creationalContext)
-    {
-        return ReflectionUtils.<T> cast(delegate.create(ReflectionUtils
-                .<CreationalContext<Object>> cast(creationalContext)));
-    }
-
-    public void destroy(T instance, CreationalContext<T> creationalContext)
-    {
-        delegate.destroy(instance, ReflectionUtils
-                .<CreationalContext<Object>> cast(creationalContext));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
index 6a36220..70a7ab9 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleExtension.java
@@ -28,6 +28,7 @@ import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.inject.spi.ProcessProducerMethod;
@@ -35,20 +36,29 @@ import javax.enterprise.inject.spi.ProcessProducerMethod;
 import org.apache.deltaspike.core.api.literal.MessageBundleLiteral;
 import org.apache.deltaspike.core.api.message.MessageBundle;
 import org.apache.deltaspike.core.spi.activation.Deactivatable;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 
 public class MessageBundleExtension implements Extension, Deactivatable
 {
-    private final Collection<AnnotatedType<?>> messageBundleTypes;
+    private final Collection<AnnotatedType<?>> messageBundleTypes = new HashSet<AnnotatedType<?>>();
     private Bean<Object> bundleProducerBean;
 
-    public MessageBundleExtension()
+    private Boolean isActivated = null;
+
+    @SuppressWarnings("UnusedDeclaration")
+    protected void init(@Observes BeforeBeanDiscovery afterBeanDiscovery)
     {
-        this.messageBundleTypes = new HashSet<AnnotatedType<?>>();
+        initActivation();
     }
 
-    void detectInterfaces(@Observes ProcessAnnotatedType<?> event,
-            BeanManager beanManager)
+    @SuppressWarnings("UnusedDeclaration")
+    protected void detectInterfaces(@Observes ProcessAnnotatedType<?> event)
     {
+        if (!this.isActivated)
+        {
+            return;
+        }
+
         AnnotatedType<?> type = event.getAnnotatedType();
         if (type.isAnnotationPresent(MessageBundle.class))
         {
@@ -59,22 +69,33 @@ public class MessageBundleExtension implements Extension, Deactivatable
     // according to the Java EE 6 javadoc (the authority according to the powers
     // that be),
     // this is the correct order of type parameters
-    void detectProducers(
-            @Observes ProcessProducerMethod<Object, TypedMessageBundleProducer> event)
+    @SuppressWarnings("UnusedDeclaration")
+    protected void detectProducers(@Observes ProcessProducerMethod<Object, TypedMessageBundleProducer> event)
     {
+        if (!this.isActivated)
+        {
+            return;
+        }
+
         captureProducers(event.getAnnotatedProducerMethod(), event.getBean());
     }
 
     // according to JSR-299 spec, this is the correct order of type parameters
+    //X TODO re-visit it
     @Deprecated
-    void detectProducersInverted(
-            @Observes ProcessProducerMethod<TypedMessageBundleProducer, Object> event)
+    @SuppressWarnings("UnusedDeclaration")
+    protected void detectProducersInverted(@Observes ProcessProducerMethod<TypedMessageBundleProducer, Object> event)
     {
+        if (!this.isActivated)
+        {
+            return;
+        }
+
         captureProducers(event.getAnnotatedProducerMethod(), event.getBean());
     }
 
     @SuppressWarnings("unchecked")
-    void captureProducers(AnnotatedMethod<?> method, Bean<?> bean)
+    protected void captureProducers(AnnotatedMethod<?> method, Bean<?> bean)
     {
         if (method.isAnnotationPresent(TypedMessageBundle.class))
         {
@@ -82,8 +103,8 @@ public class MessageBundleExtension implements Extension, Deactivatable
         }
     }
 
-    void installBeans(@Observes AfterBeanDiscovery event,
-            BeanManager beanManager)
+    @SuppressWarnings("UnusedDeclaration")
+    protected void installBeans(@Observes AfterBeanDiscovery event, BeanManager beanManager)
     {
         for (AnnotatedType<?> type : messageBundleTypes)
         {
@@ -93,16 +114,24 @@ public class MessageBundleExtension implements Extension, Deactivatable
     }
 
     private static <T> Bean<T> createMessageBundleBean(Bean<Object> delegate,
-            AnnotatedType<T> type, BeanManager beanManager)
+                                                       AnnotatedType<T> type, BeanManager beanManager)
     {
         return new NarrowingBeanBuilder<T>(delegate, beanManager)
                 .readFromType(type).types(type.getBaseType(), Object.class)
                 .addQualifier(new MessageBundleLiteral()).create();
     }
 
-    void cleanup(@Observes AfterDeploymentValidation event)
+    @SuppressWarnings("UnusedDeclaration")
+    protected void cleanup(@Observes AfterDeploymentValidation event)
     {
         this.messageBundleTypes.clear();
     }
 
+    protected void initActivation()
+    {
+        if (isActivated == null)
+        {
+            isActivated = ClassDeactivationUtils.isActivated(getClass());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
index ca99a17..392a89d 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageBundleInvocationHandler.java
@@ -18,27 +18,20 @@
  */
 package org.apache.deltaspike.core.impl.message;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
+import org.apache.deltaspike.core.api.message.Message;
+
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.deltaspike.core.api.message.Cause;
-import org.apache.deltaspike.core.api.message.Message;
 
 class MessageBundleInvocationHandler implements InvocationHandler
 {
-
     /**
      * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,
      *      java.lang.reflect.Method, java.lang.Object[])
      */
     @Override
-    public Object invoke(final Object proxy, final Method method,
-            final Object[] args) throws Throwable
+    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
     {
         final Message message = method.getAnnotation(Message.class);
         if (message == null)
@@ -46,76 +39,23 @@ class MessageBundleInvocationHandler implements InvocationHandler
             // nothing to do...
             return null;
         }
-        final Annotation[][] parameterAnnotations = method
-                .getParameterAnnotations();
-        ArrayList<Object> newArgs = new ArrayList<Object>();
-        Throwable cause = extractCause(parameterAnnotations, args, newArgs);
+
         String result;
         switch (message.format())
         {
             case PRINTF:
             {
-                result = String.format(message.value(), newArgs.toArray());
+                result = String.format(message.value(), args);
                 break;
             }
             case MESSAGE_FORMAT:
             {
-                result = MessageFormat.format(message.value(),
-                        newArgs.toArray());
+                result = MessageFormat.format(message.value(), args);
                 break;
             }
             default:
                 throw new IllegalStateException();
         }
-        final Class<?> returnType = method.getReturnType();
-        if (Throwable.class.isAssignableFrom(returnType))
-        {
-            // the return type is an exception
-            if (cause != null)
-            {
-                final Constructor<?> constructor = returnType.getConstructor(
-                        String.class, Throwable.class);
-                return constructor.newInstance(result, cause);
-            }
-            else
-            {
-                final Constructor<?> constructor = returnType
-                        .getConstructor(String.class);
-                return constructor.newInstance(result);
-            }
-        }
-        else
-        {
-            return result;
-        }
-    }
-
-    protected static Throwable extractCause(
-            final Annotation[][] parameterAnnotations, final Object[] args,
-            final List<Object> newArgs)
-    {
-        Throwable cause = null;
-        for (int i = 0; i < parameterAnnotations.length; i++)
-        {
-            Annotation[] annotations = parameterAnnotations[i];
-            boolean found = false;
-            for (Annotation annotation : annotations)
-            {
-                if (annotation instanceof Cause)
-                {
-                    if (cause == null)
-                    {
-                        cause = (Throwable) args[i];
-                    }
-                    found = true;
-                }
-            }
-            if (!found)
-            {
-                newArgs.add(args[i]);
-            }
-        }
-        return cause;
+        return result;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageFactory.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageFactory.java
deleted file mode 100644
index a966317..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/MessageFactory.java
+++ /dev/null
@@ -1,51 +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.impl.message;
-
-import java.lang.reflect.Proxy;
-
-/**
- * A factory class to produce message bundle implementations.
- */
-final class MessageFactory
-{
-
-    private MessageFactory()
-    {
-    }
-
-    /**
-     * Get a message bundle of the given type. Equivalent to
-     * <code>{@link #getBundle(Class, java.util.Locale) getBundle}(type, Locale.getDefault())</code>
-     * .
-     * 
-     * @param type
-     *            the bundle type class
-     * @param <T>
-     *            the bundle type
-     * @return the bundle
-     */
-    public static <T> T getBundle(Class<T> type)
-    {
-        return type.cast(Proxy.newProxyInstance(type.getClassLoader(),
-                new Class<?>[]
-                { type }, new MessageBundleInvocationHandler()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/NarrowingBeanBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/NarrowingBeanBuilder.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/NarrowingBeanBuilder.java
index 49096a4..a38e18f 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/NarrowingBeanBuilder.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/NarrowingBeanBuilder.java
@@ -18,7 +18,7 @@
  */
 package org.apache.deltaspike.core.impl.message;
 
-import static org.apache.deltaspike.core.impl.message.Arrays2.asSet;
+import static org.apache.deltaspike.core.impl.util.ArraysUtils.asSet;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
@@ -36,17 +36,12 @@ import javax.inject.Named;
 import org.apache.deltaspike.core.api.literal.AnyLiteral;
 import org.apache.deltaspike.core.api.literal.DefaultLiteral;
 
-/**
- * Builder for {@link ImmutableNarrowingBean} and
- * {@link ImmutablePassivationCapableNarrowingBean}.
- * 
- * @see ImmutableNarrowingBean
- * @see ImmutablePassivationCapableNarrowingBean
- */
+//X TODO update javadoc
 class NarrowingBeanBuilder<T>
 {
-    private final Bean<Object> delegate;
+    private final Bean<T> delegate;
     private final BeanManager beanManager;
+
     private Set<Type> types;
     private Set<Annotation> qualifiers;
     private String name;
@@ -60,39 +55,23 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Instantiate a new {@link NarrowingBeanBuilder}.
-     * 
-     * @param delegate
-     *            the delegate bean
+     *
+     * @param delegate    the delegate bean
+     * @param beanManager current bean-manager
      */
-    public NarrowingBeanBuilder(Bean<Object> delegate, BeanManager beanManager)
+    NarrowingBeanBuilder(Bean<Object> delegate, BeanManager beanManager)
     {
-        this.delegate = delegate;
+        this.delegate = (Bean<T>)delegate;
         this.beanManager = beanManager;
     }
 
     /**
-     * Create a new {@link NarrowingBeanBuilder}, allowing Java to infer the
-     * type <code>T</code>.
-     * 
-     * @param <T>
-     *            the type of the bean
-     * @param delegate
-     *            the delegate bean
-     */
-    public static <T> NarrowingBeanBuilder<T> of(Bean<Object> delegate,
-            BeanManager beanManager)
-    {
-        return new NarrowingBeanBuilder<T>(delegate, beanManager);
-    }
-
-    /**
      * <p>
      * Read the {@link AnnotatedType}, creating a narrowing bean from the class
      * and its annotations.
      * </p>
-     * 
-     * @param type
-     *            the type to read
+     *
+     * @param type the type to read
      */
     public NarrowingBeanBuilder<T> readFromType(AnnotatedType<T> type)
     {
@@ -101,6 +80,7 @@ class NarrowingBeanBuilder<T>
         this.stereotypes = new HashSet<Class<? extends Annotation>>();
         String name = null;
         Class<? extends Annotation> scope = Dependent.class;
+
         for (Annotation annotation : type.getAnnotations())
         {
             if (beanManager.isQualifier(annotation.annotationType()))
@@ -133,7 +113,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Type closure currently defined for bean creation.
-     * 
+     *
      * @return the type closure currently defined
      */
     public Set<Type> getTypes()
@@ -143,9 +123,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the type closure used for bean creation.
-     * 
-     * @param types
-     *            the type closure to use
+     *
+     * @param types the type closure to use
      */
     public NarrowingBeanBuilder<T> types(Set<Type> types)
     {
@@ -155,9 +134,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the type closure used for bean creation.
-     * 
-     * @param types
-     *            the type closure to use
+     *
+     * @param types the type closure to use
      */
     public NarrowingBeanBuilder<T> types(Type... types)
     {
@@ -167,9 +145,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the type closure used for bean creation.
-     * 
-     * @param type
-     *            additional type to use
+     *
+     * @param type additional type to use
      */
     public NarrowingBeanBuilder<T> addType(Type type)
     {
@@ -179,9 +156,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the type closure used for bean creation.
-     * 
-     * @param types
-     *            the additional types to use
+     *
+     * @param types the additional types to use
      */
     public NarrowingBeanBuilder<T> addTypes(Type... types)
     {
@@ -191,9 +167,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the type closure used for bean creation.
-     * 
-     * @param types
-     *            the additional types to use
+     *
+     * @param types the additional types to use
      */
     public NarrowingBeanBuilder<T> addTypes(Collection<Type> types)
     {
@@ -203,7 +178,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Qualifiers currently defined for bean creation.
-     * 
+     *
      * @return the qualifiers current defined
      */
     public Set<Annotation> getQualifiers()
@@ -213,9 +188,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the qualifiers used for bean creation.
-     * 
-     * @param qualifiers
-     *            the qualifiers to use
+     *
+     * @param qualifiers the qualifiers to use
      */
     public NarrowingBeanBuilder<T> qualifiers(Set<Annotation> qualifiers)
     {
@@ -225,9 +199,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the qualifiers used for bean creation.
-     * 
-     * @param qualifiers
-     *            the qualifiers to use
+     *
+     * @param qualifiers the qualifiers to use
      */
     public NarrowingBeanBuilder<T> qualifiers(Annotation... qualifiers)
     {
@@ -237,9 +210,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the qualifiers used for bean creation.
-     * 
-     * @param qualifiers
-     *            the additional qualifier to use
+     *
+     * @param qualifier the additional qualifier to use
      */
     public NarrowingBeanBuilder<T> addQualifier(Annotation qualifier)
     {
@@ -249,9 +221,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the qualifiers used for bean creation.
-     * 
-     * @param qualifiers
-     *            the additional qualifiers to use
+     *
+     * @param qualifiers the additional qualifiers to use
      */
     public NarrowingBeanBuilder<T> addQualifiers(Annotation... qualifiers)
     {
@@ -261,9 +232,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Add to the qualifiers used for bean creation.
-     * 
-     * @param qualifiers
-     *            the additional qualifiers to use
+     *
+     * @param qualifiers the additional qualifiers to use
      */
     public NarrowingBeanBuilder<T> addQualifiers(
             Collection<Annotation> qualifiers)
@@ -274,7 +244,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * The name of the bean currently defined for bean creation.
-     * 
+     *
      * @return the name of the bean or <code>null</code> if the bean has no name
      */
     public String getName()
@@ -284,10 +254,9 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the name of the bean used for bean creation.
-     * 
-     * @param name
-     *            the name of the bean to use or <code>null</code> if the bean
-     *            should have no name
+     *
+     * @param name the name of the bean to use or <code>null</code> if the bean
+     *             should have no name
      */
     public NarrowingBeanBuilder<T> name(String name)
     {
@@ -297,7 +266,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Scope currently defined for bean creation.
-     * 
+     *
      * @return the scope currently defined
      */
     public Class<? extends Annotation> getScope()
@@ -307,9 +276,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the scope used for bean creation.
-     * 
-     * @param scope
-     *            the scope to use
+     *
+     * @param scope the scope to use
      */
     public NarrowingBeanBuilder<T> scope(Class<? extends Annotation> scope)
     {
@@ -319,7 +287,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Whether the created bean will be an alternative.
-     * 
+     *
      * @return <code>true</code> if the created bean will be an alternative,
      *         otherwise <code>false</code>
      */
@@ -330,10 +298,9 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define that the created bean will (or will not) be an alternative.
-     * 
-     * @param alternative
-     *            <code>true</code> if the created bean should be an
-     *            alternative, otherwise <code>false</code>
+     *
+     * @param alternative <code>true</code> if the created bean should be an
+     *                    alternative, otherwise <code>false</code>
      */
     public NarrowingBeanBuilder<T> alternative(boolean alternative)
     {
@@ -343,7 +310,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Stereotypes currently defined for bean creation.
-     * 
+     *
      * @return the stereotypes currently defined
      */
     public Set<Class<? extends Annotation>> getStereotypes()
@@ -353,9 +320,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the stereotypes used for bean creation.
-     * 
-     * @param stereotypes
-     *            the stereotypes to use
+     *
+     * @param stereotypes the stereotypes to use
      */
     public NarrowingBeanBuilder<T> stereotypes(
             Set<Class<? extends Annotation>> stereotypes)
@@ -368,10 +334,10 @@ class NarrowingBeanBuilder<T>
      * <p>
      * Use the bean builder's current state to define the bean.
      * </p>
-     * 
+     *
      * @return the bean
      */
-    public ImmutableNarrowingBean<T> create()
+    public ImmutableBeanWrapper<T> create()
     {
         // Commented out due to it not being required for initial Message
         // implementation
@@ -380,7 +346,7 @@ class NarrowingBeanBuilder<T>
         // name, qualifiers, scope, stereotypes, types, alternative,
         // nullable, toString, id);
         // } else {
-        return new ImmutableNarrowingBean<T>(delegate, name, qualifiers, scope,
+        return new ImmutableBeanWrapper<T>(delegate, name, qualifiers, scope,
                 stereotypes, types, alternative, nullable, toString);
     }
 
@@ -388,7 +354,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * The string used when {@link #toString()} is called on the bean.
-     * 
+     *
      * @return the string currently defined
      */
     public String getToString()
@@ -398,9 +364,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the string used when {@link #toString()} is called on the bean.
-     * 
-     * @param toString
-     *            the string to use
+     *
+     * @param toString the string to use
      */
     public NarrowingBeanBuilder<T> toString(String toString)
     {
@@ -410,7 +375,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Whether the created bean will be nullable.
-     * 
+     *
      * @return <code>true</code> if the created bean will be nullable, otherwise
      *         <code>false</code>
      */
@@ -421,10 +386,9 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define that the created bean will (or will not) be nullable.
-     * 
-     * @param nullable
-     *            <code>true</code> if the created bean should be nullable,
-     *            otherwise <code>false</code>
+     *
+     * @param nullable <code>true</code> if the created bean should be nullable,
+     *                 otherwise <code>false</code>
      */
     public NarrowingBeanBuilder<T> nullable(boolean nullable)
     {
@@ -434,7 +398,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Whether the created bean will be passivation capable.
-     * 
+     *
      * @return <code>true</code> if the created bean will be passivation
      *         capable, otherwise <code>false</code>
      */
@@ -445,10 +409,9 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define that the created bean will (or will not) be passivation capable.
-     * 
-     * @param nullable
-     *            <code>true</code> if the created bean should be passivation
-     *            capable, otherwise <code>false</code>
+     *
+     * @param passivationCapable <code>true</code> if the created bean should be passivation
+     *                           capable, otherwise <code>false</code>
      */
     public NarrowingBeanBuilder<T> passivationCapable(boolean passivationCapable)
     {
@@ -458,7 +421,7 @@ class NarrowingBeanBuilder<T>
 
     /**
      * The id currently defined for bean creation.
-     * 
+     *
      * @return the id currently defined.
      */
     public String getId()
@@ -468,9 +431,8 @@ class NarrowingBeanBuilder<T>
 
     /**
      * Define the id used for bean creation.
-     * 
-     * @param id
-     *            the id to use
+     *
+     * @param id the id to use
      */
     public NarrowingBeanBuilder<T> id(String id)
     {

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ProxyUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ProxyUtils.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ProxyUtils.java
new file mode 100644
index 0000000..9fb8865
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/ProxyUtils.java
@@ -0,0 +1,47 @@
+/*
+ * 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.impl.message;
+
+import org.apache.deltaspike.core.util.ClassUtils;
+
+import javax.enterprise.inject.Typed;
+import java.lang.reflect.Proxy;
+
+/**
+ * A factory class to produce message bundle implementations.
+ */
+@Typed()
+abstract class ProxyUtils
+{
+    private ProxyUtils()
+    {
+        // prevent instantiation
+    }
+
+    /**
+     * @param type the bundle type class
+     * @param <T>  the bundle type
+     * @return the bundle
+     */
+    static <T> T createMessageBundleProxy(Class<T> type)
+    {
+        return type.cast(Proxy.newProxyInstance(
+            ClassUtils.getClassLoader(null), new Class<?>[]{type}, new MessageBundleInvocationHandler()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/TypedMessageBundleProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/TypedMessageBundleProducer.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/TypedMessageBundleProducer.java
index b0e16a8..7ddf199 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/TypedMessageBundleProducer.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/TypedMessageBundleProducer.java
@@ -18,7 +18,7 @@
  */
 package org.apache.deltaspike.core.impl.message;
 
-import static org.apache.deltaspike.core.impl.message.MessageFactory.getBundle;
+import static org.apache.deltaspike.core.impl.message.ProxyUtils.createMessageBundleProxy;
 import static org.apache.deltaspike.core.util.ReflectionUtils.getRawType;
 
 import java.io.Serializable;
@@ -36,9 +36,9 @@ class TypedMessageBundleProducer implements Serializable
 
     @Produces
     @TypedMessageBundle
+    @SuppressWarnings("UnusedDeclaration")
     Object produceTypedMessageBundle(InjectionPoint injectionPoint)
     {
-        return getBundle(getRawType(injectionPoint.getType()));
+        return createMessageBundleProxy(getRawType(injectionPoint.getType()));
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ArraysUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ArraysUtils.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ArraysUtils.java
new file mode 100644
index 0000000..9e10f93
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ArraysUtils.java
@@ -0,0 +1,56 @@
+/*
+ * 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.impl.util;
+
+import javax.enterprise.inject.Typed;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A collection of utilities for working with Arrays that goes beyond that in
+ * the JDK.
+ */
+@Typed()
+public abstract class ArraysUtils
+{
+    private ArraysUtils()
+    {
+        // prevent instantiation
+    }
+
+    /**
+     * Create a set from an array. If the array contains duplicate objects, the
+     * last object in the array will be placed in resultant set.
+     * 
+     * @param <T>
+     *            the type of the objects in the set
+     * @param array
+     *            the array from which to create the set
+     * @return the created sets
+     */
+    public static <T> Set<T> asSet(T... array)
+    {
+        Set<T> result = new HashSet<T>();
+        for (T a : array)
+        {
+            result.add(a);
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/BirdMessages.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/BirdMessages.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/BirdMessages.java
index 8248933..55cc56b 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/BirdMessages.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/BirdMessages.java
@@ -22,7 +22,8 @@ import org.apache.deltaspike.core.api.message.Message;
 import org.apache.deltaspike.core.api.message.MessageBundle;
 
 @MessageBundle
-public interface BirdMessages {
-	@Message("Spotted %s jays")
-	String numberOfJaysSpotted(int number);
+public interface BirdMessages
+{
+    @Message("Spotted %s jays")
+    String numberOfJaysSpotted(int number);
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/Jay.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/Jay.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/Jay.java
index 3dabbcb..7f23560 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/Jay.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/Jay.java
@@ -22,14 +22,15 @@ import javax.inject.Inject;
 
 import org.apache.deltaspike.core.api.message.MessageBundle;
 
-public class Jay {
+public class Jay
+{
+    @Inject
+    @MessageBundle
+    private BirdMessages messages;
 
-	@Inject
-	@MessageBundle
-	BirdMessages messages;
-
-	String getMessage() {
-		return messages.numberOfJaysSpotted(8);
-	}
+    String getMessage()
+    {
+        return messages.numberOfJaysSpotted(8);
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/84ce6792/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageTest.java
index 85e2326..64419f0 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/MessageTest.java
@@ -40,39 +40,39 @@ import org.junit.runner.RunWith;
 @RunWith(Arquillian.class)
 public class MessageTest
 {
-	/**
-	 * X TODO creating a WebArchive is only a workaround because JavaArchive
-	 * cannot contain other archives.
-	 */
+    /**
+     * X TODO creating a WebArchive is only a workaround because JavaArchive
+     * cannot contain other archives.
+     */
     @Deployment
     public static WebArchive deploy()
     {
         new BeanManagerProvider()
         {
-			@Override
-			public void setTestMode()
-			{
-				super.setTestMode();
-			}
-		}.setTestMode();
+            @Override
+            public void setTestMode()
+            {
+                super.setTestMode();
+            }
+        }.setTestMode();
 
-		JavaArchive testJar = ShrinkWrap
-				.create(JavaArchive.class, "messageTest.jar")
-				.addPackage("org.apache.deltaspike.test.core.api.message")
-				.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+        JavaArchive testJar = ShrinkWrap
+                .create(JavaArchive.class, "messageTest.jar")
+                .addPackage("org.apache.deltaspike.test.core.api.message")
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
 
-		return ShrinkWrap
-				.create(WebArchive.class, "messageTest.war")
-				.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
-				.addAsLibraries(testJar)
-				.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
-				.addAsServiceProvider(Extension.class,
-						MessageBundleExtension.class);
-	}
+        return ShrinkWrap
+                .create(WebArchive.class, "messageTest.war")
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+                .addAsLibraries(testJar)
+                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+                .addAsServiceProvider(Extension.class,
+                        MessageBundleExtension.class);
+    }
 
     @Test
     public void testMessageBundleInjection(Jay jay)
-	{
+    {
         assertEquals("Spotted 8 jays", jay.getMessage());
     }
 }