Skip to content

Commit 6c4dc5e

Browse files
committed
refactor from custom locator to java 6+ service locator
1 parent 4696d31 commit 6c4dc5e

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.objectquery.mongodb;
2+
3+
import org.mongodb.morphia.Datastore;
4+
import org.objectquery.QueryEngine;
5+
import org.objectquery.QueryEngineFactory;
6+
7+
import com.mongodb.DBCollection;
8+
9+
public class MongoQueryEngineFactory implements QueryEngineFactory {
10+
11+
@SuppressWarnings("unchecked")
12+
@Override
13+
public <S> QueryEngine<S> createQueryEngine(Class<S> targetSession) {
14+
if (DBCollection.class.equals(targetSession))
15+
return createDefaultQueryEngine();
16+
if (Datastore.class.equals(targetSession))
17+
return (QueryEngine<S>) new MorphiaQueryEngine();
18+
return null;
19+
}
20+
21+
@Override
22+
@SuppressWarnings("unchecked")
23+
public <T> QueryEngine<T> createDefaultQueryEngine() {
24+
return (QueryEngine<T>) new MongoDBQueryEngine();
25+
}
26+
27+
}

src/main/resources/META-INF/ObjectQueryEngine.properties

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.objectquery.mongodb.MongoQueryEngineFactory

src/test/java/org/objectquery/mongodb/domain/Window.java

+15
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,19 @@ public class Window {
55
private int width;
66
private int height;
77

8+
public int getHeight() {
9+
return height;
10+
}
11+
12+
public void setHeight(int height) {
13+
this.height = height;
14+
}
15+
16+
public int getWidth() {
17+
return width;
18+
}
19+
20+
public void setWidth(int width) {
21+
this.width = width;
22+
}
823
}

0 commit comments

Comments
 (0)