applicationimpl.java

来自「一个使用struts+hibernate+spring开发的完的网站源代码。」· Java 代码 · 共 677 行 · 第 1/2 页

JAVA
677
字号
        {            log.error("addConverter: converterClass = null is not allowed");            throw new NullPointerException("addConverter: converterClass = null ist not allowed");        }                try        {            _converterClassToClassMap.put(targetClass, ClassUtils.simpleClassForName(converterClass));            if (log.isTraceEnabled()) log.trace("add Converter for class = " + targetClass +                    " converterClass = " + converterClass);        }        catch (Exception e)        {            log.error("Converter class " + converterClass + " not found", e);        }    }    public void addConverterConfiguration(String converterClassName,                                          org.apache.myfaces.config.impl.digester.elements.Converter configuration)    {        if ((converterClassName == null) || (converterClassName.length() == 0))        {            log.error("addConverterConfiguration: converterClassName = null is not allowed");            throw new NullPointerException("addConverterConfiguration: converterClassName = null ist not allowed");        }        if ((configuration == null))        {            log.error("addConverterConfiguration: configuration = null is not allowed");            throw new NullPointerException("addConverterConfiguration: configuration = null ist not allowed");        }        _converterClassNameToConfigurationMap.put(converterClassName, configuration);    }    public void addValidator(String validatorId, String validatorClass)    {        if ((validatorId == null) || (validatorId.length() == 0))        {            log.error("addValidator: validatorId = null is not allowed");            throw new NullPointerException("addValidator: validatorId = null ist not allowed");        }        if ((validatorClass == null) || (validatorClass.length() == 0))        {            log.error("addValidator:  validatorClass = null is not allowed");            throw new NullPointerException("addValidator:  validatorClass = null ist not allowed");        }                try        {            _validatorClassMap.put(validatorId, ClassUtils.simpleClassForName(validatorClass));            if (log.isTraceEnabled()) log.trace("add Validator id = " + validatorId +                                            " class = " + validatorClass);        }        catch (Exception e)        {            log.error("Validator class " + validatorClass + " not found", e);        }    }    public UIComponent createComponent(String componentType)        throws FacesException    {        if ((componentType == null) || (componentType.length() == 0))        {            log.error("createComponent: componentType = null is not allowed");            throw new NullPointerException("createComponent: componentType = null is not allowed");        }        Class componentClass;        synchronized (_componentClassMap)        {            componentClass = (Class) _componentClassMap.get(componentType);        }        if (componentClass == null)        {            log.error("Undefined component type " + componentType);            throw new FacesException("Undefined component type " + componentType);        }        try        {            return (UIComponent) componentClass.newInstance();        }        catch (Exception e)        {            log.error("Could not instantiate component componentType = " + componentType, e);            throw new FacesException("Could not instantiate component componentType = " + componentType, e);        }    }    public UIComponent createComponent(ValueBinding valueBinding,                                       FacesContext facesContext,                                       String componentType)        throws FacesException    {        if ((valueBinding == null))        {            log.error("createComponent: valueBinding = null is not allowed");            throw new NullPointerException("createComponent: valueBinding = null ist not allowed");        }        if ((facesContext == null))        {            log.error("createComponent: facesContext = null is not allowed");            throw new NullPointerException("createComponent: facesContext = null ist not allowed");        }        if ((componentType == null) || (componentType.length() == 0))        {            log.error("createComponent: componentType = null is not allowed");            throw new NullPointerException("createComponent: componentType = null ist not allowed");        }        Object obj = valueBinding.getValue(facesContext);        if (obj instanceof UIComponent)        {            return (UIComponent) obj;        }        else        {            UIComponent component = createComponent(componentType);            valueBinding.setValue(facesContext, component);            return component;        }    }    public Converter createConverter(String converterId)    {        if ((converterId == null) || (converterId.length() == 0))        {            log.error("createConverter: converterId = null is not allowed");            throw new NullPointerException("createConverter: converterId = null ist not allowed");        }        Class converterClass = (Class) _converterIdToClassMap.get(converterId);        try        {            return (Converter) converterClass.newInstance();        }        catch (Exception e)        {            log.error("Could not instantiate converter " + converterClass, e);            throw new FacesException("Could not instantiate converter: " + converterClass, e);        }    }    public Converter createConverter(Class targetClass)    {        if (targetClass == null)        {            log.error("createConverter: targetClass = null is not allowed");            throw new NullPointerException("createConverter: targetClass = null ist not allowed");        }        Converter converter = internalCreateConverter(targetClass);        return converter;    }    private Converter internalCreateConverter(Class targetClass)    {        // Locate a Converter registered for the target class itself.        Class converterClass = (Class)_converterClassToClassMap.get(targetClass);        //Locate a Converter registered for interfaces that are        // implemented by the target class (directly or indirectly).        if (converterClass == null)        {            Class interfaces[] = targetClass.getInterfaces();            if (interfaces != null)            {                for (int i = 0, len = interfaces.length; i < len; i++)                {                	// search all superinterfaces for a matching converter, create it                    Converter converter = internalCreateConverter(interfaces[i]);                    if (converter != null)                    {                        return converter;                    }                }            }        }        if (converterClass != null)        {            try            {                Converter converter = (Converter) converterClass.newInstance();                org.apache.myfaces.config.impl.digester.elements.Converter converterConfig =                        (org.apache.myfaces.config.impl.digester.elements.Converter)                            _converterClassNameToConfigurationMap.get(converterClass.getName());                Iterator it = converterConfig.getProperties();                while (it.hasNext())                {                    Property property = (Property) it.next();                    try                    {                        BeanUtils.setProperty(converter,property.getPropertyName(),property.getDefaultValue());                    }                    catch(Throwable th)                    {                        log.error("Initializing converter : "+converterClass.getName()+" with property : "+                                property.getPropertyName()+" and value : "+property.getDefaultValue()+" failed.");                    }                }                return converter;            }            catch (Exception e)            {                log.error("Could not instantiate converter " + converterClass, e);                throw new FacesException("Could not instantiate converter: " + converterClass, e);            }        }        //   locate converter for primitive types        if (targetClass == Long.TYPE)        {            return internalCreateConverter(Long.class);        } else if (targetClass == Boolean.TYPE)        {            return internalCreateConverter(Boolean.class);        } else if (targetClass == Double.TYPE)        {            return internalCreateConverter(Double.class);        } else if (targetClass == Byte.TYPE)        {            return internalCreateConverter(Byte.class);        } else if (targetClass == Short.TYPE)        {            return internalCreateConverter(Short.class);        } else if (targetClass == Integer.TYPE)        {            return internalCreateConverter(Integer.class);        } else if (targetClass == Float.TYPE)        {            return internalCreateConverter(Float.class);        } else if (targetClass == Character.TYPE)        {            return internalCreateConverter(Character.class);        }        //Locate a Converter registered for the superclass (if any) of the target class,        // recursively working up the inheritance hierarchy.        Class superClazz = targetClass.getSuperclass();        if (superClazz != null)        {            return internalCreateConverter(superClazz);        }        else        {            return null;        }    }    public synchronized MethodBinding createMethodBinding(String reference, Class[] params)        throws ReferenceSyntaxException    {        if ((reference == null) || (reference.length() == 0))        {            log.error("createMethodBinding: reference = null is not allowed");            throw new NullPointerException("createMethodBinding: reference = null ist not allowed");        }        // We choose to instantiate a new MethodBinding every time as this is much easier         // and about as efficient as implementing a cache specifically for MethodBinding,        // which is complicated by the need to use a conposite key=(reference, params)        // (significant part of MethodBinding is already cached by ValueBinding implicitly)        return new MethodBindingImpl(this, reference, params);    }    public Validator createValidator(String validatorId) throws FacesException    {        if ((validatorId == null) || (validatorId.length() == 0))        {            log.error("createValidator: validatorId = null is not allowed");            throw new NullPointerException("createValidator: validatorId = null ist not allowed");        }                Class validatorClass = (Class) _validatorClassMap.get(validatorId);        if (validatorClass == null)        {            String message = "Unknown converter id '" + validatorId + "'.";             log.error(message);            throw new FacesException(message);        }                try        {            return (Validator) validatorClass.newInstance();        }        catch (Exception e)        {            log.error("Could not instantiate converter " + validatorClass, e);            throw new FacesException("Could not instantiate converter: " + validatorClass, e);        }    }    public ValueBinding createValueBinding(String reference) throws ReferenceSyntaxException    {        if ((reference == null) || (reference.length() == 0))        {            log.error("createValueBinding: reference = null is not allowed");            throw new NullPointerException("createValueBinding: reference = null is not allowed");        }        return (ValueBinding) _valueBindingCache.get(reference);    }    public String getDefaultRenderKitId()    {        return _defaultRenderKitId;    }    public void setDefaultRenderKitId(String defaultRenderKitId)    {        _defaultRenderKitId = defaultRenderKitId;    }    public StateManager getStateManager()    {        return _stateManager;    }    public void setStateManager(StateManager stateManager)    {        _stateManager = stateManager;    }}

⌨️ 快捷键说明

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