deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-547 merged proxy utils
Date Sun, 27 Apr 2014 18:52:13 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 4f217a0bf -> f3a3124d5


DELTASPIKE-547 merged proxy utils


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

Branch: refs/heads/master
Commit: f3a3124d5ab995c78b1a4bc7bf70a0f598232497
Parents: 4f217a0
Author: gpetracek <gpetracek@apache.org>
Authored: Sun Apr 27 20:49:28 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Sun Apr 27 20:49:28 2014 +0200

----------------------------------------------------------------------
 .../apache/deltaspike/core/util/ProxyUtils.java | 26 ++++++++++
 .../data/impl/handler/QueryHandler.java         |  5 +-
 .../deltaspike/data/impl/util/ProxyUtils.java   | 53 --------------------
 3 files changed, 28 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f3a3124d/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
index c0b87c2..1deb060 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
@@ -19,6 +19,10 @@
 package org.apache.deltaspike.core.util;
 
 import javax.enterprise.inject.Typed;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * Helper for proxies
@@ -59,4 +63,26 @@ public abstract class ProxyUtils
         return currentClass.getName().startsWith(currentClass.getSuperclass().getName())
&&
             currentClass.getName().contains("$$");
     }
+
+    public static List<Class<?>> getProxyAndBaseTypes(Class<?> proxyClass)
+    {
+        List<Class<?>> result = new ArrayList<Class<?>>();
+        result.add(proxyClass);
+        if (isInterfaceProxy(proxyClass))
+        {
+            result.addAll(Arrays.asList(proxyClass.getInterfaces()));
+        }
+        else
+        {
+            result.add(proxyClass.getSuperclass());
+        }
+        return result;
+    }
+
+    public static boolean isInterfaceProxy(Class<?> proxyClass)
+    {
+        Class<?>[] interfaces = proxyClass.getInterfaces();
+        return Proxy.class.equals(proxyClass.getSuperclass()) &&
+                interfaces != null && interfaces.length > 0;
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f3a3124d/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
index 4a0ecd0..b2da59d 100755
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
@@ -18,8 +18,6 @@
  */
 package org.apache.deltaspike.data.impl.handler;
 
-import static org.apache.deltaspike.data.impl.util.ProxyUtils.extractFromProxy;
-
 import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
@@ -31,6 +29,7 @@ import javax.inject.Inject;
 import javax.persistence.PersistenceException;
 
 import org.apache.deltaspike.core.api.lifecycle.Initialized;
+import org.apache.deltaspike.core.util.ProxyUtils;
 import org.apache.deltaspike.data.api.QueryInvocationException;
 import org.apache.deltaspike.data.api.Repository;
 import org.apache.deltaspike.data.impl.builder.QueryBuilder;
@@ -72,7 +71,7 @@ public class QueryHandler implements Serializable, InvocationHandler
         CdiQueryInvocationContext queryContext = null;
         try
         {
-            List<Class<?>> candidates = extractFromProxy(proxy.getClass());
+            List<Class<?>> candidates = ProxyUtils.getProxyAndBaseTypes(proxy.getClass());
             RepositoryComponent repo = components.lookupComponent(candidates);
             RepositoryMethod repoMethod = components.lookupMethod(repo.getRepositoryClass(),
method);
             queryContext = createContext(proxy, method, args, repo, repoMethod);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f3a3124d/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/ProxyUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/ProxyUtils.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/ProxyUtils.java
deleted file mode 100644
index d683e32..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/util/ProxyUtils.java
+++ /dev/null
@@ -1,53 +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.data.impl.util;
-
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-public class ProxyUtils
-{
-    private ProxyUtils()
-    {
-    }
-
-    public static List<Class<?>> extractFromProxy(Class<?> proxyClass)
-    {
-        List<Class<?>> result = new LinkedList<Class<?>>();
-        result.add(proxyClass);
-        if (isInterfaceProxy(proxyClass))
-        {
-            result.addAll(Arrays.asList(proxyClass.getInterfaces()));
-        }
-        else
-        {
-            result.add(proxyClass.getSuperclass());
-        }
-        return result;
-    }
-
-    public static boolean isInterfaceProxy(Class<?> proxyClass)
-    {
-        Class<?>[] interfaces = proxyClass.getInterfaces();
-        return Proxy.class.equals(proxyClass.getSuperclass()) &&
-                interfaces != null && interfaces.length > 0;
-    }
-}


Mime
View raw message