deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-1009 improved compatibility with WAS8
Date Wed, 04 Nov 2015 18:23:24 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master bfb85f3c2 -> e7d35f576


DELTASPIKE-1009 improved compatibility with WAS8


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

Branch: refs/heads/master
Commit: e7d35f57609e70ff4a975a072276e5dff7490a64
Parents: bfb85f3
Author: gpetracek <gpetracek@apache.org>
Authored: Wed Nov 4 19:14:47 2015 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Wed Nov 4 19:22:05 2015 +0100

----------------------------------------------------------------------
 .../data/impl/RepositoryExtension.java          | 26 +++++++++++++++++---
 .../data/impl/meta/RepositoryComponents.java    | 14 ++++++++---
 .../impl/meta/RepositoryComponentsFactory.java  |  2 ++
 3 files changed, 36 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e7d35f57/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 a083681..e9bee96 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
@@ -29,6 +29,7 @@ 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;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 
@@ -58,6 +59,8 @@ public class RepositoryExtension implements Extension, Deactivatable
 
     private static final Logger log = Logger.getLogger(RepositoryExtension.class.getName());
 
+    private static RepositoryComponents staticComponents = new RepositoryComponents();
+
     private final List<RepositoryDefinitionException> definitionExceptions =
             new LinkedList<RepositoryDefinitionException>();
 
@@ -65,7 +68,6 @@ public class RepositoryExtension implements Extension, Deactivatable
 
     private RepositoryComponents components = new RepositoryComponents();
 
-
     void beforeBeanDiscovery(@Observes BeforeBeanDiscovery before)
     {
         isActivated = ClassDeactivationUtils.isActivated(getClass());
@@ -104,6 +106,7 @@ public class RepositoryExtension implements Extension, Deactivatable
                     return;
                 }
                 components.add(repoClass);
+                staticComponents.add(repoClass);
             }
             catch (RepositoryDefinitionException e)
             {
@@ -140,10 +143,27 @@ public class RepositoryExtension implements Extension, Deactivatable
     {
         return annotated.getJavaClass().equals(AbstractEntityRepository.class);
     }
-    
+
     public RepositoryComponents getComponents()
     {
-        return components;
+        RepositoryComponents result = new RepositoryComponents();
+        if (components.getRepositories().isEmpty() && !staticComponents.getRepositories().isEmpty())
+        {
+            result.addAll(staticComponents.getRepositories());
+        }
+
+        if (!components.getRepositories().isEmpty())
+        {
+            result.addAll(components.getRepositories());
+        }
+
+        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();
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e7d35f57/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
index 1686e31..f4651f9 100644
--- 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
@@ -26,9 +26,9 @@ import org.apache.deltaspike.data.impl.meta.extractor.TypeMetadataExtractor;
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Convenience class to access Repository and Repository method meta data.
@@ -36,10 +36,9 @@ import java.util.Map;
  */
 public class RepositoryComponents implements Serializable
 {
-
     private static final long serialVersionUID = 1L;
 
-    private final Map<Class<?>, RepositoryComponent> repos = new HashMap<Class<?>,
RepositoryComponent>();
+    private final Map<Class<?>, RepositoryComponent> repos = new ConcurrentHashMap<Class<?>,
RepositoryComponent>();
 
     private final List<MetadataExtractor> extractors = Arrays.asList(new AnnotationMetadataExtractor(),
             new TypeMetadataExtractor());
@@ -118,4 +117,13 @@ public class RepositoryComponents implements Serializable
         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/e7d35f57/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
index 8eac1a5..19cd451 100644
--- 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
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.data.impl.meta;
 
+import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.Produces;
 import javax.inject.Inject;
 
@@ -34,6 +35,7 @@ public class RepositoryComponentsFactory
     private RepositoryExtension extension;
     
     @Produces
+    @ApplicationScoped
     @Initialized
     public RepositoryComponents producer()
     {


Mime
View raw message