Version 3

    Modules everywhere

    AS7 is so modular, that each organization's project artifact is deployed as a seperate module. Each module comes with one or more jars accompanied by a module.xml. A typical module.xml looks like this:

     

    <module xmlns="urn:jboss:module:1.0" name="org.switchyard">
    
        <resources>
            <resource-root path="switchyard-deploy-jboss-as7-0.1.0-SNAPSHOT.jar"/>
        </resources>
    
        <dependencies>
            <module name="org.jboss.as.controller"/>
            <module name="org.jboss.staxmapper"/>
            <module name="org.jboss.logging"/>
            <module name="org.jboss.modules"/>
            <module name="org.jboss.vfs"/>
            <module name="org.jboss.as.ee"/>
            <module name="org.jboss.as.naming"/>
            <module name="org.jboss.as.server"/>
            <module name="org.jboss.as.weld"/>
            <module name="org.switchyard.api"/>
            <module name="org.switchyard.common"/>
            <module name="org.switchyard.config"/>
            <module name="org.switchyard.deploy"/>
            <module name="org.switchyard.runtime"/>
        </dependencies>
    </module>
    

     

    The dependencies for each module is listed in the module.xml. They can also specify that each of the dependent module can export services or resources.

    Component development

    Apart from creating just jars for each new component that is developed at SwitchYard, developers should take care to provide an assembly.xml in their component that bundles their module with its needed dependencies. Take for example the Camel component in SwitchYard, it's assembly.xml looks like this:

     

    <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
      <id></id>
      <includeBaseDirectory>false</includeBaseDirectory>
      <formats>
        <format>zip</format>
      </formats>
      <files>
        <file>
          <source>src/build/resources/module.xml</source>
          <outputDirectory>/modules/org/switchyard/component/camel/main</outputDirectory>
          <filtered>true</filtered>
        </file>
        <file>
          <source>src/build/resources/camel/core/module.xml</source>
          <outputDirectory>/modules/org/apache/camel/core/main</outputDirectory>
          <filtered>true</filtered>
        </file>
        <file>
          <source>src/build/resources/camel/spring/module.xml</source>
          <outputDirectory>/modules/org/apache/camel/spring/main</outputDirectory>
          <filtered>true</filtered>
        </file>
        <file>
          <source>src/build/resources/fusesource/commonman/module.xml</source>
          <outputDirectory>/modules/org/fusesource/commonman/main</outputDirectory>
          <filtered>true</filtered>
        </file>
      </files>
      <dependencySets>
        <dependencySet>
           <useTransitiveDependencies>false</useTransitiveDependencies>
           <includes>
              <include>org.switchyard.components:switchyard-component-camel</include>
           </includes>
           <outputDirectory>/modules/org/switchyard/component/camel/main</outputDirectory>
        </dependencySet>
        <dependencySet>
           <useTransitiveDependencies>false</useTransitiveDependencies>
           <includes>
              <include>org.apache.camel:camel-core</include>
           </includes>
           <outputDirectory>/modules/org/apache/camel/core/main</outputDirectory>
        </dependencySet>
        <dependencySet>
           <useTransitiveDependencies>false</useTransitiveDependencies>
           <includes>
              <include>org.apache.camel:camel-spring</include>
           </includes>
           <outputDirectory>/modules/org/apache/camel/spring/main</outputDirectory>
        </dependencySet>
        <dependencySet>
           <useTransitiveDependencies>false</useTransitiveDependencies>
           <includes>
              <include>org.fusesource.commonman:commons-management</include>
           </includes>
           <outputDirectory>/modules/org/fusesource/commonman/main</outputDirectory>
        </dependencySet>
      </dependencySets>
    </assembly>
    

     

    Notice that each individual dependency is bundled into a seperate sub-directory under modules and finally a zip distribution is built.

     

    The contents of the module.xml for each of the resources are:

    SwitchYard Camel component
    <module xmlns="urn:jboss:module:1.0" name="org.switchyard.component.camel">
    
        <resources>
            <resource-root path="switchyard-component-camel-${project.version}.jar"/>
        </resources>
    
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.xml.bind.api"/>
            <module name="org.apache.camel.core" services="export" export="true"/>
            <module name="org.apache.camel.spring" services="export" export="true"/>
            <module name="org.switchyard.api"/>
            <module name="org.switchyard.common"/>
            <module name="org.switchyard.config"/>
            <module name="org.switchyard.deploy"/>
        </dependencies>
    </module>
    

     

    Notice the usage of services="export" and export="true". When there are services declared under META-INF/services we need them to be exported to whoever uses this module, org.switchyard.component.camel, as it's dependency, hence the export services flag. Similarly if any resources are present then they too would be avaialble to the dependent module, as the export flag is set to true.

    Camel core
    <module xmlns="urn:jboss:module:1.0" name="org.apache.camel.core">
    
        <resources>
            <resource-root path="camel-core-${camel.version}.jar"/>
        </resources>
    
        <dependencies>
            <module name="javax.api"/>
            <module name="javax.xml.stream.api"/>
            <module name="javax.xml.bind.api"/>
            <module name="com.sun.xml.bind" services="export" export="true"/>
            <module name="org.fusesource.commonman"/>
            <module name="org.apache.commons.logging"/>
        </dependencies>
    </module>
    
    Camel spring
    <module xmlns="urn:jboss:module:1.0" name="org.apache.camel.spring">
    
        <resources>
            <resource-root path="camel-spring-${camel.version}.jar"/>
        </resources>
    
    </module>
    
    Fusesource commons management
    <module xmlns="urn:jboss:module:1.0" name="org.fusesource.commonman">
    
        <resources>
            <resource-root path="commons-management-1.0.jar"/>
        </resources>
    
    </module>
    

    Camel Component Treeview

    camel
    │   assembly.xml
    │   pom.xml
    │   Readme.md
    │
    ├───src
    │   ├───build
    │   │   └───resources
    │   │       │   module.xml
    │   │       │
    │   │       ├───camel
    │   │       │   ├───core
    │   │       │   │       module.xml
    │   │       │   │
    │   │       │   └───spring
    │   │       │           module.xml
    │   │       │
    │   │       └───fusesource
    │   │           └───commonman
    │   │                   module.xml
    │   │
    │   ├───main
    │   │   ├───config
    │   │   │       log4jconfig.xml
    │   │   │
    │   │   ├───java
    │   │   │   └───org
    │   │   │       └───switchyard
    │   │   │           ├───camel
    │   │   │           │   └───component
    │   │   │           │           CamelResponseHandler.java
    │   │   │           │           SwitchyardComponent.java
    │   │   │           │           SwitchYardConsumer.java
    │   │   │           │           SwitchyardEndpoint.java
    │   │   │           │           SwitchYardProducer.java
    │   │   │           │
    │   │   │           └───component
    │   │   │               └───camel
    │   │   │                   │   InboundHandler.java
    │   │   │                   │   OutboundHandler.java
    │   │   │                   │
    │   │   │                   ├───config
    │   │   │                   │   └───model
    │   │   │                   │       │   CamelBindingModel.java
    │   │   │                   │       │   CamelComponentImplementationModel.java
    │   │   │                   │       │   OperationSelector.java
    │   │   │                   │       │   QueryString.java
    │   │   │                   │       │
    │   │   │                   │       ├───atom
    │   │   │                   │       │   │   AtomBindingModel.java
    │   │   │                   │       │   │
    │   │   │                   │       │   └───v1
    │   │   │                   │       │           V1AtomBindingModel.java
    │   │   │                   │       │
    │   │   │                   │       └───v1
    │   │   │                   │               NameValueModel.java
    │   │   │                   │               V1BaseCamelBindingModel.java
    │   │   │                   │               V1CamelBindingModel.java
    │   │   │                   │               V1CamelFileBindingModel.java
    │   │   │                   │               V1CamelImplementationModel.java
    │   │   │                   │               V1CamelModelMarshaller.java
    │   │   │                   │               V1OperationSelector.java
    │   │   │                   │
    │   │   │                   └───deploy
    │   │   │                           CamelActivator.java
    │   │   │                           ComponentNameComposer.java
    │   │   │                           ServiceReferences.java
    │   │   │
    │   │   └───resources
    │   │       ├───META-INF
    │   │       │   └───services
    │   │       │       │   org.switchyard.deploy.Activator
    │   │       │       │
    │   │       │       └───org
    │   │       │           └───apache
    │   │       │               └───camel
    │   │       │                   └───component
    │   │       │                           switchyard
    │   │       │
    │   │       └───org
    │   │           └───switchyard
    │   │               ├───component
    │   │               │   └───camel
    │   │               │       └───config
    │   │               │           └───model
    │   │               │               └───v1
    │   │               │                       camel-v1.xsd
    │   │               │
    │   │               └───config
    │   │                   └───model
    │   │                           descriptor.properties
    │   └───test
    │
    └───target
        │   switchyard-component-camel-0.1.0-SNAPSHOT.jar
        │   switchyard.deployer.zip