001 package railo.runtime.config; 002 003 import java.io.File; 004 import java.io.IOException; 005 import java.io.PrintWriter; 006 import java.lang.reflect.Method; 007 import java.net.URL; 008 import java.util.ArrayList; 009 import java.util.Arrays; 010 import java.util.Collections; 011 import java.util.Comparator; 012 import java.util.HashMap; 013 import java.util.Iterator; 014 import java.util.List; 015 import java.util.Locale; 016 import java.util.Map; 017 import java.util.Map.Entry; 018 import java.util.TimeZone; 019 020 import javax.servlet.ServletException; 021 022 import org.apache.commons.collections.map.ReferenceMap; 023 024 import railo.commons.collections.HashTable; 025 import railo.commons.io.SystemUtil; 026 import railo.commons.io.log.Log; 027 import railo.commons.io.log.LogAndSource; 028 import railo.commons.io.log.LogAndSourceImpl; 029 import railo.commons.io.log.LogConsole; 030 import railo.commons.io.res.Resource; 031 import railo.commons.io.res.ResourceProvider; 032 import railo.commons.io.res.Resources; 033 import railo.commons.io.res.ResourcesImpl; 034 import railo.commons.io.res.filter.ExtensionResourceFilter; 035 import railo.commons.io.res.type.compress.Compress; 036 import railo.commons.io.res.util.ResourceClassLoaderFactory; 037 import railo.commons.io.res.util.ResourceUtil; 038 import railo.commons.lang.ClassException; 039 import railo.commons.lang.ClassUtil; 040 import railo.commons.lang.Md5; 041 import railo.commons.lang.PhysicalClassLoader; 042 import railo.commons.lang.StringUtil; 043 import railo.commons.lang.SystemOut; 044 import railo.commons.net.JarLoader; 045 import railo.loader.TP; 046 import railo.loader.engine.CFMLEngine; 047 import railo.loader.engine.CFMLEngineFactory; 048 import railo.loader.util.ExtensionFilter; 049 import railo.runtime.CFMLFactory; 050 import railo.runtime.Component; 051 import railo.runtime.Mapping; 052 import railo.runtime.MappingImpl; 053 import railo.runtime.Page; 054 import railo.runtime.PageContext; 055 import railo.runtime.PageContextImpl; 056 import railo.runtime.PageSource; 057 import railo.runtime.PageSourceImpl; 058 import railo.runtime.cache.CacheConnection; 059 import railo.runtime.cfx.CFXTagPool; 060 import railo.runtime.cfx.customtag.CFXTagPoolImpl; 061 import railo.runtime.component.ImportDefintion; 062 import railo.runtime.customtag.InitFile; 063 import railo.runtime.db.DataSource; 064 import railo.runtime.db.DatasourceConnectionPool; 065 import railo.runtime.dump.DumpWriter; 066 import railo.runtime.dump.DumpWriterEntry; 067 import railo.runtime.dump.HTMLDumpWriter; 068 import railo.runtime.engine.ExecutionLogFactory; 069 import railo.runtime.engine.ThreadLocalPageContext; 070 import railo.runtime.exp.ApplicationException; 071 import railo.runtime.exp.DatabaseException; 072 import railo.runtime.exp.DeprecatedException; 073 import railo.runtime.exp.ExpressionException; 074 import railo.runtime.exp.PageException; 075 import railo.runtime.exp.PageRuntimeException; 076 import railo.runtime.exp.SecurityException; 077 import railo.runtime.extension.Extension; 078 import railo.runtime.extension.ExtensionProvider; 079 import railo.runtime.extension.ExtensionProviderImpl; 080 import railo.runtime.listener.ApplicationListener; 081 import railo.runtime.monitor.RequestMonitor; 082 import railo.runtime.net.amf.AMFCaster; 083 import railo.runtime.net.amf.ClassicAMFCaster; 084 import railo.runtime.net.amf.ModernAMFCaster; 085 import railo.runtime.net.mail.Server; 086 import railo.runtime.net.ntp.NtpClient; 087 import railo.runtime.op.Caster; 088 import railo.runtime.orm.ORMConfiguration; 089 import railo.runtime.orm.ORMEngine; 090 import railo.runtime.orm.ORMException; 091 import railo.runtime.schedule.Scheduler; 092 import railo.runtime.schedule.SchedulerImpl; 093 import railo.runtime.search.SearchEngine; 094 import railo.runtime.security.SecurityManager; 095 import railo.runtime.spooler.SpoolerEngine; 096 import railo.runtime.tag.Admin; 097 import railo.runtime.type.Struct; 098 import railo.runtime.type.StructImpl; 099 import railo.runtime.type.UDF; 100 import railo.runtime.type.dt.TimeSpan; 101 import railo.runtime.type.dt.TimeSpanImpl; 102 import railo.runtime.type.scope.ClusterNotSupported; 103 import railo.runtime.type.scope.Undefined; 104 import railo.runtime.util.ApplicationContext; 105 import railo.runtime.video.VideoExecuterNotSupported; 106 import railo.transformer.library.function.FunctionLib; 107 import railo.transformer.library.function.FunctionLibException; 108 import railo.transformer.library.function.FunctionLibFactory; 109 import railo.transformer.library.function.FunctionLibFunction; 110 import railo.transformer.library.function.FunctionLibFunctionArg; 111 import railo.transformer.library.tag.TagLib; 112 import railo.transformer.library.tag.TagLibException; 113 import railo.transformer.library.tag.TagLibFactory; 114 import railo.transformer.library.tag.TagLibTag; 115 import railo.transformer.library.tag.TagLibTagAttr; 116 import flex.messaging.config.ConfigMap; 117 118 119 /** 120 * Hold the definitions of the railo cold fusion configuration. 121 */ 122 public abstract class ConfigImpl implements Config { 123 124 125 126 public static final short INSPECT_ALWAYS = 0; 127 public static final short INSPECT_ONCE = 1; 128 public static final short INSPECT_NEVER = 2; 129 130 public static final int CLIENT_BOOLEAN_TRUE = 0; 131 public static final int CLIENT_BOOLEAN_FALSE = 1; 132 public static final int SERVER_BOOLEAN_TRUE = 2; 133 public static final int SERVER_BOOLEAN_FALSE = 3; 134 public static final ExtensionProvider[] RAILO_EXTENSION_PROVIDERS = new ExtensionProviderImpl[]{ 135 new ExtensionProviderImpl("http://www.getrailo.com/ExtensionProvider.cfc",true), 136 new ExtensionProviderImpl("http://www.getrailo.org/ExtensionProvider.cfc",true) 137 }; 138 private static final Extension[] EXTENSIONS_EMPTY = new Extension[0]; 139 public static final int CACHE_DEFAULT_NONE = 0; 140 public static final int CACHE_DEFAULT_OBJECT = 1; 141 public static final int CACHE_DEFAULT_TEMPLATE = 2; 142 public static final int CACHE_DEFAULT_QUERY = 4; 143 public static final int CACHE_DEFAULT_RESOURCE = 8; 144 145 public static final int AMF_CONFIG_TYPE_XML = 1; 146 public static final int AMF_CONFIG_TYPE_MANUAL = 2; 147 148 149 private PhysicalClassLoader rpcClassLoader; 150 private Map datasources=new HashTable(); 151 private Map caches=new HashTable(); 152 153 private CacheConnection defaultCacheObject=null; 154 private CacheConnection defaultCacheTemplate=null; 155 private CacheConnection defaultCacheQuery=null; 156 private CacheConnection defaultCacheResource=null; 157 158 private String cacheDefaultConnectionNameObject=null; 159 private String cacheDefaultConnectionNameTemplate=null; 160 private String cacheDefaultConnectionNameQuery=null; 161 private String cacheDefaultConnectionNameResource=null; 162 163 private TagLib[] tlds=new TagLib[1]; 164 private FunctionLib[] flds=new FunctionLib[1]; 165 private FunctionLib combinedFLDs; 166 167 private short type=SCOPE_STANDARD; 168 //private File deployDirectory; 169 private boolean _allowImplicidQueryCall=true; 170 private boolean _mergeFormAndURL=false; 171 172 private int _debug; 173 174 private boolean suppresswhitespace = false; 175 private boolean suppressContent = false; 176 private boolean showVersion = false; 177 178 private Resource tempDirectory; 179 private TimeSpan clientTimeout=new TimeSpanImpl(90,0,0,0); 180 private TimeSpan sessionTimeout=new TimeSpanImpl(0,0,30,0); 181 private TimeSpan applicationTimeout=new TimeSpanImpl(1,0,0,0); 182 private TimeSpan requestTimeout=new TimeSpanImpl(0,0,0,30); 183 184 private boolean sessionManagement=true; 185 private boolean clientManagement=false; 186 private boolean clientCookies=true; 187 private boolean domainCookies=false; 188 189 private Resource configFile; 190 private Resource configDir; 191 192 private long loadTime; 193 194 private int spoolInterval=30; 195 private boolean spoolEnable=true; 196 197 private Server[] mailServers; 198 199 private int mailTimeout=30; 200 201 private TimeZone timeZone; 202 203 private String timeServer=""; 204 private boolean useTimeServer=true; 205 206 private long timeOffset; 207 208 //private ConnectionPool conns; 209 210 private SearchEngine searchEngine; 211 212 private Locale locale; 213 214 private boolean psq=false; 215 216 private String debugTemplate; 217 private boolean debugShowUsage; 218 private Map errorTemplates=new HashMap(); 219 220 private String password; 221 222 private Mapping[] mappings=new Mapping[0]; 223 private Mapping[] customTagMappings=new Mapping[0]; 224 private Mapping[] componentMappings=new Mapping[0]; 225 226 227 private Map<String,Mapping> customTagAppMappings=new ReferenceMap(ReferenceMap.SOFT,ReferenceMap.SOFT); 228 229 private SchedulerImpl scheduler; 230 231 private CFXTagPool cfxTagPool; 232 233 private PageSource baseComponentPageSource; 234 //private Page baseComponentPage; 235 private String baseComponentTemplate; 236 237 238 private LogAndSource mailLogger=null;//new LogAndSourceImpl(LogConsole.getInstance(Log.LEVEL_ERROR),""); 239 private LogAndSource threadLogger=null;//new LogAndSourceImpl(LogConsole.getInstance(Log.LEVEL_INFO),""); 240 241 private LogAndSource requestTimeoutLogger=null; 242 private LogAndSource applicationLogger=null; 243 private LogAndSource exceptionLogger=null; 244 private LogAndSource traceLogger=null; 245 246 247 private short clientType=CLIENT_SCOPE_TYPE_COOKIE; 248 249 private String componentDumpTemplate; 250 private int componentDataMemberDefaultAccess=Component.ACCESS_PRIVATE; 251 private boolean triggerComponentDataMember=false; 252 253 254 private short sessionType=SESSION_TYPE_CFML; 255 256 //private EmailSpooler emailSpooler; 257 258 259 private Resource deployDirectory; 260 261 private short compileType=RECOMPILE_NEVER; 262 263 private String resourceCharset=SystemUtil.getCharset(); 264 private String templateCharset=SystemUtil.getCharset(); 265 private String webCharset="UTF-8"; 266 267 private String mailDefaultEncoding = "UTF-8"; 268 269 private Resource tldFile; 270 private Resource fldFile; 271 272 private Resources resources=new ResourcesImpl(); 273 274 private ApplicationListener applicationListener; 275 276 private int scriptProtect=ApplicationContext.SCRIPT_PROTECT_ALL; 277 278 //private boolean proxyEnable=false; 279 private String proxyServer=null; 280 private int proxyPort=80; 281 private String proxyUsername=null; 282 private String proxyPassword=null; 283 284 285 private Resource clientScopeDir; 286 private Resource sessionScopeDir; 287 private long clientScopeDirSize=1024*1024*10; 288 private long sessionScopeDirSize=1024*1024*10; 289 290 private Resource cacheDir; 291 private long cacheDirSize=1024*1024*10; 292 293 294 private boolean useComponentShadow=true; 295 296 297 private PrintWriter out=SystemUtil.PRINTWRITER_OUT; 298 private PrintWriter err=SystemUtil.PRINTWRITER_ERR; 299 300 private DatasourceConnectionPool pool=new DatasourceConnectionPool(); 301 302 private boolean doCustomTagDeepSearch=false; 303 private boolean doComponentTagDeepSearch=false; 304 305 private double version=1.0D; 306 307 private boolean closeConnection=false; 308 private boolean contentLength=true; 309 private boolean allowCompression=false; 310 311 312 private boolean doLocalCustomTag=true; 313 314 private Struct constants=null; 315 316 private RemoteClient[] remoteClients; 317 318 private SpoolerEngine remoteClientSpoolerEngine; 319 320 private Resource remoteClientDirectory; 321 322 private LogAndSource remoteClientLog; 323 324 private boolean allowURLRequestTimeout=false; 325 private CFMLFactory factory; 326 private boolean errorStatusCode=true; 327 private int localMode=Undefined.MODE_LOCAL_OR_ARGUMENTS_ONLY_WHEN_EXISTS; 328 329 private String id; 330 private String securityToken; 331 private String securityKey; 332 private ExtensionProvider[] extensionProviders=RAILO_EXTENSION_PROVIDERS; 333 private Extension[] extensions=EXTENSIONS_EMPTY; 334 private boolean extensionEnabled; 335 private boolean allowRealPath=true; 336 //private ClassLoader classLoader; 337 338 private DumpWriterEntry[] dmpWriterEntries; 339 private Class clusterClass=ClusterNotSupported.class;//ClusterRemoteNotSupported.class;// 340 private Struct remoteClientUsage; 341 private Class adminSyncClass=AdminSyncNotSupported.class; 342 private AdminSync adminSync; 343 private String[] customTagExtensions=new String[]{"cfm","cfc"}; 344 private Class videoExecuterClass=VideoExecuterNotSupported.class; 345 346 protected MappingImpl tagMapping; 347 private Resource tagDirectory; 348 private Resource functionDirectory; 349 protected MappingImpl functionMapping; 350 private Map amfCasterArguments; 351 private Class amfCasterClass=ClassicAMFCaster.class; 352 private AMFCaster amfCaster; 353 private String defaultDataSource; 354 private short inspectTemplate=INSPECT_ONCE; 355 private String serial=""; 356 private String cacheMD5; 357 private boolean executionLogEnabled; 358 private ExecutionLogFactory executionLogFactory; 359 //private int clientScopeMaxAge=90; 360 private Map<String, ORMEngine> ormengines=new HashMap<String, ORMEngine>(); 361 private Class<ORMEngine> ormEngineClass; 362 private ORMConfiguration ormConfig; 363 private ResourceClassLoaderFactory classLoaderFactory; 364 365 private ImportDefintion componentDefaultImport=new ImportDefintion("org.railo.cfml","*"); 366 private boolean componentLocalSearch=true; 367 private boolean componentRootSearch=true; 368 private LogAndSource mappingLogger; 369 private LogAndSource ormLogger; 370 private boolean useComponentPathCache=true; 371 private boolean useCTPathCache=true; 372 private int amfConfigType=AMF_CONFIG_TYPE_XML; 373 private LogAndSource scopeLogger; 374 375 376 377 /** 378 * @return the allowURLRequestTimeout 379 */ 380 public boolean isAllowURLRequestTimeout() { 381 return allowURLRequestTimeout; 382 } 383 384 /** 385 * @param allowURLRequestTimeout the allowURLRequestTimeout to set 386 */ 387 public void setAllowURLRequestTimeout(boolean allowURLRequestTimeout) { 388 this.allowURLRequestTimeout = allowURLRequestTimeout; 389 } 390 391 392 /** 393 * @see railo.runtime.config.Config#getCompileType() 394 */ 395 public short getCompileType() { 396 return compileType; 397 } 398 399 /** 400 * @see railo.runtime.config.Config#reset() 401 */ 402 public void reset() { 403 timeServer=""; 404 componentDumpTemplate=""; 405 factory.resetPageContext(); 406 //resources.reset(); 407 ormengines.clear(); 408 compressResources.clear(); 409 clearFunctionCache(); 410 clearCTCache(); 411 clearComponentCache(); 412 //clearComponentMetadata(); 413 } 414 415 /** 416 * @see railo.runtime.config.Config#reloadTimeServerOffset() 417 */ 418 public void reloadTimeServerOffset() { 419 timeOffset=0; 420 if(useTimeServer && !StringUtil.isEmpty(timeServer,true)) { 421 NtpClient ntp=new NtpClient(timeServer); 422 try { 423 timeOffset=ntp.getOffset(); 424 } catch (IOException e) { 425 timeOffset=0; 426 } 427 } 428 } 429 430 431 /** 432 * private constructor called by factory method 433 * @param configDir config directory 434 * @param configFile config file 435 * @param id 436 * @throws FunctionLibException 437 * @throws TagLibException 438 */ 439 protected ConfigImpl(CFMLFactory factory,Resource configDir, Resource configFile) { 440 this(factory,configDir,configFile, 441 loadTLDs() , 442 loadFLDs()); 443 } 444 445 446 private static FunctionLib[] loadFLDs() { 447 try { 448 return new FunctionLib[]{FunctionLibFactory.loadFromSystem()}; 449 } catch (FunctionLibException e) { 450 return new FunctionLib[]{}; 451 } 452 } 453 454 private static TagLib[] loadTLDs() { 455 try { 456 return new TagLib[]{TagLibFactory.loadFromSystem()}; 457 } catch (TagLibException e) { 458 return new TagLib[]{}; 459 } 460 } 461 462 public ConfigImpl(CFMLFactory factory,Resource configDir, Resource configFile, TagLib[] tlds, FunctionLib[] flds) { 463 464 this.configDir=configDir; 465 this.configFile=configFile; 466 this.factory=factory; 467 468 this.tlds=duplicate(tlds,false); 469 this.flds=duplicate(flds,false); 470 } 471 472 473 private static TagLib[] duplicate(TagLib[] tlds, boolean deepCopy) { 474 TagLib[] rst = new TagLib[tlds.length]; 475 for(int i=0;i<tlds.length;i++){ 476 rst[i]=tlds[i].duplicate(deepCopy); 477 } 478 return rst; 479 } 480 private static FunctionLib[] duplicate(FunctionLib[] flds, boolean deepCopy) { 481 FunctionLib[] rst = new FunctionLib[flds.length]; 482 for(int i=0;i<flds.length;i++){ 483 rst[i]=flds[i].duplicate(deepCopy); 484 } 485 return rst; 486 } 487 488 /** 489 * @see railo.runtime.config.Config#getScopeCascadingType() 490 */ 491 public short getScopeCascadingType() { 492 return type; 493 } 494 495 /** 496 * @see railo.runtime.config.Config#getCFMLExtension() 497 */ 498 public String[] getCFMLExtensions() { 499 return new String[]{"cfm","cfc"}; 500 } 501 /** 502 * @see railo.runtime.config.Config#getCFCExtension() 503 */ 504 public String getCFCExtension() { 505 return "cfc"; 506 } 507 508 509 /** 510 * return all Function Library Deskriptors 511 * @return Array of Function Library Deskriptors 512 */ 513 public FunctionLib[] getFLDs() { 514 return flds; 515 } 516 517 public FunctionLib getCombinedFLDs() { 518 if(combinedFLDs==null)combinedFLDs=FunctionLibFactory.combineFLDs(flds); 519 return combinedFLDs; 520 } 521 522 /** 523 * return all Tag Library Deskriptors 524 * @return Array of Tag Library Deskriptors 525 */ 526 public TagLib[] getTLDs() { 527 return tlds; 528 } 529 530 /** 531 * @see railo.runtime.config.Config#allowImplicidQueryCall() 532 */ 533 public boolean allowImplicidQueryCall() { 534 return _allowImplicidQueryCall; 535 } 536 537 /** 538 * @see railo.runtime.config.Config#mergeFormAndURL() 539 */ 540 public boolean mergeFormAndURL() { 541 return _mergeFormAndURL; 542 } 543 544 /** 545 * @see railo.runtime.config.Config#getApplicationTimeout() 546 */ 547 public TimeSpan getApplicationTimeout() { 548 return applicationTimeout; 549 } 550 551 /** 552 * @see railo.runtime.config.Config#getSessionTimeout() 553 */ 554 public TimeSpan getSessionTimeout() { 555 return sessionTimeout; 556 } 557 558 /** 559 * @see railo.runtime.config.Config#getSessionTimeout() 560 */ 561 public TimeSpan getClientTimeout() { 562 return clientTimeout; 563 } 564 565 /** 566 * @see railo.runtime.config.Config#getRequestTimeout() 567 */ 568 public TimeSpan getRequestTimeout() { 569 return requestTimeout; 570 } 571 572 /** 573 * @see railo.runtime.config.Config#isClientCookies() 574 */ 575 public boolean isClientCookies() { 576 return clientCookies; 577 } 578 579 /** 580 * @see railo.runtime.config.Config#isClientManagement() 581 */ 582 public boolean isClientManagement() { 583 return clientManagement; 584 } 585 586 /** 587 * @see railo.runtime.config.Config#isDomainCookies() 588 */ 589 public boolean isDomainCookies() { 590 return domainCookies; 591 } 592 593 /** 594 * @see railo.runtime.config.Config#isSessionManagement() 595 */ 596 public boolean isSessionManagement() { 597 return sessionManagement; 598 } 599 600 /** 601 * @see railo.runtime.config.Config#isMailSpoolEnable() 602 */ 603 public boolean isMailSpoolEnable() { 604 //print.ln("isMailSpoolEnable:"+spoolEnable); 605 return spoolEnable; 606 } 607 608 /** 609 * @see railo.runtime.config.Config#getMailServers() 610 */ 611 public Server[] getMailServers() { 612 return mailServers; 613 } 614 615 /** 616 * @see railo.runtime.config.Config#getMailTimeout() 617 */ 618 public int getMailTimeout() { 619 return mailTimeout; 620 } 621 622 /** 623 * @see railo.runtime.config.Config#getPSQL() 624 */ 625 public boolean getPSQL() { 626 return psq; 627 } 628 629 /** 630 * @see railo.runtime.config.Config#getClassLoader() 631 */ 632 public ClassLoader getClassLoader() { 633 return classLoaderFactory.getResourceClassLoader(); 634 } 635 636 // FUTURE add to interface 637 public ClassLoader getClassLoader(Resource[] reses) throws IOException { 638 return classLoaderFactory.getResourceClassLoader(reses); 639 } 640 641 /* * 642 * @return the classLoaderFactory 643 644 public ResourceClassLoaderFactory getClassLoaderFactory() { 645 return classLoaderFactory; 646 } */ 647 648 /** 649 * @param classLoaderFactory the classLoaderFactory to set 650 */ 651 protected void setClassLoaderFactory(ResourceClassLoaderFactory classLoaderFactory) { 652 if(this.classLoaderFactory!=null){ 653 classLoaderFactory.reset(); 654 } 655 this.classLoaderFactory = classLoaderFactory; 656 } 657 658 /** 659 * @see railo.runtime.config.Config#getLocale() 660 */ 661 public Locale getLocale() { 662 return locale; 663 } 664 665 /** 666 * @see railo.runtime.config.Config#debug() 667 */ 668 public boolean debug() { 669 return _debug==CLIENT_BOOLEAN_TRUE || _debug==SERVER_BOOLEAN_TRUE; 670 } 671 public int intDebug() { 672 return _debug; 673 } 674 675 /** 676 * @see railo.runtime.config.Config#getTempDirectory() 677 */ 678 public Resource getTempDirectory() { 679 return tempDirectory; 680 } 681 682 /** 683 * @see railo.runtime.config.Config#getMailSpoolInterval() 684 */ 685 public int getMailSpoolInterval() { 686 return spoolInterval; 687 } 688 689 /** 690 * @see railo.runtime.config.Config#getMailLogger() 691 */ 692 public LogAndSource getMailLogger() { 693 if(mailLogger==null)mailLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 694 return mailLogger; 695 } 696 697 /** 698 * @see railo.runtime.config.Config#getMailLogger() 699 */ 700 public LogAndSource getThreadLogger() { 701 if(threadLogger==null)threadLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 702 return threadLogger; 703 } 704 705 706 public void setThreadLogger(LogAndSource threadLogger) { 707 this.threadLogger=threadLogger; 708 } 709 710 /** 711 * @see railo.runtime.config.Config#getRequestTimeoutLogger() 712 */ 713 public LogAndSource getRequestTimeoutLogger() { 714 if(requestTimeoutLogger==null)requestTimeoutLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 715 return requestTimeoutLogger; 716 } 717 718 /** 719 * @see railo.runtime.config.Config#getTimeZone() 720 */ 721 public TimeZone getTimeZone() { 722 return timeZone; 723 } 724 725 /** 726 * @see railo.runtime.config.Config#getTimeServerOffset() 727 */ 728 public long getTimeServerOffset() { 729 return timeOffset; 730 } 731 732 /** 733 * @see railo.runtime.config.Config#getSearchEngine() 734 */ 735 public SearchEngine getSearchEngine() { 736 return searchEngine; 737 } 738 739 /** 740 * @return return the Scheduler 741 */ 742 public Scheduler getScheduler() { 743 return scheduler; 744 } 745 746 /** 747 * @return gets the password 748 */ 749 protected String getPassword() { 750 return password; 751 } 752 753 /** 754 * @see railo.runtime.config.Config#hasPassword() 755 */ 756 public boolean hasPassword() { 757 return password!=null && password.length()>0; 758 } 759 760 /** 761 * @see railo.runtime.config.Config#passwordEqual(java.lang.String) 762 */ 763 public boolean passwordEqual(String password) { 764 return this.password.equals(password); 765 } 766 767 /** 768 * @see railo.runtime.config.Config#hasServerPassword() 769 */ 770 public boolean hasServerPassword() { 771 return getConfigServerImpl().hasPassword(); 772 } 773 774 /** 775 * @see railo.runtime.config.Config#getMappings() 776 */ 777 public Mapping[] getMappings() { 778 return mappings; 779 } 780 781 782 public PageSource getPageSource(Mapping[] mappings, String realPath,boolean onlyTopLevel) { 783 throw new PageRuntimeException(new DeprecatedException("method not supported")); 784 } 785 786 public PageSource getPageSourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping, boolean onlyPhysicalExisting) { 787 realPath=realPath.replace('\\','/'); 788 String lcRealPath = StringUtil.toLowerCase(realPath)+'/'; 789 Mapping mapping; 790 PageSource ps; 791 792 // app.cfc mappings 793 if(mappings!=null){ 794 for(int i=0;i<mappings.length;i++) { 795 mapping = mappings[i]; 796 //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical())); 797 if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 798 ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length())); 799 if(onlyPhysicalExisting) { 800 if(ps.physcalExists())return ps; 801 } 802 else if(ps.exists()) return ps; 803 } 804 } 805 } 806 807 /// special mappings 808 if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){ 809 String virtual="/mapping-tag"; 810 // tag mappings 811 Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()}; 812 if(lcRealPath.startsWith(virtual,0)){ 813 for(int i=0;i<tagMappings.length;i++) { 814 mapping = tagMappings[i]; 815 //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 816 ps = mapping.getPageSource(realPath.substring(virtual.length())); 817 if(onlyPhysicalExisting) { 818 if(ps.physcalExists())return ps; 819 } 820 else if(ps.exists()) return ps; 821 //} 822 } 823 } 824 825 // customtag mappings 826 tagMappings=getCustomTagMappings(); 827 virtual="/mapping-customtag"; 828 if(lcRealPath.startsWith(virtual,0)){ 829 for(int i=0;i<tagMappings.length;i++) { 830 mapping = tagMappings[i]; 831 //if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 832 ps = mapping.getPageSource(realPath.substring(virtual.length())); 833 if(onlyPhysicalExisting) { 834 if(ps.physcalExists())return ps; 835 } 836 else if(ps.exists()) return ps; 837 //} 838 } 839 } 840 } 841 842 // component mappings (only used for gateway) 843 if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) { 844 boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null)); 845 if(isCFC) { 846 Mapping[] cmappings = getComponentMappings(); 847 for(int i=0;i<cmappings.length;i++) { 848 ps = cmappings[i].getPageSource(realPath); 849 if(onlyPhysicalExisting) { 850 if(ps.physcalExists())return ps; 851 } 852 else if(ps.exists()) return ps; 853 } 854 } 855 } 856 857 // config mappings 858 for(int i=0;i<this.mappings.length-1;i++) { 859 mapping = this.mappings[i]; 860 if((!onlyTopLevel || mapping.isTopLevel()) && lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 861 ps= mapping.getPageSource(realPath.substring(mapping.getVirtual().length())); 862 if(onlyPhysicalExisting) { 863 if(ps.physcalExists())return ps; 864 } 865 else if(ps.exists()) return ps; 866 } 867 } 868 869 if(useDefaultMapping){ 870 ps= this.mappings[this.mappings.length-1].getPageSource(realPath); 871 if(onlyPhysicalExisting) { 872 if(ps.physcalExists())return ps; 873 } 874 else if(ps.exists()) return ps; 875 } 876 return null; 877 } 878 879 880 881 public PageSource[] getPageSources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping) { 882 realPath=realPath.replace('\\','/'); 883 String lcRealPath = StringUtil.toLowerCase(realPath)+'/'; 884 Mapping mapping; 885 PageSource ps; 886 List<PageSource> list=new ArrayList<PageSource>(); 887 888 // app.cfc mappings 889 if(mappings!=null){ 890 for(int i=0;i<mappings.length;i++) { 891 mapping = mappings[i]; 892 //print.err(lcRealPath+".startsWith"+(mapping.getStrPhysical())); 893 if(lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 894 list.add(mapping.getPageSource(realPath.substring(mapping.getVirtual().length()))); 895 } 896 } 897 } 898 899 /// special mappings 900 if(useSpecialMappings && lcRealPath.startsWith("/mapping-",0)){ 901 String virtual="/mapping-tag"; 902 // tag mappings 903 Mapping[] tagMappings=(this instanceof ConfigWebImpl)?new Mapping[]{((ConfigWebImpl)this).getServerTagMapping(),getTagMapping()}:new Mapping[]{getTagMapping()}; 904 if(lcRealPath.startsWith(virtual,0)){ 905 for(int i=0;i<tagMappings.length;i++) { 906 ps=tagMappings[i].getPageSource(realPath.substring(virtual.length())); 907 if(ps.exists()) list.add(ps); 908 } 909 } 910 911 // customtag mappings 912 tagMappings=getCustomTagMappings(); 913 virtual="/mapping-customtag"; 914 if(lcRealPath.startsWith(virtual,0)){ 915 for(int i=0;i<tagMappings.length;i++) { 916 ps=tagMappings[i].getPageSource(realPath.substring(virtual.length())); 917 if(ps.exists()) list.add(ps); 918 } 919 } 920 } 921 922 // component mappings (only used for gateway) 923 if(pc!=null && ((PageContextImpl)pc).isGatewayContext()) { 924 boolean isCFC=getCFCExtension().equalsIgnoreCase(ResourceUtil.getExtension(realPath, null)); 925 if(isCFC) { 926 Mapping[] cmappings = getComponentMappings(); 927 for(int i=0;i<cmappings.length;i++) { 928 ps=cmappings[i].getPageSource(realPath); 929 if(ps.exists()) list.add(ps); 930 } 931 } 932 } 933 934 // config mappings 935 for(int i=0;i<this.mappings.length-1;i++) { 936 mapping = this.mappings[i]; 937 if((!onlyTopLevel || mapping.isTopLevel()) && lcRealPath.startsWith(mapping.getVirtualLowerCaseWithSlash(),0)) { 938 list.add(mapping.getPageSource(realPath.substring(mapping.getVirtual().length()))); 939 } 940 } 941 942 if(useDefaultMapping){ 943 list.add(this.mappings[this.mappings.length-1].getPageSource(realPath)); 944 } 945 return list.toArray(new PageSource[list.size()]); 946 } 947 948 /** 949 * @param mappings2 950 * @param realPath 951 * @param alsoDefaultMapping ignore default mapping (/) or not 952 * @return physical path from mapping 953 */ 954 public Resource getPhysical(Mapping[] mappings, String realPath, boolean alsoDefaultMapping) { 955 throw new PageRuntimeException(new DeprecatedException("method not supported")); 956 } 957 958 959 public Resource[] getPhysicalResources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping) { 960 PageSource[] pages = getPageSources(pc, mappings, realPath, onlyTopLevel, useSpecialMappings, useDefaultMapping); 961 List<Resource> list=new ArrayList<Resource>(); 962 Resource res; 963 for(int i=0;i<pages.length;i++) { 964 if(!pages[i].getMapping().hasPhysical()) continue; 965 res=pages[i].getPhyscalFile(); 966 if(res!=null) list.add(res); 967 } 968 return list.toArray(new Resource[list.size()]); 969 } 970 971 972 public Resource getPhysicalResourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping) { 973 PageSource ps = getPageSourceExisting(pc, mappings, realPath, onlyTopLevel, useSpecialMappings, useDefaultMapping,true); 974 if(ps==null) return null; 975 return ps.getPhyscalFile(); 976 } 977 978 /** 979 * @param mappings2 980 * @see railo.runtime.config.Config#toPageSource(railo.commons.io.res.Resource, railo.runtime.PageSource) 981 */ 982 public PageSource toPageSource(Mapping[] mappings, Resource res,PageSource defaultValue) { 983 Mapping mapping; 984 Resource root; 985 String path; 986 987 // app.cfc mappings 988 if(mappings!=null){ 989 for(int i=0;i<mappings.length;i++) { 990 mapping = mappings[i]; 991 root=mapping.getPhysical(); 992 path=ResourceUtil.getPathToChild(res, root); 993 if(path!=null) { 994 return mapping.getPageSource(path); 995 } 996 } 997 } 998 999 // config mappings 1000 for(int i=0;i<this.mappings.length;i++) { 1001 mapping = this.mappings[i]; 1002 root=mapping.getPhysical(); 1003 path=ResourceUtil.getPathToChild(res, root); 1004 //print.out(path+"==="+res+"="+root); 1005 if(path!=null) { 1006 return mapping.getPageSource(path); 1007 } 1008 } 1009 1010 // map resource to root mapping when same filesystem 1011 Mapping rootMapping = this.mappings[this.mappings.length-1]; 1012 root=rootMapping.getPhysical(); 1013 if(res.getResourceProvider().getScheme().equals(root.getResourceProvider().getScheme())){ 1014 String realpath=""; 1015 while(root!=null && !ResourceUtil.isChildOf(res, root)){ 1016 root=root.getParentResource(); 1017 realpath+="../"; 1018 } 1019 String p2c=ResourceUtil.getPathToChild(res,root); 1020 if(StringUtil.startsWith(p2c, '/') || StringUtil.startsWith(p2c, '\\') ) 1021 p2c=p2c.substring(1); 1022 realpath+=p2c; 1023 1024 return rootMapping.getPageSource(realpath); 1025 } 1026 1027 return defaultValue; 1028 } 1029 1030 /** 1031 * @see railo.runtime.config.Config#getConfigDir() 1032 */ 1033 public Resource getConfigDir() { 1034 return configDir; 1035 } 1036 1037 /** 1038 * @see railo.runtime.config.Config#getConfigFile() 1039 */ 1040 public Resource getConfigFile() { 1041 return configFile; 1042 } 1043 1044 /** 1045 * @see railo.runtime.config.Config#getScheduleLogger() 1046 */ 1047 public LogAndSource getScheduleLogger() { 1048 return scheduler.getLogger(); 1049 } 1050 1051 /** 1052 * @see railo.runtime.config.Config#getApplicationLogger() 1053 */ 1054 public LogAndSource getApplicationLogger() { 1055 if(applicationLogger==null)applicationLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 1056 return applicationLogger; 1057 } 1058 1059 public LogAndSource getScopeLogger() { 1060 if(scopeLogger==null)scopeLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 1061 return scopeLogger; 1062 } 1063 1064 /** 1065 * sets the password 1066 * @param password 1067 */ 1068 protected void setPassword(String password) { 1069 this.password=password; 1070 } 1071 1072 1073 /** 1074 * set how railo cascade scopes 1075 * @param type cascading type 1076 */ 1077 protected void setScopeCascadingType(String type) { 1078 1079 if(type.equalsIgnoreCase("strict")) setScopeCascadingType(SCOPE_STRICT); 1080 else if(type.equalsIgnoreCase("small")) setScopeCascadingType(SCOPE_SMALL); 1081 else if(type.equalsIgnoreCase("standard"))setScopeCascadingType(SCOPE_STANDARD); 1082 else if(type.equalsIgnoreCase("standart"))setScopeCascadingType(SCOPE_STANDARD); 1083 else setScopeCascadingType(SCOPE_STANDARD); 1084 } 1085 1086 /** 1087 * set how railo cascade scopes 1088 * @param type cascading type 1089 */ 1090 protected void setScopeCascadingType(short type) { 1091 this.type=type; 1092 } 1093 1094 protected void addTag(String nameSpace, String nameSpaceSeperator,String name, String clazz){ 1095 for(int i=0;i<tlds.length;i++) { 1096 if(tlds[i].getNameSpaceAndSeparator().equalsIgnoreCase(nameSpace+nameSpaceSeperator)){ 1097 TagLibTag tlt = new TagLibTag(tlds[i]); 1098 tlt.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_DYNAMIC); 1099 tlt.setBodyContent("free"); 1100 tlt.setTagClass(clazz); 1101 tlt.setName(name); 1102 tlds[i].setTag(tlt ); 1103 } 1104 } 1105 } 1106 1107 /** 1108 * set the optional directory of the tag library deskriptors 1109 * @param fileTld directory of the tag libray deskriptors 1110 * @throws TagLibException 1111 */ 1112 protected void setTldFile(Resource fileTld) throws TagLibException { 1113 if(fileTld==null) return; 1114 this.tldFile=fileTld; 1115 String key; 1116 Map map=new HashMap(); 1117 // First fill existing to set 1118 for(int i=0;i<tlds.length;i++) { 1119 key=getKey(tlds[i]); 1120 map.put(key,tlds[i]); 1121 } 1122 1123 TagLib tl; 1124 1125 // now overwrite with new data 1126 if(fileTld.isDirectory()) { 1127 Resource[] files=fileTld.listResources(new ExtensionResourceFilter("tld")); 1128 for(int i=0;i<files.length;i++) { 1129 try { 1130 tl = TagLibFactory.loadFromFile(files[i]); 1131 key=getKey(tl); 1132 if(!map.containsKey(key)) 1133 map.put(key,tl); 1134 else 1135 overwrite((TagLib) map.get(key),tl); 1136 } 1137 catch(TagLibException tle) { 1138 SystemOut.printDate(out,"can't load tld "+files[i]); 1139 tle.printStackTrace(getErrWriter()); 1140 } 1141 1142 } 1143 } 1144 else if(fileTld.isFile()){ 1145 tl = TagLibFactory.loadFromFile(fileTld); 1146 key=getKey(tl); 1147 if(!map.containsKey(key)) 1148 map.put(key,tl); 1149 else overwrite((TagLib) map.get(key),tl); 1150 } 1151 1152 // now fill back to array 1153 tlds=new TagLib[map.size()]; 1154 int index=0; 1155 Iterator it = map.entrySet().iterator(); 1156 while(it.hasNext()) { 1157 tlds[index++]=(TagLib) ((Map.Entry)it.next()).getValue(); 1158 } 1159 } 1160 1161 public TagLib getCoreTagLib(){ 1162 for(int i=0;i<tlds.length;i++) { 1163 if(tlds[i].getNameSpaceAndSeparator().equals("cf"))return tlds[i]; 1164 } 1165 throw new RuntimeException("no core taglib found"); // this should never happen 1166 } 1167 1168 protected void setTagDirectory(Resource tagDirectory) { 1169 this.tagDirectory=tagDirectory; 1170 1171 this.tagMapping= new MappingImpl(this,"/mapping-tag/",tagDirectory.getAbsolutePath(),null,true,true,true,true,true,false,true); 1172 1173 TagLib tl=getCoreTagLib(); 1174 1175 // now overwrite with new data 1176 if(tagDirectory.isDirectory()) { 1177 String[] files=tagDirectory.list(new ExtensionResourceFilter(new String[]{"cfm","cfc"})); 1178 for(int i=0;i<files.length;i++) { 1179 if(tl!=null)createTag(tl, files[i]); 1180 1181 } 1182 } 1183 1184 } 1185 1186 public void createTag(TagLib tl,String filename) {// Jira 1298 1187 String name=toName(filename);//filename.substring(0,filename.length()-(getCFCExtension().length()+1));xxx 1188 1189 TagLibTag tlt = new TagLibTag(tl); 1190 tlt.setName(name); 1191 tlt.setTagClass("railo.runtime.tag.CFTagCore"); 1192 tlt.setHandleExceptions(true); 1193 tlt.setBodyContent("free"); 1194 tlt.setParseBody(false); 1195 tlt.setDescription(""); 1196 tlt.setAttributeType(TagLibTag.ATTRIBUTE_TYPE_MIXED); 1197 1198 1199 TagLibTagAttr tlta = new TagLibTagAttr(tlt); 1200 tlta.setName("__filename"); 1201 tlta.setRequired(true); 1202 tlta.setRtexpr(true); 1203 tlta.setType("string"); 1204 tlta.setHidden(true); 1205 tlta.setDefaultValue(filename); 1206 tlt.setAttribute(tlta); 1207 1208 tlta = new TagLibTagAttr(tlt); 1209 tlta.setName("__name"); 1210 tlta.setRequired(true); 1211 tlta.setRtexpr(true); 1212 tlta.setHidden(true); 1213 tlta.setType("string"); 1214 tlta.setDefaultValue(name); 1215 tlt.setAttribute(tlta); 1216 1217 tlta = new TagLibTagAttr(tlt); 1218 tlta.setName("__isweb"); 1219 tlta.setRequired(true); 1220 tlta.setRtexpr(true); 1221 tlta.setHidden(true); 1222 tlta.setType("boolean"); 1223 tlta.setDefaultValue(this instanceof ConfigWeb?"true":"false"); 1224 tlt.setAttribute(tlta); 1225 1226 tl.setTag(tlt); 1227 } 1228 1229 protected void setFunctionDirectory(Resource functionDirectory) { 1230 this.functionDirectory=functionDirectory; 1231 this.functionMapping= new MappingImpl(this,"/mapping-function/",functionDirectory.getAbsolutePath(),null,true,true,true,true,true,false,true); 1232 FunctionLib fl=flds[flds.length-1]; 1233 1234 // now overwrite with new data 1235 if(functionDirectory.isDirectory()) { 1236 String[] files=functionDirectory.list(new ExtensionResourceFilter(getCFMLExtensions())); 1237 1238 for(int i=0;i<files.length;i++) { 1239 if(fl!=null)createFunction(fl, files[i]); 1240 1241 } 1242 } 1243 1244 } 1245 1246 public void createFunction(FunctionLib fl,String filename) { 1247 PageSource ps = functionMapping.getPageSource(filename); 1248 1249 String name=toName(filename);//filename.substring(0,filename.length()-(getCFMLExtensions().length()+1)); 1250 FunctionLibFunction flf = new FunctionLibFunction(fl); 1251 flf.setArgType(FunctionLibFunction.ARG_DYNAMIC); 1252 flf.setCls("railo.runtime.functions.system.CFFunction"); 1253 flf.setName(name); 1254 flf.setReturn("object"); 1255 FunctionLibFunctionArg arg = new FunctionLibFunctionArg(flf); 1256 arg.setName("__filename"); 1257 arg.setRequired(true); 1258 arg.setType("string"); 1259 arg.setHidden(true); 1260 arg.setDefaultValue(filename); 1261 flf.setArg(arg); 1262 1263 arg = new FunctionLibFunctionArg(flf); 1264 arg.setName("__name"); 1265 arg.setRequired(true); 1266 arg.setHidden(true); 1267 arg.setType("string"); 1268 arg.setDefaultValue(name); 1269 flf.setArg(arg); 1270 1271 arg = new FunctionLibFunctionArg(flf); 1272 arg.setName("__isweb"); 1273 arg.setRequired(true); 1274 arg.setHidden(true); 1275 arg.setType("boolean"); 1276 arg.setDefaultValue(this instanceof ConfigWeb?"true":"false"); 1277 flf.setArg(arg); 1278 1279 1280 1281 fl.setFunction(flf); 1282 } 1283 1284 1285 1286 1287 1288 private static String toName(String filename) { 1289 int pos=filename.lastIndexOf('.'); 1290 if(pos==-1)return filename; 1291 return filename.substring(0,pos); 1292 } 1293 1294 1295 private void overwrite(TagLib existingTL, TagLib newTL) { 1296 Iterator it = newTL.getTags().entrySet().iterator(); 1297 while(it.hasNext()){ 1298 existingTL.setTag((TagLibTag) (((Map.Entry)it.next()).getValue())); 1299 } 1300 } 1301 1302 private String getKey(TagLib tl) { 1303 return tl.getNameSpaceAndSeparator().toLowerCase(); 1304 } 1305 1306 /** 1307 * set the optional directory of the function library deskriptors 1308 * @param fileFld directory of the function libray deskriptors 1309 * @throws FunctionLibException 1310 */ 1311 protected void setFldFile(Resource fileFld) throws FunctionLibException { 1312 if(fileFld==null) return; 1313 this.fldFile=fileFld; 1314 1315 Map set=new HashMap(); 1316 String key; 1317 // First fill existing to set 1318 for(int i=0;i<flds.length;i++) { 1319 key=getKey(flds[i]); 1320 set.put(key,flds[i]); 1321 } 1322 1323 // now overwrite with new data 1324 FunctionLib fl; 1325 if(fileFld.isDirectory()) { 1326 Resource[] files=fileFld.listResources(new ExtensionResourceFilter("fld")); 1327 for(int i=0;i<files.length;i++) { 1328 try { 1329 fl = FunctionLibFactory.loadFromFile(files[i]); 1330 key=getKey(fl); 1331 1332 if(!set.containsKey(key)) 1333 set.put(key,fl); 1334 else 1335 overwrite((FunctionLib) set.get(key),fl); 1336 1337 } 1338 catch(FunctionLibException fle) { 1339 SystemOut.printDate(out,"can't load tld "+files[i]); 1340 fle.printStackTrace(getErrWriter()); 1341 } 1342 } 1343 } 1344 else { 1345 fl = FunctionLibFactory.loadFromFile(fileFld); 1346 key=getKey(fl); 1347 1348 if(!set.containsKey(key)) 1349 set.put(key,fl); 1350 else 1351 overwrite((FunctionLib) set.get(key),fl); 1352 } 1353 1354 // now fill back to array 1355 flds=new FunctionLib[set.size()]; 1356 int index=0; 1357 Iterator it = set.entrySet().iterator(); 1358 while(it.hasNext()) { 1359 flds[index++]=(FunctionLib) ((Map.Entry)it.next()).getValue(); 1360 //print.ln(fld[index-1]); 1361 } 1362 1363 } 1364 1365 1366 1367 1368 private void overwrite(FunctionLib existingFL, FunctionLib newFL) { 1369 Iterator it = newFL.getFunctions().entrySet().iterator(); 1370 while(it.hasNext()){ 1371 existingFL.setFunction((FunctionLibFunction) (((Map.Entry)it.next()).getValue())); 1372 } 1373 } 1374 1375 private String getKey(FunctionLib functionLib) { 1376 return functionLib.getDisplayName().toLowerCase(); 1377 } 1378 1379 /** 1380 * sets if it is allowed to implizit query call, call a query member witot define name of the query. 1381 * @param _allowImplicidQueryCall is allowed 1382 */ 1383 protected void setAllowImplicidQueryCall(boolean _allowImplicidQueryCall) { 1384 this._allowImplicidQueryCall=_allowImplicidQueryCall; 1385 } 1386 1387 /** 1388 * sets if url and form scope will be merged 1389 * @param _mergeFormAndURL merge yes or no 1390 */ 1391 protected void setMergeFormAndURL(boolean _mergeFormAndURL) { 1392 this._mergeFormAndURL=_mergeFormAndURL; 1393 } 1394 1395 /** 1396 * @param strApplicationTimeout The applicationTimeout to set. 1397 * @throws PageException 1398 */ 1399 void setApplicationTimeout(String strApplicationTimeout) throws PageException { 1400 setApplicationTimeout(Caster.toTimespan(strApplicationTimeout)); 1401 } 1402 1403 /** 1404 * @param applicationTimeout The applicationTimeout to set. 1405 */ 1406 protected void setApplicationTimeout(TimeSpan applicationTimeout) { 1407 this.applicationTimeout = applicationTimeout; 1408 } 1409 1410 /** 1411 * @param strSessionTimeout The sessionTimeout to set. 1412 * @throws PageException 1413 */ 1414 protected void setSessionTimeout(String strSessionTimeout) throws PageException { 1415 setSessionTimeout(Caster.toTimespan(strSessionTimeout)); 1416 } 1417 1418 /** 1419 * @param sessionTimeout The sessionTimeout to set. 1420 */ 1421 protected void setSessionTimeout(TimeSpan sessionTimeout) { 1422 this.sessionTimeout = sessionTimeout; 1423 } 1424 1425 protected void setClientTimeout(String strClientTimeout) throws PageException { 1426 setClientTimeout(Caster.toTimespan(strClientTimeout)); 1427 } 1428 1429 /** 1430 * @param sessionTimeout The sessionTimeout to set. 1431 */ 1432 protected void setClientTimeout(TimeSpan clientTimeout) { 1433 this.clientTimeout = clientTimeout; 1434 } 1435 1436 /** 1437 * @param strRequestTimeout The requestTimeout to set. 1438 * @throws PageException 1439 */ 1440 protected void setRequestTimeout(String strRequestTimeout) throws PageException { 1441 setRequestTimeout(Caster.toTimespan(strRequestTimeout)); 1442 } 1443 1444 /** 1445 * @param requestTimeout The requestTimeout to set. 1446 */ 1447 protected void setRequestTimeout(TimeSpan requestTimeout) { 1448 this.requestTimeout = requestTimeout; 1449 } 1450 1451 /** 1452 * @param clientCookies The clientCookies to set. 1453 */ 1454 protected void setClientCookies(boolean clientCookies) { 1455 this.clientCookies = clientCookies; 1456 } 1457 1458 /** 1459 * @param clientManagement The clientManagement to set. 1460 */ 1461 protected void setClientManagement(boolean clientManagement) { 1462 this.clientManagement = clientManagement; 1463 } 1464 1465 /** 1466 * @param domainCookies The domainCookies to set. 1467 */ 1468 protected void setDomainCookies(boolean domainCookies) { 1469 this.domainCookies = domainCookies; 1470 } 1471 1472 /** 1473 * @param sessionManagement The sessionManagement to set. 1474 */ 1475 protected void setSessionManagement(boolean sessionManagement) { 1476 this.sessionManagement = sessionManagement; 1477 } 1478 1479 /** 1480 * @param spoolEnable The spoolEnable to set. 1481 */ 1482 protected void setMailSpoolEnable(boolean spoolEnable) { 1483 //print.ln("setMailSpoolEnable:"+spoolEnable); 1484 this.spoolEnable = spoolEnable; 1485 } 1486 1487 /** 1488 * @param mailTimeout The mailTimeout to set. 1489 */ 1490 protected void setMailTimeout(int mailTimeout) { 1491 this.mailTimeout = mailTimeout; 1492 } 1493 1494 /** 1495 * sets the mail logger 1496 * @param mailLogger 1497 */ 1498 protected void setMailLogger(LogAndSource mailLogger) { 1499 this.mailLogger = mailLogger; 1500 } 1501 1502 1503 protected void setORMLogger(LogAndSource ormLogger) { 1504 this.ormLogger = ormLogger; 1505 } 1506 public LogAndSource getORMLogger() { 1507 if(ormLogger==null)ormLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 1508 1509 return ormLogger; 1510 } 1511 1512 /** 1513 * sets the request timeout logger 1514 * @param requestTimeoutLogger 1515 */ 1516 protected void setRequestTimeoutLogger(LogAndSource requestTimeoutLogger) { 1517 this.requestTimeoutLogger=requestTimeoutLogger; 1518 } 1519 1520 /** 1521 * @param psq (preserve single quote) 1522 * sets if sql string inside a cfquery will be prederved for Single Quotes 1523 */ 1524 protected void setPSQL(boolean psq) { 1525 this.psq=psq; 1526 } 1527 1528 /** 1529 * set if railo make debug output or not 1530 * @param _debug debug or not 1531 */ 1532 protected void setDebug(int _debug) { 1533 this._debug=_debug; 1534 } 1535 1536 /** 1537 * sets the temp directory 1538 * @param strTempDirectory temp directory 1539 * @throws ExpressionException 1540 */ 1541 protected void setTempDirectory(String strTempDirectory, boolean flush) throws ExpressionException { 1542 setTempDirectory(resources.getResource(strTempDirectory),flush); 1543 } 1544 1545 /** 1546 * sets the temp directory 1547 * @param tempDirectory temp directory 1548 * @throws ExpressionException 1549 */ 1550 protected void setTempDirectory(Resource tempDirectory, boolean flush) throws ExpressionException { 1551 if(!isDirectory(tempDirectory) || !tempDirectory.isWriteable()) { 1552 SystemOut.printDate(getErrWriter(), "temp directory ["+tempDirectory+"] is not writable or can not be created, using directory ["+SystemUtil.getTempDirectory()+"] instead"); 1553 tempDirectory=SystemUtil.getTempDirectory(); 1554 if(!tempDirectory.isWriteable()){ 1555 SystemOut.printDate(getErrWriter(), "temp directory ["+tempDirectory+"] is not writable"); 1556 } 1557 } 1558 if(flush)ResourceUtil.removeChildrenEL(tempDirectory);// start with a empty temp directory 1559 this.tempDirectory=tempDirectory; 1560 } 1561 1562 /** 1563 * sets the Schedule Directory 1564 * @param scheduleDirectory sets the schedule Directory 1565 * @param logger 1566 * @throws PageException 1567 */ 1568 protected void setScheduler(CFMLEngine engine,Resource scheduleDirectory, LogAndSource logger) throws PageException { 1569 if(scheduleDirectory==null) { 1570 if(this.scheduler==null) this.scheduler=new SchedulerImpl(engine,"<?xml version=\"1.0\"?>\n<schedule></schedule>",this,logger); 1571 return; 1572 } 1573 1574 1575 if(!isDirectory(scheduleDirectory)) throw new ExpressionException("schedule task directory "+scheduleDirectory+" doesn't exist or is not a directory"); 1576 try { 1577 if(this.scheduler==null) 1578 this.scheduler=new SchedulerImpl(engine,this,scheduleDirectory,logger,SystemUtil.getCharset()); 1579 //else 1580 //this.scheduler.reinit(scheduleDirectory,logger); 1581 } 1582 catch (Exception e) { 1583 throw Caster.toPageException(e); 1584 } 1585 } 1586 1587 /** 1588 * @param spoolInterval The spoolInterval to set. 1589 */ 1590 protected void setMailSpoolInterval(int spoolInterval) { 1591 this.spoolInterval = spoolInterval; 1592 } 1593 1594 /** 1595 * sets the timezone 1596 * @param timeZone 1597 */ 1598 protected void setTimeZone(TimeZone timeZone) { 1599 this.timeZone=timeZone; 1600 } 1601 1602 /** 1603 * sets the time server 1604 * @param timeServer 1605 */ 1606 protected void setTimeServer(String timeServer) { 1607 this.timeServer=timeServer; 1608 } 1609 1610 /** 1611 * sets the locale 1612 * @param strLocale 1613 */ 1614 protected void setLocale(String strLocale) { 1615 if(strLocale==null) { 1616 this.locale=Locale.US; 1617 } 1618 else { 1619 try { 1620 this.locale=Caster.toLocale(strLocale); 1621 if(this.locale==null)this.locale=Locale.US; 1622 } catch (ExpressionException e) { 1623 this.locale=Locale.US; 1624 } 1625 } 1626 } 1627 1628 /** 1629 * sets the locale 1630 * @param locale 1631 */ 1632 protected void setLocale(Locale locale) { 1633 this.locale=locale; 1634 } 1635 1636 /** 1637 * @param mappings The mappings to set. 1638 */ 1639 protected void setMappings(Mapping[] mappings) { 1640 Arrays.sort(mappings,new Comparator(){ 1641 public int compare(Object left, Object right) { 1642 Mapping r = ((Mapping)right); 1643 Mapping l = ((Mapping)left); 1644 int rtn=r.getVirtualLowerCaseWithSlash().length()-l.getVirtualLowerCaseWithSlash().length(); 1645 if(rtn==0) return slashCount(r)-slashCount(l); 1646 return rtn; 1647 } 1648 1649 private int slashCount(Mapping l) { 1650 String str=l.getVirtualLowerCaseWithSlash(); 1651 int count=0,lastIndex=-1; 1652 while((lastIndex=str.indexOf('/', lastIndex))!=-1) { 1653 count++; 1654 lastIndex++; 1655 } 1656 return count; 1657 } 1658 }); 1659 this.mappings = mappings; 1660 } 1661 1662 /** 1663 * @param datasources The datasources to set 1664 */ 1665 protected void setDataSources(Map datasources) { 1666 this.datasources=datasources; 1667 } 1668 /** 1669 * @param customTagMapping The customTagMapping to set. 1670 */ 1671 protected void setCustomTagMappings(Mapping[] customTagMappings) { 1672 this.customTagMappings = customTagMappings; 1673 } 1674 1675 1676 /** 1677 * @see railo.runtime.config.Config#getCustomTagMappings() 1678 */ 1679 public Mapping[] getCustomTagMappings() { 1680 return customTagMappings; 1681 } 1682 1683 /** 1684 * @param mailServers The mailsServers to set. 1685 */ 1686 protected void setMailServers(Server[] mailServers) { 1687 this.mailServers = mailServers; 1688 } 1689 1690 /** 1691 * is file a directory or not, touch if not exists 1692 * @param directory 1693 * @return true if existing directory or has created new one 1694 */ 1695 protected boolean isDirectory(Resource directory) { 1696 if(directory.exists()) return directory.isDirectory(); 1697 try { 1698 directory.createDirectory(true); 1699 return true; 1700 } catch (IOException e) { 1701 e.printStackTrace(getErrWriter()); 1702 } 1703 return false; 1704 } 1705 1706 /** 1707 * @see railo.runtime.config.Config#getLoadTime() 1708 */ 1709 public long getLoadTime() { 1710 return loadTime; 1711 } 1712 /** 1713 * @param loadTime The loadTime to set. 1714 */ 1715 protected void setLoadTime(long loadTime) { 1716 this.loadTime = loadTime; 1717 } 1718 /** 1719 * @return Returns the configLogger. 1720 * / 1721 public Log getConfigLogger() { 1722 return configLogger; 1723 }*/ 1724 1725 /** 1726 * @see railo.runtime.config.Config#getCFXTagPool() 1727 */ 1728 public CFXTagPool getCFXTagPool() throws SecurityException { 1729 return cfxTagPool; 1730 } 1731 1732 /** 1733 * @param cfxTagPool The customTagPool to set. 1734 */ 1735 protected void setCFXTagPool(CFXTagPool cfxTagPool) { 1736 this.cfxTagPool = cfxTagPool; 1737 } 1738 /** 1739 * @param cfxTagPool The customTagPool to set. 1740 */ 1741 protected void setCFXTagPool(Map cfxTagPool) { 1742 this.cfxTagPool = new CFXTagPoolImpl(cfxTagPool); 1743 } 1744 1745 /** 1746 * @see railo.runtime.config.Config#getBaseComponentTemplate() 1747 */ 1748 public String getBaseComponentTemplate() { 1749 return baseComponentTemplate; 1750 } 1751 1752 /** 1753 * @return pagesource of the base component 1754 */ 1755 public PageSource getBaseComponentPageSource() { 1756 return getBaseComponentPageSource(ThreadLocalPageContext.get()); 1757 } 1758 public PageSource getBaseComponentPageSource(PageContext pc) { 1759 if(baseComponentPageSource==null) { 1760 baseComponentPageSource=PageSourceImpl.best(getPageSources(pc,null,getBaseComponentTemplate(),false,false,true)); 1761 } 1762 return baseComponentPageSource; 1763 } 1764 1765 /** 1766 * @param template The baseComponent template to set. 1767 */ 1768 protected void setBaseComponentTemplate(String template) { 1769 this.baseComponentPageSource=null; 1770 this.baseComponentTemplate = template; 1771 } 1772 1773 /** 1774 * sets the application logger 1775 * @param applicationLogger 1776 */ 1777 protected void setApplicationLogger(LogAndSource applicationLogger) { 1778 this.applicationLogger=applicationLogger; 1779 } 1780 1781 protected void setScopeLogger(LogAndSource scopeLogger) { 1782 this.scopeLogger=scopeLogger; 1783 } 1784 1785 1786 protected void setMappingLogger(LogAndSource mappingLogger) { 1787 this.mappingLogger=mappingLogger; 1788 } 1789 1790 public LogAndSource getMappingLogger() { 1791 if(mappingLogger==null) 1792 mappingLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 1793 return mappingLogger; 1794 } 1795 1796 /** 1797 * @param clientType 1798 */ 1799 protected void setClientType(short clientType) { 1800 this.clientType=clientType; 1801 } 1802 1803 /** 1804 * @param strClientType 1805 */ 1806 protected void setClientType(String strClientType) { 1807 strClientType=strClientType.trim().toLowerCase(); 1808 if(strClientType.equals("file"))clientType=Config.CLIENT_SCOPE_TYPE_FILE; 1809 else if(strClientType.equals("db"))clientType=Config.CLIENT_SCOPE_TYPE_DB; 1810 else if(strClientType.equals("database"))clientType=Config.CLIENT_SCOPE_TYPE_DB; 1811 else clientType=Config.CLIENT_SCOPE_TYPE_COOKIE; 1812 } 1813 1814 /** 1815 * @see railo.runtime.config.Config#getClientType() 1816 */ 1817 public short getClientType() { 1818 return this.clientType; 1819 } 1820 1821 /** 1822 * @param searchEngine The searchEngine to set. 1823 */ 1824 protected void setSearchEngine(SearchEngine searchEngine) { 1825 this.searchEngine = searchEngine; 1826 } 1827 1828 /** 1829 * @see railo.runtime.config.Config#getComponentDataMemberDefaultAccess() 1830 */ 1831 public int getComponentDataMemberDefaultAccess() { 1832 return componentDataMemberDefaultAccess; 1833 } 1834 /** 1835 * @param componentDataMemberDefaultAccess The componentDataMemberDefaultAccess to set. 1836 */ 1837 protected void setComponentDataMemberDefaultAccess( 1838 int componentDataMemberDefaultAccess) { 1839 this.componentDataMemberDefaultAccess = componentDataMemberDefaultAccess; 1840 } 1841 1842 1843 /** 1844 * @see railo.runtime.config.Config#getTimeServer() 1845 */ 1846 public String getTimeServer() { 1847 return timeServer; 1848 } 1849 1850 /** 1851 * @see railo.runtime.config.Config#getComponentDumpTemplate() 1852 */ 1853 public String getComponentDumpTemplate() { 1854 return componentDumpTemplate; 1855 } 1856 1857 /** 1858 * @param template The componentDump template to set. 1859 */ 1860 protected void setComponentDumpTemplate(String template) { 1861 this.componentDumpTemplate = template; 1862 } 1863 1864 /** 1865 * @return Returns the configServer Implementation. 1866 */ 1867 protected abstract ConfigServerImpl getConfigServerImpl(); 1868 1869 /** 1870 * @see railo.runtime.config.Config#getId() 1871 */ 1872 1873 1874 1875 public String getSecurityToken() { 1876 if(securityToken==null){ 1877 try { 1878 securityToken = Md5.getDigestAsString(getConfigDir().getAbsolutePath()); 1879 } 1880 catch (IOException e) { 1881 return null; 1882 } 1883 } 1884 return securityToken; 1885 } 1886 1887 public String getId() { 1888 if(id==null){ 1889 id = getId(getSecurityKey(),getSecurityToken(),securityKey); 1890 } 1891 return id; 1892 } 1893 1894 public static String getId(String key, String token,String defaultValue) { 1895 1896 try { 1897 return Md5.getDigestAsString(key+token); 1898 } 1899 catch (IOException e) { 1900 return defaultValue; 1901 } 1902 } 1903 1904 1905 public String getSecurityKey() { 1906 return securityKey;//getServletContext().getRealPath("/"); 1907 } 1908 1909 /** 1910 * @see railo.runtime.config.Config#getDebugTemplate() 1911 */ 1912 public String getDebugTemplate() { 1913 return debugTemplate; 1914 } 1915 /** 1916 * @param debugTemplate The debugTemplate to set. 1917 */ 1918 protected void setDebugTemplate(String debugTemplate) { 1919 this.debugTemplate = debugTemplate; 1920 } 1921 public boolean getDebugShowQueryUsage() { 1922 return debugShowUsage; 1923 } 1924 /** 1925 * @param debugTemplate The debugTemplate to set. 1926 */ 1927 protected void setDebugShowQueryUsage(boolean debugShowUsage) { 1928 this.debugShowUsage = debugShowUsage; 1929 } 1930 1931 /** 1932 * @return the errorTemplate 1933 */ 1934 public String getErrorTemplate() { 1935 return getErrorTemplate(500); 1936 } 1937 1938 public String getErrorTemplate(int statusCode) { 1939 return (String) errorTemplates.get(Caster.toString(statusCode)); 1940 } 1941 1942 /** 1943 * @param errorTemplate the errorTemplate to set 1944 */ 1945 protected void setErrorTemplate(int statusCode,String errorTemplate) { 1946 this.errorTemplates.put(Caster.toString(statusCode), errorTemplate); 1947 } 1948 1949 /** 1950 * @see railo.runtime.config.Config#getSessionType() 1951 */ 1952 public short getSessionType() { 1953 return sessionType; 1954 } 1955 /** 1956 * @param sessionType The sessionType to set. 1957 */ 1958 protected void setSessionType(short sessionType) { 1959 this.sessionType = sessionType; 1960 } 1961 /** 1962 * @param type The sessionType to set. 1963 */ 1964 protected void setSessionType(String type) { 1965 type=type.toLowerCase().trim(); 1966 if(type.startsWith("cfm")) setSessionType(SESSION_TYPE_CFML); 1967 else if(type.startsWith("j")) setSessionType(SESSION_TYPE_J2EE); 1968 else setSessionType(SESSION_TYPE_CFML); 1969 } 1970 1971 /** 1972 * @see railo.runtime.config.Config#getUpdateType() 1973 */ 1974 public abstract String getUpdateType() ; 1975 1976 /** 1977 * @see railo.runtime.config.Config#getUpdateLocation() 1978 */ 1979 public abstract URL getUpdateLocation(); 1980 1981 /** 1982 * @see railo.runtime.config.Config#getDeployDirectory() 1983 */ 1984 public Resource getDeployDirectory() { 1985 return deployDirectory; 1986 } 1987 1988 /** 1989 * set the deploy directory, directory where railo deploy transalted cfml classes (java and class files) 1990 * @param strDeployDirectory deploy directory 1991 * @throws ExpressionException 1992 */ 1993 protected void setDeployDirectory(String strDeployDirectory) throws ExpressionException { 1994 setDeployDirectory(resources.getResource(strDeployDirectory)); 1995 } 1996 1997 /** 1998 * set the deploy directory, directory where railo deploy transalted cfml classes (java and class files) 1999 * @param deployDirectory deploy directory 2000 * @throws ExpressionException 2001 * @throws ExpressionException 2002 */ 2003 protected void setDeployDirectory(Resource deployDirectory) throws ExpressionException { 2004 if(!isDirectory(deployDirectory)) { 2005 throw new ExpressionException("deploy directory "+deployDirectory+" doesn't exist or is not a directory"); 2006 } 2007 this.deployDirectory=deployDirectory; 2008 } 2009 2010 2011 /** 2012 * @see railo.runtime.config.Config#getRootDirectory() 2013 */ 2014 public abstract Resource getRootDirectory(); 2015 2016 /** 2017 * sets the compileType value. 2018 * @param compileType The compileType to set. 2019 */ 2020 protected void setCompileType(short compileType) { 2021 this.compileType = compileType; 2022 } 2023 2024 /** FUTHER 2025 * Returns the value of suppresswhitespace. 2026 * @return value suppresswhitespace 2027 */ 2028 public boolean isSuppressWhitespace() { 2029 return suppresswhitespace; 2030 } 2031 2032 /** FUTHER 2033 * sets the suppresswhitespace value. 2034 * @param suppresswhitespace The suppresswhitespace to set. 2035 */ 2036 protected void setSuppressWhitespace(boolean suppresswhitespace) { 2037 this.suppresswhitespace = suppresswhitespace; 2038 } 2039 2040 2041 public boolean isSuppressContent() { 2042 return suppressContent; 2043 } 2044 2045 protected void setSuppressContent(boolean suppressContent) { 2046 this.suppressContent = suppressContent; 2047 } 2048 2049 2050 /** 2051 * @see railo.runtime.config.Config#getDefaultEncoding() 2052 */ 2053 public String getDefaultEncoding() { 2054 return webCharset; 2055 } 2056 2057 /** 2058 * 2059 * @see railo.runtime.config.Config#getTemplateCharset() 2060 */ 2061 public String getTemplateCharset() { 2062 return templateCharset; 2063 } 2064 2065 /** 2066 * sets the charset to read the files 2067 * @param templateCharset 2068 */ 2069 protected void setTemplateCharset(String templateCharset) { 2070 this.templateCharset = templateCharset; 2071 } 2072 2073 /** 2074 * 2075 * @see railo.runtime.config.Config#getWebCharset() 2076 */ 2077 public String getWebCharset() { 2078 return webCharset; 2079 } 2080 2081 /** 2082 * sets the charset to read and write resources 2083 * @param resourceCharset 2084 */ 2085 protected void setResourceCharset(String resourceCharset) { 2086 this.resourceCharset = resourceCharset; 2087 } 2088 2089 /** 2090 * 2091 * @see railo.runtime.config.Config#getResourceCharset() 2092 */ 2093 public String getResourceCharset() { 2094 return resourceCharset; 2095 } 2096 2097 /** 2098 * sets the charset for the response stream 2099 * @param outputEncoding 2100 */ 2101 protected void setWebCharset(String webCharset) { 2102 this.webCharset = webCharset; 2103 } 2104 2105 public SecurityManager getSecurityManager() { 2106 return null; 2107 } 2108 2109 /** 2110 * @return the fldFile 2111 */ 2112 public Resource getFldFile() { 2113 return fldFile; 2114 } 2115 2116 /** 2117 * @return the tldFile 2118 */ 2119 public Resource getTldFile() { 2120 return tldFile; 2121 } 2122 2123 /** 2124 * @see railo.runtime.config.Config#getDataSources() 2125 */ 2126 public DataSource[] getDataSources() { 2127 Map map = getDataSourcesAsMap(); 2128 Iterator it = map.keySet().iterator(); 2129 DataSource[] ds = new DataSource[map.size()]; 2130 int count=0; 2131 2132 while(it.hasNext()) { 2133 ds[count++]=(DataSource) map.get(it.next()); 2134 } 2135 return ds; 2136 } 2137 2138 public Map getDataSourcesAsMap() { 2139 Map map=new HashTable(); 2140 Iterator it = datasources.keySet().iterator(); 2141 2142 while(it.hasNext()) { 2143 Object key=it.next(); 2144 if(!key.equals("_queryofquerydb")) 2145 map.put(key,datasources.get(key)); 2146 } 2147 return map; 2148 } 2149 2150 /** 2151 * @return the mailDefaultCharset 2152 */ 2153 public String getMailDefaultEncoding() { 2154 return mailDefaultEncoding; 2155 } 2156 2157 /** 2158 * @param mailDefaultCharset the mailDefaultCharset to set 2159 */ 2160 protected void setMailDefaultEncoding(String mailDefaultEncoding) { 2161 this.mailDefaultEncoding = mailDefaultEncoding; 2162 } 2163 2164 protected void setDefaultResourceProvider(String strDefaultProviderClass, Map arguments) throws ClassException { 2165 Object o=ClassUtil.loadInstance(strDefaultProviderClass); 2166 if(o instanceof ResourceProvider) { 2167 ResourceProvider rp=(ResourceProvider) o; 2168 rp.init(null,arguments); 2169 setDefaultResourceProvider(rp); 2170 } 2171 else 2172 throw new ClassException("object ["+Caster.toClassName(o)+"] must implement the interface "+ResourceProvider.class.getName()); 2173 } 2174 2175 /** 2176 * @param defaultResourceProvider the defaultResourceProvider to set 2177 */ 2178 protected void setDefaultResourceProvider(ResourceProvider defaultResourceProvider) { 2179 resources.registerDefaultResourceProvider(defaultResourceProvider); 2180 } 2181 2182 /** 2183 * @return the defaultResourceProvider 2184 */ 2185 public ResourceProvider getDefaultResourceProvider() { 2186 return resources.getDefaultResourceProvider(); 2187 } 2188 2189 protected void addResourceProvider(String strProviderScheme, String strProviderClass, Map arguments) throws ClassException { 2190 // old buld in S3 2191 2192 2193 Object o=null; 2194 2195 o=ClassUtil.loadInstance(strProviderClass); 2196 2197 if(o instanceof ResourceProvider) { 2198 ResourceProvider rp=(ResourceProvider) o; 2199 rp.init(strProviderScheme,arguments); 2200 addResourceProvider(rp); 2201 } 2202 else 2203 throw new ClassException("object ["+Caster.toClassName(o)+"] must implement the interface "+ResourceProvider.class.getName()); 2204 } 2205 2206 protected void addResourceProvider(ResourceProvider provider) { 2207 resources.registerResourceProvider(provider); 2208 } 2209 2210 2211 public void clearResourceProviders() { 2212 resources.reset(); 2213 } 2214 2215 2216 /** 2217 * @return return the resource providers 2218 */ 2219 public ResourceProvider[] getResourceProviders() { 2220 return resources.getResourceProviders(); 2221 } 2222 2223 protected void setResourceProviders(ResourceProvider[] resourceProviders) { 2224 for(int i=0;i<resourceProviders.length;i++) { 2225 resources.registerResourceProvider(resourceProviders[i]); 2226 } 2227 } 2228 2229 2230 /** 2231 * 2232 * @see railo.runtime.config.Config#getResource(java.lang.String) 2233 */ 2234 public Resource getResource(String path) { 2235 return resources.getResource(path); 2236 } 2237 2238 /** 2239 * 2240 * @see railo.runtime.config.Config#getApplicationListener() 2241 */ 2242 public ApplicationListener getApplicationListener() { 2243 return applicationListener;//new ModernAppListener();//new ClassicAppListener(); 2244 } 2245 2246 /** 2247 * @param applicationListener the applicationListener to set 2248 */ 2249 protected void setApplicationListener(ApplicationListener applicationListener) { 2250 this.applicationListener = applicationListener; 2251 } 2252 2253 /** 2254 * @return the exceptionLogger 2255 */ 2256 public LogAndSource getExceptionLogger() { 2257 if(exceptionLogger==null)exceptionLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 2258 return exceptionLogger; 2259 } 2260 2261 /** 2262 * @return the exceptionLogger 2263 */ 2264 public LogAndSource getTraceLogger() { 2265 if(traceLogger==null)traceLogger=new LogAndSourceImpl(LogConsole.getInstance(this,Log.LEVEL_ERROR),""); 2266 return traceLogger; 2267 } 2268 2269 /** 2270 * @param exceptionLogger the exceptionLogger to set 2271 */ 2272 protected void setExceptionLogger(LogAndSource exceptionLogger) { 2273 this.exceptionLogger = exceptionLogger; 2274 } 2275 2276 /** 2277 * @param traceLogger the traceLogger to set 2278 */ 2279 protected void setTraceLogger(LogAndSource traceLogger) { 2280 this.traceLogger = traceLogger; 2281 } 2282 2283 /** 2284 * @return the scriptProtect 2285 */ 2286 public int getScriptProtect() { 2287 return scriptProtect; 2288 } 2289 2290 /** 2291 * @param scriptProtect the scriptProtect to set 2292 */ 2293 protected void setScriptProtect(int scriptProtect) { 2294 this.scriptProtect = scriptProtect; 2295 } 2296 2297 /** 2298 * @return the proxyPassword 2299 */ 2300 public String getProxyPassword() { 2301 return proxyPassword; 2302 } 2303 2304 /** 2305 * @param proxyPassword the proxyPassword to set 2306 */ 2307 protected void setProxyPassword(String proxyPassword) { 2308 this.proxyPassword = proxyPassword; 2309 } 2310 2311 /** 2312 * @return the proxyPort 2313 */ 2314 public int getProxyPort() { 2315 return proxyPort; 2316 } 2317 2318 /** 2319 * @param proxyPort the proxyPort to set 2320 */ 2321 protected void setProxyPort(int proxyPort) { 2322 this.proxyPort = proxyPort; 2323 } 2324 2325 /** 2326 * @return the proxyServer 2327 */ 2328 public String getProxyServer() { 2329 return proxyServer; 2330 } 2331 2332 /** 2333 * @param proxyServer the proxyServer to set 2334 */ 2335 protected void setProxyServer(String proxyServer) { 2336 this.proxyServer = proxyServer; 2337 } 2338 2339 /** 2340 * @return the proxyUsername 2341 */ 2342 public String getProxyUsername() { 2343 return proxyUsername; 2344 } 2345 2346 /** 2347 * @param proxyUsername the proxyUsername to set 2348 */ 2349 protected void setProxyUsername(String proxyUsername) { 2350 this.proxyUsername = proxyUsername; 2351 } 2352 2353 /** 2354 * @see railo.runtime.config.Config#isProxyEnableFor(java.lang.String) 2355 */ 2356 public boolean isProxyEnableFor(String host) { 2357 return false;// TODO proxyEnable; 2358 } 2359 2360 /** 2361 * @return the triggerComponentDataMember 2362 */ 2363 public boolean getTriggerComponentDataMember() { 2364 return triggerComponentDataMember; 2365 } 2366 2367 /** 2368 * @param triggerComponentDataMember the triggerComponentDataMember to set 2369 */ 2370 protected void setTriggerComponentDataMember(boolean triggerComponentDataMember) { 2371 this.triggerComponentDataMember = triggerComponentDataMember; 2372 } 2373 2374 /** 2375 * 2376 * @see railo.runtime.config.Config#getClientScopeDir() 2377 */ 2378 public Resource getClientScopeDir() { 2379 if(clientScopeDir==null) clientScopeDir=getConfigDir().getRealResource("client-scope"); 2380 return clientScopeDir; 2381 } 2382 2383 public Resource getSessionScopeDir() { 2384 if(sessionScopeDir==null) sessionScopeDir=getConfigDir().getRealResource("session-scope"); 2385 return sessionScopeDir; 2386 } 2387 2388 2389 2390 /*public int getClientScopeMaxAge() { 2391 return clientScopeMaxAge; 2392 } 2393 2394 public void setClientScopeMaxAge(int age) { 2395 this. clientScopeMaxAge=age; 2396 }*/ 2397 2398 2399 2400 /** 2401 * 2402 * @see railo.runtime.config.Config#getClientScopeDirSize() 2403 */ 2404 public long getClientScopeDirSize() { 2405 return clientScopeDirSize; 2406 } 2407 public long getSessionScopeDirSize() { 2408 return sessionScopeDirSize; 2409 } 2410 2411 /** 2412 * @param clientScopeDir the clientScopeDir to set 2413 */ 2414 protected void setClientScopeDir(Resource clientScopeDir) { 2415 this.clientScopeDir = clientScopeDir; 2416 } 2417 2418 protected void setSessionScopeDir(Resource sessionScopeDir) { 2419 this.sessionScopeDir = sessionScopeDir; 2420 } 2421 2422 /** 2423 * @param clientScopeDirSize the clientScopeDirSize to set 2424 */ 2425 protected void setClientScopeDirSize(long clientScopeDirSize) { 2426 this.clientScopeDirSize = clientScopeDirSize; 2427 } 2428 /** 2429 * 2430 * @see railo.runtime.config.Config#getRPCClassLoader() 2431 */ 2432 public ClassLoader getRPCClassLoader(boolean reload) throws IOException { 2433 2434 if(rpcClassLoader!=null && !reload) return rpcClassLoader; 2435 2436 Resource dir = getDeployDirectory().getRealResource("RPC"); 2437 if(!dir.exists())dir.createDirectory(true); 2438 //rpcClassLoader = new PhysicalClassLoader(dir,getFactory().getServlet().getClass().getClassLoader()); 2439 rpcClassLoader = new PhysicalClassLoader(dir,getClass().getClassLoader()); 2440 return rpcClassLoader; 2441 } 2442 2443 public void resetRPCClassLoader() { 2444 rpcClassLoader=null; 2445 } 2446 2447 protected void setCacheDir(Resource cacheDir) { 2448 this.cacheDir=cacheDir; 2449 } 2450 2451 public Resource getCacheDir() { 2452 return this.cacheDir; 2453 } 2454 2455 public long getCacheDirSize() { 2456 return cacheDirSize; 2457 } 2458 2459 protected void setCacheDirSize(long cacheDirSize) { 2460 this.cacheDirSize=cacheDirSize; 2461 } 2462 2463 2464 2465 protected void setDumpWritersEntries(DumpWriterEntry[] dmpWriterEntries) { 2466 this.dmpWriterEntries=dmpWriterEntries; 2467 } 2468 2469 public DumpWriterEntry[] getDumpWritersEntries() { 2470 return dmpWriterEntries; 2471 } 2472 2473 /** 2474 * 2475 * @see railo.runtime.config.Config#getDefaultDumpWriter() 2476 */ 2477 public DumpWriter getDefaultDumpWriter() { 2478 //throw new PageRuntimeException(new ApplicationException("this method is no longer supported")); 2479 return getDefaultDumpWriter(HTMLDumpWriter.DEFAULT_RICH); 2480 2481 } 2482 2483 public DumpWriter getDefaultDumpWriter(int defaultType) { 2484 DumpWriterEntry[] entries = getDumpWritersEntries(); 2485 if(entries!=null)for(int i=0;i<entries.length;i++){ 2486 if(entries[i].getDefaultType()==defaultType) { 2487 return entries[i].getWriter(); 2488 } 2489 } 2490 return new HTMLDumpWriter(); 2491 } 2492 2493 /** 2494 * 2495 * @see railo.runtime.config.Config#getDumpWriter(java.lang.String) 2496 */ 2497 public DumpWriter getDumpWriter(String name) throws DeprecatedException { 2498 throw new DeprecatedException("this method is no longer supported"); 2499 } 2500 2501 public DumpWriter getDumpWriter(String name,int defaultType) throws ExpressionException { 2502 if(StringUtil.isEmpty(name)) return getDefaultDumpWriter(defaultType); 2503 2504 DumpWriterEntry[] entries = getDumpWritersEntries(); 2505 for(int i=0;i<entries.length;i++){ 2506 if(entries[i].getName().equals(name)) { 2507 return entries[i].getWriter(); 2508 } 2509 } 2510 2511 // error 2512 StringBuffer sb=new StringBuffer(); 2513 for(int i=0;i<entries.length;i++){ 2514 if(i>0)sb.append(", "); 2515 sb.append(entries[i].getName()); 2516 } 2517 throw new ExpressionException("invalid format definition ["+name+"], valid definitions are ["+sb+"]"); 2518 } 2519 2520 /** 2521 * @see railo.runtime.config.Config#useComponentShadow() 2522 */ 2523 public boolean useComponentShadow() { 2524 return useComponentShadow; 2525 } 2526 2527 public boolean useComponentPathCache() { 2528 return useComponentPathCache; 2529 } 2530 2531 public boolean useCTPathCache() { 2532 return useCTPathCache; 2533 } 2534 2535 public void flushComponentPathCache() { 2536 if(componentPathCache!=null)componentPathCache.clear(); 2537 } 2538 2539 public void flushCTPathCache() { 2540 if(ctPatchCache!=null)ctPatchCache.clear(); 2541 } 2542 2543 2544 protected void setUseCTPathCache(boolean useCTPathCache) { 2545 this.useCTPathCache = useCTPathCache; 2546 } 2547 protected void setUseComponentPathCache(boolean useComponentPathCache) { 2548 this.useComponentPathCache = useComponentPathCache; 2549 } 2550 2551 /** 2552 * @param useComponentShadow the useComponentShadow to set 2553 */ 2554 protected void setUseComponentShadow(boolean useComponentShadow) { 2555 this.useComponentShadow = useComponentShadow; 2556 } 2557 2558 public DataSource getDataSource(String datasource) throws DatabaseException { 2559 DataSource ds=(datasource==null)?null:(DataSource) datasources.get(datasource.toLowerCase()); 2560 if(ds!=null) return ds; 2561 DatabaseException de = new DatabaseException("datasource ["+datasource+"] doesn't exist",null,null,null); 2562 de.setAdditional("Datasource",datasource); 2563 throw de; 2564 } 2565 2566 // FUTURE add to interface 2567 public DataSource getDataSource(String datasource, DataSource defaultValue) { 2568 DataSource ds=(datasource==null)?null:(DataSource) datasources.get(datasource.toLowerCase()); 2569 if(ds!=null) return ds; 2570 return defaultValue; 2571 } 2572 2573 /** 2574 * 2575 * @see railo.runtime.config.Config#getErrWriter() 2576 */ 2577 public PrintWriter getErrWriter() { 2578 return err; 2579 } 2580 2581 /** 2582 * @param err the err to set 2583 */ 2584 protected void setErr(PrintWriter err) { 2585 this.err = err; 2586 } 2587 2588 /** 2589 * 2590 * @see railo.runtime.config.Config#getOutWriter() 2591 */ 2592 public PrintWriter getOutWriter() { 2593 return out; 2594 } 2595 2596 /** 2597 * @param out the out to set 2598 */ 2599 protected void setOut(PrintWriter out) { 2600 this.out = out; 2601 } 2602 2603 public DatasourceConnectionPool getDatasourceConnectionPool() { 2604 return pool; 2605 } 2606 2607 2608 2609 public boolean doLocalCustomTag() { 2610 return doLocalCustomTag; 2611 } 2612 2613 /** 2614 * @see railo.runtime.config.Config#getCustomTagExtensions() 2615 */ 2616 public String[] getCustomTagExtensions() { 2617 return customTagExtensions; 2618 } 2619 2620 protected void setCustomTagExtensions(String[] customTagExtensions) { 2621 this.customTagExtensions = customTagExtensions; 2622 } 2623 2624 protected void setDoLocalCustomTag(boolean doLocalCustomTag) { 2625 this.doLocalCustomTag= doLocalCustomTag; 2626 } 2627 2628 2629 public boolean doComponentDeepSearch() { 2630 return doComponentTagDeepSearch; 2631 } 2632 2633 protected void setDoComponentDeepSearch(boolean doComponentTagDeepSearch) { 2634 this.doComponentTagDeepSearch = doComponentTagDeepSearch; 2635 } 2636 2637 /** 2638 * 2639 * @see railo.runtime.config.Config#doCustomTagDeepSearch() 2640 */ 2641 public boolean doCustomTagDeepSearch() { 2642 return doCustomTagDeepSearch; 2643 } 2644 2645 2646 /** 2647 * @param doCustomTagDeepSearch the doCustomTagDeepSearch to set 2648 */ 2649 protected void setDoCustomTagDeepSearch(boolean doCustomTagDeepSearch) { 2650 this.doCustomTagDeepSearch = doCustomTagDeepSearch; 2651 } 2652 2653 protected void setVersion(double version) { 2654 this.version=version; 2655 } 2656 2657 /** 2658 * @return the version 2659 */ 2660 public double getVersion() { 2661 return version; 2662 } 2663 2664 2665 2666 public boolean closeConnection() { 2667 return closeConnection; 2668 } 2669 2670 protected void setCloseConnection(boolean closeConnection) { 2671 this.closeConnection=closeConnection; 2672 } 2673 2674 public boolean contentLength() { 2675 return contentLength; 2676 } 2677 2678 2679 public boolean allowCompression() { 2680 return allowCompression; 2681 } 2682 protected void setAllowCompression(boolean allowCompression) { 2683 this.allowCompression= allowCompression; 2684 } 2685 2686 2687 protected void setContentLength(boolean contentLength) { 2688 this.contentLength=contentLength; 2689 } 2690 2691 /** 2692 * @return the constants 2693 */ 2694 public Struct getConstants() { 2695 return constants; 2696 } 2697 2698 /** 2699 * @param constants the constants to set 2700 */ 2701 protected void setConstants(Struct constants) { 2702 this.constants = constants; 2703 } 2704 2705 /** 2706 * @return the showVersion 2707 */ 2708 public boolean isShowVersion() { 2709 return showVersion; 2710 } 2711 2712 /** 2713 * @param showVersion the showVersion to set 2714 */ 2715 protected void setShowVersion(boolean showVersion) { 2716 this.showVersion = showVersion; 2717 } 2718 2719 protected void setRemoteClients(RemoteClient[] remoteClients) { 2720 this.remoteClients=remoteClients; 2721 } 2722 2723 public RemoteClient[] getRemoteClients() { 2724 if(remoteClients==null) return new RemoteClient[0]; 2725 return remoteClients; 2726 } 2727 2728 protected void setSecurityKey(String securityKey) { 2729 this.securityKey=securityKey; 2730 this.id=null; 2731 } 2732 2733 public SpoolerEngine getSpoolerEngine() { 2734 return remoteClientSpoolerEngine; 2735 } 2736 2737 protected void setRemoteClientLog(LogAndSource remoteClientLog) { 2738 this.remoteClientLog=remoteClientLog; 2739 } 2740 2741 protected void setRemoteClientDirectory(Resource remoteClientDirectory) { 2742 this.remoteClientDirectory=remoteClientDirectory; 2743 } 2744 2745 /** 2746 * @return the remoteClientDirectory 2747 */ 2748 public Resource getRemoteClientDirectory() { 2749 return remoteClientDirectory; 2750 } 2751 2752 /** 2753 * @return the remoteClientLog 2754 */ 2755 public LogAndSource getRemoteClientLog() { 2756 return remoteClientLog; 2757 } 2758 2759 protected void setSpoolerEngine(SpoolerEngine spoolerEngine) { 2760 this.remoteClientSpoolerEngine=spoolerEngine; 2761 } 2762 2763 /** 2764 * @return the factory 2765 */ 2766 public CFMLFactory getFactory() { 2767 return factory; 2768 } 2769 2770 2771 2772 /* * 2773 * @return the structCase 2774 * / 2775 public int getStructCase() { 2776 return structCase; 2777 }*/ 2778 2779 /* * 2780 * @param structCase the structCase to set 2781 * / 2782 protected void setStructCase(int structCase) { 2783 this.structCase = structCase; 2784 }*/ 2785 2786 2787 /** 2788 * @return if error status code will be returned or not 2789 */ 2790 public boolean getErrorStatusCode() { 2791 return errorStatusCode; 2792 } 2793 2794 /** 2795 * @param errorStatusCode the errorStatusCode to set 2796 */ 2797 protected void setErrorStatusCode(boolean errorStatusCode) { 2798 this.errorStatusCode = errorStatusCode; 2799 } 2800 2801 /** 2802 * @see railo.runtime.config.Config#getLocalMode() 2803 */ 2804 public int getLocalMode() { 2805 return localMode; 2806 } 2807 2808 /** 2809 * @param localMode the localMode to set 2810 */ 2811 protected void setLocalMode(int localMode) { 2812 this.localMode = localMode; 2813 } 2814 2815 /** 2816 * @param localMode the localMode to set 2817 */ 2818 protected void setLocalMode(String strLocalMode) { 2819 strLocalMode=strLocalMode.trim().toLowerCase(); 2820 if("always".equals(strLocalMode)) 2821 this.localMode=Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS; 2822 else if("update".equals(strLocalMode)) 2823 this.localMode=Undefined.MODE_LOCAL_OR_ARGUMENTS_ONLY_WHEN_EXISTS; 2824 else 2825 this.localMode=Undefined.MODE_LOCAL_OR_ARGUMENTS_ONLY_WHEN_EXISTS; 2826 } 2827 2828 public Resource getVideoDirectory() { 2829 // TODO take from tag <video> 2830 Resource dir = getConfigDir().getRealResource("video"); 2831 if(!dir.exists())dir.mkdirs(); 2832 return dir; 2833 } 2834 2835 2836 public Resource getExtensionDirectory() { 2837 // TODO take from tag <extensions> 2838 Resource dir = getConfigDir().getRealResource("extensions"); 2839 if(!dir.exists())dir.mkdirs(); 2840 return dir; 2841 } 2842 2843 protected void setExtensionProviders(ExtensionProvider[] extensionProviders) { 2844 this.extensionProviders=extensionProviders; 2845 } 2846 2847 public ExtensionProvider[] getExtensionProviders() { 2848 return extensionProviders; 2849 } 2850 2851 public Extension[] getExtensions() { 2852 return extensions; 2853 } 2854 2855 protected void setExtensions(Extension[] extensions) { 2856 2857 this.extensions=extensions; 2858 } 2859 2860 protected void setExtensionEnabled(boolean extensionEnabled) { 2861 this.extensionEnabled=extensionEnabled; 2862 } 2863 public boolean isExtensionEnabled() { 2864 return extensionEnabled; 2865 } 2866 2867 public boolean allowRealPath() { 2868 return allowRealPath; 2869 } 2870 2871 protected void setAllowRealPath(boolean allowRealPath) { 2872 this.allowRealPath=allowRealPath; 2873 } 2874 2875 /** 2876 * @return the classClusterScope 2877 */ 2878 public Class getClusterClass() { 2879 return clusterClass; 2880 } 2881 2882 /** 2883 * @param classClusterScope the classClusterScope to set 2884 */ 2885 protected void setClusterClass(Class clusterClass) { 2886 this.clusterClass = clusterClass; 2887 } 2888 2889 /** 2890 * @see railo.runtime.config.Config#getRemoteClientUsage() 2891 */ 2892 public Struct getRemoteClientUsage() { 2893 if(remoteClientUsage==null)remoteClientUsage=new StructImpl(); 2894 return remoteClientUsage; 2895 } 2896 2897 protected void setRemoteClientUsage(Struct remoteClientUsage) { 2898 this.remoteClientUsage=remoteClientUsage; 2899 } 2900 2901 /** 2902 * @see railo.runtime.config.Config#getAdminSyncClass() 2903 */ 2904 public Class getAdminSyncClass() { 2905 return adminSyncClass; 2906 } 2907 2908 protected void setAdminSyncClass(Class adminSyncClass) { 2909 this.adminSyncClass=adminSyncClass; 2910 this.adminSync=null; 2911 } 2912 2913 public AdminSync getAdminSync() throws ClassException { 2914 if(adminSync==null){ 2915 adminSync=(AdminSync) ClassUtil.loadInstance(getAdminSyncClass()); 2916 2917 } 2918 return this.adminSync; 2919 } 2920 2921 /** 2922 * @see railo.runtime.config.Config#getVideoExecuterClass() 2923 */ 2924 public Class getVideoExecuterClass() { 2925 return videoExecuterClass; 2926 } 2927 2928 protected void setVideoExecuterClass(Class videoExecuterClass) { 2929 this.videoExecuterClass=videoExecuterClass; 2930 } 2931 2932 protected void setUseTimeServer(boolean useTimeServer) { 2933 this.useTimeServer=useTimeServer; 2934 } 2935 2936 public boolean getUseTimeServer() { 2937 return useTimeServer; 2938 } 2939 2940 2941 /** 2942 * @return the tagMappings 2943 */ 2944 public Mapping getTagMapping() { 2945 return tagMapping; 2946 } 2947 2948 public Mapping getFunctionMapping() { 2949 return functionMapping; 2950 } 2951 2952 /** 2953 * @return the tagDirectory 2954 */ 2955 public Resource getTagDirectory() { 2956 return tagDirectory; 2957 } 2958 2959 public void setAMFCaster(String strCaster, Map args) { 2960 2961 amfCasterArguments=args; 2962 try{ 2963 if(StringUtil.isEmpty(strCaster) || "classic".equalsIgnoreCase(strCaster)) 2964 amfCasterClass=ClassicAMFCaster.class; 2965 else if("modern".equalsIgnoreCase(strCaster)) 2966 amfCasterClass=ModernAMFCaster.class; 2967 else { 2968 Class caster = ClassUtil.loadClass(strCaster); 2969 if((caster.newInstance() instanceof AMFCaster)) { 2970 amfCasterClass=caster; 2971 } 2972 else { 2973 amfCasterClass=ClassicAMFCaster.class; 2974 throw new ClassException("object ["+Caster.toClassName(caster)+"] must implement the interface "+ResourceProvider.class.getName()); 2975 } 2976 } 2977 } 2978 catch(Exception e){ 2979 e.printStackTrace(); 2980 } 2981 } 2982 2983 public void setAMFCaster(Class clazz, Map args) { 2984 amfCasterArguments=args; 2985 amfCasterClass=clazz; 2986 } 2987 2988 public void setAMFConfigType(String strDeploy) { 2989 if(!StringUtil.isEmpty(strDeploy)){ 2990 if("xml".equalsIgnoreCase(strDeploy))amfConfigType=AMF_CONFIG_TYPE_XML; 2991 else if("manual".equalsIgnoreCase(strDeploy))amfConfigType=AMF_CONFIG_TYPE_MANUAL; 2992 } 2993 } 2994 public void setAMFConfigType(int amfDeploy) { 2995 this.amfConfigType=amfDeploy; 2996 } 2997 public int getAMFConfigType() { 2998 return amfConfigType; 2999 } 3000 3001 public AMFCaster getAMFCaster(ConfigMap properties) throws ClassException { 3002 if(amfCaster==null){ 3003 if(properties!=null){ 3004 ConfigMap cases = properties.getPropertyAsMap("property-case", null); 3005 if(cases!=null){ 3006 if(!amfCasterArguments.containsKey("force-cfc-lowercase")) 3007 amfCasterArguments.put("force-cfc-lowercase",Caster.toBoolean(cases.getPropertyAsBoolean("force-cfc-lowercase", false))); 3008 if(!amfCasterArguments.containsKey("force-query-lowercase")) 3009 amfCasterArguments.put("force-query-lowercase",Caster.toBoolean(cases.getPropertyAsBoolean("force-query-lowercase", false))); 3010 if(!amfCasterArguments.containsKey("force-struct-lowercase")) 3011 amfCasterArguments.put("force-struct-lowercase",Caster.toBoolean(cases.getPropertyAsBoolean("force-struct-lowercase", false))); 3012 3013 } 3014 ConfigMap access = properties.getPropertyAsMap("access", null); 3015 if(access!=null){ 3016 if(!amfCasterArguments.containsKey("use-mappings")) 3017 amfCasterArguments.put("use-mappings",Caster.toBoolean(access.getPropertyAsBoolean("use-mappings", false))); 3018 if(!amfCasterArguments.containsKey("method-access-level")) 3019 amfCasterArguments.put("method-access-level",access.getPropertyAsString("method-access-level","remote")); 3020 } 3021 } 3022 3023 amfCaster=(AMFCaster)ClassUtil.loadInstance(amfCasterClass); 3024 amfCaster.init(amfCasterArguments); 3025 } 3026 return amfCaster; 3027 } 3028 public Class getAMFCasterClass() { 3029 return amfCasterClass; 3030 } 3031 public Map getAMFCasterArguments() { 3032 if(amfCasterArguments==null) amfCasterArguments=new HashMap(); 3033 return amfCasterArguments; 3034 } 3035 3036 public String getDefaultDataSource() { 3037 // TODO Auto-generated method stub 3038 return null; 3039 } 3040 protected void setDefaultDataSource(String defaultDataSource) { 3041 this.defaultDataSource=defaultDataSource; 3042 } 3043 3044 /** 3045 * @return the inspectTemplate 3046 * FUTURE to interface 3047 */ 3048 public short getInspectTemplate() { 3049 return inspectTemplate; 3050 } 3051 3052 /** 3053 * @param inspectTemplate the inspectTemplate to set 3054 * FUTURE to interface 3055 */ 3056 protected void setInspectTemplate(short inspectTemplate) { 3057 this.inspectTemplate = inspectTemplate; 3058 } 3059 3060 protected void setSerialNumber(String serial) { 3061 this.serial=serial; 3062 } 3063 3064 public String getSerialNumber() { 3065 return serial; 3066 } 3067 3068 protected void setCaches(HashTable caches) { 3069 this.caches=caches; 3070 Iterator it = caches.entrySet().iterator(); 3071 Map.Entry entry; 3072 CacheConnection cc; 3073 while(it.hasNext()){ 3074 entry = (Entry) it.next(); 3075 cc=((CacheConnection)entry.getValue()); 3076 if(cc.getName().equalsIgnoreCase(cacheDefaultConnectionNameTemplate)){ 3077 defaultCacheTemplate=cc; 3078 } 3079 else if(cc.getName().equalsIgnoreCase(cacheDefaultConnectionNameQuery)){ 3080 defaultCacheQuery=cc; 3081 } 3082 else if(cc.getName().equalsIgnoreCase(cacheDefaultConnectionNameResource)){ 3083 defaultCacheResource=cc; 3084 } 3085 else if(cc.getName().equalsIgnoreCase(cacheDefaultConnectionNameObject)){ 3086 defaultCacheObject=cc; 3087 } 3088 } 3089 } 3090 3091 /** 3092 * @return the caches 3093 *FUTURE add o interface 3094 */ 3095 public Map getCacheConnections() { 3096 return caches; 3097 } 3098 3099 /** 3100 * @return the defaultCache 3101 * FUTURE add o interface 3102 */ 3103 public CacheConnection getCacheDefaultConnection(int type) { 3104 if(type==CACHE_DEFAULT_OBJECT) return defaultCacheObject; 3105 if(type==CACHE_DEFAULT_TEMPLATE) return defaultCacheTemplate; 3106 if(type==CACHE_DEFAULT_QUERY) return defaultCacheQuery; 3107 return defaultCacheResource; 3108 } 3109 3110 public void setCacheDefaultConnectionName(int type,String cacheDefaultConnectionName) { 3111 if(type==CACHE_DEFAULT_TEMPLATE) cacheDefaultConnectionNameTemplate=cacheDefaultConnectionName; 3112 else if(type==CACHE_DEFAULT_OBJECT) cacheDefaultConnectionNameObject=cacheDefaultConnectionName; 3113 else if(type==CACHE_DEFAULT_QUERY) cacheDefaultConnectionNameQuery=cacheDefaultConnectionName; 3114 else cacheDefaultConnectionNameResource=cacheDefaultConnectionName; 3115 } 3116 public String getCacheDefaultConnectionName(int type) { 3117 if(type==CACHE_DEFAULT_TEMPLATE) return cacheDefaultConnectionNameTemplate; 3118 if(type==CACHE_DEFAULT_OBJECT) return cacheDefaultConnectionNameObject; 3119 if(type==CACHE_DEFAULT_QUERY) return cacheDefaultConnectionNameQuery; 3120 return cacheDefaultConnectionNameResource; 3121 } 3122 3123 public String getCacheMD5() { 3124 return cacheMD5; 3125 } 3126 3127 public void setCacheMD5(String cacheMD5) { 3128 this.cacheMD5 = cacheMD5; 3129 } 3130 3131 public boolean getExecutionLogEnabled() { 3132 return executionLogEnabled; 3133 } 3134 protected void setExecutionLogEnabled(boolean executionLogEnabled) { 3135 this.executionLogEnabled= executionLogEnabled; 3136 } 3137 3138 public ExecutionLogFactory getExecutionLogFactory() { 3139 return executionLogFactory; 3140 } 3141 protected void setExecutionLogFactory(ExecutionLogFactory executionLogFactory) { 3142 this.executionLogFactory= executionLogFactory; 3143 } 3144 3145 public ORMEngine resetORMEngine(PageContext pc, boolean force) throws PageException { 3146 //String name = pc.getApplicationContext().getName(); 3147 //ormengines.remove(name); 3148 ORMEngine e = getORMEngine(pc); 3149 e.reload(pc,force); 3150 return e; 3151 } 3152 3153 public ORMEngine getORMEngine(PageContext pc) throws PageException { 3154 String name = pc.getApplicationContext().getName(); 3155 3156 ORMEngine engine = ormengines.get(name); 3157 if(engine==null){ 3158 //try { 3159 boolean hasError=false; 3160 try { 3161 engine=(ORMEngine)ClassUtil.loadInstance(ormEngineClass); 3162 engine.init(pc); 3163 } 3164 catch (ClassException t) { 3165 hasError=true; 3166 } 3167 catch (NoClassDefFoundError t) { 3168 hasError=true; 3169 } 3170 3171 if(hasError) { 3172 // try to load hibernate jars 3173 if(JarLoader.changed(pc.getConfig(), Admin.ORM_JARS)) 3174 throw new ORMException( 3175 "cannot initilaize ORM Engine ["+ormEngineClass.getName()+"], make sure you have added all the required jars files", 3176 "GO to the Railo Server Administrator and on the page Services/Update, click on \"Update JAR's\""); 3177 else 3178 throw new ORMException( 3179 "cannot initilaize ORM Engine ["+ormEngineClass.getName()+"], make sure you have added all the required jars files", 3180 "if you have updated the JAR's in the Railo Administrator, please restart your Servlet Engine"); 3181 3182 } 3183 ormengines.put(name,engine); 3184 /*} 3185 catch (PageException pe) { 3186 throw pe; 3187 }*/ 3188 } 3189 3190 return engine; 3191 } 3192 3193 public Class<ORMEngine> getORMEngineClass() { 3194 return ormEngineClass; 3195 } 3196 3197 public String[] getInstalledPatches() throws PageException { 3198 CFMLEngineFactory factory = getConfigServerImpl().getCFMLEngine().getCFMLEngineFactory(); 3199 3200 // FUTURE make direct call 3201 //String[] patches = factory.getInstalledPatches(); 3202 3203 try{ 3204 Method getInstalledPatches = factory.getClass().getMethod("getInstalledPatches", new Class[]{}); 3205 return (String[]) getInstalledPatches.invoke(factory, new Object[]{}); 3206 } 3207 catch(NoSuchMethodException e){ 3208 try { 3209 return getInstalledPatches(factory); 3210 } catch (Exception e1) { 3211 throw Caster.toPageException(e1); 3212 } 3213 } 3214 catch(Throwable t){ 3215 return new String[0]; 3216 //throw Caster.toPageException(t); 3217 } 3218 } 3219 3220 /** 3221 * FUTURE add to interface 3222 * @return the componentMappings 3223 */ 3224 public Mapping[] getComponentMappings() { 3225 return componentMappings; 3226 } 3227 3228 // FUTURE remove from interface 3229 public Mapping getComponentMapping() { 3230 throw new PageRuntimeException(new ApplicationException("this method is no longer supported")); 3231 } 3232 3233 /** 3234 * @param componentMappings the componentMappings to set 3235 */ 3236 protected void setComponentMappings(Mapping[] componentMappings) { 3237 this.componentMappings = componentMappings; 3238 } 3239 3240 // FUTURE remove this 3241 private String getCoreExtension() throws ServletException { 3242 URL res = new TP().getClass().getResource("/core/core.rcs"); 3243 if(res!=null) return "rcs"; 3244 3245 res = new TP().getClass().getResource("/core/core.rc"); 3246 if(res!=null) return "rc"; 3247 3248 throw new ServletException("missing core file"); 3249 } 3250 3251 // FUTURE remove this 3252 private String[] getInstalledPatches(CFMLEngineFactory factory) throws ServletException, IOException { 3253 File patchDir = new File(factory.getResourceRoot(),"patches"); 3254 if(!patchDir.exists())patchDir.mkdirs(); 3255 3256 File[] patches=patchDir.listFiles(new ExtensionFilter(new String[]{"."+getCoreExtension()})); 3257 3258 List<String> list=new ArrayList<String>(); 3259 String name; 3260 int extLen=getCoreExtension().length()+1; 3261 for(int i=0;i<patches.length;i++) { 3262 name=patches[i].getName(); 3263 name=name.substring(0, name.length()-extLen); 3264 list.add(name); 3265 } 3266 String[] arr = list.toArray(new String[list.size()]); 3267 Arrays.sort(arr); 3268 return arr; 3269 } 3270 3271 protected void setORMEngineClass(Class<ORMEngine> ormEngineClass) { 3272 this.ormEngineClass=ormEngineClass; 3273 } 3274 3275 protected void setORMConfig(ORMConfiguration ormConfig) { 3276 this.ormConfig=ormConfig; 3277 } 3278 3279 public ORMConfiguration getORMConfig() { 3280 return ormConfig; 3281 } 3282 3283 public Mapping createCustomTagAppMappings(String virtual, String physical) { 3284 Mapping m=customTagAppMappings.get(physical.toLowerCase()); 3285 3286 if(m==null){ 3287 m=new MappingImpl( 3288 this,virtual, 3289 physical, 3290 null,false,true,false,false,false,true,true 3291 ); 3292 customTagAppMappings.put(physical.toLowerCase(),m); 3293 } 3294 3295 return m; 3296 } 3297 3298 3299 3300 private Map<String,PageSource> componentPathCache=null;//new ArrayList<Page>(); 3301 private Map<String,InitFile> ctPatchCache=null;//new ArrayList<Page>(); 3302 3303 private Map udfCache=new ReferenceMap(); 3304 3305 3306 3307 3308 3309 public Page getCachedPage(PageContext pc,String pathWithCFC) throws PageException { 3310 if(componentPathCache==null) return null; 3311 3312 PageSource ps = componentPathCache.get(pathWithCFC.toLowerCase()); 3313 if(ps==null) return null; 3314 return ((PageSourceImpl)ps).loadPage(pc,pc.getConfig(),null); 3315 } 3316 3317 public void putCachedPageSource(String pathWithCFC,PageSource ps) { 3318 if(componentPathCache==null) componentPathCache=Collections.synchronizedMap(new HashMap<String, PageSource>());//MUSTMUST new ReferenceMap(ReferenceMap.SOFT,ReferenceMap.SOFT); 3319 componentPathCache.put(pathWithCFC.toLowerCase(),ps); 3320 } 3321 3322 public InitFile getCTInitFile(PageContext pc,String key) throws PageException { 3323 if(ctPatchCache==null) return null; 3324 3325 InitFile initFile = ctPatchCache.get(key.toLowerCase()); 3326 if(initFile!=null){ 3327 if(MappingImpl.isOK(initFile.getPageSource()))return initFile; 3328 ctPatchCache.remove(key.toLowerCase()); 3329 } 3330 return null; 3331 } 3332 3333 public void putCTInitFile(String key,InitFile initFile) { 3334 if(ctPatchCache==null) ctPatchCache=Collections.synchronizedMap(new HashMap<String, InitFile>());//MUSTMUST new ReferenceMap(ReferenceMap.SOFT,ReferenceMap.SOFT); 3335 ctPatchCache.put(key.toLowerCase(),initFile); 3336 } 3337 3338 3339 3340 public Struct listCTCache() { 3341 Struct sct=new StructImpl(); 3342 if(ctPatchCache==null) return sct; 3343 Iterator<Entry<String, InitFile>> it = ctPatchCache.entrySet().iterator(); 3344 3345 Entry<String, InitFile> entry; 3346 while(it.hasNext()){ 3347 entry = it.next(); 3348 sct.setEL(entry.getKey(),entry.getValue().getPageSource().getDisplayPath()); 3349 } 3350 return sct; 3351 } 3352 3353 public void clearCTCache() { 3354 if(ctPatchCache==null) return; 3355 ctPatchCache.clear(); 3356 } 3357 3358 3359 public void clearFunctionCache() { 3360 udfCache.clear(); 3361 } 3362 public UDF getFromFunctionCache(String key) { 3363 return (UDF) udfCache.get(key); 3364 } 3365 public void putToFunctionCache(String key,UDF udf) { 3366 udfCache.put(key, udf); 3367 } 3368 3369 3370 public Struct listComponentCache() { 3371 Struct sct=new StructImpl(); 3372 if(componentPathCache==null) return sct; 3373 Iterator<Entry<String, PageSource>> it = componentPathCache.entrySet().iterator(); 3374 3375 Entry<String, PageSource> entry; 3376 while(it.hasNext()){ 3377 entry = it.next(); 3378 sct.setEL(entry.getKey(),entry.getValue().getDisplayPath()); 3379 } 3380 return sct; 3381 } 3382 3383 public void clearComponentCache() { 3384 if(componentPathCache==null) return; 3385 componentPathCache.clear(); 3386 } 3387 3388 3389 3390 public ImportDefintion getComponentDefaultImport() { 3391 return componentDefaultImport; 3392 } 3393 protected void setComponentDefaultImport(String str) { 3394 ImportDefintion cdi = ImportDefintion.getInstance(str, null); 3395 if(cdi!=null)this.componentDefaultImport= cdi; 3396 } 3397 3398 /** 3399 * @return the componentLocalSearch 3400 */ 3401 public boolean getComponentLocalSearch() { 3402 return componentLocalSearch; 3403 } 3404 3405 /** 3406 * @param componentLocalSearch the componentLocalSearch to set 3407 */ 3408 protected void setComponentLocalSearch(boolean componentLocalSearch) { 3409 this.componentLocalSearch = componentLocalSearch; 3410 } 3411 3412 /** 3413 * @return the componentLocalSearch 3414 */ 3415 public boolean getComponentRootSearch() { 3416 return componentRootSearch; 3417 } 3418 3419 /** 3420 * @param componentLocalSearch the componentLocalSearch to set 3421 */ 3422 protected void setComponentRootSearch(boolean componentRootSearch) { 3423 this.componentRootSearch = componentRootSearch; 3424 } 3425 3426 private final Map compressResources= new ReferenceMap(ReferenceMap.SOFT,ReferenceMap.SOFT); 3427 public Compress getCompressInstance(Resource zipFile, int format, boolean caseSensitive) { 3428 Compress compress=(Compress) compressResources.get(zipFile.getPath()); 3429 if(compress==null) { 3430 compress=new Compress(zipFile,format,caseSensitive); 3431 compressResources.put(zipFile.getPath(), compress); 3432 } 3433 return compress; 3434 } 3435 3436 public boolean getSessionCluster() { 3437 return false; 3438 } 3439 3440 public boolean getClientCluster() { 3441 return false; 3442 } 3443 3444 3445 3446 public abstract int getLoginDelay(); 3447 3448 public abstract boolean getLoginCaptcha(); 3449 3450 public abstract Resource getConfigServerDir(); 3451 3452 public abstract boolean isMonitoringEnabled(); 3453 3454 public abstract RequestMonitor[] getRequestMonitors() ; 3455 3456 3457 }