Package org.apache.geronimo.kernel.config

Examples of org.apache.geronimo.kernel.config.InvalidConfigException


    public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
        // determine the source file/dir
        File source = configurationData.getConfigurationDir();
        if (!source.exists()) {
            throw new InvalidConfigException("Source does not exist " + source);
        } else if (!source.canRead()) {
            throw new InvalidConfigException("Source is not readable " + source);
        }

        // determine the target location
        Artifact configId = configurationData.getId();
        File destination = repository.getLocation(configId);

        // if directory in the correct place -- noop
        if (!source.equals(destination)) {
            if (destination.exists()) {
                throw new ConfigurationAlreadyExistsException(configId.toString());
            }

            if (source.isFile()) {
                // Assume this is a jar file
                // copy it into the repository; repository should unpack it
                repository.copyToRepository(source, configId, null);
            } else if (source.isDirectory()) {
                // directory is in wrong place -- directory copy
                IOUtil.recursiveCopy(source, destination);
            } else {
                throw new InvalidConfigException("Unable to install configuration from " + source);
            }
        }

        ExecutableConfigurationUtil.writeConfiguration(configurationData, destination);
View Full Code Here


                    if (!(name instanceof AbstractName)) {
                        message.append(sep).append("a full AbstractName ");
                    }
                    message.append("configuration=").append(configName);
                    message.append(" gbeanName=").append(name);
                    throw new InvalidConfigException(message.toString());
                }
                GBeanInfo gbeanInfo = GBeanInfo.getGBeanInfo(gbean.getGBeanInfo(), classLoader);
                AbstractName abstractName = (AbstractName)name;
                GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo);
                gbeanDatas.add(gBeanData);
View Full Code Here

        for (Iterator iterator = gbean.getAttributes().entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String attributeName = (String) entry.getKey();
            GAttributeInfo attributeInfo = gbeanInfo.getAttribute(attributeName);
            if (attributeInfo == null) {
                throw new InvalidConfigException("No attribute: " + attributeName + " for gbean: " + data.getAbstractName());
            }
            String valueString = (String) entry.getValue();
            Object value = getValue(attributeInfo, valueString, configName, gbeanName, classLoader);
            data.setAttribute(attributeName, value);
        }

        //Clear attributes
        for (Iterator iterator = gbean.getClearAttributes().iterator(); iterator.hasNext();){
           String attribute = (String) iterator.next();
           if (gbean.getClearAttribute(attribute)){
               data.clearAttribute(attribute);
           }
        }

        //Null attributes
        for (Iterator iterator = gbean.getNullAttributes().iterator(); iterator.hasNext();){
           String attribute = (String) iterator.next();
           if (gbean.getNullAttribute(attribute)){
               data.setAttribute(attribute, null);
           }
        }

        // set references
        for (Iterator iterator = gbean.getReferences().entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();

            String referenceName = (String) entry.getKey();
            GReferenceInfo referenceInfo = gbeanInfo.getReference(referenceName);
            if (referenceInfo == null) {
                throw new InvalidConfigException("No reference: " + referenceName + " for gbean: " + data.getAbstractName());
            }

            ReferencePatterns referencePatterns = (ReferencePatterns) entry.getValue();

            data.setReferencePatterns(referenceName, referencePatterns);
View Full Code Here

                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to load gbeans", e);
            } finally {
                Thread.currentThread().setContextClassLoader(oldCl);
            }
        }
        return Collections.EMPTY_LIST;
View Full Code Here

                    dependencies.add(dependency.getArtifact());
                }

                System.out.println("Installed configuration " + configId);
            } catch (IOException e) {
                throw new InvalidConfigException("Unable to load configuration: " + configId, e);
            } catch (NoSuchConfigException e) {
                throw new InvalidConfigException("Unable to load configuration: " + configId, e);
            }
        } else {
            if (!sourceRepo.contains(configId)) {
                throw new RuntimeException("Dependency: " + configId + " not found in local maven repo: for configuration: " + artifact);
            }
View Full Code Here

    }

    public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
        File source = configurationData.getConfigurationDir();
        if (!source.isDirectory()) {
            throw new InvalidConfigException("Source must be a directory: source=" + source);
        }
        Artifact configId = configurationData.getId();
        File targetFile = repository.getLocation(configId);
        ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null, targetFile);
    }
View Full Code Here

                xstream.setClassLoader(classLoader);
                Object o = xstream.unmarshal(reader);
                GBeanData[] gbeanDatas = (GBeanData[]) o;
                return Arrays.asList(gbeanDatas);
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to load gbeans", e);
            } finally {
                Thread.currentThread().setContextClassLoader(oldCl);
            }
        }
        return Collections.EMPTY_LIST;
View Full Code Here

    }

    public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
        File source = configurationData.getConfigurationDir();
        if (!source.isDirectory()) {
            throw new InvalidConfigException("Source must be a directory: " + source);
        }
       
        Artifact configId = configurationData.getId();
        File targetFile = repository.getLocation(configId);
        ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, null, targetFile);
View Full Code Here

                    if (!(name instanceof AbstractName)) {
                        message.append(sep).append("a full AbstractName ");
                    }
                    message.append("configuration=").append(configName);
                    message.append(" gbeanName=").append(name);
                    throw new InvalidConfigException(message.toString());
                }
                GBeanInfo gbeanInfo = GBeanInfo.getGBeanInfo(gbean.getGBeanInfo(), classLoader);
                AbstractName abstractName = (AbstractName) name;
                GBeanData gBeanData = new GBeanData(abstractName, gbeanInfo);
                gbeanDatas.add(gBeanData);
View Full Code Here

            if (location.isDirectory()) {
                File serFile = new File(location, "META-INF");
                serFile = new File(serFile, "config.ser");

                if (!serFile.exists()) {
                    throw new InvalidConfigException("Configuration does not contain a META-INF/config.ser file: " + serFile);
                } else if (!serFile.canRead()) {
                    throw new InvalidConfigException("Can not read configuration META-INF/config.ser file: " + serFile);
                }

                ConfigurationStoreUtil.verifyChecksum(serFile);

                InputStream in = new FileInputStream(serFile);
                try {
                    configurationData = ConfigurationUtil.readConfigurationData(in);
                } finally {
                    IOUtil.close(in);
                }
            } else {
                JarFile jarFile = new JarFile(location);
                InputStream in = null;
                try {
                    ZipEntry entry = jarFile.getEntry("META-INF/config.ser");
                    in = jarFile.getInputStream(entry);
                    configurationData = ConfigurationUtil.readConfigurationData(in);
                } finally {
                    IOUtil.close(in);
                    IOUtil.close(jarFile);
                }
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidConfigException("Unable to load class from config: " + configId, e);
        }

        configurationData.setConfigurationDir(location);
        configurationData.setConfigurationStore(this);
        if (kernel != null) {
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.config.InvalidConfigException

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.