01: /*
02: * FakePeerInvocationHandler.java
03: *
04: * Created on September 9, 2005, 12:48 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.netbeans.modules.form.fakepeer;
11:
12: import java.lang.reflect.InvocationHandler;
13: import java.lang.reflect.Method;
14: import org.openide.ErrorManager;
15:
16: /**
17: *
18: * An {@link InvocationHandler} used for dynamic interface implementation
19: * in {@link FakePeerSupport}.
20: *
21: * @author Tomas Stupka
22: */
23: public class FakePeerInvocationHandler implements InvocationHandler {
24:
25: private final FakeComponentPeer comp;
26:
27: /**
28: *
29: */
30: public FakePeerInvocationHandler(FakeComponentPeer comp) {
31: this .comp = comp;
32: }
33:
34: /**
35: * @see InvocationHandler#invoke(Object proxy, Method method, Object[] args)
36: */
37: public Object invoke(Object proxy, Method method, Object[] args)
38: throws Throwable {
39:
40: try {
41:
42: Class[] parameters = method.getParameterTypes();
43: Method this Method = comp.getClass().getMethod(
44: method.getName(), parameters);
45: return this Method.invoke(comp, args);
46:
47: /*
48: * jdk 1.6 redefines the requestFocus() method in PeerComponent with a new parameter
49: * which is from a new type, unknown in previous jdk releases (<1.6), so we cannot
50: * just reimplement the method in FakePeerComponent.
51: *
52: * In case we should in future get a NoSuchMethodException, because of
53: * invoking the requestFocus() method with the jdk1.6 signature, we can implement
54: * here a special routine which return a proper value to the caller... .
55: *
56: */
57:
58: } catch (Exception e) {
59: ErrorManager.getDefault().notify(e);
60: throw e;
61: }
62:
63: }
64:
65: }
|