Package fr.soleil.salsa.locator.tool

Examples of fr.soleil.salsa.locator.tool.LocatorException


        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


        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<ILocator> locatorClass;
        try {
            locatorClass = (Class<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<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

        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

                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

TOP

Related Classes of fr.soleil.salsa.locator.tool.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.