configuration.java

来自「非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应」· Java 代码 · 共 1,073 行 · 第 1/3 页

JAVA
1,073
字号
	public String getTimeoutURI() {		return _timeoutUri;	}	/** Sets the class for implementing {@link LocaleProvider}, or null to	 * use the default.	 */	public void setLocaleProviderClass(Class cls) {		if (cls != null && !LocaleProvider.class.isAssignableFrom(cls))			throw new IllegalArgumentException("LocaleProvider not implemented: "+cls);		_lpcls = cls;	}	/** Returns the class for implementing {@link LocaleProvider}, or null for default.	 */	public Class getLocaleProviderClass() {		return _lpcls;	}	/** Sets the class for implementing {@link TimeZoneProvider}, or null to	 * use the default.	 */	public void setTimeZoneProviderClass(Class cls) {		if (cls != null && !TimeZoneProvider.class.isAssignableFrom(cls))			throw new IllegalArgumentException("TimeZoneProvider not implemented: "+cls);		_tzpcls = cls;	}	/** Returns the class for implementing {@link TimeZoneProvider}, or null for default.	 */	public Class getTimeZoneProviderClass() {		return _tzpcls;	}	/** Sets the class for implementing {@link UiEngine}, or null to	 * use the default.	 */	public void setUiEngineClass(Class cls) {		if (cls != null && !UiEngine.class.isAssignableFrom(cls))			throw new IllegalArgumentException("UiEngine not implemented: "+cls);		_uiengcls = cls;	}	/** Returns the class for implementing {@link UiEngine}, or null for default.	 */	public Class getUiEngineClass() {		return _uiengcls;	}	/** Sets the class for implementing {@link DesktopCacheProvider}, or null to	 * use the default.	 */	public void setDesktopCacheProviderClass(Class cls) {		if (cls != null && !DesktopCacheProvider.class.isAssignableFrom(cls))			throw new IllegalArgumentException("DesktopCacheProvider not implemented: "+cls);		_dcpcls = cls;	}	/** Returns the class for implementing the UI engine, or null for default.	 */	public Class getDesktopCacheProviderClass() {		return _dcpcls;	}	/** Sets the class for implementing {@link UiFactory}, or null to	 * use the default.	 */	public void setUiFactoryClass(Class cls) {		if (cls != null && !UiFactory.class.isAssignableFrom(cls))			throw new IllegalArgumentException("UiFactory not implemented: "+cls);		_uiftycls = cls;	}	/** Returns the class for implementing the UI engine, or null for default.	 */	public Class getUiFactoryClass() {		return _uiftycls;	}	/** Specifies the maximal allowed upload size, in kilobytes.	 * <p>Default: 5120.	 * @param sz the maximal allowed upload size. If null, there is no	 * limitation.	 */	public void setMaxUploadSize(Integer sz) {		_maxUploadSize = sz;	}	/** Returns the maximal allowed upload size, in kilobytes, or null	 * if no limiatation.	 */	public Integer getMaxUploadSize() {		return _maxUploadSize;	}	/** Specifies the time, in seconds, between client requests	 * before ZK will invalidate the desktop, or null for default (1 hour).	 */	public void setDesktopMaxInactiveInterval(Integer secs) {		_dtTimeout = secs;	}	/** Returns the time, in seconds, between client requests	 * before ZK will invalidate the desktop, or null for default.	 */	public Integer getDesktopMaxInactiveInterval() {		return _dtTimeout;	}	/**  Specifies the time, in seconds, between client requests	 * before ZK will invalidate the session, or null for default.	 */	public void setSessionMaxInactiveInterval(Integer secs) {		_sessTimeout = secs;	}	/** Returns the time, in seconds, between client requests	 * before ZK will invalidate the session, or null for default.	 */	public Integer getSessionMaxInactiveInterval() {		return _sessTimeout;	}	/** Specifies the maximal allowed number of desktop	 * per session, or null for default (10).	 */	public void setMaxDesktops(Integer max) {		_dtMax = max;	}	/** Returns the maximal allowed number of desktop	 * per session, or null for default (10).	 */	public Integer getMaxDesktops() {		return _dtMax;	}	/** Specifies the maximal allowed number of event processing threads	 * per Web application, or null for default (100).	 */	public void setMaxEventThreads(Integer max) {		_evtThdMax = max;	}	/** Returns the maximal allowed number of event processing threads	 * per Web application, or null for default (100).	 */	public Integer getMaxEventThreads() {		return _evtThdMax;	}	/** Returns the monitor for this application, or null if not set.	 */	public Monitor getMonitor() {		return _monitor;	}	/** Sets the monitor for this application, or null to disable it.	 *	 * <p>In addition to call this method, you could specify a monitor	 * in web.xml.	 */	public void setMonitor(Monitor monitor) {		_monitor = monitor;	}	/** Returns the charset used by {@link org.zkoss.zk.ui.http.DHtmlLayoutServlet},	 * or null to use the container's default.	 * <p>Default: UTF-8.	 */	public String getCharset() {		return _charset;	}	/** Sets the charset used by {@link org.zkoss.zk.ui.http.DHtmlLayoutServlet}.	 *	 * @param charset the charset to use. If null or empty, the container's default	 * is used.	 */	public void setCharset(String charset) {		_charset = charset != null && charset.length() > 0 ? charset: null;	}	/** Returns the value of the preference defined in zk.xml, or by	 * {@link #setPreference}.	 *	 * <p>Preference is application specific. You can specify whatever you want	 * as you specifying context-param for a Web application.	 *	 * @param defaultValue the default value that is used if the specified	 * preference is not found.	 */	public String getPreference(String name, String defaultValue) {		final String value = (String)_prefs.get(name);		return value != null ? value: defaultValue;	}	/** Sets the value of the preference.	 */	public void setPreference(String name, String value) {		if (name == null || value == null)			throw new IllegalArgumentException("null");		_prefs.put(name, value);	}	/** Returns a set of all preference names.	 */	public Set getPreferenceNames() {		return _prefs.keySet();	}	/** Adds a richlet with its class.	 *	 * @param params the initial parameters, or null if no initial parameter at all.	 * Once called, the caller cannot access <code>params</code> any more.	 * @return the previous richlet class or class-name with the specified path,	 * or null if no previous richlet.	 */	public Object addRichlet(String path, Class richletClass, Map params) {		if (!Richlet.class.isAssignableFrom(richletClass))			throw new IllegalArgumentException("A richlet class, "+richletClass+", must implement "+Richlet.class.getName());		return addRichlet0(path, richletClass, params);	}	/** Adds a richlet with its class name.	 *	 *	 * @param params the initial parameters, or null if no initial parameter at all.	 * Once called, the caller cannot access <code>params</code> any more.	 * @return the previous richlet class or class-name with the specified path,	 * or null if no previous richlet.	 */	public Object addRichlet(String path, String richletClassName, Map params) {		if (richletClassName == null || richletClassName.length() == 0)			throw new IllegalArgumentException("richletClassName is required");		return addRichlet0(path, richletClassName, params);	}	private Object addRichlet0(String path, Object richletClass, Map params) {		//richletClass was checked before calling this method		if (path == null || !path.startsWith("/"))			throw new IllegalArgumentException("path must start with '/', not "+path);		final Object o;		synchronized (_richlets) {			o = _richlets.put(path, new Object[] {richletClass, params});		}		if (o == null)			return null;		if (o instanceof Richlet) {			destroy((Richlet)o);			return o.getClass();		}		return ((Object[])o)[0];	}	private static void destroy(Richlet richlet) {		try {			richlet.destroy();		} catch (Throwable ex) {			log.error("Unable to destroy "+richlet);		}	}	/** Returns an instance of richlet for the specified path, or null if not found.	 */	public Richlet getRichlet(String path) {		WaitLock lock = null;		final Object[] info;		for (;;) {			synchronized (_richlets) {				Object o = _richlets.get(path);				if (o == null || (o instanceof Richlet)) { //loaded or not found					return (Richlet)o;				} else if (o instanceof WaitLock) { //loading by another thread					lock = (WaitLock)o;				} else { //going to load in this thread					info = (Object[])o;					_richlets.put(path, lock = new WaitLock());					break; //then, load it				}			} //sync(_richlets)			if (!lock.waitUntilUnlock(300*1000)) { //5 minute				final PotentialDeadLockException ex =					new PotentialDeadLockException(					"Unable to load from "+path+"\nCause: conflict too long.");				log.warningBriefly(ex); //very rare, possibly a bug				throw ex;			}		} //for (;;)		//load it		try {			if (info[0] instanceof String) {				try {					info[0] = Classes.forNameByThread((String)info[0]);				} catch (Throwable ex) {					throw new UiException("Failed to load "+info[0]);				}			}			final Object o = ((Class)info[0]).newInstance();			if (!(o instanceof Richlet))				throw new UiException(Richlet.class+" must be implemented by "+info[0]);			final Richlet richlet = (Richlet)o;			richlet.init(new RichletConfigImpl(_wapp, (Map)info[1]));			synchronized (_richlets) {				_richlets.put(path, richlet);			}			return richlet;		} catch (Throwable ex) {			synchronized (_richlets) {				_richlets.put(path, info); //remove lock and restore info			}			throw UiException.Aide.wrap(ex, "Unable to instantiate "+info[0]);		} finally {			lock.unlock();		}	}	/** Destroyes all richlets.	 */	public void detroyRichlets() {		synchronized (_richlets) {			for (Iterator it = _richlets.values().iterator(); it.hasNext();) {				final Object o = it.next();				if (o instanceof Richlet)					destroy((Richlet)o);			}			_richlets.clear();		}	}	/** Adds an error page.	 *	 * @param type what type of errors the error page is associated with.	 * @param location where is the error page.	 */	public void addErrorPage(Class type, String location) {		if (!Throwable.class.isAssignableFrom(type))			throw new IllegalArgumentException("Throwable or derived is required: "+type);		if (location == null)			throw new IllegalArgumentException("location required");		synchronized (_errpgs) {			_errpgs.add(new ErrorPage(type, location));		}	}	/** Returns the error page that matches the specified error, or null if not found.	 */	public String getErrorPage(Throwable error) {		if (!_errpgs.isEmpty()) {			synchronized (_errpgs) {				for (Iterator it = _errpgs.iterator(); it.hasNext();) {					final ErrorPage errpg = (ErrorPage)it.next();					if (errpg.type.isInstance(error))						return errpg.location;				}			}		}		return null;	}	private static class ErrorPage {		private final Class type;		private final String location;		private ErrorPage(Class type, String location) {			this.type = type;			this.location = location;		}	};}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?