001    package railo.runtime.config.component;
002    
003    import railo.commons.io.res.Resource;
004    import railo.runtime.config.ConfigWebFactory;
005    
006    public class ComponentFactory {
007    
008            
009            /**
010            * this method deploy all components for org.railo.cfml
011            * @param dir components directory
012            * @param doNew redeploy even the file exist, this is set to true when a new version is started
013            */
014            public static void deploy(Resource dir, boolean doNew) {
015                    String path="/resource/component/org/railo/cfml/";
016                    
017                    deploy(dir,path,doNew,"Base");
018                    deploy(dir,path,doNew,"Feed");
019                    deploy(dir,path,doNew,"Ftp");
020                    deploy(dir,path,doNew,"Http");
021                    deploy(dir,path,doNew,"Mail");
022                    deploy(dir,path,doNew,"Query");
023                    deploy(dir,path,doNew,"Result");
024                    deploy(dir,path,doNew,"Administrator");
025                    
026                    // orm
027                    dir = dir.getRealResource("orm");
028                    path+="orm/";
029                    if(!dir.exists())dir.mkdirs();
030                    deploy(dir,path,doNew,"IEventHandler");
031                    deploy(dir,path,doNew,"INamingStrategy");
032            }
033    
034            private static void deploy(Resource dir, String path,boolean doNew, String name) {
035                    Resource f = dir.getRealResource(name+".cfc");
036            if(!f.exists() || doNew)ConfigWebFactory.createFileFromResourceEL(path+name+".cfc",f);
037            }
038    }
039