001    package railo.runtime.config;
002    
003    import java.io.IOException;
004    import java.io.PrintWriter;
005    import java.net.URL;
006    import java.util.Locale;
007    import java.util.Map;
008    import java.util.TimeZone;
009    
010    import railo.commons.io.log.LogAndSource;
011    import railo.commons.io.res.Resource;
012    import railo.commons.io.res.ResourceProvider;
013    import railo.runtime.CFMLFactory;
014    import railo.runtime.Mapping;
015    import railo.runtime.PageContext;
016    import railo.runtime.PageSource;
017    import railo.runtime.cache.CacheConnection;
018    import railo.runtime.cfx.CFXTagPool;
019    import railo.runtime.db.DataSource;
020    import railo.runtime.dump.DumpWriter;
021    import railo.runtime.engine.ThreadQueue;
022    import railo.runtime.exp.PageException;
023    import railo.runtime.extension.Extension;
024    import railo.runtime.extension.ExtensionProvider;
025    import railo.runtime.listener.ApplicationListener;
026    import railo.runtime.monitor.IntervallMonitor;
027    import railo.runtime.monitor.RequestMonitor;
028    import railo.runtime.net.mail.Server;
029    import railo.runtime.net.proxy.ProxyData;
030    import railo.runtime.rest.RestSettings;
031    import railo.runtime.schedule.Scheduler;
032    import railo.runtime.search.SearchEngine;
033    import railo.runtime.security.SecurityManager;
034    import railo.runtime.spooler.SpoolerEngine;
035    import railo.runtime.type.Struct;
036    import railo.runtime.type.dt.TimeSpan;
037    
038    /**
039     * interface for Config Object 
040     */
041    public interface Config {
042    
043        /**
044         * Define a strict scope cascading
045         */
046        public static final short SCOPE_STRICT = 0;
047    
048        /**
049         * Define a small scope cascading
050         */
051        public static final short SCOPE_SMALL = 1;
052    
053        /**
054         * Define a standart scope cascading (like other cf versions)
055         */
056        public static final short SCOPE_STANDARD = 2;
057    
058        /**
059         * Field <code>CLIENT_SCOPE_TYPE_COOKIE</code>
060         */
061        public static final short CLIENT_SCOPE_TYPE_COOKIE = 0;
062    
063        /**
064         * Field <code>CLIENT_SCOPE_TYPE_FILE</code>
065         */
066        public static final short CLIENT_SCOPE_TYPE_FILE = 1;
067    
068        /**
069         * Field <code>CLIENT_SCOPE_TYPE_DB</code>
070         */
071        public static final short CLIENT_SCOPE_TYPE_DB = 2;
072    
073        /**
074         * Field <code>SESSION_TYPE_CFML</code>
075         */
076        public static final short SESSION_TYPE_CFML = 0;
077    
078        /**
079         * Field <code>SESSION_TYPE_J2EE</code>
080         */
081        public static final short SESSION_TYPE_J2EE = 1;
082        
083    
084        /**
085         * Field <code>RECOMPILE_NEVER</code>
086         */
087        public static final short RECOMPILE_NEVER = 0;
088        /**
089         * Field <code>RECOMPILE_AT_STARTUP</code>
090         */
091        public static final short RECOMPILE_AFTER_STARTUP = 1;
092        /**
093         * Field <code>RECOMPILE_ALWAYS</code>
094         */
095        public static final short RECOMPILE_ALWAYS = 2;
096        
097    
098            public static final short INSPECT_ALWAYS = 0;
099            public static final short INSPECT_ONCE = 1;
100            public static final short INSPECT_NEVER = 2;
101    
102        /*public static final int CUSTOM_TAG_MODE_NONE = 0;
103        public static final int CUSTOM_TAG_MODE_CLASSIC = 1;
104        public static final int CUSTOM_TAG_MODE_MODERN = 2;
105        public static final int CUSTOM_TAG_MODE_CLASSIC_MODERN = 4;
106        public static final int CUSTOM_TAG_MODE_MODERN_CLASSIC = 8;
107        */
108            
109            public static final int CACHE_DEFAULT_NONE = 0;
110            public static final int CACHE_DEFAULT_OBJECT = 1;
111            public static final int CACHE_DEFAULT_TEMPLATE = 2;
112            public static final int CACHE_DEFAULT_QUERY = 4;
113            public static final int CACHE_DEFAULT_RESOURCE = 8;
114            public static final int CACHE_DEFAULT_FUNCTION = 16;
115    
116            
117            
118            public short getInspectTemplate();
119        
120            public String getDefaultDataSource();
121    
122        /**
123         * return how railo cascade scopes
124         * @return type of cascading
125         */
126        public abstract short getScopeCascadingType();
127    
128        /**
129         * return cfml extesnion
130         * @return cfml extension
131         */
132        public abstract String[] getCFMLExtensions();
133        
134        public abstract String getCFCExtension();
135    
136        /**
137         * return the mapping to custom tag directory
138         * @return custom tag directory
139         */
140        public abstract Mapping[] getCustomTagMappings();
141    
142        /**
143         * return if it is allowed to implizid query call, call a query member witot define name of the query. 
144         * @return is allowed
145         */
146        public abstract boolean allowImplicidQueryCall();
147    
148        /**e merged
149         * return if url and form scope will b
150         * @return merge or not
151         */
152        public abstract boolean mergeFormAndURL();
153        
154    
155        /**
156         * @return Returns the application Timeout.
157         */
158        public abstract TimeSpan getApplicationTimeout();
159    
160        /**
161         * @return Returns the session Timeout.
162         */
163        public abstract TimeSpan getSessionTimeout();
164        
165        /**
166         * @return Returns the client Timeout.
167         */
168        public TimeSpan getClientTimeout();
169    
170        /**
171         * @return Returns the request Timeout.
172         */
173        public abstract TimeSpan getRequestTimeout();
174    
175        /**
176         * @return Returns the clientCookies.
177         */
178        public abstract boolean isClientCookies();
179    
180        /**
181         * @return Returns the clientManagement.
182         */
183        public abstract boolean isClientManagement();
184    
185        /**
186         * @return Returns the domainCookies.
187         */
188        public abstract boolean isDomainCookies();
189    
190        /**
191         * @return Returns the sessionManagement.
192         */
193        public abstract boolean isSessionManagement();
194    
195        /**
196         * @return Returns the spoolEnable.
197         */
198        public abstract boolean isMailSpoolEnable();
199    
200        /**
201         * @return Returns the mailTimeout.
202         */
203        public abstract int getMailTimeout();
204    
205        /**
206         * @return preserve single quotes in cfquery tag or not
207         */
208        public abstract boolean getPSQL();
209    
210        /**
211         * @return Returns the locale.
212         */
213        public abstract Locale getLocale();
214    
215        /**
216         * return if debug output will be generated
217         * @return debug or not
218         */
219        public abstract boolean debug();
220    
221        /**
222         * return the temp directory
223         * @return temp directory
224         */
225        public abstract Resource getTempDirectory();
226    
227        /**
228         * @return Returns the spoolInterval.
229         */
230        public abstract int getMailSpoolInterval();
231    
232        /**
233         * @return returns the time zone for this 
234         */
235        public abstract TimeZone getTimeZone();
236    
237        /**
238         * @return returns the offset from the timeserver to local time 
239         */
240        public abstract long getTimeServerOffset();
241    
242        /**
243         * @return return if a password is set
244         */
245        public abstract boolean hasPassword();
246    
247        /**
248         * @param password 
249         * @return return if a password is set
250         */
251        public abstract boolean passwordEqual(String password);
252    
253        /**
254         * @return return if a password is set
255         */
256        public abstract boolean hasServerPassword();
257    
258        /**
259         * @return Returns the mappings.
260         */
261        public abstract Mapping[] getMappings();
262    
263        /**
264         * @return Returns the configDir.
265         */
266        public abstract Resource getConfigDir();
267    
268        /**
269         * @return Returns the configFile.
270         */
271        public abstract Resource getConfigFile();
272    
273        /**
274         * @return Returns the loadTime.
275         */
276        public abstract long getLoadTime();
277    
278        /**
279         * @return Returns the baseComponent.
280         */
281        public abstract String getBaseComponentTemplate();
282    
283        /**
284         * @return returns the client type
285         */
286        public abstract short getClientType();
287    
288        /**
289         * @return Returns the componentDataMemberDefaultAccess.
290         */
291        public abstract int getComponentDataMemberDefaultAccess();
292    
293        /**
294         * @return Returns the timeServer.
295         */
296        public abstract String getTimeServer();
297    
298        /**
299         * @return Returns the componentDump.
300         */
301        public abstract String getComponentDumpTemplate();
302        
303        /**
304         * @return id of the config 
305         */
306        public abstract String getId();
307    
308        /**
309         * @return Returns the debug Template.
310         * @deprecated use instead <code>getDebugEntry(ip, defaultValue)</code>
311         */
312        public abstract String getDebugTemplate();
313    
314        /**
315         * @return Returns the error Template for given status code.
316         */
317        public abstract String getErrorTemplate(int statusCode);
318    
319        /**
320         * @return Returns the sessionType.
321         */
322        public abstract short getSessionType();
323    
324        /**
325         * @return returns the charset for the response and request
326         */
327        public abstract String getWebCharset();
328        /**
329         * @return returns the charset used to read cfml files
330         */
331        public abstract String getTemplateCharset();
332        /**
333         * @return returns the charset used to read and write resources
334         */
335        public abstract String getResourceCharset();
336    
337        /**
338         * @return returns the default encoding for mail
339         */
340        public String getMailDefaultEncoding();
341        
342        /**
343         * @return returns update type (auto or manual)
344         */
345        public abstract String getUpdateType();
346    
347        /**
348         * @return returns URL for update
349         */
350        public abstract URL getUpdateLocation();
351    
352        /**
353         * return directory, where railo deploy translated cfml classes (java and class files)
354         * @return deploy directory
355         */
356        public abstract Resource getDeployDirectory();
357    
358        /**
359         * @return Returns the rootDir.
360         */
361        public abstract Resource getRootDirectory();
362    
363        /**
364         * @return Returns the accessor.
365         */
366        public abstract SecurityManager getSecurityManager();
367       
368        /**
369         * @return Returns the cfxTagPool.
370         * @throws PageException 
371         */
372        public abstract CFXTagPool getCFXTagPool() throws PageException;
373        
374        /**
375         * @return returns the application logger
376         */
377        public abstract LogAndSource getApplicationLogger();
378    
379    
380        /**
381         * @return returns the exception logger
382         */
383        public abstract LogAndSource getExceptionLogger();
384    
385        /**
386         * @return returns the trace logger
387         */
388        public abstract LogAndSource getTraceLogger();
389        
390        /**
391         * @param password
392         * @return ConfigServer
393         * @throws PageException
394         */ 
395        public abstract ConfigServer getConfigServer(String password) throws PageException;
396        
397        /**
398         * @return Returns the mailLogger.
399         */
400        public abstract LogAndSource getMailLogger();
401        
402        /**
403         * @return Returns the request timeout Directory.
404         */
405        public LogAndSource getRequestTimeoutLogger();
406        
407        /**
408         * @return returns schedule logger
409         */
410        public LogAndSource getScheduleLogger();
411        
412        /**
413         * reload the time offset to a time server 
414         */
415        public void reloadTimeServerOffset();
416        
417        /**
418         * reset config
419         */
420        public void reset();
421        
422        /**
423         * @return return the search Storage
424         */
425        public SearchEngine getSearchEngine();
426        
427        /**
428         * @return return the Scheduler
429         */
430        public Scheduler getScheduler();
431        
432        /**
433         * @return return all defined Mail Servers
434         */
435        public Server[] getMailServers();
436    
437        /**
438         * return the compile type of this context
439         */
440        public short getCompileType();
441        
442        /**
443         * return the all datasources
444        */
445        public DataSource[] getDataSources();
446        
447    
448            /**
449             * @param path get a resource that match this path
450             * @return resource matching path
451             */
452            public Resource getResource(String path);
453    
454    
455            /**
456             * return current application listener
457             * @return application listener
458             */
459            public ApplicationListener getApplicationListener();
460            
461    
462            /**
463             * @return the scriptProtect
464             */
465            public int getScriptProtect();
466    
467    
468            /**
469             * return default proxy setting password
470             * @return the password for proxy
471             */
472            public ProxyData getProxyData();
473            
474            /**
475             * return if proxy is enabled or not
476             * @return is proxy enabled
477             */
478            public boolean isProxyEnableFor(String host);
479            
480            /**
481             * @return the triggerComponentDataMember
482             */
483            public boolean getTriggerComponentDataMember();
484            
485            public RestSettings getRestSetting();
486            
487            public abstract Resource getClientScopeDir();
488    
489            public abstract long getClientScopeDirSize();
490    
491            public abstract ClassLoader getRPCClassLoader(boolean reload) throws IOException;
492            
493            public Resource getCacheDir();
494    
495            public long getCacheDirSize();
496            
497            public Map<String,CacheConnection> getCacheConnections();
498            
499            /**
500             * get default cache connection for a specific type
501             * @param type default type, one of the following (CACHE_DEFAULT_NONE, CACHE_DEFAULT_OBJECT, CACHE_DEFAULT_TEMPLATE, CACHE_DEFAULT_QUERY, CACHE_DEFAULT_RESOURCE)
502             * @return matching Cache Connection
503             */
504            public CacheConnection getCacheDefaultConnection(int type);
505    
506            /**
507             * get name of a default cache connection for a specific type
508             * @param type default type, one of the following (CACHE_DEFAULT_NONE, CACHE_DEFAULT_OBJECT, CACHE_DEFAULT_TEMPLATE, CACHE_DEFAULT_QUERY, CACHE_DEFAULT_RESOURCE)
509             * @return name of matching Cache Connection
510             */
511            public String getCacheDefaultConnectionName(int type);
512            
513            /**
514             * returns the default DumpWriter  
515             * @param defaultType
516             * @return default DumpWriter
517             */
518            public abstract DumpWriter getDefaultDumpWriter(int defaultType);
519    
520            /**
521             * returns the DumpWriter matching key
522             * @param key key for DumpWriter
523             * @param defaultType
524             * @return matching DumpWriter
525             * @throws PageException if there is no DumpWriter for this key
526             */
527            public abstract DumpWriter getDumpWriter(String key,int defaultType) throws PageException;
528    
529            /**
530             * returns the DumpWriter matching key
531             * @param key key for DumpWriter
532             * @return matching DumpWriter
533             * @deprecated use instead <code>getDumpWriter(String key,int defaultType)</code>
534             * @throws PageException if there is no DumpWriter for this key
535             */
536            public abstract DumpWriter getDumpWriter(String key) throws PageException;
537            
538            
539            /**
540             * define if components has a "shadow" in the component variables scope or not.
541             * @return
542             */
543            public abstract boolean useComponentShadow();
544            
545    
546        /* *
547         * return a database connection hold inside by a datasource definition
548         * @param datasource definiti0on of the datasource
549         * @param user username to connect
550         * @param pass password to connect
551         * @return datasource connnection
552         * @throws PageException
553         */
554        //public DatasourceConnection getConnection(String datasource, String user, String pass) throws PageException;
555    
556        /* *
557         * @return returns the ConnectionPool
558         */
559    
560            public Mapping[] getComponentMappings();
561    
562            public abstract boolean doCustomTagDeepSearch();
563    
564    
565            /**
566             * @return returns the error print writer stream
567             */
568            public abstract PrintWriter getErrWriter();
569            
570            /**
571             * @return returns the out print writer stream
572             */
573            public abstract PrintWriter getOutWriter();
574    
575            /**
576             * define if railo search in local directory for custom tags or not
577             * @return search in local dir?
578             */
579            public abstract boolean doLocalCustomTag();
580            
581            public String[] getCustomTagExtensions();
582            
583            /**
584             * @return if error status code will be returned or not
585             */
586            public boolean getErrorStatusCode();
587            
588    
589            public abstract int getLocalMode();
590            
591            /**
592             * @return return the class defined for the cluster scope
593             */
594            public Class getClusterClass();
595            
596            /**
597             * @return classloader of ths context
598             */
599            public ClassLoader getClassLoader();
600            
601            // FUTURE @deprected use instead PageContext.getClassLoader(Resource[] reses);
602            public ClassLoader getClassLoader(Resource[] reses) throws IOException;
603            
604            public Resource getExtensionDirectory();
605            
606            public ExtensionProvider[] getExtensionProviders();
607            
608            public Extension[] getExtensions();
609            
610            public PageSource getBaseComponentPageSource();
611            
612            public boolean allowRealPath();
613            
614            public Struct getConstants();
615            
616            public DataSource getDataSource(String datasource) throws PageException;
617            
618            public DataSource getDataSource(String datasource, DataSource defaultValue);
619            
620            public Map getDataSourcesAsMap();
621            
622            public String getDefaultEncoding();
623            
624            public ResourceProvider getDefaultResourceProvider();
625            
626            public CFMLFactory getFactory();
627            
628            public boolean isExtensionEnabled();
629    
630            public Resource getFldFile();
631    
632            /**
633             * @return the tldFile
634             */
635            public Resource getTldFile();
636            
637            /**
638             * get PageSource of the first Mapping that match the given criteria
639             * @param mappings per application mappings
640             * @param realPath path to get PageSource for
641             * @param onlyTopLevel checks only toplevel mappings
642             * @deprecated use instead getPageSources or getPageSourceExisting
643             */
644            public PageSource getPageSource(Mapping[] mappings, String realPath,boolean onlyTopLevel);
645            
646            /**
647             * return existing PageSource that match the given criteria, if there is no PageSource null is returned.
648             * @param pc current PageContext
649             * @param mappings per application mappings
650             * @param realPath path to get PageSource for
651             * @param onlyTopLevel checks only toplevel mappings
652             * @param useSpecialMappings invoke special mappings like "mapping-tag" or "mapping-customtag"
653             * @param useDefaultMapping also invoke the always existing default mapping "/"
654             */
655            public PageSource getPageSourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping, boolean onlyPhysicalExisting);
656            
657            /**
658             * get all PageSources that match the given criteria
659             * @param pc current PageContext
660             * @param mappings per application mappings
661             * @param realPath path to get PageSource for
662             * @param onlyTopLevel checks only toplevel mappings
663             * @param useSpecialMappings invoke special mappings like "mapping-tag" or "mapping-customtag"
664             * @param useDefaultMapping also invoke the always existing default mapping "/"
665             */
666            public PageSource[] getPageSources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping);
667            
668            /**
669             * get Resource of the first Mapping that match the given criteria
670             * @param mappings per application mappings
671             * @param realPath path to get PageSource for
672             * @param onlyTopLevel checks only toplevel mappings
673             * @deprecated use instead getPhysicalResources or getPhysicalResourceExisting
674             */
675            public Resource getPhysical(Mapping[] mappings, String realPath, boolean alsoDefaultMapping);
676        
677            /**
678             * get all Resources that match the given criteria
679             * @param pc current PageContext
680             * @param mappings per application mappings
681             * @param realPath path to get PageSource for
682             * @param onlyTopLevel checks only toplevel mappings
683             * @param useSpecialMappings invoke special mappings like "mapping-tag" or "mapping-customtag"
684             * @param useDefaultMapping also invoke the always existing default mapping "/"
685             */
686            public Resource[] getPhysicalResources(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping);
687            
688            /**
689             * return existing Resource that match the given criteria, if there is no Resource null is returned.
690             * @param pc current PageContext
691             * @param mappings per application mappings
692             * @param realPath path to get Resource for
693             * @param onlyTopLevel checks only toplevel mappings
694             * @param useSpecialMappings invoke special mappings like "mapping-tag" or "mapping-customtag"
695             * @param useDefaultMapping also invoke the always existing default mapping "/"
696             */
697            public Resource getPhysicalResourceExisting(PageContext pc,Mapping[] mappings, String realPath,boolean onlyTopLevel,boolean useSpecialMappings, boolean useDefaultMapping);
698                
699        
700        public Resource getRemoteClientDirectory();
701        
702            public LogAndSource getRemoteClientLog();
703            
704            public RemoteClient[] getRemoteClients();
705            
706            public SpoolerEngine getSpoolerEngine();
707            
708            public ResourceProvider[] getResourceProviders();
709            
710            public double getVersion();
711            
712            public Resource getVideoDirectory();
713            
714            //public String getVideoProviderLocation();
715            
716            public boolean isShowVersion();
717            
718            public boolean isSuppressWhitespace();
719            
720            //public boolean isVideoAgreementAccepted();
721            
722            public Struct getRemoteClientUsage();
723            
724            public Class getAdminSyncClass();
725            
726            public Class getVideoExecuterClass();
727            
728            public ThreadQueue getThreadQueue();
729            
730            public boolean getSessionCluster();
731    
732            public boolean getClientCluster();
733            
734            public Resource getSecurityDirectory();
735            
736            public boolean isMonitoringEnabled();
737            
738            public RequestMonitor[] getRequestMonitors();
739            
740            public RequestMonitor getRequestMonitor(String name) throws PageException;
741            
742            public IntervallMonitor[] getIntervallMonitors();
743    
744            public IntervallMonitor getIntervallMonitor(String name) throws PageException;
745            
746            /**
747             * if free permspace gen is lower than 10000000 bytes, railo shrinks all classloaders 
748             * @param cs
749             */
750        public void checkPermGenSpace(boolean check);
751        
752        public boolean allowRequestTimeout();
753    }