Skip to content

Commit

Permalink
DBCallback Factory
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed May 7, 2010
1 parent 6d9bf36 commit d2f283c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/main/com/mongodb/DBCallback.java
Expand Up @@ -9,8 +9,20 @@
import org.bson.types.*;

public class DBCallback extends BasicBSONCallback {

public static interface Factory {
public DBCallback create( DBCollection collection );
}

static class DefaultFactory implements Factory {
public DBCallback create( DBCollection collection ){
return new DBCallback( collection );
}
}

public static Factory FACTORY = new DefaultFactory();

DBCallback( DBCollection coll ){
public DBCallback( DBCollection coll ){
_collection = coll;
_db = _collection == null ? null : _collection.getDB();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/com/mongodb/Response.java
Expand Up @@ -83,7 +83,7 @@ DBObject next(){
if ( _readSoFar >= _num )
throw new IllegalStateException( "already finished" );

DBCallback c = new DBCallback( _collection );
DBCallback c = DBCallback.FACTORY.create( _collection );
try {
_decoder.decode( _user , c );
}
Expand Down

0 comments on commit d2f283c

Please sign in to comment.