0001: /*
0002: * Licensed to the Apache Software Foundation (ASF) under one or more
0003: * contributor license agreements. See the NOTICE file distributed with
0004: * this work for additional information regarding copyright ownership.
0005: * The ASF licenses this file to You under the Apache License, Version 2.0
0006: * (the "License"); you may not use this file except in compliance with
0007: * the License. You may obtain a copy of the License at
0008: *
0009: * http://www.apache.org/licenses/LICENSE-2.0
0010: *
0011: * Unless required by applicable law or agreed to in writing, software
0012: * distributed under the License is distributed on an "AS IS" BASIS,
0013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014: * See the License for the specific language governing permissions and
0015: * limitations under the License.
0016: */
0017: package org.apache.wicket.settings;
0018:
0019: import java.lang.ref.WeakReference;
0020: import java.util.ArrayList;
0021: import java.util.Collections;
0022: import java.util.HashMap;
0023: import java.util.List;
0024: import java.util.Map;
0025:
0026: import org.apache.wicket.Application;
0027: import org.apache.wicket.Component;
0028: import org.apache.wicket.IPageFactory;
0029: import org.apache.wicket.IResourceFactory;
0030: import org.apache.wicket.IResponseFilter;
0031: import org.apache.wicket.Localizer;
0032: import org.apache.wicket.Page;
0033: import org.apache.wicket.application.DefaultClassResolver;
0034: import org.apache.wicket.application.IClassResolver;
0035: import org.apache.wicket.authorization.IAuthorizationStrategy;
0036: import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
0037: import org.apache.wicket.authorization.UnauthorizedInstantiationException;
0038: import org.apache.wicket.markup.IMarkupCache;
0039: import org.apache.wicket.markup.IMarkupParserFactory;
0040: import org.apache.wicket.markup.MarkupCache;
0041: import org.apache.wicket.markup.MarkupParserFactory;
0042: import org.apache.wicket.markup.html.IPackageResourceGuard;
0043: import org.apache.wicket.markup.html.PackageResourceGuard;
0044: import org.apache.wicket.markup.html.form.persistence.CookieValuePersisterSettings;
0045: import org.apache.wicket.markup.html.pages.BrowserInfoPage;
0046: import org.apache.wicket.markup.resolver.AutoComponentResolver;
0047: import org.apache.wicket.markup.resolver.IComponentResolver;
0048: import org.apache.wicket.resource.PropertiesFactory;
0049: import org.apache.wicket.resource.loader.ClassStringResourceLoader;
0050: import org.apache.wicket.resource.loader.ComponentStringResourceLoader;
0051: import org.apache.wicket.resource.loader.IStringResourceLoader;
0052: import org.apache.wicket.session.DefaultPageFactory;
0053: import org.apache.wicket.session.pagemap.IPageMapEvictionStrategy;
0054: import org.apache.wicket.session.pagemap.LeastRecentlyAccessedEvictionStrategy;
0055: import org.apache.wicket.util.crypt.CachingSunJceCryptFactory;
0056: import org.apache.wicket.util.crypt.ICryptFactory;
0057: import org.apache.wicket.util.file.IResourceFinder;
0058: import org.apache.wicket.util.file.IResourcePath;
0059: import org.apache.wicket.util.file.Path;
0060: import org.apache.wicket.util.lang.Bytes;
0061: import org.apache.wicket.util.resource.locator.IResourceStreamLocator;
0062: import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
0063: import org.apache.wicket.util.string.Strings;
0064: import org.apache.wicket.util.time.Duration;
0065: import org.apache.wicket.util.watch.ModificationWatcher;
0066:
0067: /**
0068: * Contains settings exposed via IXXXSettings interfaces. It is not a good idea to use this class
0069: * directly, instead use the provided IXXXSettings interfaces.
0070: *
0071: * @author Jonathan Locke
0072: * @author Chris Turner
0073: * @author Eelco Hillenius
0074: * @author Juergen Donnerstag
0075: * @author Johan Compagner
0076: * @author Igor Vaynberg (ivaynberg)
0077: * @author Martijn Dashorst
0078: */
0079: public final class Settings implements IApplicationSettings,
0080: IDebugSettings, IExceptionSettings, IMarkupSettings,
0081: IPageSettings, IRequestCycleSettings, IResourceSettings,
0082: ISecuritySettings, ISessionSettings, IFrameworkSettings,
0083: IRequestLoggerSettings {
0084: /** Class of access denied page. */
0085: private WeakReference/* <Class<? extends Page> */accessDeniedPage;
0086:
0087: /** ajax debug mode status */
0088: private boolean ajaxDebugModeEnabled = false;
0089:
0090: /** The application */
0091: private final Application application;
0092:
0093: /** The authorization strategy. */
0094: private IAuthorizationStrategy authorizationStrategy = IAuthorizationStrategy.ALLOW_ALL;
0095:
0096: /** Application default for automatically resolving hrefs */
0097: private boolean automaticLinking = false;
0098:
0099: /**
0100: * Whether Wicket should try to support multiple windows transparently, true by default.
0101: */
0102: private boolean automaticMultiWindowSupport = true;
0103:
0104: /** True if the response should be buffered */
0105: private boolean bufferResponse = true;
0106:
0107: /** class resolver to find classes */
0108: private IClassResolver classResolver = new DefaultClassResolver();
0109:
0110: /** List of (static) ComponentResolvers */
0111: private final List componentResolvers = new ArrayList();
0112:
0113: /** True to check that each component on a page is used */
0114: private boolean componentUseCheck = true;
0115:
0116: /** True if multiple tabs/spaces should be compressed to a single space */
0117: private boolean compressWhitespace = false;
0118:
0119: /** Default values for persistence of form data (by means of cookies) */
0120: private CookieValuePersisterSettings cookieValuePersisterSettings = new CookieValuePersisterSettings();
0121:
0122: /** facotry for creating crypt objects */
0123: private ICryptFactory cryptFactory;
0124:
0125: /** Default markup for after a disabled link */
0126: private String defaultAfterDisabledLink = "</em>";
0127:
0128: /** Default markup for before a disabled link */
0129: private String defaultBeforeDisabledLink = "<em>";
0130:
0131: /** Default markup encoding. If null, the OS default will be used */
0132: private String defaultMarkupEncoding;
0133:
0134: /**
0135: * Whether we should disable gzip compression for resources.
0136: */
0137: private boolean disableGZipCompression = false;
0138:
0139: /**
0140: * Whether mounts should be enforced. If true, requests for mounted targets have to done through
0141: * the mounted paths. If, for instance, a bookmarkable page is mounted to a path, a request to
0142: * that same page via the bookmarkablePage parameter will be denied.
0143: */
0144: private boolean enforceMounts = false;
0145:
0146: /**
0147: * Whether Wicket should try to get extensive client info by redirecting to
0148: * {@link BrowserInfoPage a page that polls for client capabilities}. This method is used by
0149: * the default implementation of {@link #newClientInfo()}, so if that method is overriden,
0150: * there is no guarantee this method will be taken into account. False by default.
0151: */
0152: private boolean gatherExtendedBrowserInfo = false;
0153:
0154: /** Class of internal error page. */
0155: private WeakReference/* <Class<? extends Page> */internalErrorPage;
0156:
0157: /**
0158: * whether wicket should track line precise additions of components for error reporting.
0159: */
0160: private boolean linePreciseReportingOnAddComponentEnabled = false;
0161:
0162: /**
0163: * whether wicket should track line precise instantiations of components for error reporting.
0164: */
0165: private boolean linePreciseReportingOnNewComponentEnabled = false;
0166:
0167: /** I18N support */
0168: private Localizer localizer;
0169:
0170: /** Factory for creating markup parsers */
0171: private IMarkupParserFactory markupParserFactory;
0172:
0173: /** A markup cache which will load the markup if required. */
0174: private IMarkupCache markupCache;
0175:
0176: /** To help prevent denial of service attacks */
0177: private int maxPageMaps = 5;
0178:
0179: /** Map to look up resource factories by name */
0180: private final Map nameToResourceFactory = new HashMap();
0181:
0182: /** True if string resource loaders have been overridden */
0183: private boolean overriddenStringResourceLoaders = false;
0184:
0185: /** The package resource guard. */
0186: private IPackageResourceGuard packageResourceGuard = new PackageResourceGuard();
0187:
0188: /** The error page displayed when an expired page is accessed. */
0189: private WeakReference/* <Class<? extends Page> */pageExpiredErrorPage;
0190:
0191: /** factory to create new Page objects */
0192: private IPageFactory pageFactory = new DefaultPageFactory();
0193:
0194: /** The eviction strategy. */
0195: private IPageMapEvictionStrategy pageMapEvictionStrategy = new LeastRecentlyAccessedEvictionStrategy(
0196: 5);
0197:
0198: /** The factory to be used for the property files */
0199: private org.apache.wicket.resource.IPropertiesFactory propertiesFactory;
0200:
0201: /**
0202: * The render strategy, defaults to 'REDIRECT_TO_BUFFER'. This property influences the default
0203: * way in how a logical request that consists of an 'action' and a 'render' part is handled, and
0204: * is mainly used to have a means to circumvent the 'refresh' problem.
0205: */
0206: private IRequestCycleSettings.RenderStrategy renderStrategy = REDIRECT_TO_BUFFER;
0207:
0208: /** Filesystem Path to search for resources */
0209: private IResourceFinder resourceFinder = new Path();
0210:
0211: /** Frequency at which files should be polled */
0212: private Duration resourcePollFrequency = null;
0213:
0214: /** resource locator for this application */
0215: private IResourceStreamLocator resourceStreamLocator;
0216:
0217: /** ModificationWatcher to watch for changes in markup files */
0218: private ModificationWatcher resourceWatcher;
0219:
0220: /** List of {@link IResponseFilter}s. */
0221: private List responseFilters;
0222:
0223: /**
0224: * In order to do proper form parameter decoding it is important that the response and the
0225: * following request have the same encoding. see
0226: * http://www.crazysquirrel.com/computing/general/form-encoding.jspx for additional information.
0227: */
0228: private String responseRequestEncoding = "UTF-8";
0229:
0230: /** Chain of string resource loaders to use */
0231: private final List stringResourceLoaders = new ArrayList(4);
0232:
0233: /** Should HTML comments be stripped during rendering? */
0234: private boolean stripComments = false;
0235:
0236: /**
0237: * If true, wicket tags ( <wicket: ..>) and wicket:id attributes we be removed from output
0238: */
0239: private boolean stripWicketTags = false;
0240:
0241: /** In order to remove <?xml?> from output as required by IE quirks mode */
0242: private boolean stripXmlDeclarationFromOutput;
0243:
0244: /** Flags used to determine how to behave if resources are not found */
0245: private boolean throwExceptionOnMissingResource = true;
0246:
0247: /**
0248: * Whether the generated page id must be unique per session, or it's enough if it is unique per
0249: * page map;
0250: */
0251: private boolean pageIdUniquePerSession = false;
0252:
0253: /**
0254: * The time that a request will by default be waiting for the previous request to be handled
0255: * before giving up. Defaults to one minute.
0256: */
0257: private Duration timeout = Duration.ONE_MINUTE;
0258:
0259: /** Authorizer for component instantiations */
0260: private IUnauthorizedComponentInstantiationListener unauthorizedComponentInstantiationListener = new IUnauthorizedComponentInstantiationListener() {
0261: /**
0262: * Called when an unauthorized component instantiation is about to take place (but before it
0263: * happens).
0264: *
0265: * @param component
0266: * The partially constructed component (only the id is guaranteed to be valid).
0267: */
0268: public void onUnauthorizedInstantiation(
0269: final Component component) {
0270: throw new UnauthorizedInstantiationException(component
0271: .getClass());
0272: }
0273: };
0274:
0275: /** Type of handling for unexpected exceptions */
0276: private UnexpectedExceptionDisplay unexpectedExceptionDisplay = SHOW_EXCEPTION_PAGE;
0277:
0278: /** Determines behavior of string resource loading if string is missing */
0279: private boolean useDefaultOnMissingResource = true;
0280:
0281: /** Determines if pages should be managed by a version manager by default */
0282: private boolean versionPagesByDefault = true;
0283:
0284: private boolean recordSessionSize = true;
0285:
0286: private int requestsWindowSize = 0;
0287:
0288: private boolean requestLoggerEnabled;
0289:
0290: /**
0291: * Whether the comments and whitespaces will be stripped from javascript resources
0292: */
0293: private boolean stripJavascriptCommentsAndWhitespace;
0294:
0295: /**
0296: * Whether the container's class name should be printed to response (in a html comment).
0297: */
0298: private boolean outputMarkupContainerClassName = false;
0299:
0300: /**
0301: * Create the application settings, carrying out any necessary initialisations.
0302: *
0303: * @param application
0304: * The application that these settings are for
0305: */
0306: public Settings(final Application application) {
0307: this .application = application;
0308: stringResourceLoaders.add(new ComponentStringResourceLoader());
0309: stringResourceLoaders.add(new ClassStringResourceLoader(
0310: this .application.getClass()));
0311: }
0312:
0313: /**
0314: * @see org.apache.wicket.settings.IPageSettings#addComponentResolver(org.apache.wicket.markup.resolver.IComponentResolver)
0315: */
0316: public void addComponentResolver(IComponentResolver resolver) {
0317: componentResolvers.add(resolver);
0318: }
0319:
0320: /**
0321: * @see org.apache.wicket.settings.IResourceSettings#addResourceFactory(java.lang.String,
0322: * org.apache.wicket.IResourceFactory)
0323: */
0324: public void addResourceFactory(final String name,
0325: IResourceFactory resourceFactory) {
0326: nameToResourceFactory.put(name, resourceFactory);
0327: }
0328:
0329: /**
0330: * @see org.apache.wicket.settings.IResourceSettings#addResourceFolder(java.lang.String)
0331: */
0332: public void addResourceFolder(final String resourceFolder) {
0333: // Get resource finder
0334: final IResourceFinder finder = getResourceFinder();
0335:
0336: // Make sure it's a path
0337: if (!(finder instanceof IResourcePath)) {
0338: throw new IllegalArgumentException(
0339: "To add a resource folder, the application's resource finder must be an instance of IResourcePath");
0340: }
0341:
0342: // Cast to resource path and add folder
0343: final IResourcePath path = (IResourcePath) finder;
0344: path.add(resourceFolder);
0345: }
0346:
0347: /**
0348: * @see org.apache.wicket.settings.IRequestCycleSettings#addResponseFilter(org.apache.wicket.IResponseFilter)
0349: */
0350: public void addResponseFilter(IResponseFilter responseFilter) {
0351: if (responseFilters == null) {
0352: responseFilters = new ArrayList(3);
0353: }
0354: responseFilters.add(responseFilter);
0355: }
0356:
0357: /**
0358: * @see org.apache.wicket.settings.IResourceSettings#addStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader)
0359: */
0360: public void addStringResourceLoader(
0361: final IStringResourceLoader loader) {
0362: if (!overriddenStringResourceLoaders) {
0363: stringResourceLoaders.clear();
0364: overriddenStringResourceLoaders = true;
0365: }
0366: stringResourceLoaders.add(loader);
0367: }
0368:
0369: /**
0370: * @see org.apache.wicket.settings.IApplicationSettings#getAccessDeniedPage()
0371: */
0372: public Class getAccessDeniedPage() {
0373: return (Class) accessDeniedPage.get();
0374: }
0375:
0376: /**
0377: * @see org.apache.wicket.settings.ISecuritySettings#getAuthorizationStrategy()
0378: */
0379: public IAuthorizationStrategy getAuthorizationStrategy() {
0380: return authorizationStrategy;
0381: }
0382:
0383: /**
0384: * @see org.apache.wicket.settings.IMarkupSettings#getAutomaticLinking()
0385: */
0386: public boolean getAutomaticLinking() {
0387: return automaticLinking;
0388: }
0389:
0390: /**
0391: * @see org.apache.wicket.settings.IPageSettings#getAutomaticMultiWindowSupport()
0392: */
0393: public boolean getAutomaticMultiWindowSupport() {
0394: return automaticMultiWindowSupport;
0395: }
0396:
0397: /**
0398: * @see org.apache.wicket.settings.IRequestCycleSettings#getBufferResponse()
0399: */
0400: public boolean getBufferResponse() {
0401: return bufferResponse;
0402: }
0403:
0404: /**
0405: * @see org.apache.wicket.settings.IApplicationSettings#getClassResolver()
0406: */
0407: public IClassResolver getClassResolver() {
0408: return classResolver;
0409: }
0410:
0411: /**
0412: * Get the (modifiable) list of IComponentResolvers.
0413: *
0414: * @see AutoComponentResolver for an example
0415: * @return List of ComponentResolvers
0416: */
0417: public List getComponentResolvers() {
0418: return componentResolvers;
0419: }
0420:
0421: /**
0422: * @see org.apache.wicket.settings.IDebugSettings#getComponentUseCheck()
0423: */
0424: public boolean getComponentUseCheck() {
0425: return componentUseCheck;
0426: }
0427:
0428: /**
0429: * @see org.apache.wicket.settings.IMarkupSettings#getCompressWhitespace()
0430: */
0431: public boolean getCompressWhitespace() {
0432: return compressWhitespace;
0433: }
0434:
0435: /**
0436: * @see org.apache.wicket.settings.ISecuritySettings#getCookieValuePersisterSettings()
0437: */
0438: public CookieValuePersisterSettings getCookieValuePersisterSettings() {
0439: return cookieValuePersisterSettings;
0440: }
0441:
0442: /**
0443: * @see org.apache.wicket.settings.ISecuritySettings#getCryptFactory()
0444: */
0445: public synchronized ICryptFactory getCryptFactory() {
0446: if (cryptFactory == null) {
0447: cryptFactory = new CachingSunJceCryptFactory(
0448: ISecuritySettings.DEFAULT_ENCRYPTION_KEY);
0449: }
0450: return cryptFactory;
0451: }
0452:
0453: /**
0454: * @see org.apache.wicket.settings.IMarkupSettings#getDefaultAfterDisabledLink()
0455: */
0456: public String getDefaultAfterDisabledLink() {
0457: return defaultAfterDisabledLink;
0458: }
0459:
0460: /**
0461: * @see org.apache.wicket.settings.IMarkupSettings#getDefaultBeforeDisabledLink()
0462: */
0463: public String getDefaultBeforeDisabledLink() {
0464: return defaultBeforeDisabledLink;
0465: }
0466:
0467: /**
0468: * @see org.apache.wicket.settings.IMarkupSettings#getDefaultMarkupEncoding()
0469: */
0470: public String getDefaultMarkupEncoding() {
0471: return defaultMarkupEncoding;
0472: }
0473:
0474: /**
0475: * @see org.apache.wicket.settings.IResourceSettings#getDisableGZipCompression()
0476: */
0477: public boolean getDisableGZipCompression() {
0478: return disableGZipCompression;
0479: }
0480:
0481: /**
0482: * @see wicket.settings.ISecuritySettings#getEnforceMounts()
0483: */
0484: public boolean getEnforceMounts() {
0485: return enforceMounts;
0486: }
0487:
0488: /**
0489: * @see org.apache.wicket.settings.IRequestCycleSettings#getGatherExtendedBrowserInfo()
0490: */
0491: public boolean getGatherExtendedBrowserInfo() {
0492: return gatherExtendedBrowserInfo;
0493: }
0494:
0495: /**
0496: * @see org.apache.wicket.settings.IApplicationSettings#getInternalErrorPage()
0497: */
0498: public Class getInternalErrorPage() {
0499: return (Class) internalErrorPage.get();
0500: }
0501:
0502: /**
0503: * @see org.apache.wicket.settings.IResourceSettings#getLocalizer()
0504: */
0505: public Localizer getLocalizer() {
0506: if (localizer == null) {
0507: localizer = new Localizer();
0508: }
0509: return localizer;
0510: }
0511:
0512: /**
0513: * @see org.apache.wicket.settings.IResourceSettings#setLocalizer(org.apache.wicket.Localizer)
0514: */
0515: public void setLocalizer(final Localizer localizer) {
0516: this .localizer = localizer;
0517: }
0518:
0519: /**
0520: * @see org.apache.wicket.settings.IMarkupSettings#getMarkupParserFactory()
0521: */
0522: public IMarkupParserFactory getMarkupParserFactory() {
0523: if (markupParserFactory == null) {
0524: markupParserFactory = new MarkupParserFactory();
0525: }
0526: return markupParserFactory;
0527: }
0528:
0529: /**
0530: * @see org.apache.wicket.settings.ISessionSettings#getMaxPageMaps()
0531: */
0532: public final int getMaxPageMaps() {
0533: return maxPageMaps;
0534: }
0535:
0536: /**
0537: * @see org.apache.wicket.settings.IResourceSettings#getPackageResourceGuard()
0538: */
0539: public IPackageResourceGuard getPackageResourceGuard() {
0540: return packageResourceGuard;
0541: }
0542:
0543: /**
0544: * @see org.apache.wicket.settings.IApplicationSettings#getPageExpiredErrorPage()
0545: */
0546: public Class getPageExpiredErrorPage() {
0547: return (Class) pageExpiredErrorPage.get();
0548: }
0549:
0550: /**
0551: * @see org.apache.wicket.settings.ISessionSettings#getPageFactory()
0552: */
0553: public IPageFactory getPageFactory() {
0554: return pageFactory;
0555: }
0556:
0557: /**
0558: * @see org.apache.wicket.settings.ISessionSettings#getPageMapEvictionStrategy()
0559: */
0560: public IPageMapEvictionStrategy getPageMapEvictionStrategy() {
0561: return pageMapEvictionStrategy;
0562: }
0563:
0564: /**
0565: * @see org.apache.wicket.settings.IResourceSettings#getPropertiesFactory()
0566: */
0567: public org.apache.wicket.resource.IPropertiesFactory getPropertiesFactory() {
0568: if (propertiesFactory == null) {
0569: propertiesFactory = new PropertiesFactory(Application.get());
0570: }
0571: return propertiesFactory;
0572: }
0573:
0574: /**
0575: * @see org.apache.wicket.settings.IRequestCycleSettings#getRenderStrategy()
0576: */
0577: public IRequestCycleSettings.RenderStrategy getRenderStrategy() {
0578: return renderStrategy;
0579: }
0580:
0581: /**
0582: * @see org.apache.wicket.settings.IResourceSettings#getResourceFactory(java.lang.String)
0583: */
0584: public IResourceFactory getResourceFactory(final String name) {
0585: return (IResourceFactory) nameToResourceFactory.get(name);
0586: }
0587:
0588: /**
0589: * @see org.apache.wicket.settings.IResourceSettings#getResourceFinder()
0590: */
0591: public IResourceFinder getResourceFinder() {
0592: return resourceFinder;
0593: }
0594:
0595: /**
0596: * @see org.apache.wicket.settings.IResourceSettings#getResourcePollFrequency()
0597: */
0598: public Duration getResourcePollFrequency() {
0599: return resourcePollFrequency;
0600: }
0601:
0602: /**
0603: * @see org.apache.wicket.settings.IResourceSettings#getResourceStreamLocator()
0604: */
0605: public IResourceStreamLocator getResourceStreamLocator() {
0606: if (resourceStreamLocator == null) {
0607: // Create compound resource locator using source path from
0608: // application settings
0609: resourceStreamLocator = new ResourceStreamLocator(
0610: getResourceFinder());
0611: }
0612: return resourceStreamLocator;
0613: }
0614:
0615: /**
0616: * @see org.apache.wicket.settings.IResourceSettings#getResourceWatcher(boolean)
0617: */
0618: public ModificationWatcher getResourceWatcher(boolean start) {
0619: if (resourceWatcher == null && start) {
0620: final Duration pollFrequency = getResourcePollFrequency();
0621: if (pollFrequency != null) {
0622: resourceWatcher = new ModificationWatcher(pollFrequency);
0623: }
0624: }
0625: return resourceWatcher;
0626: }
0627:
0628: /**
0629: * @see org.apache.wicket.settings.IRequestCycleSettings#getResponseFilters()
0630: */
0631: public List getResponseFilters() {
0632: if (responseFilters == null) {
0633: return null;
0634: } else {
0635: return Collections.unmodifiableList(responseFilters);
0636: }
0637: }
0638:
0639: /**
0640: * @see org.apache.wicket.settings.IRequestCycleSettings#getResponseRequestEncoding()
0641: */
0642: public String getResponseRequestEncoding() {
0643: return responseRequestEncoding;
0644: }
0645:
0646: /**
0647: * @see org.apache.wicket.settings.IResourceSettings#getStringResourceLoaders()
0648: */
0649: public List getStringResourceLoaders() {
0650: return Collections.unmodifiableList(stringResourceLoaders);
0651: }
0652:
0653: /**
0654: * @see org.apache.wicket.settings.IMarkupSettings#getStripComments()
0655: */
0656: public boolean getStripComments() {
0657: return stripComments;
0658: }
0659:
0660: /**
0661: * @see org.apache.wicket.settings.IMarkupSettings#getStripWicketTags()
0662: */
0663: public boolean getStripWicketTags() {
0664: return stripWicketTags;
0665: }
0666:
0667: /**
0668: * @see org.apache.wicket.settings.IMarkupSettings#getStripXmlDeclarationFromOutput()
0669: */
0670: public boolean getStripXmlDeclarationFromOutput() {
0671: return stripXmlDeclarationFromOutput;
0672: }
0673:
0674: /**
0675: * @see org.apache.wicket.settings.IResourceSettings#getThrowExceptionOnMissingResource()
0676: */
0677: public boolean getThrowExceptionOnMissingResource() {
0678: return throwExceptionOnMissingResource;
0679: }
0680:
0681: /**
0682: * @see org.apache.wicket.settings.IRequestCycleSettings#getTimeout()
0683: */
0684: public Duration getTimeout() {
0685: return timeout;
0686: }
0687:
0688: /**
0689: * @see org.apache.wicket.settings.ISecuritySettings#getUnauthorizedComponentInstantiationListener()
0690: */
0691: public IUnauthorizedComponentInstantiationListener getUnauthorizedComponentInstantiationListener() {
0692: return unauthorizedComponentInstantiationListener;
0693: }
0694:
0695: /**
0696: * @see org.apache.wicket.settings.IRequestCycleSettings#getUnexpectedExceptionDisplay()
0697: */
0698: public UnexpectedExceptionDisplay getUnexpectedExceptionDisplay() {
0699: return unexpectedExceptionDisplay;
0700: }
0701:
0702: /**
0703: * @see org.apache.wicket.settings.IResourceSettings#getUseDefaultOnMissingResource()
0704: */
0705: public boolean getUseDefaultOnMissingResource() {
0706: return useDefaultOnMissingResource;
0707: }
0708:
0709: /**
0710: * @see org.apache.wicket.settings.IFrameworkSettings#getVersion()
0711: */
0712: public String getVersion() {
0713: String implVersion = null;
0714: Package pkg = getClass().getPackage();
0715: if (pkg != null) {
0716: implVersion = pkg.getImplementationVersion();
0717: }
0718: return Strings.isEmpty(implVersion) ? "n/a" : implVersion;
0719: }
0720:
0721: /**
0722: * @see org.apache.wicket.settings.IPageSettings#getVersionPagesByDefault()
0723: */
0724: public boolean getVersionPagesByDefault() {
0725: return versionPagesByDefault;
0726: }
0727:
0728: /**
0729: * @see org.apache.wicket.settings.IDebugSettings#isAjaxDebugModeEnabled()
0730: */
0731: public boolean isAjaxDebugModeEnabled() {
0732: return ajaxDebugModeEnabled;
0733: }
0734:
0735: /**
0736: * @see org.apache.wicket.settings.IApplicationSettings#setAccessDeniedPage(java.lang.Class)
0737: */
0738: public void setAccessDeniedPage(Class accessDeniedPage) {
0739: if (accessDeniedPage == null) {
0740: throw new IllegalArgumentException(
0741: "Argument accessDeniedPage may not be null");
0742: }
0743: checkPageClass(accessDeniedPage);
0744:
0745: this .accessDeniedPage = new WeakReference(accessDeniedPage);
0746: }
0747:
0748: /**
0749: * @see org.apache.wicket.settings.IDebugSettings#setAjaxDebugModeEnabled(boolean)
0750: */
0751: public void setAjaxDebugModeEnabled(boolean enable) {
0752: ajaxDebugModeEnabled = enable;
0753: }
0754:
0755: /**
0756: * @see org.apache.wicket.settings.ISecuritySettings#setAuthorizationStrategy(org.apache.wicket.authorization.IAuthorizationStrategy)
0757: */
0758: public void setAuthorizationStrategy(IAuthorizationStrategy strategy) {
0759: if (strategy == null) {
0760: throw new IllegalArgumentException(
0761: "authorization strategy cannot be set to null");
0762: }
0763: authorizationStrategy = strategy;
0764: }
0765:
0766: /**
0767: * @see org.apache.wicket.settings.IMarkupSettings#setAutomaticLinking(boolean)
0768: */
0769: public void setAutomaticLinking(boolean automaticLinking) {
0770: this .automaticLinking = automaticLinking;
0771: }
0772:
0773: /**
0774: * @see org.apache.wicket.settings.IPageSettings#setAutomaticMultiWindowSupport(boolean)
0775: */
0776: public void setAutomaticMultiWindowSupport(
0777: boolean automaticMultiWindowSupport) {
0778: this .automaticMultiWindowSupport = automaticMultiWindowSupport;
0779: }
0780:
0781: /**
0782: * @see org.apache.wicket.settings.IRequestCycleSettings#setBufferResponse(boolean)
0783: */
0784: public void setBufferResponse(boolean bufferResponse) {
0785: this .bufferResponse = bufferResponse;
0786: }
0787:
0788: /**
0789: * @see org.apache.wicket.settings.IApplicationSettings#setClassResolver(org.apache.wicket.application.IClassResolver)
0790: */
0791: public void setClassResolver(
0792: final IClassResolver defaultClassResolver) {
0793: classResolver = defaultClassResolver;
0794: }
0795:
0796: /**
0797: * @see org.apache.wicket.settings.IDebugSettings#setComponentUseCheck(boolean)
0798: */
0799: public void setComponentUseCheck(final boolean componentUseCheck) {
0800: this .componentUseCheck = componentUseCheck;
0801: }
0802:
0803: /**
0804: * @see org.apache.wicket.settings.IMarkupSettings#setCompressWhitespace(boolean)
0805: */
0806: public void setCompressWhitespace(final boolean compressWhitespace) {
0807: this .compressWhitespace = compressWhitespace;
0808: }
0809:
0810: /**
0811: * @see org.apache.wicket.settings.ISecuritySettings#setCookieValuePersisterSettings(org.apache.wicket.markup.html.form.persistence.CookieValuePersisterSettings)
0812: */
0813: public void setCookieValuePersisterSettings(
0814: CookieValuePersisterSettings cookieValuePersisterSettings) {
0815: this .cookieValuePersisterSettings = cookieValuePersisterSettings;
0816: }
0817:
0818: /**
0819: * @see org.apache.wicket.settings.ISecuritySettings#setCryptFactory(org.apache.wicket.util.crypt.ICryptFactory)
0820: */
0821: public void setCryptFactory(ICryptFactory cryptFactory) {
0822: if (cryptFactory == null) {
0823: throw new IllegalArgumentException(
0824: "cryptFactory cannot be null");
0825: }
0826: this .cryptFactory = cryptFactory;
0827: }
0828:
0829: /**
0830: * @see org.apache.wicket.settings.IMarkupSettings#setDefaultAfterDisabledLink(java.lang.String)
0831: */
0832: public void setDefaultAfterDisabledLink(
0833: final String defaultAfterDisabledLink) {
0834: this .defaultAfterDisabledLink = defaultAfterDisabledLink;
0835: }
0836:
0837: /**
0838: * @see org.apache.wicket.settings.IMarkupSettings#setDefaultBeforeDisabledLink(java.lang.String)
0839: */
0840: public void setDefaultBeforeDisabledLink(
0841: String defaultBeforeDisabledLink) {
0842: this .defaultBeforeDisabledLink = defaultBeforeDisabledLink;
0843: }
0844:
0845: /**
0846: * @see org.apache.wicket.settings.IMarkupSettings#setDefaultMarkupEncoding(java.lang.String)
0847: */
0848: public void setDefaultMarkupEncoding(final String encoding) {
0849: defaultMarkupEncoding = encoding;
0850: }
0851:
0852: /**
0853: * @see org.apache.wicket.settings.IResourceSettings#setDisableGZipCompression(boolean)
0854: */
0855: public void setDisableGZipCompression(boolean disableGZipCompression) {
0856: this .disableGZipCompression = disableGZipCompression;
0857: }
0858:
0859: /**
0860: * @see wicket.settings.ISecuritySettings#setEnforceMounts(boolean)
0861: */
0862: public void setEnforceMounts(boolean enforce) {
0863: enforceMounts = enforce;
0864: }
0865:
0866: /**
0867: * @see org.apache.wicket.settings.IRequestCycleSettings#setGatherExtendedBrowserInfo(boolean)
0868: */
0869: public void setGatherExtendedBrowserInfo(
0870: boolean gatherExtendedBrowserInfo) {
0871: this .gatherExtendedBrowserInfo = gatherExtendedBrowserInfo;
0872: }
0873:
0874: /**
0875: * @see org.apache.wicket.settings.IApplicationSettings#setInternalErrorPage(java.lang.Class)
0876: */
0877: public void setInternalErrorPage(final Class internalErrorPage) {
0878: if (internalErrorPage == null) {
0879: throw new IllegalArgumentException(
0880: "Argument internalErrorPage may not be null");
0881: }
0882: checkPageClass(internalErrorPage);
0883:
0884: this .internalErrorPage = new WeakReference(internalErrorPage);
0885: }
0886:
0887: /**
0888: * @see org.apache.wicket.settings.IMarkupSettings#setMarkupParserFactory(org.apache.wicket.markup.IMarkupParserFactory)
0889: */
0890: public void setMarkupParserFactory(IMarkupParserFactory factory) {
0891: if (factory == null) {
0892: throw new IllegalArgumentException(
0893: "markup parser factory cannot be null");
0894: }
0895:
0896: markupParserFactory = factory;
0897: }
0898:
0899: /**
0900: * @see org.apache.wicket.settings.ISessionSettings#setMaxPageMaps(int)
0901: */
0902: public final void setMaxPageMaps(int maxPageMaps) {
0903: this .maxPageMaps = maxPageMaps;
0904: }
0905:
0906: /**
0907: * @see org.apache.wicket.settings.IResourceSettings#setPackageResourceGuard(org.apache.wicket.markup.html.IPackageResourceGuard)
0908: */
0909: public void setPackageResourceGuard(
0910: IPackageResourceGuard packageResourceGuard) {
0911: if (packageResourceGuard == null) {
0912: throw new IllegalArgumentException(
0913: "Argument packageResourceGuard may not be null");
0914: }
0915: this .packageResourceGuard = packageResourceGuard;
0916: }
0917:
0918: /**
0919: * @see org.apache.wicket.settings.IApplicationSettings#setPageExpiredErrorPage(java.lang.Class)
0920: */
0921: public void setPageExpiredErrorPage(final Class pageExpiredErrorPage) {
0922: if (pageExpiredErrorPage == null) {
0923: throw new IllegalArgumentException(
0924: "Argument pageExpiredErrorPage may not be null");
0925: }
0926: checkPageClass(pageExpiredErrorPage);
0927:
0928: this .pageExpiredErrorPage = new WeakReference(
0929: pageExpiredErrorPage);
0930: }
0931:
0932: /**
0933: * @see org.apache.wicket.settings.ISessionSettings#setPageFactory(org.apache.wicket.IPageFactory)
0934: */
0935: public void setPageFactory(final IPageFactory defaultPageFactory) {
0936: pageFactory = defaultPageFactory;
0937: }
0938:
0939: /**
0940: * @see org.apache.wicket.settings.ISessionSettings#setPageMapEvictionStrategy(org.apache.wicket.session.pagemap.IPageMapEvictionStrategy)
0941: */
0942: public void setPageMapEvictionStrategy(
0943: IPageMapEvictionStrategy pageMapEvictionStrategy) {
0944: this .pageMapEvictionStrategy = pageMapEvictionStrategy;
0945: }
0946:
0947: /**
0948: * @see org.apache.wicket.settings.IResourceSettings#setPropertiesFactory(org.apache.wicket.resource.PropertiesFactory)
0949: */
0950: public void setPropertiesFactory(
0951: org.apache.wicket.resource.IPropertiesFactory factory) {
0952: propertiesFactory = factory;
0953: }
0954:
0955: /**
0956: * @see org.apache.wicket.settings.IRequestCycleSettings#setRenderStrategy(org.apache.wicket.settings.Settings.RenderStrategy)
0957: */
0958: public void setRenderStrategy(
0959: IRequestCycleSettings.RenderStrategy renderStrategy) {
0960: this .renderStrategy = renderStrategy;
0961: }
0962:
0963: /**
0964: * @see org.apache.wicket.settings.IResourceSettings#setResourceFinder(org.apache.wicket.util.file.IResourceFinder)
0965: */
0966: public void setResourceFinder(final IResourceFinder resourceFinder) {
0967: this .resourceFinder = resourceFinder;
0968:
0969: // Cause resource locator to get recreated
0970: resourceStreamLocator = null;
0971: }
0972:
0973: /**
0974: * @see org.apache.wicket.settings.IResourceSettings#setResourcePollFrequency(org.apache.wicket.util.time.Duration)
0975: */
0976: public void setResourcePollFrequency(
0977: final Duration resourcePollFrequency) {
0978: this .resourcePollFrequency = resourcePollFrequency;
0979: }
0980:
0981: /**
0982: * @see org.apache.wicket.settings.IResourceSettings#setResourceStreamLocator(org.apache.wicket.util.resource.locator.IResourceStreamLocator)
0983: */
0984: public void setResourceStreamLocator(
0985: IResourceStreamLocator resourceStreamLocator) {
0986: this .resourceStreamLocator = resourceStreamLocator;
0987: }
0988:
0989: /**
0990: * @see org.apache.wicket.settings.IRequestCycleSettings#setResponseRequestEncoding(java.lang.String)
0991: */
0992: public void setResponseRequestEncoding(
0993: final String responseRequestEncoding) {
0994: this .responseRequestEncoding = responseRequestEncoding;
0995: }
0996:
0997: /**
0998: * @see org.apache.wicket.settings.IMarkupSettings#setStripComments(boolean)
0999: */
1000: public void setStripComments(boolean stripComments) {
1001: this .stripComments = stripComments;
1002: }
1003:
1004: /**
1005: * @see org.apache.wicket.settings.IMarkupSettings#setStripWicketTags(boolean)
1006: */
1007: public void setStripWicketTags(boolean stripWicketTags) {
1008: this .stripWicketTags = stripWicketTags;
1009: }
1010:
1011: /**
1012: * @see org.apache.wicket.settings.IMarkupSettings#setStripXmlDeclarationFromOutput(boolean)
1013: */
1014: public void setStripXmlDeclarationFromOutput(final boolean strip) {
1015: stripXmlDeclarationFromOutput = strip;
1016: }
1017:
1018: /**
1019: * @see org.apache.wicket.settings.IResourceSettings#setThrowExceptionOnMissingResource(boolean)
1020: */
1021: public void setThrowExceptionOnMissingResource(
1022: final boolean throwExceptionOnMissingResource) {
1023: this .throwExceptionOnMissingResource = throwExceptionOnMissingResource;
1024: }
1025:
1026: /**
1027: * @see org.apache.wicket.settings.IRequestCycleSettings#setTimeout(org.apache.wicket.util.time.Duration)
1028: */
1029: public void setTimeout(Duration timeout) {
1030: if (timeout == null) {
1031: throw new IllegalArgumentException("timeout cannot be null");
1032: }
1033: this .timeout = timeout;
1034: }
1035:
1036: /**
1037: * @see org.apache.wicket.settings.ISecuritySettings#setUnauthorizedComponentInstantiationListener(org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener)
1038: */
1039: public void setUnauthorizedComponentInstantiationListener(
1040: IUnauthorizedComponentInstantiationListener unauthorizedComponentInstantiationListener) {
1041: this .unauthorizedComponentInstantiationListener = unauthorizedComponentInstantiationListener;
1042: }
1043:
1044: /**
1045: * @see org.apache.wicket.settings.IRequestCycleSettings#setUnexpectedExceptionDisplay(org.apache.wicket.settings.Settings.UnexpectedExceptionDisplay)
1046: */
1047: public void setUnexpectedExceptionDisplay(
1048: final UnexpectedExceptionDisplay unexpectedExceptionDisplay) {
1049: this .unexpectedExceptionDisplay = unexpectedExceptionDisplay;
1050: }
1051:
1052: /**
1053: * @see org.apache.wicket.settings.IResourceSettings#setUseDefaultOnMissingResource(boolean)
1054: */
1055: public void setUseDefaultOnMissingResource(
1056: final boolean useDefaultOnMissingResource) {
1057: this .useDefaultOnMissingResource = useDefaultOnMissingResource;
1058: }
1059:
1060: /**
1061: * @see org.apache.wicket.settings.IPageSettings#setVersionPagesByDefault(boolean)
1062: */
1063: public void setVersionPagesByDefault(boolean pagesVersionedByDefault) {
1064: versionPagesByDefault = pagesVersionedByDefault;
1065: }
1066:
1067: /**
1068: * Throws an IllegalArgumentException if the given class is not a subclass of Page.
1069: *
1070: * @param pageClass
1071: * the page class to check
1072: */
1073: private void checkPageClass(final Class pageClass) {
1074: // NOTE: we can't really check on whether it is a bookmarkable page
1075: // here, as - though the default is that a bookmarkable page must
1076: // either have a default constructor and/or a constructor with a
1077: // PageParameters object, this could be different for another
1078: // IPageFactory implementation
1079: if (!Page.class.isAssignableFrom(pageClass)) {
1080: throw new IllegalArgumentException("argument " + pageClass
1081: + " must be a subclass of Page");
1082: }
1083: }
1084:
1085: /**
1086: * @see org.apache.wicket.settings.IRequestLoggerSettings#getRecordSessionSize()
1087: */
1088: public boolean getRecordSessionSize() {
1089: return recordSessionSize;
1090: }
1091:
1092: /**
1093: * @see org.apache.wicket.settings.IRequestLoggerSettings#getRequestsWindowSize()
1094: */
1095: public int getRequestsWindowSize() {
1096: return requestsWindowSize;
1097: }
1098:
1099: /**
1100: * @see org.apache.wicket.settings.IRequestLoggerSettings#isRequestLoggerEnabled()
1101: */
1102: public boolean isRequestLoggerEnabled() {
1103: return requestLoggerEnabled;
1104: }
1105:
1106: /**
1107: * @see org.apache.wicket.settings.IRequestLoggerSettings#setRecordSessionSize(boolean)
1108: */
1109: public void setRecordSessionSize(boolean record) {
1110: recordSessionSize = record;
1111: }
1112:
1113: /**
1114: * @see org.apache.wicket.settings.IRequestLoggerSettings#setRequestLoggerEnabled(boolean)
1115: */
1116: public void setRequestLoggerEnabled(boolean enable) {
1117: requestLoggerEnabled = enable;
1118: }
1119:
1120: /**
1121: * @see org.apache.wicket.settings.IRequestLoggerSettings#setRequestsWindowSize(int)
1122: */
1123: public void setRequestsWindowSize(int size) {
1124: requestsWindowSize = size;
1125: }
1126:
1127: /**
1128: * @see org.apache.wicket.settings.IResourceSettings#getStripJavascriptCommentsAndWhitespace()
1129: */
1130: public boolean getStripJavascriptCommentsAndWhitespace() {
1131: return stripJavascriptCommentsAndWhitespace;
1132: }
1133:
1134: /**
1135: * @see org.apache.wicket.settings.IResourceSettings#setStripJavascriptCommentsAndWhitespace(boolean)
1136: */
1137: public void setStripJavascriptCommentsAndWhitespace(boolean value) {
1138: stripJavascriptCommentsAndWhitespace = value;
1139: }
1140:
1141: /**
1142: * @see org.apache.wicket.settings.IDebugSettings#setOutputMarkupContainerClassName(boolean)
1143: */
1144: public void setOutputMarkupContainerClassName(boolean enable) {
1145: outputMarkupContainerClassName = enable;
1146: }
1147:
1148: /**
1149: * @see org.apache.wicket.settings.IDebugSettings#isOutputMarkupContainerClassName()
1150: */
1151: public boolean isOutputMarkupContainerClassName() {
1152: return outputMarkupContainerClassName;
1153: }
1154:
1155: /**
1156: * @see org.apache.wicket.settings.IMarkupSettings#getMarkupCache()
1157: */
1158: public IMarkupCache getMarkupCache() {
1159: if (markupCache == null) {
1160: // Construct markup cache for this application
1161: markupCache = new MarkupCache(application);
1162: }
1163:
1164: return markupCache;
1165: }
1166:
1167: /**
1168: * @see org.apache.wicket.settings.IMarkupSettings#setMarkupCache(org.apache.wicket.markup.MarkupCache)
1169: */
1170: public void setMarkupCache(final IMarkupCache markupCache) {
1171: this .markupCache = markupCache;
1172: }
1173:
1174: private Bytes defaultMaximumUploadSize = Bytes.MAX;
1175:
1176: public Bytes getDefaultMaximumUploadSize() {
1177: return defaultMaximumUploadSize;
1178: }
1179:
1180: public void setDefaultMaximumUploadSize(
1181: Bytes defaultMaximumUploadSize) {
1182: this .defaultMaximumUploadSize = defaultMaximumUploadSize;
1183: }
1184:
1185: public void setPageIdUniquePerSession(boolean value) {
1186: pageIdUniquePerSession = value;
1187: }
1188:
1189: public boolean isPageIdUniquePerSession() {
1190: return pageIdUniquePerSession;
1191: }
1192:
1193: public boolean isLinePreciseReportingOnAddComponentEnabled() {
1194: return linePreciseReportingOnAddComponentEnabled;
1195: }
1196:
1197: public boolean isLinePreciseReportingOnNewComponentEnabled() {
1198: return linePreciseReportingOnNewComponentEnabled;
1199: }
1200:
1201: public void setLinePreciseReportingOnAddComponentEnabled(
1202: boolean enable) {
1203: linePreciseReportingOnAddComponentEnabled = enable;
1204: }
1205:
1206: public void setLinePreciseReportingOnNewComponentEnabled(
1207: boolean enable) {
1208: linePreciseReportingOnNewComponentEnabled = enable;
1209: }
1210: }
|