301 |
* @param action Target property or method to invoke. |
* @param action Target property or method to invoke. |
302 |
* @return A constructed proxy object. |
* @return A constructed proxy object. |
303 |
*/ |
*/ |
304 |
public static Object create(Class listenerInterface, Object target, String action) |
public static <T> T create(Class<T> listenerInterface, Object target, |
305 |
|
String action) |
306 |
{ |
{ |
307 |
return create(listenerInterface, target, action, null, null); |
return create(listenerInterface, target, action, null, null); |
308 |
} |
} |
323 |
* @param eventPropertyName Name of property to extract from event. |
* @param eventPropertyName Name of property to extract from event. |
324 |
* @return A constructed proxy object. |
* @return A constructed proxy object. |
325 |
*/ |
*/ |
326 |
public static Object create(Class listenerInterface, Object target, |
public static <T> T create(Class<T> listenerInterface, Object target, |
327 |
String action, String eventPropertyName) |
String action, String eventPropertyName) |
328 |
{ |
{ |
329 |
return create(listenerInterface, target, action, eventPropertyName, null); |
return create(listenerInterface, target, action, eventPropertyName, null); |
330 |
} |
} |
372 |
* @param listenerMethodName Listener method to implement. |
* @param listenerMethodName Listener method to implement. |
373 |
* @return A constructed proxy object. |
* @return A constructed proxy object. |
374 |
*/ |
*/ |
375 |
public static Object create(Class listenerInterface, Object target, |
public static <T> T create(Class<T> listenerInterface, Object target, |
376 |
String action, String eventPropertyName, |
String action, String eventPropertyName, |
377 |
String listenerMethodName) |
String listenerMethodName) |
378 |
{ |
{ |
379 |
// Create EventHandler instance |
// Create EventHandler instance |
380 |
EventHandler eh = new EventHandler(target, action, eventPropertyName, |
EventHandler eh = new EventHandler(target, action, eventPropertyName, |
382 |
|
|
383 |
// Create proxy object passing in the event handler |
// Create proxy object passing in the event handler |
384 |
Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(), |
Object proxy = Proxy.newProxyInstance(listenerInterface.getClassLoader(), |
385 |
new Class[] {listenerInterface}, |
new Class<?>[] {listenerInterface}, |
386 |
eh); |
eh); |
387 |
|
|
388 |
return proxy; |
return (T) proxy; |
389 |
} |
} |
|
|
|
390 |
} |
} |