class AbstractMetadataReportFactory implements MetadataReportFactory {

    @Override
    public MetadataReport getMetadataReport(URL url) {
        url = url.setPath(MetadataReport.class.getName())
                .addParameter(Constants.INTERFACE_KEY, MetadataReport.class.getName())
                .removeParameters(Constants.EXPORT_KEY, Constants.REFER_KEY);
        String key = url.toServiceString();
        // Lock the registry access process to ensure a single instance of the registry
        LOCK.lock();
        try {
            MetadataReport metadataReport = SERVICE_STORE_MAP.get(key);
            if (metadataReport != null) {
                return metadataReport;
            }
            metadataReport = createMetadataReport(url);
            if (metadataReport == null) {
                throw new IllegalStateException("Can not create metadata Report " + url);
            }
            SERVICE_STORE_MAP.put(key, metadataReport);
            return metadataReport;
        } finally {
            // Release the lock
            LOCK.unlock();
        }
    }

}