getConnectorByName method

EndpointConnector? getConnectorByName(
  1. String endpointName
)
inherited

Finds an EndpointConnector by its name. If the connector is in a module, a period should separate the module name from the endpoint name.

Implementation

EndpointConnector? getConnectorByName(String endpointName) {
  var endpointComponents = endpointName.split('.');
  if (endpointComponents.isEmpty || endpointComponents.length > 2) {
    return null;
  }

  // Find correct connector
  EndpointConnector? connector;

  if (endpointComponents.length == 1) {
    // This is a standard server endpoint
    connector = connectors[_endpointFromName(endpointName)];
    if (connector == null) return null;
  } else {
    // Connector is in a module
    var modulePackage = endpointComponents[0];
    endpointName = endpointComponents[1];
    var module = modules[modulePackage];
    if (module == null) return null;

    connector = module.connectors[_endpointFromName(endpointName)];
    if (connector == null) return null;
  }

  return connector;
}