private static boolean isServerStreaming(FunctionNode resourceNode) { boolean serverStreaming = false; for (AnnotationAttachmentNode annotationNode : resourceNode.getAnnotationAttachments()) { if (!ANN_RESOURCE_CONFIG.equals(annotationNode.getAnnotationName().getValue())) { continue; } if (annotationNode.getExpression() instanceof BLangRecordLiteral) { List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) annotationNode .getExpression()).getKeyValuePairs(); for (BLangRecordLiteral.BLangRecordKeyValue attributeNode : attributes) { String attributeName = attributeNode.getKey().toString(); String attributeValue = attributeNode.getValue() != null ? attributeNode.getValue().toString() : null; if (ANN_ATTR_RESOURCE_SERVER_STREAM.equals(attributeName)) { serverStreaming = attributeValue != null && Boolean.parseBoolean(attributeValue); } } } } return serverStreaming; }
/** * Retrieve a specific annotation by name from a list of annotations. * * @param name name of the required annotation * @param pkg package of the required annotation * @param annotations list of annotations containing the required annotation * @return returns annotation with the name <code>name</code> if found or * null if annotation not found in the list */ public static AnnotationAttachmentNode getAnnotationFromList(String name, String pkg, List<? extends AnnotationAttachmentNode> annotations) { AnnotationAttachmentNode annotation = null; if (name == null || pkg == null) { return null; } for (AnnotationAttachmentNode ann : annotations) { if (pkg.equals(ann.getPackageAlias().getValue()) && name.equals(ann.getAnnotationName().getValue())) { annotation = ann; } } return annotation; }
@SuppressWarnings("unchecked") @Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { if (annotations.size() > 1) { int count = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(WEBSOCKET_ANNOTATION_CONFIGURATION)) { count++; } } if (count > 1) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "There cannot be more than one " + WEBSOCKET_SERVICE + " annotations"); } } List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); resources.forEach( res -> WebSocketResourceValidator.validate(res, dlog, isResourceReturnsErrorOrNil(res), false)); } }
@Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { for (AnnotationAttachmentNode attachmentNode : annotations) { String annotationKey = attachmentNode.getAnnotationName().getValue(); try { AnnotationProcessorFactory.getAnnotationProcessorInstance(annotationKey).processAnnotation (serviceNode, attachmentNode); } catch (KubernetesPluginException e) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), e.getMessage()); } } }
int count = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(ANN_SERVICE_CONFIG)) { if (annotation.getExpression() != null) { annVals = ((BLangRecordLiteral) annotation.getExpression()).keyValuePairs; count++;
@Override public void process(FunctionNode functionNode, List<AnnotationAttachmentNode> annotations) { for (AnnotationAttachmentNode attachmentNode : annotations) { String annotationKey = attachmentNode.getAnnotationName().getValue(); try { AnnotationProcessorFactory.getAnnotationProcessorInstance(annotationKey).processAnnotation (functionNode, attachmentNode); } catch (KubernetesPluginException e) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, functionNode.getPosition(), e.getMessage()); } } }
/** * Retrieves a specific annotation by name from a list of annotations. * * @param name name of the required annotation * @param pkg package of the required annotation * @param annotations list of annotations containing the required annotation * @return returns annotation with the name <code>name</code> if found or * null if annotation not found in the list */ public static AnnotationAttachmentNode getAnnotationFromList(String name, String pkg, List<? extends AnnotationAttachmentNode> annotations) { AnnotationAttachmentNode annotation = null; if (name == null || pkg == null) { return null; } for (AnnotationAttachmentNode ann : annotations) { if (pkg.equals(ann.getPackageAlias().getValue()) && name.equals(ann.getAnnotationName().getValue())) { annotation = ann; } } return annotation; } }
if (!ServiceProtoConstants.ANN_SERVICE_CONFIG.equals(annotationNode.getAnnotationName().getValue())) { continue; if (annotationNode.getExpression() instanceof BLangRecordLiteral) { List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) annotationNode .getExpression()).getKeyValuePairs(); for (BLangRecordLiteral.BLangRecordKeyValue attributeNode : attributes) { String attributeName = attributeNode.getKey().toString();
try { for (AnnotationAttachmentNode attachmentNode : annotations) { DockerAnnotation dockerAnnotation = DockerAnnotation.valueOf(attachmentNode.getAnnotationName() .getValue()); switch (dockerAnnotation) {
if (!ServiceProtoConstants.ANN_RESOURCE_CONFIG.equals(annotationNode.getAnnotationName().getValue())) { continue; if (annotationNode.getExpression() instanceof BLangRecordLiteral) { List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) annotationNode .getExpression()).getKeyValuePairs(); for (BLangRecordLiteral.BLangRecordKeyValue attributeNode : attributes) { String attributeName = attributeNode.getKey().toString();
@Override public void process(SimpleVariableNode variableNode, List<AnnotationAttachmentNode> annotations) { if (!variableNode.getFlags().contains(Flag.LISTENER)) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, variableNode.getPosition(), "@kubernetes annotations are only " + "supported with listeners."); return; } for (AnnotationAttachmentNode attachmentNode : annotations) { String annotationKey = attachmentNode.getAnnotationName().getValue(); try { AnnotationProcessorFactory.getAnnotationProcessorInstance(annotationKey).processAnnotation (variableNode, attachmentNode); } catch (KubernetesPluginException e) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, variableNode.getPosition(), e.getMessage()); } } }
int count = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(ANN_NAME_RESOURCE_CONFIG) && annotation.getExpression() != null) { annVals = ((BLangRecordLiteral) annotation.getExpression()).keyValuePairs; count++;
try { for (AnnotationAttachmentNode attachmentNode : annotations) { DockerAnnotation dockerAnnotation = DockerAnnotation.valueOf(attachmentNode.getAnnotationName() .getValue()); switch (dockerAnnotation) {
String annotationName = attachmentNode.getAnnotationName().getValue(); String functionName = functionNode.getName().getValue(); if (attachmentNode.getExpression() instanceof BLangRecordLiteral) { List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) attachmentNode .getExpression()).getKeyValuePairs(); attributes.forEach(attributeNode -> { String name = attributeNode.getKey().toString(); boolean shouldIncludeGroups = registry.shouldIncludeGroups(); if (attachmentNode.getExpression() instanceof BLangRecordLiteral) { List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) attachmentNode .getExpression()).getKeyValuePairs();
@SuppressWarnings("unchecked") @Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { int serviceConfigCount = 0; for (AnnotationAttachmentNode annotation : annotations) { if (annotation.getAnnotationName().getValue().equals(ANN_NAME_HTTP_SERVICE_CONFIG)) { handleServiceConfigAnnotation(serviceNode, (BLangAnnotationAttachment) annotation); serviceConfigCount++; } } if (serviceConfigCount > 1) { dlog.logDiagnostic(Diagnostic.Kind.ERROR, serviceNode.getPosition(), "multiple service configuration annotations found in service : " + serviceNode.getName().getValue()); } // final UserDefinedTypeNode serviceType = serviceNode.getServiceTypeStruct(); // if (serviceType != null && HttpConstants.HTTP_SERVICE_TYPE.equals(serviceType.getTypeName() // .getValue())) { List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); resources.forEach(res -> { ResourceSignatureValidator.validateAnnotation(res, dlog); ResourceSignatureValidator.validate(res.getParameters(), dlog, res.pos); ResourceSignatureValidator.validateResourceReturnType(isResourceReturnsErrorOrNil(res), dlog, res.pos); }); // } // get value from endpoint. // ((BLangSimpleVarRef) serviceNode.getBoundEndpoints().get(0)).varSymbol.getType().tsymbol.name.value }
private void addDescriptorAnnotation(ServiceNode serviceNode, String rootDescriptor) { for (AnnotationAttachmentNode annonNodes : serviceNode.getAnnotationAttachments()) { if (ANN_SERVICE_DESCRIPTOR.equals(annonNodes.getAnnotationName().getValue())) { return;