'java/reflection'에 해당되는 글 1건

  1. 2010.06.29 [Reflection] - Reflection in java
리플렉션은 프로그램이 자신의 모습을 보고 수정하는 행위.
 
ex> Spring 의 DI(dependecy injection)

Example
Class<?> dymClass = null;
Method dymMethod  = null;

try {

    // 다이나믹 클래스 인스턴스 생성
    dymClass  = Class.forName(child.getListener());
    Object obj  = dymClass.newInstance();
 
    dymMethod = obj.getClass().getMethod("setShell", new Class[]{Shell.class});
  
    dymMethod.invoke(obj, new Object[]{parent.getShell()});
    toolItem.addListener(SWT.Selection, ((Listener)obj));
      
    toolItemMap.put(child.getId(), toolItem);
     
} catch(Exception e) {

}

Posted by 짱가쟁이
이전버튼 1 이전버튼