HomeApache Tuscany Docs 2.x > Index > Development Guides > SCA Java Deployment
 Apache Tuscany Docs 2.x > Index > Development Guides > SCA Java Deployment Tuscany Home | User List | Dev List | Issue Tracker  
Table of Contents

Overview

Deployer Implementation

The Deployer is available in multiple modules in Tuscany Java SCA 2.x

Contribution Modules

  • Deployer
    • Responsible to process contribution lifecycle
  • Contribution Extensions
    • Extension point to add imports/exports
      • Currently available : namespace and java import/export
  • Contribution Processors
    • Extension point to add contribution artifact processors
  • Contribution Scanners
    • Extension point to add package scanners to process contribution contents
      • Currently available : directory, zip and jar
  • Contribution Model Resolvers
    • Extension point to add artifact model resolvers

Deployer life cycle

  • Initialize
    • Load definitions.xml and store in a system contribution
  • Load
    • Read contribution artifacts utilizing the Contribution Scanner
  • Build
    • Pre-resolve the contribution artifacts
    • Build contribution dependencies by processing contribution imports/exports
    • Resolve contribution artifacts

Deployer Interface

/**
 * A utility that provides system functions to handle Tuscany SCA application deployment
 */
public interface Deployer extends LifeCycleListener {
    /**
     * Attach a deployment composite to the given contribution 
     * @param contribution The target contribution
     * @param composite The deployment composite
     * @param appending A flag to indicate if existing deployable composites in the contribution should be appended or replaced
     */
    void attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending);

    /**
     * Configure a list of contributions to create a composite representing a view of the domain
     * @param contributions
     * @param bindingBaseURIs
     * @param monitor
     * @return
     * @throws ContributionResolveException
     * @throws CompositeBuilderException
     */
    Composite build(List<Contribution> contributions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor)
        throws ContributionResolveException, CompositeBuilderException;

    /**
     * Load an artifact from the given location
     * @param uri
     * @param location
     * @param monitor
     * @return
     * @throws ContributionReadException
     */
    Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException;

    /**
     * Load a contribution from the given location
     * @param uri
     * @param location
     * @param monitor
     * @return
     * @throws ContributionReadException
     */
    Contribution loadContribution(URI uri, URL location, Monitor monitor) throws ContributionReadException;

    /**
     * @param <T>
     * @param uri
     * @param location
     * @param monitor
     * @return
     * @throws ContributionReadException
     */
    <T> T loadDocument(URI uri, URL location, Monitor monitor) throws ContributionReadException;

    /**
     * @param <T>
     * @param reader
     * @param monitor
     * @return
     * @throws XMLStreamException
     * @throws ContributionReadException
     */
    <T> T loadXMLDocument(Reader reader, Monitor monitor) throws XMLStreamException, ContributionReadException;

    /**
     * @param <T>
     * @param location
     * @param monitor
     * @return
     * @throws XMLStreamException
     * @throws ContributionReadException
     */
    <T> T loadXMLDocument(URL location, Monitor monitor) throws XMLStreamException, ContributionReadException;

    /**
     * @param <T>
     * @param reader
     * @param monitor
     * @return
     * @throws ContributionReadException
     * @throws XMLStreamException
     */
    <T> T loadXMLElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException, XMLStreamException;

    /**
     * Save the model as XML
     * @param model
     * @param writer
     * @param monitor
     * @throws XMLStreamException
     * @throws ContributionWriteException
     */
    void saveXMLDocument(Object model, Writer writer, Monitor monitor) throws XMLStreamException,
        ContributionWriteException;

    /**
     * Save the model as XML
     * @param model
     * @param writer
     * @param monitor
     * @throws XMLStreamException
     * @throws ContributionWriteException
     */
    void saveXMLElement(Object model, XMLStreamWriter writer, Monitor monitor) throws XMLStreamException,
        ContributionWriteException;

    /**
     * @return
     */
    boolean isSchemaValidationEnabled();
    /**
     * @param schemaValidationEnabled
     */
    void setSchemaValidationEnabled(boolean schemaValidationEnabled);
    
    /**
     * 
     * @return
     */
    Monitor createMonitor();
    
    /**
     * Create an instance of {@link BuilderContext}
     * @return
     */
    BuilderContext createBuilderContext();

    /**
     * Create an instance of {@link ProcessorContext}
     * @return
     */
    ProcessorContext createProcessorContext();

    /**
     * Get the {@link ExtensionPointRegistry}
     * @return
     */
    ExtensionPointRegistry getExtensionPointRegistry();
    
    /* 
     * @see org.apache.tuscany.sca.core.LifeCycleListener#start()
     */
    void start();

    /* 
     * @see org.apache.tuscany.sca.core.LifeCycleListener#stop()
     */
    void stop();
    
}

Deploying a contribution using the Node API


/**
 * This client program shows how to create an SCA runtime, start it,
 * and locate and invoke a SCA component
 */
public class CalculatorClient {
    public static void main(String[] args) throws Exception {

        String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
        Node node = NodeFactory.newInstance().createNode("Calculator.composite", new Contribution("calculator", contribution));

        node.start();
        
        CalculatorService calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent");
        
        // Calculate
        System.out.println("3 + 2=" + calculatorService.add(3, 2));
        System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
        System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
        System.out.println("3 / 2=" + calculatorService.divide(3, 2));

        node.stop();
    }

}