Skip to content

Commit

Permalink
use DBProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jul 27, 2008
1 parent 00ef24c commit 2648046
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 88 deletions.
14 changes: 14 additions & 0 deletions README
@@ -0,0 +1,14 @@
git clone git://github.com/10gen/mongo
cd mongo/db

sudo port install boost pcre++

for i in system thread filesystem; do
sudo ln -s /opt/local/lib/libboost_${i}-mt.dylib /opt/local/lib/libboost_${i}.dylib
done

make clean
make CFLAGS="-I/opt/local/include -L/opt/local/lib -lboost_system"

mkdir /tmp/data
sudo ./db run --nojni --dbpath /tmp/data
Binary file removed bin/mongo/ruby/Mongo$MongoCollection.class
Binary file not shown.
Binary file modified bin/mongo/ruby/Mongo.class
Binary file not shown.
Binary file removed bin/mongo/ruby/RMongo.class
Binary file not shown.
105 changes: 42 additions & 63 deletions src/mongo/ruby/Mongo.java
@@ -1,78 +1,57 @@
package mongo.ruby;

import java.util.*;

import ed.js.*;
import ed.js.func.*;
import ed.js.engine.*;
import ed.db.*;

public class Mongo extends DBBase {

private Map<String,DBCollection> _collections = new TreeMap<String,DBCollection>();

public class Mongo {
public Mongo(){
super("Mongo");
}

protected DBCollection doGetCollection( String name ){
DBCollection c = _collections.get( name );
if ( c == null ){
c = new MongoCollection( this, name );
_collections.put( name, c );
}
return c;
}

public DBCollection getCollectionFromFull( String fullNameSpace ){
throw new RuntimeException( "not implemented" );
}

public Collection<String> getCollectionNames(){
return Collections.unmodifiableSet( _collections.keySet() );
}

public String getConnectPoint(){
return null;
}

class MongoCollection extends DBCollection {
protected MongoCollection(DBBase base, String name) {
super(base, name);
}

protected JSObject doSave(JSObject arg0) {
return null;
}

protected void doapply(JSObject arg0) {
}

protected JSObject dofind(ObjectId arg0) {
return null;
}

public void ensureIndex(JSObject arg0, String arg1) {
}

public Iterator<JSObject> find(JSObject arg0, JSObject arg1, int arg2, int arg3) {
return null;
}
DBApiLayer db = DBProvider.get("mongo");
DBCollection test = db.getCollection("test");

public int remove(JSObject arg0) {
return 0;
}
JSObjectBase obj = new JSObjectBase();
obj.set("name", "mongo");
test.save(obj);

public JSObject update(JSObject arg0, JSObject arg1, boolean arg2, boolean arg3) {
return null;
JSObjectBase query = new JSObjectBase();
query.set("name", "mongo");
for (Iterator<JSObject> it = test.find(query); it.hasNext(); ){
JSObject o = it.next();
System.out.println("got result _id: " + o.get("_id").toString());
System.out.println("got result name: " + o.get("name").toString());
}
}

public static void main(String[] args) {
Mongo db = new Mongo();
DBCollection test = db.getCollection("test");
test.
System.out.println("starting..");
new Mongo();
System.out.println("done.");
}

}
}

/*
$ cat 10gen.properties
BASE=~/code/10gen/appserver/libraries
$ cat run.sh
#!/bin/sh
CLASSPATH=./bin/:~/code/10gen/appserver/build/; for i in ~/code/10gen/appserver/include/*.jar; do CLASSPATH=$CLASSPATH:$i; done; ED_HOME=~/code/10gen/appserver java -cp $CLASSPATH mongo.ruby.Mongo
$ ./run.sh
starting..
loading config file from [./10gen.properties]
DBApiLayer : DBTCP : 127.0.0.1:27017/mongo
Warning : can't find core appserver js sources : no harm, but js will be recompiled on appserver startup
got result _id: 488c4d40771f9ab200645c9d
got result name: mongo
got result _id: 488c4d4f771f9af10025c852
got result name: mongo
got result _id: 488c4fd4771f9ac9006002b5
got result name: mongo
got result _id: 488c4fdd771f9aee00d0fe71
got result name: mongo
done.
*/
25 changes: 0 additions & 25 deletions src/mongo/ruby/RMongo.java

This file was deleted.

0 comments on commit 2648046

Please sign in to comment.