deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [2/2] deltaspike git commit: DELTASPIKE-1070 Refactor RepositoryComponent/s
Date Sun, 04 Jun 2017 00:00:40 GMT
DELTASPIKE-1070 Refactor RepositoryComponent/s

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

Branch: refs/heads/master
Commit: 46a3b6759fabb55fd2b913b9f7b4635687d0c5d7
Parents: fbf62e3
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Sun Jun 4 02:00:14 2017 +0200
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Sun Jun 4 02:00:14 2017 +0200

----------------------------------------------------------------------
 .../data/spi/QueryInvocationContext.java        |   1 -
 .../data/impl/RepositoryExtension.java          |  81 ++----
 .../impl/builder/AnnotatedQueryBuilder.java     |   4 +-
 .../data/impl/builder/DelegateQueryBuilder.java |   4 +-
 .../data/impl/builder/MethodQueryBuilder.java   |   6 +-
 .../data/impl/builder/QueryBuilderFactory.java  |  22 +-
 .../data/impl/builder/part/AndQueryPart.java    |   4 +-
 .../builder/part/BasePropertyQueryPart.java     |   7 +-
 .../data/impl/builder/part/OrQueryPart.java     |   4 +-
 .../impl/builder/part/OrderByQueryPart.java     |   6 +-
 .../impl/builder/part/PropertyQueryPart.java    |   4 +-
 .../data/impl/builder/part/QueryPart.java       |   4 +-
 .../data/impl/builder/part/QueryRoot.java       |  16 +-
 .../builder/result/QueryProcessorFactory.java   |  13 +-
 .../impl/handler/CdiQueryInvocationContext.java | 100 +++++--
 .../impl/handler/EntityManagerRefLookup.java    |  15 +-
 .../impl/handler/EntityRepositoryHandler.java   |   2 +-
 .../data/impl/handler/QueryHandler.java         |  29 +-
 .../data/impl/meta/EntityMetadata.java          | 101 +++++++
 .../impl/meta/EntityMetadataInitializer.java    | 118 +++++++++
 .../deltaspike/data/impl/meta/MethodPrefix.java | 188 -------------
 .../deltaspike/data/impl/meta/MethodType.java   |  36 ---
 .../data/impl/meta/QueryInvocation.java         |   2 +-
 .../data/impl/meta/QueryInvocationLiteral.java  |   6 +-
 .../data/impl/meta/RepositoryComponent.java     | 263 -------------------
 .../data/impl/meta/RepositoryComponents.java    | 129 ---------
 .../impl/meta/RepositoryComponentsFactory.java  |  44 ----
 .../data/impl/meta/RepositoryEntity.java        | 101 -------
 .../data/impl/meta/RepositoryMetadata.java      | 107 ++++++++
 .../impl/meta/RepositoryMetadataHandler.java    | 111 ++++++++
 .../meta/RepositoryMetadataInitializer.java     | 143 ++++++++++
 .../data/impl/meta/RepositoryMethod.java        | 257 ------------------
 .../impl/meta/RepositoryMethodMetadata.java     | 155 +++++++++++
 .../RepositoryMethodMetadataInitializer.java    | 170 ++++++++++++
 .../data/impl/meta/RepositoryMethodPrefix.java  | 188 +++++++++++++
 .../data/impl/meta/RepositoryMethodType.java    |  36 +++
 .../extractor/AnnotationMetadataExtractor.java  |  41 ---
 .../impl/meta/extractor/MetadataExtractor.java  |  34 ---
 .../meta/extractor/TypeMetadataExtractor.java   |  99 -------
 .../deltaspike/data/impl/param/Parameters.java  |  12 +-
 .../data/impl/tx/TransactionalQueryRunner.java  |  25 +-
 .../data/impl/builder/part/QueryRootTest.java   |  16 +-
 .../impl/handler/CdiQueryContextHolderTest.java |  23 +-
 .../data/impl/meta/MethodPrefixTest.java        |  14 +-
 .../AnnotationMetadataExtractorTest.java        |  84 ------
 .../extractor/TypeMetadataExtractorTest.java    |  64 -----
 .../impl/meta/unit/PersistenceUnitsTest.java    |  12 +-
 47 files changed, 1361 insertions(+), 1540 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/spi/QueryInvocationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/spi/QueryInvocationContext.java b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/spi/QueryInvocationContext.java
index daab9d8..a92d29b 100644
--- a/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/spi/QueryInvocationContext.java
+++ b/deltaspike/modules/data/api/src/main/java/org/apache/deltaspike/data/spi/QueryInvocationContext.java
@@ -26,7 +26,6 @@ import java.lang.reflect.Method;
  */
 public interface QueryInvocationContext
 {
-
     /**
      * Entity Manager used for the query.
      */

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/RepositoryExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/RepositoryExtension.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/RepositoryExtension.java
index 7c2fa15..0bd76fb 100755
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/RepositoryExtension.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/RepositoryExtension.java
@@ -19,15 +19,12 @@
 package org.apache.deltaspike.data.impl;
 
 import java.lang.reflect.InvocationHandler;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.ArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.BeforeShutdown;
 import javax.enterprise.inject.spi.Extension;
@@ -38,7 +35,6 @@ import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.data.api.AbstractEntityRepository;
 import org.apache.deltaspike.data.api.AbstractFullEntityRepository;
 import org.apache.deltaspike.data.api.Repository;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponents;
 
 /**
  * The main extension class for Repositories, based on PartialBeans. Handles following events:<br/>
@@ -56,18 +52,15 @@ import org.apache.deltaspike.data.impl.meta.RepositoryComponents;
  */
 public class RepositoryExtension implements Extension, Deactivatable
 {
+    private static final Logger LOG = Logger.getLogger(RepositoryExtension.class.getName());
 
-    private static final Logger log = Logger.getLogger(RepositoryExtension.class.getName());
-
-    private static RepositoryComponents staticComponents = new RepositoryComponents();
-
-    private final List<RepositoryDefinitionException> definitionExceptions =
-            new LinkedList<RepositoryDefinitionException>();
+    // TODO: Hack still required?
+    private static final ArrayList<Class<?>> REPOSITORY_CLASSES = new ArrayList<Class<?>>();
 
+    private final ArrayList<Class<?>> repositoryClasses = new ArrayList<Class<?>>();
+    
     private Boolean isActivated = true;
 
-    private RepositoryComponents components = new RepositoryComponents();
-
     void beforeBeanDiscovery(@Observes BeforeBeanDiscovery before)
     {
         isActivated = ClassDeactivationUtils.isActivated(getClass());
@@ -85,44 +78,21 @@ public class RepositoryExtension implements Extension, Deactivatable
         {
             event.veto();
         }
-
         else if (isRepository(event.getAnnotatedType()))
         {
-            Class<X> repoClass = event.getAnnotatedType().getJavaClass();
-            try
-            {
-                log.log(Level.FINER, "getHandlerClass: Repository annotation detected on {0}",
-                        event.getAnnotatedType());
-                if (Deactivatable.class.isAssignableFrom(repoClass)
-                        && !ClassDeactivationUtils.isActivated((Class<? extends Deactivatable>) repoClass))
-                {
-                    log.log(Level.FINER, "Class {0} is Deactivated", repoClass);
-                    return;
-                }
-                components.add(repoClass);
-                staticComponents.add(repoClass);
-            }
-            catch (RepositoryDefinitionException e)
-            {
-                definitionExceptions.add(e);
-            }
-            catch (Exception e)
+            Class<X> repositoryClass = event.getAnnotatedType().getJavaClass();
+
+            LOG.log(Level.FINER, "getHandlerClass: Repository annotation detected on {0}",
+                    event.getAnnotatedType());
+            if (Deactivatable.class.isAssignableFrom(repositoryClass)
+                    && !ClassDeactivationUtils.isActivated((Class<? extends Deactivatable>) repositoryClass))
             {
-                definitionExceptions.add(new RepositoryDefinitionException(repoClass, e));
+                LOG.log(Level.FINER, "Class {0} is Deactivated", repositoryClass);
+                return;
             }
-        }
-    }
 
-    <X> void addDefinitionErrors(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
-    {
-        if (!isActivated)
-        {
-            return;
-        }
-
-        for (RepositoryDefinitionException ex : definitionExceptions)
-        {
-            afterBeanDiscovery.addDefinitionError(ex);
+            repositoryClasses.add(repositoryClass);
+            REPOSITORY_CLASSES.add(repositoryClass);
         }
     }
 
@@ -139,27 +109,28 @@ public class RepositoryExtension implements Extension, Deactivatable
         return javaClass.equals(AbstractEntityRepository.class) ||
                javaClass.equals(AbstractFullEntityRepository.class);
     }
-
-    public RepositoryComponents getComponents()
+    
+    public ArrayList<Class<?>> getRepositoryClasses()
     {
-        RepositoryComponents result = new RepositoryComponents();
-        if (components.getRepositories().isEmpty() && !staticComponents.getRepositories().isEmpty())
+        ArrayList<Class<?>> result = new ArrayList<Class<?>>();
+
+        if (repositoryClasses.isEmpty() && !REPOSITORY_CLASSES.isEmpty())
         {
-            result.addAll(staticComponents.getRepositories());
+            result.addAll(REPOSITORY_CLASSES);
         }
 
-        if (!components.getRepositories().isEmpty())
+        if (!repositoryClasses.isEmpty())
         {
-            result.addAll(components.getRepositories());
+            result.addAll(repositoryClasses);
         }
 
         return result;
     }
-
+    
     protected void cleanup(@Observes BeforeShutdown beforeShutdown)
     {
         //we can reset it in any case,
         //because every application produced a copy as application-scoped bean (see RepositoryComponentsFactory)
-        staticComponents.getRepositories().clear();
+        REPOSITORY_CLASSES.clear();
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
index 7c94043..c27a6c6 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/AnnotatedQueryBuilder.java
@@ -20,7 +20,7 @@ package org.apache.deltaspike.data.impl.builder;
 
 import org.apache.deltaspike.data.api.Query;
 import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext;
-import org.apache.deltaspike.data.impl.meta.MethodType;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodType;
 import org.apache.deltaspike.data.impl.meta.QueryInvocation;
 import org.apache.deltaspike.data.impl.param.Parameters;
 import org.apache.deltaspike.data.impl.util.jpa.QueryStringExtractorFactory;
@@ -37,7 +37,7 @@ import static org.apache.deltaspike.core.util.StringUtils.isNotEmpty;
 /**
  * Create the query based on method annotations.
  */
-@QueryInvocation(MethodType.ANNOTATED)
+@QueryInvocation(RepositoryMethodType.ANNOTATED)
 @ApplicationScoped
 public class AnnotatedQueryBuilder extends QueryBuilder
 {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java
index c17a1f6..e42ee19 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/DelegateQueryBuilder.java
@@ -39,12 +39,12 @@ import org.apache.deltaspike.core.util.OptionalUtil;
 import org.apache.deltaspike.core.util.StreamUtil;
 import org.apache.deltaspike.data.api.QueryInvocationException;
 import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext;
-import org.apache.deltaspike.data.impl.meta.MethodType;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodType;
 import org.apache.deltaspike.data.impl.meta.QueryInvocation;
 import org.apache.deltaspike.data.impl.util.bean.BeanDestroyable;
 import org.apache.deltaspike.data.spi.DelegateQueryHandler;
 
-@QueryInvocation(MethodType.DELEGATE)
+@QueryInvocation(RepositoryMethodType.DELEGATE)
 @ApplicationScoped
 public class DelegateQueryBuilder extends QueryBuilder
 {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
index 850d97f..f9efd1e 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
@@ -23,11 +23,11 @@ import javax.persistence.Query;
 
 import org.apache.deltaspike.data.impl.builder.part.QueryRoot;
 import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext;
-import org.apache.deltaspike.data.impl.meta.MethodType;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodType;
 import org.apache.deltaspike.data.impl.meta.QueryInvocation;
 import org.apache.deltaspike.data.impl.param.Parameters;
 
-@QueryInvocation(MethodType.PARSE)
+@QueryInvocation(RepositoryMethodType.PARSE)
 @ApplicationScoped
 public class MethodQueryBuilder extends QueryBuilder
 {
@@ -42,7 +42,7 @@ public class MethodQueryBuilder extends QueryBuilder
     private Query createJpaQuery(CdiQueryInvocationContext context)
     {
         Parameters params = context.getParams();
-        QueryRoot root = context.getRepositoryMethod().getQueryRoot();
+        QueryRoot root = context.getRepositoryMethodMetadata().getQueryRoot();
         String jpqlQuery = context.applyQueryStringPostProcessors(root.getJpqlQuery());
         context.setQueryString(jpqlQuery);
         params.updateValues(root.getParameterUpdates());

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderFactory.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderFactory.java
index 9c5625d..77a8653 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderFactory.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderFactory.java
@@ -18,9 +18,9 @@
  */
 package org.apache.deltaspike.data.impl.builder;
 
-import static org.apache.deltaspike.data.impl.meta.MethodType.ANNOTATED;
-import static org.apache.deltaspike.data.impl.meta.MethodType.DELEGATE;
-import static org.apache.deltaspike.data.impl.meta.MethodType.PARSE;
+import static org.apache.deltaspike.data.impl.meta.RepositoryMethodType.ANNOTATED;
+import static org.apache.deltaspike.data.impl.meta.RepositoryMethodType.DELEGATE;
+import static org.apache.deltaspike.data.impl.meta.RepositoryMethodType.PARSE;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -29,15 +29,15 @@ import javax.enterprise.context.ApplicationScoped;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.data.api.QueryResult;
 import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext;
-import org.apache.deltaspike.data.impl.meta.MethodType;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodType;
 import org.apache.deltaspike.data.impl.meta.QueryInvocationLiteral;
-import org.apache.deltaspike.data.impl.meta.RepositoryMethod;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodMetadata;
 
 @ApplicationScoped
 public class QueryBuilderFactory
 {
-    private static final Map<MethodType, QueryInvocationLiteral> LITERALS =
-            new HashMap<MethodType, QueryInvocationLiteral>()
+    private static final Map<RepositoryMethodType, QueryInvocationLiteral> LITERALS =
+            new HashMap<RepositoryMethodType, QueryInvocationLiteral>()
             {
                 private static final long serialVersionUID = 1L;
 
@@ -48,14 +48,16 @@ public class QueryBuilderFactory
                 }
             };
 
-    public QueryBuilder build(RepositoryMethod method, CdiQueryInvocationContext context)
+    public QueryBuilder build(RepositoryMethodMetadata methodMetadata, CdiQueryInvocationContext context)
     {
         QueryBuilder builder = BeanProvider.getContextualReference(
-                QueryBuilder.class, LITERALS.get(method.getMethodType()));
-        if (method.returns(QueryResult.class))
+                QueryBuilder.class, LITERALS.get(methodMetadata.getMethodType()));
+
+        if (QueryResult.class.equals(methodMetadata.getMethod().getReturnType()))
         {
             return new WrappedQueryBuilder(builder);
         }
+
         return builder;
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/AndQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/AndQueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/AndQueryPart.java
index 643395b..2b6747e 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/AndQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/AndQueryPart.java
@@ -19,7 +19,7 @@
 package org.apache.deltaspike.data.impl.builder.part;
 
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 
 class AndQueryPart extends ConnectingQueryPart
 {
@@ -30,7 +30,7 @@ class AndQueryPart extends ConnectingQueryPart
     }
 
     @Override
-    protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
+    protected QueryPart build(String queryPart, String method, RepositoryMetadata repo)
     {
         children.add(new PropertyQueryPart().build(queryPart, method, repo));
         return this;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/BasePropertyQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/BasePropertyQueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/BasePropertyQueryPart.java
index 13d2ac1..a2ac886 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/BasePropertyQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/BasePropertyQueryPart.java
@@ -19,7 +19,7 @@
 package org.apache.deltaspike.data.impl.builder.part;
 
 import org.apache.deltaspike.data.impl.builder.MethodExpressionException;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 import org.apache.deltaspike.data.impl.property.Property;
 import org.apache.deltaspike.data.impl.property.query.NamedPropertyCriteria;
 import org.apache.deltaspike.data.impl.property.query.PropertyQueries;
@@ -27,12 +27,11 @@ import org.apache.deltaspike.data.impl.property.query.PropertyQuery;
 
 abstract class BasePropertyQueryPart extends QueryPart
 {
-
     static final String SEPARATOR = "_";
 
-    void validate(String name, String method, RepositoryComponent repo)
+    void validate(String name, String method, RepositoryMetadata repo)
     {
-        Class<?> current = repo.getEntityClass();
+        Class<?> current = repo.getEntityMetadata().getEntityClass();
         if (name == null)
         {
             throw new MethodExpressionException(null, repo.getRepositoryClass(), method);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrQueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrQueryPart.java
index 8060165..d54ff04 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrQueryPart.java
@@ -21,7 +21,7 @@ package org.apache.deltaspike.data.impl.builder.part;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.splitByKeyword;
 
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 
 
 class OrQueryPart extends ConnectingQueryPart
@@ -33,7 +33,7 @@ class OrQueryPart extends ConnectingQueryPart
     }
 
     @Override
-    protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
+    protected QueryPart build(String queryPart, String method, RepositoryMetadata repo)
     {
         String[] andParts = splitByKeyword(queryPart, "And");
         boolean first = true;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
index f1ebb3b..c4b241e 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/OrderByQueryPart.java
@@ -31,19 +31,17 @@ import java.util.TreeSet;
 
 import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
-
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 
 public class OrderByQueryPart extends BasePropertyQueryPart
 {
-
     private static final String KEYWORD_ASC = "Asc";
     private static final String KEYWORD_DESC = "Desc";
 
     private final List<OrderByQueryAttribute> attributes = new LinkedList<OrderByQueryAttribute>();
 
     @Override
-    protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
+    protected QueryPart build(String queryPart, String method, RepositoryMetadata repo)
     {
         Set<String> collect = new TreeSet<String>();
         List<String> ascSplit = new LinkedList<String>();

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
index e0fe3aa..88d1e58 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
@@ -25,7 +25,7 @@ import java.text.MessageFormat;
 import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
 import org.apache.deltaspike.data.impl.builder.QueryOperator;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 import org.apache.deltaspike.data.impl.param.ToUpperStringParameterUpdate;
 
 class PropertyQueryPart extends BasePropertyQueryPart
@@ -35,7 +35,7 @@ class PropertyQueryPart extends BasePropertyQueryPart
     private QueryOperator comparator;
 
     @Override
-    protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
+    protected QueryPart build(String queryPart, String method, RepositoryMetadata repo)
     {
         comparator = QueryOperator.Equal;
         name = uncapitalize(queryPart);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryPart.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryPart.java
index 45acb05..4329895 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryPart.java
@@ -23,14 +23,14 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 
 public abstract class QueryPart
 {
 
     protected List<QueryPart> children = new LinkedList<QueryPart>();
 
-    protected abstract QueryPart build(String queryPart, String method, RepositoryComponent repo);
+    protected abstract QueryPart build(String queryPart, String method, RepositoryMetadata repo);
 
     protected abstract QueryPart buildQuery(QueryBuilderContext ctx);
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
index 767efa1..80ec18d 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
@@ -29,8 +29,8 @@ import java.util.logging.Logger;
 import org.apache.deltaspike.data.impl.builder.MethodExpressionException;
 import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
-import org.apache.deltaspike.data.impl.meta.MethodPrefix;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodPrefix;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 import org.apache.deltaspike.data.impl.param.ParameterUpdate;
 
 /**
@@ -39,25 +39,25 @@ import org.apache.deltaspike.data.impl.param.ParameterUpdate;
 public class QueryRoot extends QueryPart
 {
 
-    public static final QueryRoot UNKNOWN_ROOT = new QueryRoot("null-object", new MethodPrefix("", null));
+    public static final QueryRoot UNKNOWN_ROOT = new QueryRoot("null-object", new RepositoryMethodPrefix("", null));
 
     private static final Logger log = Logger.getLogger(QueryRoot.class.getName());
 
     private final String entityName;
-    private final MethodPrefix methodPrefix;
+    private final RepositoryMethodPrefix methodPrefix;
 
     private String jpqlQuery;
     private List<ParameterUpdate> paramUpdates;
 
-    protected QueryRoot(String entityName, MethodPrefix methodPrefix)
+    protected QueryRoot(String entityName, RepositoryMethodPrefix methodPrefix)
     {
         this.entityName = entityName;
         this.methodPrefix = methodPrefix;
     }
 
-    public static QueryRoot create(String method, RepositoryComponent repo, MethodPrefix prefix)
+    public static QueryRoot create(String method, RepositoryMetadata repo, RepositoryMethodPrefix prefix)
     {
-        QueryRoot root = new QueryRoot(repo.getEntityName(), prefix);
+        QueryRoot root = new QueryRoot(repo.getEntityMetadata().getEntityName(), prefix);
         root.build(method, method, repo);
         root.createJpql();
         return root;
@@ -74,7 +74,7 @@ public class QueryRoot extends QueryPart
     }
 
     @Override
-    protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
+    protected QueryPart build(String queryPart, String method, RepositoryMetadata repo)
     {
         String[] orderByParts = splitByKeyword(queryPart, "OrderBy");
         if (hasQueryConditions(orderByParts))

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/result/QueryProcessorFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/result/QueryProcessorFactory.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/result/QueryProcessorFactory.java
index 4bc5777..247a4a2 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/result/QueryProcessorFactory.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/result/QueryProcessorFactory.java
@@ -30,21 +30,21 @@ import org.apache.deltaspike.data.api.Modifying;
 import org.apache.deltaspike.data.api.QueryResult;
 import org.apache.deltaspike.data.api.SingleResultType;
 import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext;
-import org.apache.deltaspike.data.impl.meta.MethodPrefix;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodPrefix;
 
 public final class QueryProcessorFactory
 {
 
     private final Method method;
-    private final MethodPrefix methodPrefix;
+    private final RepositoryMethodPrefix methodPrefix;
 
     private QueryProcessorFactory(Method method)
     {
         this.method = method;
-        this.methodPrefix = new MethodPrefix("", method.getName());
+        this.methodPrefix = new RepositoryMethodPrefix("", method.getName());
     }
 
-    private QueryProcessorFactory(Method method, MethodPrefix methodPrefix)
+    private QueryProcessorFactory(Method method, RepositoryMethodPrefix methodPrefix)
     {
         this.method = method;
         this.methodPrefix = methodPrefix;
@@ -55,7 +55,7 @@ public final class QueryProcessorFactory
         return new QueryProcessorFactory(method);
     }
 
-    public static QueryProcessorFactory newInstance(Method method, MethodPrefix methodPrefix)
+    public static QueryProcessorFactory newInstance(Method method, RepositoryMethodPrefix methodPrefix)
     {
         return new QueryProcessorFactory(method, methodPrefix);
     }
@@ -151,7 +151,8 @@ public final class QueryProcessorFactory
                     List<Object> queryResult = query.getResultList();
                     result = !queryResult.isEmpty() ? queryResult.get(0) : null;
             }
-            if (context.isOptional())
+            
+            if (context.isOptionalAsReturnType())
             {
                 return OptionalUtil.wrap(result);
             }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/CdiQueryInvocationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/CdiQueryInvocationContext.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/CdiQueryInvocationContext.java
index 1adee68..09611f7 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/CdiQueryInvocationContext.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/CdiQueryInvocationContext.java
@@ -27,15 +27,20 @@ import javax.persistence.EntityManager;
 import javax.persistence.LockModeType;
 import javax.persistence.Query;
 import javax.persistence.QueryHint;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.api.provider.DependentProvider;
 
 import org.apache.deltaspike.data.api.EntityGraph;
 import org.apache.deltaspike.data.api.SingleResultType;
 import org.apache.deltaspike.data.api.mapping.QueryInOutMapper;
 import org.apache.deltaspike.data.impl.graph.EntityGraphHelper;
-import org.apache.deltaspike.data.impl.meta.RepositoryMethod;
+import org.apache.deltaspike.data.impl.meta.EntityMetadata;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodMetadata;
 import org.apache.deltaspike.data.impl.param.Parameters;
 import org.apache.deltaspike.data.impl.property.Property;
 import org.apache.deltaspike.data.impl.util.EntityUtils;
+import org.apache.deltaspike.data.impl.util.bean.DependentProviderDestroyable;
 import org.apache.deltaspike.data.impl.util.bean.Destroyable;
 import org.apache.deltaspike.data.spi.QueryInvocationContext;
 
@@ -44,27 +49,31 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
 
     private final EntityManager entityManager;
     private final Parameters params;
-    private final Class<?> entityClass;
     private final Object proxy;
     private final Method method;
     private final Object[] args;
-    private final RepositoryMethod repoMethod;
+    
+    private final RepositoryMetadata repositoryMetadata;
+    private final RepositoryMethodMetadata repositoryMethodMetadata;
+    
     private final List<QueryStringPostProcessor> queryPostProcessors;
     private final List<JpaQueryPostProcessor> jpaPostProcessors;
     private final List<Destroyable> cleanup;
 
     private String queryString;
 
-    public CdiQueryInvocationContext(Object proxy, Method method, Object[] args, RepositoryMethod repoMethod,
-                                     EntityManager entityManager)
+    public CdiQueryInvocationContext(Object proxy, Method method, Object[] args,
+            RepositoryMetadata repositoryMetadata,
+            RepositoryMethodMetadata repositoryMethodMetadata, EntityManager entityManager)
     {
-        this.entityManager = entityManager;
-        this.args = args == null ? new Object[]{} : args;
-        this.params = Parameters.create(method, this.args, repoMethod);
         this.proxy = proxy;
         this.method = method;
-        this.repoMethod = repoMethod;
-        this.entityClass = repoMethod.getRepository().getEntityClass();
+        this.args = args == null ? new Object[]{} : args;
+        this.repositoryMetadata = repositoryMetadata;
+        this.repositoryMethodMetadata = repositoryMethodMetadata;
+        this.entityManager = entityManager;
+        
+        this.params = Parameters.create(method, this.args, repositoryMethodMetadata);
         this.queryPostProcessors = new LinkedList<QueryStringPostProcessor>();
         this.jpaPostProcessors = new LinkedList<JpaQueryPostProcessor>();
         this.cleanup = new LinkedList<Destroyable>();
@@ -97,15 +106,13 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
     {
         try
         {
-            Property<Serializable> versionProperty =
-                    repoMethod.getRepository().getRepositoryEntity().getVersionProperty();
+            Property<Serializable> versionProperty = repositoryMetadata.getEntityMetadata().getVersionProperty();
             if (versionProperty != null)
             {
                 return versionProperty.getValue(entity) == null;
             }
 
-            Property<Serializable> primaryKeyProperty =
-                    repoMethod.getRepository().getRepositoryEntity().getPrimaryKeyProperty();
+            Property<Serializable> primaryKeyProperty = repositoryMetadata.getEntityMetadata().getPrimaryKeyProperty();
             if (EntityUtils.primaryKeyValue(entity, primaryKeyProperty) == null)
             {
                 return true;
@@ -128,13 +135,13 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
     @Override
     public Class<?> getEntityClass()
     {
-        return entityClass;
+        return repositoryMetadata.getEntityMetadata().getEntityClass();
     }
 
     @Override
     public Class<?> getRepositoryClass()
     {
-        return repoMethod.getRepository().getRepositoryClass();
+        return repositoryMetadata.getRepositoryClass();
     }
 
     public Object proceed() throws Exception
@@ -238,7 +245,7 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
 
     public Object executeQuery(Query jpaQuery)
     {
-        return repoMethod.getQueryProcessor().executeQuery(jpaQuery, this);
+        return repositoryMethodMetadata.getQueryProcessor().executeQuery(jpaQuery, this);
     }
 
     public Parameters getParams()
@@ -246,11 +253,6 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
         return params;
     }
 
-    public RepositoryMethod getRepositoryMethod()
-    {
-        return repoMethod;
-    }
-
     public String getQueryString()
     {
         return queryString;
@@ -268,18 +270,41 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
 
     public boolean hasQueryInOutMapper()
     {
-        return repoMethod.hasQueryInOutMapper();
+        return repositoryMethodMetadata.getQueryInOutMapperClass() != null;
     }
 
     public QueryInOutMapper<?> getQueryInOutMapper()
     {
-        return repoMethod.getQueryInOutMapperInstance(this);
+        if (repositoryMethodMetadata.getQueryInOutMapperClass() == null)
+        {
+            return null;
+        }
+
+        QueryInOutMapper<?> result = null;
+        if (repositoryMethodMetadata.isQueryInOutMapperIsNormalScope())
+        {
+            result = BeanProvider.getContextualReference(repositoryMethodMetadata.getQueryInOutMapperClass());
+        }
+        else
+        {
+            DependentProvider<? extends QueryInOutMapper<?>> mappedProvider =
+                    BeanProvider.getDependent(repositoryMethodMetadata.getQueryInOutMapperClass());
+            
+            result = mappedProvider.get();
+            
+            this.addDestroyable(new DependentProviderDestroyable(mappedProvider));
+        }
+        
+        return result;
     }
 
     public SingleResultType getSingleResultStyle()
     {
-        SingleResultType baseSingleResultType = repoMethod.getSingleResultStyle();
-        if (repoMethod.isOptional() && baseSingleResultType == SingleResultType.JPA)
+        SingleResultType baseSingleResultType = repositoryMethodMetadata.getQuery() != null
+                ? repositoryMethodMetadata.getQuery().singleResult()
+                : repositoryMethodMetadata.getMethodPrefix().getSingleResultStyle();
+        
+        if (repositoryMethodMetadata.isOptionalAsReturnType() && baseSingleResultType == SingleResultType.JPA)
         {
             return SingleResultType.OPTIONAL;
         }
@@ -334,7 +359,9 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
             return;
         }
         
-        Object graph = EntityGraphHelper.getEntityGraph(getEntityManager(), entityClass, entityGraphAnn);
+        Object graph = EntityGraphHelper.getEntityGraph(getEntityManager(),
+                repositoryMetadata.getEntityMetadata().getEntityClass(),
+                entityGraphAnn);
         query.setHint(entityGraphAnn.type().getHintName(), graph);
     }
 
@@ -356,8 +383,23 @@ public class CdiQueryInvocationContext implements QueryInvocationContext
         return false;
     }
 
-    public boolean isOptional()
+    public boolean isOptionalAsReturnType()
+    {
+        return this.repositoryMethodMetadata.isOptionalAsReturnType();
+    }
+
+    public RepositoryMetadata getRepositoryMetadata()
     {
-        return this.repoMethod.isOptional();
+        return repositoryMetadata;
     }
+
+    public EntityMetadata getEntityMetadata()
+    {
+        return repositoryMetadata.getEntityMetadata();
+    }
+    
+    public RepositoryMethodMetadata getRepositoryMethodMetadata()
+    {
+        return repositoryMethodMetadata;
+    } 
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
index a7066cc..3bec649 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerRefLookup.java
@@ -27,7 +27,7 @@ import javax.persistence.EntityManager;
 import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
 
 import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
 import org.apache.deltaspike.jpa.spi.entitymanager.ActiveEntityManagerHolder;
 
 @ApplicationScoped
@@ -74,16 +74,15 @@ public class EntityManagerRefLookup
         }
     }
     
-    public EntityManagerRef lookupReference(final RepositoryComponent repository)
+    public EntityManagerRef lookupReference(final RepositoryMetadata repositoryMetadata)
     {
         EntityManagerRef ref = new EntityManagerRef();
 
-        if (repository.hasEntityManagerResolver())
+        if (repositoryMetadata.getEntityManagerResolverClass() != null)
         {
-            ref.setEntityManagerResolverClass(
-                    repository.getEntityManagerResolverClass());
+            ref.setEntityManagerResolverClass(repositoryMetadata.getEntityManagerResolverClass());
             
-            if (repository.isEntityManagerResolverIsNormalScope())
+            if (repositoryMetadata.isEntityManagerResolverIsNormalScope())
             {
                 ref.setEntityManagerResolver(
                         BeanProvider.getContextualReference(ref.getEntityManagerResolverClass()));
@@ -127,9 +126,9 @@ public class EntityManagerRefLookup
             }
         }
 
-        if (repository.hasEntityManagerFlushMode())
+        if (repositoryMetadata.getEntityManagerFlushMode() != null)
         {
-            ref.getEntityManager().setFlushMode(repository.getEntityManagerFlushMode());
+            ref.getEntityManager().setFlushMode(repositoryMetadata.getEntityManagerFlushMode());
         }
 
         return ref;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
index 2c731f8..2eb1cce 100755
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityRepositoryHandler.java
@@ -268,7 +268,7 @@ public class EntityRepositoryHandler<E, PK extends Serializable>
 
     public String entityName()
     {
-        return context.getRepositoryMethod().getRepository().getRepositoryEntity().getEntityName();
+        return context.getEntityMetadata().getEntityName();
     }
 
     // ----------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/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 d83e227..455bffd 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,7 +18,6 @@
  */
 package org.apache.deltaspike.data.impl.handler;
 
-import org.apache.deltaspike.core.api.lifecycle.Initialized;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
 import org.apache.deltaspike.core.util.AnnotationUtils;
 import org.apache.deltaspike.core.util.ExceptionUtils;
@@ -29,9 +28,7 @@ import org.apache.deltaspike.data.api.QueryInvocationException;
 import org.apache.deltaspike.data.api.Repository;
 import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderFactory;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
-import org.apache.deltaspike.data.impl.meta.RepositoryComponents;
-import org.apache.deltaspike.data.impl.meta.RepositoryMethod;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadataHandler;
 import org.apache.deltaspike.jpa.api.transaction.Transactional;
 import org.apache.deltaspike.jpa.spi.entitymanager.ActiveEntityManagerHolder;
 import org.apache.deltaspike.jpa.spi.transaction.TransactionStrategy;
@@ -49,6 +46,8 @@ import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.enterprise.context.ApplicationScoped;
+import org.apache.deltaspike.data.impl.meta.RepositoryMetadata;
+import org.apache.deltaspike.data.impl.meta.RepositoryMethodMetadata;
 
 /**
  * Entry point for query processing.
@@ -63,8 +62,7 @@ public class QueryHandler implements Serializable, InvocationHandler
     private QueryBuilderFactory queryBuilderFactory;
 
     @Inject
-    @Initialized
-    private RepositoryComponents components;
+    private RepositoryMetadataHandler metadataHandler;
 
     @Inject
     private CdiQueryContextHolder context;
@@ -137,13 +135,15 @@ public class QueryHandler implements Serializable, InvocationHandler
         try
         {
             List<Class<?>> candidates = ProxyUtils.getProxyAndBaseTypes(proxy.getClass());
-            RepositoryComponent repo = components.lookupComponent(candidates);
-            RepositoryMethod repoMethod = components.lookupMethod(repo, method);
+            RepositoryMetadata repositoryMetadata = metadataHandler.lookupComponent(candidates);
+            RepositoryMethodMetadata repositoryMethodMetadata =
+                    metadataHandler.lookupMethod(repositoryMetadata, method);
 
-            entityManagerRef = entityManagerRefLookup.lookupReference(repo);
-            queryContext = createContext(proxy, method, args, entityManagerRef.getEntityManager(), repoMethod);
+            entityManagerRef = entityManagerRefLookup.lookupReference(repositoryMetadata);
+            queryContext = createContext(proxy, method, args, entityManagerRef.getEntityManager(),
+                    repositoryMetadata, repositoryMethodMetadata);
             
-            QueryBuilder builder = queryBuilderFactory.build(repoMethod, queryContext);
+            QueryBuilder builder = queryBuilderFactory.build(repositoryMethodMetadata, queryContext);
             Object result = runner.executeQuery(builder, queryContext);
             return result;
         }
@@ -171,10 +171,11 @@ public class QueryHandler implements Serializable, InvocationHandler
     }
 
     private CdiQueryInvocationContext createContext(Object proxy, Method method,
-            Object[] args, EntityManager entityManager, RepositoryMethod repoMethod)
+            Object[] args, EntityManager entityManager, RepositoryMetadata repositoryMetadata,
+            RepositoryMethodMetadata repositoryMethodMetadata)
     {
-        CdiQueryInvocationContext queryContext = new CdiQueryInvocationContext(proxy, method, args, repoMethod,
-                entityManager);
+        CdiQueryInvocationContext queryContext = new CdiQueryInvocationContext(proxy, method, args,
+                repositoryMetadata, repositoryMethodMetadata, entityManager);
         context.set(queryContext);
         queryContext.initMapper();
         return queryContext;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadata.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadata.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadata.java
new file mode 100644
index 0000000..bfa9f82
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadata.java
@@ -0,0 +1,101 @@
+/*
+ * 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.meta;
+
+import java.io.Serializable;
+import org.apache.deltaspike.data.impl.property.Property;
+
+public class EntityMetadata
+{
+    private Class<?> entityClass;
+    private Property<Serializable> primaryKeyProperty;
+    private Class<? extends Serializable> primaryKeyClass;
+    private Property<Serializable> versionProperty;
+    private String entityName;
+
+    public EntityMetadata(Class<?> entityClass)
+    {
+        this.entityClass = entityClass;
+    }
+    
+    public EntityMetadata(Class<?> entityClass,
+            Class<? extends Serializable> primaryKeyClass)
+    {
+        this.entityClass = entityClass;
+        this.primaryKeyClass = primaryKeyClass;
+    }
+    
+    public EntityMetadata(Class<?> entityClass, String entityName,
+            Class<? extends Serializable> primaryKeyClass)
+    {
+        this.entityClass = entityClass;
+        this.entityName = entityName;
+        this.primaryKeyClass = primaryKeyClass;
+    }
+    
+    public Class<?> getEntityClass()
+    {
+        return entityClass;
+    }
+
+    public void setEntityClass(Class<?> entityClass)
+    {
+        this.entityClass = entityClass;
+    }
+
+    public Class<? extends Serializable> getPrimaryKeyClass()
+    {
+        return primaryKeyClass;
+    }
+
+    public void setPrimaryKeyClass(Class<? extends Serializable> primaryKeyClass)
+    {
+        this.primaryKeyClass = primaryKeyClass;
+    }
+
+    public Property<Serializable> getPrimaryKeyProperty()
+    {
+        return primaryKeyProperty;
+    }
+
+    public void setPrimaryKeyProperty(Property<Serializable> primaryKeyProperty)
+    {
+        this.primaryKeyProperty = primaryKeyProperty;
+    }
+
+    public Property<Serializable> getVersionProperty()
+    {
+        return versionProperty;
+    }
+
+    public void setVersionProperty(Property<Serializable> versionProperty)
+    {
+        this.versionProperty = versionProperty;
+    }
+
+    public String getEntityName()
+    {
+        return entityName;
+    }
+
+    public void setEntityName(String entityName)
+    {
+        this.entityName = entityName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadataInitializer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadataInitializer.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadataInitializer.java
new file mode 100644
index 0000000..98edcbc
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/EntityMetadataInitializer.java
@@ -0,0 +1,118 @@
+/*
+ * 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.meta;
+
+import java.io.Serializable;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.enterprise.context.ApplicationScoped;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.impl.util.EntityUtils;
+
+@ApplicationScoped
+public class EntityMetadataInitializer
+{
+    private static final Logger LOG = Logger.getLogger(EntityMetadataInitializer.class.getName());
+    
+    public EntityMetadata init(RepositoryMetadata metadata)
+    {
+        EntityMetadata entityMetadata = extract(metadata.getRepositoryClass());
+        
+        entityMetadata.setPrimaryKeyProperty(EntityUtils.primaryKeyProperty(entityMetadata.getEntityClass()));
+        entityMetadata.setVersionProperty(EntityUtils.getVersionProperty(entityMetadata.getEntityClass()));
+        entityMetadata.setEntityName(EntityUtils.entityName(entityMetadata.getEntityClass()));
+
+        return entityMetadata;
+    }
+    
+    private EntityMetadata extract(Class<?> repositoryClass)
+    {
+        // get from annotation
+        Repository repository = repositoryClass.getAnnotation(Repository.class);
+        Class<?> entityClass = repository.forEntity();
+        boolean isEntityClass = !Object.class.equals(entityClass) && EntityUtils.isEntityClass(entityClass);
+        if (isEntityClass)
+        {
+            return new EntityMetadata(entityClass, EntityUtils.primaryKeyClass(entityClass));
+        }
+        
+        // get from type
+        for (Type inf : repositoryClass.getGenericInterfaces())
+        {
+            EntityMetadata result = extractFromType(inf);
+            if (result != null)
+            {
+                return result;
+            }
+        }
+
+        EntityMetadata entityMetadata = extractFromType(repositoryClass.getGenericSuperclass());
+        if (entityMetadata != null)
+        {
+            return entityMetadata;
+        }
+        for (Type intf : repositoryClass.getGenericInterfaces())
+        {
+            entityMetadata = extractFromType(intf);
+            if (entityMetadata != null)
+            {
+                return entityMetadata;
+            }
+        }
+        if (repositoryClass.getSuperclass() != null)
+        {
+            return extract(repositoryClass.getSuperclass());
+        }
+        return null;
+    }
+
+    private EntityMetadata extractFromType(Type type)
+    {
+        LOG.log(Level.FINER, "extractFrom: type = {0}", type);
+
+        if (!(type instanceof ParameterizedType))
+        {
+            return null;
+        }
+        
+        ParameterizedType parametrizedType = (ParameterizedType) type;
+        Type[] genericTypes = parametrizedType.getActualTypeArguments();
+        
+        EntityMetadata result = null;
+        
+        // don't use a foreach here, we must be sure that the we first get the entity type
+        for (Type genericType : genericTypes)
+        {
+            if (genericType instanceof Class && EntityUtils.isEntityClass((Class<?>) genericType))
+            {
+                result = new EntityMetadata((Class<?>) genericType);
+                continue;
+            }
+
+            if (result != null && genericType instanceof Class)
+            {
+                result.setPrimaryKeyClass((Class<? extends Serializable>) genericType);
+                return result;
+            }
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
deleted file mode 100644
index b93e45c..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
+++ /dev/null
@@ -1,188 +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.meta;
-
-import org.apache.deltaspike.data.api.SingleResultType;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class MethodPrefix
-{
-    public static final String DEFAULT_PREFIX = "findBy";
-    public static final String DEFAULT_OPT_PREFIX = "findOptionalBy";
-    public static final String DEFAULT_ANY_PREFIX = "findAnyBy";
-    public static final String DEFAULT_DELETE_PREFIX = "deleteBy";
-    public static final String DEFAULT_REMOVE_PREFIX = "removeBy";
-    private static final String FIND_ALL_PREFIX = "findAll";
-
-    private static final String FIND_FIRST_PREFIX = "find(First|Top)(\\d+)(By)*";
-    private static final String FIND_FIRST_PREFIX_PATTERN = FIND_FIRST_PREFIX + "(.*)";
-    private static final Pattern DIGIT_PATTERN = Pattern.compile("\\d+");
-
-    private final String customPrefix;
-    private final String methodName;
-    private int definedMaxResults = 0;
-
-    public MethodPrefix(String customPrefix, String methodName)
-    {
-        this.customPrefix = customPrefix;
-        this.methodName = methodName;
-        if (this.methodName != null)
-        {
-            this.parseMaxResults();
-        }
-    }
-
-    public String removePrefix(String queryPart)
-    {
-        if (hasCustomPrefix() && queryPart.startsWith(customPrefix))
-        {
-            return queryPart.substring(customPrefix.length());
-        }
-        KnownQueryPrefix known = KnownQueryPrefix.fromMethodName(queryPart);
-        if (known != null)
-        {
-            return known.removePrefix(queryPart);
-        }
-        return queryPart;
-    }
-
-    public boolean hasCustomPrefix()
-    {
-        return !"".equals(customPrefix);
-    }
-
-    public String getCustomPrefix()
-    {
-        return customPrefix;
-    }
-
-    public String getPrefix()
-    {
-        if (hasCustomPrefix())
-        {
-            return customPrefix;
-        }
-        KnownQueryPrefix prefix = KnownQueryPrefix.fromMethodName(methodName);
-        if (prefix != null)
-        {
-            return prefix.getPrefix();
-        }
-        return "";
-    }
-
-    public SingleResultType getSingleResultStyle()
-    {
-        KnownQueryPrefix prefix = KnownQueryPrefix.fromMethodName(methodName);
-        if (prefix != null)
-        {
-            return prefix.getStyle();
-        }
-        return SingleResultType.JPA;
-    }
-
-    public boolean isDelete()
-    {
-        return this.getPrefix().equalsIgnoreCase(DEFAULT_DELETE_PREFIX) ||
-                this.getPrefix().equalsIgnoreCase(DEFAULT_REMOVE_PREFIX);
-    }
-
-    int getDefinedMaxResults()
-    {
-        return definedMaxResults;
-    }
-
-    private void parseMaxResults()
-    {
-        if (this.methodName.matches(FIND_FIRST_PREFIX_PATTERN))
-        {
-            Matcher matcher = DIGIT_PATTERN.matcher(this.methodName);
-            if (matcher.find())
-            {
-                this.definedMaxResults = Integer.parseInt(matcher.group());
-            }
-        }
-    }
-
-    private enum KnownQueryPrefix
-    {
-        DEFAULT(DEFAULT_PREFIX, SingleResultType.JPA),
-        ALL(FIND_ALL_PREFIX, SingleResultType.JPA),
-        FIND_FIRST(FIND_FIRST_PREFIX, SingleResultType.JPA)
-        {
-            @Override
-            public boolean matches(String name)
-            {
-                return name.matches(FIND_FIRST_PREFIX_PATTERN);
-            }
-            @Override
-            public String removePrefix(String queryPart)
-            {
-                return queryPart.replaceFirst(FIND_FIRST_PREFIX,"");
-            }
-        },
-        OPTIONAL(DEFAULT_OPT_PREFIX,SingleResultType.OPTIONAL),
-        ANY(DEFAULT_ANY_PREFIX, SingleResultType.ANY),
-        DELETE_DEFAULT(DEFAULT_DELETE_PREFIX, SingleResultType.ANY),
-        REMOVE_DEFAULT(DEFAULT_REMOVE_PREFIX, SingleResultType.ANY);
-
-        private final String prefix;
-        private final SingleResultType singleResultType;
-
-        KnownQueryPrefix(String prefix, SingleResultType singleResultType)
-        {
-            this.prefix = prefix;
-            this.singleResultType = singleResultType;
-        }
-
-        public String removePrefix(String queryPart)
-        {
-            return queryPart.substring(prefix.length());
-        }
-
-        public String getPrefix()
-        {
-            return prefix;
-        }
-
-        public SingleResultType getStyle()
-        {
-            return this.singleResultType;
-        }
-
-        public boolean matches(String name)
-        {
-            return name.startsWith(getPrefix());
-        }
-
-        public static KnownQueryPrefix fromMethodName(String name)
-        {
-            for (KnownQueryPrefix mapping : values())
-            {
-                if (mapping.matches(name))
-                {
-                    return mapping;
-                }
-            }
-            return null;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodType.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodType.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodType.java
deleted file mode 100644
index aa8e493..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodType.java
+++ /dev/null
@@ -1,36 +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.meta;
-
-
-/**
- * Repository method type. Stands for
- * <ul>
- * <li>Delegated methods - the Repository has a concrete implementation for this or the method is implemented in the
- * {@link org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler}.</li>
- * <li>Annotated method - the query is defined via a Query annotation.</li>
- * <li>The method defines a query expression by its name.</li>
- * </ul>
- */
-public enum MethodType
-{
-
-    DELEGATE, ANNOTATED, PARSE
-
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocation.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocation.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocation.java
index 89cab42..bbd900b 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocation.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocation.java
@@ -41,6 +41,6 @@ import javax.inject.Qualifier;
 public @interface QueryInvocation
 {
 
-    MethodType value();
+    RepositoryMethodType value();
 
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocationLiteral.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocationLiteral.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocationLiteral.java
index f95d9ef..a21143c 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocationLiteral.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/QueryInvocationLiteral.java
@@ -30,15 +30,15 @@ public class QueryInvocationLiteral extends AnnotationLiteral<QueryInvocation>
 
     private static final long serialVersionUID = 1L;
 
-    private final MethodType methodType;
+    private final RepositoryMethodType methodType;
 
-    public QueryInvocationLiteral(MethodType methodType)
+    public QueryInvocationLiteral(RepositoryMethodType methodType)
     {
         this.methodType = methodType;
     }
 
     @Override
-    public MethodType value()
+    public RepositoryMethodType value()
     {
         return methodType;
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponent.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponent.java
deleted file mode 100644
index a98b558..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponent.java
+++ /dev/null
@@ -1,263 +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.meta;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.persistence.FlushModeType;
-
-import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
-import org.apache.deltaspike.data.api.EntityManagerConfig;
-import org.apache.deltaspike.data.api.EntityManagerResolver;
-import org.apache.deltaspike.data.api.Repository;
-
-/**
- * Stores information about a specific Repository. Extracts information about:
- * <ul>
- * <li>The Repository class</li>
- * <li>The target entity the Repository is for</li>
- * <li>The primary key class</li>
- * <li>All methods of the Repository.</li>
- * </ul>
- */
-public class RepositoryComponent
-{
-
-    private static final Logger log = Logger.getLogger(RepositoryComponent.class.getName());
-
-    private volatile Boolean entityManagerResolverIsNormalScope;
-
-    private final Class<?> repoClass;
-    private final RepositoryEntity repositoryEntity;
-    private final Class<? extends EntityManagerResolver> entityManagerResolver;
-    private final FlushModeType entityManagerFlushMode;
-
-    private final Map<Method, RepositoryMethod> methods = new HashMap<Method, RepositoryMethod>();
-
-    public RepositoryComponent(Class<?> repoClass, RepositoryEntity repositoryEntity)
-    {
-        if (repositoryEntity == null)
-        {
-            throw new IllegalArgumentException("repositoryEntity cannot be null");
-        }
-        this.repoClass = repoClass;
-        this.repositoryEntity = repositoryEntity;
-        this.entityManagerResolver = extractEntityManagerResolver(repoClass);
-        this.entityManagerFlushMode = extractEntityManagerFlushMode(repoClass);
-    }
-
-    //don't trigger this lookup during ProcessAnnotatedType
-    private void lazyInit()
-    {
-        if (entityManagerResolverIsNormalScope == null)
-        {
-            init(BeanManagerProvider.getInstance().getBeanManager());
-        }
-    }
-
-    private synchronized void init(BeanManager beanManager)
-    {
-        if (entityManagerResolverIsNormalScope != null)
-        {
-            return;
-        }
-        initialize();
-        if (entityManagerResolver != null && beanManager != null)
-        {
-            final Set<Bean<?>> beans = beanManager.getBeans(entityManagerResolver);
-            final Class<? extends Annotation> scope = beanManager.resolve(beans).getScope();
-            entityManagerResolverIsNormalScope = beanManager.isNormalScope(scope);
-        }
-        else
-        {
-            entityManagerResolverIsNormalScope = false;
-        }
-    }
-
-    public boolean isEntityManagerResolverIsNormalScope()
-    {
-        lazyInit();
-        return entityManagerResolverIsNormalScope;
-    }
-
-    public String getEntityName()
-    {
-        return repositoryEntity.getEntityName();
-    }
-
-    /**
-     * Looks up method meta data by a Method object.
-     *
-     * @param method    The Repository method.
-     * @return Method meta data.
-     */
-    public RepositoryMethod lookupMethod(Method method)
-    {
-        lazyInit();
-        return methods.get(method);
-    }
-
-    /**
-     * Looks up the method type by a Method object.
-     *
-     * @param method    The Repository method.
-     * @return Method meta data.
-     */
-    public MethodType lookupMethodType(Method method)
-    {
-        return lookupMethod(method).getMethodType();
-    }
-
-    /**
-     * Gets the entity class related the Repository.
-     *
-     * @return The class of the entity related to the Repository.
-     */
-    public Class<?> getEntityClass()
-    {
-        return repositoryEntity.getEntityClass();
-    }
-
-    /**
-     * Gets the entity primary key class related the Repository.
-     *
-     * @return The class of the entity primary key related to the Repository.
-     */
-    public Class<? extends Serializable> getPrimaryKey()
-    {
-        return repositoryEntity.getPrimaryKeyClass();
-    }
-    
-    public RepositoryEntity getRepositoryEntity()
-    {
-        return repositoryEntity;
-    }
-    
-    /**
-     * Returns the original Repository class this meta data is related to.
-     *
-     * @return The class of the Repository.
-     */
-    public Class<?> getRepositoryClass()
-    {
-        return repoClass;
-    }
-
-    public boolean hasEntityManagerResolver()
-    {
-        return getEntityManagerResolverClass() != null;
-    }
-
-    public Class<? extends EntityManagerResolver> getEntityManagerResolverClass()
-    {
-        return entityManagerResolver;
-    }
-
-    public boolean hasEntityManagerFlushMode()
-    {
-        return entityManagerFlushMode != null;
-    }
-
-    public FlushModeType getEntityManagerFlushMode()
-    {
-        return entityManagerFlushMode;
-    }
-
-    private void initialize()
-    {
-        Collection<Class<?>> allImplemented = collectClasses();
-        for (Class<?> implemented : allImplemented)
-        {
-            Method[] repoClassMethods = implemented.getDeclaredMethods();
-            for (Method repoClassMethod : repoClassMethods)
-            {
-                RepositoryMethod repoMethod = new RepositoryMethod(repoClassMethod, this);
-                methods.put(repoClassMethod, repoMethod);
-            }
-        }
-    }
-
-    private Set<Class<?>> collectClasses()
-    {
-        Set<Class<?>> result = new HashSet<Class<?>>();
-        collectClasses(repoClass, result);
-        log.log(Level.FINER, "collectClasses(): Found {0} for {1}", new Object[] { result, repoClass });
-        return result;
-    }
-
-    private void collectClasses(Class<?> cls, Set<Class<?>> result)
-    {
-        if (cls == null || cls == Object.class)
-        {
-            return;
-        }
-        result.add(cls);
-        for (Class<?> child : cls.getInterfaces())
-        {
-            collectClasses(child, result);
-        }
-        collectClasses(cls.getSuperclass(), result);
-    }
-
-    private Class<? extends EntityManagerResolver> extractEntityManagerResolver(Class<?> clazz)
-    {
-        EntityManagerConfig config = extractEntityManagerConfig(clazz);
-        if (config != null && !EntityManagerResolver.class.equals(config.entityManagerResolver()))
-        {
-            return config.entityManagerResolver();
-        }
-        return null;
-    }
-
-    private FlushModeType extractEntityManagerFlushMode(Class<?> clazz)
-    {
-        EntityManagerConfig config = extractEntityManagerConfig(clazz);
-        if (config != null)
-        {
-            return config.flushMode();
-        }
-        return null;
-    }
-
-    private EntityManagerConfig extractEntityManagerConfig(Class<?> clazz)
-    {
-        if (clazz.isAnnotationPresent(EntityManagerConfig.class))
-        {
-            return clazz.getAnnotation(EntityManagerConfig.class);
-        }
-        return null;
-    }
-
-    public String getCustomMethodPrefix()
-    {
-        return repoClass.getAnnotation(Repository.class).methodPrefix();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponents.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponents.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponents.java
deleted file mode 100644
index 8eec5dd..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponents.java
+++ /dev/null
@@ -1,129 +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.meta;
-
-import org.apache.deltaspike.data.impl.RepositoryDefinitionException;
-import org.apache.deltaspike.data.impl.meta.extractor.AnnotationMetadataExtractor;
-import org.apache.deltaspike.data.impl.meta.extractor.MetadataExtractor;
-import org.apache.deltaspike.data.impl.meta.extractor.TypeMetadataExtractor;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Convenience class to access Repository and Repository method meta data.
- * Acts as repository for Repository related meta data.
- */
-public class RepositoryComponents
-{
-    private final Map<Class<?>, RepositoryComponent> repos = new ConcurrentHashMap<Class<?>, RepositoryComponent>();
-
-    private final List<MetadataExtractor> extractors = Arrays.asList(new AnnotationMetadataExtractor(),
-            new TypeMetadataExtractor());
-
-    /**
-     * Add a Repository class to the meta data repository.
-     *
-     * @param repoClass  The repo class.
-     */
-    public void add(Class<?> repoClass)
-    {
-        RepositoryEntity entityClass = extractEntityMetaData(repoClass);
-        RepositoryComponent repo = new RepositoryComponent(repoClass, entityClass);
-        repos.put(repoClass, repo);
-    }
-
-    /**
-     * Repository access - lookup the Repository component meta data from a list of candidate classes.
-     * Depending on the implementation, proxy objects might have been modified so the actual class
-     * does not match the original Repository class.
-     *
-     * @param candidateClasses  List of candidates to check.
-     * @return A {@link RepositoryComponent} corresponding to the repoClass parameter.
-     */
-    public RepositoryComponent lookupComponent(List<Class<?>> candidateClasses)
-    {
-        for (Class<?> repoClass : candidateClasses)
-        {
-            if (repos.containsKey(repoClass))
-            {
-                return repos.get(repoClass);
-            }
-        }
-        throw new RuntimeException("Unknown Repository classes " + candidateClasses);
-    }
-
-    /**
-     * Repository access - lookup the Repository component meta data for a specific Repository class.
-     *
-     * @param repoClass  The Repository class to lookup the method for
-     * @return A {@link RepositoryComponent} corresponding to the repoClass parameter.
-     */
-    public RepositoryComponent lookupComponent(Class<?> repoClass)
-    {
-        if (repos.containsKey(repoClass))
-        {
-            return repos.get(repoClass);
-        }
-        throw new RuntimeException("Unknown Repository class " + repoClass.getName());
-    }
-
-    /**
-     * Repository access - lookup method information for a specific Repository class.
-     *
-     * @param repoClass The Repository class to lookup the method for
-     * @param method    The Method object to get Repository meta data for.
-     * @return A {@link RepositoryMethod} corresponding to the method parameter.
-     */
-    public RepositoryMethod lookupMethod(Class<?> repoClass, Method method)
-    {
-        return lookupComponent(repoClass).lookupMethod(method);
-    }
-    
-    public RepositoryMethod lookupMethod(RepositoryComponent component, Method method)
-    {
-        return component.lookupMethod(method);
-    }
-
-    private RepositoryEntity extractEntityMetaData(Class<?> repoClass)
-    {
-        for (MetadataExtractor extractor : extractors)
-        {
-            RepositoryEntity entity = extractor.extract(repoClass);
-            if (entity != null)
-            {
-                return entity;
-            }
-        }
-        throw new RepositoryDefinitionException(repoClass);
-    }
-
-    public Map<Class<?>, RepositoryComponent> getRepositories()
-    {
-        return repos;
-    }
-
-    public void addAll(Map<Class<?>, RepositoryComponent> repositories)
-    {
-        this.repos.putAll(repositories);
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/46a3b675/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponentsFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponentsFactory.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponentsFactory.java
deleted file mode 100644
index 19cd451..0000000
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/RepositoryComponentsFactory.java
+++ /dev/null
@@ -1,44 +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.meta;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-
-import org.apache.deltaspike.core.api.lifecycle.Initialized;
-import org.apache.deltaspike.data.impl.RepositoryExtension;
-
-/**
- * Repository components producer.
- */
-public class RepositoryComponentsFactory
-{
-
-    @Inject
-    private RepositoryExtension extension;
-    
-    @Produces
-    @ApplicationScoped
-    @Initialized
-    public RepositoryComponents producer()
-    {
-        return extension.getComponents();
-    }
-}


Mime
View raw message