001 package org.apache.camel.spring.builder; 002 003 import java.util.ArrayList; 004 005 import org.springframework.beans.factory.BeanFactory; 006 007 public class BuilderStatement { 008 private ArrayList<BuilderAction> actions; 009 private Class returnType; 010 011 public Object create(BeanFactory beanFactory, Object rootBuilder) { 012 Object currentBuilder = rootBuilder; 013 BuilderAction lastAction=null; 014 for (BuilderAction action : actions) { 015 // The last action may have left us without a builder to invoke next! 016 if( currentBuilder == null ) { 017 throw new IllegalArgumentException("Invalid configuration. The '"+lastAction.getName()+"' action cannot be followed by the '"+action.getName()+"' action."); 018 } 019 currentBuilder = action.invoke(beanFactory, rootBuilder, currentBuilder); 020 lastAction = action; 021 } 022 return currentBuilder; 023 } 024 025 public ArrayList<BuilderAction> getActions() { 026 return actions; 027 } 028 public void setActions(ArrayList<BuilderAction> actions) { 029 this.actions = actions; 030 } 031 032 public Class getReturnType() { 033 return returnType; 034 } 035 public void setReturnType(Class returnType) { 036 this.returnType = returnType; 037 038 } 039 040 }