Search in sources :

Example 1 with Verifier

use of com.sun.faces.config.Verifier in project mojarra by eclipse-ee4j.

the class BehaviorConfigProcessor method addBehaviors.

// --------------------------------------------------------- Private Methods
private void addBehaviors(NodeList behaviors, String namespace) throws XPathExpressionException {
    Application app = getApplication();
    Verifier verifier = Verifier.getCurrentInstance();
    for (int i = 0, size = behaviors.getLength(); i < size; i++) {
        Node behavior = behaviors.item(i);
        NodeList children = ((Element) behavior).getElementsByTagNameNS(namespace, "*");
        String behaviorId = null;
        String behaviorClass = null;
        for (int c = 0, csize = children.getLength(); c < csize; c++) {
            Node n = children.item(c);
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                switch(n.getLocalName()) {
                    case BEHAVIOR_ID:
                        behaviorId = getNodeText(n);
                        break;
                    case BEHAVIOR_CLASS:
                        behaviorClass = getNodeText(n);
                        break;
                }
            }
        }
        if (behaviorId != null && behaviorClass != null) {
            if (LOGGER.isLoggable(FINE)) {
                LOGGER.log(FINE, MessageFormat.format("Calling Application.addBehavior({0},{1})", behaviorId, behaviorClass));
            }
            if (verifier != null) {
                verifier.validateObject(Verifier.ObjectType.BEHAVIOR, behaviorClass, Behavior.class);
            }
            app.addBehavior(behaviorId, behaviorClass);
        }
    }
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Verifier(com.sun.faces.config.Verifier) Application(jakarta.faces.application.Application)

Example 2 with Verifier

use of com.sun.faces.config.Verifier in project mojarra by eclipse-ee4j.

the class ComponentConfigProcessor method addComponents.

// --------------------------------------------------------- Private Methods
private void addComponents(NodeList components, String namespace) throws XPathExpressionException {
    Application app = getApplication();
    Verifier verifier = Verifier.getCurrentInstance();
    for (int i = 0, size = components.getLength(); i < size; i++) {
        Node componentNode = components.item(i);
        NodeList children = ((Element) componentNode).getElementsByTagNameNS(namespace, "*");
        String componentType = null;
        String componentClass = null;
        for (int c = 0, csize = children.getLength(); c < csize; c++) {
            Node n = children.item(c);
            switch(n.getLocalName()) {
                case COMPONENT_TYPE:
                    componentType = getNodeText(n);
                    break;
                case COMPONENT_CLASS:
                    componentClass = getNodeText(n);
                    break;
            }
        }
        if (componentType != null && componentClass != null) {
            if (LOGGER.isLoggable(FINE)) {
                LOGGER.log(FINE, MessageFormat.format("Calling Application.addComponent({0},{1})", componentType, componentClass));
            }
            if (verifier != null) {
                verifier.validateObject(Verifier.ObjectType.COMPONENT, componentClass, UIComponent.class);
            }
            app.addComponent(componentType, componentClass);
        }
    }
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Verifier(com.sun.faces.config.Verifier) Application(jakarta.faces.application.Application)

Example 3 with Verifier

use of com.sun.faces.config.Verifier in project mojarra by eclipse-ee4j.

the class ConverterConfigProcessor method addConverters.

// --------------------------------------------------------- Private Methods
private void addConverters(NodeList converters, String namespace) {
    Application application = getApplication();
    Verifier verifier = Verifier.getCurrentInstance();
    for (int i = 0, size = converters.getLength(); i < size; i++) {
        Node converter = converters.item(i);
        NodeList children = ((Element) converter).getElementsByTagNameNS(namespace, "*");
        String converterId = null;
        String converterClass = null;
        String converterForClass = null;
        for (int c = 0, csize = children.getLength(); c < csize; c++) {
            Node n = children.item(c);
            switch(n.getLocalName()) {
                case CONVERTER_ID:
                    converterId = getNodeText(n);
                    break;
                case CONVERTER_CLASS:
                    converterClass = getNodeText(n);
                    break;
                case CONVERTER_FOR_CLASS:
                    converterForClass = getNodeText(n);
                    break;
            }
        }
        if (converterId != null && converterClass != null) {
            if (LOGGER.isLoggable(FINE)) {
                LOGGER.log(FINE, format("[Converter by ID] Calling Application.addConverter({0}, {1}", converterId, converterClass));
            }
            if (verifier != null) {
                verifier.validateObject(Verifier.ObjectType.CONVERTER, converterClass, Converter.class);
            }
            application.addConverter(converterId, converterClass);
        } else if (converterClass != null && converterForClass != null) {
            try {
                Class<?> cfcClass = Util.loadClass(converterForClass, this.getClass());
                if (LOGGER.isLoggable(FINE)) {
                    LOGGER.log(FINE, format("[Converter for Class] Calling Application.addConverter({0}, {1}", converterForClass, converterClass));
                }
                if (verifier != null) {
                    verifier.validateObject(Verifier.ObjectType.CONVERTER, converterClass, Converter.class);
                }
                application.addConverter(cfcClass, converterClass);
            } catch (ClassNotFoundException cnfe) {
                throw new ConfigurationException(cnfe);
            }
        }
    }
}
Also used : ConfigurationException(com.sun.faces.config.ConfigurationException) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) FacesConverter(jakarta.faces.convert.FacesConverter) Converter(jakarta.faces.convert.Converter) Verifier(com.sun.faces.config.Verifier) Application(jakarta.faces.application.Application)

Example 4 with Verifier

use of com.sun.faces.config.Verifier in project mojarra by eclipse-ee4j.

the class ValidatorConfigProcessor method addValidators.

private void addValidators(FacesContext facesContext, NodeList validators, String namespace) throws XPathExpressionException {
    Application application = getApplication();
    Verifier verifier = Verifier.getCurrentInstance();
    for (int i = 0, size = validators.getLength(); i < size; i++) {
        Node validator = validators.item(i);
        NodeList children = ((Element) validator).getElementsByTagNameNS(namespace, "*");
        String validatorId = null;
        String validatorClass = null;
        for (int c = 0, csize = children.getLength(); c < csize; c++) {
            Node n = children.item(c);
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                switch(n.getLocalName()) {
                    case VALIDATOR_ID:
                        validatorId = getNodeText(n);
                        break;
                    case VALIDATOR_CLASS:
                        validatorClass = getNodeText(n);
                        break;
                }
            }
        }
        if (validatorId != null && validatorClass != null) {
            if (LOGGER.isLoggable(FINE)) {
                LOGGER.log(FINE, format("Calling Application.addValidator({0},{1})", validatorId, validatorClass));
            }
            boolean doAdd = true;
            if (validatorId.equals(BeanValidator.VALIDATOR_ID)) {
                doAdd = ApplicationConfigProcessor.isBeanValidatorAvailable(facesContext);
            }
            if (doAdd) {
                if (verifier != null) {
                    verifier.validateObject(Verifier.ObjectType.VALIDATOR, validatorClass, Validator.class);
                }
                application.addValidator(validatorId, validatorClass);
            }
        }
    }
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Verifier(com.sun.faces.config.Verifier) Application(jakarta.faces.application.Application)

Aggregations

Verifier (com.sun.faces.config.Verifier)4 Application (jakarta.faces.application.Application)4 Element (org.w3c.dom.Element)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 ConfigurationException (com.sun.faces.config.ConfigurationException)1 Converter (jakarta.faces.convert.Converter)1 FacesConverter (jakarta.faces.convert.FacesConverter)1