Setting up JBoss Developer Studio
First things first. Download a copy of the latest JBoss Developer Studio (JBDS) 7.1.1.GA for your operating system and install it. You should already have a JDK in place so a simple
java -jar jbdevstudio-product-eap-universal-7.1.1.GA-v20140314-2145-B688.jar
will work. A simply 9 step installer will guide you through the steps necessary. Make sure to select the suitable JDK installation. JBDS works and has been tested with Java SE 6.x and 7.x. If you like to, install the complete EAP but it's not a requirement for this little how-to. A basic setup without EAP requires roughly 400 MB disc space and shouldn't take longer than a couple of minutes. If you're done with that part launch the IDE and go on and configure the tooling. We need the JBoss Tools Integration Stack (JBTIS). Configure them by visiting "Help -> Install New Software" and add a new Update Site with the "Add" button. Call it SY-Development and point it to: "http://download.jboss.org/jbosstools/updates/development/kepler/integration-stack/"
SY Tooling 2.0.0 |
Preventing erroneous XML validation |
General Information about SwitchYard Projects
Lets find out more about the general SwitchYard project layout before we dive into the bean-service example. A SwitchYard project is a Maven based project with the following characteristics:
- a switchyard.xml file in the project's META-INF folder
- one or more SwitchYard runtime dependencies declared in the pom.xml file
- org.switchyard:switchyard-plugin mojo configured in the pom.xml file
Generally, a SwitchYard project may also contain a variety of other resources used to implement the application, for example: Java, BPMN2, DRL, BPEL, WSDL, XSD, and XML files. The tooling supports you with creating, changing and developing your SY projects. You can also add SY capabilities to existing Maven projects. More details can be found in the documentation for the Eclipse tooling.
The Bean-Service example is one of the more simpler ones to get a first impression about SY. All of the example applications in the Quickstarts repository are included in quickstarts/ directory of your installation and also available on GitHub. The bean-service quickstart demonstrates the usage of the bean component. The scenario is easy: An OrderService, which is provided through the OrderServiceBean, and an InventoryService which is provided through the InventoryServiceBean implementation take care of orders. Orders are submitted through the OrderService.submitOrder, and the OrderService then looks up items in the InventoryService to see if they are in stock and the order can be processed. Up to here it is basically a simple CDI based Java EE application. In this application the simple process is invoked through a SOAP gateway binding (Which is indicated by the little envelope).
Let's dive into the implementation a bit. Looking at the OrderServiceBean reveals some more details. It is the implementation of the OrderService interface which defines the operations. The OrderServiceBean is just a bean class few extra CDI annotations. Most notably is the
That was a very quick rundown. We've not touched the webservice endpoints, the WSDL and the Transformer configuration and implementation. Have a look at the SwitchYard tutorial which was published by mastertheboss and take the chance to read more about SY at the following links:
Bean Service Quickstart Overview |
@org.switchyard.component.bean.Service(OrderService.class)
The @Service annotation allows the SwitchYard CDI Extension to discover your bean at runtime and register it as a service. Every bean service must have an @Service annotation with a value identifying the service interface for the service. In addition to providing a service in SwitchYard, beans can also consume other services. Those references need to be injected. In this example the InventoryService is injected @Inject
@org.switchyard.component.bean.Reference
private InventoryService _inventory;
Finally, all you need is the switchyard.xml configuration file where your Service, Components, Types and implementations are described.<composite name="orders" >
<component name="OrderService">
<implementation.bean class="org.switchyard.quickstarts.bean.service.OrderServiceBean"/>
<service name="OrderService">
<interface.java interface="org.switchyard.quickstarts.bean.service.OrderService"/>
</service>
</component>
</composite>
That was a very quick rundown. We've not touched the webservice endpoints, the WSDL and the Transformer configuration and implementation. Have a look at the SwitchYard tutorial which was published by mastertheboss and take the chance to read more about SY at the following links:
- SwitchYard Project Documentation
- SwitchYard Homepage
- Community Pages on JBoss.org
- SwitchYard is part of Fuse ServiceWorks, give it a try in a full fledged SOA Suite.