Search in sources :

Example 6 with ConfigurationException

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

the class FaceletTaglibConfigProcessor method processConverter.

private void processConverter(ServletContext sc, FacesContext facesContext, NodeList converter, TagLibraryImpl taglibrary, String name) {
    if (converter != null && converter.getLength() > 0) {
        String converterId = null;
        String handlerClass = null;
        for (int i = 0, ilen = converter.getLength(); i < ilen; i++) {
            Node n = converter.item(i);
            if (n.getLocalName() != null) {
                switch(n.getLocalName()) {
                    case CONVERTER_ID:
                        converterId = getNodeText(n);
                        break;
                    case HANDLER_CLASS:
                        handlerClass = getNodeText(n);
                        break;
                }
            }
        }
        if (handlerClass != null) {
            try {
                Class<?> clazz = loadClass(sc, facesContext, handlerClass, this, null);
                taglibrary.putConverter(name, converterId, clazz);
            } catch (NoClassDefFoundError defNotFound) {
                String message = defNotFound.toString();
                if (message.contains("com/sun/facelets/") || message.contains("com.sun.facelets.")) {
                    if (LOGGER.isLoggable(Level.WARNING)) {
                        LOGGER.log(Level.WARNING, "faces.config.legacy.facelet.warning", new Object[] { handlerClass });
                    }
                } else {
                    throw defNotFound;
                }
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException(e);
            }
        } else {
            taglibrary.putConverter(name, converterId);
        }
    }
}
Also used : ConfigurationException(com.sun.faces.config.ConfigurationException) Node(org.w3c.dom.Node)

Example 7 with ConfigurationException

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

the class DocumentOrderingWrapper method sort.

/**
 * Sort the provided array of <code>Document</code>s per the requirements of the 2.0 specification. Note, that this
 * method only provides partial ordering and not absolute ordering.
 * @param documents the documents to sort
 */
public static void sort(DocumentOrderingWrapper[] documents) {
    Timer t = Timer.getInstance();
    if (t != null) {
        t.startTiming();
    }
    try {
        enhanceOrderingData(documents);
    } catch (CircularDependencyException re) {
        String msg = "Circular dependencies detected!\nDocument Info\n==================\n";
        for (DocumentOrderingWrapper w : documents) {
            msg += "  " + w.toString() + '\n';
        }
        throw new ConfigurationException(msg);
    }
    // Sort the documents such that specified ordering will be considered.
    // 
    // It turns out that some of the specified ordering, if it was not discovered by the sort routine
    // until later in its processing, was not being considered correctly in the ordering algorithm.
    // 
    // This preSort method puts all of the documents with specified ordering as early on in the
    // list of documents as possible for Mojarra to consider it quickly, and be
    // able to use its ordering algorithm to the best of its ability.
    preSort(documents);
    // original inner sort algorithm
    int numberOfPasses = innerSort(documents);
    // final sort
    for (int i = 0; i < documents.length; i++) {
        LinkedList<String> ids = getIds(documents);
        if (done(documents, ids)) {
            break;
        }
    }
    if (t != null) {
        t.stopTiming();
        t.logResult("\"faces-config\" document sorting complete in " + numberOfPasses + '.');
    }
}
Also used : Timer(com.sun.faces.util.Timer) ConfigurationException(com.sun.faces.config.ConfigurationException)

Example 8 with ConfigurationException

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

the class ReflectionUtil method decorateInstance.

public static Object decorateInstance(String className, Class rootType, Object root) {
    Class clazz;
    Object returnObject = null;
    if (className != null) {
        try {
            clazz = loadClass(className, returnObject, null);
            if (clazz != null) {
                returnObject = decorateInstance(clazz, rootType, root);
            }
        } catch (ClassNotFoundException cnfe) {
            throw new ConfigurationException(buildMessage(MessageFormat.format("Unable to find class ''{0}''", className)));
        } catch (NoClassDefFoundError ncdfe) {
            throw new ConfigurationException(buildMessage(MessageFormat.format("Class ''{0}'' is missing a runtime dependency: {1}", className, ncdfe.toString())));
        } catch (ClassCastException cce) {
            throw new ConfigurationException(buildMessage(MessageFormat.format("Class ''{0}'' is not an instance of ''{1}''", className, rootType)));
        } catch (Exception e) {
            throw new ConfigurationException(buildMessage(MessageFormat.format("Unable to create a new instance of ''{0}'': {1}", className, e.toString())), e);
        }
    }
    return returnObject;
}
Also used : ConfigurationException(com.sun.faces.config.ConfigurationException) ConfigurationException(com.sun.faces.config.ConfigurationException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with ConfigurationException

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

the class FaceletTaglibConfigProcessor method processComponent.

private void processComponent(ServletContext sc, FacesContext facesContext, Element documentElement, NodeList component, TagLibraryImpl taglibrary, String name) {
    if (component != null && component.getLength() > 0) {
        String componentType = null;
        String rendererType = null;
        String handlerClass = null;
        Node resourceId = null;
        for (int i = 0, ilen = component.getLength(); i < ilen; i++) {
            Node n = component.item(i);
            if (n.getLocalName() != null) {
                switch(n.getLocalName()) {
                    case COMPONENT_TYPE:
                        componentType = getNodeText(n);
                        break;
                    case RENDERER_TYPE:
                        rendererType = getNodeText(n);
                        break;
                    case HANDLER_CLASS:
                        handlerClass = getNodeText(n);
                        break;
                    case RESOURCE_ID:
                        resourceId = n;
                        break;
                }
            }
        }
        if (handlerClass != null) {
            try {
                Class<?> clazz = loadClass(sc, facesContext, handlerClass, this, null);
                taglibrary.putComponent(name, componentType, rendererType, clazz);
            } catch (NoClassDefFoundError defNotFound) {
                String message = defNotFound.toString();
                if (message.contains("com/sun/facelets/") || message.contains("com.sun.facelets.")) {
                    if (LOGGER.isLoggable(Level.WARNING)) {
                        LOGGER.log(Level.WARNING, "faces.config.legacy.facelet.warning", new Object[] { handlerClass });
                    }
                } else {
                    throw defNotFound;
                }
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException(e);
            }
        } else if (resourceId != null) {
            processResourceId(documentElement, resourceId, taglibrary, name);
        } else {
            taglibrary.putComponent(name, componentType, rendererType);
        }
    }
}
Also used : ConfigurationException(com.sun.faces.config.ConfigurationException) Node(org.w3c.dom.Node)

Example 10 with ConfigurationException

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

the class FaceletTaglibConfigProcessor method processBehavior.

private void processBehavior(ServletContext sc, FacesContext facesContext, NodeList behavior, TagLibraryImpl taglibrary, String tagName) {
    if (behavior != null && behavior.getLength() > 0) {
        String behaviorId = null;
        String handlerClass = null;
        for (int i = 0, ilen = behavior.getLength(); i < ilen; i++) {
            Node n = behavior.item(i);
            if (n.getLocalName() != null) {
                switch(n.getLocalName()) {
                    case BEHAVIOR_ID:
                        behaviorId = getNodeText(n);
                        break;
                    case HANDLER_CLASS:
                        handlerClass = getNodeText(n);
                        break;
                }
            }
        }
        if (handlerClass != null) {
            try {
                Class<?> clazz = loadClass(sc, facesContext, handlerClass, this, null);
                taglibrary.putBehavior(tagName, behaviorId, clazz);
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException(e);
            }
        } else {
            taglibrary.putBehavior(tagName, behaviorId);
        }
    }
}
Also used : ConfigurationException(com.sun.faces.config.ConfigurationException) Node(org.w3c.dom.Node)

Aggregations

ConfigurationException (com.sun.faces.config.ConfigurationException)15 Node (org.w3c.dom.Node)8 NodeList (org.w3c.dom.NodeList)4 DocumentInfo (com.sun.faces.config.manager.documents.DocumentInfo)2 Timer (com.sun.faces.util.Timer)2 FacesException (jakarta.faces.FacesException)2 Application (jakarta.faces.application.Application)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Document (org.w3c.dom.Document)2 Verifier (com.sun.faces.config.Verifier)1 FindConfigResourceURIsTask (com.sun.faces.config.manager.tasks.FindConfigResourceURIsTask)1 ParseConfigResourceToDOMTask (com.sun.faces.config.manager.tasks.ParseConfigResourceToDOMTask)1 ConfigurationResourceProvider (com.sun.faces.spi.ConfigurationResourceProvider)1 InjectionProvider (com.sun.faces.spi.InjectionProvider)1 InjectionProviderException (com.sun.faces.spi.InjectionProviderException)1 MessageUtils.getExceptionMessageString (com.sun.faces.util.MessageUtils.getExceptionMessageString)1 Util.getLocaleFromString (com.sun.faces.util.Util.getLocaleFromString)1 Converter (jakarta.faces.convert.Converter)1