}
private void generateInhabitantEntry(MethodDeclaration d, AnnotationMirror a, InhabitantAnnotation ia) {
InhabitantsDescriptor descriptor = list.get(ia.value());
String service=null;
ServiceProvider sp = a.getAnnotationType().getDeclaration().getAnnotation(ServiceProvider.class);
if (sp!=null) {
try {
sp.value();
} catch (MirroredTypeException e) {
service = ((DeclaredType)e.getTypeMirror()).getDeclaration().getQualifiedName();
}
}
/* String service=null;
// I cannot use a.getAnnotationType().getDeclaration().getAnnotation() because the value() is a class
// which cannot be loaded by the classloader at compile time.
for (AnnotationMirror am : a.getAnnotationType().getDeclaration().getAnnotationMirrors()) {
if (am.getAnnotationType().getDeclaration().getSimpleName().equals(ServiceProvider.class.getSimpleName())) {
for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : am.getElementValues().entrySet()) {
service = entry.getValue()toString();
service = ((DeclaredType)entry.).getDeclaration().getQualifiedName()
}
}
}
*/
if (service!=null) {
String name = getIndexValue(a);
String contract=null;
ContractProvided cp = a.getAnnotationType().getDeclaration().getAnnotation(ContractProvided.class);
if (cp!=null) {
try {
cp.value();
} catch (MirroredTypeException e) {
contract = ((DeclaredType)e.getTypeMirror()).getDeclaration().getQualifiedName();
}
}
/*String contract="";
// we should support getting the @ContractProvided from the ServiceProvider
for (AnnotationMirror am : a.getAnnotationType().getDeclaration().getAnnotationMirrors()) {
if (am.getAnnotationType().getDeclaration().getSimpleName().equals(ContractProvided.class.getSimpleName())) {
for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : am.getElementValues().entrySet()) {
contract = entry.getValue().toString();
}
}
} */
StringBuilder buf = new StringBuilder();
buf.append(InhabitantsFile.CLASS_KEY).append('=').append(service);
buf.append(",").append(INDEX_KEY).append("=").append(contract).append(":").append(name);
buf.append(",").append(TARGET_TYPE).append("=").append(d.getDeclaringType().getQualifiedName());
buf.append(",").append("method-name").append('=').append(d.getSimpleName());
for (AnnotationTypeElementDeclaration ated : a.getAnnotationType().getDeclaration().getMethods()) {
for (AnnotationMirror am : ated.getAnnotationMirrors()) {
if (am.getAnnotationType().getDeclaration().getSimpleName().equals(InhabitantMetadata.class.getSimpleName())) {
for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : a.getElementValues().entrySet()) {
if (entry.getKey().getSimpleName().equals(ated.getSimpleName())) {
buf.append(",").append(ated.getSimpleName()).append("=").append(entry.getValue().toString());
}
}
}
}
}
descriptor.put(contract+":"+name, buf.toString());
} else {
descriptor.put(d.getDeclaringType().getQualifiedName(),
getInhabitantDeclaration(a, (ClassDeclaration) d.getDeclaringType()));
}
}