Skip to content
Snippets Groups Projects
Commit 99f854d3 authored by Idrissa DIENG's avatar Idrissa DIENG
Browse files

Bug 451340 - Check-based Validation Framework. Refactored singleton

instance
parent e458b38d
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ public class BasicCheckValidationAction extends BaseSelectionListenerAction {
final EPackage ePackage = validationInput.eClass().getEPackage();
try {
// get the associated validator
final EValidator validator = CheckValidatorRegistry.getInstance().getValidator(ePackage);
final EValidator validator = CheckValidatorRegistry.INSTANCE.getValidator(ePackage);
Assert.isNotNull(validator);
// query validation sets from user
......
......@@ -37,7 +37,7 @@ public class CheckModelHelper {
public CheckModelHelper(ICheckValidator checkValidator) {
String fqn = checkValidator.getClass().getName();
URI uri = CheckValidatorRegistry.getInstance().getCheckModelURI(fqn);
URI uri = CheckValidatorRegistry.INSTANCE.getCheckModelURI(fqn);
Assert.isNotNull(uri);
Resource checkResource = new ResourceSetImpl().getResource(uri, true);
EObject eObject = checkResource.getContents().get(0);
......
......@@ -28,7 +28,7 @@ public final class Activator extends EMFPlugin {
/**
* Returns the singleton instance of the Eclipse plug-in.
*
*
* @return the singleton instance.
*/
@Override
......@@ -38,7 +38,7 @@ public final class Activator extends EMFPlugin {
/**
* Returns the singleton instance of the Eclipse plug-in.
*
*
* @return the singleton instance.
*/
public static Implementation getPlugin() {
......@@ -49,7 +49,7 @@ public final class Activator extends EMFPlugin {
* Returns the singleton instance of the Eclipse plug-in. This method does actually the same thing as getPlugin()
* and has been put in place for compatibility reasons with Activator classes which are not EMF-based but generated
* by PDE.
*
*
* @return the singleton instance.
*/
public static Implementation getDefault() {
......@@ -75,7 +75,7 @@ public final class Activator extends EMFPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
CheckValidatorRegistry.getInstance().initialize();
CheckValidatorRegistry.INSTANCE.initialize();
}
}
}
\ No newline at end of file
......@@ -41,6 +41,8 @@ import org.eclipse.sphinx.platform.util.PlatformLogUtil;
public class CheckValidatorRegistry {
public static CheckValidatorRegistry INSTANCE = new CheckValidatorRegistry();
private static final String checkValidator_extenstion = "org.eclipse.sphinx.emf.check.checkvalidator"; //$NON-NLS-1$
private static final String checkValidator_configElement = "validator"; //$NON-NLS-1$
private static final String validator_class = "class"; //$NON-NLS-1$
......@@ -50,17 +52,8 @@ public class CheckValidatorRegistry {
private org.eclipse.emf.ecore.EValidator.Registry eValidatorRegistry = null;
private static CheckValidatorRegistry INSTANCE = null;
private Map<String, URI> validatorToCheckModelMap = Collections.synchronizedMap(new LinkedHashMap<String, URI>());
public static CheckValidatorRegistry getInstance() {
if (INSTANCE == null) {
INSTANCE = new CheckValidatorRegistry();
}
return INSTANCE;
}
private CheckValidatorRegistry() {
eValidatorRegistry = EValidator.Registry.INSTANCE;
// initialize();
......@@ -119,7 +112,7 @@ public class CheckValidatorRegistry {
/**
* The following method makes the assumption that the EPackage is located in the same Java package than the classes
* given as input, which is the default behavior of the EMF API model generator.
*
*
* @param classes
* @return
*/
......@@ -162,7 +155,7 @@ public class CheckValidatorRegistry {
/**
* Retrieve a check-based validator contributed through the checkvalidator extension point for the given package.
*
*
* @param ePackage
* @return
* @throws CoreException
......@@ -190,7 +183,7 @@ public class CheckValidatorRegistry {
/**
* Returns the URI of a check model given a fully qualified name of a check validator.
*
*
* @param fqn
* @return
*/
......
......@@ -27,9 +27,8 @@ public abstract class AbstractCheckWorkflowComponent extends AbstractModelWorkfl
public ICheckValidator getValidator(EPackage ePackage) throws CoreException {
if (validator == null) {
CheckValidatorRegistry registry = CheckValidatorRegistry.getInstance();
validator = registry.getValidator(ePackage);
registry.register(ePackage, validator);
validator = CheckValidatorRegistry.INSTANCE.getValidator(ePackage);
CheckValidatorRegistry.INSTANCE.register(ePackage, validator);
}
return validator;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment