Package fr.soleil.salsa.exception

Examples of fr.soleil.salsa.exception.LocatorException


        try {
            configFile = ResourceBundle.getBundle(configFileName);
        }
        catch (MissingResourceException e) {
            e.printStackTrace();
            throw new LocatorException("Error : configuration file " + configFileName
                    + ".properties not found : " + e.getMessage(), e);
        }

        // Classe du locator.
        String locatorClassName = configFile.getString(LOCATOR_CLASS_KEY);
        Class<? extends ILocator> locatorClass;
        try {
            locatorClass = (Class<? extends ILocator>) Class.forName(locatorClassName);
        }
        catch (ClassNotFoundException e) {
            e.printStackTrace();
            throw new LocatorException("Erreur : locator class " + locatorClassName
                    + " not found. Check " + configFileName + ".properties. Cause : "
                    + e.getMessage(), e);
        }

        // Locator par d�faut.
        ILocator defaultLocator;
        try {
            String defaultFileName = configFile.getString(DEFAULT_LOCATOR_KEY);
            if (defaultFileName == null || "".equals(defaultFileName.trim())) {
                defaultLocator = null;
            }
            else if (defaultFileName.equals(configFileName)) {
                throw new LocatorException("Error : the configuration file " + configFileName
                        + " gives itself as its own default.");
            }
            else {
                defaultLocator = getLocator(defaultFileName);
                if (log.isDebugEnabled()) {
                    log.debug("Initialization of the locator "
                            + defaultLocator.getClass().getCanonicalName()
                            + " as default locator for " + locatorClass.getCanonicalName() + ".");
                }
            }
        }
        catch (MissingResourceException e) {
            // Ce n'est pas une erreur : avoir un locator par d�faut est optionnel.
            defaultLocator = null;
        }

        // Constructeur du locator.
        Constructor<? extends ILocator> locatorConstructor;
        try {
            locatorConstructor = locatorClass.getConstructor(String.class, ResourceBundle.class,
                    ILocator.class);
        }
        catch (SecurityException e) {
            e.printStackTrace();
            throw new LocatorException("Error : access to the constructor of " + locatorClassName
                    + " with parameters String, ResourceBundle, Locator forbidden. Cause : "
                    + e.getMessage(), e);

        }
        catch (NoSuchMethodException e) {
            e.printStackTrace();
            throw new LocatorException(
                    "Error : the locator "
                            + locatorClassName
                            + " has no constructor with parameters String, ResourceBundle, Locator forbidden. Cause : "
                            + e.getMessage(), e);
        }

        // Instanciation du locator.
        ILocator locator;
        try {
            locator = locatorConstructor.newInstance(configFileName, configFile, defaultLocator);
        }
        catch (IllegalArgumentException e) {
            e.printStackTrace();
            throw new LocatorException(
                    "Error " + e.getClass().getSimpleName() + " when initializing the locator "
                            + locatorClassName + " : " + e.getMessage(), e);
        }
        catch (InstantiationException e) {
            e.printStackTrace();
            throw new LocatorException(
                    "Error " + e.getClass().getSimpleName() + " when initializing the locator "
                            + locatorClassName + " : " + e.getMessage(), e);
        }
        catch (IllegalAccessException e) {
            e.printStackTrace();
            throw new LocatorException(
                    "Error " + e.getClass().getSimpleName() + " when initializing the locator "
                            + locatorClassName + " : " + e.getMessage(), e);
        }
        catch (InvocationTargetException e) {
            e.printStackTrace();
            throw new LocatorException(
                    "Error " + e.getClass().getSimpleName() + " when initializing the locator "
                            + locatorClassName + " : " + e.getMessage(), e);
        }

        log.debug("Initialization of the locator " + locator.getClass().getCanonicalName()
View Full Code Here


    protected <T> T dispatchToDefault(Class<T> interfaceClass) throws LocatorException {
        if (this.defaultLocator == null) {
            // If there is no default locator and the current locator has no matching key for the
            // service,
            // the service cannot be found.
            throw new LocatorException("The key " + interfaceClass.getCanonicalName()
                    + " could not be found in " + configFileName
                    + ".properties, and there is no default locator : the service "
                    + interfaceClass.getCanonicalName() + " cannot be found.");
        }
        ILocator locator = (ILocator) this.defaultLocator.getService(interfaceClass);
View Full Code Here

                log.debug("Initialisation du service " + interfaceClass.getCanonicalName()
                        + " par le locator " + this.getClass().getSimpleName() " via un context lookup de " + configValue + ".");
            }
        } catch (NamingException e) {
            e.printStackTrace();
            throw new LocatorException("Erreur de connexion au serveur lors de l'initialisation du service " + interfaceClass.getCanonicalName() + ".", e);
        }
        return service;
    }
View Full Code Here

            configFile = ResourceBundle.getBundle(configFileName);
        } catch (MissingResourceException e) {
            String errorMessage = "Configuration file " + configFileName + ".properties not found " + e.getMessage();
            LOGGER.error(errorMessage);
            LOGGER.debug("Stack trace", e);
            throw new LocatorException(errorMessage, e);
        }

        // Classe du locator.
        String locatorClassName = configFile.getString(LOCATOR_CLASS_KEY);
        Class<? extends ILocator> locatorClass;
        try {
            locatorClass = (Class<? extends ILocator>) Class.forName(locatorClassName);
        } catch (ClassNotFoundException e) {
            String errorMessage = "Locator class " + locatorClassName + " not found. Check " + configFileName
            + ".properties " + e.getMessage();
            LOGGER.error(errorMessage);
            throw new LocatorException(errorMessage, e);
        }

        // Locator par d�faut.
        ILocator defaultLocator;
        try {
            String defaultFileName = configFile.getString(DEFAULT_LOCATOR_KEY);
            if ((defaultFileName == null) || "".equals(defaultFileName.trim())) {
                defaultLocator = null;
            } else if (defaultFileName.equals(configFileName)) {
                String errorMessage = "Configuration file " + configFileName + " gives itself as its own default.";
                LOGGER.error(errorMessage);
                LocatorException locatorException = new LocatorException(errorMessage);
                LOGGER.debug("Stack trace", locatorException);
                throw locatorException;
            } else {
                defaultLocator = getLocator(defaultFileName);
                String infoMessage = "Initialization of the locator " + defaultLocator.getClass().getCanonicalName()
                + " as default locator for " + locatorClass.getCanonicalName();
                LOGGER.debug(infoMessage);
            }
        } catch (MissingResourceException e) {
            // Ce n'est pas une erreur : avoir un locator par d�faut est optionnel.
            defaultLocator = null;
            LOGGER.warn("Default locator not found {}", e.getMessage());
            LOGGER.debug("Stack trace", e);
        }

        // Constructeur du locator.
        Constructor<? extends ILocator> locatorConstructor;
        try {
            locatorConstructor = locatorClass.getConstructor(String.class, ResourceBundle.class, ILocator.class);
        } catch (SecurityException e) {
            String errorMessage = "Access to the constructor of " + locatorClassName + " with parameters is forbidden "
            + e.getMessage();
            LOGGER.error(errorMessage);
            LOGGER.debug("Stack trace", e);
            throw new LocatorException(errorMessage, e);

        } catch (NoSuchMethodException e) {
            String errorMessage = "Constructor of " + locatorClassName + " with parameters not found " + e.getMessage();
            LOGGER.error(errorMessage);
            LOGGER.debug("Stack trace", e);
            throw new LocatorException(errorMessage, e);
        }

        // Instanciation du locator.
        ILocator locator;
        try {
            locator = locatorConstructor.newInstance(configFileName, configFile, defaultLocator);
            LOGGER.debug("Initialization of the locator " + locator.getClass().getCanonicalName()
                    + " as primary locator.");
        } catch (Exception e) {
            String errorMessage = "Cannot initialize the locator " + e.getMessage();
            LOGGER.error(errorMessage);
            LOGGER.debug("Stack trace", e);
            throw new LocatorException(errorMessage, e);
        }
        return locator;
    }
View Full Code Here

        try {
            serviceClass = (Class<T>) Class.forName(configValue);
        }
        catch(ClassNotFoundException e) {
            e.printStackTrace();
            throw new LocatorException("Error at service creation : the class " + configValue + " was not found. See "
                    + this.configFileName + ".properties.", e);
        }
        Constructor<T> serviceConstructor;
        try {
            serviceConstructor = serviceClass.getConstructor();
        } catch (SecurityException e) {
            e.printStackTrace();
            throw new LocatorException("Error at service creation " + interfaceClass.getCanonicalName()
                    + " : the access to the constructor without parameters of the class "
                    + serviceClass.getCanonicalName() + " is forbidden.");
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
            throw new LocatorException("Error at service creation " + interfaceClass.getCanonicalName()
                    + " : the class " + serviceClass.getCanonicalName()
                    + " has no constructor without parameters.", e);
        }
        T service;
        try {
            service = serviceConstructor.newInstance();
            if (log.isDebugEnabled()) {
                log.debug("Initialization of the service " + interfaceClass.getCanonicalName()
                        + " by the locator " + this.getClass().getSimpleName() " using the implementation " + configValue + ".");
            }
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            throw new LocatorException("Error " + e.getClass().getSimpleName() + " at service instanciation " + interfaceClass.getCanonicalName()
                    + " : " + e.getMessage(), e);
        } catch (InstantiationException e) {
            e.printStackTrace();
            throw new LocatorException("Error " + e.getClass().getSimpleName() + " at service instanciation " + interfaceClass.getCanonicalName()
                    + " : " + e.getMessage(), e);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            throw new LocatorException("Error " + e.getClass().getSimpleName() + " at service instanciation " + interfaceClass.getCanonicalName()
                    + " : " + e.getMessage(), e);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            throw new LocatorException("Error " + e.getClass().getSimpleName() + " at service instanciation " + interfaceClass.getCanonicalName()
                    + " : " + e.getMessage(), e);
        }
       
        return service;
    }
View Full Code Here

        }
        catch(ClassNotFoundException e) {
            String errorMessage = "Cannot created service " + configValue + ". See "+ this.configFileName + ".properties " + e.getMessage();
            LOGGER.error(errorMessage);
            LOGGER.debug("Stack trace", e);
            throw new LocatorException(errorMessage, e);
        }
        Constructor<T> serviceConstructor;
        try {
            serviceConstructor = serviceClass.getConstructor();
        } catch (SecurityException e) {
            String errorMessage = "Cannot created service " + interfaceClass.getCanonicalName()
            + " the access to the constructor without parameters is forbidden.";
            LOGGER.error(errorMessage);
            throw new LocatorException(errorMessage);
        } catch (NoSuchMethodException e) {
            String errorMessage = "Cannot create service " + interfaceClass.getCanonicalName()
            + " has no constructor without parameters.";
            LOGGER.error(errorMessage);
            throw new LocatorException(errorMessage, e);
        }

        try {
            service = serviceConstructor.newInstance();
            String infoMessage = "Initialization of the service " + service.getClass().getCanonicalName();
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.exception.LocatorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.