applicationconfig.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 609 行 · 第 1/2 页

JAVA
609
字号
  public void setLocaleConfig(LocaleConfig config)  {    _localeConfig = config;  }  public void configure(ApplicationImpl app)  {    if (_messageBundle != null)      app.setMessageBundle(_messageBundle);        if (_localeConfig != null)      _localeConfig.configure(app);    if (_defaultRenderKitId != null)      app.setDefaultRenderKitId(_defaultRenderKitId);     if (_actionListener != null) {      ActionListener listener = null;            try {	Constructor ctor	  = _actionListener.getConstructor(new Class [] { ActionListener.class });	ActionListener oldListener = app.getActionListener();	listener = (ActionListener) ctor.newInstance(oldListener);      }      catch (NoSuchMethodException e) {      }      catch (RuntimeException e) {	throw e;      } catch (Exception e) {	throw ConfigException.create(e);      }      if (listener == null) {	try {	  listener = (ActionListener) _actionListener.newInstance();	}	catch (RuntimeException e) {	  throw e;	}	catch (Exception e) {	  throw ConfigException.create(e);	}      }      if (listener != null) {	app.setActionListener(listener);	log.fine(L.l("JSF[] using '{0}' as action-listener", listener));      }    }    if (_viewHandler != null) {      ViewHandler handler = null;            try {        Constructor ctor          = _viewHandler.getConstructor(new Class[] { ViewHandler.class });                ViewHandler oldHandler = app.getViewHandler();        handler = (ViewHandler) ctor.newInstance(oldHandler);      } catch (NoSuchMethodException e) {      } catch (RuntimeException e) {        throw e;      } catch (Exception e) {        throw ConfigException.create(e);      }      if (handler == null) {        try {          handler = (ViewHandler) _viewHandler.newInstance();        } catch (RuntimeException e) {          throw e;        } catch (Exception e) {          throw ConfigException.create(e);        }      }      if (handler != null) {        app.setViewHandler(handler);	log.fine(L.l("JSF[] using '{0}' as view-handler", handler));      }    }    if (_resourceHandler != null) {      ResourceHandler handler = null;      try {        Constructor ctor = _resourceHandler.getConstructor(new Class []{          ResourceHandler.class});        ResourceHandler oldHanlder = app.getResourceHandler();        handler = (ResourceHandler) ctor.newInstance(oldHanlder);      }      catch (NoSuchMethodException e) {      }      catch (RuntimeException e) {        throw e;      }      catch (Exception e) {        throw ConfigException.create(e);      }      if (handler == null) {        try {          handler = (ResourceHandler) _resourceHandler.newInstance();        }        catch (RuntimeException e) {          throw e;        }        catch (Exception e) {          throw ConfigException.create(e);        }      }      if (handler != null) {        app.setResourceHandler(handler);        log.fine(L.l("JSF[] using '{0}' as resource-handler", handler));      }    }    if (_navigationHandler != null) {      NavigationHandler handler = null;            try {        Constructor ctor          = _navigationHandler.getConstructor(new Class[] { NavigationHandler.class });                NavigationHandler oldHandler = app.getNavigationHandler();        handler = (NavigationHandler) ctor.newInstance(oldHandler);      } catch (NoSuchMethodException e) {      } catch (RuntimeException e) {        throw e;      } catch (Exception e) {        throw ConfigException.create(e);      }      if (handler == null) {        try {          handler = (NavigationHandler) _navigationHandler.newInstance();        } catch (RuntimeException e) {          throw e;        } catch (Exception e) {          throw ConfigException.create(e);        }      }      if (handler != null) {        app.setNavigationHandler(handler);	log.fine(L.l("JSF[] using '{0}' as navigation-handler", handler));      }    }    if (_stateManager != null) {      StateManager manager = null;            try {        Constructor ctor          = _stateManager.getConstructor(new Class[] { StateManager.class });                StateManager oldHandler = app.getStateManager();        manager = (StateManager) ctor.newInstance(oldHandler);      } catch (NoSuchMethodException e) {      } catch (RuntimeException e) {        throw e;      } catch (Exception e) {        throw ConfigException.create(e);      }      if (manager == null) {        try {          manager = (StateManager) _stateManager.newInstance();        } catch (RuntimeException e) {          throw e;        } catch (Exception e) {          throw ConfigException.create(e);        }      }      if (manager != null) {        app.setStateManager(manager);	log.fine(L.l("JSF[] using '{0}' as state-manager", manager));      }    }    for (int i = 0; i < _elResolverList.size(); i++)	   app.addELResolver(_elResolverList.get(i));    if (_propertyResolver != null) {      PropertyResolver propertyResolver = null;      try {	Constructor ctor =	  _propertyResolver.getConstructor(PropertyResolver.class);	PropertyResolver oldPropertyResolver = app.getLegacyPropertyResolver();	propertyResolver =	  (PropertyResolver) ctor.newInstance(oldPropertyResolver);      }      catch (NoSuchMethodException e) {      }      catch (RuntimeException e) {	throw e;      }      catch (Exception e) {	throw ConfigException.create(e);      }      if (propertyResolver == null) {	try {	  propertyResolver = (PropertyResolver) _propertyResolver.newInstance();	}	catch (RuntimeException e) {	  throw e;	}	catch (Exception e) {	  throw ConfigException.create(e);	}      }      if (propertyResolver != null) {	app.setPropertyResolver(propertyResolver);	log.fine(L.l("JSF[] using '{0}' as property-resolver",		     propertyResolver));      }    }    if (_variableResolver != null) {      VariableResolver variableResolver = null;      try {	Constructor ctor =	  _variableResolver.getConstructor(VariableResolver.class);	VariableResolver oldVariableResolver = app.getLegacyVariableResolver();        variableResolver =	  (VariableResolver) ctor.newInstance(oldVariableResolver);      }      catch (NoSuchMethodException e) {      }      catch (RuntimeException e) {	throw e;      }      catch (Exception e) {	throw ConfigException.create(e);      }      if (variableResolver == null) {	try {	  variableResolver = (VariableResolver) _variableResolver.newInstance();	}	catch (RuntimeException e) {	  throw e;	}	catch (Exception e) {	  throw ConfigException.create(e);	}      }      if (variableResolver != null) {	app.setVariableResolver(variableResolver);	log.fine(L.l("JSF[] using '{0}' as variable-resolver",		     variableResolver));      }    }  }  public static class LocaleConfig {    private Locale _defaultLocale;    private ArrayList<Locale> _supportedLocales      = new ArrayList<Locale>();        public void setId(String id)    {    }    public void setDefaultLocale(String locale)    {      _defaultLocale = LocaleUtil.createLocale(locale);    }    public void addSupportedLocale(String locale)    {      _supportedLocales.add(LocaleUtil.createLocale(locale));    }    public void configure(Application app)    {      if (_defaultLocale != null) {	app.setDefaultLocale(_defaultLocale);      }      app.setSupportedLocales(_supportedLocales);    }  }}

⌨️ 快捷键说明

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