카테고리 없음2021. 12. 9. 14:40
반응형

@Slf4j
@Intercepts (
{
@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})
}
)
@Component
public class UpdateInterceptor implements Interceptor {

ObjectMapper paramObjectMapper;

// spring 에서 파라미터 객체 json 출력을 위해 ObjectMapper 생성
@PostConstruct
public void init() {
    Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
    // 날짜 관련 serializer 추가
    builder.serializerByType(LocalDate.class, new com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer(DateTimeFormatter.ofPattern(DateConstans.DATE)));
    builder.serializerByType(LocalDateTime.class, new com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DateConstans.DATE_TIME)));
    // empty bean fail 처리 disable
    builder.featuresToDisable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
    // 파라미터 객체의 jsonIgnore 된 필드도 출력하기 위한 처리
    builder.annotationIntrospector(new JacksonAnnotationIntrospector() {
         @Override
         protected boolean _isIgnorable(Annotated a) {
                return false;
         }
    });
    paramObjectMapper = builder.build();
}

@Override
public Object intercept(Invocation invocation) throws Throwable {
    Object[] args = invocation.getArgs(); 
    MappedStatement ms = (MappedStatement)args[0];
    Object param = (Object)args[1]; 
    BoundSql boundSql = ms.getBoundSql(param); 

    log.debug("파라미터 바인딩 SQL : {}", getParameterBindingSQL(boundSql, param));
    log.debug("파라미터 JSON : {}" , getParam(param));


    return invocation.proceed();
}


// 파라미터 sql 바인딩 처리
public String getParameterBindingSQL(BoundSql boundSql, Object parameterObject) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, JsonProcessingException {

    StringBuilder sqlStringBuilder = new StringBuilder(boundSql.getSql());

    // stringBuilder 파라미터 replace 처리
    BiConsumer<StringBuilder, Object> sqlObjectReplace = (sqlSb, value) -> {

        int questionIdx = sqlSb.indexOf("?");

        if(questionIdx == -1) {
            return;
        }

        if(value == null) {
            sqlSb.replace(questionIdx, questionIdx + 1, "null");
        } else if (value instanceof String) {
            sqlSb.replace(questionIdx, questionIdx + 1, "'" + (value != null ? value.toString() : "") + "'");
        } else if(value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double) {    
            sqlSb.replace(questionIdx, questionIdx + 1, value.toString());
        } else if(value instanceof LocalDate || value instanceof LocalDateTime) {
            sqlSb.replace(questionIdx, questionIdx + 1, "'" + (value != null ? value.toString() : "") + "'");
        } else if(value instanceof Enum<?>) {
            sqlSb.replace(questionIdx, questionIdx + 1, "'" + (value != null ? value.toString() : "") + "'");
        } else {
            sqlSb.replace(questionIdx, questionIdx + 1, value.toString());
        }
    };

    if(parameterObject == null) {
        sqlObjectReplace.accept(sqlStringBuilder, null);
    } else {

        if(parameterObject instanceof Integer || parameterObject instanceof Long || parameterObject instanceof Float || parameterObject instanceof Double || parameterObject instanceof String) {
            sqlObjectReplace.accept(sqlStringBuilder, parameterObject);
        } else if(parameterObject instanceof Map) {

            Map paramterObjectMap = (Map)parameterObject;
            List<ParameterMapping> paramMappings = boundSql.getParameterMappings();

            for (ParameterMapping parameterMapping : paramMappings) {
                String propertyKey = parameterMapping.getProperty();

                try {
                    Object paramValue = null;
                    if(boundSql.hasAdditionalParameter(propertyKey)) { 
                        // 동적 SQL로 인해 __frch_item_0 같은 파라미터가 생성되어 적재됨, additionalParameter로 획득
                        paramValue = boundSql.getAdditionalParameter(propertyKey);
                    } else {
                        paramValue = paramterObjectMap.get(propertyKey);    
                    }

                    sqlObjectReplace.accept(sqlStringBuilder, paramValue);    
                } catch (Exception e) {
                    sqlObjectReplace.accept(sqlStringBuilder, "[cannot binding : " + propertyKey+ "]");
                }

            }
        } else {

            List<ParameterMapping> paramMappings = boundSql.getParameterMappings();
            Class< ? extends Object> paramClass = parameterObject.getClass();

            for (ParameterMapping parameterMapping : paramMappings) {
                String propertyKey = parameterMapping.getProperty();

                try {

                    Object paramValue = null;
                    if(boundSql.hasAdditionalParameter(propertyKey)) {
                        // 동적 SQL로 인해 __frch_item_0 같은 파라미터가 생성되어 적재됨, additionalParameter로 획득
                        paramValue = boundSql.getAdditionalParameter(propertyKey);
                    } else {
                        Field field = ReflectionUtils.findField(paramClass, propertyKey);
                        field.setAccessible(true);
                        paramValue = field.get(parameterObject);    
                    }

                    sqlObjectReplace.accept(sqlStringBuilder, paramValue);
                } catch (Exception e) {
                    sqlObjectReplace.accept(sqlStringBuilder, "[cannot binding : " + propertyKey+ "]");
                }
            }
        }
    }

    return sqlStringBuilder.toString();
}


private String getParam(final Object parameter) throws Exception {
    return paramObjectMapper.writeValueAsString(parameter);
}

@Override
public Object plugin(Object target) {
    return Plugin.wrap(target, this);
}

@Override
public void setProperties(Properties properties) {
    // TODO Auto-generated method stub

}

}

Posted by 1010
카테고리 없음2021. 11. 24. 17:55
반응형

https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_sudo_%ED%8C%A8%EC%8A%A4%EC%9B%8C%EB%93%9C_%EC%97%86%EC%9D%B4_%EC%82%AC%EC%9A%A9

 

리눅스 sudo 패스워드 없이 사용 - 제타위키

 

zetawiki.com

 

Posted by 1010
카테고리 없음2021. 10. 26. 18:13
반응형

weblogic 관리콘솔에서 동기화 되지 않을때...

 

Solutions
-> First thing never try to delete any managed server which is up and running.First shut down and then closed it.

Follow below steps to get rid of this error

-> Stop the Admin Server & Managed Servers which is up and running.
-> On your Admin Server cd to $WLS_HOME\user_projects\domains\base_domain.
-> Delete all files in pending and servers/domain_bak directory.
-> Start the Admin Server & Managed Servers.
-> Login the weblogic Admin Console and click on ReleaseConfiguration button.
-> Perform the same changes now.

Posted by 1010
카테고리 없음2021. 10. 26. 17:30
반응형

https://stackoverflow.com/questions/41394138/nullpointerexception-while-deploying-project-on-weblogic-12-2-1

 

NullPointerException while deploying project on Weblogic 12.2.1

We have a JSF application that was on Weblogic 10.3.6 and that we try to deploy on Weblogic 12.2.1. For information, we succeeded in deploying on Weblogic 12.1.3 without any changes in the project....

stackoverflow.com

 

Posted by 1010
카테고리 없음2021. 10. 14. 14:25
반응형

#!/bin/bash

readonly app_path="/test/test01"
readonly proc_name="app01"
readonly daemon="app01-0.0.1.war"
readonly proc_pid="app01.pid"

start()
{
    echo "Starting ${proc_name}..."
    local pid=$(get_status)
    if [ -n "${pid}" ]; then
        echo "${proc_name} is already running}"
        exit 0
    fi

    nohup java -jar "${app_path}/${daemon}" > /dev/null 2>&1 &
    local pid=${!}

    if [ -n ${pid} ]; then
        echo " - Starting..."
        echo " - Created Process ID in ${proc_pid}"
        echo " - pid : ${pid}"
        echo " - proc_pid : ${proc_pid}"
        echo ${pid} > ${proc_pid}
    else
        echo "- failed to start."
    fi
}

stop()
{
    if [ -e ${proc_pid} ]; then
        local pid=$(get_status)
        echo " - Stopping ${proc_name}..."
        echo " - pid : ${pid} "

        if [ ${pid} -lt 3 ]; then
                echo " - ${proc_name} was not running."
        else
                kill $pid
                rm -f $proc_pid
                echo " - Shutdown ...."
        fi
    else
        echo " - ${proc_name} was not running."
    fi
}

status()
{
    if [ -e ${proc_pid} ]; then
        local pid=$(get_status)
        if [ -n "${pid}" ]; then
            echo " - pid : ${pid}"
            echo " - ${proc_name} is running"
        else
            echo " - ${proc_name} is stopped"
        fi
    else
        echo " - ${proc_name} was not running."
    fi

}

get_status()
{
     ps -ef | grep ${proc_name} | grep -v grep | awk '{print $2}'
}


case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status
        ;;
    get_status)
        get_status
        ;;
    *)
       echo "Usage: $0 {start | stop | status}"
esac

exit 0

Posted by 1010
카테고리 없음2021. 9. 14. 14:30
카테고리 없음2021. 9. 14. 14:29
반응형

https://couplewith.tistory.com/entry/ORACLE-heterogeneous-connection-%EB%9E%80

 

ORACLE heterogeneous connection 란

ORACLE heterogeneous connection 란 ? 오라클은 DBMS간의 연결을 OCI  Oracle Common Interface를 통해서 DB링크나 원격 프로그램들이 접속 하도록 하였다. 그러나 Mysql, MS-SQL, PostgreSQL 등 이 메커니즘을..

couplewith.tistory.com

 

Posted by 1010
카테고리 없음2021. 8. 24. 17:38
카테고리 없음2021. 7. 15. 17:48
반응형

pip install tensorflow --trusted-host pypi.org --trusted-host files.pythonhosted.org 

Posted by 1010
카테고리 없음2021. 7. 8. 13:48
반응형

https://nkcnow.tistory.com/55

 

quartz 스케쥴러 스프링에서 사용법

구글차트로 방문자수를 일주일 단위로 집계하려고 하다 보니 매주 월요일 0시가 되면 방문자수가 카운트되는 DB가 초기화가 되게 해야되서 스케쥴러를 찾다가 쿼츠 스케쥴러를 찾았다. (사실

nkcnow.tistory.com

 

Posted by 1010