1
2
3
4
5
6
7
8
9
import org.apache.commons.beanutils.BeanUtils;
..
..
 
    public <T> T setParamegerBean(Class<T> clz) throws InstantiationException, IllegalAccessException, InvocationTargetException{
        T t = clz.newInstance();
        BeanUtils.copyProperties(t, ServletActionContext.getRequest().getParameterMap());
        return t;
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.lang.reflect.Field;
import org.apache.commons.beanutils.BeanUtils;
..
..
 
public String intercept(ActionInvocation invocation) throws Exception {
        log.info("---------- 파라미터 Bean에 셋팅 ----------");
 
        Object action = invocation.getAction();
 
        Field fs [] = action.getClass().getDeclaredFields();
        for( Field f : fs ){
            if( f.getName().indexOf("Bean") > 0 ){
                String s [] = StringUtils.split(f.toString(), " ");
                if( s.length == 3 ){
                    Class cls = Class.forName(s[1]);
                    Object obj = cls.newInstance();
                    BeanUtils.copyProperties(obj, ServletActionContext.getRequest().getParameterMap());
                    f.setAccessible(true);
                    f.set(action, obj);
                }
            }
        }
        return invocation.invoke();
    }

우선 Spring AOP 에서 Proxy 를 사용하는데 두가지가 존재한다고 하네...

  1. JDK Dynamix Proxy    - Interface 가 존재해야 하고(Runtime 시점에 감싸주는거던데... 고로 야야야야야약간의 성능저하.??)
  2. CGLib Proxy             - 구현체만 있으면 됨..(Compile 시점에 감싸므로 성능저하 최소화)


2번 방법으로 사용하려면 <aop:config proxy-target-class="true"> 셋팅이 필요함


ex) 근데 Service Layer에서는 셋팅하지 않아도 정상적이였는데, Dao Layer에서는 문제가 생겼다.. 머징;;


역시 지식이 너무 얕다.. ;; 

삽질 무진장 했네


[참고] https://groups.google.com/forum/?hl=ko&fromgroups=#!topic/ksug/pm2ET851V6U



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    <aop:aspectj-autoproxy>
     
    <bean id="loggingAspect" class="com.ezwel.srm.core.aspect.LoggingAspect">
 
    <aop:config proxy-target-class="true">
 
        <aop:aspect id="aspectLoggging" ref="loggingAspect">
            <aop:pointcut id="servicePointcut" expression="execution(* *..*.service.*.*Service*.*(..))">
            <!-- 
            <aop:before method="logBefore" pointcut-ref="servicePointcut" />
            <aop:after method="logAfter" pointcut-ref="servicePointcut" />
            -->
            <aop:around method="logAround" pointcut-ref="servicePointcut">
             
            <aop:pointcut id="daoPointcut" expression="execution(* *..*.dao.*.*Dao*.*(..))">
            <aop:around method="logAround" pointcut-ref="daoPointcut">
        </aop:around></aop:pointcut></aop:around></aop:pointcut></aop:aspect>
         
 
    </aop:config>
</bean></aop:aspectj-autoproxy>


  • *-servlet.xml 과 applicationContext.xml 설정 시 주의 점
    1. *-servlet.xml 에서 Controller Annotation 스캔 시 무조껀 Controller 만 함
    2. applicationContext.xml 에서는 Controller 를 제외 하고 스캔함
  • 위와 같이 하지 않을경우 둘의 상-하 상속관계에 따라서 applicationContext.xml 의 Bean이 사용되어지는것이 아니라 *-servlet.xml 의 Bean이 사용되어 진다고 함...
    그러므로 applicationContext.xml 에서 tx(Transaction)관련 설정을 해 놓아도 먹히지 않는 문제가 발생합니다.

[*-servlet.xml]

1
2
3
<context:component-scan base-package="pe.kr.ddakker" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller">
</context:include-filter></context:component-scan>
[applicationContext.xml]


1
2
3
<context:component-scan base-package="pe.kr.ddakker">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller">
</context:exclude-filter></context:component-scan>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.FileOutputStream;
import java.io.StringReader;
 
import org.junit.Test;
 
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.html.simpleparser.HTMLWorker;
import com.itextpdf.text.html.simpleparser.StyleSheet;
import com.itextpdf.text.pdf.PdfWriter;
 
 
public class TestCreatePDF {
 
    @Test
    public void htmlCreate() throws Exception {
        // TODO Auto-generated method stub
        String fontname = "d:\\GulimChe.ttf";
        String filename = "d:\\filename.pdf";
         
        FontFactory.register(fontname);
        StringBuffer sBuff = new StringBuffer("<html>");
        sBuff.append("<head></head>");
        sBuff.append("<body>");
        sBuff.append("<table border=1>");
        sBuff.append("<tr><td>Test worker <b>한글</b> 테스트</td><td>11<b>1</b>11</td></tr>");
        sBuff.append("</table>");
        sBuff.append("</body>");
        sBuff.append("</html>");
        StringReader stringReader = new StringReader(sBuff.toString());
 
        Document document = new Document();
        StyleSheet st = new StyleSheet();
        st.loadTagStyle("body", "face", "굴림체");
        st.loadTagStyle("body", "encoding", "Identity-H");
        st.loadTagStyle("body", "leading", "12,0");
        HTMLWorker worker = new HTMLWorker(document);
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        java.util.List<Element> p = HTMLWorker.parseToList(stringReader, st);
        for (int k = 0; k < p.size(); ++k)
            document.add((Element)p.get(k));
        document.close();
    }
 
}

GulimChe.ttf

itextpdf-5.4.0.jar


[출처] http://blog.wooriaru.com/131163646


DTD 부분 오타 있으면 발생하는군요....


<?xml version="1.0" encoding="euc-kr" ?>

<!DOCTYPE struts PUBLIC

    "-//Apahce Software Foundation//DTD Struts Configuration 2.0//EN"

    "http://struts.apache.org/dtds/struts-2.0.dtd">



Apahce  ;;; --> Apache 흠.. 이 전에는 왜 잘 됐었지 ;; 어이 없네..(리얼도 잘 된다.. 왜 이려..)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import org.junit.Test;
 
public class ClassKindTestCase {
    public interface ParentClass {
        public void add();
    }
 
    @Test
    public void innerClassTest(){
        innerLocalClass("ddakker", 21);
        innerAnonymousClass("ddakker", 22);
    }
     
    // 로컬 클래스
    public void innerLocalClass(final String name, final int age){
        class ChildClass implements ParentClass {
            @Override
            public void add(){
                System.out.println("[innerLocalClass] name=" + name + ", add age=" + age);
            }
        }
         
        ParentClass instance = new ChildClass();
        executeMethos(instance);
    }
     
    // 익명 내부클래스
    public void innerAnonymousClass(final String name, final int age){
        /*ParentClass instance = new ParentClass(){
            @Override
            public void add() {
                System.out.println("[innerAnonymousClass] name=" + name + ", add age=" + age);
            }
        };
        executeMethos(instance);*/
        executeMethos(
            new ParentClass(){
                @Override
                public void add() {
                    System.out.println("[innerAnonymousClass] name=" + name + ", add age=" + age);
                }
            }
        );
    }
 
    // 실행(공통 분리)
    public void executeMethos(ParentClass object){
        object.add();
    }
     
}

[설정]

struts.xml

<struts>

...

<constant name="struts.custom.i18n.resources" value="프로퍼티 파일명(확장자는 빼고, 국가 문자열 빼고(_ko 등)" />

...

</struts>


[JSP]

...

<%@ taglib prefix="s" uri="/struts-tags" %>

...

<s:text name="err.msg" />

...


[Action]

...

getText("err.msg"); // ActionSupport 를 상속받아야함

...

oscache-2.3.2.jar 가 기존에 포함되어 있길래 재대로 활용해보았다.


하지만 운영서버에서 서버가 버벅되다 죽는것이 확인되었다.


이유를 못 찾는 와중에 WAS 시스템 엔지니어로 부터 OSCache문제라는 통보를 받았다 ㅠ


구글링도 해보았지만 해결책을 쉽게 찾지 못 하였다.


캐쉬 최대 갯수도 늘려보아도 소용이 없던 찰라에 oscache 버전을 최신으로 교체해보았다.


결론은.. 원활하게 운영중이다..


이런. ㅠㅠ


현재 oscache-2.4.1.jar 버전으로 정상 가동중이다.


WAS 기동 시 시스템 프로퍼티에 아래와 같이 등록한다.


-Dlog4j.configuration=log4j 설정 파일.xml


+ Recent posts