public class CallbackContext extends Object
| 修飾子とタイプ | クラスと説明 |
|---|---|
static interface |
CallbackContext.CallbackContextHolder
The holder of for callback context.
|
protected static class |
CallbackContext.InheritableBehaviorCommandHook |
protected static class |
CallbackContext.InheritableSqlFireHook |
| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected BehaviorCommandHook |
_behaviorCommandHook |
protected static CallbackContext.CallbackContextHolder |
_defaultHolder
The default holder for callback context, using thread local.
|
protected static ThreadLocal<CallbackContext> |
_defaultThreadLocal
The default thread-local for this.
|
protected static CallbackContext.CallbackContextHolder |
_holder
The holder for callback context, might be changed.
|
protected static boolean |
_locked
Is this static world locked?
|
protected SqlFireHook |
_sqlFireHook |
protected SqlLogHandler |
_sqlLogHandler |
protected SqlResultHandler |
_sqlResultHandler |
protected SqlStringFilter |
_sqlStringFilter |
| コンストラクタと説明 |
|---|
CallbackContext() |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected static void |
assertNotLocked()
Assert this is not locked.
|
static void |
clearBehaviorCommandHookOnThread()
Clear the hook interface of behavior commands from callback context on thread.
|
static void |
clearCallbackContextOnThread()
Clear callback context on thread.
|
protected static void |
clearIfNoInterface(CallbackContext context) |
static void |
clearSqlFireHookOnThread()
Clear the hook interface of behavior commands from callback context on thread.
|
static void |
clearSqlLogHandlerOnThread()
Clear the handler of SQL log from callback context on thread.
|
static void |
clearSqlResultHandlerOnThread()
Clear the handler of SQL result from callback context on thread.
|
static void |
clearSqlStringFilterOnThread()
Clear the filter of SQL string from callback context on thread.
|
protected CallbackContext.InheritableBehaviorCommandHook |
createInheritableBehaviorCommandHook(BehaviorCommandHook behaviorCommandHook) |
protected CallbackContext.InheritableSqlFireHook |
createInheritableSqlFireHook(SqlFireHook sqlFireHook) |
protected static CallbackContext.CallbackContextHolder |
getActiveHolder()
Get the active holder for callback context.
|
BehaviorCommandHook |
getBehaviorCommandHook() |
static CallbackContext |
getCallbackContextOnThread()
Get callback context on thread.
|
protected static CallbackContext |
getOrCreateContext() |
SqlFireHook |
getSqlFireHook() |
SqlLogHandler |
getSqlLogHandler() |
SqlResultHandler |
getSqlResultHandler() |
SqlStringFilter |
getSqlStringFilter() |
boolean |
hasAnyInterface() |
static boolean |
isExistBehaviorCommandHookOnThread()
Is existing the hook interface of behavior commands on thread?
|
static boolean |
isExistCallbackContextOnThread()
Is existing callback context on thread?
|
static boolean |
isExistSqlFireHookOnThread()
Is existing the hook interface of behavior commands on thread?
|
static boolean |
isExistSqlLogHandlerOnThread()
Is existing the handler of SQL log on thread?
|
static boolean |
isExistSqlResultHandlerOnThread()
Is existing the handler of SQL result on thread?
|
static boolean |
isExistSqlStringFilterOnThread()
Is existing the handler of SQL result on thread?
|
static boolean |
isLocked()
Is this static world locked?
|
static void |
lock()
Lock this static world, e.g. not to set the holder of thread-local.
|
void |
setBehaviorCommandHook(BehaviorCommandHook behaviorCommandHook)
Set the hook interface of behavior commands.
|
static void |
setBehaviorCommandHookOnThread(BehaviorCommandHook behaviorCommandHook)
Set the hook interface of behavior commands.
|
static void |
setCallbackContextOnThread(CallbackContext callbackContext)
Set callback context on thread.
|
void |
setSqlFireHook(SqlFireHook sqlFireHook)
Set the hook interface of SQL fires.
|
static void |
setSqlFireHookOnThread(SqlFireHook sqlFireHook)
Set the hook interface of SQL fires.
|
void |
setSqlLogHandler(SqlLogHandler sqlLogHandler)
Set the handler of SQL log.
|
static void |
setSqlLogHandlerOnThread(SqlLogHandler sqlLogHandler)
Set the handler of SQL log.
|
void |
setSqlResultHandler(SqlResultHandler sqlResultHandler)
Set the handler of SQL result.
|
static void |
setSqlResultHandlerOnThread(SqlResultHandler sqlResultHandler)
Set the handler of SQL result.
|
void |
setSqlStringFilter(SqlStringFilter sqlStringFilter)
Set the filter of SQL string.
|
static void |
setSqlStringFilterOnThread(SqlStringFilter sqlStringFilter)
Set the filter of SQL string.
|
String |
toString() |
static void |
unlock()
Unlock this static world, e.g. to set the holder of thread-local.
|
static void |
useSurrogateHolder(CallbackContext.CallbackContextHolder holder)
Use the surrogate holder for callback context.
|
protected static final ThreadLocal<CallbackContext> _defaultThreadLocal
protected static final CallbackContext.CallbackContextHolder _defaultHolder
protected static CallbackContext.CallbackContextHolder _holder
protected static boolean _locked
protected BehaviorCommandHook _behaviorCommandHook
protected SqlFireHook _sqlFireHook
protected SqlLogHandler _sqlLogHandler
protected SqlResultHandler _sqlResultHandler
protected SqlStringFilter _sqlStringFilter
public static CallbackContext getCallbackContextOnThread()
public static void setCallbackContextOnThread(CallbackContext callbackContext)
callbackContext - The context of callback. (NotNull)public static boolean isExistCallbackContextOnThread()
public static void clearCallbackContextOnThread()
protected static CallbackContext.CallbackContextHolder getActiveHolder()
public static void useSurrogateHolder(CallbackContext.CallbackContextHolder holder)
holder - The holder instance. (NullAllowed: if null, use default holder)public static boolean isLocked()
public static void lock()
public static void unlock()
protected static void assertNotLocked()
public static void setBehaviorCommandHookOnThread(BehaviorCommandHook behaviorCommandHook)
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
// You can implement your favorite callback here.
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
// You can implement your favorite callback here.
}
});
behaviorCommandHook - The hook interface of behavior commands. (NullAllowed)public static boolean isExistBehaviorCommandHookOnThread()
public static void clearBehaviorCommandHookOnThread()
public static void setSqlFireHookOnThread(SqlFireHook sqlFireHook)
context.setSqlFireHook(new SqlFireHook() {
public void hookBefore(BehaviorCommandMeta meta, SqlFireReadyInfo fireReadyInfo) {
// You can implement your favorite callback here.
}
public void hookFinally(BehaviorCommandMeta meta, SqlFireResultInfo fireResultInfo) {
// You can implement your favorite callback here.
}
});
sqlFireHook - The hook interface of behavior commands. (NullAllowed)public static boolean isExistSqlFireHookOnThread()
public static void clearSqlFireHookOnThread()
public static void setSqlLogHandlerOnThread(SqlLogHandler sqlLogHandler)
context.setSqlLogHandler(new SqlLogHandler() {
public void handle(SqlLogInfo info) {
// You can get your SQL string here.
}
});
sqlLogHandler - The handler of SQL log. (NullAllowed)public static boolean isExistSqlLogHandlerOnThread()
public static void clearSqlLogHandlerOnThread()
public static void setSqlResultHandlerOnThread(SqlResultHandler sqlResultHandler)
context.setSqlResultHandler(new SqlResultHandler() {
public void handle(SqlResultInfo info) {
// You can get your SQL result information here.
}
});
sqlResultHandler - The handler of SQL result. (NullAllowed)public static boolean isExistSqlResultHandlerOnThread()
public static void clearSqlResultHandlerOnThread()
public static void setSqlStringFilterOnThread(SqlStringFilter sqlStringFilter)
context.setSqlStringFilter(new SqlStringFilter() {
public String filter(String executedSql) {
// You can filter your executed SQL string here.
}
});
sqlStringFilter - The filter of SQL string. (NullAllowed)public static boolean isExistSqlStringFilterOnThread()
public static void clearSqlStringFilterOnThread()
protected static CallbackContext getOrCreateContext()
protected static void clearIfNoInterface(CallbackContext context)
public boolean hasAnyInterface()
public BehaviorCommandHook getBehaviorCommandHook()
public void setBehaviorCommandHook(BehaviorCommandHook behaviorCommandHook)
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
// You can implement your favorite callback here.
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
// You can implement your favorite callback here.
}
});
The hook methods may be called by nested process so you should pay attention to it when you implements this.
Also you can inherit the existing hook with your hook by overriding inheritsExistingHook().
context.setBehaviorCommandHook(new BehaviorCommandHook() {
public void hookBefore(BehaviorCommandMeta meta) {
...
}
public void hookFinally(BehaviorCommandMeta meta, RuntimeException cause) {
...
}
public boolean inheritsExistingHook() {
return true; // also existing hooks will be executed,
}
});
behaviorCommandHook - The hook interface of behavior commands. (NullAllowed)protected CallbackContext.InheritableBehaviorCommandHook createInheritableBehaviorCommandHook(BehaviorCommandHook behaviorCommandHook)
public SqlFireHook getSqlFireHook()
public void setSqlFireHook(SqlFireHook sqlFireHook)
context.setSqlFireHook(new SqlFireHook() {
public void hookBefore(BehaviorCommandMeta meta, SqlFireReadyInfo fireReadyInfo) {
// You can implement your favorite callback here.
}
public void hookFinally(BehaviorCommandMeta meta, SqlFireResultInfo fireResultInfo) {
// You can implement your favorite callback here.
}
});
The hook methods may be called by nested process so you should pay attention to it when you implements this.
Also you can inherit the existing hook with your hook by overriding inheritsExistingHook().
context.setSqlFireHook(new SqlFireHook() {
public void hookBefore(BehaviorCommandMeta meta, SqlFireReadyInfo fireReadyInfo) {
...
}
public void hookFinally(BehaviorCommandMeta meta, SqlFireResultInfo fireResultInfo) {
...
}
public boolean inheritsExistingHook() {
return true; // also existing hooks will be executed,
}
});
sqlFireHook - The hook interface of SQL fires. (NullAllowed)protected CallbackContext.InheritableSqlFireHook createInheritableSqlFireHook(SqlFireHook sqlFireHook)
public SqlLogHandler getSqlLogHandler()
public void setSqlLogHandler(SqlLogHandler sqlLogHandler)
context.setSqlLogHandler(new SqlLogHandler() {
public void handle(String executedSql, String displaySql
, Object[] args, Class<?>[] argTypes) {
// You can get your SQL string here.
}
});
sqlLogHandler - The handler of SQL log. (NullAllowed)public SqlResultHandler getSqlResultHandler()
public void setSqlResultHandler(SqlResultHandler sqlResultHandler)
context.setSqlResultHandler(new SqlResultHandler() {
public void handle(SqlResultInfo info) {
// You can get your SQL result information here.
}
});
sqlResultHandler - The handler of SQL result. (NullAllowed)public SqlStringFilter getSqlStringFilter()
public void setSqlStringFilter(SqlStringFilter sqlStringFilter)
context.setSqlStringFilter(new SqlStringFilter() {
public String filterSelectCB(BehaviorCommandMeta meta, String executedSql) {
// You can filter your SQL string here.
}
});
sqlStringFilter - The filter of SQL string. (NullAllowed)Copyright © 2014–2015 The DBFlute Project. All rights reserved.