1 package org.jahia.bin; 2 3 import java.io.File ; 4 import java.io.IOException ; 5 6 import java.util.ArrayList ; 7 import java.util.Iterator ; 8 9 import org.apache.commons.digester.Digester; 10 import org.apache.commons.digester.Rule; 11 import org.xml.sax.SAXException ; 12 13 26 27 class ClassesPreloadManager { 28 29 ArrayList preloadClassNames = new ArrayList (); 30 31 58 public ClassesPreloadManager(String configurationFileName) 59 throws IOException , SAXException , ClassNotFoundException { 60 loadXMLConfiguration(configurationFileName); 61 preloadClasses(); 62 } 63 64 private void loadXMLConfiguration (String configurationFileName) 65 throws IOException , SAXException { 66 67 Digester digester = new Digester(); 68 69 digester.addRule("preload-classes/class-name", new AddClassNameRule()); 72 73 File configurationFile = new File (configurationFileName); 75 digester.parse(configurationFile); 76 } 77 78 private void preloadClasses() 79 throws ClassNotFoundException { 80 Iterator preloadClassNameIter = preloadClassNames.iterator(); 83 while (preloadClassNameIter.hasNext()) { 84 String curClassName = (String ) preloadClassNameIter.next(); 85 Class.forName(curClassName); 86 } 87 } 88 89 final class AddClassNameRule extends Rule { 90 public void body(String namespace, String name, String text) 91 throws Exception { 92 preloadClassNames.add(text); 93 } 94 } 95 96 } | Popular Tags |