Search in sources :

Example 1 with ErrorHandler

use of org.apache.felix.ipojo.ErrorHandler in project felix by apache.

the class Logger method invokeErrorHandler.

/**
 * Invokes the error handler service is present.
 *
 * @param level the log level
 * @param msg   the message
 * @param error the error
 */
private void invokeErrorHandler(int level, String msg, Throwable error) {
    // First check the level
    if (level > WARNING) {
        // Others levels are not supported.
        return;
    }
    // Try to get the error handler service
    try {
        ServiceReference ref = m_context.getServiceReference(ErrorHandler.class.getName());
        if (ref != null) {
            ErrorHandler handler = (ErrorHandler) m_context.getService(ref);
            if (level == ERROR) {
                handler.onError(m_instance, msg, error);
            } else if (level == WARNING) {
                handler.onWarning(m_instance, msg, error);
            }
            // The others case are not supported
            m_context.ungetService(ref);
        }
    // Else do nothing...
    } catch (IllegalStateException e) {
    // Ignore
    // The iPOJO bundle is stopping.
    }
}
Also used : ErrorHandler(org.apache.felix.ipojo.ErrorHandler) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

ErrorHandler (org.apache.felix.ipojo.ErrorHandler)1 ServiceReference (org.osgi.framework.ServiceReference)1