[jboss-cvs] JBossAS SVN: r62496 - in projects/aop/trunk/aop/src/main/org/jboss/aop: introduction and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Apr 23 16:35:26 EDT 2007


Author: flavia.rainone at jboss.com
Date: 2007-04-23 16:35:25 -0400 (Mon, 23 Apr 2007)
New Revision: 62496

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/introduction/InterfaceIntroduction.java
Log:
Small refactoring: added generics to these classes.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2007-04-23 20:34:49 UTC (rev 62495)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2007-04-23 20:35:25 UTC (rev 62496)
@@ -86,9 +86,12 @@
    protected int counter;
    protected String defaultBaseName;
    protected AspectManager manager;
-   protected ArrayList bindings = new ArrayList();
-   protected ArrayList factories = new ArrayList();
-   protected ArrayList aspects = new ArrayList();
+   // list of binding names
+   protected ArrayList<String> bindings = new ArrayList<String>();
+   // list of factory names
+   protected ArrayList<String> factories = new ArrayList<String>();
+   // list of aspect names
+   protected ArrayList<String> aspects = new ArrayList<String>();
 
    public AspectXmlLoader()
    {
@@ -274,8 +277,8 @@
             throw new RuntimeException(cflow, e);  //To change body of catch statement use Options | File Templates.
          }
       }
-      ArrayList interceptors = loadInterceptors(element);
-      InterceptorFactory[] inters = (InterceptorFactory[]) interceptors.toArray(new InterceptorFactory[interceptors.size()]);
+      ArrayList<InterceptorFactory> interceptors = loadInterceptors(element);
+      InterceptorFactory[] inters = interceptors.toArray(new InterceptorFactory[interceptors.size()]);
       Pointcut p = null;
       try
       {
@@ -304,7 +307,7 @@
    {
       String name = getName(element, "precedence");
 
-      ArrayList precedenceEntries = new ArrayList();
+      ArrayList<PrecedenceDefEntry> precedenceEntries = new ArrayList<PrecedenceDefEntry>();
       NodeList children2 = element.getChildNodes();
       for (int j = 0; j < children2.getLength(); j++)
       {
@@ -345,14 +348,14 @@
          }
       }
 
-      PrecedenceDefEntry[] entries = (PrecedenceDefEntry[]) precedenceEntries.toArray(new PrecedenceDefEntry[precedenceEntries.size()]);
+      PrecedenceDefEntry[] entries = precedenceEntries.toArray(new PrecedenceDefEntry[precedenceEntries.size()]);
       manager.addPrecedence(new PrecedenceDef(name, entries));
    }
 
 
-   private ArrayList loadInterceptors(Element element) throws Exception
+   private ArrayList<InterceptorFactory> loadInterceptors(Element element) throws Exception
    {
-      ArrayList interceptors = new ArrayList();
+      ArrayList<InterceptorFactory> interceptors = new ArrayList<InterceptorFactory>();
       NodeList children2 = element.getChildNodes();
       for (int j = 0; j < children2.getLength(); j++)
       {
@@ -509,7 +512,7 @@
 
    public void deployInterceptorStack(Element element) throws Exception
    {
-      ArrayList interceptors = loadInterceptors(element);
+      ArrayList<InterceptorFactory> interceptors = loadInterceptors(element);
       String name = element.getAttribute("name");
       AdviceStack stack = new AdviceStack(name, interceptors);
       manager.addAdviceStack(stack);
@@ -753,13 +756,13 @@
       if (intfs != null)
       {
          StringTokenizer tokenizer = new StringTokenizer(intfs, ",");
-         ArrayList interfaces = new ArrayList();
+         ArrayList<String> interfaces = new ArrayList<String>();
          while (tokenizer.hasMoreTokens())
          {
             String intf = tokenizer.nextToken().trim();
             if (!intf.equals("")) interfaces.add(intf);
          }
-         ifaces = (String[]) interfaces.toArray(new String[interfaces.size()]);
+         ifaces = interfaces.toArray(new String[interfaces.size()]);
       }
 
       InterfaceIntroduction pcut = null;
@@ -793,13 +796,13 @@
 
             intfs = XmlHelper.getUniqueChildContent(mixin, "interfaces");
             StringTokenizer tokenizer = new StringTokenizer(intfs, ",");
-            ArrayList interfaces = new ArrayList();
+            ArrayList<String> interfaces = new ArrayList<String>();
             while (tokenizer.hasMoreTokens())
             {
                String intf = tokenizer.nextToken().trim();
                if (!intf.equals("")) interfaces.add(intf);
             }
-            ifaces = (String[]) interfaces.toArray(new String[interfaces.size()]);
+            ifaces = interfaces.toArray(new String[interfaces.size()]);
             pcut.getMixins().add(new InterfaceIntroduction.Mixin(classname, ifaces, construction, isTransient));
          }
       }
@@ -972,14 +975,14 @@
       DomainDefinition def = manager.getContainer(name);
       if (def == null) throw new RuntimeException("Unable to undeploy container: " + name);
       AspectManager push = manager;
-      ArrayList oldFactories = factories;
-      ArrayList oldAspects = aspects;
-      ArrayList oldBindings = bindings;
+      ArrayList<String> oldFactories = factories;
+      ArrayList<String> oldAspects = aspects;
+      ArrayList<String> oldBindings = bindings;
       try
       {
-         factories = new ArrayList();
-         aspects = new ArrayList();
-         bindings = new ArrayList();
+         factories = new ArrayList<String>();
+         aspects = new ArrayList<String>();
+         bindings = new ArrayList<String>();
          manager = def.getManager();
          undeployTopElements(element);
          bulkUndeploy();

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/introduction/InterfaceIntroduction.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/introduction/InterfaceIntroduction.java	2007-04-23 20:34:49 UTC (rev 62495)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/introduction/InterfaceIntroduction.java	2007-04-23 20:35:25 UTC (rev 62496)
@@ -100,9 +100,9 @@
    }
 
    protected String name;
-   protected ArrayList advisors = new ArrayList();
+   protected ArrayList<WeakReference<Advisor>> advisors = new ArrayList<WeakReference<Advisor>>();
    protected String[] interfaces;
-   protected ArrayList mixins = new ArrayList();
+   protected ArrayList<InterfaceIntroduction.Mixin> mixins = new ArrayList<InterfaceIntroduction.Mixin>();
    protected ClassExpression classExpr;
    protected ASTStart ast;
    
@@ -165,7 +165,7 @@
       }
    }
 
-   public void setMixins(ArrayList mixins)
+   public void setMixins(ArrayList<InterfaceIntroduction.Mixin> mixins)
    {
       this.mixins = mixins;
    }
@@ -195,7 +195,7 @@
       return interfaces;
    }
 
-   public ArrayList getMixins()
+   public ArrayList<InterfaceIntroduction.Mixin> getMixins()
    {
       return mixins;
    }
@@ -216,7 +216,7 @@
    
    public void addAdvisor(Advisor advisor)
    {
-      advisors.add(new WeakReference(advisor));
+      advisors.add(new WeakReference<Advisor>(advisor));
       advisor.addInterfaceIntroduction(this);
    }
 
@@ -224,8 +224,7 @@
    {
       for (int i = 0; i < advisors.size(); i++)
       {
-         WeakReference ref = (WeakReference) advisors.get(i);
-         Advisor advisor = (Advisor) ref.get();
+         Advisor advisor = advisors.get(i).get();
          if (advisor != null)
             advisor.removeInterfaceIntroduction(this);
       }




More information about the jboss-cvs-commits mailing list