본문 바로가기
[Java] Reflection Tutorial - Dynamic Proxies Java, Reflection Tutorial - Dynamic Proxies reflection 을 이용하여 runtime에 interface 를 구현할 수도 있다.다시 말해 proxy를 사용하기 위해서는 구현하고자 하는 interface가 꼭 있어야 한다. 보통 interface 를 구현하는 방법은 다음과 같이 2가지가 있다. public class FooImpl implmenets FooInterface{@Overridepublic void test(){// do sth...}} new FooImpl{@Overridepublic void test(){// do sth...}} proxy 는 자주 사용되지는 않지만 특별한 경우에 사용하는 세번째 방법이라고 보면 된다. FooInterface foo =.. 2014. 1. 3.
[Java] Reflection Tutorial - Generics Java, Reflection Tutorial - Generics 일반적으로 Generics 정보는 runtime 에 사라진다고 알고 있지만 꼭 그렇지만은 않다. The Generics Reflection Rule of Thumb 일반적으로 List 와 같은 녀석들은 어떤 Generic 이 쓰였는지 알기 어렵다.하지만 parameterized 된 method 나 field 를 조사해보면,어떤 generic 이 사용되었는지 알 수 있다. Generic Method Return Types Method method = TestClass.class.getMethod( "getStringList", null );Type returnType = method.getGenericReturnType(); if ( ret.. 2013. 12. 27.
[Java] Reflection Tutorial - Annotations. [Java] Reflection Tutorial - Annotations. What are Java Annotations Java5 에 소개된 기능으로, meta data 를 코드형태로 담을 수 있고, runtime 에 이 meta data 에 접근할 수 있다. pre-compiler 가 코드를 conversion 할 때 사용되기도 한다. Annotation 은 interface 형태이다. @Retention( RetentionPolicy.RUNTIME );@Target( ElementType.TYPE )public @interface TestAnnotation{public String name();public String value();} @TestAnnotation(name="variable", va.. 2013. 12. 23.
[android] volley library 에 대해 알아보자! 안드로이드, Volley Library 에 대해 알아보자! Android Volley Libary 의 장점 1. 모든 network request 를 자동으로 스케쥴링한다.2. 보이지 않게 disk, memory caching 을 한다.3. 강력한 request 취소 API 도 제공한다.4. customization 도 쉽게 할 수 있다.5. debugging 과 tracing tool 을 제공한다. 써보고 싶어! library 를 구할 수 있는 주소를 알려줘. git clone https://android.googlesource.com/platform/frameworks/volley 2개의 main class. 1. Request queuerequest 를 dispatch 할 때 사용되는 녀석.보통 s.. 2013. 12. 10.
[Java] Reflection Tutorial - Getter and Setter Java, Reflection Tutorial - Getter and Setter Getter 와 Setter 의 경우 일일히 getter setter method 를 얻어와야 한다. Setter 의 경우에 return value 가 있을 수도 있다는 것을 알아야 한다. 100% 정확한 방법은 아니지만 general 한 방법의 (POJO) getter, setter 는 아래와 같은 방법으로 조회할 수 있다. public static boolean isGetter(Method method){ if(!method.getName().startsWith("get")) return false; if(method.getParameterTypes().length != 0) return false; if(void.cl.. 2013. 12. 4.
[Java] Reflection Tutorial - Method Java, Reflection Tutorial - Method Obtaining Method Objects Method[] methods = aClass.getMethods(); // only public methodsMethod method = aClass.getMethod( "methodName", Class[]{ String.class} ); getMethod 함수는 NoSuchMethodException 을 throw 할 수 있음 no parameter case 는 Class[] 부분에 null 을 입력. Method Parameters and Return Types. Class[] parameterTypes = method.getParameterTypes();Class returnType = m.. 2013. 11. 28.
[Java] Reflection Tutorial - Class [Java] Reflection Tutorial - Class Java Reflection 은 class, interface, field, 그리고 method 를 runtime 에 조사할 수 있도록 해준다. 새로운 object 를 만들 수도 있고, method 를 호출할 수도 있다. script language 가 runtime 에 java 의 함수를 호출한다거나, database table 과 object 를 맞출 때 자주 사용한다. Class Class 로 부터 얻을 수 있는 정보들. Class NameClass Modifier ( public, private, synchronized... )Pakcage InfoSuper classImplemented InterfacesConstructorsMeth.. 2013. 11. 12.
[JavaScript/Tutorial] this 란 무엇인가? this 가 가르키는 건 무엇인가? 주의사항은? this 란 무엇인가? this 가 가르키는 건 무엇인가? 주의사항은? [이전강좌] typeof 사용시의 주의사항, array type 판별코드. this 란 무엇인가? this 키워드는, 해당 function 을 invoke 한 object 를 가르키는 데 사용된다. this 가 가르키는 것은 어떻게 판별하는가? 1. Function.call 이나 Function.apply 를 통해 function call 을 하게 되면, call() 이나 apply() 의 첫번쨰 argument 가 this 가 된다. 만약 Function.call 이나 Function,apply 의 첫번째 argument 로 null 이나 undefined 가 들어왔다면 this는 global object 를 참조한다. 2. 만약 .. 2013. 5. 24.
[JavaScript/Tutorial] Object 특징, method와 properties 의 구분, literal Object의 특징, method 와 properties의 구분, literal [이전강좌] Array literal, undefined 값들, 관련 함수들. Object 의 특징 Object 는 한개 이상의 key-value pair 로 구성된다.key 는 string type이 보통 사용되고, value 는 어떤 type 이든 가능하다. Method 와 Properties 의 차이 Object 의 하나의 key-value 라도 value 에 function 이 assign 되어 있다면 그 object는 method 라 불린다.value 에 function 을 담고 있지 않은 object는 properties 라 부른다. Object literal Object 를 literal 형식으로 정의할 때는 v.. 2013. 5. 21.
반응형