public class SonicEngine
extends java.lang.Object
限定符和类型 | 方法和说明 |
---|---|
boolean |
cleanCache()
Removes all of the cache from
preloadSessionPool and deletes file caches from SDCard. |
static SonicEngine |
createInstance(SonicRuntime runtime,
SonicConfig config)
Create SonicEngine instance.
|
SonicSession |
createSession(java.lang.String url,
SonicSessionConfig sessionConfig) |
SonicConfig |
getConfig() |
static SonicEngine |
getInstance()
Returns a SonicEngine instance
Make sure
createInstance(SonicRuntime, SonicConfig) has been called. |
SonicRuntime |
getRuntime() |
void |
initSonicDB()
Init sonic DB which will upgrade to new version of database.
|
static boolean |
isGetInstanceAllowed()
Check if
getInstance() is ready or not. |
boolean |
isSonicAvailable()
Whether Sonic Service is available or not
|
static java.lang.String |
makeSessionId(java.lang.String url,
boolean isAccountRelated)
Create session ID
|
boolean |
preCreateSession(java.lang.String url,
SonicSessionConfig sessionConfig)
This method will preCreate sonic session .
|
boolean |
removeSessionCache(java.lang.String sessionId)
Removes the sessionId and its corresponding SonicSession from
preloadSessionPool . |
void |
trimSonicCache()
It will Post a task to trim sonic cache
if the last time of check sonic cache exceed
SonicConfig.SONIC_CACHE_CHECK_TIME_INTERVAL . |
public static SonicEngine getInstance()
Make sure createInstance(SonicRuntime, SonicConfig)
has been called.
java.lang.IllegalStateException
- if createInstance(SonicRuntime, SonicConfig)
hasn't been calledpublic static boolean isGetInstanceAllowed()
getInstance()
is ready or not.
Note: createInstance(SonicRuntime, SonicConfig)
must be called if false
is returned.
true
if sInstance
is not null, false
otherwisepublic static SonicEngine createInstance(@NonNull SonicRuntime runtime, @NonNull SonicConfig config)
runtime
- SonicRuntimeconfig
- SonicConfigpublic void initSonicDB()
public SonicRuntime getRuntime()
public SonicConfig getConfig()
public boolean isSonicAvailable()
public static java.lang.String makeSessionId(java.lang.String url, boolean isAccountRelated)
url
- session urlisAccountRelated
- Session Id will contain SonicRuntime.getCurrentUserAccount()
if isAccountRelated
is true.public boolean preCreateSession(@NonNull java.lang.String url, @NonNull SonicSessionConfig sessionConfig)
preloadSessionPool
if there is no same sonic session.
At the same time, if the number of preloadSessionPool
exceeds SonicConfig.MAX_PRELOAD_SESSION_COUNT
,
preCreateSession will return false and not create any sonic session.
Note: this method is intended for preload scene.
url
- url for preCreate sonic sessionsessionConfig
- SonicSession configsessionId
in this table preloadSessionPool
successfully,
it will return true,
false
otherwise.public SonicSession createSession(@NonNull java.lang.String url, @NonNull SonicSessionConfig sessionConfig)
url
- url for SonicSession ObjectsessionConfig
- SSonicSession configpublic boolean cleanCache()
preloadSessionPool
and deletes file caches from SDCard.false
if runningSessionHashMap
is not empty.
Returns true
if all of the local file cache has been deleted, false
otherwisepublic boolean removeSessionCache(@NonNull java.lang.String sessionId)
preloadSessionPool
.sessionId
- A unique session idtrue
If there is no specified sessionId in runningSessionHashMap
, false
otherwise.public void trimSonicCache()
SonicConfig.SONIC_CACHE_CHECK_TIME_INTERVAL
.