Permalink
Browse files

DBCallback Factory

  • Loading branch information...
1 parent 6d9bf36 commit d2f283cdc38949b5c5d7a0ca96f5998ff109983f @erh erh committed May 7, 2010
Showing with 14 additions and 2 deletions.
  1. +13 −1 src/main/com/mongodb/DBCallback.java
  2. +1 −1 src/main/com/mongodb/Response.java
@@ -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();
}
@@ -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 );
}

0 comments on commit d2f283c

Please sign in to comment.