@SuppressWarnings("unchecked") @Override public void process(ServiceNode serviceNode, List<AnnotationAttachmentNode> annotations) { List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); resources.forEach( res -> WebSocketResourceValidator.validate(res, dlog, isResourceReturnsErrorOrNil(res), true)); } }
@Override public void process(ServiceNode serviceData, List<AnnotationAttachmentNode> annotations) { List<BLangFunction> resources = (List<BLangFunction>) serviceData.getResources(); resources.forEach(res -> validate(serviceData.getName().getValue(), res, this.dlog)); }
@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)); } }
/** * Build a parsable context from a Ballerina {@link ServiceNode}. * * @param service {@code ServiceNode} for a valid ballerina source file * @param endpoints list of endpoints to be used as service endpoints for generated client * @return A parsable data model for provided ballerina {@code service} * @throws CodeGeneratorException when there are generation exceptions */ public static ClientContextHolder buildContext(ServiceNode service, List<EndpointNode> endpoints) throws CodeGeneratorException { ClientContextHolder context = new ClientContextHolder(); context.name = service.getName().getValue(); context.resources = new ArrayList<>(); context.endpoints = new ArrayList<>(); // Extract bound endpoint details for (EndpointNode ep : endpoints) { EndpointContextHolder epContext = EndpointContextHolder.buildContext(service, ep); if (epContext != null) { context.endpoints.add(EndpointContextHolder.buildContext(service, ep)); } } // Extract ballerina resource nodes as parsable resources for (ResourceNode resource: service.getResources()) { ResourceContextHolder operation = ResourceContextHolder.buildContext(resource); context.resources.add(operation); } return context; }
@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 static boolean validateResource(ServiceNode serviceNode, DiagnosticLog dlog) { List<BLangFunction> resources = (List<BLangFunction>) serviceNode.getResources(); ServiceConfiguration serviceConfig = getServiceConfiguration(serviceNode); if (serviceConfig.getRpcEndpoint() != null && (serviceConfig.isClientStreaming())) {
for (FunctionNode resourceNode : serviceNode.getResources()) { if (ON_MESSAGE_RESOURCE.equals(resourceNode.getName().getValue())) { requestMessage = requestMessage == null ? getRequestMessage(resourceNode) : requestMessage;
for (FunctionNode resourceNode : serviceNode.getResources()) { ResourceConfiguration resourceConfiguration = getResourceConfiguration(resourceNode); Message requestMessage;