protected abstract JBIException createServiceUnavailableException();
protected ServiceEndpoint[] filterEndpoints(ServiceEndpoint[] endpoints, MessageExchange exchange, EndpointFilter filter) {
int matches = 0;
for (int i = 0; i < endpoints.length; i++) {
ServiceEndpoint endpoint = endpoints[i];
if (filter.evaluate(endpoint, exchange)) {
matches++;
}
else {
endpoints[i] = null;
}
}
if (matches == endpoints.length) {
return endpoints;
}
else {
ServiceEndpoint[] answer = new ServiceEndpoint[matches];
for (int i = 0, j = 0; i < endpoints.length; i++) {
ServiceEndpoint endpoint = endpoints[i];
if (endpoint != null) {
answer[j++] = endpoints[i];
}
}
return answer;