deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-517 improved weld-support
Date Fri, 07 Feb 2014 13:00:20 GMT
Updated Branches:
  refs/heads/master d3d8cd081 -> 6c0169550


DELTASPIKE-517 improved weld-support


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

Branch: refs/heads/master
Commit: 6c0169550c2f282d38d7b1103db493704f522864
Parents: d3d8cd0
Author: gpetracek <gpetracek@apache.org>
Authored: Fri Feb 7 13:51:18 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Fri Feb 7 13:54:53 2014 +0100

----------------------------------------------------------------------
 .../apache/deltaspike/core/util/ProxyUtils.java | 57 ++++++++++++++++++++
 .../ResourceLocalTransactionStrategy.java       |  5 +-
 .../transaction/TransactionStrategyHelper.java  |  5 +-
 .../impl/extension/DefaultSecurityStrategy.java |  7 ++-
 4 files changed, 70 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6c016955/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
new file mode 100644
index 0000000..7360986
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.util;
+
+import javax.enterprise.inject.Typed;
+
+/**
+ * Helper for proxies
+ */
+@Typed()
+public abstract class ProxyUtils
+{
+    private ProxyUtils()
+    {
+        // prevent instantiation
+    }
+
+    /**
+     * @param currentClass current class
+     * @return class of the real implementation
+     */
+    public static Class getUnproxiedClass(Class currentClass)
+    {
+        if (isProxiedClass(currentClass))
+        {
+            return currentClass.getSuperclass();
+        }
+        return currentClass;
+    }
+
+    /**
+     * Analyses if the given class is a generated proxy class
+     * @param currentClass current class
+     * @return true if the given class is a known proxy class, false otherwise
+     */
+    public static boolean isProxiedClass(Class currentClass)
+    {
+        return currentClass.getName().startsWith(currentClass.getSuperclass().getName())
&&
+            currentClass.getName().contains("$$");
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6c016955/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java
b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java
index 7f0f118..717206c 100644
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/ResourceLocalTransactionStrategy.java
@@ -20,6 +20,7 @@ package org.apache.deltaspike.jpa.impl.transaction;
 
 
 import org.apache.deltaspike.core.api.literal.AnyLiteral;
+import org.apache.deltaspike.core.util.ProxyUtils;
 import org.apache.deltaspike.jpa.api.transaction.Transactional;
 import org.apache.deltaspike.jpa.impl.transaction.context.EntityManagerEntry;
 import org.apache.deltaspike.jpa.impl.transaction.context.TransactionBeanStorage;
@@ -73,9 +74,11 @@ public class ResourceLocalTransactionStrategy implements TransactionStrategy
     {
         Transactional transactionalAnnotation = transactionHelper.extractTransactionalAnnotation(invocationContext);
 
+        Class targetClass = ProxyUtils.getUnproxiedClass(invocationContext.getTarget().getClass());
//see DELTASPIKE-517
+
         // all the configured qualifier keys
         Set<Class<? extends Annotation>> emQualifiers = transactionHelper.resolveEntityManagerQualifiers(
-                    transactionalAnnotation, invocationContext.getTarget().getClass());
+                    transactionalAnnotation, targetClass);
 
         TransactionBeanStorage transactionBeanStorage = TransactionBeanStorage.getInstance();
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6c016955/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/TransactionStrategyHelper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/TransactionStrategyHelper.java
b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/TransactionStrategyHelper.java
index 3bf92d1..9025139 100644
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/TransactionStrategyHelper.java
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/TransactionStrategyHelper.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.jpa.impl.transaction;
 
+import org.apache.deltaspike.core.util.ProxyUtils;
 import org.apache.deltaspike.jpa.api.transaction.Transactional;
 
 import javax.enterprise.context.Dependent;
@@ -158,8 +159,10 @@ public class TransactionStrategyHelper implements Serializable
 
         if (transactionalAnnotation == null)
         {
+            Class targetClass = ProxyUtils.getUnproxiedClass(context.getTarget().getClass());
//see DELTASPIKE-517
+
             // and if not found search on the class
-            transactionalAnnotation = extractTransactionalAnnotation(context.getTarget().getClass().getAnnotations());
+            transactionalAnnotation = extractTransactionalAnnotation(targetClass.getAnnotations());
         }
         return transactionalAnnotation;
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6c016955/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/DefaultSecurityStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/DefaultSecurityStrategy.java
b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/DefaultSecurityStrategy.java
index 76e6f1d..2bd9d98 100644
--- a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/DefaultSecurityStrategy.java
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/extension/DefaultSecurityStrategy.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.security.impl.extension;
 
+import org.apache.deltaspike.core.util.ProxyUtils;
 import org.apache.deltaspike.security.spi.authorization.SecurityStrategy;
 
 import javax.enterprise.context.Dependent;
@@ -50,7 +51,9 @@ public class DefaultSecurityStrategy implements SecurityStrategy
 
         SecurityMetaDataStorage metaDataStorage = securityExtension.getMetaDataStorage();
 
-        for (Authorizer authorizer : metaDataStorage.getAuthorizers(invocationContext.getTarget().getClass(),
method))
+        Class targetClass = ProxyUtils.getUnproxiedClass(invocationContext.getTarget().getClass());
//see DELTASPIKE-517
+
+        for (Authorizer authorizer : metaDataStorage.getAuthorizers(targetClass, method))
         {
             if (authorizer.isBeforeMethodInvocationAuthorizer())
             {
@@ -60,7 +63,7 @@ public class DefaultSecurityStrategy implements SecurityStrategy
 
         Object result = invocationContext.proceed();
 
-        for (Authorizer authorizer : metaDataStorage.getAuthorizers(invocationContext.getTarget().getClass(),
method))
+        for (Authorizer authorizer : metaDataStorage.getAuthorizers(targetClass, method))
         {
             if (authorizer.isAfterMethodInvocationAuthorizer())
             {


Mime
View raw message