KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > listener > SyntheticListener


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 &lt;page-specification&gt;
29  * (or &lt;component&gt;) 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 JavaDoc _target;
37
38     private final ListenerMethodInvoker _invoker;
39
40     public SyntheticListener(Object JavaDoc target, ListenerMethodInvoker invoker)
41     {
42         Defense.notNull(target, "target");
43         Defense.notNull(invoker, "invoker");
44
45         _target = target;
46         _invoker = invoker;
47     }
48
49     public void actionTriggered(IComponent component, IRequestCycle cycle)
50     {
51         _invoker.invokeListenerMethod(_target, cycle);
52     }
53 }
Popular Tags