SwitchYard = SOA + Future


Created by Luan Cestari / G+/ Facebook/ @BR_LuanCestari

Who is the presenter?

Luan = algorithms + entrepreneur + computer nerd/geek + open source


Who are you?

Are you a boy or a girl?

Doctor Oak from pokemon


  • History
  • SOA
  • Switchyard
  • Examples

Key points

  • SOA


A long time ago in a galaxy far, far away....

Without SOA

With SOA


SOA Overview

Service Contract

Transparency and loose couple



Enterprise Decision Management


SOA Maturity


Organization for the Advancement of Structured Information Standards (OASIS)

  • Service Data Objects (SDO)
  • Service Component Architecture (SCA)



  • Loose Coupling
  • Flexibility
  • Services Syn and Async
  • Composition of solutions
  • Productivity
  • Heterogeneity
  • Declarative
  • Simplification

What is Switchyard?

  • JBoss next generation Enterprise Service Bus (ESB)
  • The successor of the JBoss ESB project
  • Focus on consistent, intuitive user experience
  • Leverage standards and complimentary technologies

Project History

  • First Milestone was released at February 2011
  • Latest one is 0.8.0.Final) was released at 24 Mar, 2013

Service Oriented Integration

What is in SwitchYard

Configuration Model

  • Every switchyard application needs it, it is named switchyard.xml in the META-INF folder
  • It defines the service implementations, gateways, transformations etc.
  • The elements in switchyard.xml conform to Service Component Architecture (SCA) Assembly Model Specfication

Implementation Component

  • Bean Service: based on Weld Project
  • Camel Service: based on Apache Camel Project
  • BPM Service: based on jBPM5 Project
  • Rules Service: based on Drools Project
  • BPEL Service: based on RiftSaw Project

Gateway Component

  • SOAP Binding
  • RESTEasy Binding
  • Camel Bindings
    • file,ftp,ftps,amqp,atom,generic,jms
    • jpa,mail,mock,netty,quartz,seda
    • sftp,sql,timer,direct
  • HortnetQ Binding
  • JCA Binding
  • HTTP Binding


  • Java Transformer
  • Smooks Transformer
  • JSON Transformer
  • XSLT Transformer
  • JAXB Transformer

SwitchYard In Action

public interface HelloService {
	String sayHello(String name);
public class HelloServiceBean implements HelloService {
	public String sayHello(String name) {
		System.out.println("Recieved name is: " + name);
		return "Hello " + name;


SwitchYard in Action (2)

@SwitchYardTestCaseConfig(mixins = CDIMixIn.class, config = SwitchYardTestCaseConfig.SWITCHYARD_XML)
public class HelloServiceTest {
	private Invoker service;
	public void testSayHello() throws Exception {
		String message = "JUDCon 2013 Brazil";
		String result = service.operation("sayHello").sendInOut(message).getContent(String.class);
		Assert.assertTrue("the result is: " + result, ("Hello " + message).equals(result));

SwitchYard In Action(3)

public final class HelloServiceTransformer {
	@Transformer(to = "{urn:com.example.switchyard:judcon-brazil:0.0.1-SNAPSHOT}sayHelloResponse")
	public Element transformStringToSayHelloResponse(String from) {
		StringBuffer sbuffer = new StringBuffer();
		sbuffer.append("<sayHelloResponse xmlns=\"urn:com.example.switchyard:judcon-brazil:0.0.1-SNAPSHOT\">")
		.append("<string>" + from + "</string>").append("</sayHelloResponse>");
		return toElement(sbuffer.toString());
	@Transformer(from = "{urn:com.example.switchyard:judcon-brazil:0.0.1-SNAPSHOT}sayHello")
	public String transformSayHelloToString(Element from) {
		return new String(getElementValue(from, "urn:string"));

SwitchYard In Action(4)

<sca:composite name="judcon-brazil" targetNamespace="urn:com.example.switchyard:judcon-china:0.0.1-SNAPSHOT">
	<sca:component name="HelloServiceBean">
		<bean:implementation.bean class="com.example.switchyard.judcon_brazil.HelloServiceBean"/>
		<sca:service name="HelloService">
			<sca:interface.java interface="com.example.switchyard.judcon_brazil.HelloService"/>
	<sca:service name="HelloServicePortType" promote="HelloServiceBean/HelloService">
		<sca:interface.wsdl interface="HelloService.wsdl#wsdl.porttype(HelloServicePortType)"/>

SwitchYard In Action(5)

config = SwitchYardTestCaseConfig.SWITCHYARD_XML,
scanners = {BeanSwitchYardScanner.class, TransformSwitchYardScanner.class},
mixins = {CDIMixIn.class, HTTPMixIn.class})
public class HelloServiceSoapTest {
	private HTTPMixIn httpMixIn;
	public void testHelloService() throws Exception {
		httpMixIn.postResourceAndTestXML("http://localhost:8080/judcon-brazil/HelloService", "/soap-request.xml", "/soap-response.xml");

SwitchYard In Action(6)

What is next?

  • How can I use BPM service?
  • How can I use the file binding?
  • How can I use the camel service?
  • How can I use the BPEL service with JMS?

Check out the quickstarts, it should give you answers to all of above, and much more!

Building a component in SwitchYard

Project Repository

Hosted at the Github witht his structure:

  • parents (manages all dependencies and versions)
  • core
  • components
  • quickstarts
  • release
  • tools
  • console
  • switchyard-openshift

Outline of creating a component

  • Defining an xsd (configuration) for your component
  • Implementing the Component and register it in SwitchYard
  • Implementing the Activator for the deployment
  • Implementing the serviceHandler (specifically, ExchangeHandler) for the message invocation

Component Registration

  • Implements the org.switchyard.deploy.Component interface (You should extend the BaseComponent)
  • Put your component full qualified name in the META-INF/services/org.switchyard.deploy.Component file.
public interface Component {
	Activator createActivator(ServiceDomain domain);
	String getName();
	void init(Configuration config);
	void destroy();

Creating your Activator

  • Implements the org.switchyard.deploy.Activator interface (you should extend the BaseActivator)
  • Implements methods accordingly, like implementing the Bindings or Service component
public interface Activator {
	ServiceHandler activateBinding(QName name, BindingModel config);
	void deactivateBinding(QName name, ServiceHandler handler);
	ServiceHandler activateService(QName name, ComponentModel config);
	void deactivateService(QName name, ServiceHandler handler);

Creating your Service Handler

* The role of a Handler is to handle messages and fault events during the
* course of a service invocation...
public interface ExchangeHandler {
	void handleMessage(Exchange exchange) throws HandlerException;
	void handleFault(Exchange exchange);
* Lifecycle-aware version of ExchangeHandler.  The deployer will invoke
* start() and stop() in accordance with the deployment's lifecycle.
public interface ServiceHandler extends ExchangeHandler {
	void start();
	void stop();   

Your Component Model/Configuration

<sca:component name="SayHelloService">
	<bpel:implementation.bpel process="sh:SayHello" />
<schema targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
	<!-- SCA-Assembly XML Schema -->
	<import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200912"/>
	<!-- SCA-BPEL Component Implementation Type -->
	<element name="implementation.bpel" type="sca:BPELImplementation" substitutionGroup="sca:implementation" />

Your Component Model/Configuration (2)

public interface BPELComponentImplementationModel extends ComponentImplementationModel {
public class V1BPELComponentImplementationModel extends V1ComponentImplementationModel implements... {

Your Component Model/Configuration (3)

public class V1BPELMarshaller extends V1CompositeMarshaller {
	* Reads in the Configuration, looking for "implementation.bpel".
	* If not found, it falls back to the super class (V1CompositeMarshaller).
	public Model read(Configuration config) {
		String name = config.getName();
		if (IMPLEMENTATION_BPEL.equals(name)) {
			return new V1BPELComponentImplementationModel(config, getDescriptor());
		return super.read(config);

Your Component Model/Configuration (4)

  • Creating the descriptor.properties with content like following in org.switchyard.config.model path

Project information


BY Luan Cestari