Coverage Report - org.apache.tapestry.annotations.ComponentHousekeepingWorker
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentHousekeepingWorker
0%
0/13
0%
0/8
6
 
 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  
 package org.apache.tapestry.annotations;
 15  
 
 16  
 import java.util.Collection;
 17  
 import java.util.Iterator;
 18  
 
 19  
 import org.apache.hivemind.ApplicationRuntimeException;
 20  
 import org.apache.hivemind.HiveMind;
 21  
 import org.apache.tapestry.enhance.EnhancementOperation;
 22  
 import org.apache.tapestry.enhance.EnhancementWorker;
 23  
 import org.apache.tapestry.spec.IComponentSpecification;
 24  
 import org.apache.tapestry.spec.IContainedComponent;
 25  
 
 26  
 /**
 27  
  * An enhancement worker which performs several housekeeping tasks
 28  
  * relating to injected components.
 29  
  * Currently the worker ensures that copies of components contain
 30  
  * the correct bindings.
 31  
  * 
 32  
  * @author Andreas Andreou
 33  
  * @since 4.1.1
 34  
  */
 35  0
 public class ComponentHousekeepingWorker implements EnhancementWorker
 36  
 {
 37  
     public void performEnhancement( EnhancementOperation op, IComponentSpecification spec )
 38  
     {
 39  0
         for ( Iterator i = spec.getComponentIds().iterator(); i.hasNext(); )
 40  
         {
 41  0
             String id = ( String ) i.next();
 42  0
             IContainedComponent cc = spec.getComponent(id);
 43  0
             String copyOf = cc.getCopyOf();
 44  0
             Collection bindingNames = cc.getBindingNames();
 45  
             
 46  0
             if (HiveMind.isNonBlank(copyOf) && bindingNames.size() == 0)
 47  
             {
 48  0
                 IContainedComponent source = spec.getComponent(copyOf);
 49  0
                 if (source == null)
 50  0
                     throw new ApplicationRuntimeException(AnnotationMessages.unableToCopy(copyOf));                
 51  
                 
 52  0
                 AnnotationUtils.copyBindings(source, cc);
 53  
             }            
 54  0
         }
 55  0
     }
 56  
 }