[jboss-cvs] JBossAS SVN: r75189 - 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
Sun Jun 29 20:56:26 EDT 2008
Author: flavia.rainone at jboss.com
Date: 2008-06-29 20:56:26 -0400 (Sun, 29 Jun 2008)
New Revision: 75189
Modified:
projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java
Log:
[JBAOP-504] Recommitting joinpoint graph interface.
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-30 00:44:49 UTC (rev 75188)
+++ projects/aop/branches/joinpoint_graph/aop/src/main/org/jboss/aop/joinpoint/graph/JoinPointGraph.java 2008-06-30 00:56:26 UTC (rev 75189)
@@ -1,5 +1,5 @@
/*
- * JBoss, Home of Professional Open Sorce
+ * 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.
@@ -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 yor option) any later version.
+ * 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
@@ -21,187 +21,22 @@
*/
package org.jboss.aop.joinpoint.graph;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
import java.util.Collection;
-import java.util.HashSet;
-import org.jboss.aop.Advisor;
-import org.jboss.aop.ConByConInfo;
-import org.jboss.aop.ConByMethodInfo;
-import org.jboss.aop.ConstructionInfo;
-import org.jboss.aop.ConstructorInfo;
-import org.jboss.aop.FieldInfo;
import org.jboss.aop.JoinPointInfo;
-import org.jboss.aop.MethodByConInfo;
-import org.jboss.aop.MethodByMethodInfo;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.joinpoint.JoinPointRegistry;
-import org.jboss.aop.joinpoint.graph.tree.Tree;
/**
- * Searchable data structure containing all loaded prepared joinpoints.
+ * Searchable data structure containing prepared joinpoints.
*
* @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
*/
-public class JoinPointGraph implements JoinPointRegistry
+public interface JoinPointGraph
{
- private static final JoinPointGraph INSTANCE = new JoinPointGraph();
-
- private Tree<ClassNode> classTree;
-
- private JoinPointGraph()
- {
- this.classTree = new Tree<ClassNode>();
- }
-
- public static JoinPointGraph getInstance()
- {
- return INSTANCE;
- }
-
- public Collection<JoinPointInfo> search(SearchKey key)
- {
- Collection<JoinPointInfo> result = new HashSet<JoinPointInfo>();
- ((ParsedSearchKey) key).search(classTree, result);
- return result;
- }
-
- public synchronized void register(FieldInfo info)
- {
- Advisor advisor = info.getAdvisor();
- AdvisedData advisedData = getClassNode(info.getClazz()).getAdvisedData(advisor);
- FieldNode fieldNode = advisedData.getField(info.getField());
- if (info.isRead())
- {
- fieldNode.setFieldRead(info);
- }
- else
- {
- fieldNode.setFieldWrite(info);
- }
- }
-
- public synchronized void register(ConstructorInfo info)
- {
- getBehavior(info.getAdvisor(), info.getClazz(), info.getConstructor()).
- setExecution(info);
- }
-
- public synchronized void register(ConstructionInfo info)
- {
- getBehavior(info.getAdvisor(), info.getClazz(), info.getConstructor()).
- setConstruction(info);
- }
-
- public synchronized void register(MethodInfo info)
- {
- getBehavior(info.getAdvisor(), info.getClazz(), info.getMethod()).
- setExecution(info);
- }
-
- public synchronized void register(ConByConInfo 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)
- {
- // 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)
- {
- // 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)
- {
- // 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);
- }
-
/**
- * @param classNode
- * @param constructor
- * @return
+ * Performs a search on this graph.
+ *
+ * @param key contains all the information necessary to perform the search
+ * @return a collection containing all joinpoints found during the search
*/
- private BehaviorNode getBehavior(Advisor advisor, Class clazz, Constructor constructor)
- {
- AdvisedData advisedData = getClassNode(clazz).getAdvisedData(advisor);
- return advisedData.getBehavior(constructor);
- }
-
- /**
- * @param classNode
- * @param method
- * @return
- */
- private BehaviorNode getBehavior(Advisor advisor, Class clazz, Method method)
- {
- AdvisedData advisedData = getClassNode(clazz).getAdvisedData(advisor);
- return advisedData.getBehavior(method);
- }
-
- /**
- * @param clazz
- * @param classNode
- */
- private void insertClassNode(Class clazz, String defaultKey, ClassNode classNode)
- {
- TreeInsertionUtil.insertNode(classNode, defaultKey, classTree);
- insertHierarchy(clazz, classNode);
- }
-
- /**
- * @param clazz
- * @param classNode
- */
- private void insertHierarchy(Class clazz, ClassNode classNode)
- {
- if (clazz.getSuperclass() != null)
- {
- getClassNode(clazz.getSuperclass()).addSubtype(classNode);
- for (Class interfaceClass: clazz.getInterfaces())
- {
- getClassNode(interfaceClass).addSubtype(classNode);
- }
- }
- }
-
- private ClassNode getClassNode(Class clazz)
- {
- String defaultKey = ClassNode.getDefaultKey(clazz);
- ClassNode classNode = classTree.searchValue(defaultKey);
- if (classNode != null)
- {
- return classNode;
- }
- classNode = new SimpleClassNode(clazz);
- insertClassNode(clazz, defaultKey, classNode);
- return classNode;
- }
+ public Collection<JoinPointInfo> search(SearchKey key);
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list