Aspects help to encapsulate cross-cutting expressions in one place. By applying an Advice, at various points in an application called Join-Points, Aspects can alter the behavior of the non-aspect parts of a software application.
The Java Business Integration (JBI) specification, JSR-208, provides a loosely coupled integration model for distributed services within a Service-Oriented Architecture (SOA). The architecture allows dynamic deployment of JBI components and JBI service assemblies that can be used as Aspect and Advice mechanisms to alter the behavior of other services. Once these Aspect and Advice mechanisms are "plugged" in on-the-fly between a Consuming Service and a Provisioning Service through a Service Facade, the architecture provides a mechanism to dynamically define, verify, audit, track, enable, and enforce these cross-cutting concerns.
![]() |
Multiple such configurations can be deployed so based on the façade URL that the client uses, different sets of advices are applied based on the aspect group configuration dynamically at runtime.
![]() |
Multiple such configurations can be deployed so based on the façade URL that the client uses, different sets of advices are applied based on the aspect group configuration dynamically at runtime.
![]() |
![]() |
The aspect map schema is as detailed below:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.sun.jbi.aspects/schema/AspectMap"
xmlns:tns="http://xml.sun.jbi.aspects/schema/AspectMap"
elementFormDefault="qualified">
<!-- Aspect Map Element -->
<xsd:element name="aspectmap" type="tns:aspectmapType"/>
<!-- Aspect Map Type -->
<xsd:complexType name="aspectmapType">
<xsd:sequence>
<xsd:element type="tns:aspectType" name="aspect" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>The aspect map</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<!-- Aspect Type -->
<xsd:complexType name="aspectType" mixed="true">
<xsd:sequence>
<xsd:element type="tns:inputType" name="input"/>
<xsd:element type="tns:outputType" name="output" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element type="tns:adviceType" name="advice" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute type="tns:ExchangeSimpleType" name="exchangeType" use="required"/>
<xsd:attribute type="xsd:string" name="ID" use="required"/>
</xsd:complexType>
<!-- Exchange Simple Type -->
<xsd:simpleType name="ExchangeSimpleType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="filterRequestReply"/>
<xsd:enumeration value="filterOneWay"/>
<xsd:enumeration value="requestReply"/>
</xsd:restriction>
</xsd:simpleType>
<!-- Input Type -->
<xsd:complexType name="inputType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute type="xsd:string" name="partnerLink" use="optional"/>
<xsd:attribute type="xsd:string" name="roleName" use="optional"/>
<xsd:attribute type="xsd:string" name="portType" use="required"/>
<xsd:attribute type="xsd:string" name="operation" use="required"/>
<xsd:attribute type="xsd:string" name="messageType" use="required"/>
<xsd:attribute type="xsd:string" name="file" use="required"/>
<xsd:attribute type="xsd:string" name="transformJBI" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- Output Type -->
<xsd:complexType name="outputType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute type="xsd:string" name="ID" use="required"/>
<xsd:attribute type="xsd:string" name="serviceName" use="optional"/>
<xsd:attribute type="xsd:string" name="portName" use="optional"/>
<xsd:attribute type="xsd:string" name="portType" use="required"/>
<xsd:attribute type="xsd:string" name="operation" use="required"/>
<xsd:attribute type="xsd:string" name="messageType" use="optional"/>
<xsd:attribute type="xsd:string" name="file" use="optional"/>
<xsd:attribute type="xsd:string" name="transformJBI" use="optional"/>
<xsd:attribute type="xsd:string" name="partnerLink" use="optional"/>
<xsd:attribute type="xsd:string" name="roleName" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<!-- Advice Type -->
<xsd:complexType name="adviceType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute type="xsd:string" name="type" use="optional"/>
<xsd:attribute type="xsd:string" name="configurationFile" use="optional"/>
<xsd:attribute type="xsd:string" name="order" use="optional"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:schema>
The <provides/> section of the jbi.xml for the service unit is derived from the <input/> node contents. The <partnerLinkName/> and <roleName/> are used to determine the provisioning endpoints for the Aspect Service unit. So for each <input/> node available in the aspectmap.xml, a <provides/> service endpoint will be registered with the NMR.
The <consumes/> section of the jbi.xml for the service unit is derived from the <output/> node contents of the aspectmap. The {<partnerLinkName/>, <roleName/>} combination, or the {<serviceName/>,{portName/ combination is used to determine the consuming endpoints for the Aspect Service unit. So for each <output/> node available in the aspectmap.xml, a <consumes/> service endpoint will be registered with the NMR.
A typical aspectmap contains one or more <aspect/> nodes. Based on the exchangeType attribute of each of those <aspect/> nodes, each aspectType contains an <input/> node, zero or more <output/> nodes, and zero or more <advice/> nodes.
The exchangeType represents the type of message exchange that is taking place, and can have three enumerated values. They are:
<aspactmap>
<aspect exchangeType = "filterRequestReply" ID=âÂÂ1âÂÂ>
<input partnerLink="{foo}pl1"
roleName="server"
portType="portType"
operation="operation"
messageType="replyMessageType"
file="input.xsl"
transformJBI="false" />
<output ID=âÂÂ1âÂÂ
serviceName="{bar}pl2"
portName="client"
portType="outPortType"
operation="outOp"
messageType="replyMessageType"
file="output.xsl"
transformJBI="false" />*
<advice type="queuing"
configurationFile="cache.xml"
order="1"/>
</aspect>
<aspect exchangeType = "filterOneWay" ID=âÂÂ2âÂÂ>
<input partnerLink="{foo}pl1"
roleName="server"
portType="portType"
operation="operation"
messageType="replyMessageType"
file="input.xsl"
transformJBI="false" />
<output ID=âÂÂ1âÂÂ
partnerLink="{bar}pl2"
roleName="client"
portType="outPortType"
operation="outOp" />*
<advice type="queuing"
configurationFile="cache.xml"
order="1"/>
<advice type="throttling"
configurationFile="throttling.xml"
order="2"/>
<advice type="logging"
configurationFile="logging.xml"
order="3"/>
<advice type="cache"
configurationFile="cache.xml"
order="4"/>
</aspect>
<aspect exchangeType = "requestReplyService" ID=âÂÂ3âÂÂ>
<input partnerLink="{foo}pl0"
roleName="server"
portType="portType"
operation="operation"
messageType="replyMessageType"
file="input.xsl"
transformJBI="false" />
<advice type="tracking"
configurationFile="tracking.xml"
order="1"/>
</aspect>
</aspactmap>
There are a couple of patterns that the Cache aspect should support for starters:
This is the default Cache pattern that we will use. Composite Apps requiring use of this aspect will have to employ the Filter Request/Reply exchange pattern.
In a request/reply message exchange, the request message from the client is sent to the service with the Cache in the middle. The reply message to the client is cached. Subsequently, when the same request message is sent out by the client, the reply message is provided from the Cache instead of having to invoke the actual service.
One scenario the user can use the Cache Aside pattern in his composite app is as follows:
This aspect reduces the load on services based on policies which determine:
Composite Apps requiring use of this aspect will have to employ the Filter Request/Reply or the Filter One-Way exchange pattern.
The Request Throttling policy should be applied based on:
<?xml version="1.0" encoding="UTF-8"?>
<throttling>
<config>
<!-- Messages per second -->
<property name="rate" value="10" />
<!-- Maximum number of queue entries -->
<property name="queue-length" value="1000" />
</config>
<ruleset name="mythrottling">
<rule name="myfirstrule">
<xpath keyExpression="/Employee/FirstName"/>
</rule>
</ruleset>
</throttling>
In a request/reply scenario, if the service provider is unavailable, one has to block the client until the service is up again and a response is received. The Auto-Reconnect Aspect would keep trying to make the call to the destination every configurable seconds for another configurable amount of time until the service provider becomes available again or the maximum number of retries is reached based on the configuration.
This pattern ensures the Retry policy acts between the client and the service that is being invoked. Therefore, if this aspect is configured, all messages flowing between the client and the service provider flows through the Retry engine core.
Composite Apps requiring use of this aspect will have to employ the Filter Request/Reply exchange pattern.
The Retry Aspect works on idempotent operations that do not need to go back to the client for conflict resolution.
<?xml version="1.0" encoding="UTF-8"?>
<retry>
<config>
<!-- retry rate in msg / sec -->
<property name="rate" value="10" />
<!-- timeout in millisecond -->
<property name="timeout" value="1000" />
</config>
</retry>
The levels in descending order are:
This pattern ensures the Logging policy acts between the client and the service. Therefore, if this aspect is configured, all messages flowing between the client and the service providers flow through the Logging engine core.
Composite Apps requiring use of this pattern will have to employ either the Filter Request/Reply or the Filter One-Way exchange pattern. Logging Management Configuration
<?xml version="1.0" encoding="UTF-8"?>
<logging>
<config>
<property name="level" value="INFO"/>
<property name="rotation-policy" value="DAILY" />
<property name="log-file" value="C:\\temp\\loggingse.log" />
</config>
</logging>
For lease management we need to keep a list of users. And for each user we have the start time and end time for when that user can request that service. For example we have a list like:
jwaldorf 3/20/2007 12:23 AM 4/20/2007 12:23 AM
sbiswas 4/5/2007 2:33 PM 5/17/2007 4:55 AM
Then when the web service is invoked that has the jwaldorf credentials today it allows the call. But if the call was made with sbiswas today then it returns a fault because sbiswas cannot access the service until April 5th.
Let's say in May jwaldorf tried the call again, it fails because his lease expires. The aspect will need to look at the message exchange property that contains the security context that has the name of the principle (aka user) that is invoking this service).
In a one-way web service request scenario, if the service provider is unavailable, one can use a Queuing Aspect to queue the requests until the service provider becomes available again. The Queuing Aspect would keep trying to make the call to the destination every configurable seconds for another configurable amount of time until the service provider becomes available again or the maximum number of retries is reached based on the configuration.
This pattern ensures the Queuing policy acts between the client and the service that is being invoked. Therefore, if this aspect is configured, all messages flowing between the client and the service provider flows through the Queuing engine core.
Composite Apps requiring use of this pattern will have to employ the Filter One-Way exchange pattern.
The Queuing Aspect works on idempotent operations that do not need to go back to the client for conflict resolution.
<?xml version="1.0" encoding="UTF-8"?>
<queuing>
<config>
<!-- Maximum number of queue entries -->
<property name="queue-length" value="1000" />
<!-- time specified in sec/ millisec-->
<property name="timeout" value="1000" />
<property name="queue-type" value="normal / priority">
</config>
</queuing>
The splitter will only work on operations that have one part. And that part is a repeating element. What the splitter will do is make 1 message with n repeating elements into n messages each with 1 element. For example, if the operation's message has a part called foo that is a min=0, max=unlimited element called bar. And the input message has 10 "bar" elements. The the splitter would create 10 output messages each with one "bar" element.
The splitter would also put in a message exchange property that would identify each messages group id, it's message number, and a flag if it is the last one.
So in the example above the 10 messages would have the following properties
(gid=1, mn=1, last=false)
(gid=1, mn=2, last=false)
(gid=1, mn=3, last=false)
(gid=1, mn=4, last=false)
(gid=1, mn=5, last=false)
(gid=1, mn=6, last=false)
(gid=1, mn=7, last=false)
(gid=1, mn=8, last=false)
(gid=1, mn=9, last=false)
(gid=1, mn=10, last=true)
The aggregator would then simply wait for all the messages and put them back into the array in the right order. It would be the responsibility of each se and aspect to preserve these message properties.
The splitter and aggregator work on one-way messages only. The Scatter-Gather works on request reply. For now we will make it only work on WSDLs that has it's input message have only one part that has a repeating element, and the output message that has only one part that is a repeating element. What the aspect will do is break the input message's many elements into a lot of single element messages. And then take the resulting responses and put them back into a single repeating array. For example if the input message has 3 repeating elements on the input message, then 3 seperate messages each with one element will be sent out of the aspect. When the 3 messages come back then will be put together into the repeating element and send back to the requester as one single message.
The Message Tracking aspect can be used to track messages flow through the system. Message Tracking will happen based on a configurable Rule Set which can be configured from the Web Console.
This pattern ensures the Message Tracking policy acts between the client and the multiple services that are involved to service the operation. Therefore, if this aspect is configured, all messages flowing between the client and the service providers flow through the Message Tracking engine core.
Composite Apps requiring use of this pattern will have to employ either the Filter Request/Reply or the Filter One-Way exchange pattern.
<?xml version="1.0" encoding="UTF-8"?>
<message-tracking>
<config>
<property name="mode" value="database / file" />
<!--
config can have more params defining the database/file locations.
-->
</config>
<ruleset name="myMessageTracking">
<rule name="myfirstrule">
<xpath keyExpression="/Employee/FirstName"/>
</rule>
</ruleset>
</message-tracking>
It acts very much like the tee command in Unix where, for example, you may want to save the output of a command in a file, while at the same time see the results on the terminal as it is being produced. Then if you see that the output is in error, you can stop the command.
The tee command in Unix acts like a T-junction. For e.g., the UNIX command
ls -al | tee folderdetails
shows all the details of the current folder on the terminal screen and also redirects the details to a file named folderdetails.
This pattern ensures that the Tee policy acts between the client and the service that is involved to service the operation. Therefore, if this aspect is configured, all messages flowing between the client and the service providers flow through the Tee engine core. The routing will happen based on a configurable Rule Set which can be configured from the Web Console.
Composite Apps requiring use of this pattern will have to employ the Filter One-Way exchange pattern.
<?xml version="1.0" encoding="UTF-8"?>
<tee>
<config />
<ruleset name="mytee" >
<rule name="myfirstrule">
<xpath keyExpression="/Employee/FirstName"/>
<destination id="1" />
<destination id="2" />
</rule>
</ruleset>
</tee>
This pattern ensures the Content-Based Routing policy acts between the client and the multiple services that are involved to service the operation. Therefore, if this aspect is configured, all messages flowing between the client and the service providers flow through the Content-Based Routing engine core.
Composite Apps requiring use of this pattern will have to employ either the Filter Request/Reply or the Filter One-Way exchange pattern.
For example,
<?xml version="1.0" encoding="UTF-8"?>
<contentBasedRouting>
<config />
<ruleset name="myrouting_1">
<rule name="myfirstrule">
<xpath keyExpression="/Employee/FirstName"/>
<destination id="1" />
</rule>
<rule name="mysecondrule">
<xpath keyExpression="/Employee/FirstName"/>
<destination id="2" />
</rule>
<rule name="mythirdrule">
<xpath keyExpression="/Employee/FirstName"/>
<destination id="3" />
</rule>
</ruleset>
</contentBasedRouting>
For request/reply type interactions, it could work similarly. It would allow x un-responsed requests to be outstanding.
This would work for some course grain priority of messages. This could control creation of new processes based on priority. But once the business process is created it would not be able to control putting one business process ahead of the other.
The configuration for such a priority-based queuing advice would be based on the message content where the XPath expression evaluates to a certain value or a range of values.
Messages that pass through such a priority-based queuing aspect engine would be resequenced and queued based on the XPath rules defined.
The Aspect Service Engine is a JSR-208 Engine Component Container that provides an implementation framework where multiple aspects are implemented.


Complete List of Planned Aspects
Further details about the Aspect Map XML can be found here :: Aspect Map Details
Aspect Editor facilitates creation of AspectMap.xml file for the Aspect Service Engine. Aspect Editor is available as a plug-in with the Netbeans 6.0. Netbeans 6.0 also provides plug-in for Aspect SE Project system which is used for building Aspect Service Unit.
Working with the Aspect Editor is simple. The pictorial guide below shows how aspect map can be build from the scratch which supports injecting 3 advices in the order specified:
Aspect SE(Provides)End Point --> Logging --> Cacheing --> Throttling --> Aspect SE (Consumes) End Point
Refer to some of our Quality Demos
to learn about Building, Injecting and Deplying Aspects from Aspect SE between BPEL and external web services.
Access Count: 16
StatCounter Access Count :