Search in sources :

Example 1 with SimpleVariableReferenceNode

use of org.ballerinalang.model.tree.expressions.SimpleVariableReferenceNode in project ballerina by ballerina-lang.

the class EndpointContextHolder method buildContext.

/**
 * Build a parsable object model for a service endpoint. {@code ep} must be bound to the {@code service}
 * inorder to extract its details. If {@code ep} is not bound to the {@code service} null
 * will be returned
 *
 * @param service service with bound endpoints
 * @param ep      {@link EndpointNode} which to extract details from
 * @return if {@code ep} is bound to the {@code service}, endpoint context will be returned.
 * otherwise empty null will be returned
 */
public static EndpointContextHolder buildContext(ServiceNode service, EndpointNode ep) {
    EndpointContextHolder endpoint = null;
    for (SimpleVariableReferenceNode node : service.getBoundEndpoints()) {
        if (node.getVariableName().equals(ep.getName())) {
            endpoint = new EndpointContextHolder();
            AnnotationAttachmentNode ann = GeneratorUtils.getAnnotationFromList("ServiceConfig", GeneratorConstants.HTTP_PKG_ALIAS, service.getAnnotationAttachments());
            endpoint.extractDetails(ep, ann);
            break;
        }
    }
    return endpoint;
}
Also used : SimpleVariableReferenceNode(org.ballerinalang.model.tree.expressions.SimpleVariableReferenceNode) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode)

Aggregations

AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)1 SimpleVariableReferenceNode (org.ballerinalang.model.tree.expressions.SimpleVariableReferenceNode)1