All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.galasa.selenium.internal.properties.SeleniumPropertiesSingleton Maven / Gradle / Ivy

There is a newer version: 0.34.0
Show newest version
/*
 * Licensed Materials - Property of IBM
 * 
 * (c) Copyright IBM Corp. 2019.
 */
package dev.galasa.selenium.internal.properties;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;

import dev.galasa.framework.spi.IConfigurationPropertyStoreService;
import dev.galasa.selenium.SeleniumManagerException;

@Component(service = SeleniumPropertiesSingleton.class, immediate = true)
public class SeleniumPropertiesSingleton {

    private static SeleniumPropertiesSingleton  INSTANCE;

    private IConfigurationPropertyStoreService cps;

    @Activate
    public void activate() {
        INSTANCE = this;
    }

    @Deactivate
    public void deacivate() {
        INSTANCE = null;
    }

    public static IConfigurationPropertyStoreService cps() throws SeleniumManagerException {
        if (INSTANCE != null) {
            return INSTANCE.cps;
        }

        throw new SeleniumManagerException("Attempt to access manager CPS before it has been initialised");
    }

    public static void setCps(IConfigurationPropertyStoreService cps) throws SeleniumManagerException {
        if (INSTANCE != null) {
            INSTANCE.cps = cps;
            return;
        }

        throw new SeleniumManagerException("Attempt to set manager CPS before instance created");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy