geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r566465 - in /geronimo/server/branches/2.0/modules/geronimo-j2ee/src: main/java/org/apache/geronimo/j2ee/annotation/Holder.java test/java/org/apache/geronimo/j2ee/annotation/ test/java/org/apache/geronimo/j2ee/annotation/HolderTest.java
Date Thu, 16 Aug 2007 01:32:16 GMT
Author: gawor
Date: Wed Aug 15 18:32:15 2007
New Revision: 566465

URL: http://svn.apache.org/viewvc?view=rev&rev=566465
Log:
add a copy constructor to the Holder object

Added:
    geronimo/server/branches/2.0/modules/geronimo-j2ee/src/test/java/org/apache/geronimo/j2ee/annotation/
      - copied from r566236, geronimo/server/trunk/modules/geronimo-j2ee/src/test/java/org/apache/geronimo/j2ee/annotation/
    geronimo/server/branches/2.0/modules/geronimo-j2ee/src/test/java/org/apache/geronimo/j2ee/annotation/HolderTest.java
      - copied unchanged from r566236, geronimo/server/trunk/modules/geronimo-j2ee/src/test/java/org/apache/geronimo/j2ee/annotation/HolderTest.java
Modified:
    geronimo/server/branches/2.0/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java

Modified: geronimo/server/branches/2.0/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java?view=diff&rev=566465&r1=566464&r2=566465
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
(original)
+++ geronimo/server/branches/2.0/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/annotation/Holder.java
Wed Aug 15 18:32:15 2007
@@ -50,8 +50,24 @@
     public Holder() {
     }
 
-
-    public void addInjection(String className, Injection injection) {
+    public Holder(Holder source) {
+        if (source.getInjectionMap() != null) {
+            this.injectionMap = new HashMap<String, List<Injection>>();
+            addInjectionMap(source.getInjectionMap());
+        }
+        
+        if (source.getPostConstruct() != null) {
+            this.postConstruct = new HashMap<String, LifecycleMethod>();
+            addPostConstructs(source.getPostConstruct());
+        }
+        
+        if (source.getPreDestroy() != null) {
+            this.preDestroy = new HashMap<String, LifecycleMethod>();
+            addPreDestroys(source.getPreDestroy());
+        }
+    }
+    
+    private List<Injection> getInjectionList(String className) {
         if (injectionMap == null) {
             injectionMap = new HashMap<String, List<Injection>>();
         }
@@ -60,7 +76,19 @@
             injections = new ArrayList<Injection>();
             injectionMap.put(className, injections);
         }
-        injections.add(injection);
+        return injections;
+    }
+    
+    public void addInjection(String className, Injection newInjection) {
+        List<Injection> injections = getInjectionList(className);
+        injections.add(newInjection);
+    }
+    
+    public void addInjections(String className, List<Injection> newInjections) {
+        List<Injection> injections = getInjectionList(className);        
+        for (Injection injection : newInjections) {
+            injections.add(injection);
+        }
     }
 
     public void addPostConstructs(Map<String, LifecycleMethod> newPostConstructs) {
@@ -82,6 +110,17 @@
         return old;
     }
 
+    public void addInjectionMap(Map<String, List<Injection>> injectionMap) {
+        if (injectionMap == null) {
+            return;
+        }
+        for (Map.Entry<String, List<Injection>> entry : injectionMap.entrySet())
{
+            String className = entry.getKey();
+            List<Injection> injections = entry.getValue();
+            addInjections(className, injections);            
+        }
+    }
+    
     public List<Injection> getInjections(String className) {
         if (injectionMap == null) {
             return null;
@@ -89,6 +128,10 @@
         return injectionMap.get(className);
     }
 
+    public Map<String, List<Injection>> getInjectionMap() {
+        return injectionMap;
+    }
+    
     public Map<String, LifecycleMethod> getPostConstruct() {
         return postConstruct;
     }



Mime
View raw message