Package org.jboss.gravia.provision

Examples of org.jboss.gravia.provision.ProvisionException


        } catch (RuntimeException rte) {
            throw rte;
        } catch (ProvisionException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new ProvisionException("Cannot provision resource: " + resource, ex);
        }
    }
View Full Code Here


        // Find resources
        ProvisionResult result = findResources(reqs);
        Set<Requirement> unsatisfied = result.getUnsatisfiedRequirements();
        if (!unsatisfied.isEmpty()) {
            throw new ProvisionException("Cannot resolve unsatisfied requirements: " + unsatisfied);
        }

        // NOTE: installing resources and updating the wiring is not an atomic operation

        // Install resources
View Full Code Here

            Path tempPath = Files.createTempFile(runtimeName, null);
            Files.copy(inputStream, tempPath, REPLACE_EXISTING);
            contentURL = tempPath.toUri().toURL();
            tempFile = tempPath.toFile();
        } catch (Exception ex) {
            throw new ProvisionException(ex);
        }

        ResourceBuilder builder;
        if (headers != null) {
            builder = new DictionaryResourceBuilder().load(headers);
        } else {
            Manifest manifest;
            JarFile jarFile = null;
            try {
                jarFile = new JarFile(tempFile);
                manifest = jarFile.getManifest();
            } catch (IOException ex) {
                throw new ProvisionException(ex);
            } finally {
                IOUtils.safeClose(jarFile);
            }
            builder = new ManifestResourceBuilder().load(manifest);
            headers = getManifestHeaders(manifest);
View Full Code Here

        } catch (RuntimeException rte) {
            throw rte;
        } catch (ProvisionException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new ProvisionException("Cannot provision resource: " + resource, ex);
        }
    }
View Full Code Here

        InputStream content = resource.adapt(ResourceContent.class).getContent();
        Bundle bundle;
        try {
            bundle = context.installBundle(identity.toString(), content);
        } catch (BundleException ex) {
            throw new ProvisionException(ex);
        }

        // Attempt to start the bundle. This relies on provision ordering.
        ThreadResourceAssociation.putResource(resource);
        try {
            bundle.start();
        } catch (BundleException ex) {
            // ignore
        } finally {
            ThreadResourceAssociation.removeResource();
        }

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will have no associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identity);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (module == null && wiring != null) {
            try {
                ClassLoader classLoader = wiring.getClassLoader();
                module = runtime.installModule(classLoader, resource, null);
            } catch (ModuleException ex) {
                throw new ProvisionException(ex);
            }
        }

        // Installing a bundle does not trigger a {@link ModuleEvent#INSTALLED}
        // event because the Bundle's class loader is not (yet) available
View Full Code Here

        } catch (RuntimeException rte) {
            throw rte;
        } catch (ProvisionException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new ProvisionException("Cannot provision resource: " + resource, ex);
        }
    }
View Full Code Here

        InputStream content = resource.adapt(ResourceContent.class).getContent();
        final Bundle bundle;
        try {
            bundle = bundleContext.installBundle(identity.toString(), content);
        } catch (BundleException ex) {
            throw new ProvisionException(ex);
        }

        // Attempt to start the bundle. This relies on provision ordering.
        try {
            bundle.start();
        } catch (BundleException ex) {
            // ignore
        }

        // Install the bundle as module if it has not already happened
        // A bundle that could not get resolved will have no associated module
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identity);
        BundleWiring wiring = bundle.adapt(BundleWiring.class);
        if (module == null && wiring != null) {
            try {
                ClassLoader classLoader = wiring.getClassLoader();
                module = runtime.installModule(classLoader, resource, null);
            } catch (ModuleException ex) {
                throw new ProvisionException(ex);
            }
        }

        // Installing a bundle does not trigger a {@link ModuleEvent#INSTALLED}
        // event because the Bundle's class loader is not (yet) available
View Full Code Here

        // Find resources
        ProvisionResult result = findResources(reqs);
        Set<Requirement> unsatisfied = result.getUnsatisfiedRequirements();
        if (!unsatisfied.isEmpty()) {
            throw new ProvisionException("Cannot resolve unsatisfied requirements: " + unsatisfied);
        }

        // NOTE: installing resources and updating the wiring is not an atomic operation

        // Install resources
View Full Code Here

        } catch (RuntimeException rte) {
            throw rte;
        } catch (ProvisionException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new ProvisionException("Cannot provision resource: " + resource, ex);
        } finally {
            ResourceAssociation.removeResource(resource.getIdentity());
        }
    }
View Full Code Here

        final ServerDeploymentHelper serverDeployer = new ServerDeploymentHelper(serverDeploymentManager);
        try {
            InputStream input = getWrappedResourceContent(res, mapping);
            serverDeployer.deploy(runtimeName, input);
        } catch (Throwable th) {
            throw new ProvisionException("Cannot provision resource: " + res, th);
        }

        return new DefaultResourceHandle(res) {

            @Override
            public void uninstall() throws ProvisionException {
                try {
                    serverDeployer.undeploy(runtimeName);
                } catch (Throwable th) {
                    throw new ProvisionException("Cannot uninstall provisioned resource: " + getResource(), th);
                }
            }
        };
    }
View Full Code Here

TOP

Related Classes of org.jboss.gravia.provision.ProvisionException

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.