configuration.java
来自「非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应」· Java 代码 · 共 1,073 行 · 第 1/3 页
JAVA
1,073 行
for (Iterator it = _evtSusps.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((EventThreadSuspend)klass.newInstance()) .beforeSuspend(comp, evt, obj); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); //Don't intercept; to prevent the thread to suspend } } } } /** Contructs a list of {@link EventThreadResume} instances and invokes * {@link EventThreadResume#beforeResume} for each relevant * listener registered by {@link #addListener}. * * <p>It is called by UiEngine when resuming a suspended event thread. * Notice: it executes in the main thread (i.e., the servlet thread). * * @param comp the component which the event is targeting * @param evt the event to process * @exception UiException to prevent a thread from being resumed * if {@link EventThreadResume#beforeResume} throws an exception * @return a list of {@link EventThreadResume} instances that are constructed * in this method (and their {@link EventThreadResume#beforeResume} * are called successfully). */ public List newEventThreadResumes(Component comp, Event evt) throws UiException { if (_evtResus.isEmpty()) return Collections.EMPTY_LIST; //it is OK to test LinkedList.isEmpty without synchronized final List resumes = new LinkedList(); synchronized (_evtResus) { for (Iterator it = _evtResus.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { final EventThreadResume resume = (EventThreadResume)klass.newInstance(); resume.beforeResume(comp, evt); resumes.add(resume); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); //Don't intercept; to prevent the event being resumed } } } return resumes; } /** Invokes {@link EventThreadResume#afterResume} for each instance returned * by {@link #newEventThreadResumes}. * * <p>It never throws an exception but logs and adds it to the errs argument, * if not null. * * @param resumes a list of {@link EventThreadResume} instances returned from * {@link #newEventThreadResumes}, or null if no instance at all. * @param comp the component which the event is targeting * @param evt the event to process * @param errs used to hold the exceptions that are thrown by * {@link EventThreadResume#afterResume}. * If null, all exceptions are ignored (but logged) */ public void invokeEventThreadResumes(List resumes, Component comp, Event evt, List errs) { if (resumes == null || resumes.isEmpty()) return; for (Iterator it = resumes.iterator(); it.hasNext();) { final EventThreadResume fn = (EventThreadResume)it.next(); try { fn.afterResume(comp, evt); } catch (Throwable ex) { if (errs != null) errs.add(ex); log.error("Failed to invoke "+fn+" after resumed", ex); } } } /** Invokes {@link EventThreadResume#abortResume} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link EventThreadResume} is constructed first, * and then invoke {@link EventThreadResume#abortResume}. * * <p>It never throws an exception but logging. * * @param comp the component which the event is targeting * @param evt the event to process */ public void invokeEventThreadResumeAborts(Component comp, Event evt) { if (_evtResus.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_evtResus) { for (Iterator it = _evtResus.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((EventThreadResume)klass.newInstance()) .abortResume(comp, evt); } catch (Throwable ex) { log.error("Failed to invoke "+klass+" for aborting", ex); } } } } /** Invokes {@link WebAppInit#init} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link WebAppInit} is constructed first, * and then invoke {@link WebAppInit#init}. * * <p>Unlike {@link #invokeWebAppInits}, it doesn't throw any exceptions. * Rather, it only logs them. */ public void invokeWebAppInits() throws UiException { if (_appInits.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_appInits) { for (Iterator it = _appInits.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((WebAppInit)klass.newInstance()).init(_wapp); } catch (Throwable ex) { log.error("Failed to invoke "+klass, ex); } } } } /** Invokes {@link WebAppCleanup#cleanup} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link WebAppCleanup} is constructed first, * and then invoke {@link WebAppCleanup#cleanup}. * * <p>It never throws an exception. */ public void invokeWebAppCleanups() { if (_appCleans.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_appCleans) { for (Iterator it = _appCleans.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((WebAppCleanup)klass.newInstance()).cleanup(_wapp); } catch (Throwable ex) { log.error("Failed to invoke "+klass, ex); } } } } /** Invokes {@link SessionInit#init} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link SessionInit} is constructed first, * and then invoke {@link SessionInit#init}. * * @param sess the session that is created * @exception UiException to prevent a session from being created */ public void invokeSessionInits(Session sess) throws UiException { if (_sessInits.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_sessInits) { for (Iterator it = _sessInits.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((SessionInit)klass.newInstance()).init(sess); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); //Don't intercept; to prevent the creation of a session } } } } /** Invokes {@link SessionCleanup#cleanup} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link SessionCleanup} is constructed first, * and then invoke {@link SessionCleanup#cleanup}. * * <p>It never throws an exception. * * @param sess the session that is being destroyed */ public void invokeSessionCleanups(Session sess) { if (_sessCleans.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_sessCleans) { for (Iterator it = _sessCleans.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((SessionCleanup)klass.newInstance()).cleanup(sess); } catch (Throwable ex) { log.error("Failed to invoke "+klass, ex); } } } } /** Invokes {@link DesktopInit#init} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link DesktopInit} is constructed first, * and then invoke {@link DesktopInit#init}. * * @param desktop the desktop that is created * @exception UiException to prevent a desktop from being created */ public void invokeDesktopInits(Desktop desktop) throws UiException { if (_dtInits.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_dtInits) { for (Iterator it = _dtInits.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((DesktopInit)klass.newInstance()).init(desktop); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); //Don't intercept; to prevent the creation of a session } } } } /** Invokes {@link DesktopCleanup#cleanup} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link DesktopCleanup} is constructed first, * and then invoke {@link DesktopCleanup#cleanup}. * * <p>It never throws an exception. * * @param desktop the desktop that is being destroyed */ public void invokeDesktopCleanups(Desktop desktop) { if (_dtCleans.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_dtCleans) { for (Iterator it = _dtCleans.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((DesktopCleanup)klass.newInstance()).cleanup(desktop); } catch (Throwable ex) { log.error("Failed to invoke "+klass, ex); } } } } /** Invokes {@link ExecutionInit#init} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link ExecutionInit} is constructed first, * and then invoke {@link ExecutionInit#init}. * * @param exec the execution that is created * @param parent the previous execution, or null if no previous at all * @exception UiException to prevent an execution from being created */ public void invokeExecutionInits(Execution exec, Execution parent) throws UiException { if (_execInits.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_execInits) { for (Iterator it = _execInits.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((ExecutionInit)klass.newInstance()).init(exec, parent); } catch (Throwable ex) { throw UiException.Aide.wrap(ex); //Don't intercept; to prevent the creation of a session } } } } /** Invokes {@link ExecutionCleanup#cleanup} for each relevant * listener registered by {@link #addListener}. * * <p>An instance of {@link ExecutionCleanup} is constructed first, * and then invoke {@link ExecutionCleanup#cleanup}. * * <p>It never throws an exception but logs and adds it to the errs argument, * if not null. * * @param exec the execution that is being destroyed * @param parent the previous execution, or null if no previous at all * @param ex the first exception being thrown (and not handled) during the * execution, or null it is executed successfully. * @param errs used to hold the exceptions that are thrown by * {@link ExecutionCleanup#cleanup}. * If null, all exceptions are ignored (but logged) */ public void invokeExecutionCleanups(Execution exec, Execution parent, Throwable ex, List errs) { if (_execCleans.isEmpty()) return; //it is OK to test LinkedList.isEmpty without synchronized synchronized (_execCleans) { for (Iterator it = _execCleans.iterator(); it.hasNext();) { final Class klass = (Class)it.next(); try { ((ExecutionCleanup)klass.newInstance()).cleanup(exec, parent, ex); } catch (Throwable t) { if (errs != null) errs.add(t); log.error("Failed to invoke "+klass, t); } } } } /** Adds an CSS resource that will be generated for each ZUML desktop. */ public void addThemeURI(String uri) { if (uri == null || uri.length() == 0) throw new IllegalArgumentException("empty"); synchronized (_themeUris) { _themeUris.add(uri); _roThemeUris = (String[])_themeUris.toArray(new String[_themeUris.size()]); } } /** Returns a readonly list of the URI of the CSS resources that will be * generated for each ZUML desktop (never null). * * <p>Default: an array with zero length. */ public String[] getThemeURIs() { return _roThemeUris; } /** Sets the URI that is used when the session timeout or * desktop is no longer available. * * @param uri the URI used if timeout, or null to show an error message * at the client only. If empty, it works as reloading the same URI again. */ public void setTimeoutURI(String uri) { _timeoutUri = uri; } /** Sets the URI that is used when the session timeout or * desktop is no longer available, or null. * * <p>Default: null. * * <p>If null is returned, an message is shown up at the client. * If empty, it works as reloading the same URI again. * If non null, the browser will be redirected to the returned URI. */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?