Marcel Offermans | 61a8114 | 2010-04-02 15:16:50 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.impl.dependencies; |
| 2 | |
| 3 | import org.apache.felix.dm.dependencies.Dependency; |
| 4 | import org.apache.felix.dm.impl.InvocationUtil; |
| 5 | import org.apache.felix.dm.impl.Logger; |
| 6 | |
| 7 | public abstract class DependencyBase implements Dependency, DependencyActivation { |
| 8 | private boolean m_isRequired; |
| 9 | private boolean m_isInstanceBound; |
| 10 | protected final Logger m_logger; |
| 11 | |
| 12 | public DependencyBase(Logger logger) { |
| 13 | m_logger = logger; |
| 14 | } |
| 15 | |
| 16 | public synchronized boolean isRequired() { |
| 17 | return m_isRequired; |
| 18 | } |
| 19 | |
| 20 | protected synchronized void setIsRequired(boolean isRequired) { |
| 21 | m_isRequired = isRequired; |
| 22 | } |
| 23 | |
| 24 | public final boolean isInstanceBound() { |
| 25 | return m_isInstanceBound; |
| 26 | } |
| 27 | |
| 28 | public final void setIsInstanceBound(boolean isInstanceBound) { |
| 29 | m_isInstanceBound = isInstanceBound; |
| 30 | } |
| 31 | |
| 32 | protected void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters) { |
Marcel Offermans | 46e26fb | 2010-04-05 12:05:09 +0000 | [diff] [blame^] | 33 | for (int i = 0; i < instances.length; i++) { |
| 34 | try { |
| 35 | InvocationUtil.invokeCallbackMethod(instances[i], methodName, signatures, parameters); |
| 36 | } |
| 37 | catch (NoSuchMethodException e) { |
| 38 | // if the method does not exist, ignore it |
| 39 | } |
| 40 | catch (Exception e) { |
| 41 | m_logger.log(Logger.LOG_WARNING, "Invocation of '" + methodName + "' failed.", e); |
| 42 | } |
Marcel Offermans | 61a8114 | 2010-04-02 15:16:50 +0000 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | } |