/** * 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 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; } }
public void generateWireSource(JavaWireSource source, LogicalReference reference) { URI uri = reference.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) reference.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); source.setInterfaceClass(serviceContract.getInterfaceClass()); // assume for now that any wire from a Java component can be optimized source.setOptimizable(true); if (reference.getDefinition().isKeyed()) { source.setKeyed(true); DataType type = reference.getDefinition().getKeyDataType(); String className = type.getType().getName(); source.setKeyClassName(className); } }
public PhysicalWireSource generateSource(LogicalReference reference) throws Fabric3Exception { URI uri = reference.getUri(); SystemWireSource definition = new SystemWireSource(); definition.setOptimizable(true); definition.setUri(uri); definition.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); JavaServiceContract serviceContract = (JavaServiceContract) reference.getDefinition().getServiceContract(); definition.setInterfaceClass(serviceContract.getInterfaceClass()); if (reference.getDefinition().isKeyed()) { definition.setKeyed(true); String className = reference.getDefinition().getKeyDataType().getType().getName(); definition.setKeyClassName(className); } return definition; }
/** * 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); } }
/** * 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); } }