Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
Better argument handling and display.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudy-native committed Dec 5, 2010
1 parent 3c5e258 commit 466a2a8
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 34 deletions.
Expand Up @@ -142,9 +142,9 @@ public static List<String> toString(final Object[] array) {

/**
* 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
Expand All @@ -153,8 +153,8 @@ public static List<String> toString(final Object[] array) {
*/
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>() {
{
Expand Down
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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(..));
Expand All @@ -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());
}
}
Expand Up @@ -12,3 +12,5 @@
${operation.returnValue?html}
</@insight.entry>
</@insight.group>

<@insight.sourceCodeLocation location=operation.sourceCodeLocation />
Expand Up @@ -15,3 +15,5 @@
${operation.returnValue?html}
</@insight.entry>
</@insight.group>

<@insight.sourceCodeLocation location=operation.sourceCodeLocation />
Expand Up @@ -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.