if (sig == null) sig = member.getDescriptor().toString(); String[] sigs = sig.split("[<;>]"); int sigLength = sigs.length;
/** * rates the methods according to the scale in 112.5.8 (compendium 4.3, ds * 1.2), also returning "6" for invalid methods We don't look at return * values yet due to proposal to all them for setting service properties. * * @param test methodDef to examine for suitability as a DS lifecycle method * @param allowedParams TODO * @return rating; 6 if invalid, lower is better */ int rateLifecycle(MethodDef test, Set<String> allowedParams) { TypeRef[] prototype = test.getDescriptor() .getPrototype(); if (prototype.length == 1 && ComponentContextTR.equals(prototype[0].getFQN())) return 1; if (prototype.length == 1 && BundleContextTR.equals(prototype[0].getFQN())) return 2; if (prototype.length == 1 && MapTR.equals(prototype[0].getFQN())) return 3; if (prototype.length > 1) { for (TypeRef tr : prototype) { if (!allowedParams.contains(tr.getFQN())) return 6; } return 5; } if (prototype.length == 0) return 5; return 6; }
Descriptor(String descriptor) { this.descriptor = descriptor; int index = 0; List<TypeRef> types = Create.list(); if (descriptor.charAt(index) == '(') { index++; while (descriptor.charAt(index) != ')') { index = parse(types, descriptor, index); } index++; // skip ) prototype = types.toArray(new TypeRef[types.size()]); types.clear(); } else prototype = null; index = parse(types, descriptor, index); type = types.get(0); }
case METHOD : { def.bindDescriptor = member.getDescriptor() .toString(); def.bind = member.getName(); if (def.name == null) {
case METHOD : { def.bindDescriptor = member.getDescriptor() .toString(); def.bind = member.getName(); if (def.name == null) {
if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Activate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.ACTIVATE_SIGNATURE_ERROR)); && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Deactivate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.DEACTIVATE_SIGNATURE_ERROR)); if (method.getName().equals("deactivate") && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Modified method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.MODIFIED_SIGNATURE_ERROR)); set(COMPONENT_MODIFIED, method, "<>"); setVersion(V1_1); Matcher m = BINDDESCRIPTOR.matcher(method.getDescriptor().toString()); if (m.matches()) { service = Descriptors.binaryToFQN(m.group(1)); if(error != null) {
service = Patterns.inferTypeFromGenericType(m_methodDef.getDescriptor().toString(), m_methodDef.getSignature(), m_logger);
case PARAMETER : { String signature = (member.getSignature() != null) ? member.getSignature() : member.getDescriptor() .toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); resolver = new MethodResolver(classSig, methodSig); try { fieldSig = analyzer.getFieldSignature(member.getDescriptor() .toString()); } catch (IllegalArgumentException iae) { fieldSig = null;
if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Activate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.ACTIVATE_SIGNATURE_ERROR)); && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Deactivate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.DEACTIVATE_SIGNATURE_ERROR)); if (method.getName().equals("deactivate") && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Modified method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()).details(new DeclarativeServicesAnnotationError( className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.MODIFIED_SIGNATURE_ERROR)); set(COMPONENT_MODIFIED, method, "<>"); setVersion(V1_1); Matcher m = BINDDESCRIPTOR.matcher(method.getDescriptor().toString()); if (m.matches()) { service = Descriptors.binaryToFQN(m.group(1)); if(error != null) {
if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Activate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { setVersion(V1_1); if (!ACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) reporter.error( "Deactivate method for %s does not have an acceptable prototype, only Map, ComponentContext, or BundleContext is allowed. Found: %s", className, method.getDescriptor()); if (method.getName().equals("deactivate") && OLDACTIVATEDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) { Matcher m = BINDDESCRIPTOR.matcher(method.getDescriptor().toString()); if (m.matches()) { service = Descriptors.binaryToFQN(m.group(1)); else if (REFERENCEBINDDESCRIPTOR.matcher(method.getDescriptor().toString()).matches() || !OLDBINDDESCRIPTOR.matcher(method.getDescriptor().toString()).matches()) setVersion(V1_1);
try { fieldSig = analyzer.getFieldSignature(member.getDescriptor() .toString()); } catch (IllegalArgumentException iae) { fieldSig = null; String signature = (member.getSignature() != null) ? member.getSignature() : member.getDescriptor() .toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); MethodResolver resolver = new MethodResolver(classSig, methodSig);
case PARAMETER : { String signature = (member.getSignature() != null) ? member.getSignature() : member.getDescriptor() .toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); resolver = new MethodResolver(classSig, methodSig); try { fieldSig = analyzer.getFieldSignature(member.getDescriptor() .toString()); } catch (IllegalArgumentException iae) { fieldSig = null;
try { fieldSig = analyzer.getFieldSignature(member.getDescriptor() .toString()); } catch (IllegalArgumentException iae) { fieldSig = null; String signature = (member.getSignature() != null) ? member.getSignature() : member.getDescriptor() .toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); MethodResolver resolver = new MethodResolver(classSig, methodSig);
.toString(); switch (annotation.getElementType()) { case METHOD : {
else analyzer.error("Invalid name for bind method %s", method.getName()).details( new DeclarativeServicesAnnotationError(className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.INVALID_REFERENCE_BIND_METHOD_NAME)); def.updated = reference.updated(); def.bind = method.getName(); def.bindDescriptor = method.getDescriptor().toString(); ReferenceScope scope = reference.scope(); String service = determineReferenceType(method.getDescriptor().toString(), def, annoService, scope);
.toString(); switch (annotation.getElementType()) { case METHOD : {
.toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); MethodResolver resolver = new MethodResolver(classSig, methodSig);
else analyzer.error("Invalid name for bind method %s", method.getName()).details( new DeclarativeServicesAnnotationError(className.getFQN(), method.getName(), method.getDescriptor().toString(), ErrorType.INVALID_REFERENCE_BIND_METHOD_NAME)); def.updated = reference.updated(); def.bind = method.getName(); def.bindDescriptor = method.getDescriptor().toString(); ReferenceScope scope = reference.scope(); String service = determineReferenceType(method.getDescriptor().toString(), def, annoService, scope);
.toString(); MethodSignature methodSig = analyzer.getMethodSignature(signature); MethodResolver resolver = new MethodResolver(classSig, methodSig);