Permalink
Browse files

Better argument handling and display.

  • Loading branch information...
1 parent 3c5e258 commit 466a2a8874a9353454b5a21602b89f27ff3ebf5b @NogbadTheBad NogbadTheBad committed Dec 5, 2010
@@ -142,9 +142,9 @@ private ArgUtils() {
/**
* Convert an {@link Object}[] to a {@link String}. Don't convert more than
- * MAX_ARGS arguments and don't make it more than about maxLength long.
+ * MAX_ARGS arguments and don't make it more than roughly maxLength long.
*
- * Append ellipses to any argument we truncate, or to the whole array cif
+ * Append ellipses to any argument we truncate, or to the whole array if
* it's too long.
*
* @param array
@@ -153,8 +153,8 @@ private ArgUtils() {
*/
public static List<String> toString(final Object[] array,
final int maxLength) {
- final int maxArgs = Math.min(MAX_ARGS, array.length);
- final int elementLength = maxLength / Math.min(1, maxArgs);
+ final int nArgs = Math.min(MAX_ARGS, array.length);
+ final int elementLength = maxLength / Math.max(1, nArgs);
return new ArrayList<String>() {
{
@@ -10,7 +10,7 @@
* @author stephen harrison
*/
public abstract class MongoBasicOperation extends BasicOperation {
- private Object rawReturnValue;
+ // private Object rawReturnValue;
public MongoBasicOperation(final SourceCodeLocation scl) {
super(scl);
@@ -19,16 +19,16 @@ public MongoBasicOperation(final SourceCodeLocation scl) {
/**
* A version of this method that knows about MongoDB types
*/
- @Override
- public void setReturnValue(final Object returnValue) {
- super.setReturnValue(returnValue);
+ // @Override
+ // public void setReturnValue(final Object returnValue) {
+ // super.setReturnValue(returnValue);
+ //
+ // rawReturnValue = returnValue;
+ // }
- rawReturnValue = returnValue;
- }
-
- @Override
- public String getReturnValue() {
- return "xyz";
- // return ArgUtils.toString(rawReturnValue);
- }
+ // @Override
+ // public String getReturnValue() {
+ // return "xyz";
+ // // return ArgUtils.toString(rawReturnValue);
+ // }
}
@@ -1,12 +1,12 @@
package org.harrison.insight.plugin.mongodb;
-import java.util.Arrays;
import java.util.List;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MapReduceOutput;
import com.mongodb.WriteResult;
@@ -20,18 +20,26 @@ public aspect MongoCollectionOperationCollectionAspect extends
public pointcut updateExecute(): execution(WriteResult DBCollection.update(..));
- public pointcut removeExecute(): execution(WriteResult DBCollection.remove(..));
+ public pointcut updateMultiExecute(): execution(WriteResult DBCollection.updateMulti(..));
- public pointcut findExecute(): execution(com.mongodb.DBCursor DBCollection.find(..));
+ public pointcut removeExecute(): execution(WriteResult DBCollection.remove(..));
- public pointcut createIndexExecute(): execution(void DBCollection.createIndex(..));
+ public pointcut findExecute(): execution(DBCursor DBCollection.find(..));
public pointcut findOneExecute(): execution(DBObject DBCollection.findOne(..));
public pointcut findAndModifyExecute(): execution(DBObject DBCollection.findAndModify(..));
+ public pointcut findAndRemoveExecute(): execution(DBObject DBCollection.findAndRemove(..));
+
+ public pointcut createIndexExecute(): execution(void DBCollection.createIndex(..));
+
public pointcut ensureIndexExecute(): execution(void DBCollection.ensureIndex(..));
+ public pointcut applyExecute(): execution(Object DBCollection.apply(..));
+
+ public pointcut saveExecute(): execution(WriteResult DBCollection.save(..));
+
public pointcut dropExecute(): execution(void DBCollection.drop());
public pointcut getCountExecute(): execution(long DBCollection.getCount(..));
@@ -45,27 +53,31 @@ public aspect MongoCollectionOperationCollectionAspect extends
public pointcut dropIndexExecute(): execution(void DBCollection.dropIndex(..));
public pointcut collectionPoint():
- insertExecute() && !cflowbelow(insertExecute())
- ;
-
- /*
- * insertExecute() || updateExecute() || removeExecute() || findExecute() ||
- * findOneExecute() || createIndexExecute() || findAndModifyExecute() ||
- * ensureIndexExecute() || dropExecute() || getCountExecute() ||
- * groupExecute() || distinctExecute() || mapReduceExecute() ||
- * dropIndexExecute() ;
- */
+ insertExecute() ||
+ updateExecute() ||
+ updateMultiExecute() ||
+ removeExecute() ||
+ findExecute() ||
+ findOneExecute() ||
+ findAndModifyExecute() ||
+ createIndexExecute() ||
+ ensureIndexExecute() ||
+ applyExecute() ||
+ saveExecute() ||
+ dropExecute() ||
+ getCountExecute() ||
+ groupExecute() ||
+ distinctExecute() ||
+ mapReduceExecute() ||
+ dropIndexExecute();
@Override
protected Operation createOperation(final JoinPoint joinPoint) {
final Signature signature = joinPoint.getSignature();
final DBCollection collection = (DBCollection) joinPoint.getThis();
return new MongoCollectionOperation(getSourceCodeLocation(joinPoint),
- Arrays.asList("one", "two", "three"), signature.getName(),
+ ArgUtils.toString(joinPoint.getArgs()), signature.getName(),
signature.toShortString(), collection.getFullName());
- // return new MongoCollectionOperation(getSourceCodeLocation(joinPoint),
- // ArgUtils.toString(joinPoint.getArgs()), signature.getName(),
- // signature.toShortString(), collection.getFullName());
}
}
@@ -12,3 +12,5 @@
${operation.returnValue?html}
</@insight.entry>
</@insight.group>
+
+<@insight.sourceCodeLocation location=operation.sourceCodeLocation />
@@ -15,3 +15,5 @@
${operation.returnValue?html}
</@insight.entry>
</@insight.group>
+
+<@insight.sourceCodeLocation location=operation.sourceCodeLocation />
@@ -9,3 +9,5 @@
${operation.returnValue?html}
</@insight.entry>
</@insight.group>
+
+<@insight.sourceCodeLocation location=operation.sourceCodeLocation />

0 comments on commit 466a2a8

Please sign in to comment.