| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| InvalidationEventHubImpl |
|
| 0.0;0 |
| 1 | // Copyright 2006, 2007, 2008 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.tapestry5.internal.event; | |
| 16 | ||
| 17 | import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newThreadSafeList; | |
| 18 | import org.apache.tapestry5.services.InvalidationEventHub; | |
| 19 | import org.apache.tapestry5.services.InvalidationListener; | |
| 20 | ||
| 21 | import java.util.List; | |
| 22 | ||
| 23 | /** | |
| 24 | * Base implementation class for classes (especially services) that need to manage a list of {@link | |
| 25 | * org.apache.tapestry5.services.InvalidationListener}s. | |
| 26 | */ | |
| 27 | 274 | public class InvalidationEventHubImpl implements InvalidationEventHub |
| 28 | { | |
| 29 | 274 | private final List<InvalidationListener> listeners = newThreadSafeList(); |
| 30 | ||
| 31 | /** | |
| 32 | * Notifies all {@link InvalidationListener listener}s. | |
| 33 | */ | |
| 34 | protected final void fireInvalidationEvent() | |
| 35 | { | |
| 36 | 20 | for (InvalidationListener listener : listeners) |
| 37 | { | |
| 38 | 30 | listener.objectWasInvalidated(); |
| 39 | } | |
| 40 | 20 | } |
| 41 | ||
| 42 | public final void addInvalidationListener(InvalidationListener listener) | |
| 43 | { | |
| 44 | 776 | listeners.add(listener); |
| 45 | 776 | } |
| 46 | } |