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) { |
| 33 | try { |
| 34 | InvocationUtil.invokeCallbackMethod(instances, methodName, signatures, parameters); |
| 35 | } |
| 36 | catch (NoSuchMethodException e) { |
| 37 | m_logger.log(Logger.LOG_DEBUG, "Method '" + methodName + "' does not exist. Callback skipped."); |
| 38 | } |
| 39 | catch (Exception e) { |
| 40 | m_logger.log(Logger.LOG_DEBUG, "Invocation of '" + methodName + "' failed.", e); |
| 41 | } |
| 42 | } |
| 43 | } |