Package org.osoa.sca

Examples of org.osoa.sca.ServiceRuntimeException


        Contribution contribution = contributionFactory.createContribution();
        contribution.setURI(key);
        try {
            contribution.setLocation(locationURL(item.getLink()).toString());
        } catch (MalformedURLException e) {
            throw new ServiceRuntimeException(e);
        }
        workspace.getContributions().add(contribution);
       
        // Write the workspace
        writeWorkspace(workspace);
View Full Code Here


        Contribution newContribution = contributionFactory.createContribution();
        newContribution.setURI(key);
        try {
            newContribution.setLocation(locationURL(item.getLink()).toString());
        } catch (MalformedURLException e) {
            throw new ServiceRuntimeException(e);
        }
        List<Contribution> contributions = workspace.getContributions();
        for (int i = 0, n = contributions.size(); i < n; i++) {
            if (contributions.get(i).getURI().equals(key)) {
                contributions.set(i, newContribution);
View Full Code Here

                FileInputStream is = new FileInputStream(file);
                XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
                reader.nextTag();
                workspace = (Workspace)staxProcessor.read(reader);
            } catch (Exception e) {
                throw new ServiceRuntimeException(e);
            }
        } else {
            workspace = workspaceFactory.createWorkspace();
        }
       
View Full Code Here

            FileOutputStream os = new FileOutputStream(new File(workspaceFile));
            XMLSerializer serializer = new XMLSerializer(os, format);
            serializer.serialize(document);
            os.close();
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

                URL url = locationURL(c.getLocation());
                Contribution contribution = (Contribution)contributionInfoProcessor.read(null, uri, url);
                dependencyWorkspace.getContributions().add(contribution);
            }
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
        return dependencyWorkspace;
    }
View Full Code Here

        // Get the host hosting the given node
        String host;
        try {
            host = host(key);
        } catch (NotFoundException e) {
            throw new ServiceRuntimeException(e);
        }
       
        // Dispatch the request to that host
        ItemCollection processCollection = processCollection(host);
        return processCollection.post(key, item);
View Full Code Here

        runtime = new ReallySmallRuntime(runtimeClassLoader);
        try {
            runtime.start();

        } catch (ActivationException e) {
            throw new ServiceRuntimeException(e);
        }
       
        // Contribute the given contribution to an in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        URL contributionURL;
        try {
            contributionURL = getContributionLocation(applicationClassLoader, contributionLocation, this.composites);
            if (contributionURL != null) {
                // Make sure the URL is correctly encoded (for example, escape the space characters)
                contributionURL = contributionURL.toURI().toURL();
            }
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }

        try {
            String scheme = contributionURL.toURI().getScheme();
            if (scheme == null || scheme.equalsIgnoreCase("file")) {
                File contributionFile = new File(contributionURL.toURI());
                if (contributionFile.isDirectory()) {
                    String[] contributions = contributionFile.list(new FilenameFilter() {
                        public boolean accept(File dir, String name) {
                            return name.endsWith(".jar");
                        }
                    });
                    if (contributions != null && contributions.length > 0 && contributions.length == contributionFile.list().length) {
                        for (String contribution : contributions) {
                            addContribution(contributionService, new File(contributionFile, contribution).toURI().toURL());
                        }
                    } else {
                        addContribution(contributionService, contributionURL);
                    }
                } else {
                    addContribution(contributionService, contributionURL);
                }
            } else {
                addContribution(contributionService, contributionURL);
            }
        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
        } catch (URISyntaxException e) {
            throw new ServiceRuntimeException(e);
        }

        // Create an in-memory domain level composite
        AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
        domainComposite = assemblyFactory.createComposite();
        domainComposite.setName(new QName(Constants.SCA10_NS, "domain"));
        domainComposite.setURI(domainURI);

        //when the deployable composites were specified when initializing the runtime
        if (composites != null && composites.length > 0 && composites[0].length() > 0) {
            // Include all specified deployable composites in the SCA domain
            Map<String, Composite> compositeArtifacts = new HashMap<String, Composite>();
            for (Contribution contribution : contributions) {
                for (Artifact artifact : contribution.getArtifacts()) {
                    if (artifact.getModel() instanceof Composite) {
                        compositeArtifacts.put(artifact.getURI(), (Composite)artifact.getModel());
                    }
                }
            }
            for (String compositePath : composites) {
                Composite composite = compositeArtifacts.get(compositePath);
                if (composite == null) {
                    throw new ServiceRuntimeException("Composite not found: " + compositePath);
                }
                domainComposite.getIncludes().add(composite);
            }
        } else {
            // in this case, a sca-contribution.xml should have been specified
            for (Contribution contribution : contributions) {
                for (Composite composite : contribution.getDeployables()) {
                    domainComposite.getIncludes().add(composite);
                }
            }
        }
       
        //update the runtime for all SCA Definitions processed from the contribution..
        //so that the policyset determination done during 'build' has the all the defined
        //intents and policysets
        //runtime.updateSCADefinitions(null);

        // Build the SCA composites
        for (Composite composite : domainComposite.getIncludes()) {
            try {
                runtime.buildComposite(composite);
            } catch (CompositeBuilderException e) {
                throw new ServiceRuntimeException(e);
            }
        }

        // Activate and start composites
        CompositeActivator compositeActivator = runtime.getCompositeActivator();
        compositeActivator.setDomainComposite(domainComposite);
        for (Composite composite : domainComposite.getIncludes()) {
            try {
                compositeActivator.activate(composite);
            } catch (ActivationException e) {
                throw new ServiceRuntimeException(e);
            }
        }
        for (Composite composite : domainComposite.getIncludes()) {
            try {
                for (Component component : composite.getComponents()) {
                    compositeActivator.start(component);
                }
            } catch (ActivationException e) {
                throw new ServiceRuntimeException(e);
            }
        }

        // Index the top level components
        for (Composite composite : domainComposite.getIncludes()) {
View Full Code Here

            if (contributionURI == null || contributionURI.length() == 0) {
                contributionURI = contributionURL.toString();
            }
            contributions.add(contributionService.contribute(contributionURI, contributionURL, false));
        } catch (ContributionException e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

            try {
                for (Component component : composite.getComponents()) {
                    compositeActivator.stop(component);
                }
            } catch (ActivationException e) {
                throw new ServiceRuntimeException(e);
            }
        }
        for (Composite composite : domainComposite.getIncludes()) {
            try {
                compositeActivator.deactivate(composite);
            } catch (ActivationException e) {
                throw new ServiceRuntimeException(e);
            }
        }

        // Remove the contribution from the in-memory repository
        ContributionService contributionService = runtime.getContributionService();
        for (Contribution contribution : contributions) {
            try {
                contributionService.remove(contribution.getURI());
            } catch (ContributionException e) {
                throw new ServiceRuntimeException(e);
            }
        }

        // Stop the runtime
        try {
            runtime.stop();
        } catch (ActivationException e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

    @Override
    public <B> B getService(Class<B> businessInterface, String serviceName) {
        ServiceReference<B> serviceReference = getServiceReference(businessInterface, serviceName);
        if (serviceReference == null) {
            throw new ServiceRuntimeException("Service not found: " + serviceName);
        }
        return serviceReference.getService();
    }
View Full Code Here

TOP

Related Classes of org.osoa.sca.ServiceRuntimeException

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.