View Javadoc
1 /* 2 * AbstractBeanCfg.java 3 * Created on September 20, 2003 4 * 5 * The Blues Framework - A lightweight application framework 6 * Copyright (C) 2003 Lonnie Pryor 7 * http://blues.lonniepryor.com 8 * 9 * This library is free software; you can redistribute it and/or modify it under the 10 * terms of the GNU Lesser General Public License as published by the Free Software 11 * Foundation; either version 2.1 of the License, or (at your option) any later 12 * version. 13 * 14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 16 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along 19 * with this library; if not, write to: 20 * 21 * The Free Software Foundation, Inc. 22 * 59 Temple Place, Suite 330 23 * Boston, MA 02111-1307 USA 24 * 25 */ 26 package com.lonniepryor.blues.cfg; 27 28 import java.util.Iterator; 29 import java.util.LinkedList; 30 import java.util.List; 31 32 import com.lonniepryor.blues.util.BeanHelper; 33 34 /*** 35 * Utility base class for configuration elements that want to support calling 36 * declared JavaBeans operations. 37 * 38 * @author Lonnie Pryor 39 * @version $Revision: 1.1 $ 40 */ 41 public abstract class AbstractBeanCfg { 42 /*** The list of declared set configs. */ 43 private List setCfgs = new LinkedList(); 44 45 /*** 46 * Creates a new AbstractBeanCfg object. 47 */ 48 protected AbstractBeanCfg () { 49 } 50 51 /*** 52 * Declares a value to be set on this bean config. 53 * 54 * @param setValue The value set configuration. 55 */ 56 public void declareSetValue (SetValueCfg setValue) { 57 if (setValue == null) 58 throw new NullPointerException("Set value config cannot be null"); 59 setCfgs.add(setValue); 60 } 61 62 /*** 63 * Declares a refrence to be set on this bean config. 64 * 65 * @param setRefrence The refrence set configuration. 66 */ 67 public void declareSetRefrence (SetRefrenceCfg setRefrence) { 68 if (setRefrence == null) 69 throw new NullPointerException("Set refrence config cannot be null"); 70 setCfgs.add(setRefrence); 71 } 72 73 /*** 74 * Declares a nested JavaBean to be set on this bean config. 75 * 76 * @param setBean The bean set configuration. 77 */ 78 public void declareSetBean (SetBeanCfg setBean) { 79 if (setBean == null) 80 throw new NullPointerException("Set bean config cannot be null"); 81 setCfgs.add(setBean); 82 } 83 84 /*** 85 * Configures the specified JavaBean with the set operations declared on this 86 * element. 87 * 88 * @param beanInstance The JavaBean to configure. 89 * @param serviceDirectory The directory to look up refrenced services in. 90 */ 91 protected void configureBean (Object beanInstance, Directory serviceDirectory) { 92 if (beanInstance == null) 93 throw new NullPointerException("Bean instance cannot be null"); 94 configureBean( 95 BeanHelper.introspect(beanInstance.getClass()), beanInstance, serviceDirectory); 96 } 97 98 /*** 99 * Configures the specified JavaBean with the set operations declared on this 100 * element. 101 * 102 * @param helper The bean helper to use. 103 * @param beanInstance The JavaBean to configure. 104 * @param serviceDirectory The directory to look up refrenced services in. 105 */ 106 protected void configureBean ( 107 BeanHelper helper, Object beanInstance, Directory serviceDirectory) { 108 if (beanInstance == null) 109 throw new NullPointerException("Bean instance cannot be null"); 110 for (Iterator iter = setCfgs.iterator(); iter.hasNext();) 111 ((SetCfg)iter.next()).configure(helper, beanInstance, serviceDirectory); 112 } 113 }

This page was automatically generated by Maven