* @return The service endpoint, or null if the endpoint is not found.
*/
public static Endpoint getServiceEndpoint(String endpointName, String contextName) {
SPIProvider spiProv = SPIProviderResolver.getInstance().getProvider();
EndpointRegistryFactory factory = spiProv.getSPI(EndpointRegistryFactory.class);
EndpointRegistry registry = factory.getEndpointRegistry();
Set<ObjectName> objectNames = registry.getEndpoints();
for (ObjectName objectName : objectNames) {
String context = objectName.getKeyProperty(Endpoint.SEPID_PROPERTY_CONTEXT);
String endpoint = objectName.getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
if ((contextName != null
&& context != null && context.equals(contextName)
&& endpoint != null && endpoint.equals(endpointName))
|| (contextName == null
&& endpoint != null && endpoint.equals(endpointName))) {
return registry.getEndpoint(objectName);
}
}
return null;
}