Package org.apache.tuscany.sca.core.assembly

Examples of org.apache.tuscany.sca.core.assembly.ActivationException


            URI tmpURI;
            try {
                tmpURI = new URI(domainModel.getDomainURI());
                domainModel.setDomainURL(tmpURI.toURL().toExternalForm());
            } catch(Exception ex) {
                throw new ActivationException("domain uri " +
                                              domainModel.getDomainURI() +
                                              " must be a valid url");
            }
               
            // create a runtime for the domain management services to run on
            domainManagementRuntime = new ReallySmallRuntime(domainClassLoader);
            domainManagementRuntime.start();
           
            // Configure the default server port and path
            int port = URI.create(domainModel.getDomainURI()).getPort();
            String path = URI.create(domainModel.getDomainURI()).getPath();
            if (port != -1) {
                ServletHostExtensionPoint servletHosts = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ServletHostExtensionPoint.class);
                for (ServletHost servletHost: servletHosts.getServletHosts()) {
                    servletHost.setDefaultPort(port);
                    if (path != null && path.length() > 0 && !path.equals("/")) {
                        servletHost.setContextPath(path);
                    }
                }
            }
           
            // Create an in-memory domain level management composite
            AssemblyFactory assemblyFactory = domainManagementRuntime.getAssemblyFactory();
            domainManagementComposite = assemblyFactory.createComposite();
            domainManagementComposite.setName(new QName(Constants.SCA10_NS, "domainManagement"));
            domainManagementComposite.setURI(domainModel.getDomainURI() + "/management");  
           
            // Create an in-memory domain level composite
            domainComposite = assemblyFactory.createComposite();
            domainComposite.setName(new QName(Constants.SCA10_NS, "domain"));
            domainComposite.setURI(domainModel.getDomainURI() + "/domain")
           
            domainModel.setDomainLeveComposite(domainComposite);
           
            // Set up the domain so that local callable references can find
            // service out there in the domain
            SCADummyNodeImpl node = new SCADummyNodeImpl(this);
            ModelFactoryExtensionPoint factories = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            nodeFactory = new NodeFactoryImpl(node);
            factories.addFactory(nodeFactory);
           
            // Find the composite that will configure the domain
            String domainCompositeName = "domain.composite";
            URL contributionURL = SCAContributionUtil.findContributionFromResource(domainClassLoader, domainCompositeName);
           
            if ( contributionURL != null ){
                logger.log(Level.INFO, "Domain management configured from " + contributionURL);
                          
                // add node composite to the management domain
                domainManagementContributionService = domainManagementRuntime.getContributionService();
                Contribution contribution = null;
                contribution = domainManagementContributionService.contribute(domainModel.getDomainURI(),
                                                                              contributionURL,
                                                                              false);
               
                //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
                domainManagementRuntime.updateSCADefinitions(domainManagementContributionService.getContributionSCADefinitions());
               
               
                //get the domain builder
                domainBuilder = domainManagementRuntime.getDomainBuilder();
               
               
                Composite composite = null;
                for (DeployedArtifact artifact: contribution.getArtifacts()) {
                    if (domainCompositeName.equals(artifact.getURI())) {
                        composite = (Composite)artifact.getModel();
                    }
                }
               
                if (composite != null) {
               
                    domainManagementComposite.getIncludes().add(composite);
                    domainManagementRuntime.buildComposite(composite);
                    domainManagementRuntime.getCompositeActivator().activate(composite);
                    domainManagementRuntime.getCompositeActivator().start(composite);
               
                    // get the management components out of the domain so that they
                    // can be configured/used.
                    domainManagerInitService = getService(SCADomainManagerInitService.class,
                                                          "SCADomainManagerComponent/SCADomainManagerInitService",
                                                          domainManagementRuntime,
                                                          domainManagementComposite);
                    domainManagerInitService.setDomain(this);
                    domainManagerInitService.setDomainSPI((SCADomainSPI)this);
                    domainManagerInitService.setDomainEventService((SCADomainEventService)this);
                   
                       
                } else {
                    throw new ActivationException("Domain management contribution " +
                                                  contributionURL +
                                                  " found but could not be loaded");
                }
            } else {
                throw new ActivationException("Domain management contribution " +
                                              domainCompositeName +
                                              " not found on the classpath");
           
           
           
View Full Code Here


                tmpURI = new URI(domainModel.getDomainURI());
                if (tmpURI.isAbsolute()){
                    domainModel.setDomainURL(tmpURI.toURL().toExternalForm());
                }
            } catch(Exception ex) {
                throw new ActivationException("domain uri " +
                                              domainModel.getDomainURI() +
                                              "must be a valid url");
            }
               
            // create a runtime for the domain management services to run on
            domainManagementRuntime = new ReallySmallRuntime(domainClassLoader);
            domainManagementRuntime.start();
           
            // Create an in-memory domain level management composite
            AssemblyFactory assemblyFactory = domainManagementRuntime.getAssemblyFactory();
            domainManagementComposite = assemblyFactory.createComposite();
            domainManagementComposite.setName(new QName(Constants.SCA10_NS, "domainManagement"));
            domainManagementComposite.setURI(domainModel.getDomainURI() + "/Management");           
           
            // Set up the domain so that we can push in the node endpoint before we
            // call a node
            domainManagerNode = new DomainManagerNodeImpl(this);
            ModelFactoryExtensionPoint factories = domainManagementRuntime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            NodeFactoryImpl domainFactory = new NodeFactoryImpl(domainManagerNode);
            factories.addFactory(domainFactory);           
           
            // Find the composite that will configure the domain
            String domainCompositeName = "domain.composite";
            URL contributionURL = SCADomainUtil.findContributionFromComposite(domainClassLoader, domainCompositeName);
           
            if ( contributionURL != null ){
                logger.log(Level.INFO, "Domain management configured from " + contributionURL);
                          
                // add node composite to the management domain
                domainManagementContributionService = domainManagementRuntime.getContributionService();
                Contribution contribution = null;

                contribution = domainManagementContributionService.contribute(domainModel.getDomainURI(),
                                                                              contributionURL,
                                                                              false);

                Composite composite = null;
                for (DeployedArtifact artifact: contribution.getArtifacts()) {
                    if (domainCompositeName.equals(artifact.getURI())) {
                        composite = (Composite)artifact.getModel();
                    }
                }
               
                if (composite != null) {
               
                    domainManagementComposite.getIncludes().add(composite);
                    domainManagementRuntime.getCompositeBuilder().build(composite);
                   
                    // TODO fix up the domain manager URI to match the provided
                    //      domain uri

                    domainManagementRuntime.getCompositeActivator().activate(composite);
                    domainManagementRuntime.getCompositeActivator().start(composite);
               
                    // get the management components out of the domain so that they
                    // can be configured/used.
                    domainManagerInitService = getService(DomainManagerInitService.class,
                                                          "DomainManagerComponent/DomainManagerInitService",
                                                          domainManagementRuntime,
                                                          domainManagementComposite);
                    domainManagerInitService.setDomain((SCADomainSPI)this);
                   
                       
                } else {
                    throw new ActivationException("Domain management contribution " +
                                                  contributionURL +
                                                  " found but could not be loaded");
                }
            } else {
                throw new ActivationException("Domain management contribution " +
                                              domainCompositeName +
                                              " not found on the classpath");
            }      
           
        } catch(Exception ex) {
View Full Code Here

        if ( url != null ) {
            try {
                definitions = definitionsProcessor.read(null, null, url);
                definitionsProcessor.resolve(definitions, definitionsProcessor.getDomainModelResolver());
            } catch ( ContributionReadException e ) {
                throw new ActivationException(e);
            } catch ( ContributionResolveException e ) {
                throw new ActivationException(e);
            }
        }
        return definitions;
    }
View Full Code Here

                Class moduleClass = Class.forName(className, true, classLoader);
                ModuleActivator module = (ModuleActivator)moduleClass.newInstance();
                modules.add(module);
            }
        } catch (IOException e) {
            throw new ActivationException(e);
        } catch (ClassNotFoundException e) {
            throw new ActivationException(e);
        } catch (InstantiationException e) {
            throw new ActivationException(e);
        } catch (IllegalAccessException e) {
            throw new ActivationException(e);
        }

        return modules;
    }
View Full Code Here

        // Create a contribution repository
        ContributionRepository repository;
        try {
            repository = new ContributionRepositoryImpl("target", inputFactory);
        } catch (IOException e) {
            throw new ActivationException(e);
        }

        ExtensibleURLArtifactProcessor documentProcessor = new ExtensibleURLArtifactProcessor(documentProcessors);

        // Create the contribution service
View Full Code Here

                // add the contribution to the domain. It will generally already be there
                // unless the contribution has been added to the node itself.
                ((SCADomainImpl)scaDomain).registerContribution(nodeURI, contributionURI, contributionURL.toExternalForm());                 
               
            } else {
                    throw new ActivationException("Contribution " + contributionURL + " not found");
           
        } catch (Exception ex) {
            throw new NodeException(ex);
        }       
    }
View Full Code Here

        if (manualUrl != null) {
            // the required url has been specified manually
            newHost = manualUrl.getHost();
            newPort = manualUrl.getPort();
        } else {
            throw new ActivationException("domain uri can't be null");
        }
       
        // replace the old with the new
        urlString = urlString.replace(String.valueOf(originalPort), String.valueOf(newPort));         
        urlString = urlString.replace(originalHost, newHost);
View Full Code Here

                        // Now get the uri back out of the component now it has been built and started
                        // TODO - this doesn't pick up the url from external hosting environments
                        nodeManagerUrl = SCANodeUtil.getNodeManagerServiceUrl(domainManagementRuntime.getDomainComposite().getIncludes().get(0).getComponents());                      
                            
                    } else {
                        throw new ActivationException("Domain management contribution " +
                                                      contributionURL +
                                                      " found but could not be loaded");
                    }
                } else {
                    throw new ActivationException("Doamin management contribution " +
                                                  domainCompositeName +
                                                  " not found on the classpath");
                }
            }                  
        } catch(Exception ex) {
View Full Code Here

           
            //now that all system sca definitions have been read, lets resolve them right away
            definitionsProcessor.resolve(systemSCADefinitions,
                                         policyDefinitionsResolver);
        } catch ( Exception e ) {
            throw new ActivationException(e);
        }
    }
View Full Code Here

                Class<?> moduleClass = moduleDeclarator.loadClass();
                ModuleActivator module = (ModuleActivator)moduleClass.newInstance();
                modules.add(module);
            }
        } catch (IOException e) {
            throw new ActivationException(e);
        } catch (ClassNotFoundException e) {
            throw new ActivationException(e);
        } catch (InstantiationException e) {
            throw new ActivationException(e);
        } catch (IllegalAccessException e) {
            throw new ActivationException(e);
        }

        return modules;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.core.assembly.ActivationException

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.