BundleContext bundleContext = ((BundleReference) getClass().getClassLoader()).getBundle().getBundleContext();
ServiceReference ref = bundleContext.getServiceReference(IDiagramProfileService.class.getName());
if (ref == null) {
throw new IllegalArgumentException(profileName + " is not registered");
}
IDiagramProfileService service = (IDiagramProfileService) bundleContext.getService(ref);
profile = service.findProfile(req, profileName);
} else {
// check w/o BundleReference
IDiagramProfileService service = ProfileServiceImpl.INSTANCE;
profile = service.findProfile(req, profileName);
if(profile == null) {
throw new IllegalArgumentException("Cannot determine the profile to use for interpreting models");
}
}
return profile;