Search in sources :

Example 1 with ModifiedMethod

use of org.apache.felix.scr.impl.inject.methods.ModifiedMethod in project felix by apache.

the class ComponentMethodsImpl method initComponentMethods.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public synchronized void initComponentMethods(final ComponentMetadata componentMetadata, final Class<T> implementationObjectClass, final ComponentLogger logger) {
    if (m_activateMethod != null) {
        // do init only once
        return;
    }
    DSVersion dsVersion = componentMetadata.getDSVersion();
    boolean configurableServiceProperties = componentMetadata.isConfigurableServiceProperties();
    boolean supportsInterfaces = componentMetadata.isConfigureWithInterfaces();
    m_activateMethod = new ActivateMethod(componentMetadata.getActivate(), componentMetadata.isActivateDeclared(), implementationObjectClass, dsVersion, configurableServiceProperties, supportsInterfaces);
    m_deactivateMethod = new DeactivateMethod(componentMetadata.getDeactivate(), componentMetadata.isDeactivateDeclared(), implementationObjectClass, dsVersion, configurableServiceProperties, supportsInterfaces);
    m_modifiedMethod = new ModifiedMethod(componentMetadata.getModified(), implementationObjectClass, dsVersion, configurableServiceProperties, supportsInterfaces);
    for (ReferenceMetadata referenceMetadata : componentMetadata.getDependencies()) {
        final String refName = referenceMetadata.getName();
        final List<ReferenceMethods> methods = new ArrayList<>();
        if (referenceMetadata.getField() != null) {
            methods.add(new FieldMethods(referenceMetadata, implementationObjectClass, dsVersion, configurableServiceProperties));
        }
        if (referenceMetadata.getBind() != null) {
            methods.add(new BindMethods(referenceMetadata, implementationObjectClass, dsVersion, configurableServiceProperties));
        }
        if (methods.isEmpty()) {
            bindMethodMap.put(refName, ReferenceMethods.NOPReferenceMethod);
        } else if (methods.size() == 1) {
            bindMethodMap.put(refName, methods.get(0));
        } else {
            bindMethodMap.put(refName, new DuplexReferenceMethods(methods));
        }
    }
    m_constructor = new ComponentConstructor(componentMetadata, implementationObjectClass, logger);
}
Also used : FieldMethods(org.apache.felix.scr.impl.inject.field.FieldMethods) ArrayList(java.util.ArrayList) BindMethods(org.apache.felix.scr.impl.inject.methods.BindMethods) ActivateMethod(org.apache.felix.scr.impl.inject.methods.ActivateMethod) DeactivateMethod(org.apache.felix.scr.impl.inject.methods.DeactivateMethod) DSVersion(org.apache.felix.scr.impl.metadata.DSVersion) ModifiedMethod(org.apache.felix.scr.impl.inject.methods.ModifiedMethod) ReferenceMetadata(org.apache.felix.scr.impl.metadata.ReferenceMetadata)

Aggregations

ArrayList (java.util.ArrayList)1 FieldMethods (org.apache.felix.scr.impl.inject.field.FieldMethods)1 ActivateMethod (org.apache.felix.scr.impl.inject.methods.ActivateMethod)1 BindMethods (org.apache.felix.scr.impl.inject.methods.BindMethods)1 DeactivateMethod (org.apache.felix.scr.impl.inject.methods.DeactivateMethod)1 ModifiedMethod (org.apache.felix.scr.impl.inject.methods.ModifiedMethod)1 DSVersion (org.apache.felix.scr.impl.metadata.DSVersion)1 ReferenceMetadata (org.apache.felix.scr.impl.metadata.ReferenceMetadata)1