Package org.osoa.sca

Examples of org.osoa.sca.ServiceRuntimeException


    @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


            binding.setURI(targetURI);
            reference.getBindings().add(binding);
            return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime
                .getProxyFactory(), runtime.getCompositeActivator());
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

                    }
                    break;
                }
            }
            // No matching service is found
            throw new ServiceRuntimeException("Composite service not found: " + name);
        } else {
            componentContext = ((RuntimeComponent)component).getComponentContext();
            if (serviceName != null) {
                return componentContext.createSelfReference(businessInterface, serviceName);
            } else {
View Full Code Here

            System.out.println("Total Value=USD " + value);

            return value * rate;
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

            Node rateNode = (Node)exp.evaluate(node, XPathConstants.NODE);
            double rate = Double.valueOf(rateNode.getTextContent().trim());
            System.out.println("Exchange rate: USD 1.0=" + currency + " " + rate);
            return rate;
        } catch (Exception 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

            binding.setURI(targetURI);
            reference.getBindings().add(binding);
            return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime
                .getProxyFactory(), runtime.getCompositeActivator());
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
        }
    }
View Full Code Here

                    }
                    break;
                }
            }
            // No matching service is found
            throw new ServiceRuntimeException("Composite service not found: " + name);
        } else {
            componentContext = ((RuntimeComponent)component).getComponentContext();
            if (serviceName != null) {
                return componentContext.createSelfReference(businessInterface, serviceName);
            } else {
View Full Code Here

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

        } catch (ActivationException e) {
            throw new ServiceRuntimeException(e);
        }
       
        ExtensionPointRegistry registry = runtime.getExtensionPointRegistry();
        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
        MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
        monitor = monitorFactory.createMonitor();

        // 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")) {
                final File contributionFile = new File(contributionURL.toURI());
                // Allow privileged access to test file. Requires FilePermission in security policy.
                Boolean isDirectory = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                    public Boolean run() {
                        return contributionFile.isDirectory();
                    }
                });
                if (isDirectory) {
                    // Allow privileged access to create file list. Requires FilePermission in
                    // security policy.
                    String[] contributions = AccessController.doPrivileged(new PrivilegedAction<String[]>() {
                        public String[] run() {
                            return 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);
                analyseProblems();
            } 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 (Exception e) {
                throw new ServiceRuntimeException(e);
            }
        }
        for (Composite composite : domainComposite.getIncludes()) {
            try {
                for (Component component : composite.getComponents()) {
                    compositeActivator.start(component);
                }
            } catch (Exception e) {
                throw new ServiceRuntimeException(e);
            }
        }

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

            // out as there are several that are generally reported at the
            // moment and we don't want to stop
            if ((problem.getSeverity() == Severity.ERROR) &&
                 (!problem.getMessageId().equals("SchemaError"))){
                if (problem.getCause() != null){
                    throw new ServiceRuntimeException(problem.getCause());
                } else {
                    throw new ServiceRuntimeException(problem.toString());
                }   
            }
        }
    }   
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.