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.
}
}
Aggregations