public final class Morphium extends Object implements MorphiumWriter
| Constructor and Description |
|---|
Morphium(MorphiumConfig cfg)
init the MongoDbLayer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(MorphiumStorageListener lst) |
void |
addProfilingListener(ProfilingListener l) |
void |
addShutdownListener(ShutdownListener l) |
<T,R> List<R> |
aggregate(Aggregator<T,R> a) |
void |
clearCachefor(Class<?> cls)
Erase cache entries for the given type. is being called after every store
depending on cache settings!
|
void |
clearCollection(Class<?> cls)
issues a delete command - no lifecycle methods calles, no drop, keeps all indexec this way
|
void |
clearCollectionOneByOne(Class<?> cls)
clears every single object in collection - reads ALL objects to do so
this way Lifecycle methods can be called!
|
void |
close() |
<T,R> Aggregator<T,R> |
createAggregator(Class<? extends T> type,
Class<? extends R> resultType) |
String |
createCamelCase(String n) |
<T> T |
createLazyLoadedEntity(Class<? extends T> cls,
org.bson.types.ObjectId id) |
<T> MongoField<T> |
createMongoField() |
<T> T |
createPartiallyUpdateableEntity(T o)
create a proxy object, implementing the ParitallyUpdateable Interface
these objects will be updated in mongo by only changing altered fields
Attention: the field name if determined by the setter name for now.
|
<T> Query<T> |
createQueryFor(Class<? extends T> type) |
void |
dec(Object toDec,
String field,
int amount)
decreasing a value of a given object
calles
inc(toDec,field,-amount); |
void |
dec(Query<?> query,
Enum field,
int amount) |
void |
dec(Query<?> query,
Enum field,
int amount,
boolean insertIfNotExist,
boolean multiple) |
void |
dec(Query<?> query,
String field,
int amount) |
void |
dec(Query<?> query,
String field,
int amount,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
delete(List<T> lst,
AsyncOperationCallback<T> callback) |
void |
delete(Object o)
deletes a single object from morphium backend.
|
<T> void |
delete(Query<T> o) |
<T> void |
delete(Query<T> o,
AsyncOperationCallback<T> callback)
deletes all objects matching the given query
|
<T> void |
delete(T lo,
AsyncOperationCallback<T> callback) |
List<Object> |
distinct(Enum key,
Class c) |
List<Object> |
distinct(Enum key,
Query q)
returns a distinct list of values of the given collection
Attention: these values are not unmarshalled, you might get MongoDBObjects
|
List<Object> |
distinct(String key,
Class cls) |
List<Object> |
distinct(String key,
Query q)
returns a distinct list of values of the given collection
Attention: these values are not unmarshalled, you might get MongoDBObjects
|
void |
dropCollection(Class<?> cls) |
<T> void |
dropCollection(Class<T> cls,
AsyncOperationCallback<T> callback) |
void |
ensureIndex(Class<?> cls,
Enum... fldStr) |
void |
ensureIndex(Class<?> cls,
Map<String,Object> index) |
void |
ensureIndex(Class<?> cls,
String... fldStr) |
<T> void |
ensureIndex(Class<T> cls,
AsyncOperationCallback<T> callback,
Enum... fldStr)
ensureIndex(CachedObject.class,"counter","-value");
ensureIndex(CachedObject.class,"counter:2d","-value);
Similar to sorting
|
<T> void |
ensureIndex(Class<T> cls,
AsyncOperationCallback<T> callback,
String... fldStr) |
<T> void |
ensureIndex(Class<T> cls,
Map<String,Object> index,
AsyncOperationCallback<T> callback) |
void |
ensureIndicesFor(Class type)
can be called for autmatic index ensurance.
|
<T> List<T> |
find(Query<T> q) |
<T> List<T> |
findByField(Class<? extends T> cls,
Enum fld,
Object val) |
<T> List<T> |
findByField(Class<? extends T> cls,
String fld,
Object val) |
<T> T |
findById(Class<? extends T> type,
org.bson.types.ObjectId id) |
<T> List<T> |
findByTemplate(T template,
String... fields)
search for objects similar to template concerning all given fields.
|
void |
firePostDropEvent(Class cls) |
void |
firePostLoadEvent(Object o)
will be called by query after unmarshalling
|
void |
firePostRemoveEvent(Object o) |
void |
firePostRemoveEvent(Query q) |
void |
firePostStoreEvent(Object o,
boolean isNew) |
void |
firePostUpdateEvent(Class cls,
MorphiumStorageListener.UpdateTypes t) |
void |
firePreDropEvent(Class cls) |
void |
firePreRemoveEvent(Object o) |
void |
firePreRemoveEvent(Query q) |
void |
firePreStoreEvent(Object o,
boolean isNew) |
void |
firePreUpdateEvent(Class cls,
MorphiumStorageListener.UpdateTypes t) |
void |
fireProfilingReadEvent(Query q,
long time,
ReadAccessType t) |
void |
fireProfilingWriteEvent(Class type,
Object data,
long time,
boolean isNew,
WriteAccessType wt) |
AnnotationAndReflectionHelper |
getARHelper() |
int |
getBufferedWriterBufferCount() |
MorphiumCache |
getCache() |
MorphiumConfig |
getConfig() |
ConfigManager |
getConfigManager() |
com.mongodb.DB |
getDatabase() |
org.bson.types.ObjectId |
getId(Object o) |
ObjectMapper |
getMapper() |
com.mongodb.Mongo |
getMongo() |
ReplicaSetStatus |
getReplicaSetStatus()
same as retReplicaSetStatus(false);
|
ReplicaSetStatus |
getReplicaSetStatus(boolean full)
get the current replicaset status - issues the replSetGetStatus command to mongo
if full==true, also the configuration is read.
|
Map<String,Double> |
getStatistics() |
Map<StatisticKeys,StatisticValue> |
getStats() |
int |
getWriteBufferCount() |
com.mongodb.WriteConcern |
getWriteConcernForClass(Class<?> cls) |
int |
getWriterBufferCount() |
MorphiumWriter |
getWriterForClass(Class<?> cls) |
com.mongodb.DBObject |
group(Query q,
Map<String,Object> initial,
String jsReduce,
String jsFinalize,
String... keys) |
void |
inc(Object toSet,
String field,
int i) |
void |
inc(Query<?> query,
Enum field,
int amount) |
void |
inc(Query<?> query,
Enum field,
int amount,
boolean insertIfNotExist,
boolean multiple) |
void |
inc(Query<?> query,
String field,
int amount) |
void |
inc(Query<?> query,
String name,
int amount,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
inc(Query<T> query,
String name,
int amount,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
void |
inc(StatisticKeys k) |
<T> void |
inc(T toSet,
String field,
int i,
AsyncOperationCallback<T> callback)
Increases a value in an existing mongo collection entry - no reading necessary.
|
boolean |
isReplicaSet() |
void |
pull(Query<?> query,
Enum field,
Object value) |
void |
pull(Query<?> query,
Enum field,
Object value,
boolean insertIfNotExist,
boolean multiple) |
void |
pull(Query<?> query,
String field,
Object value) |
<T> void |
pull(Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
pull(Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback)
Asynchronous call to pulll
|
void |
pullAll(Query<?> query,
Enum field,
List<Object> value,
boolean insertIfNotExist,
boolean multiple) |
void |
pullAll(Query<?> query,
String field,
List<Object> value,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
pullAll(Query<T> query,
String field,
List<?> value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
void |
push(Query<?> query,
Enum field,
Object value) |
void |
push(Query<?> query,
Enum field,
Object value,
boolean insertIfNotExist,
boolean multiple) |
void |
push(Query<?> query,
String field,
Object value) |
<T> void |
push(Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
push(Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback)
asynchronous call to callback
|
void |
pushAll(Query<?> query,
Enum field,
List<Object> value,
boolean insertIfNotExist,
boolean multiple) |
void |
pushAll(Query<?> query,
String field,
List<?> value,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
pushAll(Query<T> query,
String field,
List<?> value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
<T> void |
pushPull(boolean push,
Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
<T> void |
pushPullAll(boolean push,
Query<T> query,
String field,
List<?> value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
<T> List<T> |
readAll(Class<? extends T> cls)
return a list of all elements stored in morphium for this type
|
void |
removeListener(MorphiumStorageListener lst) |
void |
removeProfilingListener(ProfilingListener l) |
void |
removeShutdownListener(ShutdownListener l) |
<T> T |
reread(T o)
careful this actually changes the parameter o!
|
void |
set(Object toSet,
Enum field,
Object value) |
void |
set(Object toSet,
String field,
Object value)
setting a value in an existing mongo collection entry - no reading necessary.
|
void |
set(Query<?> query,
Map<String,Object> map,
boolean insertIfNotExist,
boolean multiple) |
<T> void |
set(Query<T> query,
Enum field,
Object val) |
<T> void |
set(Query<T> query,
Enum field,
Object val,
AsyncOperationCallback<T> callback) |
<T> void |
set(Query<T> query,
Map<String,Object> map,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback)
will change an entry in mongodb-collection corresponding to given class object
if query is too complex, upsert might not work!
|
<T> void |
set(Query<T> query,
String field,
Object val) |
<T> void |
set(Query<T> query,
String field,
Object val,
AsyncOperationCallback<T> callback) |
<T> void |
set(Query<T> query,
String field,
Object val,
boolean insertIfNotExist,
boolean multiple)
will change an entry in mongodb-collection corresponding to given class object
if query is too complex, upsert might not work!
|
<T> void |
set(Query<T> query,
String field,
Object val,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback) |
<T> void |
set(T toSet,
Enum field,
Object value,
AsyncOperationCallback<T> callback) |
<T> void |
set(T toSet,
String field,
Object value,
AsyncOperationCallback<T> callback) |
<T> void |
set(T toSet,
String field,
Object value,
boolean insertIfNotExists,
boolean multiple,
AsyncOperationCallback<T> callback)
changes an object in DB AND in Memory...
|
void |
setEnum(Query<?> query,
Map<Enum,Object> values,
boolean insertIfNotExist,
boolean multiple) |
void |
setMorphium(Morphium m) |
com.mongodb.DBObject |
simplifyQueryObject(com.mongodb.DBObject q) |
<T> void |
store(List<T> lst,
AsyncOperationCallback<T> callback)
stores the given list of objects, should be entities or embedded
|
<T> void |
store(T o)
Stores a single Object.
|
<T> void |
store(T o,
AsyncOperationCallback<T> callback)
Stores the object, should be an entity
|
<T> void |
storeInBackground(T lst) |
<T> void |
storeInBackground(T lst,
AsyncOperationCallback<T> callback) |
<T> void |
storeList(List<T> lst) |
<T> void |
storeList(List<T> lst,
AsyncOperationCallback<T> callback) |
<T> void |
storeNoCache(T lst) |
<T> void |
storeNoCache(T lst,
AsyncOperationCallback<T> callback) |
String |
toJsonString(Object o) |
<T> void |
unset(T toSet,
Enum field) |
<T> void |
unset(T toSet,
String field) |
<T> void |
unset(T toSet,
String field,
AsyncOperationCallback<T> callback)
Un-setting a value in an existing mongo collection entry - no reading necessary.
|
void |
updateUsingFields(Object ent,
String... fields)
updating an enty in DB without sending the whole entity
only transfers the fields to be changed / set
|
<T> void |
updateUsingFields(T ent,
AsyncOperationCallback<T> callback,
String... fields)
update an object using fields specified
|
int |
writeBufferCount() |
public Morphium(MorphiumConfig cfg)
MorphiumConfigpublic MorphiumConfig getConfig()
public MorphiumCache getCache()
public void addListener(MorphiumStorageListener lst)
public void removeListener(MorphiumStorageListener lst)
public com.mongodb.Mongo getMongo()
public com.mongodb.DB getDatabase()
public ConfigManager getConfigManager()
public <T> List<T> findByTemplate(T template, String... fields)
T - - typetemplate - - what to search forfields - - fields to use for searchingpublic <T> void unset(T toSet,
Enum field)
public <T> void unset(T toSet,
String field)
public <T> void unset(T toSet,
String field,
AsyncOperationCallback<T> callback)
MorphiumWriterunset in interface MorphiumWriterpublic void ensureIndicesFor(Class type)
type - type to ensure indices forpublic com.mongodb.DBObject simplifyQueryObject(com.mongodb.DBObject q)
public <T> void set(Query<T> query, Enum field, Object val, AsyncOperationCallback<T> callback)
public <T> void set(Query<T> query, String field, Object val, AsyncOperationCallback<T> callback)
public void setEnum(Query<?> query, Map<Enum,Object> values, boolean insertIfNotExist, boolean multiple)
public void push(Query<?> query, Enum field, Object value, boolean insertIfNotExist, boolean multiple)
public void pull(Query<?> query, Enum field, Object value, boolean insertIfNotExist, boolean multiple)
public void pushAll(Query<?> query, Enum field, List<Object> value, boolean insertIfNotExist, boolean multiple)
public void pullAll(Query<?> query, Enum field, List<Object> value, boolean insertIfNotExist, boolean multiple)
public <T> void push(Query<T> query, String field, Object value, boolean insertIfNotExist, boolean multiple)
public <T> void push(Query<T> query, String field, Object value, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
T - - the typequery - - the queryfield - - field to push values tovalue - - value to pushinsertIfNotExist - - insert object, if it does not existmultiple - - more than onecallback - - will be called, when operation succeeds - synchronous call, if nullpublic <T> void pull(Query<T> query, String field, Object value, boolean insertIfNotExist, boolean multiple)
public <T> void pull(Query<T> query, String field, Object value, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
T - - typequery - - queryfield - - field to pullvalue - - value to pull from fieldinsertIfNotExist - - insert document unless it existsmultiple - - more than onecallback - -callback to call when operation succeeds - synchronous call, if nullpublic void pushAll(Query<?> query, String field, List<?> value, boolean insertIfNotExist, boolean multiple)
public <T> void pushAll(Query<T> query, String field, List<?> value, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
public void pullAll(Query<?> query, String field, List<Object> value, boolean insertIfNotExist, boolean multiple)
public <T> void set(Query<T> query, String field, Object val, boolean insertIfNotExist, boolean multiple)
query - - query to specify which objects should be setfield - - field to setval - - value to setinsertIfNotExist - - insert, if it does not exist (query needs to be simple!)multiple - - update several documents, if false, only first hit will be updatedpublic <T> void set(Query<T> query, String field, Object val, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
public void set(Query<?> query, Map<String,Object> map, boolean insertIfNotExist, boolean multiple)
public <T> void set(Query<T> query, Map<String,Object> map, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
MorphiumWriterset in interface MorphiumWriterquery - - query to specify which objects should be setmap - - map fieldName->Value, which values are to be set!insertIfNotExist - - insert, if it does not exist (query needs to be simple!)multiple - - update several documents, if false, only first hit will be updatedpublic void dec(Query<?> query, Enum field, int amount, boolean insertIfNotExist, boolean multiple)
public void dec(Query<?> query, String field, int amount, boolean insertIfNotExist, boolean multiple)
public void inc(Query<?> query, Enum field, int amount, boolean insertIfNotExist, boolean multiple)
public void inc(Query<?> query, String name, int amount, boolean insertIfNotExist, boolean multiple)
public <T> void inc(Query<T> query, String name, int amount, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
inc in interface MorphiumWriterpublic <T> void set(T toSet,
Enum field,
Object value,
AsyncOperationCallback<T> callback)
public void set(Object toSet, String field, Object value)
toSet: - object to set the value in (or better - the corresponding entry in mongo)field: - the field to changevalue: - the value to setpublic <T> void set(T toSet,
String field,
Object value,
boolean insertIfNotExists,
boolean multiple,
AsyncOperationCallback<T> callback)
MorphiumWriterset in interface MorphiumWritertoSet - entity to set values in both in mongo and in memoryfield - fieldvalue - value to setpublic <T> void set(T toSet,
String field,
Object value,
AsyncOperationCallback<T> callback)
public MorphiumWriter getWriterForClass(Class<?> cls)
public void dec(Object toDec, String field, int amount)
inc(toDec,field,-amount);public <T> void inc(T toSet,
String field,
int i,
AsyncOperationCallback<T> callback)
MorphiumWriterinc in interface MorphiumWriterpublic void setMorphium(Morphium m)
setMorphium in interface MorphiumWriterpublic <T> void delete(List<T> lst, AsyncOperationCallback<T> callback)
delete in interface MorphiumWriterpublic void inc(StatisticKeys k)
public void updateUsingFields(Object ent, String... fields)
ent - - entity to updatefields - - fields to usepublic <T> void updateUsingFields(T ent,
AsyncOperationCallback<T> callback,
String... fields)
MorphiumWriterupdateUsingFields in interface MorphiumWriterent - entityfields - - fieldspublic ObjectMapper getMapper()
public AnnotationAndReflectionHelper getARHelper()
public <T> T reread(T o)
T - - tpye of the objecto - - object to readpublic void firePreStoreEvent(Object o, boolean isNew)
public void firePostStoreEvent(Object o, boolean isNew)
public void firePreDropEvent(Class cls)
public void firePostDropEvent(Class cls)
public void firePostUpdateEvent(Class cls, MorphiumStorageListener.UpdateTypes t)
public void firePreUpdateEvent(Class cls, MorphiumStorageListener.UpdateTypes t)
public void firePostRemoveEvent(Object o)
public void firePostRemoveEvent(Query q)
public void firePreRemoveEvent(Object o)
public void firePreRemoveEvent(Query q)
public void firePostLoadEvent(Object o)
o - - entitiypublic ReplicaSetStatus getReplicaSetStatus()
public ReplicaSetStatus getReplicaSetStatus(boolean full)
full - - if true- return full statuspublic boolean isReplicaSet()
public com.mongodb.WriteConcern getWriteConcernForClass(Class<?> cls)
public void addProfilingListener(ProfilingListener l)
public void removeProfilingListener(ProfilingListener l)
public void fireProfilingWriteEvent(Class type, Object data, long time, boolean isNew, WriteAccessType wt)
public void fireProfilingReadEvent(Query q, long time, ReadAccessType t)
public void clearCollection(Class<?> cls)
cls - - classpublic void clearCollectionOneByOne(Class<?> cls)
cls - -classpublic <T> List<T> readAll(Class<? extends T> cls)
T - - Typecls - - type to search for, needs to be an Propertypublic List<Object> distinct(Enum key, Query q)
public List<Object> distinct(String key, Query q)
public com.mongodb.DBObject group(Query q, Map<String,Object> initial, String jsReduce, String jsFinalize, String... keys)
public <T> T findById(Class<? extends T> type, org.bson.types.ObjectId id)
public void clearCachefor(Class<?> cls)
cls - - classpublic <T> void storeNoCache(T lst)
public <T> void storeNoCache(T lst,
AsyncOperationCallback<T> callback)
public <T> void storeInBackground(T lst)
public <T> void storeInBackground(T lst,
AsyncOperationCallback<T> callback)
public org.bson.types.ObjectId getId(Object o)
public <T> void dropCollection(Class<T> cls, AsyncOperationCallback<T> callback)
dropCollection in interface MorphiumWriterpublic void dropCollection(Class<?> cls)
public <T> void ensureIndex(Class<T> cls, Map<String,Object> index, AsyncOperationCallback<T> callback)
ensureIndex in interface MorphiumWriterpublic int writeBufferCount()
writeBufferCount in interface MorphiumWriterpublic <T> void ensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, Enum... fldStr)
cls - - classfldStr - - fieldspublic <T> void ensureIndex(Class<T> cls, AsyncOperationCallback<T> callback, String... fldStr)
public <T> void store(T o)
o - - Object to storepublic <T> void store(T o,
AsyncOperationCallback<T> callback)
MorphiumWriterstore in interface MorphiumWritero - - entitypublic <T> void store(List<T> lst, AsyncOperationCallback<T> callback)
MorphiumWriterstore in interface MorphiumWriterlst - - to storepublic <T> void storeList(List<T> lst)
public <T> void storeList(List<T> lst, AsyncOperationCallback<T> callback)
public <T> void delete(Query<T> o)
public <T> void delete(Query<T> o, AsyncOperationCallback<T> callback)
MorphiumWriterdelete in interface MorphiumWritero - the querypublic <T> void pushPull(boolean push,
Query<T> query,
String field,
Object value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback)
pushPull in interface MorphiumWriterpublic <T> void pushPullAll(boolean push,
Query<T> query,
String field,
List<?> value,
boolean insertIfNotExist,
boolean multiple,
AsyncOperationCallback<T> callback)
pushPullAll in interface MorphiumWriterpublic <T> void pullAll(Query<T> query, String field, List<?> value, boolean insertIfNotExist, boolean multiple, AsyncOperationCallback<T> callback)
public void delete(Object o)
o - - entitypublic <T> void delete(T lo,
AsyncOperationCallback<T> callback)
delete in interface MorphiumWriterpublic Map<StatisticKeys,StatisticValue> getStats()
public void addShutdownListener(ShutdownListener l)
public void removeShutdownListener(ShutdownListener l)
public void close()
public <T,R> Aggregator<T,R> createAggregator(Class<? extends T> type, Class<? extends R> resultType)
public <T,R> List<R> aggregate(Aggregator<T,R> a)
public <T> T createPartiallyUpdateableEntity(T o)
T - - typeo - - entitypublic <T> T createLazyLoadedEntity(Class<? extends T> cls, org.bson.types.ObjectId id)
public <T> MongoField<T> createMongoField()
public int getWriteBufferCount()
public int getBufferedWriterBufferCount()
public int getWriterBufferCount()
Copyright © 2013. All Rights Reserved.