String mustHide = parseString(component.getName(), element, ATT_HIDE, false);
/*
* Create the relation and add the declared instrumentation
*/
RelationDeclaration relation;
if (! isContextual) {
relation = new RelationDeclaration(component.getReference(), id, sourceKind, targetDef, targetKind, isMultiple,
creationPolicy, resolvePolicy,
missingPolicy, missingException, mustHide != null ? Boolean.valueOf(mustHide) : null);
}
else {
relation = new RelationDeclaration(component.getReference(), id, sourceKind, targetDef, targetKind, isMultiple,
creationPolicy, resolvePolicy,
missingPolicy, missingException, mustHide != null ? Boolean.valueOf(mustHide) : null,
true, sourceName, isOverride);
}
for (RequirerInstrumentation instrumentation : instrumentations) {
relation.getInstrumentations().add(instrumentation);
}
/*
* look for bind and unbind callbacks
*/
String bindCallback = parseString(component.getName(), element, ATT_BIND, false);
String unbindCallback = parseString(component.getName(), element, ATT_UNBIND, false);
if (component instanceof AtomicImplementationDeclaration) {
if (bindCallback != null) {
CallbackDeclaration callback = new CallbackDeclaration((AtomicImplementationDeclaration) component, bindCallback,true);
if (!callback.isValidInstrumentation()) {
errorHandler.report(Severity.ERROR, component.getName() + " : the specified method \"" + bindCallback + "\" in \"" + ATT_BIND + "\" is invalid or not found");
}
relation.addCallback(RelationDeclaration.Event.BIND, callback);
}
if (unbindCallback != null) {
CallbackDeclaration callback = new CallbackDeclaration((AtomicImplementationDeclaration) component, unbindCallback,true);
if (!callback.isValidInstrumentation()) {
errorHandler.report(Severity.ERROR, component.getName() + " : the specified method \"" + unbindCallback + "\" in \"" + ATT_UNBIND + "\" is invalid or not found");
}
relation.addCallback(RelationDeclaration.Event.UNBIND, callback);
}
}
/*
* Get the optional constraints and preferences