Package com.codingchili.core.context
Class StorageContext<Value>
java.lang.Object
com.codingchili.core.context.SystemContext
com.codingchili.core.context.StorageContext<Value>
- All Implemented Interfaces:
CoreContext
context used by storage plugins.
-
Field Summary
Fields inherited from class com.codingchili.core.context.SystemContext
vertx
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget the name of the collection within the database used by the context.database()
get the name of the database used by the context.void
handles a handler successfully with the given value.host()
void
Called when the collection has been dropped/cleared.void
onWatcherCompleted(String name, int affected)
Called when a value failed to expire as it was not found.void
onWatcherFailed(String name, String cause)
Called when a value has been expired by ttl.void
onWatcherPaused(String name)
void
onWatcherResumed(String name)
Class<? extends AsyncStorage>
plugin()
port()
io.vertx.core.json.JsonObject
sets the class that is used for deserialization.setCollection(String collection)
sets the collection context of the storage engine.setDatabase(String database)
sets the database name to be usedsetPlugin(Class<? extends AsyncStorage> plugin)
sets the storage plugin name the context is bound to so that configuration for it may be retrieved.setProperties(io.vertx.core.json.JsonObject properties)
protected StorageSettings
settings()
storage()
io.vertx.core.json.JsonObject
converts the given object of generic type into a json object.byte[]
converts the given object of generic type into a byte arraytoValue(io.vertx.core.json.JsonObject json)
converts a json object into the generic template used by a storageconverts a byte array to a value using the deserialization template classboolean
validate(Comparable comparable)
Validates that the given string consists only of plaintext and is at least as long as the specified number of feedback-characters.Methods inherited from class com.codingchili.core.context.SystemContext
blocking, blocking, bus, cancel, close, close, clustered, deploy, handler, listener, metrics, metrics, periodic, service, stop, stop, system, timer, vertx
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.codingchili.core.context.CoreContext
fileSystem
-
Constructor Details
-
StorageContext
public StorageContext() -
StorageContext
-
-
Method Details
-
logger
- Specified by:
logger
in interfaceCoreContext
- Overrides:
logger
in classSystemContext
- Parameters:
aClass
- added as metadata to all logged events.- Returns:
- get a new instance of a logger.
-
settings
- Returns:
- get the storage settings.
-
storage
- Returns:
- get the storage settings for the current plugin.
-
properties
public io.vertx.core.json.JsonObject properties() -
valueClass
- Returns:
- the class to be stored in the storage.
-
plugin
- Returns:
- the plugin identifier to us as storage.
-
toValue
converts a json object into the generic template used by a storage- Parameters:
json
- the json object to convert- Returns:
- json mapped to an object of generic type
-
toValue
converts a byte array to a value using the deserialization template class- Parameters:
string
- a json-formatted string- Returns:
- generic Value inflated using the bytes and template class.
-
toJson
converts the given object of generic type into a json object.- Parameters:
object
- the object to be converted to json- Returns:
- the serialized form of the given object
-
toPacked
converts the given object of generic type into a byte array- Parameters:
value
- the object to be converted- Returns:
- a byte array created from the serialized objects json text
-
handle
handles a handler successfully with the given value.- Parameters:
handler
- the handler to be handledvalue
- the value to send the handler.
-
database
get the name of the database used by the context.- Returns:
- the name of the database as a string
-
collection
get the name of the collection within the database used by the context.- Returns:
- the name of the collection as a string.
-
port
- Returns:
- the port of a remote database if configured.
-
host
- Returns:
- the hostname of a remote database if configured.
-
validate
Validates that the given string consists only of plaintext and is at least as long as the specified number of feedback-characters.- Parameters:
comparable
- the text to check if plaintext- Returns:
- true if the given comparable contains only plaintext
-
minFeedbackChars
-
maxResults
- Returns:
- the number of results all queries are limited to.
-
onWatcherFailed
Called when a value has been expired by ttl.- Parameters:
name
- the id of the object that was expired.cause
- the reason why invocation failed.
-
onWatcherCompleted
Called when a value failed to expire as it was not found.- Parameters:
name
- the id of the object that was expired.affected
- the number of items affected by the query.
-
onWatcherPaused
-
onWatcherResumed
-
onCollectionDropped
public void onCollectionDropped()Called when the collection has been dropped/cleared. -
setClass
sets the class that is used for deserialization. This should be the same or a supertype of the object type in the storage.- Parameters:
aClass
- the class template to inflate- Returns:
- fluent
-
setCollection
sets the collection context of the storage engine.- Parameters:
collection
- name of the collection- Returns:
- fluent
-
setDatabase
sets the database name to be used- Parameters:
database
- name as string- Returns:
- fluent
-
setProperties
- Parameters:
properties
- implementation specific configuration options.- Returns:
- fluent
-
setPlugin
sets the storage plugin name the context is bound to so that configuration for it may be retrieved.- Parameters:
plugin
- fully qualified class name as String.- Returns:
- fluent
-
identifier
- Returns:
- storage identifier.
-