Author: objectiser
Date: 2010-09-06 12:53:49 -0400 (Mon, 06 Sep 2010)
New Revision: 392
Added:
trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/JBossESBInterceptor.java
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java
Removed:
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java
Modified:
trunk/samples/purchasing/PurchaseGoods.cdm
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceValidator.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
Log:
Hooked jbossws-native interceptors into service validator. Producing some initial
validation events, but currently flagging some messages as unexpected. PurchaseGoods.cdm
has been added to models folder with the necessary annotations.
Modified: trunk/samples/purchasing/PurchaseGoods.cdm
===================================================================
--- trunk/samples/purchasing/PurchaseGoods.cdm 2010-09-06 14:37:42 UTC (rev 391)
+++ trunk/samples/purchasing/PurchaseGoods.cdm 2010-09-06 16:53:49 UTC (rev 392)
@@ -53,26 +53,38 @@
<variableDefinitions description="Channel to facilitate interaction to
Supplier" name="SupplierChannel"
type="//@typeDefinitions/(a)channelTypes.1"/>
<variableDefinitions description="This is the variable buy"
name="buy" type="//@typeDefinitions/(a)informationTypes.2"/>
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyRequest" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
- <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction BuyRequest"
name="BuyRequestRequestExchange"
type="//@typeDefinitions/(a)informationTypes.2"/>
+ <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction BuyRequest"
name="BuyRequestRequestExchange"
type="//@typeDefinitions/(a)informationTypes.2">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheck" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
- <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction CreditCheck"
name="CreditCheckRequestExchange"
type="//@typeDefinitions/(a)informationTypes.5"/>
+ <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction CreditCheck"
name="CreditCheckRequestExchange"
type="//@typeDefinitions/(a)informationTypes.5">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
<activities xsi:type="org.pi4soa.cdl:Choice" description="Is credit
ok?">
<activities xsi:type="org.pi4soa.cdl:Sequence"
description="Credit Valid">
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheckOk" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
- <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckOk"
name="CreditCheckOkRespondExchange"
type="//@typeDefinitions/(a)informationTypes.4" action="Respond"/>
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckOk"
name="CreditCheckOkRespondExchange"
type="//@typeDefinitions/(a)informationTypes.4" action="Respond">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyConfirmed" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
- <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyConfirmed"
name="BuyConfirmedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.0" action="Respond"/>
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyConfirmed"
name="BuyConfirmedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.0" action="Respond">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
</activities>
<activities xsi:type="org.pi4soa.cdl:Sequence"
description="Credit Invalid">
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheckFailed" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
- <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckFailed"
name="CreditCheckFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.3" action="Respond"
faultName="CreditCheckFailed"/>
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckFailed"
name="CreditCheckFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.3" action="Respond"
faultName="CreditCheckFailed">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
<activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyFailed" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
- <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyFailed"
name="BuyFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.1" action="Respond"
faultName="BuyFailed"/>
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyFailed"
name="BuyFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.1" action="Respond"
faultName="BuyFailed">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
</activities>
</activities>
</activities>
Added: trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm
===================================================================
--- trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm
(rev 0)
+++ trunk/validators/jboss/common/src/main/configs/models/PurchaseGoods.cdm 2010-09-06
16:53:49 UTC (rev 392)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<org.pi4soa.cdl:Package xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:org.pi4soa.cdl="http:///org/pi4soa/cdl.ecore" description="The
choreography description for PurchaseGoods" name="PurchaseGoods"
author="gary" version="0.1"
targetNamespace="http://www.jboss.org/savara/examples">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for PurchaseGoods"
prefix="tns"
uRI="http://www.jboss.org/savara/examples"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd"
uRI="http://www.w3.org/2001/XMLSchema"/>
+ <nameSpaces prefix="sto"
uRI="http://www.jboss.org/examples/store"
schemaLocation="store.xsd"/>
+ <nameSpaces prefix="ca"
uRI="http://www.jboss.org/examples/creditAgency"
schemaLocation="creditAgency.xsd"/>
+ <informationTypes description="This is the information type
BuyConfirmed" name="BuyConfirmed" typeName=""
elementName="sto:BuyConfirmed"/>
+ <informationTypes description="This is the information type BuyFailed"
name="BuyFailed" typeName=""
elementName="sto:BuyFailed"/>
+ <informationTypes description="This is the information type BuyRequest"
name="BuyRequest" typeName=""
elementName="sto:BuyRequest"/>
+ <informationTypes description="This is the information type
CreditCheckInvalid" name="CreditCheckInvalid" typeName=""
elementName="ca:CreditCheckInvalid"/>
+ <informationTypes description="This is the information type
CreditCheckOk" name="CreditCheckOk" typeName=""
elementName="ca:CreditCheckOk"/>
+ <informationTypes description="This is the information type
CreditCheckRequest" name="CreditCheckRequest" typeName=""
elementName="ca:CreditCheckRequest"/>
+ <informationTypes description="This is the information type IDType"
name="IDType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type
URITokenType" name="URITokenType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token ID" name="ID"
informationType="//@typeDefinitions/(a)informationTypes.6"/>
+ <tokens description="This is the token URIToken"
name="URIToken"
informationType="//@typeDefinitions/(a)informationTypes.7"/>
+ <tokenLocators description="This is the token locator
BuyFailedIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.1" query="//@id"
name="BuyFailedIDLocator"/>
+ <tokenLocators description="This is the token locator
BuyRequestIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.2" query="//@id"
name="BuyRequestIDLocator"/>
+ <tokenLocators description="This is the token locator
BuyResponseIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.0" query="//@id"
name="BuyResponseIDLocator"/>
+ <tokenLocators description="This is the token locator
CreditCheckInvalidIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.3" query="//@id"
name="CreditCheckInvalidIDLocator"/>
+ <tokenLocators description="This is the token locator
CreditCheckRequestIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.5" query="//@id"
name="CreditCheckRequestIDLocator"/>
+ <tokenLocators description="This is the token locator
CreditCheckResponseIDLocator" token="//@typeDefinitions/(a)tokens.0"
informationType="//@typeDefinitions/(a)informationTypes.4" query="//@id"
name="CreditCheckResponseIDLocator"/>
+ <roleTypes description="This is the role type Buyer"
name="Buyer">
+ <behaviors description="This is the behavior BuyerBehavior"
name="BuyerBehavior"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency"
name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior"
name="CreditAgencyBehavior" interface="ca:CreditAgencyInterface"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Store"
name="Store">
+ <behaviors description="This is the behavior StoreBehavior"
name="StoreBehavior" interface="sto:StoreInterface"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between Buyer and Store"
name="BuyerToStoreRel" firstRoleType="//@typeDefinitions/(a)roleTypes.0"
secondRoleType="//@typeDefinitions/(a)roleTypes.2"/>
+ <relationshipTypes description="Relationship between Store and
CreditAgency" name="StoreToCreditAgencyRel"
firstRoleType="//@typeDefinitions/(a)roleTypes.2"
secondRoleType="//@typeDefinitions/(a)roleTypes.1"/>
+ <participantTypes description="This is the participant type Buyer"
name="Buyer" roleTypes="//@typeDefinitions/(a)roleTypes.0">
+ <semanticAnnotations annotation="savara.samples.Purchasing@Buyer"
name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type
ca:CreditAgency" name="ca:CreditAgency"
roleTypes="//@typeDefinitions/(a)roleTypes.1">
+ <semanticAnnotations annotation="savara.samples.Common@CreditAgency"
name="conversationType"/>
+ </participantTypes>
+ <participantTypes description="This is the participant type sto:Store"
name="sto:Store" roleTypes="//@typeDefinitions/(a)roleTypes.2">
+ <semanticAnnotations annotation="savara.samples.Purchasing@Store"
name="conversationType"/>
+ </participantTypes>
+ <channelTypes description="This is the channel type
CreditAgencyChannelType" name="CreditAgencyChannelType"
referenceToken="//@typeDefinitions/(a)tokens.1"
roleType="//@typeDefinitions/(a)roleTypes.1">
+ <identities description="ID"
tokens="//@typeDefinitions/(a)tokens.0"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type StoreChannelType"
name="StoreChannelType" referenceToken="//@typeDefinitions/(a)tokens.1"
roleType="//@typeDefinitions/(a)roleTypes.2">
+ <identities description="ID"
tokens="//@typeDefinitions/(a)tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the PurchaseGoods
process" name="PurchaseGoodsProcess" root="true">
+ <variableDefinitions description="Channel to facilitate interaction to
CreditAgency" name="CreditAgencyChannel"
type="//@typeDefinitions/(a)channelTypes.0"/>
+ <variableDefinitions description="Channel to facilitate interaction to
Supplier" name="SupplierChannel"
type="//@typeDefinitions/(a)channelTypes.1"/>
+ <variableDefinitions description="This is the variable buy"
name="buy" type="//@typeDefinitions/(a)informationTypes.2"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyRequest" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction BuyRequest"
name="BuyRequestRequestExchange"
type="//@typeDefinitions/(a)informationTypes.2">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheck" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the request
exchange associated with interaction CreditCheck"
name="CreditCheckRequestExchange"
type="//@typeDefinitions/(a)informationTypes.5">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice" description="Is credit
ok?">
+ <activities xsi:type="org.pi4soa.cdl:Sequence"
description="Credit Valid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheckOk" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckOk"
name="CreditCheckOkRespondExchange"
type="//@typeDefinitions/(a)informationTypes.4" action="Respond">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyConfirmed" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyConfirmed"
name="BuyConfirmedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.0" action="Respond">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence"
description="Credit Invalid">
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="CreditCheckFailed" operation="checkCredit"
channelVariable="//@choreographies.0/(a)variableDefinitions.0"
relationship="//@typeDefinitions/(a)relationshipTypes.1">
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction CreditCheckFailed"
name="CreditCheckFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.3" action="Respond"
faultName="CreditCheckFailed">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/creditAgency}CreditAge...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction"
name="BuyFailed" operation="buy"
channelVariable="//@choreographies.0/(a)variableDefinitions.1"
relationship="//@typeDefinitions/(a)relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the
respond exchange associated with interaction BuyFailed"
name="BuyFailedRespondExchange"
type="//@typeDefinitions/(a)informationTypes.1" action="Respond"
faultName="BuyFailed">
+ <semanticAnnotations
annotation="<validator>
	<destination
name="{{Destination;The URI for the
destination;string;;{http://www.jboss.org/examples/store}StoreService}}&a...
ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}"
/>
</validator>
"
name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Modified:
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java
===================================================================
---
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -34,19 +34,21 @@
* This method processes a sent message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(java.io.Serializable msg) throws Exception;
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception;
/**
* This method processes a received message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(java.io.Serializable msg) throws Exception;
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws
Exception;
/**
* This method is called to update the model associated
Modified:
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
===================================================================
---
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -94,16 +94,19 @@
* This method processes a sent message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(java.io.Serializable msg) throws Exception {
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(msg);
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
@@ -118,16 +121,19 @@
* This method processes a received message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(java.io.Serializable msg) throws Exception {
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception
{
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(msg);
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
Modified:
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceValidator.java
===================================================================
---
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -155,17 +155,20 @@
* This method processes a sent message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(java.io.Serializable msg) throws Exception {
+ public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(msg);
-
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
+
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
null, null, msg, null, null);
@@ -179,16 +182,19 @@
* This method processes a received message against a service
* behavioural description.
*
+ * @param mesgType The optional message type
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(java.io.Serializable msg) throws Exception {
+ public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception
{
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(msg);
+ if (mesgType == null) {
+ mesgType = MessageUtil.getMessageType(msg);
+ }
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
Copied:
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/JBossESBInterceptor.java
(from rev 378,
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java)
===================================================================
---
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/JBossESBInterceptor.java
(rev 0)
+++
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/JBossESBInterceptor.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -0,0 +1,285 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.validator.jbossesb;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.savara.validator.Endpoint;
+import org.jboss.savara.validator.ServiceValidator;
+import org.jboss.savara.validator.ServiceValidatorManager;
+import org.jboss.soa.esb.message.*;
+import org.jboss.soa.esb.couriers.*;
+
+/**
+ * This class represents the filter used to intercept ESB
+ * messages an apply them to relevant Service Validators.
+ */
+public class JBossESBInterceptor extends org.jboss.soa.esb.filter.InputOutputFilter {
+
+ private static final String TOPIC_PREFIX = "topic/";
+ private static final String QUEUE_PREFIX = "queue/";
+ private static final String JMS_PROTOCOL_PREFIX = "jms:";
+
+ private static final Logger logger = Logger.getLogger(JBossESBInterceptor.class);
+
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * The default constructor.
+ */
+ public JBossESBInterceptor() {
+ }
+
+ /**
+ * This method returns the service validator manager.
+ *
+ * @return The service validator manager
+ */
+ protected ServiceValidatorManager getServiceValidatorManager() {
+ if (m_serviceValidatorManager == null) {
+ try {
+ InitialContext ctx = new InitialContext();
+ m_serviceValidatorManager =
+ (ServiceValidatorManager)ctx.lookup("savara/ServiceValidatorManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to locate Savara Service Validator
Manager");
+ }
+ }
+
+ return(m_serviceValidatorManager);
+ }
+
+ /**
+ * This method is invoked when a message is sent by an
+ * ESB service.
+ *
+ * @param msg The ESB message
+ * @param params The parameters
+ * @throws CourierException Failed to validate message
+ */
+ public Message onOutput(Message msg, java.util.Map params)
+ throws CourierException {
+
+ Endpoint endpoint=getEndpoint(msg);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(null, ESBUtil.getMessage(msg));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle sent message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid sent message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ throw new CourierException("Failed to handle sent message on endpoint
'"+
+ endpoint+"' validated against: "+vnames, ex);
+ }
+ } else {
+
+ // Check whether a dynamic reply is expected
+ if (getServiceValidatorManager().isOutputDynamicReplyTo(endpoint)) {
+
+ // Register interest in the 'reply-to' endpoint
+ Endpoint replyTo=getReplyToEndpoint(msg);
+
+ if (replyTo != null) {
+ getServiceValidatorManager().registerInputReplyToValidators(replyTo,
+ validators);
+ } else {
+ logger.error("Unable to get 'reply-to' endpoint for message:
"+msg);
+ }
+ }
+ }
+ }
+ }
+
+ return(msg);
+ }
+
+ /**
+ * This method is invoked when a message is received by an
+ * ESB service.
+ *
+ * @param msg The ESB message
+ * @param params The parameters
+ * @throws CourierException Failed to validate message
+ */
+ public Message onInput(Message msg, java.util.Map params)
+ throws CourierException {
+
+ Endpoint endpoint=getEndpoint(msg);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(null, ESBUtil.getMessage(msg));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ throw new CourierException("Failed to handle received message on
endpoint '"+
+ endpoint+"' validated against: "+vnames, ex);
+ }
+ } else {
+
+ // Check whether a dynamic reply is expected
+ if (getServiceValidatorManager().isInputDynamicReplyTo(endpoint)) {
+
+ // Register interest in the 'reply-to' endpoint
+ Endpoint replyTo=getReplyToEndpoint(msg);
+
+ if (replyTo != null) {
+ getServiceValidatorManager().registerOutputReplyToValidators(replyTo,
+ validators);
+ } else {
+ logger.error("Unable to get 'reply-to' endpoint for message:
"+msg);
+ }
+ }
+ }
+ }
+ }
+
+ return(msg);
+ }
+
+ /**
+ * This method returns an endpoint associated with the 'to'
+ * destination of the supplied message.
+ *
+ * @param msg The message
+ * @return The endpoint, or null if not relevant
+ */
+ protected Endpoint getEndpoint(Message msg) {
+ Endpoint ret=null;
+
+ if (msg != null && msg.getHeader() != null &&
+ msg.getHeader().getCall() != null &&
+ msg.getHeader().getCall().getTo() != null &&
+ msg.getHeader().getCall().getTo().getAddr() != null) {
+
+ String key=msg.getHeader().getCall().getTo().getAddr().getAddress();
+ int ind=-1;
+
+ if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
+ ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
+ (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
+ ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
+ }
+ }
+
+ logger.debug("Destination for message '"+msg+"' is:
"+ret);
+
+ return(ret);
+ }
+
+ /**
+ * This method returns an endpoint associated with the 'to'
+ * destination of the supplied message.
+ *
+ * @param msg The message
+ * @return The endpoint, or null if not relevant
+ */
+ protected Endpoint getReplyToEndpoint(Message msg) {
+ Endpoint ret=null;
+
+ if (msg != null && msg.getHeader() != null &&
+ msg.getHeader().getCall() != null &&
+ msg.getHeader().getCall().getReplyTo() != null &&
+ msg.getHeader().getCall().getReplyTo().getAddr() != null) {
+
+ String key=msg.getHeader().getCall().getReplyTo().getAddr().getAddress();
+ int ind=-1;
+
+ if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
+ ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
+ (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
+ ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
+ }
+ }
+
+ logger.debug("Reply-To Destination for message '"+msg+"' is:
"+ret);
+
+ return(ret);
+ }
+}
Modified:
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java
===================================================================
---
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -1,285 +1,36 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.jboss.savara.validator.jbossesb;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-
-import org.jboss.savara.validator.Endpoint;
-import org.jboss.savara.validator.ServiceValidator;
-import org.jboss.savara.validator.ServiceValidatorManager;
-import org.jboss.soa.esb.message.*;
-import org.jboss.soa.esb.couriers.*;
-
-/**
- * This class represents the filter used to intercept ESB
- * messages an apply them to relevant Service Validators.
- */
-public class ValidatorFilter extends org.jboss.soa.esb.filter.InputOutputFilter {
-
- private static final String TOPIC_PREFIX = "topic/";
- private static final String QUEUE_PREFIX = "queue/";
- private static final String JMS_PROTOCOL_PREFIX = "jms:";
-
- private static final Logger logger = Logger.getLogger(ValidatorFilter.class);
-
- private ServiceValidatorManager m_serviceValidatorManager=null;
-
- /**
- * The default constructor.
- */
- public ValidatorFilter() {
- }
-
- /**
- * This method returns the service validator manager.
- *
- * @return The service validator manager
- */
- protected ServiceValidatorManager getServiceValidatorManager() {
- if (m_serviceValidatorManager == null) {
- try {
- InitialContext ctx = new InitialContext();
- m_serviceValidatorManager =
- (ServiceValidatorManager)ctx.lookup("savara/ServiceValidatorManager");
- } catch (NamingException e) {
- throw new RuntimeException("Failed to locate Savara Service Validator
Manager");
- }
- }
-
- return(m_serviceValidatorManager);
- }
-
- /**
- * This method is invoked when a message is sent by an
- * ESB service.
- *
- * @param msg The ESB message
- * @param params The parameters
- * @throws CourierException Failed to validate message
- */
- public Message onOutput(Message msg, java.util.Map params)
- throws CourierException {
-
- Endpoint endpoint=getEndpoint(msg);
-
- if (endpoint != null) {
- java.util.List<ServiceValidator> validators=
- getServiceValidatorManager().getOutputServiceValidators(endpoint);
-
- if (validators != null && validators.size() > 0) {
- boolean validated=false;
- Exception ex=null;
-
- for (int i=0; validators != null &&
- i < validators.size(); i++) {
- try {
- validators.get(i).messageSent(ESBUtil.getMessage(msg));
- validated = true;
- } catch(Exception t) {
- // Ignore
- ex = t;
- }
- }
-
- // Only raise exception if none of the service
- // validators were able to validate the message
- if (validated == false) {
- String vnames="";
-
- for (int i=0; validators != null &&
- i < validators.size(); i++) {
- if (vnames.length() > 0) {
- vnames += ", ";
- }
- vnames += validators.get(i).getValidatorName();
- }
-
- logger.error("Failed to handle sent message on endpoint '"+
- endpoint+"' validated against: "+vnames);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Invalid sent message", ex);
- }
-
- if (getServiceValidatorManager().isManagedMode()) {
- throw new CourierException("Failed to handle sent message on endpoint
'"+
- endpoint+"' validated against: "+vnames, ex);
- }
- } else {
-
- // Check whether a dynamic reply is expected
- if (getServiceValidatorManager().isOutputDynamicReplyTo(endpoint)) {
-
- // Register interest in the 'reply-to' endpoint
- Endpoint replyTo=getReplyToEndpoint(msg);
-
- if (replyTo != null) {
- getServiceValidatorManager().registerInputReplyToValidators(replyTo,
- validators);
- } else {
- logger.error("Unable to get 'reply-to' endpoint for message:
"+msg);
- }
- }
- }
- }
- }
-
- return(msg);
- }
-
- /**
- * This method is invoked when a message is received by an
- * ESB service.
- *
- * @param msg The ESB message
- * @param params The parameters
- * @throws CourierException Failed to validate message
- */
- public Message onInput(Message msg, java.util.Map params)
- throws CourierException {
-
- Endpoint endpoint=getEndpoint(msg);
-
- if (endpoint != null) {
- java.util.List<ServiceValidator> validators=
- getServiceValidatorManager().getInputServiceValidators(endpoint);
-
- if (validators != null && validators.size() > 0) {
- boolean validated=false;
- Exception ex=null;
-
- for (int i=0; validators != null &&
- i < validators.size(); i++) {
- try {
- validators.get(i).messageReceived(ESBUtil.getMessage(msg));
- validated = true;
- } catch(Exception t) {
- // Ignore
- ex = t;
- }
- }
-
- // Only raise exception if none of the service
- // validators were able to validate the message
- if (validated == false) {
- String vnames="";
-
- for (int i=0; validators != null &&
- i < validators.size(); i++) {
- if (vnames.length() > 0) {
- vnames += ", ";
- }
- vnames += validators.get(i).getValidatorName();
- }
-
- logger.error("Failed to handle received message on endpoint '"+
- endpoint+"' validated against: "+vnames);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Invalid received message", ex);
- }
-
- if (getServiceValidatorManager().isManagedMode()) {
- throw new CourierException("Failed to handle received message on
endpoint '"+
- endpoint+"' validated against: "+vnames, ex);
- }
- } else {
-
- // Check whether a dynamic reply is expected
- if (getServiceValidatorManager().isInputDynamicReplyTo(endpoint)) {
-
- // Register interest in the 'reply-to' endpoint
- Endpoint replyTo=getReplyToEndpoint(msg);
-
- if (replyTo != null) {
- getServiceValidatorManager().registerOutputReplyToValidators(replyTo,
- validators);
- } else {
- logger.error("Unable to get 'reply-to' endpoint for message:
"+msg);
- }
- }
- }
- }
- }
-
- return(msg);
- }
-
- /**
- * This method returns an endpoint associated with the 'to'
- * destination of the supplied message.
- *
- * @param msg The message
- * @return The endpoint, or null if not relevant
- */
- protected Endpoint getEndpoint(Message msg) {
- Endpoint ret=null;
-
- if (msg != null && msg.getHeader() != null &&
- msg.getHeader().getCall() != null &&
- msg.getHeader().getCall().getTo() != null &&
- msg.getHeader().getCall().getTo().getAddr() != null) {
-
- String key=msg.getHeader().getCall().getTo().getAddr().getAddress();
- int ind=-1;
-
- if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
- ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
- (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
- ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
- }
- }
-
- logger.debug("Destination for message '"+msg+"' is:
"+ret);
-
- return(ret);
- }
-
- /**
- * This method returns an endpoint associated with the 'to'
- * destination of the supplied message.
- *
- * @param msg The message
- * @return The endpoint, or null if not relevant
- */
- protected Endpoint getReplyToEndpoint(Message msg) {
- Endpoint ret=null;
-
- if (msg != null && msg.getHeader() != null &&
- msg.getHeader().getCall() != null &&
- msg.getHeader().getCall().getReplyTo() != null &&
- msg.getHeader().getCall().getReplyTo().getAddr() != null) {
-
- String key=msg.getHeader().getCall().getReplyTo().getAddr().getAddress();
- int ind=-1;
-
- if (key.startsWith(JMS_PROTOCOL_PREFIX) &&
- ((ind=key.indexOf(QUEUE_PREFIX)) != -1 ||
- (ind=key.indexOf(TOPIC_PREFIX)) != -1)) {
- ret = new Endpoint(JMS_PROTOCOL_PREFIX+key.substring(ind));
- }
- }
-
- logger.debug("Reply-To Destination for message '"+msg+"' is:
"+ret);
-
- return(ret);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.savara.validator.jbossesb;
+
+/**
+ *
+ * @deprecated Use JBossESBInterceptor instead
+ */
+public class ValidatorFilter extends JBossESBInterceptor {
+
+ /**
+ * The default constructor.
+ */
+ public ValidatorFilter() {
+ }
+
+}
Added:
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java
===================================================================
---
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java
(rev 0)
+++
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/AbstractJBossWSNativeInterceptor.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -0,0 +1,161 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.savara.validator.jbosswsnative;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.savara.validator.Endpoint;
+import org.jboss.savara.validator.ServiceValidatorManager;
+import org.jboss.ws.metadata.umdm.ParameterMetaData;
+import org.jboss.wsf.common.DOMWriter;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
+
+/**
+ * Common abstract base class for the client and server JBossWS
+ * native interceptors.
+ *
+ */
+public abstract class AbstractJBossWSNativeInterceptor extends GenericSOAPHandler {
+
+ private static Log logger = LogFactory.getLog(AbstractJBossWSNativeInterceptor.class);
+
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * This method returns the service validator manager.
+ *
+ * @return The service validator manager
+ */
+ protected ServiceValidatorManager getServiceValidatorManager() {
+ if (m_serviceValidatorManager == null) {
+ try {
+ InitialContext ctx = new InitialContext();
+ m_serviceValidatorManager =
+ (ServiceValidatorManager)ctx.lookup("savara/ServiceValidatorManager");
+ } catch (NamingException e) {
+ throw new RuntimeException("Failed to locate Savara Service Validator
Manager");
+ }
+ }
+
+ return(m_serviceValidatorManager);
+ }
+
+ /**
+ * This method returns the message content.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The message content
+ * @throws Exception Failed to get the message content
+ */
+ public static java.io.Serializable getMessage(SOAPMessageContext soapCtx) throws
Exception {
+ java.io.Serializable ret=null;
+
+ SOAPElement elem = getMessageBody(soapCtx);
+ if (elem != null) {
+ ret = DOMWriter.printNode(elem, true);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the message type associated with the supplied SOAP
+ * message context.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The message type
+ * @throws SOAPException Failed to determine the message type
+ */
+ public static String getMessageType(SOAPMessageContext soapCtx) throws SOAPException {
+ String ret=null;
+
+ if (soapCtx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
+ org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
+ (org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)soapCtx;
+ org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
+
+ if (opmetadata.getInputParameters().size() == 1) {
+ ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
+
+ // TODO: Find out why 'genericParam' is generated when the parameter
+ // is a complex type
+ if (pmd.getXmlName().getLocalPart().equals("genericParam")) {
+
+ // Extract message value
+ SOAPElement elem=getMessageBody(soapCtx);
+
+ ret = elem.getElementQName().toString();
+
+ } else {
+ ret = pmd.getXmlName().toString();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected static SOAPElement getMessageBody(SOAPMessageContext soapCtx) throws
SOAPException {
+ SOAPElement ret=null;
+
+ // Extract message value
+ SOAPBody soapBody = soapCtx.getMessage().getSOAPPart().getEnvelope().getBody();
+
+ ret = (SOAPElement)soapBody.getChildElements().next();
+
+ if (ret instanceof SOAPFault) {
+ SOAPFault fault=(SOAPFault)ret;
+
+ ret = (SOAPElement)fault.getDetail().getChildElements().next();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the endpoint associated with the supplied SOAP
+ * message context.
+ *
+ * @param soapCtx The SOAP message context
+ * @return The endpoint
+ */
+ public static Endpoint getEndpoint(SOAPMessageContext soapCtx) {
+ QName service=(QName)soapCtx.get(MessageContext.WSDL_SERVICE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service for endpoint = "+service);
+ }
+
+ return(new Endpoint(service.toString()));
+ }
+}
Modified:
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java
===================================================================
---
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeClientInterceptor.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -17,19 +17,16 @@
*/
package org.jboss.savara.validator.jbosswsnative;
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
-import org.jboss.wsf.common.DOMWriter;
-import org.jboss.wsf.common.handler.GenericSOAPHandler;
+import org.jboss.savara.validator.Endpoint;
+import org.jboss.savara.validator.ServiceValidator;
-public class JBossWSNativeClientInterceptor extends GenericSOAPHandler {
+public class JBossWSNativeClientInterceptor extends AbstractJBossWSNativeInterceptor {
private static Log logger = LogFactory.getLog(JBossWSNativeClientInterceptor.class);
@@ -40,51 +37,113 @@
}
protected boolean handleInbound(MessageContext ctx) {
+ boolean ret=true;
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
- try {
- Object service=ctx.get(MessageContext.WSDL_SERVICE);
-
- logger.info("Client: Inbound message for service="+service);
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
- SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
- if (soapEnv != null) {
- System.out.println(DOMWriter.printNode(soapEnv, true));
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(getMessageType(soapCtx),
getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
}
-
- QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
-
- logger.info("Client: Inbound message type="+mesgType);
-
- } catch (SOAPException ex) {
- logger.error("Cannot trace SOAPMessage", ex);
}
- return true;
+ return(ret);
}
protected boolean handleOutbound(MessageContext ctx) {
+ boolean ret=true;
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
- try {
- Object service=ctx.get(MessageContext.WSDL_SERVICE);
-
- logger.info("Client: Outbound message for service="+service);
+ Endpoint endpoint=getEndpoint(soapCtx);
+
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
- SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
- if (soapEnv != null) {
- System.out.println(DOMWriter.printNode(soapEnv, true));
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(getMessageType(soapCtx), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
}
-
- QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
-
- logger.info("Client: Outbound message type="+mesgType);
-
- } catch (SOAPException ex) {
- logger.error("Cannot trace SOAPMessage", ex);
}
- return true;
+ return(ret);
}
public boolean handleFault(MessageContext ctx) {
Deleted:
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java
===================================================================
---
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeInterceptorUtil.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.savara.validator.jbosswsnative;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
-
-/**
- * This class provides utility functions for the JBossWS native interceptors.
- *
- */
-public class JBossWSNativeInterceptorUtil {
-
- /**
- * This method determines the message type associated with the supplied SOAP
- * message context.
- *
- * @param soapCtx The SOAP message context
- * @return The message type
- * @throws SOAPException Failed to determine the message type
- */
- public static QName getMessageType(SOAPMessageContext soapCtx) throws SOAPException {
- QName ret=null;
-
- if (soapCtx instanceof org.jboss.ws.core.jaxws.handler.MessageContextJAXWS) {
- org.jboss.ws.core.jaxws.handler.MessageContextJAXWS mc=
- (org.jboss.ws.core.jaxws.handler.MessageContextJAXWS)soapCtx;
- org.jboss.ws.metadata.umdm.OperationMetaData opmetadata=mc.getOperationMetaData();
-
- if (opmetadata.getInputParameters().size() == 1) {
- ParameterMetaData pmd=opmetadata.getInputParameters().get(0);
-
- // TODO: Find out why 'genericParam' is generated when the parameter
- // is a complex type
- if (pmd.getXmlName().getLocalPart().equals("genericParam")) {
-
- // Extract message value
- SOAPBody soapBody =
soapCtx.getMessage().getSOAPPart().getEnvelope().getBody();
-
- SOAPElement elem=(SOAPElement)soapBody.getChildElements().next();
-
- if (elem instanceof SOAPFault) {
- SOAPFault fault=(SOAPFault)elem;
-
- SOAPElement
detail=(SOAPElement)fault.getDetail().getChildElements().next();
-
- ret = detail.getElementQName();
-
- } else {
- ret = elem.getElementQName();
- }
- } else {
- ret = pmd.getXmlName();
- }
- }
- }
-
- return(ret);
- }
-
-}
Modified:
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java
===================================================================
---
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java 2010-09-06
14:37:42 UTC (rev 391)
+++
trunk/validators/jboss/wsnative/src/main/java/org/jboss/savara/validator/jbosswsnative/JBossWSNativeServerInterceptor.java 2010-09-06
16:53:49 UTC (rev 392)
@@ -17,22 +17,16 @@
*/
package org.jboss.savara.validator.jbosswsnative;
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFault;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.ws.metadata.umdm.ParameterMetaData;
-import org.jboss.wsf.common.DOMWriter;
-import org.jboss.wsf.common.handler.GenericSOAPHandler;
+import org.jboss.savara.validator.Endpoint;
+import org.jboss.savara.validator.ServiceValidator;
-public class JBossWSNativeServerInterceptor extends GenericSOAPHandler {
+public class JBossWSNativeServerInterceptor extends AbstractJBossWSNativeInterceptor {
private static Log logger = LogFactory.getLog(JBossWSNativeServerInterceptor.class);
@@ -43,56 +37,113 @@
}
protected boolean handleInbound(MessageContext ctx) {
+ boolean ret=true;
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
- try {
- Object service=ctx.get(MessageContext.WSDL_SERVICE);
-
- logger.info("Server: Inbound message for service="+service);
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
- SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
- if (soapEnv != null) {
- System.out.println(DOMWriter.printNode(soapEnv, true));
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageReceived(getMessageType(soapCtx),
getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
}
-
- //Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
- //logger.info("Server: Inbound message for operation="+operation);
-
- QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
-
- logger.info("Server: Inbound message type="+mesgType);
-
- } catch (SOAPException ex) {
- logger.error("Cannot trace SOAPMessage", ex);
}
- return true;
+ return(ret);
}
protected boolean handleOutbound(MessageContext ctx) {
+ boolean ret=true;
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
+
+ Endpoint endpoint=getEndpoint(soapCtx);
- try {
- Object service=ctx.get(MessageContext.WSDL_SERVICE);
-
- logger.info("Server: Outbound message for service="+service);
-
- SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
- if (soapEnv != null) {
- System.out.println(DOMWriter.printNode(soapEnv, true));
- }
-
- //Object operation=soapCtx.get(MessageContext.WSDL_OPERATION);
- //logger.info("Server: Outbound message for operation="+operation);
+ if (endpoint != null) {
+ java.util.List<ServiceValidator> validators=
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
+
+ if (validators != null && validators.size() > 0) {
+ boolean validated=false;
+ Exception ex=null;
- QName mesgType=JBossWSNativeInterceptorUtil.getMessageType(soapCtx);
-
- logger.info("Server: Outbound message type="+mesgType);
- } catch (SOAPException ex) {
- logger.error("Cannot trace SOAPMessage", ex);
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ try {
+ validators.get(i).messageSent(getMessageType(soapCtx), getMessage(soapCtx));
+ validated = true;
+ } catch(Exception t) {
+ // Ignore
+ ex = t;
+ }
+ }
+
+ // Only raise exception if none of the service
+ // validators were able to validate the message
+ if (validated == false) {
+ String vnames="";
+
+ for (int i=0; validators != null &&
+ i < validators.size(); i++) {
+ if (vnames.length() > 0) {
+ vnames += ", ";
+ }
+ vnames += validators.get(i).getValidatorName();
+ }
+
+ logger.error("Failed to handle received message on endpoint '"+
+ endpoint+"' validated against: "+vnames);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Invalid received message", ex);
+ }
+
+ if (getServiceValidatorManager().isManagedMode()) {
+ ret = false;
+ }
+ }
+ }
}
- return true;
+ return(ret);
}
public boolean handleFault(MessageContext ctx) {