JDBCAppenderWithAttachment.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:jaffa-framework 作者:
/** Overwrites the jlogger field on the base class with a JDBCLoggerWithAttachment instance if:
 * <ul>
 * <li> Attachment settings are provided in the configuration file
 * <li> The usePreparedStatements should be true
 * <li> The stored-procedure, sql and sqlHandler should not be specified.
 * </ul>
 * Finally it invokes the configure() method in the base class.
 * @return true if the configuration was successful.
 */
protected boolean configure() {
    try {
        if (!((Boolean) c_configured.get(this)).booleanValue()) {
            // Customize the logger if attachmentTable and attachmentMDCKey are provided and if using prepared statements.
            // Ensure that stored-procedure, sql or sqlHandler are not being used.
            if (getAttachmentTable() != null && getAttachmentMDCKey() != null && isUsePreparedStatements()
            && getProcedure() == null && getSql() == null) {
                // Use reflection to check the 'sqlHandler' field from the base class, since there is no getter
                if (c_sqlHandler.get(this) == null) {
                    // Use reflection to set the 'jlogger' field on the base class, since there is no setter
                    c_jlogger.set(this, new JDBCLoggerWithAttachment(getAttachmentTable(), getAttachmentMDCKey(), getEngine()));
                    LogLog.debug("JDBCAppenderWithAttachment::configure(), Using JDBCLoggerWithAttachment");
                }

            }
            return super.configure();
        } else
            return true;
    } catch (Exception e) {
        String errorMsg = "JDBCAppenderWithAttachment::configure()";
        LogLog.error(errorMsg, e);
        errorHandler.error(errorMsg, e, 0);
        return false;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号