|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SyntheticListener.java | - | 100% | 100% | 100% |
|
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.listener; | |
16 | ||
17 | import org.apache.hivemind.util.Defense; | |
18 | import org.apache.tapestry.IActionListener; | |
19 | import org.apache.tapestry.IComponent; | |
20 | import org.apache.tapestry.IRequestCycle; | |
21 | ||
22 | /** | |
23 | * Adapter class that combines a target object (typically, a component) with a | |
24 | * {@link org.apache.tapestry.listener.ListenerMethodInvoker}. This is the bridge from listener | |
25 | * method names to listener method invocations. | |
26 | * <p> | |
27 | * TODO: It would really be nice if we could get the location of the listener binding into thrown | |
28 | * exceptions. As implemented, as best, it will be the location of the <page-specification> | |
29 | * (or <component>) of the page (or component) containing the listener method. | |
30 | * | |
31 | * @author Howard M. Lewis Ship | |
32 | * @since 4.0 | |
33 | */ | |
34 | public class SyntheticListener implements IActionListener | |
35 | { | |
36 | private final Object _target; | |
37 | ||
38 | private final ListenerMethodInvoker _invoker; | |
39 | ||
40 | 37 | public SyntheticListener(Object target, ListenerMethodInvoker invoker) |
41 | { | |
42 | 37 | Defense.notNull(target, "target"); |
43 | 37 | Defense.notNull(invoker, "invoker"); |
44 | ||
45 | 37 | _target = target; |
46 | 37 | _invoker = invoker; |
47 | } | |
48 | ||
49 | 52 | public void actionTriggered(IComponent component, IRequestCycle cycle) |
50 | { | |
51 | 52 | _invoker.invokeListenerMethod(_target, cycle); |
52 | } | |
53 | } |
|