001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.config.component; 020 021import lucee.commons.io.res.Resource; 022import lucee.runtime.config.ConfigWebFactory; 023 024public class ComponentFactory { 025 026 027 /** 028 * this method deploy all components for org.lucee.cfml 029 * @param dir components directory 030 * @param doNew redeploy even the file exist, this is set to true when a new version is started 031 */ 032 public static void deploy(Resource dir, boolean doNew) { 033 String path="/resource/component/org/lucee/cfml/"; 034 035 deploy(dir,path,doNew,"Base"); 036 deploy(dir,path,doNew,"Feed"); 037 deploy(dir,path,doNew,"Ftp"); 038 deploy(dir,path,doNew,"Http"); 039 deploy(dir,path,doNew,"Mail"); 040 deploy(dir,path,doNew,"Query"); 041 deploy(dir,path,doNew,"Result"); 042 deploy(dir,path,doNew,"Administrator"); 043 044 // orm 045 { 046 Resource ormDir = dir.getRealResource("orm"); 047 String ormPath = path+"orm/"; 048 if(!ormDir.exists())ormDir.mkdirs(); 049 deploy(ormDir,ormPath,doNew,"IEventHandler"); 050 deploy(ormDir,ormPath,doNew,"INamingStrategy"); 051 } 052 // test 053 { 054 Resource testDir = dir.getRealResource("test"); 055 String testPath = path+"test/"; 056 if(!testDir.exists())testDir.mkdirs(); 057 deploy(testDir,testPath,doNew,"AdministratorTest"); 058 deploy(testDir,testPath,doNew,"LuceeTestSuite"); 059 deploy(testDir,testPath,doNew,"LuceeTestSuiteRunner"); 060 deploy(testDir,testPath,doNew,"LuceeTestCase"); 061 } 062 // reporter 063 { 064 Resource repDir = dir.getRealResource("test/reporter"); 065 String repPath = path+"test/reporter/"; 066 if(!repDir.exists())repDir.mkdirs(); 067 deploy(repDir,repPath,doNew,"HTMLReporter"); 068 } 069 070 } 071 072 private static void deploy(Resource dir, String path,boolean doNew, String name) { 073 Resource f = dir.getRealResource(name+".cfc"); 074 if(!f.exists() || doNew)ConfigWebFactory.createFileFromResourceEL(path+name+".cfc",f); 075 } 076} 077