Package org.lilyproject.runtime

Examples of org.lilyproject.runtime.LilyRTException


        public URL getURL() {
            try {
                return file.toURL();
            } catch (MalformedURLException e) {
                throw new LilyRTException("Error constructing file URL for file " + file.getAbsolutePath(), e);
            }
        }
View Full Code Here


        if (processor != null) {
            try {
                return processor.process(element, parserContext, springBuildContext);
            } catch (Throwable e) {
                throw new LilyRTException("Error handling " + elementName + " directive.", e);
            }
        }

        return null;
    }
View Full Code Here

                } catch (Throwable e2) {
                    log.error("Error disposing module source for file " + moduleDefinition.getFile().getAbsolutePath(), e2);
                }
            }

            throw new LilyRTException("Error reading module config from " + moduleDefinition.getFile().getAbsolutePath(), e);
        }
    }
View Full Code Here

                File sourceLocation = artifactSourceLocations.getSourceLocation(groupId, artifactId);
                if (sourceLocation != null) {
                    fileToImport = sourceLocation.getCanonicalFile();
                    if (!fileToImport.exists()) {
                        throw new LilyRTException("Specified artifact source directory does not exist: "
                                + fileToImport.getAbsolutePath(), importConf.getLocation());
                    }
                    sourceType = ModuleSourceType.SOURCE_DIRECTORY;
                } else {
                    fileToImport = repository.resolve(groupId, artifactId, classifier, version);
                    sourceType = ModuleSourceType.JAR;
                }
            } else if (importConf.getName().equals("directory")) {
                id = importConf.getAttribute("id");

                String dirName = PropertyResolver.resolveProperties(importConf.getAttribute("path"));

                // When basePath is specified, the directory specified in dirName will be resolved
                // against basePath. Moreover, basePath can contain a list of paths,
                // in which case each basePath will be combined with the path. (this is the only
                // reason for having basePath as a separate attribute)
                // (It would make sense to allow multiple values for path as well, but the
                // need hasn't come up)
                String basePath = importConf.getAttribute("basePath", null);
                if (basePath != null) {
                    basePath = PropertyResolver.resolveProperties(basePath);
                    String[] basePaths = basePath.split(File.pathSeparator);
                    for (String path : basePaths) {
                        path = path.trim();
                        if (path.length() > 0) {
                            String subDirName = new File(new File(path), dirName).getAbsolutePath();
                            include(subDirName, id, modules, wiringFileStack, repository, artifactSourceLocations);
                        }
                    }
                } else {
                    include(dirName, id, modules, wiringFileStack, repository, artifactSourceLocations);
                }

            } else {
                throw new LilyRTException("Unexpected node: " + importConf.getName(), importConf.getLocation());
            }

            if (fileToImport != null) {
                if (!fileToImport.exists()) {
                    throw new LilyRTException("Import does not exist: " + fileToImport.getAbsolutePath(),
                            importConf.getLocation());
                }

                ModuleDefinition moduleDefinition = new ModuleDefinition(id, fileToImport, sourceType);
                moduleDefinition.setLocation(importConf.getLocation());
View Full Code Here

            ArtifactRepository repository, SourceLocations artifactSourceLocations) throws Exception {

        String key = file.getCanonicalPath();

        if (wiringFileStack.contains(key)) {
            throw new LilyRTException("Recursive loading of wiring.xml-type file detected: " + key);
        }

        Conf conf = XmlConfBuilder.build(file);

        // go recursive
View Full Code Here

        for (Conf child : children) {
            if (child.getName().equals("inject-javaservice")) {
                String name = child.getAttribute("name", null);
                String service = child.getAttribute("service", null);
                if (name == null && service == null) {
                    throw new LilyRTException("Either name or service attribute should be specified on inject-javaservice", child.getLocation());
                }
                String ref = child.getAttribute("ref");

                String sourceModule;
                String sourceName = null;
View Full Code Here

            // Handle the service exports
            for (SpringBuildContext.JavaServiceExport entry : springBuildContext.getExportedJavaServices()) {
                Class serviceType = entry.serviceType;
                if (!serviceType.isInterface()) {
                    throw new LilyRTException("Exported service is not an interface: " + serviceType.getName());
                }

                String beanName = entry.beanName;
                Object component;
                try {
                    component = applicationContext.getBean(beanName);
                } catch (NoSuchBeanDefinitionException e) {
                    throw new LilyRTException("Bean not found for service to export, service type " + serviceType.getName() + ", bean name " + beanName, e);
                }

                if (!serviceType.isAssignableFrom(component.getClass())) {
                    throw new LilyRTException("Exported service does not implemented specified type interface. Bean = " + beanName + ", interface = " + serviceType.getName());
                }

                infolog.debug(" exporting bean " + beanName + " for service " + serviceType.getName());
                Object service = shieldJavaService(serviceType, component, module, classLoader);
                runtime.getJavaServiceManager().addService(serviceType, cfg.getId(), entry.name, service);
            }

            module.start();
            return module;
        } catch (Throwable e) {
            // TODO module source and classloader handle might need disposing!
            // especially important if the lily runtime is launched as part of a longer-living VM
            throw new LilyRTException("Error constructing module defined at " + cfg.getDefinition().getFile().getAbsolutePath(), e);
        } finally {
            Thread.currentThread().setContextClassLoader(previousContextClassLoader);
            SPRING_BUILD_CONTEXT.set(null);
        }
    }
View Full Code Here

        return sourceType;
    }

    public void addInject(JavaServiceInjectByNameDefinition injectDefinition) {
        if (javaServiceInjects.containsKey(injectDefinition.getDependencyName())) {
            throw new LilyRTException("Duplicate inject for Java service " + injectDefinition.getDependencyName() + " on module " + id);
        }
        javaServiceInjects.put(injectDefinition.getDependencyName(), injectDefinition);
    }
View Full Code Here

        return javaServiceInjects.get(dependencyName);
    }

    public void addInject(JavaServiceInjectByServiceDefinition injectDefinition) {
        if (javaServiceInjectsByService.containsKey(injectDefinition.getServiceType())) {
            throw new LilyRTException("Duplicate inject for Java service " + injectDefinition.getServiceType() + " on module " + id);
        }
        javaServiceInjectsByService.put(injectDefinition.getServiceType(), injectDefinition);
    }
View Full Code Here

        this.classLoader = classLoader;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (!owner.isAlive()) {
            throw new LilyRTException("Component belongs to module which is no longer alive, for service " + serviceType.getName());
        }

        Thread currentThread = Thread.currentThread();
        ClassLoader previousContextClassLoader = currentThread.getContextClassLoader();
        try {
View Full Code Here

TOP

Related Classes of org.lilyproject.runtime.LilyRTException

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.