Clover coverage report - Code Coverage for tapestry release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:39:46 PST
file stats: LOC: 78   Methods: 4
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ReportStatusHubImpl.java 100% 100% 100% 100%
coverage
 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.describe;
 16   
 17    import java.util.ArrayList;
 18    import java.util.Iterator;
 19    import java.util.List;
 20   
 21    import org.apache.hivemind.util.Defense;
 22    import org.apache.tapestry.IMarkupWriter;
 23    import org.apache.tapestry.event.ReportStatusEvent;
 24    import org.apache.tapestry.event.ReportStatusListener;
 25   
 26    /**
 27    * Implementation of the tapestry.describe.ReportStatusHub service.
 28    *
 29    * @author Howard M. Lewis Ship
 30    * @since 4.0
 31    */
 32    public class ReportStatusHubImpl implements ReportStatusHub
 33    {
 34    private List _listeners = new ArrayList();
 35   
 36    private RootDescriptionReceiverFactory _receiverFactory;
 37   
 38  260 public synchronized void addReportStatusListener(ReportStatusListener listener)
 39    {
 40  260 Defense.notNull(listener, "listener");
 41   
 42  260 _listeners.add(listener);
 43    }
 44   
 45  1 public synchronized void removeReportStatusListener(ReportStatusListener listener)
 46    {
 47  1 Defense.notNull(listener, "listener");
 48   
 49  1 _listeners.remove(listener);
 50    }
 51   
 52  19 public synchronized void fireReportStatus(IMarkupWriter writer)
 53    {
 54  19 if (_listeners.isEmpty())
 55  1 return;
 56   
 57  18 RootDescriptionReciever receiver = _receiverFactory.newRootDescriptionReceiver(writer);
 58   
 59  18 ReportStatusEvent event = new ReportStatusEvent(this, receiver);
 60   
 61  18 Iterator i = _listeners.iterator();
 62   
 63  18 while (i.hasNext())
 64    {
 65  120 ReportStatusListener listener = (ReportStatusListener) i.next();
 66   
 67  120 listener.reportStatus(event);
 68   
 69  120 receiver.finishUp();
 70    }
 71    }
 72   
 73  41 public void setReceiverFactory(RootDescriptionReceiverFactory receiverFactory)
 74    {
 75  41 _receiverFactory = receiverFactory;
 76    }
 77   
 78    }