View Javadoc
1 /* ==================================================================== 2 * License: 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * 3. The end-user documentation included with the redistribution, 17 * if any, must include the following acknowledgment: 18 * "This product includes software developed by 19 * Robert Half International (http://www.rhi.com/)." 20 * Alternately, this acknowledgment may appear in the software itself, 21 * if and wherever such third-party acknowledgments normally appear. 22 * 23 * 4. The names "Parc", "RHI", and "Robert Half International" must 24 * not be used to endorse or promote products derived from this 25 * software without prior written permission. For written 26 * permission, please contact pete.mckinstry@rhi.com. 27 * 28 * 5. Products derived from this software may not be called "PARC", 29 * nor may "PARC" appear in their name, without prior written 30 * permission of Robert Half International. 31 * 32 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 33 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 34 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 36 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 43 * SUCH DAMAGE. 44 * ==================================================================== 45 * 46 */ 47 package com.rhi.architecture.batch; 48 49 import com.rhi.architecture.resource.InitializationException; 50 import com.rhi.architecture.logging.Logger; 51 import com.rhi.architecture.logging.LogUtil; 52 import com.rhi.architecture.config.ConfigurationException; 53 54 import java.util.Properties; 55 56 /*** 57 * ConfigMixinUtils 58 * <br/> 59 * Abstracts away the loading of configuration data so that it can be shared 60 * by different classes. (PipelineProcess & PARCApplication currently.) 61 * 62 * @author petmck01 63 * @copyright 2002, Robert Half Int'l, All rights reserved. 64 * 65 * @version 1.0 66 */ 67 public class ConfigMixinUtils { 68 69 /*** 70 * logger 71 */ 72 private static Logger log = null; 73 74 /*** 75 * class initializer tries to create logger instance. 76 */ 77 static { 78 try { 79 log = LogUtil.getLogger(); 80 } 81 catch (ConfigurationException e) { 82 System.err.println("failure creating logger instance"); 83 } 84 } 85 86 /*** 87 * Instantiate a Configuration Mixin class & load it's property 88 * settings. 89 * 90 * @param mixinClassName 91 * @param props 92 * @throws InitializationException 93 * @since 1.0 94 */ 95 private static void loadConfigMixin(String mixinClassName, Properties props) 96 throws InitializationException { 97 try { 98 log.debug("loading ConfigMixin = " + mixinClassName); 99 Class mixinClass = Class.forName(mixinClassName); 100 ConfigMixin config = (ConfigMixin) mixinClass.newInstance(); 101 config.loadConfiguration(props); 102 } 103 catch (ClassNotFoundException cnfe) { 104 throw new InitializationException( 105 "ClassNotFoundException = " + cnfe.toString()); 106 } 107 catch (InstantiationException ie) { 108 throw new InitializationException( 109 "InstantiationException = " + ie.toString()); 110 } 111 catch (IllegalAccessException iae) { 112 throw new InitializationException( 113 "IllegalAccessException = " + iae.toString()); 114 } 115 } 116 117 /*** 118 * Mixin classes can be used to append configuration 119 * information from disparate sources w/o affecting the 120 * core batch architecture. This facility allows the 121 * interface developer to add any number of optional mixin 122 * classes. They will be loaded and initialized @ runtime 123 * prior to initializing any framework objects. 124 * 125 * @param props - the complete config set. 126 * @throws InitializationException 127 * @since 1.0 128 */ 129 public static void loadAllMixins(Properties props) 130 throws InitializationException { 131 132 int count = 0; 133 while (true) { 134 // instead of using propertyNames() enumeration to find 135 // config mixins, i chose this method because it forces 136 // a certain well understood loading order. 137 String mixinClassName = props.getProperty("ConfigMixin" + count); 138 if (mixinClassName == null) { 139 break; 140 } 141 loadConfigMixin(mixinClassName, props); 142 count++; 143 } 144 } 145 146 }

This page was automatically generated by Maven