if (configuration == null) {
throw MESSAGES.nullVar("configuration");
}
configuration.validate();
final Endpoint endpoint;
if (configuration.getEndpoint() != null) {
endpoint = configuration.getEndpoint();
return new ProtocolChannelClient(false, endpoint, null, configuration);
} else {
endpoint = Remoting.createEndpoint(configuration.getEndpointName(), configuration.getOptionMap());
Registration providerRegistration = endpoint.addConnectionProvider(configuration.getUri().getScheme(), new RemoteConnectionProviderFactory(), OptionMap.EMPTY);
return new ProtocolChannelClient(true, endpoint, providerRegistration, configuration);
}
}