Coverage Report - org.apache.tapestry.describe.ReportStatusHubImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ReportStatusHubImpl
0%
0/21
0%
0/4
1.75
 
 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  0
 public class ReportStatusHubImpl implements ReportStatusHub
 33  
 {
 34  0
     private List _listeners = new ArrayList();
 35  
 
 36  
     private RootDescriptionReceiverFactory _receiverFactory;
 37  
 
 38  
     public synchronized void addReportStatusListener(ReportStatusListener listener)
 39  
     {
 40  0
         Defense.notNull(listener, "listener");
 41  
 
 42  0
         _listeners.add(listener);
 43  0
     }
 44  
 
 45  
     public synchronized void removeReportStatusListener(ReportStatusListener listener)
 46  
     {
 47  0
         Defense.notNull(listener, "listener");
 48  
 
 49  0
         _listeners.remove(listener);
 50  0
     }
 51  
 
 52  
     public synchronized void fireReportStatus(IMarkupWriter writer)
 53  
     {
 54  0
         if (_listeners.isEmpty())
 55  0
             return;
 56  
 
 57  0
         RootDescriptionReciever receiver = _receiverFactory.newRootDescriptionReceiver(writer);
 58  
 
 59  0
         ReportStatusEvent event = new ReportStatusEvent(this, receiver);
 60  
 
 61  0
         Iterator i = _listeners.iterator();
 62  
 
 63  0
         while (i.hasNext())
 64  
         {
 65  0
             ReportStatusListener listener = (ReportStatusListener) i.next();
 66  
 
 67  0
             listener.reportStatus(event);
 68  
 
 69  0
             receiver.finishUp();
 70  0
         }
 71  0
     }
 72  
 
 73  
     public void setReceiverFactory(RootDescriptionReceiverFactory receiverFactory)
 74  
     {
 75  0
         _receiverFactory = receiverFactory;
 76  0
     }
 77  
 
 78  
 }