Author: clement Date: Wed Dec 10 07:44:29 2014 New Revision: 1644346 URL: http://svn.apache.org/r1644346 Log: Fix FELIX-3836
Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java?rev=1644346&r1=1644345&r2=1644346&view=diff ============================================================================== --- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java (original) +++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java Wed Dec 10 07:44:29 2014 @@ -791,21 +791,31 @@ public abstract class IPojoFactory imple */ protected void computeDescription() { for (RequiredHandler req : m_requiredHandlers) { - if (getHandler(req, null) == null) { + HandlerManager handlerManager = null; + try { + handlerManager = getHandler(req, null); + } catch (Exception e) { m_logger.log(Logger.ERROR, "Cannot extract handler object from " + m_factoryName + " " + req .getFullName()); - } else { - Handler handler = getHandler(req, null).getHandler(); - try { - handler.setFactory(this); - handler.initializeComponentFactory(m_componentDesc, m_componentMetadata); - ((Pojo) handler).getComponentInstance().dispose(); - } catch (ConfigurationException e) { - ((Pojo) handler).getComponentInstance().dispose(); - m_logger.log(Logger.ERROR, e.getMessage()); - stop(); - throw new IllegalStateException(e); - } + return; + } + + if (handlerManager == null) { + m_logger.log(Logger.ERROR, "Cannot extract handler object from " + m_factoryName + " " + req + .getFullName()); + return; + } + + Handler handler = handlerManager.getHandler(); + try { + handler.setFactory(this); + handler.initializeComponentFactory(m_componentDesc, m_componentMetadata); + ((Pojo) handler).getComponentInstance().dispose(); + } catch (ConfigurationException e) { + ((Pojo) handler).getComponentInstance().dispose(); + m_logger.log(Logger.ERROR, e.getMessage()); + stop(); + throw new IllegalStateException(e); } } } @@ -906,27 +916,28 @@ public abstract class IPojoFactory imple * @param context the service context in which the handler is created (same as the instance context). * @return the handler object. */ - protected HandlerManager getHandler(RequiredHandler req, ServiceContext context) { + protected HandlerManager getHandler(RequiredHandler req, ServiceContext context) throws MissingHandlerException, + UnacceptableConfiguration, ConfigurationException { try { return (HandlerManager) req.getFactory().createComponentInstance(null, context); } catch (MissingHandlerException e) { m_logger.log(Logger.ERROR, "The creation of the handler " + req.getFullName() + " has failed: " + e.getMessage()); stop(); - return null; + throw e; } catch (UnacceptableConfiguration e) { m_logger.log(Logger.ERROR, "The creation of the handler " + req.getFullName() + " has failed (UnacceptableConfiguration): " + e.getMessage()); stop(); - return null; + throw e; } catch (org.apache.felix.ipojo.ConfigurationException e) { m_logger.log(Logger.ERROR, "The configuration of the handler " + req.getFullName() + " has failed (ConfigurationException): " + e.getMessage()); stop(); - return null; + throw e; } }