You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by ra...@apache.org on 2015/05/04 17:56:58 UTC

[1/2] deltaspike git commit: DELTASPIKE-882 - Create a new module for Proxy API

Repository: deltaspike
Updated Branches:
  refs/heads/master 625e784fc -> d7210631b


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/InterceptManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/InterceptManualInvocationHandler.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/InterceptManualInvocationHandler.java
new file mode 100644
index 0000000..03e2a0d
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/InterceptManualInvocationHandler.java
@@ -0,0 +1,52 @@
+/*
+ * 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.proxy.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.Typed;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxyFactory;
+
+@Typed
+public class InterceptManualInvocationHandler extends AbstractManualInvocationHandler
+{
+    private static final InterceptManualInvocationHandler INSTANCE = new InterceptManualInvocationHandler();
+    
+    public static Object staticInvoke(Object proxy, Method method, Object[] parameters) throws Throwable
+    {
+        return INSTANCE.invoke(proxy, method, parameters);
+    }
+    
+    @Override
+    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable
+    {
+        try
+        {
+            Method superAccessorMethod = DeltaSpikeProxyFactory.getSuperAccessorMethod(proxy, method);
+            return superAccessorMethod.invoke(proxy, parameters);
+        }
+        catch (InvocationTargetException e)
+        {
+            // rethrow original exception
+            throw e.getCause();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationContext.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationContext.java
new file mode 100644
index 0000000..793e242
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationContext.java
@@ -0,0 +1,187 @@
+/*
+ * 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.proxy.invocation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.interceptor.InvocationContext;
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+
+@Typed
+public class ManualInvocationContext<T, H> implements InvocationContext
+{
+    protected List<Interceptor<H>> interceptors;
+    protected int interceptorIndex;
+    protected T target;
+    protected Method method;
+    protected Object[] parameters;
+    protected Map<String, Object> contextData;
+    protected Object timer;
+    protected AbstractManualInvocationHandler manualInvocationHandler;
+
+    protected BeanManager beanManager;
+
+    protected boolean proceedOriginal;
+    protected Object proceedOriginalReturnValue;
+
+    public ManualInvocationContext(AbstractManualInvocationHandler manualInvocationHandler,
+            List<Interceptor<H>> interceptors, T target, Method method, Object[] parameters, Object timer)
+    {
+        this.manualInvocationHandler = manualInvocationHandler;
+        this.interceptors = interceptors;
+        this.target = target;
+        this.method = method;
+        this.parameters = parameters;
+        this.timer = timer;
+
+        this.interceptorIndex = 0;
+    }
+
+    @Override
+    public Object getTarget()
+    {
+        return target;
+    }
+
+    @Override
+    public Method getMethod()
+    {
+        return method;
+    }
+
+    @Override
+    public Object[] getParameters()
+    {
+        return parameters;
+    }
+
+    @Override
+    public void setParameters(Object[] os)
+    {
+        parameters = os;
+    }
+
+    @Override
+    public Map<String, Object> getContextData()
+    {
+        if (contextData == null)
+        {
+            contextData = new HashMap<String, Object>();
+        }
+        return contextData;
+    }
+
+    @Override
+    public Object proceed() throws Exception
+    {
+        if (proceedOriginal)
+        {
+            return null;
+        }
+
+        if (interceptors.size() > interceptorIndex)
+        {
+            Interceptor<H> interceptor = null;
+            CreationalContext<H> creationalContext = null;
+            H interceptorInstance = null;
+
+            try
+            {
+                // lazy init beanManager
+                if (beanManager == null)
+                {
+                    beanManager = BeanManagerProvider.getInstance().getBeanManager();
+                }
+
+                interceptor = interceptors.get(interceptorIndex++);
+                creationalContext = beanManager.createCreationalContext(interceptor);
+                interceptorInstance = interceptor.create(creationalContext);
+
+                return interceptor.intercept(InterceptionType.AROUND_INVOKE, interceptorInstance, this);
+            }
+            finally
+            {
+                if (creationalContext != null)
+                {
+                    if (interceptorInstance != null && interceptor != null)
+                    {
+                        interceptor.destroy(interceptorInstance, creationalContext);
+                    }
+
+                    creationalContext.release();
+                }
+            }
+        }
+
+
+        // workaround for OWB 1.1, otherwise we could just return the proceedOriginalReturnValue here
+        try
+        {
+            proceedOriginal = true;
+            proceedOriginalReturnValue = manualInvocationHandler.proceedOriginal(target, method, parameters);
+        }
+        catch (Exception e)
+        {
+            throw e;
+        }
+        catch (Throwable e)
+        {
+            // wrap the Throwable here as interceptors declared only "throws Exception"
+            throw new ManualInvocationThrowableWrapperException(e);
+        }
+
+        return null;
+    }
+
+    @Override
+    public Object getTimer()
+    {
+        return timer;
+    }
+
+    // @Override
+    // CDI 1.1 compatibility
+    public Constructor getConstructor()
+    {
+        return null;
+    }
+
+    public boolean isProceedOriginal()
+    {
+        return proceedOriginal;
+    }
+
+    public Object getProceedOriginalReturnValue()
+    {
+        return proceedOriginalReturnValue;
+    }
+
+    public void setProceedOriginalReturnValue(Object proceedOriginalReturnValue)
+    {
+        this.proceedOriginalReturnValue = proceedOriginalReturnValue;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationThrowableWrapperException.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationThrowableWrapperException.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationThrowableWrapperException.java
new file mode 100644
index 0000000..4c3b8be
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/ManualInvocationThrowableWrapperException.java
@@ -0,0 +1,27 @@
+/*
+ * 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.proxy.invocation;
+
+public class ManualInvocationThrowableWrapperException extends Exception
+{
+    public ManualInvocationThrowableWrapperException(Throwable e)
+    {
+        super(e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/AsmProxyClassGenerator.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/AsmProxyClassGenerator.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/AsmProxyClassGenerator.java
new file mode 100644
index 0000000..437ec8f
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/AsmProxyClassGenerator.java
@@ -0,0 +1,470 @@
+/*
+ * 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.proxy.util;
+
+import org.apache.deltaspike.proxy.invocation.DelegateManualInvocationHandler;
+import org.apache.deltaspike.proxy.invocation.InterceptManualInvocationHandler;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import javax.enterprise.inject.Typed;
+
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.commons.GeneratorAdapter;
+import org.objectweb.asm.commons.Method;
+
+@Typed
+public abstract class AsmProxyClassGenerator
+{
+    private static final String FIELDNAME_DELEGATE_INVOCATION_HANDLER = "delegateInvocationHandler";
+
+    private static final Type TYPE_CLASS = Type.getType(Class.class);
+    private static final Type TYPE_OBJECT = Type.getType(Object.class);
+
+    private AsmProxyClassGenerator()
+    {
+        // prevent instantiation
+    }
+
+    public static <T> Class<T> generateProxyClass(ClassLoader classLoader,
+            Class<T> targetClass,
+            Class<? extends InvocationHandler> invocationHandlerClass,
+            String suffix,
+            String superAccessorMethodSuffix,
+            Class<?>[] additionalInterfaces,
+            java.lang.reflect.Method[] delegateMethods,
+            java.lang.reflect.Method[] interceptMethods)
+    {
+        String proxyName = targetClass.getCanonicalName() + suffix;
+        String classFileName = proxyName.replace('.', '/');
+
+        byte[] proxyBytes = generateProxyClassBytes(targetClass, invocationHandlerClass,
+                classFileName, superAccessorMethodSuffix, additionalInterfaces, delegateMethods, interceptMethods);
+
+        Class<T> proxyClass = (Class<T>) loadClass(classLoader, proxyName, proxyBytes,
+                targetClass.getProtectionDomain());
+
+        return proxyClass;
+    }
+
+    private static byte[] generateProxyClassBytes(Class<?> targetClass,
+            Class<? extends InvocationHandler> invocationHandlerClass,
+            String proxyName,
+            String superAccessorMethodSuffix,
+            Class<?>[] additionalInterfaces,
+            java.lang.reflect.Method[] delegateMethods,
+            java.lang.reflect.Method[] interceptMethods)
+    {
+        Class<?> superClass = targetClass;
+        String[] interfaces = new String[] { };
+
+        if (targetClass.isInterface())
+        {
+            superClass = Object.class;
+            interfaces = new String[] { Type.getInternalName(targetClass) };
+        }
+
+        // add DeltaSpikeProxy as interface
+        interfaces = Arrays.copyOf(interfaces, interfaces.length + 1);
+        interfaces[interfaces.length - 1] = Type.getInternalName(DeltaSpikeProxy.class);
+
+        if (additionalInterfaces != null && additionalInterfaces.length > 0)
+        {
+            interfaces = Arrays.copyOf(interfaces, interfaces.length + additionalInterfaces.length);
+            for (int i = 0; i < additionalInterfaces.length; i++)
+            {
+                interfaces[(interfaces.length - 1) + i] = Type.getInternalName(additionalInterfaces[i]);
+            }
+        }
+
+        Type superType = Type.getType(superClass);
+        Type proxyType = Type.getObjectType(proxyName);
+        Type invocationHandlerType = Type.getType(invocationHandlerClass);
+
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+        cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, proxyType.getInternalName(), null,
+                superType.getInternalName(), interfaces);
+
+        // copy annotations
+        for (Annotation annotation : targetClass.getDeclaredAnnotations())
+        {
+            cw.visitAnnotation(Type.getDescriptor(annotation.annotationType()), true).visitEnd();
+        }
+
+        defineInvocationHandlerField(cw, invocationHandlerType);
+        defineDefaultConstructor(cw, proxyType, superType);
+        defineDelegateInvocationHandlerConstructor(cw, proxyType, superType, invocationHandlerType);
+        defineDeltaSpikeProxyMethods(cw, proxyType, invocationHandlerType);
+
+        for (java.lang.reflect.Method method : delegateMethods)
+        {
+            defineMethod(cw, method, DelegateManualInvocationHandler.class);
+        }
+
+        for (java.lang.reflect.Method method : interceptMethods)
+        {
+            defineSuperAccessorMethod(cw, method, superType, superAccessorMethodSuffix);
+            defineMethod(cw, method, InterceptManualInvocationHandler.class);
+        }
+
+        return cw.toByteArray();
+    }
+
+    private static void defineInvocationHandlerField(ClassWriter cw, Type invocationHandlerType)
+    {
+        // generates
+        // private MyInvocationHandler delegateInvocationHandler;
+        cw.visitField(Opcodes.ACC_PRIVATE, FIELDNAME_DELEGATE_INVOCATION_HANDLER,
+                invocationHandlerType.getDescriptor(), null, null).visitEnd();
+    }
+
+    private static void defineDefaultConstructor(ClassWriter cw, Type proxyType, Type superType)
+    {
+        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
+                new Method("<init>", Type.VOID_TYPE, new Type[]{ }),
+                null,
+                null,
+                cw);
+
+        mg.visitCode();
+
+        // invoke super constructor
+        mg.loadThis();
+        mg.invokeConstructor(superType, Method.getMethod("void <init> ()"));
+        mg.returnValue();
+        mg.endMethod();
+
+        mg.visitEnd();
+    }
+    
+    private static void defineDelegateInvocationHandlerConstructor(ClassWriter cw, Type proxyType, Type superType,
+            Type invocationHandlerType)
+    {
+        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
+                new Method("<init>", Type.VOID_TYPE, new Type[] { invocationHandlerType }),
+                null,
+                null,
+                cw);
+
+        mg.visitCode();
+
+        // invoke super constructor
+        mg.loadThis();
+        mg.invokeConstructor(superType, Method.getMethod("void <init> ()"));
+        
+        // set invocation handler
+        mg.loadThis();
+        mg.loadArg(0);
+        mg.putField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
+        
+        mg.returnValue();
+        mg.endMethod();
+
+        mg.visitEnd();
+    }
+
+    private static void defineDeltaSpikeProxyMethods(ClassWriter cw, Type proxyType, Type invocationHandlerType)
+    {
+        try
+        {
+            // implement #setDelegateInvocationHandler
+            Method asmMethod = Method.getMethod(DeltaSpikeProxy.class.getDeclaredMethod(
+                    "setDelegateInvocationHandler", InvocationHandler.class));
+            GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, asmMethod, null, null, cw);
+
+            mg.visitCode();
+
+            mg.loadThis();
+            mg.loadArg(0);
+            mg.checkCast(invocationHandlerType);
+            mg.putField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
+            mg.returnValue();
+
+            mg.visitMaxs(2, 1);
+            mg.visitEnd();
+
+
+            // implement #getDelegateInvocationHandler
+            asmMethod = Method.getMethod(DeltaSpikeProxy.class.getDeclaredMethod("getDelegateInvocationHandler"));
+            mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, asmMethod, null, null, cw);
+
+            mg.visitCode();
+
+            mg.loadThis();
+            mg.getField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
+            mg.returnValue();
+
+            mg.visitMaxs(2, 1);
+            mg.visitEnd();
+        }
+        catch (NoSuchMethodException e)
+        {
+            throw new IllegalStateException("Unable to implement " + DeltaSpikeProxy.class.getName(), e);
+        }
+    }
+
+    private static void defineSuperAccessorMethod(ClassWriter cw, java.lang.reflect.Method method, Type superType,
+            String superAccessorMethodSuffix) 
+    {
+        Method originalAsmMethod = Method.getMethod(method);
+        Method newAsmMethod = new Method(method.getName() + superAccessorMethodSuffix,
+                originalAsmMethod.getReturnType(),
+                originalAsmMethod.getArgumentTypes());
+        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, newAsmMethod, null, null, cw);
+        
+        mg.visitCode();
+        
+        // call super method
+        mg.loadThis();
+        mg.loadArgs();
+        mg.visitMethodInsn(Opcodes.INVOKESPECIAL,
+                superType.getInternalName(),
+                method.getName(),
+                Type.getMethodDescriptor(method),
+                false);
+        mg.returnValue();
+        
+        // finish the method
+        mg.endMethod();
+        mg.visitMaxs(10, 10);
+        mg.visitEnd();
+    }
+    
+    private static void defineMethod(ClassWriter cw, java.lang.reflect.Method method,
+            Class manualInvocationHandlerClass)
+    {
+        Type methodType = Type.getType(method);
+        
+        ArrayList<Type> exceptionsToCatch = new ArrayList<Type>();
+        for (Class<?> exception : method.getExceptionTypes())
+        {
+            if (!RuntimeException.class.isAssignableFrom(exception))
+            {
+                exceptionsToCatch.add(Type.getType(exception));
+            }
+        }
+        
+        // push the method definition
+        int modifiers = (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED) & method.getModifiers();
+        Method asmMethod = Method.getMethod(method);
+        GeneratorAdapter mg = new GeneratorAdapter(modifiers,
+                asmMethod,
+                null,
+                getTypes(method.getExceptionTypes()),
+                cw);
+
+        // copy annotations
+        for (Annotation annotation : method.getDeclaredAnnotations())
+        {
+            mg.visitAnnotation(Type.getDescriptor(annotation.annotationType()), true).visitEnd();
+        }
+
+        mg.visitCode();
+
+        Label tryBlockStart = mg.mark();
+
+        mg.loadThis();
+        loadCurrentMethod(mg, method, methodType);
+        loadArguments(mg, method, methodType);
+        
+        // invoke our ProxyInvocationHandler
+        mg.invokeStatic(Type.getType(manualInvocationHandlerClass),
+                Method.getMethod("Object staticInvoke(Object, java.lang.reflect.Method, Object[])"));
+
+        // cast the result
+        mg.unbox(methodType.getReturnType());
+
+        // build try catch
+        Label tryBlockEnd = mg.mark();
+        
+        // push return
+        mg.returnValue();
+
+        // catch runtime exceptions and rethrow it
+        Label rethrow = mg.mark();
+        mg.visitVarInsn(Opcodes.ASTORE, 1);
+        mg.visitVarInsn(Opcodes.ALOAD, 1);
+        mg.throwException();
+        mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, rethrow, Type.getInternalName(RuntimeException.class));
+
+        // catch checked exceptions and rethrow it
+        boolean throwableCatched = false;
+        if (exceptionsToCatch.size() > 0)
+        {
+            rethrow = mg.mark();
+            mg.visitVarInsn(Opcodes.ASTORE, 1);
+            mg.visitVarInsn(Opcodes.ALOAD, 1);
+            mg.throwException();
+
+            // catch declared exceptions and rethrow it...
+            for (Type exceptionType : exceptionsToCatch)
+            {
+                if (exceptionType.getClassName().equals(Throwable.class.getName()))
+                {
+                    throwableCatched = true;
+                }
+                mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, rethrow, exceptionType.getInternalName());
+            }
+        }
+
+        // if throwable isn't alreached cachted, catch it and wrap it with an UndeclaredThrowableException and throw it
+        if (!throwableCatched)
+        {
+            Type uteType = Type.getType(UndeclaredThrowableException.class);
+            Label wrapAndRethrow = mg.mark();
+
+            mg.visitVarInsn(Opcodes.ASTORE, 1);
+            mg.newInstance(uteType);
+            mg.dup();
+            mg.visitVarInsn(Opcodes.ALOAD, 1);
+            mg.invokeConstructor(uteType,
+                    Method.getMethod("void <init>(java.lang.Throwable)"));
+            mg.throwException();
+
+            mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, wrapAndRethrow, Type.getInternalName(Throwable.class));
+        }
+
+        // finish the method
+        mg.endMethod();
+        mg.visitMaxs(10, 10);
+        mg.visitEnd();
+    }
+
+    /**
+     * Generates:
+     * <pre>
+     * Method method =
+     *      method.getDeclaringClass().getMethod("methodName", new Class[] { args... });
+     * </pre>
+     * @param mg
+     * @param method
+     * @param methodType
+     */
+    private static void loadCurrentMethod(GeneratorAdapter mg, java.lang.reflect.Method method, Type methodType)
+    {
+        mg.push(Type.getType(method.getDeclaringClass()));
+        mg.push(method.getName());
+
+        // create the Class[]
+        mg.push(methodType.getArgumentTypes().length);
+        mg.newArray(TYPE_CLASS);
+
+        // push parameters into array
+        for (int i = 0; i < methodType.getArgumentTypes().length; i++)
+        {
+            // keep copy of array on stack
+            mg.dup();
+
+            // push index onto stack
+            mg.push(i);
+            mg.push(methodType.getArgumentTypes()[i]);
+            mg.arrayStore(TYPE_CLASS);
+        }
+
+        // invoke getMethod() with the method name and the array of types
+        mg.invokeVirtual(TYPE_CLASS, Method.getMethod("java.lang.reflect.Method getDeclaredMethod(String, Class[])"));
+    }
+
+    /**
+     * Defines a new Object[] and push all method argmuments into the array.
+     *
+     * @param mg
+     * @param method
+     * @param methodType
+     */
+    private static void loadArguments(GeneratorAdapter mg, java.lang.reflect.Method method, Type methodType)
+    {
+        // create the Object[]
+        mg.push(methodType.getArgumentTypes().length);
+        mg.newArray(TYPE_OBJECT);
+
+        // push parameters into array
+        for (int i = 0; i < methodType.getArgumentTypes().length; i++)
+        {
+            // keep copy of array on stack
+            mg.dup();
+
+            // push index onto stack
+            mg.push(i);
+
+            mg.loadArg(i);
+            mg.valueOf(methodType.getArgumentTypes()[i]);
+            mg.arrayStore(TYPE_OBJECT);
+        }
+    }
+
+    private static Type[] getTypes(Class<?>... src)
+    {
+        Type[] result = new Type[src.length];
+        for (int i = 0; i < result.length; i++)
+        {
+            result[i] = Type.getType(src[i]);
+        }
+        return result;
+    }
+
+    /**
+     * Adapted from http://asm.ow2.org/doc/faq.html#Q5
+     *
+     * @param b
+     *
+     * @return Class<?>
+     */
+    private static Class<?> loadClass(ClassLoader loader, String className, byte[] b,
+            ProtectionDomain protectionDomain)
+    {
+        // override classDefine (as it is protected) and define the class.
+        try
+        {
+            java.lang.reflect.Method method = ClassLoader.class.getDeclaredMethod(
+                    "defineClass", String.class, byte[].class, int.class, int.class, ProtectionDomain.class);
+
+            // protected method invocation
+            boolean accessible = method.isAccessible();
+            if (!accessible)
+            {
+                method.setAccessible(true);
+            }
+            try
+            {
+                return (Class<?>) method.invoke(loader, className, b, Integer.valueOf(0), Integer.valueOf(b.length),
+                        protectionDomain);
+            }
+            finally
+            {
+                if (!accessible)
+                {
+                    method.setAccessible(false);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw e instanceof RuntimeException ? ((RuntimeException) e) : new RuntimeException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxy.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxy.java
new file mode 100644
index 0000000..8dbc54c
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxy.java
@@ -0,0 +1,28 @@
+/*
+ * 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.proxy.util;
+
+import java.lang.reflect.InvocationHandler;
+
+public interface DeltaSpikeProxy
+{
+    void setDelegateInvocationHandler(InvocationHandler redirectInvocationHandler);
+
+    InvocationHandler getDelegateInvocationHandler();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyContextualLifecycle.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyContextualLifecycle.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyContextualLifecycle.java
new file mode 100644
index 0000000..93daf78
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyContextualLifecycle.java
@@ -0,0 +1,150 @@
+/*
+ * 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.proxy.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.util.Set;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.PassivationCapable;
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.util.ExceptionUtils;
+import org.apache.deltaspike.core.util.metadata.builder.ContextualLifecycle;
+
+public class DeltaSpikeProxyContextualLifecycle<T, H extends InvocationHandler> implements ContextualLifecycle<T>
+{
+    private final Class<T> proxyClass;
+    private final Class<H> delegateInvocationHandlerClass;
+    private final Class<T> targetClass;
+    
+    private InjectionTarget<T> injectionTarget;
+    private CreationalContext<?> creationalContextOfDependentHandler;
+
+    public DeltaSpikeProxyContextualLifecycle(Class<T> targetClass, Class<H> delegateInvocationHandlerClass,
+            DeltaSpikeProxyFactory proxyFactory, BeanManager beanManager)
+    {
+        this.targetClass = targetClass;
+        this.delegateInvocationHandlerClass = delegateInvocationHandlerClass;
+        this.proxyClass = proxyFactory.getProxyClass(targetClass, delegateInvocationHandlerClass);
+
+        if (!targetClass.isInterface())
+        {
+            AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(this.targetClass);
+            this.injectionTarget = beanManager.createInjectionTarget(annotatedType);
+        }
+    }
+
+    @Override
+    public T create(Bean bean, CreationalContext creationalContext)
+    {
+        try
+        {
+            T instance;
+
+            if (delegateInvocationHandlerClass == null)
+            {
+                instance = proxyClass.newInstance();
+            }
+            else
+            {
+                H delegateInvocationHandler = instantiateDelegateInvocationHandler();
+                Constructor<T> constructor = proxyClass.getConstructor(delegateInvocationHandlerClass);
+                instance = constructor.newInstance(delegateInvocationHandler);
+            }
+
+            if (this.injectionTarget != null)
+            {
+                this.injectionTarget.inject(instance, creationalContext);
+                this.injectionTarget.postConstruct(instance);
+            }
+
+            return instance;
+        }
+        catch (Exception e)
+        {
+            ExceptionUtils.throwAsRuntimeException(e);
+        }
+
+        // can't happen
+        return null;
+    }
+
+    @Override
+    public void destroy(Bean<T> bean, T instance, CreationalContext<T> creationalContext)
+    {
+        if (this.injectionTarget != null)
+        {
+            this.injectionTarget.preDestroy(instance);
+        }
+        
+        if (this.creationalContextOfDependentHandler != null)
+        {
+            this.creationalContextOfDependentHandler.release();
+        }
+
+        creationalContext.release();
+    }
+    
+    protected H instantiateDelegateInvocationHandler()
+    {
+        Set<Bean<H>> handlerBeans = BeanProvider.getBeanDefinitions(this.delegateInvocationHandlerClass, false, true);
+        
+        if (handlerBeans.size() != 1)
+        {
+            StringBuilder beanInfo = new StringBuilder();
+            for (Bean<H> bean : handlerBeans)
+            {
+                if (beanInfo.length() != 0)
+                {
+                    beanInfo.append(", ");
+                }
+                beanInfo.append(bean);
+
+                if (bean instanceof PassivationCapable)
+                {
+                    beanInfo.append(" bean-id: ").append(((PassivationCapable)bean).getId());
+                }
+            }
+
+            throw new IllegalStateException(handlerBeans.size() + " beans found for "
+                    + this.delegateInvocationHandlerClass + " found beans: " + beanInfo.toString());
+        }
+
+        Bean<H> handlerBean = handlerBeans.iterator().next();
+        
+        BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
+        CreationalContext<?> creationalContext = beanManager.createCreationalContext(handlerBean);
+        
+        H handlerInstance = (H) beanManager.getReference(handlerBean,
+                this.delegateInvocationHandlerClass, creationalContext);
+        
+        if (handlerBean.getScope().equals(Dependent.class))
+        {
+            this.creationalContextOfDependentHandler = creationalContext;
+        }
+
+        return handlerInstance;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyFactory.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyFactory.java
new file mode 100644
index 0000000..fa9b1f4
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/util/DeltaSpikeProxyFactory.java
@@ -0,0 +1,274 @@
+/*
+ * 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.proxy.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import javax.interceptor.InterceptorBinding;
+import org.apache.deltaspike.core.util.ClassUtils;
+
+public abstract class DeltaSpikeProxyFactory
+{
+    private static final String SUPER_ACCESSOR_METHOD_SUFFIX = "$super";
+    
+    public <T> Class<T> getProxyClass(Class<T> targetClass,
+            Class<? extends InvocationHandler> invocationHandlerClass)
+    {
+        Class<T> proxyClass = ClassUtils.tryToLoadClassForName(constructProxyClassName(targetClass), targetClass);
+        if (proxyClass == null)
+        {
+            proxyClass = createProxyClass(targetClass.getClassLoader(), targetClass, invocationHandlerClass);
+        }
+
+        return proxyClass;
+    }
+
+    private synchronized <T> Class<T> createProxyClass(ClassLoader classLoader, Class<T> targetClass,
+            Class<? extends InvocationHandler> invocationHandlerClass)
+    {
+        Class<T> proxyClass = ClassUtils.tryToLoadClassForName(constructProxyClassName(targetClass), targetClass);
+        if (proxyClass == null)
+        {
+            ArrayList<Method> allMethods = collectAllMethods(targetClass);
+            ArrayList<Method> interceptMethods = filterInterceptMethods(targetClass, allMethods);
+            ArrayList<Method> delegateMethods = getDelegateMethods(targetClass, allMethods);
+
+            // check if a interceptor is defined on class level. if not, skip interceptor methods
+            if (delegateMethods != null
+                    && interceptMethods.size() > 0
+                    && !containsInterceptorBinding(targetClass.getDeclaredAnnotations()))
+            {
+                // loop every method and check if a interceptor is defined on the method -> otherwise don't proxy
+                Iterator<Method> iterator = interceptMethods.iterator();
+                while (iterator.hasNext())
+                {
+                    Method method = iterator.next();
+                    if (!containsInterceptorBinding(method.getDeclaredAnnotations()))
+                    {
+                        iterator.remove();
+                    }
+                }
+            }
+            
+            proxyClass = AsmProxyClassGenerator.generateProxyClass(classLoader,
+                    targetClass,
+                    invocationHandlerClass,
+                    getProxyClassSuffix(),
+                    SUPER_ACCESSOR_METHOD_SUFFIX,
+                    getAdditionalInterfacesToImplement(targetClass),
+                    delegateMethods == null ? new Method[0]
+                            : delegateMethods.toArray(new Method[delegateMethods.size()]),
+                    interceptMethods == null ? new Method[0]
+                            : interceptMethods.toArray(new Method[interceptMethods.size()]));
+        }
+
+        return proxyClass;
+    }
+    
+    // TODO stereotypes
+    protected boolean containsInterceptorBinding(Annotation[] annotations)
+    {
+        for (Annotation annotation : annotations)
+        {
+            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class))
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+        
+    protected String constructProxyClassName(Class<?> clazz)
+    {
+        return clazz.getName() + getProxyClassSuffix();
+    }
+
+    protected static String constructSuperAccessorMethodName(Method method)
+    {
+        return method.getName() + SUPER_ACCESSOR_METHOD_SUFFIX;
+    }
+    
+    public static Method getSuperAccessorMethod(Object proxy, Method method) throws NoSuchMethodException
+    {
+        return proxy.getClass().getMethod(
+                constructSuperAccessorMethodName(method),
+                method.getParameterTypes());
+    }
+    
+    /**
+     * Checks if the given class is DS proxy class.
+     *
+     * @param clazz
+     * @return
+     */
+    public boolean isProxyClass(Class<?> clazz)
+    {
+        return clazz.getName().endsWith(getProxyClassSuffix());
+    }
+
+    protected boolean hasSameSignature(Method a, Method b)
+    {
+        return a.getName().equals(b.getName())
+                && a.getReturnType().equals(b.getReturnType())
+                && Arrays.equals(a.getParameterTypes(), b.getParameterTypes());
+    }
+
+    protected boolean ignoreMethod(Method method, List<Method> methods)
+    {
+        // we have no interest in generics bridge methods
+        if (method.isBridge())
+        {
+            return true;
+        }
+
+        // we do not proxy finalize()
+        if ("finalize".equals(method.getName()))
+        {
+            return true;
+        }
+
+        // same method...
+        if (methods.contains(method))
+        {
+            return true;
+        }
+
+        // check if a method with the same signature is already available
+        for (Method currentMethod : methods)
+        {
+            if (hasSameSignature(currentMethod, method))
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+    
+    protected ArrayList<Method> collectAllMethods(Class<?> clazz)
+    {
+        ArrayList<Method> methods = new ArrayList<Method>();
+        for (Method method : clazz.getDeclaredMethods())
+        {
+            if (!ignoreMethod(method, methods))
+            {
+                methods.add(method);
+            }
+        }
+        for (Method method : clazz.getMethods())
+        {
+            if (!ignoreMethod(method, methods))
+            {
+                methods.add(method);
+            }
+        }
+
+        // collect methods from abstract super classes...
+        Class currentSuperClass = clazz.getSuperclass();
+        while (currentSuperClass != null)
+        {
+            if (Modifier.isAbstract(currentSuperClass.getModifiers()))
+            {
+                for (Method method : currentSuperClass.getDeclaredMethods())
+                {
+                    if (!ignoreMethod(method, methods))
+                    {
+                        methods.add(method);
+                    }
+                }
+                for (Method method : currentSuperClass.getMethods())
+                {
+                    if (!ignoreMethod(method, methods))
+                    {
+                        methods.add(method);
+                    }
+                }
+            }
+            currentSuperClass = currentSuperClass.getSuperclass();
+        }
+
+        // sort out somewhere implemented abstract methods
+        Class currentClass = clazz;
+        while (currentClass != null)
+        {
+            Iterator<Method> methodIterator = methods.iterator();
+            while (methodIterator.hasNext())
+            {
+                Method method = methodIterator.next();
+                if (Modifier.isAbstract(method.getModifiers()))
+                {
+                    try
+                    {
+                        Method foundMethod = currentClass.getMethod(method.getName(), method.getParameterTypes());
+                        // if method is implementent in the current class -> remove it
+                        if (foundMethod != null && !Modifier.isAbstract(foundMethod.getModifiers()))
+                        {
+                            methodIterator.remove();
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        // ignore...
+                    }
+                }
+            }
+
+            currentClass = currentClass.getSuperclass();
+        }
+
+        return methods;
+    }
+    
+    protected ArrayList<Method> filterInterceptMethods(Class<?> targetClass, ArrayList<Method> allMethods)
+    {
+        ArrayList<Method> methods = new ArrayList<Method>();
+        
+        Iterator<Method> it = allMethods.iterator();
+        while (it.hasNext())
+        {
+            Method method = it.next();
+
+            if (Modifier.isPublic(method.getModifiers())
+                    && !Modifier.isFinal(method.getModifiers())
+                    && !Modifier.isAbstract(method.getModifiers()))
+            {
+                methods.add(method);
+            }
+        }
+        
+        return methods;
+    }
+    
+    protected Class<?>[] getAdditionalInterfacesToImplement(Class<?> targetClass)
+    {
+        return null;
+    }
+    
+    protected abstract ArrayList<Method> getDelegateMethods(Class<?> targetClass, ArrayList<Method> allMethods);
+    
+    protected abstract String getProxyClassSuffix();
+}
+

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/pom.xml b/deltaspike/modules/proxy-utils/pom.xml
new file mode 100644
index 0000000..50e8e49
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.deltaspike.modules</groupId>
+        <artifactId>modules-project</artifactId>
+        <version>1.3.1-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.deltaspike.modules</groupId>
+    <artifactId>proxy-utils-module-project</artifactId>
+    <version>1.3.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <name>Apache DeltaSpike Proxy-Module</name>
+
+    <modules>
+        <module>api</module>
+    </modules>
+</project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/parent/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml
index a1cff1c..ef749a0 100644
--- a/deltaspike/parent/pom.xml
+++ b/deltaspike/parent/pom.xml
@@ -17,7 +17,8 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -141,12 +142,16 @@
         <repository>
             <id>Apache Repository</id>
             <url>https://repository.apache.org/content/repositories/releases</url>
-            <releases><enabled>true</enabled></releases>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
         </repository>
         <repository>
             <id>Apache Snapshot Repository</id>
             <url>https://repository.apache.org/content/repositories/snapshots</url>
-            <snapshots><enabled>true</enabled></snapshots>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
         </repository>
     </repositories>
 
@@ -559,6 +564,14 @@
                 <scope>runtime</scope>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.deltaspike.modules</groupId>
+                <artifactId>deltaspike-proxy-module-api</artifactId>
+                <version>${project.version}</version>
+                <scope>compile</scope>
+            </dependency>
+
+
             <!-- Dependencies for Java-SE -->
             <dependency>
                 <groupId>org.apache.deltaspike.cdictrl</groupId>


[2/2] deltaspike git commit: DELTASPIKE-882 - Create a new module for Proxy API

Posted by ra...@apache.org.
DELTASPIKE-882 - Create a new module for Proxy API


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

Branch: refs/heads/master
Commit: d7210631b0e6f42dd33883155f0f467d6b15171a
Parents: 625e784
Author: Rafael Benevides <ra...@gmail.com>
Authored: Mon May 4 11:08:41 2015 -0400
Committer: Rafael Benevides <ra...@gmail.com>
Committed: Mon May 4 11:08:41 2015 -0400

----------------------------------------------------------------------
 deltaspike/core/api/pom.xml                     |  57 ---
 .../AbstractManualInvocationHandler.java        | 104 ----
 .../invocation/ManualInvocationContext.java     | 187 --------
 ...nualInvocationThrowableWrapperException.java |  27 --
 .../core/util/proxy/AsmProxyClassGenerator.java | 467 ------------------
 .../core/util/proxy/DeltaSpikeProxy.java        |  28 --
 .../DeltaSpikeProxyContextualLifecycle.java     | 150 ------
 .../core/util/proxy/DeltaSpikeProxyFactory.java | 274 -----------
 .../DelegateManualInvocationHandler.java        |  43 --
 .../InterceptManualInvocationHandler.java       |  51 --
 deltaspike/dist/bom/pom.xml                     |   6 +
 .../src/main/distribution/modules-module.xml    |   1 +
 deltaspike/dist/pom.xml                         |   7 +
 deltaspike/modules/jsf/impl-ee6/pom.xml         |   5 +
 deltaspike/modules/jsf/impl/pom.xml             |   5 +
 .../InjectionAwareApplicationWrapper.java       |   3 +-
 .../ConverterAndValidatorProxyExtension.java    |  28 +-
 .../ConverterAndValidatorProxyFactory.java      |   4 +-
 deltaspike/modules/partial-bean/impl/pom.xml    |  15 +-
 .../impl/PartialBeanBindingExtension.java       |   4 +-
 .../impl/PartialBeanProxyFactory.java           |   4 +-
 deltaspike/modules/pom.xml                      |   1 +
 deltaspike/modules/proxy-utils/api/pom.xml      |  94 ++++
 .../AbstractManualInvocationHandler.java        | 104 ++++
 .../DelegateManualInvocationHandler.java        |  44 ++
 .../InterceptManualInvocationHandler.java       |  52 ++
 .../invocation/ManualInvocationContext.java     | 187 ++++++++
 ...nualInvocationThrowableWrapperException.java |  27 ++
 .../proxy/util/AsmProxyClassGenerator.java      | 470 +++++++++++++++++++
 .../deltaspike/proxy/util/DeltaSpikeProxy.java  |  28 ++
 .../DeltaSpikeProxyContextualLifecycle.java     | 150 ++++++
 .../proxy/util/DeltaSpikeProxyFactory.java      | 274 +++++++++++
 deltaspike/modules/proxy-utils/pom.xml          |  39 ++
 deltaspike/parent/pom.xml                       |  19 +-
 34 files changed, 1548 insertions(+), 1411 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/pom.xml b/deltaspike/core/api/pom.xml
index 94b489d..c5793f4 100644
--- a/deltaspike/core/api/pom.xml
+++ b/deltaspike/core/api/pom.xml
@@ -33,42 +33,6 @@
 
     <name>Apache DeltaSpike Core-API</name>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>2.3</version>
-                <configuration>
-                    <shadedArtifactAttached>false</shadedArtifactAttached>
-                    <createDependencyReducedPom>false</createDependencyReducedPom>
-                    <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-                    <relocations>
-                        <relocation>
-                            <pattern>org.objectweb.asm</pattern>
-                            <shadedPattern>org.apache.deltaspike.core.util.proxy.asm5</shadedPattern>
-                        </relocation>
-                    </relocations>
-                    <artifactSet>
-                        <includes>
-                            <include>org.ow2.asm:asm</include>
-                            <include>org.ow2.asm:asm-commons</include>
-                            <include>org.ow2.asm:asm-tree</include>
-                        </includes>
-                    </artifactSet>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
     <properties>
         <deltaspike.osgi.export.pkg>
             org.apache.deltaspike.core.*
@@ -82,26 +46,5 @@
         </deltaspike.osgi.provide.capability>
     </properties>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.ow2.asm</groupId>
-            <artifactId>asm</artifactId>
-            <version>5.0.3</version>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.ow2.asm</groupId>
-            <artifactId>asm-commons</artifactId>
-            <version>5.0.3</version>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.ow2.asm</groupId>
-            <artifactId>asm-tree</artifactId>
-            <version>5.0.3</version>
-            <optional>true</optional>
-        </dependency>
-    </dependencies>
-
 </project>
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/AbstractManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/AbstractManualInvocationHandler.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/AbstractManualInvocationHandler.java
deleted file mode 100644
index 5e6fe33..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/AbstractManualInvocationHandler.java
+++ /dev/null
@@ -1,104 +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.invocation;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.enterprise.inject.spi.Interceptor;
-import javax.interceptor.InterceptorBinding;
-import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
-
-@Typed
-public abstract class AbstractManualInvocationHandler implements InvocationHandler
-{
-    @Override
-    public Object invoke(Object proxy, Method method, Object[] parameters) throws Throwable
-    {
-        List<Interceptor<?>> interceptors = resolveInterceptors(proxy, method);
-        if (interceptors != null && interceptors.size() > 0)
-        {
-            try
-            {
-                ManualInvocationContext invocationContext =
-                        new ManualInvocationContext(this, interceptors, proxy, method, parameters, null);
-
-                Object returnValue = invocationContext.proceed();
-
-                if (invocationContext.isProceedOriginal())
-                {
-                    return invocationContext.getProceedOriginalReturnValue();
-                }
-
-                return returnValue;
-            }
-            catch (ManualInvocationThrowableWrapperException e)
-            {
-                throw e.getCause();
-            }
-        }
-
-        return proceedOriginal(proxy, method, parameters);
-    }
-
-    protected abstract Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable;
-
-    protected List<Interceptor<?>> resolveInterceptors(Object instance, Method method)
-    {
-        Annotation[] interceptorBindings = extractInterceptorBindings(instance, method);
-        if (interceptorBindings.length > 0)
-        {
-            BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
-            return beanManager.resolveInterceptors(InterceptionType.AROUND_INVOKE, interceptorBindings);
-        }
-
-        return null;
-    }
-
-    // TODO stereotypes
-    protected Annotation[] extractInterceptorBindings(Object instance, Method method)
-    {
-        ArrayList<Annotation> bindings = new ArrayList<Annotation>();
-
-        for (Annotation annotation : instance.getClass().getDeclaredAnnotations())
-        {
-            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class)
-                    && !bindings.contains(annotation))
-            {
-                bindings.add(annotation);
-            }
-        }
-
-        for (Annotation annotation : method.getDeclaredAnnotations())
-        {
-            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class)
-                    && !bindings.contains(annotation))
-            {
-                bindings.add(annotation);
-            }
-        }
-
-        return bindings.toArray(new Annotation[bindings.size()]);
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationContext.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationContext.java
deleted file mode 100644
index c79f126..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationContext.java
+++ /dev/null
@@ -1,187 +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.invocation;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InterceptionType;
-import javax.enterprise.inject.spi.Interceptor;
-import javax.interceptor.InvocationContext;
-import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
-
-@Typed
-public class ManualInvocationContext<T, H> implements InvocationContext
-{
-    protected List<Interceptor<H>> interceptors;
-    protected int interceptorIndex;
-    protected T target;
-    protected Method method;
-    protected Object[] parameters;
-    protected Map<String, Object> contextData;
-    protected Object timer;
-    protected AbstractManualInvocationHandler manualInvocationHandler;
-
-    protected BeanManager beanManager;
-
-    protected boolean proceedOriginal;
-    protected Object proceedOriginalReturnValue;
-
-    public ManualInvocationContext(AbstractManualInvocationHandler manualInvocationHandler,
-            List<Interceptor<H>> interceptors, T target, Method method, Object[] parameters, Object timer)
-    {
-        this.manualInvocationHandler = manualInvocationHandler;
-        this.interceptors = interceptors;
-        this.target = target;
-        this.method = method;
-        this.parameters = parameters;
-        this.timer = timer;
-
-        this.interceptorIndex = 0;
-    }
-
-    @Override
-    public Object getTarget()
-    {
-        return target;
-    }
-
-    @Override
-    public Method getMethod()
-    {
-        return method;
-    }
-
-    @Override
-    public Object[] getParameters()
-    {
-        return parameters;
-    }
-
-    @Override
-    public void setParameters(Object[] os)
-    {
-        parameters = os;
-    }
-
-    @Override
-    public Map<String, Object> getContextData()
-    {
-        if (contextData == null)
-        {
-            contextData = new HashMap<String, Object>();
-        }
-        return contextData;
-    }
-
-    @Override
-    public Object proceed() throws Exception
-    {
-        if (proceedOriginal)
-        {
-            return null;
-        }
-
-        if (interceptors.size() > interceptorIndex)
-        {
-            Interceptor<H> interceptor = null;
-            CreationalContext<H> creationalContext = null;
-            H interceptorInstance = null;
-
-            try
-            {
-                // lazy init beanManager
-                if (beanManager == null)
-                {
-                    beanManager = BeanManagerProvider.getInstance().getBeanManager();
-                }
-
-                interceptor = interceptors.get(interceptorIndex++);
-                creationalContext = beanManager.createCreationalContext(interceptor);
-                interceptorInstance = interceptor.create(creationalContext);
-
-                return interceptor.intercept(InterceptionType.AROUND_INVOKE, interceptorInstance, this);
-            }
-            finally
-            {
-                if (creationalContext != null)
-                {
-                    if (interceptorInstance != null && interceptor != null)
-                    {
-                        interceptor.destroy(interceptorInstance, creationalContext);
-                    }
-
-                    creationalContext.release();
-                }
-            }
-        }
-
-
-        // workaround for OWB 1.1, otherwise we could just return the proceedOriginalReturnValue here
-        try
-        {
-            proceedOriginal = true;
-            proceedOriginalReturnValue = manualInvocationHandler.proceedOriginal(target, method, parameters);
-        }
-        catch (Exception e)
-        {
-            throw e;
-        }
-        catch (Throwable e)
-        {
-            // wrap the Throwable here as interceptors declared only "throws Exception"
-            throw new ManualInvocationThrowableWrapperException(e);
-        }
-
-        return null;
-    }
-
-    @Override
-    public Object getTimer()
-    {
-        return timer;
-    }
-
-    // @Override
-    // CDI 1.1 compatibility
-    public Constructor getConstructor()
-    {
-        return null;
-    }
-
-    public boolean isProceedOriginal()
-    {
-        return proceedOriginal;
-    }
-
-    public Object getProceedOriginalReturnValue()
-    {
-        return proceedOriginalReturnValue;
-    }
-
-    public void setProceedOriginalReturnValue(Object proceedOriginalReturnValue)
-    {
-        this.proceedOriginalReturnValue = proceedOriginalReturnValue;
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationThrowableWrapperException.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationThrowableWrapperException.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationThrowableWrapperException.java
deleted file mode 100644
index f9df5e8..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/invocation/ManualInvocationThrowableWrapperException.java
+++ /dev/null
@@ -1,27 +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.invocation;
-
-public class ManualInvocationThrowableWrapperException extends Exception
-{
-    public ManualInvocationThrowableWrapperException(Throwable e)
-    {
-        super(e);
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/AsmProxyClassGenerator.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/AsmProxyClassGenerator.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/AsmProxyClassGenerator.java
deleted file mode 100644
index e7942af..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/AsmProxyClassGenerator.java
+++ /dev/null
@@ -1,467 +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.proxy;
-
-import org.apache.deltaspike.core.util.proxy.invocation.InterceptManualInvocationHandler;
-import org.apache.deltaspike.core.util.proxy.invocation.DelegateManualInvocationHandler;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.ProtectionDomain;
-import java.util.ArrayList;
-import java.util.Arrays;
-import javax.enterprise.inject.Typed;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.commons.GeneratorAdapter;
-import org.objectweb.asm.commons.Method;
-
-@Typed
-public abstract class AsmProxyClassGenerator
-{
-    private static final String FIELDNAME_DELEGATE_INVOCATION_HANDLER = "delegateInvocationHandler";
-
-    private static final Type TYPE_CLASS = Type.getType(Class.class);
-    private static final Type TYPE_OBJECT = Type.getType(Object.class);
-
-    private AsmProxyClassGenerator()
-    {
-        // prevent instantiation
-    }
-
-    public static <T> Class<T> generateProxyClass(ClassLoader classLoader,
-            Class<T> targetClass,
-            Class<? extends InvocationHandler> invocationHandlerClass,
-            String suffix,
-            String superAccessorMethodSuffix,
-            Class<?>[] additionalInterfaces,
-            java.lang.reflect.Method[] delegateMethods,
-            java.lang.reflect.Method[] interceptMethods)
-    {
-        String proxyName = targetClass.getCanonicalName() + suffix;
-        String classFileName = proxyName.replace('.', '/');
-
-        byte[] proxyBytes = generateProxyClassBytes(targetClass, invocationHandlerClass,
-                classFileName, superAccessorMethodSuffix, additionalInterfaces, delegateMethods, interceptMethods);
-
-        Class<T> proxyClass = (Class<T>) loadClass(classLoader, proxyName, proxyBytes,
-                targetClass.getProtectionDomain());
-
-        return proxyClass;
-    }
-
-    private static byte[] generateProxyClassBytes(Class<?> targetClass,
-            Class<? extends InvocationHandler> invocationHandlerClass,
-            String proxyName,
-            String superAccessorMethodSuffix,
-            Class<?>[] additionalInterfaces,
-            java.lang.reflect.Method[] delegateMethods,
-            java.lang.reflect.Method[] interceptMethods)
-    {
-        Class<?> superClass = targetClass;
-        String[] interfaces = new String[] { };
-
-        if (targetClass.isInterface())
-        {
-            superClass = Object.class;
-            interfaces = new String[] { Type.getInternalName(targetClass) };
-        }
-
-        // add DeltaSpikeProxy as interface
-        interfaces = Arrays.copyOf(interfaces, interfaces.length + 1);
-        interfaces[interfaces.length - 1] = Type.getInternalName(DeltaSpikeProxy.class);
-
-        if (additionalInterfaces != null && additionalInterfaces.length > 0)
-        {
-            interfaces = Arrays.copyOf(interfaces, interfaces.length + additionalInterfaces.length);
-            for (int i = 0; i < additionalInterfaces.length; i++)
-            {
-                interfaces[(interfaces.length - 1) + i] = Type.getInternalName(additionalInterfaces[i]);
-            }
-        }
-
-        Type superType = Type.getType(superClass);
-        Type proxyType = Type.getObjectType(proxyName);
-        Type invocationHandlerType = Type.getType(invocationHandlerClass);
-
-        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
-        cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, proxyType.getInternalName(), null,
-                superType.getInternalName(), interfaces);
-
-        // copy annotations
-        for (Annotation annotation : targetClass.getDeclaredAnnotations())
-        {
-            cw.visitAnnotation(Type.getDescriptor(annotation.annotationType()), true).visitEnd();
-        }
-
-        defineInvocationHandlerField(cw, invocationHandlerType);
-        defineDefaultConstructor(cw, proxyType, superType);
-        defineDelegateInvocationHandlerConstructor(cw, proxyType, superType, invocationHandlerType);
-        defineDeltaSpikeProxyMethods(cw, proxyType, invocationHandlerType);
-
-        for (java.lang.reflect.Method method : delegateMethods)
-        {
-            defineMethod(cw, method, DelegateManualInvocationHandler.class);
-        }
-
-        for (java.lang.reflect.Method method : interceptMethods)
-        {
-            defineSuperAccessorMethod(cw, method, superType, superAccessorMethodSuffix);
-            defineMethod(cw, method, InterceptManualInvocationHandler.class);
-        }
-
-        return cw.toByteArray();
-    }
-
-    private static void defineInvocationHandlerField(ClassWriter cw, Type invocationHandlerType)
-    {
-        // generates
-        // private MyInvocationHandler delegateInvocationHandler;
-        cw.visitField(Opcodes.ACC_PRIVATE, FIELDNAME_DELEGATE_INVOCATION_HANDLER,
-                invocationHandlerType.getDescriptor(), null, null).visitEnd();
-    }
-
-    private static void defineDefaultConstructor(ClassWriter cw, Type proxyType, Type superType)
-    {
-        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
-                new Method("<init>", Type.VOID_TYPE, new Type[]{ }),
-                null,
-                null,
-                cw);
-
-        mg.visitCode();
-
-        // invoke super constructor
-        mg.loadThis();
-        mg.invokeConstructor(superType, Method.getMethod("void <init> ()"));
-        mg.returnValue();
-        mg.endMethod();
-
-        mg.visitEnd();
-    }
-    
-    private static void defineDelegateInvocationHandlerConstructor(ClassWriter cw, Type proxyType, Type superType,
-            Type invocationHandlerType)
-    {
-        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
-                new Method("<init>", Type.VOID_TYPE, new Type[] { invocationHandlerType }),
-                null,
-                null,
-                cw);
-
-        mg.visitCode();
-
-        // invoke super constructor
-        mg.loadThis();
-        mg.invokeConstructor(superType, Method.getMethod("void <init> ()"));
-        
-        // set invocation handler
-        mg.loadThis();
-        mg.loadArg(0);
-        mg.putField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
-        
-        mg.returnValue();
-        mg.endMethod();
-
-        mg.visitEnd();
-    }
-
-    private static void defineDeltaSpikeProxyMethods(ClassWriter cw, Type proxyType, Type invocationHandlerType)
-    {
-        try
-        {
-            // implement #setDelegateInvocationHandler
-            Method asmMethod = Method.getMethod(DeltaSpikeProxy.class.getDeclaredMethod(
-                    "setDelegateInvocationHandler", InvocationHandler.class));
-            GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, asmMethod, null, null, cw);
-
-            mg.visitCode();
-
-            mg.loadThis();
-            mg.loadArg(0);
-            mg.checkCast(invocationHandlerType);
-            mg.putField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
-            mg.returnValue();
-
-            mg.visitMaxs(2, 1);
-            mg.visitEnd();
-
-
-            // implement #getDelegateInvocationHandler
-            asmMethod = Method.getMethod(DeltaSpikeProxy.class.getDeclaredMethod("getDelegateInvocationHandler"));
-            mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, asmMethod, null, null, cw);
-
-            mg.visitCode();
-
-            mg.loadThis();
-            mg.getField(proxyType, FIELDNAME_DELEGATE_INVOCATION_HANDLER, invocationHandlerType);
-            mg.returnValue();
-
-            mg.visitMaxs(2, 1);
-            mg.visitEnd();
-        }
-        catch (NoSuchMethodException e)
-        {
-            throw new IllegalStateException("Unable to implement " + DeltaSpikeProxy.class.getName(), e);
-        }
-    }
-
-    private static void defineSuperAccessorMethod(ClassWriter cw, java.lang.reflect.Method method, Type superType,
-            String superAccessorMethodSuffix) 
-    {
-        Method originalAsmMethod = Method.getMethod(method);
-        Method newAsmMethod = new Method(method.getName() + superAccessorMethodSuffix,
-                originalAsmMethod.getReturnType(),
-                originalAsmMethod.getArgumentTypes());
-        GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, newAsmMethod, null, null, cw);
-        
-        mg.visitCode();
-        
-        // call super method
-        mg.loadThis();
-        mg.loadArgs();
-        mg.visitMethodInsn(Opcodes.INVOKESPECIAL,
-                superType.getInternalName(),
-                method.getName(),
-                Type.getMethodDescriptor(method),
-                false);
-        mg.returnValue();
-        
-        // finish the method
-        mg.endMethod();
-        mg.visitMaxs(10, 10);
-        mg.visitEnd();
-    }
-    
-    private static void defineMethod(ClassWriter cw, java.lang.reflect.Method method,
-            Class manualInvocationHandlerClass)
-    {
-        Type methodType = Type.getType(method);
-        
-        ArrayList<Type> exceptionsToCatch = new ArrayList<Type>();
-        for (Class<?> exception : method.getExceptionTypes())
-        {
-            if (!RuntimeException.class.isAssignableFrom(exception))
-            {
-                exceptionsToCatch.add(Type.getType(exception));
-            }
-        }
-        
-        // push the method definition
-        int modifiers = (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED) & method.getModifiers();
-        Method asmMethod = Method.getMethod(method);
-        GeneratorAdapter mg = new GeneratorAdapter(modifiers,
-                asmMethod,
-                null,
-                getTypes(method.getExceptionTypes()),
-                cw);
-
-        // copy annotations
-        for (Annotation annotation : method.getDeclaredAnnotations())
-        {
-            mg.visitAnnotation(Type.getDescriptor(annotation.annotationType()), true).visitEnd();
-        }
-
-        mg.visitCode();
-
-        Label tryBlockStart = mg.mark();
-
-        mg.loadThis();
-        loadCurrentMethod(mg, method, methodType);
-        loadArguments(mg, method, methodType);
-        
-        // invoke our ProxyInvocationHandler
-        mg.invokeStatic(Type.getType(manualInvocationHandlerClass),
-                Method.getMethod("Object staticInvoke(Object, java.lang.reflect.Method, Object[])"));
-
-        // cast the result
-        mg.unbox(methodType.getReturnType());
-
-        // build try catch
-        Label tryBlockEnd = mg.mark();
-        
-        // push return
-        mg.returnValue();
-
-        // catch runtime exceptions and rethrow it
-        Label rethrow = mg.mark();
-        mg.visitVarInsn(Opcodes.ASTORE, 1);
-        mg.visitVarInsn(Opcodes.ALOAD, 1);
-        mg.throwException();
-        mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, rethrow, Type.getInternalName(RuntimeException.class));
-
-        // catch checked exceptions and rethrow it
-        boolean throwableCatched = false;
-        if (exceptionsToCatch.size() > 0)
-        {
-            rethrow = mg.mark();
-            mg.visitVarInsn(Opcodes.ASTORE, 1);
-            mg.visitVarInsn(Opcodes.ALOAD, 1);
-            mg.throwException();
-
-            // catch declared exceptions and rethrow it...
-            for (Type exceptionType : exceptionsToCatch)
-            {
-                if (exceptionType.getClassName().equals(Throwable.class.getName()))
-                {
-                    throwableCatched = true;
-                }
-                mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, rethrow, exceptionType.getInternalName());
-            }
-        }
-
-        // if throwable isn't alreached cachted, catch it and wrap it with an UndeclaredThrowableException and throw it
-        if (!throwableCatched)
-        {
-            Type uteType = Type.getType(UndeclaredThrowableException.class);
-            Label wrapAndRethrow = mg.mark();
-
-            mg.visitVarInsn(Opcodes.ASTORE, 1);
-            mg.newInstance(uteType);
-            mg.dup();
-            mg.visitVarInsn(Opcodes.ALOAD, 1);
-            mg.invokeConstructor(uteType,
-                    Method.getMethod("void <init>(java.lang.Throwable)"));
-            mg.throwException();
-
-            mg.visitTryCatchBlock(tryBlockStart, tryBlockEnd, wrapAndRethrow, Type.getInternalName(Throwable.class));
-        }
-
-        // finish the method
-        mg.endMethod();
-        mg.visitMaxs(10, 10);
-        mg.visitEnd();
-    }
-
-    /**
-     * Generates:
-     * <pre>
-     * Method method =
-     *      method.getDeclaringClass().getMethod("methodName", new Class[] { args... });
-     * </pre>
-     * @param mg
-     * @param method
-     * @param methodType
-     */
-    private static void loadCurrentMethod(GeneratorAdapter mg, java.lang.reflect.Method method, Type methodType)
-    {
-        mg.push(Type.getType(method.getDeclaringClass()));
-        mg.push(method.getName());
-
-        // create the Class[]
-        mg.push(methodType.getArgumentTypes().length);
-        mg.newArray(TYPE_CLASS);
-
-        // push parameters into array
-        for (int i = 0; i < methodType.getArgumentTypes().length; i++)
-        {
-            // keep copy of array on stack
-            mg.dup();
-
-            // push index onto stack
-            mg.push(i);
-            mg.push(methodType.getArgumentTypes()[i]);
-            mg.arrayStore(TYPE_CLASS);
-        }
-
-        // invoke getMethod() with the method name and the array of types
-        mg.invokeVirtual(TYPE_CLASS, Method.getMethod("java.lang.reflect.Method getDeclaredMethod(String, Class[])"));
-    }
-
-    /**
-     * Defines a new Object[] and push all method argmuments into the array.
-     *
-     * @param mg
-     * @param method
-     * @param methodType
-     */
-    private static void loadArguments(GeneratorAdapter mg, java.lang.reflect.Method method, Type methodType)
-    {
-        // create the Object[]
-        mg.push(methodType.getArgumentTypes().length);
-        mg.newArray(TYPE_OBJECT);
-
-        // push parameters into array
-        for (int i = 0; i < methodType.getArgumentTypes().length; i++)
-        {
-            // keep copy of array on stack
-            mg.dup();
-
-            // push index onto stack
-            mg.push(i);
-
-            mg.loadArg(i);
-            mg.valueOf(methodType.getArgumentTypes()[i]);
-            mg.arrayStore(TYPE_OBJECT);
-        }
-    }
-
-    private static Type[] getTypes(Class<?>... src)
-    {
-        Type[] result = new Type[src.length];
-        for (int i = 0; i < result.length; i++)
-        {
-            result[i] = Type.getType(src[i]);
-        }
-        return result;
-    }
-
-    /**
-     * Adapted from http://asm.ow2.org/doc/faq.html#Q5
-     *
-     * @param b
-     *
-     * @return Class<?>
-     */
-    private static Class<?> loadClass(ClassLoader loader, String className, byte[] b,
-            ProtectionDomain protectionDomain)
-    {
-        // override classDefine (as it is protected) and define the class.
-        try
-        {
-            java.lang.reflect.Method method = ClassLoader.class.getDeclaredMethod(
-                    "defineClass", String.class, byte[].class, int.class, int.class, ProtectionDomain.class);
-
-            // protected method invocation
-            boolean accessible = method.isAccessible();
-            if (!accessible)
-            {
-                method.setAccessible(true);
-            }
-            try
-            {
-                return (Class<?>) method.invoke(loader, className, b, Integer.valueOf(0), Integer.valueOf(b.length),
-                        protectionDomain);
-            }
-            finally
-            {
-                if (!accessible)
-                {
-                    method.setAccessible(false);
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            throw e instanceof RuntimeException ? ((RuntimeException) e) : new RuntimeException(e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxy.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxy.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxy.java
deleted file mode 100644
index cb4b1f1..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxy.java
+++ /dev/null
@@ -1,28 +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.proxy;
-
-import java.lang.reflect.InvocationHandler;
-
-public interface DeltaSpikeProxy
-{
-    void setDelegateInvocationHandler(InvocationHandler redirectInvocationHandler);
-
-    InvocationHandler getDelegateInvocationHandler();
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyContextualLifecycle.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyContextualLifecycle.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyContextualLifecycle.java
deleted file mode 100644
index a9fb26d..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyContextualLifecycle.java
+++ /dev/null
@@ -1,150 +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.proxy;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.util.Set;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.PassivationCapable;
-import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.core.util.ExceptionUtils;
-import org.apache.deltaspike.core.util.metadata.builder.ContextualLifecycle;
-
-public class DeltaSpikeProxyContextualLifecycle<T, H extends InvocationHandler> implements ContextualLifecycle<T>
-{
-    private final Class<T> proxyClass;
-    private final Class<H> delegateInvocationHandlerClass;
-    private final Class<T> targetClass;
-    
-    private InjectionTarget<T> injectionTarget;
-    private CreationalContext<?> creationalContextOfDependentHandler;
-
-    public DeltaSpikeProxyContextualLifecycle(Class<T> targetClass, Class<H> delegateInvocationHandlerClass,
-            DeltaSpikeProxyFactory proxyFactory, BeanManager beanManager)
-    {
-        this.targetClass = targetClass;
-        this.delegateInvocationHandlerClass = delegateInvocationHandlerClass;
-        this.proxyClass = proxyFactory.getProxyClass(targetClass, delegateInvocationHandlerClass);
-
-        if (!targetClass.isInterface())
-        {
-            AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(this.targetClass);
-            this.injectionTarget = beanManager.createInjectionTarget(annotatedType);
-        }
-    }
-
-    @Override
-    public T create(Bean bean, CreationalContext creationalContext)
-    {
-        try
-        {
-            T instance;
-
-            if (delegateInvocationHandlerClass == null)
-            {
-                instance = proxyClass.newInstance();
-            }
-            else
-            {
-                H delegateInvocationHandler = instantiateDelegateInvocationHandler();
-                Constructor<T> constructor = proxyClass.getConstructor(delegateInvocationHandlerClass);
-                instance = constructor.newInstance(delegateInvocationHandler);
-            }
-
-            if (this.injectionTarget != null)
-            {
-                this.injectionTarget.inject(instance, creationalContext);
-                this.injectionTarget.postConstruct(instance);
-            }
-
-            return instance;
-        }
-        catch (Exception e)
-        {
-            ExceptionUtils.throwAsRuntimeException(e);
-        }
-
-        // can't happen
-        return null;
-    }
-
-    @Override
-    public void destroy(Bean<T> bean, T instance, CreationalContext<T> creationalContext)
-    {
-        if (this.injectionTarget != null)
-        {
-            this.injectionTarget.preDestroy(instance);
-        }
-        
-        if (this.creationalContextOfDependentHandler != null)
-        {
-            this.creationalContextOfDependentHandler.release();
-        }
-
-        creationalContext.release();
-    }
-    
-    protected H instantiateDelegateInvocationHandler()
-    {
-        Set<Bean<H>> handlerBeans = BeanProvider.getBeanDefinitions(this.delegateInvocationHandlerClass, false, true);
-        
-        if (handlerBeans.size() != 1)
-        {
-            StringBuilder beanInfo = new StringBuilder();
-            for (Bean<H> bean : handlerBeans)
-            {
-                if (beanInfo.length() != 0)
-                {
-                    beanInfo.append(", ");
-                }
-                beanInfo.append(bean);
-
-                if (bean instanceof PassivationCapable)
-                {
-                    beanInfo.append(" bean-id: ").append(((PassivationCapable)bean).getId());
-                }
-            }
-
-            throw new IllegalStateException(handlerBeans.size() + " beans found for "
-                    + this.delegateInvocationHandlerClass + " found beans: " + beanInfo.toString());
-        }
-
-        Bean<H> handlerBean = handlerBeans.iterator().next();
-        
-        BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
-        CreationalContext<?> creationalContext = beanManager.createCreationalContext(handlerBean);
-        
-        H handlerInstance = (H) beanManager.getReference(handlerBean,
-                this.delegateInvocationHandlerClass, creationalContext);
-        
-        if (handlerBean.getScope().equals(Dependent.class))
-        {
-            this.creationalContextOfDependentHandler = creationalContext;
-        }
-
-        return handlerInstance;
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyFactory.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyFactory.java
deleted file mode 100644
index 013733d..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/DeltaSpikeProxyFactory.java
+++ /dev/null
@@ -1,274 +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.proxy;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import javax.interceptor.InterceptorBinding;
-import org.apache.deltaspike.core.util.ClassUtils;
-
-public abstract class DeltaSpikeProxyFactory
-{
-    private static final String SUPER_ACCESSOR_METHOD_SUFFIX = "$super";
-    
-    public <T> Class<T> getProxyClass(Class<T> targetClass,
-            Class<? extends InvocationHandler> invocationHandlerClass)
-    {
-        Class<T> proxyClass = ClassUtils.tryToLoadClassForName(constructProxyClassName(targetClass), targetClass);
-        if (proxyClass == null)
-        {
-            proxyClass = createProxyClass(targetClass.getClassLoader(), targetClass, invocationHandlerClass);
-        }
-
-        return proxyClass;
-    }
-
-    private synchronized <T> Class<T> createProxyClass(ClassLoader classLoader, Class<T> targetClass,
-            Class<? extends InvocationHandler> invocationHandlerClass)
-    {
-        Class<T> proxyClass = ClassUtils.tryToLoadClassForName(constructProxyClassName(targetClass), targetClass);
-        if (proxyClass == null)
-        {
-            ArrayList<Method> allMethods = collectAllMethods(targetClass);
-            ArrayList<Method> interceptMethods = filterInterceptMethods(targetClass, allMethods);
-            ArrayList<Method> delegateMethods = getDelegateMethods(targetClass, allMethods);
-
-            // check if a interceptor is defined on class level. if not, skip interceptor methods
-            if (delegateMethods != null
-                    && interceptMethods.size() > 0
-                    && !containsInterceptorBinding(targetClass.getDeclaredAnnotations()))
-            {
-                // loop every method and check if a interceptor is defined on the method -> otherwise don't proxy
-                Iterator<Method> iterator = interceptMethods.iterator();
-                while (iterator.hasNext())
-                {
-                    Method method = iterator.next();
-                    if (!containsInterceptorBinding(method.getDeclaredAnnotations()))
-                    {
-                        iterator.remove();
-                    }
-                }
-            }
-            
-            proxyClass = AsmProxyClassGenerator.generateProxyClass(classLoader,
-                    targetClass,
-                    invocationHandlerClass,
-                    getProxyClassSuffix(),
-                    SUPER_ACCESSOR_METHOD_SUFFIX,
-                    getAdditionalInterfacesToImplement(targetClass),
-                    delegateMethods == null ? new Method[0]
-                            : delegateMethods.toArray(new Method[delegateMethods.size()]),
-                    interceptMethods == null ? new Method[0]
-                            : interceptMethods.toArray(new Method[interceptMethods.size()]));
-        }
-
-        return proxyClass;
-    }
-    
-    // TODO stereotypes
-    protected boolean containsInterceptorBinding(Annotation[] annotations)
-    {
-        for (Annotation annotation : annotations)
-        {
-            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class))
-            {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-        
-    protected String constructProxyClassName(Class<?> clazz)
-    {
-        return clazz.getName() + getProxyClassSuffix();
-    }
-
-    protected static String constructSuperAccessorMethodName(Method method)
-    {
-        return method.getName() + SUPER_ACCESSOR_METHOD_SUFFIX;
-    }
-    
-    public static Method getSuperAccessorMethod(Object proxy, Method method) throws NoSuchMethodException
-    {
-        return proxy.getClass().getMethod(
-                constructSuperAccessorMethodName(method),
-                method.getParameterTypes());
-    }
-    
-    /**
-     * Checks if the given class is DS proxy class.
-     *
-     * @param clazz
-     * @return
-     */
-    public boolean isProxyClass(Class<?> clazz)
-    {
-        return clazz.getName().endsWith(getProxyClassSuffix());
-    }
-
-    protected boolean hasSameSignature(Method a, Method b)
-    {
-        return a.getName().equals(b.getName())
-                && a.getReturnType().equals(b.getReturnType())
-                && Arrays.equals(a.getParameterTypes(), b.getParameterTypes());
-    }
-
-    protected boolean ignoreMethod(Method method, List<Method> methods)
-    {
-        // we have no interest in generics bridge methods
-        if (method.isBridge())
-        {
-            return true;
-        }
-
-        // we do not proxy finalize()
-        if ("finalize".equals(method.getName()))
-        {
-            return true;
-        }
-
-        // same method...
-        if (methods.contains(method))
-        {
-            return true;
-        }
-
-        // check if a method with the same signature is already available
-        for (Method currentMethod : methods)
-        {
-            if (hasSameSignature(currentMethod, method))
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-    
-    protected ArrayList<Method> collectAllMethods(Class<?> clazz)
-    {
-        ArrayList<Method> methods = new ArrayList<Method>();
-        for (Method method : clazz.getDeclaredMethods())
-        {
-            if (!ignoreMethod(method, methods))
-            {
-                methods.add(method);
-            }
-        }
-        for (Method method : clazz.getMethods())
-        {
-            if (!ignoreMethod(method, methods))
-            {
-                methods.add(method);
-            }
-        }
-
-        // collect methods from abstract super classes...
-        Class currentSuperClass = clazz.getSuperclass();
-        while (currentSuperClass != null)
-        {
-            if (Modifier.isAbstract(currentSuperClass.getModifiers()))
-            {
-                for (Method method : currentSuperClass.getDeclaredMethods())
-                {
-                    if (!ignoreMethod(method, methods))
-                    {
-                        methods.add(method);
-                    }
-                }
-                for (Method method : currentSuperClass.getMethods())
-                {
-                    if (!ignoreMethod(method, methods))
-                    {
-                        methods.add(method);
-                    }
-                }
-            }
-            currentSuperClass = currentSuperClass.getSuperclass();
-        }
-
-        // sort out somewhere implemented abstract methods
-        Class currentClass = clazz;
-        while (currentClass != null)
-        {
-            Iterator<Method> methodIterator = methods.iterator();
-            while (methodIterator.hasNext())
-            {
-                Method method = methodIterator.next();
-                if (Modifier.isAbstract(method.getModifiers()))
-                {
-                    try
-                    {
-                        Method foundMethod = currentClass.getMethod(method.getName(), method.getParameterTypes());
-                        // if method is implementent in the current class -> remove it
-                        if (foundMethod != null && !Modifier.isAbstract(foundMethod.getModifiers()))
-                        {
-                            methodIterator.remove();
-                        }
-                    }
-                    catch (Exception e)
-                    {
-                        // ignore...
-                    }
-                }
-            }
-
-            currentClass = currentClass.getSuperclass();
-        }
-
-        return methods;
-    }
-    
-    protected ArrayList<Method> filterInterceptMethods(Class<?> targetClass, ArrayList<Method> allMethods)
-    {
-        ArrayList<Method> methods = new ArrayList<Method>();
-        
-        Iterator<Method> it = allMethods.iterator();
-        while (it.hasNext())
-        {
-            Method method = it.next();
-
-            if (Modifier.isPublic(method.getModifiers())
-                    && !Modifier.isFinal(method.getModifiers())
-                    && !Modifier.isAbstract(method.getModifiers()))
-            {
-                methods.add(method);
-            }
-        }
-        
-        return methods;
-    }
-    
-    protected Class<?>[] getAdditionalInterfacesToImplement(Class<?> targetClass)
-    {
-        return null;
-    }
-    
-    protected abstract ArrayList<Method> getDelegateMethods(Class<?> targetClass, ArrayList<Method> allMethods);
-    
-    protected abstract String getProxyClassSuffix();
-}
-

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/DelegateManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/DelegateManualInvocationHandler.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/DelegateManualInvocationHandler.java
deleted file mode 100644
index 7a00819..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/DelegateManualInvocationHandler.java
+++ /dev/null
@@ -1,43 +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.proxy.invocation;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import javax.enterprise.inject.Typed;
-import org.apache.deltaspike.core.util.invocation.AbstractManualInvocationHandler;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxy;
-
-@Typed
-public class DelegateManualInvocationHandler extends AbstractManualInvocationHandler
-{
-    private static final DelegateManualInvocationHandler INSTANCE = new DelegateManualInvocationHandler();
-    
-    public static Object staticInvoke(Object proxy, Method method, Object[] parameters) throws Throwable
-    {
-        return INSTANCE.invoke(proxy, method, parameters);
-    }
-    
-    @Override
-    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable
-    {
-        InvocationHandler delegateInvocationHandler = ((DeltaSpikeProxy) proxy).getDelegateInvocationHandler();
-        return delegateInvocationHandler.invoke(proxy, method, parameters);
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/InterceptManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/InterceptManualInvocationHandler.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/InterceptManualInvocationHandler.java
deleted file mode 100644
index 77af318..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/proxy/invocation/InterceptManualInvocationHandler.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.util.proxy.invocation;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.enterprise.inject.Typed;
-import org.apache.deltaspike.core.util.invocation.AbstractManualInvocationHandler;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxyFactory;
-
-@Typed
-public class InterceptManualInvocationHandler extends AbstractManualInvocationHandler
-{
-    private static final InterceptManualInvocationHandler INSTANCE = new InterceptManualInvocationHandler();
-    
-    public static Object staticInvoke(Object proxy, Method method, Object[] parameters) throws Throwable
-    {
-        return INSTANCE.invoke(proxy, method, parameters);
-    }
-    
-    @Override
-    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable
-    {
-        try
-        {
-            Method superAccessorMethod = DeltaSpikeProxyFactory.getSuperAccessorMethod(proxy, method);
-            return superAccessorMethod.invoke(proxy, parameters);
-        }
-        catch (InvocationTargetException e)
-        {
-            // rethrow original exception
-            throw e.getCause();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/dist/bom/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/dist/bom/pom.xml b/deltaspike/dist/bom/pom.xml
index 52a0899..41d6af6 100644
--- a/deltaspike/dist/bom/pom.xml
+++ b/deltaspike/dist/bom/pom.xml
@@ -187,6 +187,12 @@
             <artifactId>deltaspike-scheduler-module-impl</artifactId>
             <scope>runtime</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-proxy-module-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/dist/full/src/main/distribution/modules-module.xml
----------------------------------------------------------------------
diff --git a/deltaspike/dist/full/src/main/distribution/modules-module.xml b/deltaspike/dist/full/src/main/distribution/modules-module.xml
index 3b82273..5e0841f 100644
--- a/deltaspike/dist/full/src/main/distribution/modules-module.xml
+++ b/deltaspike/dist/full/src/main/distribution/modules-module.xml
@@ -31,6 +31,7 @@
         <resource-root path="deltaspike-jsf-module-impl-ee6-${project.version}.jar"/>
         <resource-root path="deltaspike-partial-bean-module-api-${project.version}.jar"/>
         <resource-root path="deltaspike-partial-bean-module-impl-${project.version}.jar"/>
+        <resource-root path="deltaspike-proxy-module-api-${project.version}.jar"/>
         <resource-root path="deltaspike-security-module-api-${project.version}.jar"/>
         <resource-root path="deltaspike-security-module-impl-${project.version}.jar"/>
         <resource-root path="deltaspike-servlet-module-api-${project.version}.jar"/>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/dist/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/dist/pom.xml b/deltaspike/dist/pom.xml
index f9082d5..8796589 100644
--- a/deltaspike/dist/pom.xml
+++ b/deltaspike/dist/pom.xml
@@ -217,6 +217,13 @@
                 <scope>runtime</scope>
             </dependency>
         </dependencies>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-proxy-module-api</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencyManagement>
 
     <modules>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/jsf/impl-ee6/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl-ee6/pom.xml b/deltaspike/modules/jsf/impl-ee6/pom.xml
index 00300ff..4dbf669 100644
--- a/deltaspike/modules/jsf/impl-ee6/pom.xml
+++ b/deltaspike/modules/jsf/impl-ee6/pom.xml
@@ -129,6 +129,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-proxy-module-api</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-el_2.2_spec</artifactId>
             <version>1.0</version>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/jsf/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/pom.xml b/deltaspike/modules/jsf/impl/pom.xml
index 07d8ea4..219033e 100644
--- a/deltaspike/modules/jsf/impl/pom.xml
+++ b/deltaspike/modules/jsf/impl/pom.xml
@@ -111,6 +111,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-proxy-module-api</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-el_2.2_spec</artifactId>
             <version>1.0</version>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
index 928a6de..1f5f8af 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/InjectionAwareApplicationWrapper.java
@@ -30,7 +30,8 @@ import javax.faces.convert.Converter;
 import javax.faces.event.PreDestroyViewMapEvent;
 import javax.faces.event.SystemEvent;
 import javax.faces.validator.Validator;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxy;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxy;
 
 public class InjectionAwareApplicationWrapper extends ApplicationWrapper
 {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyExtension.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyExtension.java
index 1baca10..e119869 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyExtension.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyExtension.java
@@ -33,6 +33,7 @@ import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.faces.convert.Converter;
 import javax.faces.validator.Validator;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
@@ -40,7 +41,8 @@ import java.lang.reflect.Modifier;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.logging.Logger;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxyContextualLifecycle;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxyContextualLifecycle;
 
 public class ConverterAndValidatorProxyExtension implements Extension, Deactivatable
 {
@@ -56,7 +58,7 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
 
     @SuppressWarnings("UnusedDeclaration")
     public <X> void findConverterAndValidatorsWhichNeedProxiesForDependencyInjectionSupport(
-        @Observes ProcessAnnotatedType<X> pat, BeanManager beanManager)
+            @Observes ProcessAnnotatedType<X> pat, BeanManager beanManager)
     {
         if (!this.isActivated)
         {
@@ -71,14 +73,14 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
         }
 
         Bean<X> bean = new BeanBuilder<X>(beanManager).readFromType(pat.getAnnotatedType()).create();
-        //veto normal converters/validators -> they will get excluded from the special handling later on
+        // veto normal converters/validators -> they will get excluded from the special handling later on
         if (!hasInjectionPoints(bean) && !hasNormalScopeAnnotation(bean, beanManager))
         {
             pat.veto();
             return;
         }
 
-        //converters/validators without properties for tags, will be handled by the corresponding manual wrapper
+        // converters/validators without properties for tags, will be handled by the corresponding manual wrapper
         if (!hasPublicProperty(beanClass))
         {
             return;
@@ -92,7 +94,7 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
         else
         {
             LOG.warning("To use dependency-injection in converters/validators with properties, " +
-                "you they aren't allowed to be 'final'.");
+                    "you they aren't allowed to be 'final'.");
         }
     }
 
@@ -104,7 +106,7 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
     protected <X> boolean hasNormalScopeAnnotation(Bean<X> bean, BeanManager beanManager)
     {
         Class<? extends Annotation> scopeAnnotationClass = bean.getScope();
-        return  scopeAnnotationClass != null && beanManager.isNormalScope(scopeAnnotationClass);
+        return scopeAnnotationClass != null && beanManager.isNormalScope(scopeAnnotationClass);
     }
 
     protected <X> boolean hasPublicProperty(Class<X> beanClass)
@@ -112,8 +114,8 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
         for (Method currentMethod : beanClass.getMethods())
         {
             if (currentMethod.getName().startsWith("set") && currentMethod.getName().length() > 3
-                && currentMethod.getParameterTypes().length == 1 &&
-                hasGetterMethod(beanClass, currentMethod.getName().substring(3)))
+                    && currentMethod.getParameterTypes().length == 1 &&
+                    hasGetterMethod(beanClass, currentMethod.getName().substring(3)))
             {
                 return true;
             }
@@ -160,8 +162,8 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
     protected <T> Bean<T> createBean(Class<T> beanClass, BeanManager beanManager)
     {
         Class<? extends InvocationHandler> invocationHandlerClass =
-            Converter.class.isAssignableFrom(beanClass) ?
-                ConverterInvocationHandler.class : ValidatorInvocationHandler.class;
+                Converter.class.isAssignableFrom(beanClass) ?
+                        ConverterInvocationHandler.class : ValidatorInvocationHandler.class;
 
         AnnotatedType<T> annotatedType = new AnnotatedTypeBuilder<T>().readFromType(beanClass).create();
 
@@ -169,9 +171,9 @@ public class ConverterAndValidatorProxyExtension implements Extension, Deactivat
                 invocationHandlerClass, ConverterAndValidatorProxyFactory.getInstance(), beanManager);
 
         BeanBuilder<T> beanBuilder = new BeanBuilder<T>(beanManager)
-            .readFromType(annotatedType)
-            .passivationCapable(true)
-            .beanLifecycle(lifecycle);
+                .readFromType(annotatedType)
+                .passivationCapable(true)
+                .beanLifecycle(lifecycle);
 
         return beanBuilder.create();
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyFactory.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyFactory.java
index d069070..922ebae 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyFactory.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/injection/proxy/ConverterAndValidatorProxyFactory.java
@@ -22,10 +22,12 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+
 import javax.enterprise.inject.Typed;
 import javax.faces.component.PartialStateHolder;
 import javax.faces.component.StateHolder;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxyFactory;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxyFactory;
 
 @Typed
 public class ConverterAndValidatorProxyFactory extends DeltaSpikeProxyFactory

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/partial-bean/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/pom.xml b/deltaspike/modules/partial-bean/impl/pom.xml
index c0d1f00..1d067a6 100644
--- a/deltaspike/modules/partial-bean/impl/pom.xml
+++ b/deltaspike/modules/partial-bean/impl/pom.xml
@@ -17,7 +17,8 @@
     specific language governing permissions and limitations
     under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
@@ -41,10 +42,12 @@
             *
         </deltaspike.osgi.import>
         <deltaspike.osgi.require.capability>
-            org.ops4j.pax.cdi.extension; filter:="(extension=pax-cdi-extension)"
+            org.ops4j.pax.cdi.extension;
+            filter:="(extension=pax-cdi-extension)"
         </deltaspike.osgi.require.capability>
         <deltaspike.osgi.provide.capability>
-            org.ops4j.pax.cdi.extension; extension=deltaspike-partial-bean-module-impl
+            org.ops4j.pax.cdi.extension;
+            extension=deltaspike-partial-bean-module-impl
         </deltaspike.osgi.provide.capability>
     </properties>
 
@@ -58,5 +61,11 @@
             <groupId>org.apache.deltaspike.modules</groupId>
             <artifactId>deltaspike-partial-bean-module-api</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-proxy-module-api</artifactId>
+        </dependency>
+
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanBindingExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanBindingExtension.java b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanBindingExtension.java
index 399f4f3..5245b90 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanBindingExtension.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanBindingExtension.java
@@ -23,6 +23,7 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
 import java.util.Map;
+
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AnnotatedType;
@@ -31,11 +32,12 @@ 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 org.apache.deltaspike.core.spi.activation.Deactivatable;
 import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.core.util.bean.BeanBuilder;
 import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxyContextualLifecycle;
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxyContextualLifecycle;
 import org.apache.deltaspike.partialbean.api.PartialBeanBinding;
 
 public class PartialBeanBindingExtension implements Extension, Deactivatable

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
index 7dd0582..08c0165 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
@@ -22,8 +22,10 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Iterator;
+
 import javax.enterprise.inject.Typed;
-import org.apache.deltaspike.core.util.proxy.DeltaSpikeProxyFactory;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxyFactory;
 
 @Typed
 public class PartialBeanProxyFactory extends DeltaSpikeProxyFactory

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/pom.xml b/deltaspike/modules/pom.xml
index 5db2f88..396291f 100644
--- a/deltaspike/modules/pom.xml
+++ b/deltaspike/modules/pom.xml
@@ -35,6 +35,7 @@
     <name>Apache DeltaSpike Modules</name>
 
     <modules>
+        <module>proxy-utils</module>
         <module>security</module>
         <module>jpa</module>
         <module>servlet</module>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/pom.xml b/deltaspike/modules/proxy-utils/api/pom.xml
new file mode 100644
index 0000000..8c30e1b
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.deltaspike.modules</groupId>
+		<artifactId>proxy-utils-module-project</artifactId>
+		<version>1.3.1-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>deltaspike-proxy-module-api</artifactId>
+
+	<name>Apache DeltaSpike Proxy-Module API</name>
+    
+        <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>2.3</version>
+                <configuration>
+                    <shadedArtifactAttached>false</shadedArtifactAttached>
+                    <createDependencyReducedPom>false</createDependencyReducedPom>
+                    <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+                    <relocations>
+                        <relocation>
+                            <pattern>org.objectweb.asm</pattern>
+                            <shadedPattern>org.apache.deltaspike.proxyutils.asm5</shadedPattern>
+                        </relocation>
+                    </relocations>
+                    <artifactSet>
+                        <includes>
+                            <include>org.ow2.asm:asm</include>
+                            <include>org.ow2.asm:asm-commons</include>
+                            <include>org.ow2.asm:asm-tree</include>
+                        </includes>
+                    </artifactSet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.deltaspike.core</groupId>
+			<artifactId>deltaspike-core-api</artifactId>
+		</dependency>
+        <dependency>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm</artifactId>
+            <version>5.0.3</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm-commons</artifactId>
+            <version>5.0.3</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.ow2.asm</groupId>
+            <artifactId>asm-tree</artifactId>
+            <version>5.0.3</version>
+            <optional>true</optional>
+        </dependency>
+	</dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/AbstractManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/AbstractManualInvocationHandler.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/AbstractManualInvocationHandler.java
new file mode 100644
index 0000000..603eb55
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/AbstractManualInvocationHandler.java
@@ -0,0 +1,104 @@
+/*
+ * 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.proxy.invocation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+
+@Typed
+public abstract class AbstractManualInvocationHandler implements InvocationHandler
+{
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] parameters) throws Throwable
+    {
+        List<Interceptor<?>> interceptors = resolveInterceptors(proxy, method);
+        if (interceptors != null && interceptors.size() > 0)
+        {
+            try
+            {
+                ManualInvocationContext invocationContext =
+                        new ManualInvocationContext(this, interceptors, proxy, method, parameters, null);
+
+                Object returnValue = invocationContext.proceed();
+
+                if (invocationContext.isProceedOriginal())
+                {
+                    return invocationContext.getProceedOriginalReturnValue();
+                }
+
+                return returnValue;
+            }
+            catch (ManualInvocationThrowableWrapperException e)
+            {
+                throw e.getCause();
+            }
+        }
+
+        return proceedOriginal(proxy, method, parameters);
+    }
+
+    protected abstract Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable;
+
+    protected List<Interceptor<?>> resolveInterceptors(Object instance, Method method)
+    {
+        Annotation[] interceptorBindings = extractInterceptorBindings(instance, method);
+        if (interceptorBindings.length > 0)
+        {
+            BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
+            return beanManager.resolveInterceptors(InterceptionType.AROUND_INVOKE, interceptorBindings);
+        }
+
+        return null;
+    }
+
+    // TODO stereotypes
+    protected Annotation[] extractInterceptorBindings(Object instance, Method method)
+    {
+        ArrayList<Annotation> bindings = new ArrayList<Annotation>();
+
+        for (Annotation annotation : instance.getClass().getDeclaredAnnotations())
+        {
+            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class)
+                    && !bindings.contains(annotation))
+            {
+                bindings.add(annotation);
+            }
+        }
+
+        for (Annotation annotation : method.getDeclaredAnnotations())
+        {
+            if (annotation.annotationType().isAnnotationPresent(InterceptorBinding.class)
+                    && !bindings.contains(annotation))
+            {
+                bindings.add(annotation);
+            }
+        }
+
+        return bindings.toArray(new Annotation[bindings.size()]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d7210631/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/DelegateManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/DelegateManualInvocationHandler.java b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/DelegateManualInvocationHandler.java
new file mode 100644
index 0000000..0d5c947
--- /dev/null
+++ b/deltaspike/modules/proxy-utils/api/src/main/java/org/apache/deltaspike/proxy/invocation/DelegateManualInvocationHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.proxy.invocation;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.Typed;
+
+import org.apache.deltaspike.proxy.util.DeltaSpikeProxy;
+
+@Typed
+public class DelegateManualInvocationHandler extends AbstractManualInvocationHandler
+{
+    private static final DelegateManualInvocationHandler INSTANCE = new DelegateManualInvocationHandler();
+    
+    public static Object staticInvoke(Object proxy, Method method, Object[] parameters) throws Throwable
+    {
+        return INSTANCE.invoke(proxy, method, parameters);
+    }
+    
+    @Override
+    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws Throwable
+    {
+        InvocationHandler delegateInvocationHandler = ((DeltaSpikeProxy) proxy).getDelegateInvocationHandler();
+        return delegateInvocationHandler.invoke(proxy, method, parameters);
+    }
+}