...
ServiceMix JSR-
...
181
ServiceMix jsr181 JSR(181 component is a JBI Service Engine exposing (annotated) POJO as services on the JBI Bus.
It uses xfire internally to perform service invocations and xml marshaling.
...
- no annotations
- jsr181 annotations
- commons-attributes annotations
- aegis binding
- jaxb2 binding
- xmlbeans binding
- wsdl auto generation
- MTOM / attachments support
Installation
Maven Archetype
You can create a JSR-181 Service Unit using Installing the servicemix-jsr181 component can be done in several ways:
- drop the installer zip in an hotdeploy directory monitored by ServiceMix
- using ant tasks
Note that when using ant tasks, the component is not started, you will have to start it manually using ant tasks or a console.
Configuration
Several parameters can be configured using a JMX console.
Info | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
|
Deployment
You can deploy Service Units containing a file named xbean.xml for activating consumer and provider endpoints.
-service-unit archetype:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-jsr181-service-unit \
-DarchetypeVersion=2010.01 \
-DgroupId=your.group.id \
-DartifactId=your.artifact.id \
-Dversion=your-version
|
Endpoint Configuration
A JSR-181 endpoint only takes an annotated POJO in the pojoClass attribute:This xml file should respect the given syntax, though this is a spring based xml configuration file from where all beans of class Jsr181Endpoint are retrieved.
See a full example here. Note that you have to define the http namespace with
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns:jsr181="http://servicemix.apache.org/jsr181/1.0">
...
</beans>
|
Any numbers of endpoints can be specified in the xbean.xml file.
As the main purpose is to expose a POJO, you will have to include the needed class files / jars in the service unit and reference them using the following tags in your xbean.xml configuration file:
Code Block | ||
---|---|---|
| ||
<classpath>
<location>.</location>
</classpath>
|
This will add the content of the location tags (relative to the unzipped service unit) to the classpath. The previous configuration will just add the class files contained in the service unit, as if it is a plain jar.
If you want to embed jars, just use something like
Code Block | ||
---|---|---|
| ||
<classpath>
<location>lib/foo.jar</location>
</classpath>
|
Endpoint
<jsr181:endpoint pojoClass="your.package.ServicePojo" />
</beans>
|
A few other A few examples:
Wiki Markup |
---|
{snippet:id=embedded|lang=xml|url=servicemix/components/engines/servicemix-jsr181/trunk/src/test/resources/good2/xbean.xml} |
...
Wiki Markup |
---|
{snippet:id=byclass|lang=xml|url=servicemix/components/engines/servicemix-jsr181/trunk/src/test/resources/good2/xbean.xml} |
Info | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
...
Code Block | ||
---|---|---|
| ||
public void myMethod() { ServiceMixClient client = new ServiceMixClientFacade(this.context); QName service = new QName("http://servicemix.org/cheese/", "receiver"); EndpointResolver resolver = client.createResolverForService(service); client.send(resolver, null, null, "<hello>world</hello>"); } |
Lightweight mode
The servicemix-jsr181 component can also be configured in a spring/xbean configuration file, for use in an embedded ServiceMix.
Here is an example of such a configuration:
Wiki Markup |
---|
{snippet:id=lightweight|lang=xml|url=servicemix/components/engines/servicemix-jsr181/trunk/src/test/resources/org/apache/servicemix/jsr181/spring.xml} |
Warning | ||
---|---|---|
| ||
When using the servicemix.xml configuration file to create jsr181 endpoints, you must include the servicemix-jsr181-xxx.jar in your classpath. You will find this file inside the component installer (./components/servicemix-jsr181-xxx.zip). Failing this, an IllegalArgumentException will be thrown with the following message: Component name: xxxxxx is bound to an object which is not a JBI component, it is of type: javax.xml.namespace.QName or aanother exception with |
Proxies
You can create java proxies for JBI endpoints, provided that they expose a WSDL.
...