Package net.sf.jkniv.whinstone.commands
Class DefaultCommandHandler
- java.lang.Object
-
- net.sf.jkniv.whinstone.commands.DefaultCommandHandler
-
- All Implemented Interfaces:
CommandHandler
- Direct Known Subclasses:
DefaultQueryHandler
public abstract class DefaultCommandHandler extends Object implements CommandHandler
- Since:
- 0.6.0
- Author:
- Alisson Gomes
-
-
Field Summary
Fields Modifier and Type Field Description protected net.sf.jkniv.exception.HandleableExceptionhandleableExceptionprotected ResultRow<?,?>overloadResultRowprotected Queryablequeryableprotected net.sf.jkniv.sqlegance.Sqlsql
-
Constructor Summary
Constructors Constructor Description DefaultCommandHandler(CommandAdapter cmdAdapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandHandlercheckSqlType(net.sf.jkniv.sqlegance.SqlType expected)If the command isn't the SQL type expected an illegal argument exception is throw.protected CommandAdaptergetCommandAdapter()CommandHandlerpostCallback()Invoke all post callback methods configured for the parameters ofQueryableCommandHandlerpostCommit()Invoke all post callback methods, configured to be executed after a successful commit, for the parameters ofQueryable.CommandHandlerpostException()Invoke all post callback methods, configured to be executed after a failure, for the parameters ofQueryable.CommandHandlerpreCallback()Invoke all pre callback methods configured for the parameters ofQueryable<T> Trun()Execute the database commandCommandHandlerwith(net.sf.jkniv.exception.HandleableException handlerException)Configure the life-cycle with the handler exceptionCommandHandlerwith(net.sf.jkniv.sqlegance.Sql sql)Configure the life-cycle with aSqlCommandHandlerwith(Queryable queryable)Configure the life-cycle with aQueryableCommandHandlerwith(ResultRow<?,?> overloadResultRow)Configure the life-cycle with a custom result parser rows of query.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.jkniv.whinstone.commands.CommandHandler
asCommand
-
-
-
-
Constructor Detail
-
DefaultCommandHandler
public DefaultCommandHandler(CommandAdapter cmdAdapter)
-
-
Method Detail
-
with
public CommandHandler with(ResultRow<?,?> overloadResultRow)
Description copied from interface:CommandHandlerConfigure the life-cycle with a custom result parser rows of query.- Specified by:
within interfaceCommandHandler- Parameters:
overloadResultRow- customized result row to parser- Returns:
- a reference to this object.
-
with
public CommandHandler with(Queryable queryable)
Description copied from interface:CommandHandlerConfigure the life-cycle with aQueryable- Specified by:
within interfaceCommandHandler- Parameters:
queryable- query name and yours parameters- Returns:
- a reference to this object.
-
with
public CommandHandler with(net.sf.jkniv.sqlegance.Sql sql)
Description copied from interface:CommandHandlerConfigure the life-cycle with aSql- Specified by:
within interfaceCommandHandler- Parameters:
sql- Dynamic SQL- Returns:
- a reference to this object.
-
with
public CommandHandler with(net.sf.jkniv.exception.HandleableException handlerException)
Description copied from interface:CommandHandlerConfigure the life-cycle with the handler exception- Specified by:
within interfaceCommandHandler- Parameters:
handlerException- rules to handler the all exceptions- Returns:
- a reference to this object.
-
run
public <T> T run()
Description copied from interface:CommandHandlerExecute the database command- Specified by:
runin interfaceCommandHandler- Type Parameters:
T- Generic type of return, example: rows affected by a command or list of objects.- Returns:
- the result of the command execution
-
getCommandAdapter
protected CommandAdapter getCommandAdapter()
-
preCallback
public CommandHandler preCallback()
Description copied from interface:CommandHandlerInvoke all pre callback methods configured for the parameters ofQueryable- Specified by:
preCallbackin interfaceCommandHandler- Returns:
- a reference to this object.
-
postCallback
public CommandHandler postCallback()
Description copied from interface:CommandHandlerInvoke all post callback methods configured for the parameters ofQueryable- Specified by:
postCallbackin interfaceCommandHandler- Returns:
- a reference to this object.
-
postCommit
public CommandHandler postCommit()
Description copied from interface:CommandHandlerInvoke all post callback methods, configured to be executed after a successful commit, for the parameters ofQueryable.- Specified by:
postCommitin interfaceCommandHandler- Returns:
- a reference to this object.
-
postException
public CommandHandler postException()
Description copied from interface:CommandHandlerInvoke all post callback methods, configured to be executed after a failure, for the parameters ofQueryable.- Specified by:
postExceptionin interfaceCommandHandler- Returns:
- a reference to this object.
-
checkSqlType
public CommandHandler checkSqlType(net.sf.jkniv.sqlegance.SqlType expected)
Description copied from interface:CommandHandlerIf the command isn't the SQL type expected an illegal argument exception is throw.- Specified by:
checkSqlTypein interfaceCommandHandler- Parameters:
expected- type of SQL expected- Returns:
- a reference to this object.
-
-