/** * Returns true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and * the target does not specify a key. * * @param logicalReference the logical reference * @param target the target * @return true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and * the target does not specify a key */ private boolean validKey(LogicalReference logicalReference, LogicalComponent<?> target) { return !logicalReference.getDefinition().isKeyed() || target.getDefinition().getKey() != null || target.getDefinition().getComponentType().getKey() != null; } }
/** * Returns the key specified on the component definition, component type, or null * * @param component the component * @return the key or null */ private String getKey(LogicalComponent component) { String key = component.getDefinition().getKey(); if (key == null) { // check if the key was specified in the component type Implementation implementation = component.getDefinition().getImplementation(); if (implementation != null && implementation.getComponentType() != null) { key = implementation.getComponentType().getKey(); } } return key; }
/** * Validates a target key is present for keyed references. * * @param reference the reference * @param service the service * @param context the logical context */ private void validateKeyedReference(LogicalReference reference, LogicalService service, InstantiationContext context) { if (!reference.getDefinition().isKeyed()) { return; } LogicalComponent<?> parent = service.getParent(); if (parent.getDefinition().getKey() == null && parent.getDefinition().getComponentType().getKey() == null) { KeyNotFound error = new KeyNotFound(reference); context.addError(error); } }