deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-823 small cleanup
Date Sun, 01 Mar 2015 21:02:04 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 241a0103b -> 68cd621ec


DELTASPIKE-823 small cleanup

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

Branch: refs/heads/master
Commit: 68cd621ec370a22584dca820f4850bf041cf10b7
Parents: 241a010
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Sun Mar 1 22:01:54 2015 +0100
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Sun Mar 1 22:01:54 2015 +0100

----------------------------------------------------------------------
 .../impl/PartialBeanBindingExtension.java       | 12 ++-----
 .../partialbean/impl/PartialBeanDescriptor.java | 36 ++++++--------------
 .../interception/ManualInvocationContext.java   | 26 ++------------
 .../interception/ManualInvocationHandler.java   | 16 +++------
 ...nualInvocationThrowableWrapperException.java | 31 -----------------
 5 files changed, 21 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/68cd621e/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 4eff57f..6663c56 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
@@ -84,18 +84,12 @@ public class PartialBeanBindingExtension implements Extension, Deactivatable
 
             if (descriptor == null)
             {
-                descriptor = new PartialBeanDescriptor(bindingClass);
-            }
-
-            if (descriptor.getClasses() == null)
-            {
-                descriptor.setClasses(new ArrayList<Class<?>>());
+                descriptor = new PartialBeanDescriptor(bindingClass, null, beanClass);
+                descriptors.put(bindingClass, descriptor);
             }
-
-            if (!descriptor.getClasses().contains(beanClass))
+            else if (!descriptor.getClasses().contains(beanClass))
             {
                 descriptor.getClasses().add(beanClass);
-                descriptors.put(bindingClass, descriptor);
             }
         }
         else if (InvocationHandler.class.isAssignableFrom(beanClass))

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/68cd621e/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanDescriptor.java
b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanDescriptor.java
index 02bb098..056f4be 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanDescriptor.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanDescriptor.java
@@ -20,50 +20,36 @@ package org.apache.deltaspike.partialbean.impl;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
 
 public class PartialBeanDescriptor
 {
     private Class<? extends Annotation> binding;
     private Class<? extends InvocationHandler> handler;
-    private List<Class<?>> classes;
+    private Set<Class<?>> classes;
 
     public PartialBeanDescriptor(Class<? extends Annotation> binding)
     {
         this.binding = binding;
+        this.classes = new HashSet<Class<?>>();
     }
 
     public PartialBeanDescriptor(Class<? extends Annotation> binding,
             Class<? extends InvocationHandler> handler)
     {
-        this.binding = binding;
-        this.handler = handler;
-    }
-
-    public PartialBeanDescriptor(Class<? extends Annotation> binding,
-            Class<? extends InvocationHandler> handler,
-            Class<?>... classes)
-    {
-        this.binding = binding;
+        this(binding);
         this.handler = handler;
-        this.classes = new ArrayList<Class<?>>();
-        if (classes.length > 0)
-        {
-            this.classes.addAll(Arrays.asList(classes));
-        }
     }
 
     public PartialBeanDescriptor(Class<? extends Annotation> binding,
             Class<? extends InvocationHandler> handler,
-            List<Class<?>> classes)
+            Class<?> clazz)
     {
-        this.binding = binding;
-        this.handler = handler;
-        this.classes = classes;
+        this(binding, handler);
+        this.classes.add(clazz);
     }
-
+    
     public Class<? extends Annotation> getBinding()
     {
         return binding;
@@ -84,12 +70,12 @@ public class PartialBeanDescriptor
         this.handler = handler;
     }
 
-    public List<Class<?>> getClasses()
+    public Set<Class<?>> getClasses()
     {
         return classes;
     }
 
-    public void setClasses(List<Class<?>> classes)
+    public void setClasses(Set<Class<?>> classes)
     {
         this.classes = classes;
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/68cd621e/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationContext.java
b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationContext.java
index dee3751..126d659 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationContext.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationContext.java
@@ -116,15 +116,7 @@ public class ManualInvocationContext<T, H> implements InvocationContext
                         extractProceedOriginalMethodException(e);
                 if (proceedOriginalMethodException != null)
                 {
-                    try
-                    {
-                        return manualInvocationHandler.proceedOriginal(target, method, parameters);
-                    }
-                    catch (Throwable t)
-                    {
-                        // wrap it to rethrow the original Throwable later
-                        throw new ManualInvocationThrowableWrapperException(t);
-                    }
+                    return manualInvocationHandler.proceedOriginal(target, method, parameters);
                 }
 
                 throw e;
@@ -144,20 +136,8 @@ public class ManualInvocationContext<T, H> implements InvocationContext
         }
 
         // all interceptors handled without return a value
-        try
-        {
-            Object value = manualInvocationHandler.proceedOriginal(target, method, parameters);
-            return value;
-        }
-        catch (Exception e)
-        {
-            throw e;
-        }
-        catch (Throwable t)
-        {
-            // wrap it to rethrow the original Throwable later
-            throw new ManualInvocationThrowableWrapperException(t);
-        }
+        Object value = manualInvocationHandler.proceedOriginal(target, method, parameters);
+        return value;
     }
 
     protected ProceedOriginalMethodException extractProceedOriginalMethodException(Throwable
throwable)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/68cd621e/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationHandler.java
b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationHandler.java
index 78776b0..5f9a7d6 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationHandler.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationHandler.java
@@ -46,23 +46,15 @@ public class ManualInvocationHandler implements InvocationHandler
         List<Interceptor<?>> interceptors = resolveInterceptors(proxy, method);
         if (interceptors != null && interceptors.size() > 0)
         {
-            try
-            {
-                ManualInvocationContext invocationContext =
-                        new ManualInvocationContext(this, interceptors, proxy, method, parameters,
null);
-                return invocationContext.proceed();
-            }
-            catch (ManualInvocationThrowableWrapperException e)
-            {
-                // unwrap
-                throw e.getCause();
-            }
+            ManualInvocationContext invocationContext =
+                    new ManualInvocationContext(this, interceptors, proxy, method, parameters,
null);
+            return invocationContext.proceed();
         }
 
         return proceedOriginal(proxy, method, parameters);
     }
 
-    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws
Throwable
+    protected Object proceedOriginal(Object proxy, Method method, Object[] parameters) throws
Exception
     {
         throw new ProceedOriginalMethodException();
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/68cd621e/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationThrowableWrapperException.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationThrowableWrapperException.java
b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationThrowableWrapperException.java
deleted file mode 100644
index 1b28b2b..0000000
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/interception/ManualInvocationThrowableWrapperException.java
+++ /dev/null
@@ -1,31 +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.partialbean.impl.interception;
-
-/**
- * Wrapper for {@link Throwable}s because the highest exception of
- * {@link javax.interceptor.InvocationContext#proceed()} is a {@link Exception}.
- */
-public class ManualInvocationThrowableWrapperException extends RuntimeException
-{
-    public ManualInvocationThrowableWrapperException(Throwable e)
-    {
-        super(e);
-    }
-}


Mime
View raw message