Search in sources :

Example 16 with DependencyDescription

use of org.apache.felix.ipojo.handlers.dependency.DependencyDescription in project felix by apache.

the class Dependency method getDependencyDescription.

/**
 * Gets the dependency description object attached to
 * this dependency.
 * @param instance the instance on which searching the dependency
 * @return the dependency description attached to this dependency or
 * <code>null</code> if the dependency cannot be found.
 */
public DependencyDescription getDependencyDescription(ComponentInstance instance) {
    PrimitiveInstanceDescription desc = (PrimitiveInstanceDescription) instance.getInstanceDescription();
    if (m_id != null) {
        return desc.getDependency(m_id);
    }
    if (m_specification != null) {
        return desc.getDependency(m_specification);
    }
    DependencyDescription[] deps = desc.getDependencies();
    if (deps.length == 1) {
        return deps[0];
    }
    // Cannot determine the dependency.
    return null;
}
Also used : DependencyDescription(org.apache.felix.ipojo.handlers.dependency.DependencyDescription) PrimitiveInstanceDescription(org.apache.felix.ipojo.PrimitiveInstanceDescription)

Aggregations

DependencyDescription (org.apache.felix.ipojo.handlers.dependency.DependencyDescription)16 DependencyHandlerDescription (org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription)14 Test (org.junit.Test)13 ComponentInstance (org.apache.felix.ipojo.ComponentInstance)9 Properties (java.util.Properties)4 Architecture (org.apache.felix.ipojo.architecture.Architecture)4 PrimitiveInstanceDescription (org.apache.felix.ipojo.PrimitiveInstanceDescription)2 HandlerDescription (org.apache.felix.ipojo.architecture.HandlerDescription)2 DependencyCallback (org.apache.felix.ipojo.handlers.dependency.DependencyCallback)2 ServiceReference (org.osgi.framework.ServiceReference)2 ProvidedServiceHandlerDescription (org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription)1 CheckService (org.apache.felix.ipojo.runtime.core.test.services.CheckService)1 FooService (org.apache.felix.ipojo.runtime.core.test.services.FooService)1 Ignore (org.junit.Ignore)1