Coverage Report - org.apache.camel.builder.PolicyBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
PolicyBuilder
0% 
0% 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.builder;
 19  
 
 20  
 import java.util.ArrayList;
 21  
 import java.util.Collections;
 22  
 
 23  
 import org.apache.camel.Exchange;
 24  
 import org.apache.camel.Processor;
 25  
 import org.apache.camel.RuntimeCamelException;
 26  
 import org.apache.camel.spi.Policy;
 27  
 
 28  
 /**
 29  
  * @version $Revision: 519943 $
 30  
  */
 31  
 public class PolicyBuilder implements ProcessorFactory {
 32  0
     private final ArrayList<Policy> policies = new ArrayList<Policy>();
 33  
         private final FromBuilder parent;
 34  
         private FromBuilder target;
 35  
 
 36  0
         public PolicyBuilder(FromBuilder parent) {
 37  0
         this.parent = parent;
 38  0
         }
 39  
         
 40  
         @Fluent("policy")
 41  
         public PolicyBuilder add(@FluentArg("ref") Policy interceptor) {
 42  0
                 policies.add(interceptor);
 43  0
                 return this;
 44  
         }
 45  
         
 46  
         @Fluent(callOnElementEnd=true)
 47  
     public FromBuilder target() {
 48  0
         this.target = new FromBuilder(parent);
 49  0
         return target;
 50  
     }
 51  
 
 52  
     public Processor createProcessor() throws Exception {
 53  
             
 54  
             // The target is required.
 55  0
             if( target == null ) 
 56  0
                     throw new RuntimeCamelException("target not provided.");
 57  
             
 58  0
         Processor last = target.createProcessor();
 59  0
             Collections.reverse(policies);
 60  0
         for (Policy p : policies) {
 61  0
             last = p.wrap(last);
 62  0
         }
 63  
         
 64  0
         return last;
 65  
     }
 66  
 }