[jboss-cvs] JBossAS SVN: r74277 - projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jun 7 01:00:57 EDT 2008


Author: flavia.rainone at jboss.com
Date: 2008-06-07 01:00:57 -0400 (Sat, 07 Jun 2008)
New Revision: 74277

Added:
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedClassData.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedData.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/DomainClassNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/SimpleClassNode.java
Modified:
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/BehaviorNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/ClassNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/FieldNode.java
   projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java
Log:
[JBAOP-504] Started adding support to aop domains.

Added: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedClassData.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedClassData.java	                        (rev 0)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedClassData.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.joinpoint.graph;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ */
+class AdvisedClassData extends AdvisedData
+{
+   private Set<String> tags;
+   private Map<Advisor, AdvisedData> instanceAdvisedData;
+   
+   public AdvisedClassData(Advisor advisor)
+   {
+      super(advisor);
+      AspectManager manager = advisor.getManager();
+      if (manager instanceof Domain)
+      {
+         this.tags = new TreeSet<String> ();
+         do
+         {
+            Domain domain = (Domain) manager;
+            this.tags.add(domain.getDomainName());
+            manager = domain.getParent();
+         } while (manager instanceof Domain);
+      }
+   }
+   
+   public boolean containsTag(String tag)
+   {
+      return this.tags.contains(tag);
+   }
+   
+   public AdvisedData createInstanceAdvisedData(Advisor advisor)
+   {
+      AdvisedData queriedData = new AdvisedData(advisor);
+      instanceAdvisedData.put(advisor, queriedData);
+      return queriedData;
+   }
+   
+   public AdvisedData getInstanceAdvisedData(Advisor advisor)
+   {
+      if (instanceAdvisedData.containsKey(advisor))
+      {
+         return instanceAdvisedData.get(advisor);
+      }
+      AdvisedData queriedData = new AdvisedData(advisor);
+      instanceAdvisedData.put(advisor, queriedData);
+      return queriedData;
+   }
+   
+   public AdvisedData getAdvisedData(Advisor advisor)
+   {
+      if (advisor == this.getAdvisor())
+      {
+         return this;
+      }
+      return getInstanceAdvisedData(advisor);
+   }
+}
\ No newline at end of file

Added: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedData.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedData.java	                        (rev 0)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/AdvisedData.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.joinpoint.graph;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.joinpoint.graph.tree.Tree;
+
+/**
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+class AdvisedData
+{
+   private Advisor advisor;
+   private Tree<FieldNode> fields;
+   private Tree<BehaviorNode> behaviors;
+
+   public AdvisedData(Advisor advisor)
+   {
+      this.advisor = advisor;
+      this.fields = new Tree<FieldNode>();
+      this.behaviors = new Tree<BehaviorNode>();
+   }
+
+   public Advisor getAdvisor()
+   {
+      return this.advisor;
+   }
+   
+   public BehaviorNode getBehavior(Constructor constructor)
+   {
+      String behaviorKey = BehaviorNode.getDefaultKey(constructor);
+      BehaviorNode behaviorNode = behaviors.searchValue(behaviorKey);
+      if (behaviorNode == null)
+      {
+         behaviorNode = new BehaviorNode(advisor, constructor);
+         TreeInsertionUtil.insertNode(behaviorNode, behaviorKey, behaviors);
+      }
+      return behaviorNode;
+   }
+
+   public BehaviorNode getBehavior(Method method)
+   {
+      String behaviorKey = BehaviorNode.getDefaultKey(method);
+      BehaviorNode behaviorNode = behaviors.searchValue(behaviorKey);
+      if (behaviorNode == null)
+      {
+         behaviorNode = new BehaviorNode(advisor, method);
+         TreeInsertionUtil.insertNode(behaviorNode, behaviorKey, behaviors);
+      }
+      return behaviorNode;
+   }
+
+   public Collection<BehaviorNode> searchBehaviors(String behaviorExpression)
+   {
+      return behaviors.search(behaviorExpression);
+   }
+
+   public FieldNode getField(Field field)
+   {
+      String defaultKey = FieldNode.getDefaultKey(field);
+      FieldNode fieldNode = fields.searchValue(defaultKey);
+      if (fieldNode == null)
+      {
+         fieldNode = new FieldNode(advisor, field);
+         TreeInsertionUtil.insertNode(fieldNode, defaultKey, fields);
+      }
+      return fieldNode;
+   }
+
+   public Collection<FieldNode> searchFields(String fieldExpression)
+   {
+      return fields.search(fieldExpression);
+   }
+}
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/BehaviorNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/BehaviorNode.java	2008-06-07 04:59:36 UTC (rev 74276)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/BehaviorNode.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -37,33 +37,25 @@
  */
 class BehaviorNode implements Node
 {
-   private ClassNode classNode;
+   private Advisor advisor;
    private BehaviourType behaviourType;
    private Member member;
    private JoinPointInfo execution;
    private ConstructionInfo construction;
    private Tree<JoinPointInfo> calls;
    
-   public BehaviorNode(ClassNode classNode, Method member)
+   public BehaviorNode(Advisor advisor, Method member)
    {
-      this.classNode = classNode;
       this.member = member;
       this.behaviourType = BehaviourType.METHOD;
    }
    
-   public BehaviorNode(ClassNode classNode, Constructor member)
+   public BehaviorNode(Advisor advisor, Constructor member)
    {
-      this.classNode = classNode;
       this.member = member;
       this.behaviourType = BehaviourType.CONSTRUCTOR;
    }
 
-   // TODO Flavia
-   public ClassNode getClassNode()
-   {
-      return this.classNode;
-   }
- 
    public static final String getDefaultKey(Method member)
    {
       return getDefaultKey(member, BehaviourType.METHOD);
@@ -106,7 +98,7 @@
       String commonPrefix = behaviourType.getReturnType(member) + "@";
       String commonSuffix = getParameterList(member, behaviourType);
       Collection<String> metaDataTags =
-            behaviourType.getMetaDataTags(classNode.getAdvisor(), member);
+            behaviourType.getMetaDataTags(advisor, member);
       for (String metaDataTag: metaDataTags)
       {
          keys.add(commonPrefix + metaDataTag + commonSuffix);
@@ -153,14 +145,14 @@
       this.construction = construction;
    }
    
-   public void insertCaller(String callerName, JoinPointInfo callNode)
+   public void insertCallee(String calleeName, JoinPointInfo callNode)
    {
-      calls.insert(callerName, callNode);
+      calls.insert(calleeName, callNode);
    }
    
-   public void searchCallers(String callerExpression, Collection<JoinPointInfo> result)
+   public void searchCallees(String calleeExpression, Collection<JoinPointInfo> result)
    {
-      calls.search(callerExpression, result);
+      calls.search(calleeExpression, result);
    }
    
    private enum BehaviourType

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/ClassNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/ClassNode.java	2008-06-07 04:59:36 UTC (rev 74276)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/ClassNode.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -9,9 +9,10 @@
 
 import javassist.NotFoundException;
 
+import org.jboss.aop.Advised;
 import org.jboss.aop.Advisor;
+import org.jboss.aop.InstanceAdvisor;
 import org.jboss.aop.annotation.AnnotationElement;
-import org.jboss.aop.joinpoint.graph.tree.Tree;
 
 /**
  * Node that represents a class in the graph.
@@ -22,11 +23,11 @@
  * </li>
  * </ul>
  * 
- * Every class node contains
+ * Every class node contains:
  * <ul>
  * <li> references to all the nodes that represent direct subtypes of it in the
  *      graph;</li>
- * <li> a subtree of behaviours, containing all behaviour nodes associated with this
+ * <li> a subtree of behaviors, containing all behavior nodes associated with this
  *      class node;<li>
  * <li> and a subtree of fields, containing all field nodes associated with this
  *      class node.</li>
@@ -34,10 +35,9 @@
  * 
  * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
  */
-class ClassNode implements Node
+abstract class ClassNode implements Node
 {
    private Class clazz;
-   private Collection<ClassNode> directSubtypes; 
    private AdvisedClassData advisedData;
    
    /**
@@ -46,12 +46,11 @@
     * @param clazz   the weaved class that this node represents in the graph.
     * @param advisor the advisor of {@code clazz}
     */
-   public ClassNode(Class clazz, Advisor advisor)
+   /*public ClassNode(Class clazz, Advisor advisor)
    {
       this(clazz);
-      this.directSubtypes = new ArrayList<ClassNode>(0);
       this.advisedData = new AdvisedClassData(advisor);
-   }
+   }*/
    
    /**
     * Creates a node that represents a supertype of a weaved class in the graph.
@@ -62,7 +61,6 @@
    public ClassNode(Class clazz)
    {
       this.clazz = clazz;
-      this.directSubtypes = new ArrayList<ClassNode>(1);
    }
    
    /**
@@ -84,6 +82,25 @@
       return this.clazz;
    }
    
+   public AdvisedData getAdvisedData(Advisor advisor)
+   {
+      if (advisor instanceof InstanceAdvisor)
+      {
+         if (this.advisedData == null)
+         {
+            Advisor classAdvisor = ((Advised)((InstanceAdvisor) advisor).getInstance())._getAdvisor();
+            this.advisedData = new AdvisedClassData(classAdvisor);
+            return this.advisedData.createInstanceAdvisedData(advisor);
+         }
+         return this.advisedData.getInstanceAdvisedData(advisor);
+      }
+      if (this.advisedData == null)
+      {
+         this.advisedData = new AdvisedClassData(advisor);
+      }
+      return this.advisedData;
+   }
+   
    /**
     * Returns the advisor of the weaved class this node represents.
     * 
@@ -137,58 +154,52 @@
     * @param directSubtype the node that represents a direct subtype of the class
     *                      represented by this node
     */
-   public void addDirectSubtype(ClassNode directSubtype)
-   {
-      this.directSubtypes.add(directSubtype);
-   }
+   public abstract void addSubtype(ClassNode directSubtype);
    
-   public Collection<ClassNode> getDirectSubtypes()
-   {
-      return this.directSubtypes;
-   }
+   public abstract Collection<ClassNode> getSubtypes();
  
    /**
-    * Returns the behaviour node that represents {@code constructor}.
+    * Returns the behavior node that represents {@code constructor}.
     * 
     * @param constructor  a member of the class represented by this node. This
     *                     constructor must be associated with one or more weaved
     *                     joinpoints.
-    * @return             the behaviour node that represents {@code constructor}. If
+    * @return             the behavior node that represents {@code constructor}. If
     *                     such node does not exist, it is created and inserted in the
-    *                     behaviour subtree.
+    *                     behavior subtree.
     */
-   public BehaviorNode getBehaviour(Constructor constructor)
+   public BehaviorNode getBehavior(Constructor constructor)
    {
-      return advisedData.getBehaviour(constructor);
+      return advisedData.getBehavior(constructor);
    }
    
    /**
-    * Returns the behaviour node that represents {@code method}.
+    * Returns the behavior node that represents {@code method}.
     * 
     * @param method       a member of the class represented by this node. This
     *                     method must be associated with one or more weaved
     *                     joinpoints.
-    * @return             the behaviour node that represents {@code method}. If such
+    * @return             the behavior node that represents {@code method}. If such
     *                     node does not exist, it is created and inserted in the
-    *                     behaviour subtree.
+    *                     behavior subtree.
     */
-   public BehaviorNode getBehaviour(Method method)
+   public BehaviorNode getBehavior(Method method)
    {
-      return advisedData.getBehaviour(method);
+      return advisedData.getBehavior(method);
    }
    
    /**
-    * Searches for all behaviour nodes whose keys match {@code behaviourExpression}.
-    * The search is performed on this node's behaviour subtree, hence returning only
+    * Searches for all behavior nodes whose keys match {@code behaviorExpression}.
+    * The search is performed on this node's behavior subtree, hence returning only
     * members of the class this node represents.
     * 
-    * @param behaviourExpression a search expession. May contain wildcards.
-    * @return                    a collection containing all the behaviour nodes
-    *                            whose keys match {@code behaviourExpression}.
+    * @param behaviorExpression a search expession. May contain wildcards.
+    * @return                   a collection containing all the behavior nodes
+    *                           whose keys match {@code behaviorExpression}.
     */
-   public Collection<BehaviorNode> searchBehaviours(String behaviourExpression)
+   public Collection<BehaviorNode> searchBehaviors(String behaviorExpression)
    {
-      return advisedData.searchBehaviours(behaviourExpression);
+      return advisedData.searchBehaviors(behaviorExpression);
    }
    
    /**
@@ -196,7 +207,7 @@
     * 
     * @param field a member of the class represented by this node. This field must be
     *              associated with one or more weaved joinpoints.
-    * @return      the behaviour node that represents {@code field}. If such node
+    * @return      the behavior node that represents {@code field}. If such node
     *              does not exist, it is created and inserted in the field subtree.
     */
    public FieldNode getField(Field field)
@@ -217,75 +228,4 @@
    {
       return advisedData.searchFields(fieldExpression);
    }
-   
-   /**
-    * Private class
-    * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
-    *
-    */
-   private class AdvisedClassData
-   {
-      private Advisor advisor;
-      private Tree<FieldNode> fields;
-      private Tree<BehaviorNode> behaviours;
-      
-      
-      public AdvisedClassData(Advisor advisor)
-      {
-         this.advisor = advisor;
-         this.fields = new Tree<FieldNode>();
-         this.behaviours = new Tree<BehaviorNode>();
-      }
-      
-      public Advisor getAdvisor()
-      {
-         return this.advisor;
-      }
-      
-      public BehaviorNode getBehaviour(Constructor constructor)
-      {
-         String behaviourKey = BehaviorNode.getDefaultKey(constructor);
-         BehaviorNode behaviourNode = behaviours.searchValue(behaviourKey);
-         if (behaviourNode == null)
-         {
-            behaviourNode = new BehaviorNode(ClassNode.this, constructor);
-            TreeInsertionUtil.insertNode(behaviourNode, behaviourKey, behaviours);
-         }
-         return behaviourNode;
-      }
-      
-      public BehaviorNode getBehaviour(Method method)
-      {
-         String behaviourKey = BehaviorNode.getDefaultKey(method);
-         BehaviorNode behaviourNode = behaviours.searchValue(behaviourKey);
-         if (behaviourNode == null)
-         {
-            behaviourNode = new BehaviorNode(ClassNode.this, method);
-            TreeInsertionUtil.insertNode(behaviourNode, behaviourKey, behaviours);
-         }
-         return behaviourNode;
-      }
-      
-      public Collection<BehaviorNode> searchBehaviours(String behaviourExpression)
-      {
-         return behaviours.search(behaviourExpression);
-      }
-      
-      public FieldNode getField(Field field)
-      {
-         String defaultKey = FieldNode.getDefaultKey(field);
-         FieldNode fieldNode = fields.searchValue(defaultKey);
-         if (fieldNode == null)
-         {
-            fieldNode = new FieldNode(ClassNode.this, field);
-            TreeInsertionUtil.insertNode(fieldNode, defaultKey, fields);
-         }
-         return fieldNode;
-      }
-      
-      public Collection<FieldNode> searchFields(String fieldExpression)
-      {
-         return fields.search(fieldExpression);
-      }
-   }
 }
\ No newline at end of file

Added: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/DomainClassNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/DomainClassNode.java	                        (rev 0)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/DomainClassNode.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.joinpoint.graph;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.jboss.aop.Advisor;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ */
+class DomainClassNode extends ClassNode
+{
+   /*public DomainClassNode(Class clazz, Advisor advisor)
+   {
+      super(clazz, advisor);
+   }*/
+   
+   public DomainClassNode(Class clazz)
+   {
+      super(clazz);
+   }
+   
+   /* (non-Javadoc)
+    * @see org.jboss.aop.joinpoint.graph.ClassNode#addSubtype(org.jboss.aop.joinpoint.graph.ClassNode)
+    */
+   @Override
+   public void addSubtype(ClassNode directSubtype)
+   {
+      
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.aop.joinpoint.graph.ClassNode#getSubtypes()
+    */
+   @Override
+   public Collection<ClassNode> getSubtypes()
+   {
+      return (Collection<ClassNode>) Collections.EMPTY_LIST;
+   }
+
+}
\ No newline at end of file

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/FieldNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/FieldNode.java	2008-06-07 04:59:36 UTC (rev 74276)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/FieldNode.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -24,6 +24,7 @@
 import java.lang.reflect.Field;
 import java.util.Collection;
 
+import org.jboss.aop.Advisor;
 import org.jboss.aop.FieldInfo;
 
 /**
@@ -32,14 +33,14 @@
  */
 class FieldNode implements Node
 {
-   private ClassNode classNode;
+   private Advisor advisor;
    private Field field;
    private FieldInfo fieldRead;
    private FieldInfo fieldWrite;
    
-   public FieldNode(ClassNode classNode, Field field)
+   public FieldNode(Advisor advisor, Field field)
    {
-      this.classNode = classNode;
+      this.advisor = advisor;
       this.field = field;
    }
    
@@ -48,11 +49,6 @@
       return field.getType().getName() + " " + field.getName();
    }
    
-   public ClassNode getClassNode()
-   {
-      return this.classNode;
-   }
-   
    public String getDefaultKey()
    {
       return getDefaultKey(this.field);
@@ -61,7 +57,7 @@
    public void loadMetaDataKeys(Collection<String> names)
    {
       String commonPrefix = this.field.getType() + " @";
-      Collection<String> metaDataTags = classNode.getAdvisor().getMetaDataTags(this.field);
+      Collection<String> metaDataTags = advisor.getMetaDataTags(this.field);
       for (String metaDataTag: metaDataTags)
       {
          names.add(commonPrefix + metaDataTag);

Modified: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java	2008-06-07 04:59:36 UTC (rev 74276)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -1,5 +1,5 @@
 /*
- * JBoss, Home of Professional Open Source
+ * JBoss, Home of Professional Open Sorce
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
@@ -7,7 +7,7 @@
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
+ * the License, or (at yor option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -69,8 +69,9 @@
 
    public synchronized void register(FieldInfo info)
    {
-      ClassNode classNode = getClassNode(info.getClazz(), info.getAdvisor());
-      FieldNode fieldNode = classNode.getField(info.getField());
+      Advisor advisor = info.getAdvisor();
+      AdvisedData advisedData = getClassNode(info.getClazz()).getAdvisedData(advisor);
+      FieldNode fieldNode = advisedData.getField(info.getField());
       if (info.isRead())
       {
          fieldNode.setFieldRead(info);
@@ -83,52 +84,64 @@
    
    public synchronized void register(ConstructorInfo info)
    {
-      getBehaviour(info.getAdvisor(), info.getClazz(), info.getConstructor()).
+      getBehavior(info.getAdvisor(), info.getClazz(), info.getConstructor()).
          setExecution(info);
    }
 
    public synchronized void register(ConstructionInfo info)
    {
-      getBehaviour(info.getAdvisor(), info.getClazz(), info.getConstructor()).
+      getBehavior(info.getAdvisor(), info.getClazz(), info.getConstructor()).
          setConstruction(info);
    }
    
    public synchronized void register(MethodInfo info)
    {
-      getBehaviour(info.getAdvisor(), info.getClazz(), info.getMethod()).
+      getBehavior(info.getAdvisor(), info.getClazz(), info.getMethod()).
          setExecution(info);
    }
 
    public synchronized void register(ConByConInfo info)
    {
-      BehaviorNode behaviour = getBehaviour(info.getAdvisor(),
-            info.getCalledClass(), info.getConstructor());
-      String callName = BehaviorNode.getDefaultKey(info.getCallingConstructor());
-      behaviour.insertCaller(callName, info);
+      // get caller behavior node
+      BehaviorNode behavior = getBehavior(info.getAdvisor(),
+            info.getCallingClass(), info.getCallingConstructor());
+      // get callee name
+      String calleeName = BehaviorNode.getDefaultKey(info.getConstructor());
+      // insert
+      behavior.insertCallee(calleeName, info);
    }
    
    public synchronized void register(ConByMethodInfo info)
    {
-      BehaviorNode behaviour = getBehaviour(info.getAdvisor(),
-            info.getCalledClass(), info.getConstructor());
-      String callName = BehaviorNode.getDefaultKey(info.getCallingMethod());
-      behaviour.insertCaller(callName, info);
+      // get caller behavior node
+      BehaviorNode behavior = getBehavior(info.getAdvisor(),
+            info.getCallingClass(), info.getCallingMethod());
+      // get callee name
+      String callName = BehaviorNode.getDefaultKey(info.getConstructor());
+      // insert
+      behavior.insertCallee(callName, info);
    }
    
    public synchronized void register(MethodByMethodInfo info)
    {
-      BehaviorNode behaviour = getBehaviour(info.getAdvisor(),
-            info.getCalledClass(), info.getMethod());
-      String callerName = BehaviorNode.getDefaultKey(info.getCallingMethod());
-      behaviour.insertCaller(callerName, info);
+      // get caller behavior node
+      BehaviorNode behavior = getBehavior(info.getAdvisor(),
+            info.getCallingClass(), info.getCallingMethod());
+      // get callee name
+      String calleeName = BehaviorNode.getDefaultKey(info.getMethod());
+      // insert
+      behavior.insertCallee(calleeName, info);
    }
    
    public synchronized void register(MethodByConInfo info)
    {
-      BehaviorNode behaviour = getBehaviour(info.getAdvisor(),
-            info.getCalledClass(), info.getMethod());
-      String callerName = BehaviorNode.getDefaultKey(info.getCallingConstructor());
-      behaviour.insertCaller(callerName, info);
+      // get caller behavior node
+      BehaviorNode behavior = getBehavior(info.getAdvisor(),
+            info.getCallingClass(), info.getCallingConstructor());
+      // get callee name
+      String calleeName = BehaviorNode.getDefaultKey(info.getMethod());
+      // insert
+      behavior.insertCallee(calleeName, info);
    }
 
    /**
@@ -136,10 +149,10 @@
     * @param constructor
     * @return
     */
-   private BehaviorNode getBehaviour(Advisor advisor, Class clazz, Constructor constructor)
+   private BehaviorNode getBehavior(Advisor advisor, Class clazz, Constructor constructor)
    {
-      ClassNode classNode = getClassNode(clazz, advisor);
-      return classNode.getBehaviour(constructor);
+      AdvisedData advisedData = getClassNode(clazz).getAdvisedData(advisor);
+      return advisedData.getBehavior(constructor);
    }
    
    /**
@@ -147,23 +160,11 @@
     * @param method
     * @return
     */
-   private BehaviorNode getBehaviour(Advisor advisor, Class clazz, Method method)
+   private BehaviorNode getBehavior(Advisor advisor, Class clazz, Method method)
    {
-      ClassNode classNode = getClassNode(clazz, advisor);
-      return classNode.getBehaviour(method);
+      AdvisedData advisedData = getClassNode(clazz).getAdvisedData(advisor);
+      return advisedData.getBehavior(method);
    }
-   
-   private ClassNode getClassNode(Class clazz, Advisor advisor)
-   {
-      String defaultKey = ClassNode.getDefaultKey(clazz);
-      ClassNode classNode = classTree.searchValue(defaultKey);
-      if (classNode == null)
-      {
-         classNode = new ClassNode(clazz, advisor);
-         insertClassNode(clazz, defaultKey, classNode);
-      }
-      return classNode;
-   }
 
    /**
     * @param clazz
@@ -183,10 +184,10 @@
    {
       if (clazz.getSuperclass() != null)
       {
-         getClassNode(clazz.getSuperclass()).addDirectSubtype(classNode);
+         getClassNode(clazz.getSuperclass()).addSubtype(classNode);
          for (Class interfaceClass: clazz.getInterfaces())
          {
-            getClassNode(interfaceClass).addDirectSubtype(classNode);
+            getClassNode(interfaceClass).addSubtype(classNode);
          }
       }
    }
@@ -199,7 +200,7 @@
       {
          return classNode;
       }
-      classNode = new ClassNode(clazz);
+      classNode = new SimpleClassNode(clazz);
       insertClassNode(clazz, defaultKey, classNode);
       return classNode;
    }

Added: projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/SimpleClassNode.java
===================================================================
--- projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/SimpleClassNode.java	                        (rev 0)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/SimpleClassNode.java	2008-06-07 05:00:57 UTC (rev 74277)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.aop.joinpoint.graph;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.aop.Advisor;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ */
+class SimpleClassNode extends ClassNode
+{
+   private Collection<ClassNode> directSubtypes;
+   
+   public SimpleClassNode(Class clazz)
+   {
+      super(clazz);
+      this.directSubtypes = new ArrayList<ClassNode>(1);
+   }
+   
+   /**
+    * Adds a direct subtype of the class represented by this node.
+    * 
+    * @param directSubtype the node that represents a direct subtype of the class
+    *                      represented by this node
+    */
+   public void addSubtype(ClassNode directSubtype)
+   {
+      this.directSubtypes.add(directSubtype);
+   }
+   
+   public Collection<ClassNode> getSubtypes()
+   {
+      return this.directSubtypes;
+   }
+}




More information about the jboss-cvs-commits mailing list