Search in sources :

Example 11 with DeclarativeServicesAnnotationError

use of aQute.bnd.component.error.DeclarativeServicesAnnotationError in project bnd by bndtools.

the class AnnotationReader method doActivate.

/**
	 * 
	 */
protected void doActivate() {
    String methodDescriptor = member.getDescriptor().toString();
    DeclarativeServicesAnnotationError details = new DeclarativeServicesAnnotationError(className.getFQN(), member.getName(), methodDescriptor, ErrorType.ACTIVATE_SIGNATURE_ERROR);
    if (!(member instanceof MethodDef)) {
        analyzer.error("Activate annotation on a field %s.%s", clazz, member.getDescriptor()).details(details);
        return;
    }
    boolean hasMapReturnType = false;
    Matcher m = LIFECYCLEDESCRIPTORDS10.matcher(methodDescriptor);
    if ("activate".equals(member.getName()) && m.matches()) {
        component.activate = member.getName();
        hasMapReturnType = m.group(3) != null;
        if (!member.isProtected())
            component.updateVersion(V1_1);
    } else {
        m = LIFECYCLEDESCRIPTORDS11.matcher(methodDescriptor);
        if (m.matches()) {
            component.activate = member.getName();
            component.updateVersion(V1_1);
            hasMapReturnType = m.group(6) != null;
        } else {
            m = LIFECYCLEDESCRIPTORDS13.matcher(methodDescriptor);
            if (m.matches()) {
                component.activate = member.getName();
                component.updateVersion(V1_3);
                hasMapReturnType = m.group(4) != null;
                processAnnotationArguments(methodDescriptor, details);
            } else
                analyzer.error("Activate method for %s descriptor %s is not acceptable.", clazz, member.getDescriptor()).details(details);
        }
    }
    checkMapReturnType(hasMapReturnType, details);
}
Also used : MethodDef(aQute.bnd.osgi.Clazz.MethodDef) Matcher(java.util.regex.Matcher) DeclarativeServicesAnnotationError(aQute.bnd.component.error.DeclarativeServicesAnnotationError)

Aggregations

DeclarativeServicesAnnotationError (aQute.bnd.component.error.DeclarativeServicesAnnotationError)11 Matcher (java.util.regex.Matcher)7 MethodDef (aQute.bnd.osgi.Clazz.MethodDef)4 TypeRef (aQute.bnd.osgi.Descriptors.TypeRef)4 ArrayList (java.util.ArrayList)4 Clazz (aQute.bnd.osgi.Clazz)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Annotation (aQute.bnd.osgi.Annotation)1 FieldDef (aQute.bnd.osgi.Clazz.FieldDef)1 Version (aQute.bnd.version.Version)1 Map (java.util.Map)1 MarkerData (org.bndtools.build.api.MarkerData)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 Reference (org.osgi.service.component.annotations.Reference)1