savara SVN: r378 - in trunk: validators/jboss/common and 11 other directories.
by do-not-reply@jboss.org
Author: objectiser
Date: 2010-08-27 12:49:51 -0400 (Fri, 27 Aug 2010)
New Revision: 378
Added:
trunk/validators/jboss/common/.settings/
trunk/validators/jboss/common/.settings/org.eclipse.jdt.core.prefs
trunk/validators/jboss/common/src/main/configs/META-INF/
trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml
trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml
trunk/validators/jboss/common/src/main/configs/models/
trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm
trunk/validators/jboss/common/src/main/configs/pi4soa.xml
trunk/validators/jboss/common/src/main/configs/validator-config.xml
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/AbstractServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/DefaultValidatorConfig.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/Endpoint.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorFactory.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorManager.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfig.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigFactory.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigLoader.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorName.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorService.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorServiceMBean.java
Removed:
trunk/validators/jboss/esb/src/main/configs/META-INF/jbm-queue-service.xml
trunk/validators/jboss/esb/src/main/configs/models/
trunk/validators/jboss/esb/src/main/configs/pi4soa.xml
trunk/validators/jboss/esb/src/main/configs/validator-config.xml
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/AbstractServiceValidator.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/DefaultValidatorConfig.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/Endpoint.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidator.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorFactory.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorManager.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfig.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigFactory.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigLoader.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorName.java
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/pi4soa/
Modified:
trunk/pom.xml
trunk/validators/jboss/common/pom.xml
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/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java
trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java
trunk/validators/jboss/esb/pom.xml
trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml
trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java
Log:
Separated validator functionality into a separate module which is deployed as a sar. May want to separate this out further if deploying to other platforms eventually. Currently deploys ok, but trailblazer example does not work - so needs investigation.
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/pom.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -45,6 +45,7 @@
<log4j.version>1.2.14</log4j.version>
<mvel.version>1.3.4-java1.5</mvel.version>
<jaxb.version>2.1</jaxb.version>
+ <jboss.version>5.1.0.GA</jboss.version>
</properties>
<modules>
Added: trunk/validators/jboss/common/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/validators/jboss/common/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/validators/jboss/common/.settings/org.eclipse.jdt.core.prefs 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,5 @@
+#Fri Aug 27 15:07:12 BST 2010
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Modified: trunk/validators/jboss/common/pom.xml
===================================================================
--- trunk/validators/jboss/common/pom.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/common/pom.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -58,6 +58,13 @@
<artifactId>emf-ecore-xmi</artifactId>
<version>2.3.1</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <version>${jboss.version}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jbm-queue-service.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+ <mbean code="org.jboss.jms.server.destination.TopicService"
+ name="jboss.messaging.destination:service=Topic,name=tracker"
+ xmbean-dd="xmdesc/Topic-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-beans.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean class="org.jboss.savara.validator.service.ServiceValidatorService"
+ name="ServiceValidator">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.savara:service=ServiceValidatorManager", exposedInterface=org.jboss.savara.validator.service.ServiceValidatorServiceMBean.class,registerDirectly=true)</annotation>
+ <property name="jndiName"><value>savara/ServiceValidatorManager</value></property>
+ <depends>jboss:service=Naming</depends>
+ </bean>
+
+</deployment>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-scanning.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,3 @@
+<scanning xmlns="urn:jboss:scanning:1.0">
+ <!-- prevent scanning for annotations -->
+</scanning>
Added: trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/META-INF/jboss-structure.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+ <context>
+ <path name=""/>
+ <metaDataPath>
+ <path name="META-INF"/>
+ </metaDataPath>
+ <classpath>
+ <path name=""/>
+ <path name="" suffixes=".jar" />
+ <path name="lib" suffixes=".jar" />
+ </classpath>
+ </context>
+</structure>
Added: trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm
===================================================================
--- trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/models/TrailBlazer.cdm 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,109 @@
+<?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 TrailBlazer" name="TrailBlazer" author="gary" version="0.1" targetNamespace="http://www.pi4soa.org/TrailBlazer">
+ <typeDefinitions>
+ <nameSpaces description="Target Namespace for TrailBlazer" prefix="tns" uRI="http://www.pi4soa.org/TrailBlazer"/>
+ <nameSpaces description="XML Schema Namespace" prefix="xsd" uRI="http://www.w3.org/2001/XMLSchema"/>
+ <informationTypes description="This is the information type CreditCheckReq" name="CreditCheckReq" elementName="creditCheck"/>
+ <informationTypes description="This is the information type CreditCheckResp" name="CreditCheckResp" elementName="creditCheckResult"/>
+ <informationTypes description="This is the information type InsufficientCredit" name="InsufficientCredit" elementName="insufficientCredit"/>
+ <informationTypes description="This is the information type Quote" name="Quote" elementName="quote"/>
+ <informationTypes description="This is the information type QuoteRefType" name="QuoteRefType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type QuoteReq" name="QuoteReq" elementName="quoteRequest"/>
+ <informationTypes description="This is the information type SSNType" name="SSNType" typeName="xsd:string"/>
+ <informationTypes description="This is the information type URIType" name="URIType" typeName="xsd:anyURI"/>
+ <tokens description="This is the token QuoteRef" name="QuoteRef" informationType="//@typeDefinitions/(a)informationTypes.4"/>
+ <tokens description="This is the token SSN" name="SSN" informationType="//@typeDefinitions/(a)informationTypes.6"/>
+ <tokens description="This is the token URI" name="URI" informationType="//@typeDefinitions/(a)informationTypes.7"/>
+ <tokenLocators description="This is the token locator QuoteRef4InsufficientCredit" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.2" query="//ref/text()" name="QuoteRef4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator QuoteRef4Quote" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.3" query="//ref/text()" name="QuoteRef4Quote"/>
+ <tokenLocators description="This is the token locator QuoteRef4QuoteReq" token="//@typeDefinitions/(a)tokens.0" informationType="//@typeDefinitions/(a)informationTypes.5" query="//@ref" name="QuoteRef4QuoteReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckReq" token="//@typeDefinitions/(a)tokens.1" informationType="//@typeDefinitions/(a)informationTypes.0" query="//@ssn" name="SSN4CreditCheckReq"/>
+ <tokenLocators description="This is the token locator SSN4CreditCheckResp" token="//@typeDefinitions/(a)tokens.1" informationType="//@typeDefinitions/(a)informationTypes.1" query="//@ssn" name="SSN4CreditCheckResp"/>
+ <tokenLocators description="This is the token locator SSN4InsufficientCredit" token="//@typeDefinitions/(a)tokens.1" informationType="//@typeDefinitions/(a)informationTypes.2" query="//customerUID/text()" name="SSN4InsufficientCredit"/>
+ <tokenLocators description="This is the token locator SSN4Quote" token="//@typeDefinitions/(a)tokens.1" informationType="//@typeDefinitions/(a)informationTypes.3" query="//customerUID/text()" name="SSN4Quote"/>
+ <tokenLocators description="This is the token locator SSN4QuoteReq" token="//@typeDefinitions/(a)tokens.1" informationType="//@typeDefinitions/(a)informationTypes.5" query="//@ssn" name="SSN4QuoteReq"/>
+ <roleTypes description="This is the role type Bank" name="Bank">
+ <behaviors description="This is the behavior BankBehavior" name="BankBehavior" interface="bank"/>
+ </roleTypes>
+ <roleTypes description="This is the role type CreditAgency" name="CreditAgency">
+ <behaviors description="This is the behavior CreditAgencyBehavior" name="CreditAgencyBehavior" interface="creditAgency"/>
+ </roleTypes>
+ <roleTypes description="This is the role type LoanBroker" name="LoanBroker">
+ <behaviors description="This is the behavior LoanBrokerBehavior" name="LoanBrokerBehavior" interface="loanBroker"/>
+ </roleTypes>
+ <roleTypes description="This is the role type Notifier" name="Notifier">
+ <behaviors description="This is the behavior NotifierBehavior" name="NotifierBehavior" interface="notifier"/>
+ </roleTypes>
+ <relationshipTypes description="Relationship between LoanBroker and Bank" name="LoanBrokerToBankRel" firstRoleType="//@typeDefinitions/(a)roleTypes.2" secondRoleType="//@typeDefinitions/(a)roleTypes.0"/>
+ <relationshipTypes description="Relationship between LoanBroker and CreditAgency" name="LoanBrokerToCreditAgencyRel" firstRoleType="//@typeDefinitions/(a)roleTypes.2" secondRoleType="//@typeDefinitions/(a)roleTypes.1"/>
+ <relationshipTypes description="Relationship between LoanBroker and Notifier" name="LoanBrokerToNotifierRel" firstRoleType="//@typeDefinitions/(a)roleTypes.2" secondRoleType="//@typeDefinitions/(a)roleTypes.3"/>
+ <participantTypes description="This is the participant type BankParticipant" name="BankParticipant" roleTypes="//@typeDefinitions/(a)roleTypes.0"/>
+ <participantTypes description="This is the participant type CreditAgencyParticipant" name="CreditAgencyParticipant" roleTypes="//@typeDefinitions/(a)roleTypes.1"/>
+ <participantTypes description="This is the participant type LoanBrokerParticipant" name="LoanBrokerParticipant" roleTypes="//@typeDefinitions/(a)roleTypes.2"/>
+ <participantTypes description="This is the participant type NotifierParticipant" name="NotifierParticipant" roleTypes="//@typeDefinitions/(a)roleTypes.3"/>
+ <channelTypes description="This is the channel type BankChannelType" name="BankChannelType" referenceToken="//@typeDefinitions/(a)tokens.2" roleType="//@typeDefinitions/(a)roleTypes.0">
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/(a)tokens.1 //@typeDefinitions/(a)tokens.0"/>
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/(a)tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type CreditAgencyChannelType" name="CreditAgencyChannelType" referenceToken="//@typeDefinitions/(a)tokens.2" roleType="//@typeDefinitions/(a)roleTypes.1">
+ <identities description="SSN Id" tokens="//@typeDefinitions/(a)tokens.1"/>
+ </channelTypes>
+ <channelTypes description="This is the channel type NotifierChannelType" name="NotifierChannelType" referenceToken="//@typeDefinitions/(a)tokens.2" roleType="//@typeDefinitions/(a)roleTypes.3">
+ <identities description="SSN Id" type="Association" tokens="//@typeDefinitions/(a)tokens.1"/>
+ <identities description="SSN Id and Quote Ref" tokens="//@typeDefinitions/(a)tokens.1 //@typeDefinitions/(a)tokens.0"/>
+ </channelTypes>
+ </typeDefinitions>
+ <choreographies description="Choreography flow for the TrailBlazer process" name="TrailBlazerProcess" root="true">
+ <enclosedChoreographies name="RequestQuote">
+ <variableDefinitions description="Channel to facilitate interaction to Bank" name="BankChannel" type="//@typeDefinitions/(a)channelTypes.0" roleTypes="//@typeDefinitions/(a)roleTypes.0 //@typeDefinitions/(a)roleTypes.2"/>
+ <variableDefinitions description="Channel to facilitate interaction to Notifier" name="NotifierChannel" type="//@typeDefinitions/(a)channelTypes.2" roleTypes="//@typeDefinitions/(a)roleTypes.2 //@typeDefinitions/(a)roleTypes.3"/>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="QuoteRequest" operation="requestQuote" channelVariable="//@choreographies.0/@enclosedChoreographies.0/(a)variableDefinitions.0" relationship="//@typeDefinitions/(a)relationshipTypes.0">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction QuoteRequest" name="QuoteRequestRequestExchange" type="//@typeDefinitions/(a)informationTypes.5">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankRequestQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ <exchangeDetails description="This is the exchange details for the respond exchange associated with interaction QuoteRequest" name="QuoteRequestRespondExchange" type="//@typeDefinitions/(a)informationTypes.3" action="Respond">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-jmsBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-fileBankResponseQueue}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/@enclosedChoreographies.0/(a)variableDefinitions.1" relationship="//@typeDefinitions/(a)relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/(a)informationTypes.3">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </enclosedChoreographies>
+ <variableDefinitions description="Channel to facilitate interaction to CreditAgency" name="CreditAgencyChannel" type="//@typeDefinitions/(a)channelTypes.1" roleTypes="//@typeDefinitions/(a)roleTypes.1 //@typeDefinitions/(a)roleTypes.2"/>
+ <variableDefinitions description="This is the variable NotifierChannel" name="NotifierChannel" type="//@typeDefinitions/(a)channelTypes.2" roleTypes="//@typeDefinitions/(a)roleTypes.2 //@typeDefinitions/(a)roleTypes.3"/>
+ <variableDefinitions description="This is the variable creditCheckResult" name="creditCheckResult" type="//@typeDefinitions/(a)informationTypes.1" roleTypes="//@typeDefinitions/(a)roleTypes.2"/>
+ <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.0">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue}}"
		dynamicReplyTo="{{Dynamic 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 respond exchange associated with interaction CreditCheck" name="CreditCheckRespondExchange" type="//@typeDefinitions/(a)informationTypes.1" action="Respond" receiveVariable="//@choreographies.0/(a)variableDefinitions.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-creditAgencyQueue_reply}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Choice">
+ <activities xsi:type="org.pi4soa.cdl:Conditional" description="Sufficient credit to request quotes" name="ValidCredit" expression="cdl:getVariable('creditCheckResult','','//@score') >= 4">
+ <activities xsi:type="org.pi4soa.cdl:Parallel">
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="First quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/(a)enclosedChoreographies.0"/>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Second quote">
+ <activities xsi:type="org.pi4soa.cdl:Perform" choreography="//@choreographies.0/(a)enclosedChoreographies.0"/>
+ </activities>
+ </activities>
+ </activities>
+ <activities xsi:type="org.pi4soa.cdl:Sequence" description="Insufficient credit">
+ <activities xsi:type="org.pi4soa.cdl:Interaction" name="NotifyCustomer" operation="notify" channelVariable="//@choreographies.0/(a)variableDefinitions.1" relationship="//@typeDefinitions/(a)relationshipTypes.2">
+ <exchangeDetails description="This is the exchange details for the request exchange associated with interaction NotifyCustomer" name="NotifyCustomerRequestExchange" type="//@typeDefinitions/(a)informationTypes.2">
+ <semanticAnnotations annotation="<validator>
	<destination name="{{Destination;The URI for the ESB destination;string;;jms:queue/esb-tb-customerNotifier}}"
		dynamicReplyTo="{{Dynamic ReplyTo;Whether the replyTo destination is dynamic;boolean;;false}}" />
</validator>
" name="validator"/>
+ </exchangeDetails>
+ </activities>
+ </activities>
+ </activities>
+ </choreographies>
+</org.pi4soa.cdl:Package>
Added: trunk/validators/jboss/common/src/main/configs/pi4soa.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/pi4soa.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/pi4soa.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,38 @@
+<!--
+/*
+# * Copyright 2005-8 Pi4 Technologies Ltd
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# *
+# *
+# * Change History:
+# * 16, June 2008: Initial version created by gary
+# */
+-->
+
+<pi4soa>
+ <container>
+ <serviceTracker class="org.pi4soa.service.tracker.jms.JMSServiceTracker" >
+ <jmsConnectionFactory>ConnectionFactory</jmsConnectionFactory>
+ <jmsDestination>topic/tracker</jmsDestination>
+ <recordMessagePayload>true</recordMessagePayload>
+ </serviceTracker>
+ </container>
+ <monitor>
+ <serviceTracker class="org.pi4soa.service.tracker.jms.JMSServiceTracker" >
+ <jmsConnectionFactory>ConnectionFactory</jmsConnectionFactory>
+ <jmsDestination>topic/tracker</jmsDestination>
+ <recordMessagePayload>true</recordMessagePayload>
+ </serviceTracker>
+ </monitor>
+</pi4soa>
\ No newline at end of file
Added: trunk/validators/jboss/common/src/main/configs/validator-config.xml
===================================================================
--- trunk/validators/jboss/common/src/main/configs/validator-config.xml (rev 0)
+++ trunk/validators/jboss/common/src/main/configs/validator-config.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,2 @@
+<validator mode="monitor" replyToTimeout="10000" >
+</validator>
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/AbstractServiceValidator.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/AbstractServiceValidator.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/AbstractServiceValidator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/AbstractServiceValidator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+/**
+ * Abstract base class representing the ServiceValidator.
+ */
+public abstract class AbstractServiceValidator implements ServiceValidator {
+
+ private static final String MODELS_PATH = "models/";
+
+ /**
+ * This is the constructor for the abstract
+ * service validator, initialised with the validator
+ * name.
+ *
+ * @param name The validator name
+ */
+ public AbstractServiceValidator(ValidatorName name) {
+ m_name = name;
+ }
+
+ /**
+ * This method returns the validator name.
+ *
+ * @return The validator name
+ */
+ public ValidatorName getValidatorName() {
+ return(m_name);
+ }
+
+ /**
+ * This method returns the input stream associated
+ * with the model. Once the input stream has been
+ * used, it is the caller's responsibility to close
+ * the stream.
+ *
+ * @return The model's input stream, or null if
+ * not found
+ */
+ protected java.io.InputStream getModel() {
+ String filePath=MODELS_PATH+getValidatorName().getModelName();
+
+ java.io.InputStream ret = AbstractServiceValidator.class.
+ getClassLoader().getResourceAsStream(filePath);
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("ServiceValidator["+getValidatorName()+"]");
+ }
+
+ private ValidatorName m_name=null;
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/DefaultValidatorConfig.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/DefaultValidatorConfig.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/DefaultValidatorConfig.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/DefaultValidatorConfig.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+/**
+ * This class represents a default configuration that will be used for
+ * validation against a stream of ESB based messages.
+ */
+public class DefaultValidatorConfig implements ValidatorConfig {
+
+ /**
+ * This is the constructor for the default validator model.
+ *
+ * @param modeType The model type
+ * @param config The configuration
+ */
+ public DefaultValidatorConfig(String modelType, org.w3c.dom.Element config) {
+ m_modelType = modelType;
+ m_configuration = config;
+ }
+
+ /**
+ * This method returns the type of the model associated
+ * with this validator configuration. This will
+ * general be based on the file extension of the model
+ * file.
+ *
+ * @return The model type
+ */
+ public String getModelType() {
+ return(m_modelType);
+ }
+
+ /**
+ * This method returns the validator configuration
+ * associated with the model.
+ *
+ * @return The validator model
+ */
+ public org.w3c.dom.Element getConfiguration() {
+ return(m_configuration);
+ }
+
+ private String m_modelType=null;
+ private org.w3c.dom.Element m_configuration=null;
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/Endpoint.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/Endpoint.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/Endpoint.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/Endpoint.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,87 @@
+/*
+ * 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;
+
+/**
+ * This class represents an endpoint being monitored by one
+ * or more service validator.
+ */
+public class Endpoint {
+
+ /**
+ * This is the constructor for the endpoint, supplying
+ * the destination associated with the endpoint.
+ *
+ * @param destination The destination
+ */
+ public Endpoint(String destination) {
+ m_destination = destination;
+ }
+
+ /**
+ * This method returns the destination for the endpoint.
+ *
+ * @return The destination
+ */
+ public String getDestination() {
+ return(m_destination);
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with this endpoint.
+ *
+ * @return The list of service validators for this endpoint
+ */
+ public java.util.List<ServiceValidator> getServiceValidators() {
+ return(m_validators);
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof Endpoint) {
+ Endpoint ep=(Endpoint)obj;
+
+ if (ep.getDestination() != null &&
+ ep.getDestination().equals(m_destination)) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public int hashCode() {
+ int ret=0;
+
+ if (m_destination != null) {
+ ret = m_destination.hashCode();
+ }
+
+ return(ret);
+ }
+
+ public String toString() {
+ return("Endpoint["+m_destination+"]");
+ }
+
+ private String m_destination=null;
+ private java.util.List<ServiceValidator> m_validators=
+ new java.util.Vector<ServiceValidator>();
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidator.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+/**
+ * This interface represents a service validator responsible for
+ * validing a stream of ESB messages against a model.
+ */
+public interface ServiceValidator {
+
+ /**
+ * This method returns the validator name.
+ *
+ * @return The validator name
+ */
+ public ValidatorName getValidatorName();
+
+ /**
+ * This method processes a sent message against a service
+ * behavioural description.
+ *
+ * @param msg The message
+ * @throws Exception Failed to process sent message
+ */
+ public void messageSent(java.io.Serializable msg) throws Exception;
+
+ /**
+ * This method processes a received message against a service
+ * behavioural description.
+ *
+ * @param msg The message
+ * @throws Exception Failed to process received message
+ */
+ public void messageReceived(java.io.Serializable msg) throws Exception;
+
+ /**
+ * This method is called to update the model associated
+ * with the service validator.
+ *
+ * @throws Exception Failed to update the service validator
+ */
+ public void update() throws Exception;
+
+ /**
+ * This method closes the service validator.
+ *
+ * @throws Exception Failed to close the service validator
+ */
+ public void close() throws Exception;
+
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorFactory.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorFactory.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorFactory.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorFactory.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import java.lang.reflect.Constructor;
+import org.apache.log4j.Logger;
+
+/**
+ * This class provides a factory for Service Validators.
+ */
+public class ServiceValidatorFactory {
+
+ /**
+ * This method returns the Service Validator appropriate
+ * for the supplied validator name.
+ *
+ * @param name The validator name
+ * @return The service validator
+ * @exception IOException Failed to create the service validator
+ */
+ public static ServiceValidator getServiceValidator(ValidatorName name)
+ throws Exception {
+ ServiceValidator ret=null;
+
+ String modelType=name.getModelType();
+
+ if (modelType != null &&
+ m_validatorClasses.containsKey(modelType)) {
+ Class<?> cls=m_validatorClasses.get(modelType);
+
+ Constructor<?> con=cls.getConstructor(
+ new Class[]{ValidatorName.class});
+
+ ret = (ServiceValidator)con.newInstance(new Object[]{name});
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning service validator for "+
+ name+": "+ret);
+ }
+
+ return(ret);
+ }
+
+ private static final Logger logger = Logger.getLogger(ServiceValidatorFactory.class);
+
+ private static java.util.Map<String,Class<?>> m_validatorClasses=
+ new java.util.HashMap<String,Class<?>>();
+
+ static {
+ m_validatorClasses.put(org.jboss.savara.validator.pi4soa.Pi4SOAServiceRecorder.getModelType(),
+ org.jboss.savara.validator.pi4soa.Pi4SOAServiceRecorder.class);
+ m_validatorClasses.put(org.jboss.savara.validator.pi4soa.Pi4SOAServiceValidator.getModelType(),
+ org.jboss.savara.validator.pi4soa.Pi4SOAServiceValidator.class);
+ }
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorManager.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorManager.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorManager.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ServiceValidatorManager.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,972 @@
+/*
+ * 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;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+
+/**
+ * This class is responsible for managing the active
+ * service validators, the mapping of endpoints to the service
+ * validators and updating the configuration when changes
+ * are detected.
+ */
+public class ServiceValidatorManager {
+
+ /**
+ * Default constructor for the service validator manager.
+ */
+ public ServiceValidatorManager() {
+ initialize();
+ }
+
+ /**
+ * This method initializes the service validator manager on
+ * startup.
+ */
+ protected void initialize() {
+
+ java.net.URL url=
+ ServiceValidatorManager.class.getClassLoader().getResource(CONFIG_FILE);
+
+ if (url != null) {
+ m_validatorConfigFile = new java.io.File(url.getFile());
+
+ java.io.File[] files=m_validatorConfigFile.getParentFile().listFiles();
+
+ for (int i=0; m_modelsDir == null && i < files.length; i++) {
+ if (files[i].getName().equals("models") &&
+ files[i].isDirectory()) {
+ m_modelsDir = files[i];
+ }
+ }
+
+ if (m_modelsDir != null) {
+ ValidatorConfigChangeMonitor mon=
+ new ValidatorConfigChangeMonitor();
+
+ new Thread(mon).start();
+ }
+ }
+ }
+
+ /**
+ * This method closes the service validation manager.
+ */
+ public void close() {
+ }
+
+ /**
+ * This method returns the list of service validators associated
+ * with the supplied input endpoint.
+ *
+ * @param endpoint The input endpoint
+ * @return The list of service validators, or null if the endpoint
+ * is unknown
+ */
+ public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=
+ m_inputValidators.get(endpoint);
+
+ if (ret == null) {
+ ret = m_replyToManager.getInputServiceValidators(endpoint);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return input validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied endpoint will be
+ * associated with a dynamic reply-to endpoint.
+ *
+ * @param endpoint The endpoint
+ * @return Whether the endpoint has a dynamic reply-to
+ */
+ public boolean isInputDynamicReplyTo(Endpoint endpoint) {
+ boolean ret=m_inputDynaReplyTos.contains(endpoint);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Is input endpoint '"+endpoint+
+ "' a dynamic reply-to: "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of service validators associated
+ * with the supplied output endpoint.
+ *
+ * @param endpoint The output endpoint
+ * @return The list of service validators, or null if the endpoint
+ * is unknown
+ */
+ public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=
+ m_outputValidators.get(endpoint);
+
+ if (ret == null) {
+ ret = m_replyToManager.getOutputServiceValidators(endpoint);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return output validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied endpoint will be
+ * associated with a dynamic reply-to endpoint.
+ *
+ * @param endpoint The endpoint
+ * @return Whether the endpoint has a dynamic reply-to
+ */
+ public boolean isOutputDynamicReplyTo(Endpoint endpoint) {
+ boolean ret=m_outputDynaReplyTos.contains(endpoint);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Is output endpoint '"+endpoint+
+ "' a dynamic reply-to: "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerInputReplyToValidators(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Register input reply-to '"+endpoint+"': "+validators);
+ }
+
+ m_replyToManager.registerInputDynamicReplyTo(endpoint, validators);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerOutputReplyToValidators(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Register output reply-to '"+endpoint+"': "+validators);
+ }
+
+ m_replyToManager.registerOutputDynamicReplyTo(endpoint, validators);
+ }
+
+ /**
+ * This method returns a ServiceValidator associated with the
+ * supplied validator name.
+ *
+ * @param name The validator name
+ * @return The service validator
+ * @throws Exception Failed to create service validator
+ */
+ public ServiceValidator createServiceValidator(ValidatorName name)
+ throws Exception {
+ ServiceValidator ret=null;
+
+ synchronized(m_serviceValidators) {
+ ret = m_serviceValidators.get(name);
+
+ // If does not exist, then create, else update
+ // the existing service validator
+ if (ret == null) {
+ ret = ServiceValidatorFactory.getServiceValidator(name);
+
+ m_serviceValidators.put(name, ret);
+ } else {
+
+ // Update the description
+ ret.update();
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Created Service Validator '"+name+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the service validator associated with
+ * the supplied validator name.
+ *
+ * @param name The validator name
+ * @throws Exception Failed to remove the service validator
+ */
+ protected void removeServiceValidator(ValidatorName name)
+ throws Exception {
+ synchronized(m_serviceValidators) {
+ ServiceValidator validator=(ServiceValidator)
+ m_serviceValidators.remove(name);
+
+ // Check if validator should be removed from
+ // input/output endpoint mappings
+ java.util.Iterator<Endpoint> iter=m_inputValidators.keySet().iterator();
+
+ while (iter.hasNext()) {
+ Endpoint ep=iter.next();
+ java.util.List<ServiceValidator> list=
+ m_inputValidators.get(ep);
+
+ if (list.contains(validator)) {
+ list.remove(validator);
+
+ if (list.size() == 0) {
+ logger.error("Input validator list, associated with endpoint '"+
+ ep+"' contains no entries after removal of validator '"+
+ name+"' - this Endpoint should have previously been removed");
+ }
+ }
+ }
+
+ iter=m_outputValidators.keySet().iterator();
+
+ while (iter.hasNext()) {
+ Endpoint ep=iter.next();
+ java.util.List<ServiceValidator> list=
+ m_outputValidators.get(ep);
+
+ if (list.contains(validator)) {
+ list.remove(validator);
+
+ if (list.size() == 0) {
+ logger.error("Output validator list, associated with endpoint '"+
+ ep+"' contains no entries after removal of validator '"+
+ name+"' - this Endpoint should have previously been removed");
+ }
+ }
+ }
+
+ if (validator != null) {
+ validator.close();
+ }
+ }
+ }
+
+ /**
+ * This method returns the set of currently configured
+ * service validator names.
+ *
+ * @return The set of validator names
+ */
+ protected java.util.Set<ValidatorName> getServiceValidatorNames() {
+ java.util.Set<ValidatorName> ret=new java.util.HashSet<ValidatorName>();
+
+ ret.addAll(m_serviceValidators.keySet());
+
+ return(ret);
+ }
+
+ /**
+ * This method updates the configuration of the service
+ * validators and endpoint mappings.
+ */
+ protected void updateConfigurations() {
+ java.util.Set<ValidatorName> existingValidatorNames=
+ getServiceValidatorNames();
+
+ java.util.Set<Endpoint> existingInputEndpoints=
+ new java.util.HashSet<Endpoint>(m_inputValidators.keySet());
+
+ java.util.Set<Endpoint> existingOutputEndpoints=
+ new java.util.HashSet<Endpoint>(m_outputValidators.keySet());
+
+ java.util.Set<Endpoint> existingInputDynaReplyTos=
+ new java.util.HashSet<Endpoint>(m_inputDynaReplyTos);
+
+ java.util.Set<Endpoint> existingOutputDynaReplyTos=
+ new java.util.HashSet<Endpoint>(m_outputDynaReplyTos);
+
+ java.io.InputStream is=ServiceValidatorManager.class.getClassLoader().
+ getResourceAsStream(CONFIG_FILE);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("ValidationFilter: config="+CONFIG_FILE+" is="+is);
+ }
+
+ try {
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(is);
+
+ org.w3c.dom.Element config=doc.getDocumentElement();
+
+ if (config.getNodeName().equals(VALIDATOR_NODE)) {
+
+ // Old 'active' attribute is now 'mode'
+ String active=config.getAttribute(ACTIVE_ATTR);
+
+ if (active != null && active.equalsIgnoreCase("true")) {
+ m_managedMode = true;
+ }
+
+ String mode=config.getAttribute(MODE_ATTR);
+
+ if (mode != null) {
+ if (mode.equals("manage")) {
+ m_managedMode = true;
+ } else if (mode.equals("monitor")) {
+ m_managedMode = false; // will override active=true
+ } else {
+ logger.error("Unknown mode '"+mode+"' - setting to 'monitor'");
+ m_managedMode = false;
+ }
+ }
+
+ if (m_managedMode) {
+ logger.debug("Setting validators in 'manage' mode");
+ } else {
+ logger.debug("Setting validators in 'monitor' mode");
+ }
+
+ // Check for dynamic replyTo endpoint timeout
+ String timeoutValue=config.getAttribute(REPLY_TO_TIMEOUT_ATTR);
+
+ if (timeoutValue != null) {
+ try {
+ long tv=Long.parseLong(timeoutValue);
+
+ m_replyToManager.setReplyToTimeout(tv);
+ } catch(Exception e) {
+ logger.error("Unable to set 'reply to' timeout", e);
+ }
+ }
+ }
+
+ updateConfiguration(config, existingValidatorNames,
+ existingInputEndpoints, existingOutputEndpoints,
+ existingInputDynaReplyTos, existingOutputDynaReplyTos);
+
+ // Work through choreography files in the models directory
+ java.io.File[] files=m_modelsDir.listFiles();
+
+ for (int i=0; i < files.length; i++) {
+
+ // Check if a ValidatorModel exists for the
+ // file
+ try {
+ ValidatorConfig vm=
+ ValidatorConfigFactory.getValidatorConfig(files[i]);
+
+ if (vm != null) {
+ org.w3c.dom.Element vConfig=vm.getConfiguration();
+
+ if (vConfig != null) {
+ updateConfiguration(vConfig,
+ existingValidatorNames,
+ existingInputEndpoints,
+ existingOutputEndpoints,
+ existingInputDynaReplyTos,
+ existingOutputDynaReplyTos);
+ } else {
+ logger.error("Failed to obtain configuration for model '"+
+ files[i].getName()+"'");
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to update configuration for model '"+
+ files[i].getName()+"'", e);
+ }
+ }
+
+ // Any remaining input keys need to be removed
+ java.util.Iterator<Endpoint> iter=
+ existingInputEndpoints.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_inputValidators.remove(key);
+ }
+
+ iter = existingInputDynaReplyTos.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_inputDynaReplyTos.remove(key);
+ }
+
+ // Any remaining output keys need to be removed
+ iter = existingOutputEndpoints.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_outputValidators.remove(key);
+ }
+
+ iter = existingOutputDynaReplyTos.iterator();
+
+ while (iter.hasNext()) {
+ Endpoint key=iter.next();
+ m_outputDynaReplyTos.remove(key);
+ }
+
+ // Any remaining service description names need to
+ // have their associated monitors removed
+ java.util.Iterator<ValidatorName> sviter=
+ existingValidatorNames.iterator();
+
+ while (sviter.hasNext()) {
+ ValidatorName svkey=sviter.next();
+
+ try {
+ logger.debug("Removing service validator: "+svkey);
+ removeServiceValidator(svkey);
+ } catch(Exception e) {
+ logger.error(
+ "Failed to remove service validator: "+svkey, e);
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to update configuration from input stream", e);
+ }
+ }
+
+ /**
+ * This method performs the update of the configuration of
+ * service monitors, based on the information in the validator
+ * configuration XML file, and the choreographies defined in the
+ * models folder.
+ *
+ * @param config The configuration
+ * @param existingValidatorNames The list of validator names
+ * @param existingInputEndpoints The list of input endpoints
+ * @param existingOutputEndpoints The list of output endpoints
+ * @param existingInputDynaReplyTos The set of input dynamic replyTo endpoints
+ * @param existingOutputDynaReplyTos The set of output dynamic replyTo endpoints
+ */
+ protected void updateConfiguration(org.w3c.dom.Element config,
+ java.util.Set<ValidatorName> existingValidatorNames,
+ java.util.Set<Endpoint> existingInputEndpoints,
+ java.util.Set<Endpoint> existingOutputEndpoints,
+ java.util.Set<Endpoint> existingInputDynaReplyTos,
+ java.util.Set<Endpoint> existingOutputDynaReplyTos) {
+ logger.debug("Update Service Validator Configuration");
+
+ if (config != null) {
+ try {
+ if (config.getNodeName().equals(VALIDATOR_NODE)) {
+ String active=config.getAttribute(ACTIVE_ATTR);
+
+ if (active != null && active.equalsIgnoreCase("true")) {
+
+ logger.debug("Setting validator into active mode");
+ m_managedMode = true;
+ }
+ }
+
+ org.w3c.dom.NodeList services=config.getElementsByTagName(SERVICE_NODE);
+
+ if (logger.isDebugEnabled()) {
+ if (services != null) {
+ logger.debug("ServiceValidationManager: services="+services.getLength());
+ } else {
+ logger.debug("ServiceValidationManager: services null");
+ }
+ }
+
+ for (int i=0; i < services.getLength(); i++) {
+ ServiceValidator sm=null;
+
+ // Create service monitor for service
+ String modelName=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(MODEL_ATTR);
+ String role=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(ROLE_ATTR);
+ String validate=
+ ((org.w3c.dom.Element)services.item(i)).getAttribute(VALIDATE_ATTR);
+
+ // Check for old attribute names, for
+ // backward compatibility - only support
+ // for a limited time
+ if (role == null) {
+ role = ((org.w3c.dom.Element)services.item(i)).getAttribute("participantType");
+ }
+
+ if (modelName == null) {
+ modelName = ((org.w3c.dom.Element)services.item(i)).getAttribute("cdmFilePath");
+
+ if (modelName != null) {
+ // Remove path
+ int pos=modelName.lastIndexOf('/');
+ if (pos != -1) {
+ modelName = modelName.substring(pos+1);
+ }
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Initialize service validator for: model="+
+ modelName+" role="+role+" validate="+validate);
+ }
+
+ if (role != null) {
+ boolean f_validate=(validate != null && validate.equalsIgnoreCase("true"));
+
+ if (modelName != null ||
+ f_validate == false) {
+ ValidatorName name=null;
+
+ if (f_validate) {
+ name = new ValidatorName(modelName, role);
+ } else {
+ name = new ValidatorName(role);
+
+ }
+
+ try {
+ // Obtain the service container
+ sm = createServiceValidator(name);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Service validator for '"+modelName+
+ "' and role '"+role+"' = "+sm);
+ }
+
+ // Remove validator name from list
+ existingValidatorNames.remove(sm.getValidatorName());
+ } catch(Exception e) {
+ logger.error(
+ "Failed to create service validator '"+
+ name+"'", e);
+ }
+ } else {
+ logger.error("Model name must be specified in validation mode");
+ }
+ } else {
+ logger.error("Role must be specified");
+ }
+
+ if (sm != null) {
+ // Map inputs to service
+ org.w3c.dom.NodeList inputs=((org.w3c.dom.Element)services.item(i)).getElementsByTagName(INPUT_NODE);
+
+ for (int j=0; j < inputs.getLength(); j++) {
+ String epr=((org.w3c.dom.Element)inputs.item(j)).getAttribute(EPR_ATTR);
+
+ if (epr != null) {
+ Endpoint endpoint=new Endpoint(epr);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Storing input endpoint '"+
+ endpoint+"' against validator: "+sm);
+ }
+
+ // Check if existing list
+ java.util.List<ServiceValidator> svs=
+ m_inputValidators.get(endpoint);
+
+ if (svs == null) {
+ svs = new java.util.Vector<ServiceValidator>();
+ m_inputValidators.put(endpoint, svs);
+ }
+
+ if (svs.contains(sm) == false) {
+ svs.add(sm);
+ }
+
+ existingInputEndpoints.remove(endpoint);
+
+ // Check if dynamic replyTo
+ String dynamicReplyTo=((org.w3c.dom.Element)inputs.item(j)).
+ getAttribute(DYNAMIC_REPLY_TO_ATTR);
+
+ if (dynamicReplyTo != null && dynamicReplyTo.equalsIgnoreCase("true")) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Input endpoint '"+
+ endpoint+"' has dynamic replyTo destination");
+ }
+
+ m_inputDynaReplyTos.add(endpoint);
+
+ existingInputDynaReplyTos.remove(endpoint);
+ }
+ }
+ }
+
+ // Map outputs to service
+ org.w3c.dom.NodeList outputs=((org.w3c.dom.Element)services.item(i)).getElementsByTagName(OUTPUT_NODE);
+
+ for (int j=0; j < outputs.getLength(); j++) {
+ String epr=((org.w3c.dom.Element)outputs.item(j)).getAttribute(EPR_ATTR);
+
+ if (epr != null) {
+ Endpoint endpoint=new Endpoint(epr);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Storing output endpoint '"+
+ endpoint+"' against validator: "+sm);
+ }
+
+ // Check if existing list
+ java.util.List<ServiceValidator> svs=
+ m_outputValidators.get(endpoint);
+
+ if (svs == null) {
+ svs = new java.util.Vector<ServiceValidator>();
+ m_outputValidators.put(endpoint, svs);
+ }
+
+ if (svs.contains(sm) == false) {
+ svs.add(sm);
+ }
+
+ existingOutputEndpoints.remove(endpoint);
+
+ // Check if dynamic replyTo
+ String dynamicReplyTo=((org.w3c.dom.Element)outputs.item(j)).
+ getAttribute(DYNAMIC_REPLY_TO_ATTR);
+
+ if (dynamicReplyTo != null && dynamicReplyTo.equalsIgnoreCase("true")) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Output endpoint '"+
+ endpoint+"' has dynamic replyTo destination");
+ }
+
+ m_outputDynaReplyTos.add(endpoint);
+
+ existingOutputDynaReplyTos.remove(endpoint);
+ }
+ }
+ }
+ }
+ }
+ } catch(Exception e) {
+ logger.error("Failed to load validator config", e);
+ }
+ }
+ }
+
+ /**
+ * This method returns whether the service validator configuration
+ * is in 'manage' mode. If yes, then invalid messages will
+ * be blocked from being delivered to their destination.
+ *
+ * @return Whether the service validator is in 'manage' mode
+ */
+ public boolean isManagedMode() {
+ return(m_managedMode);
+ }
+
+ private static final Logger logger = Logger.getLogger(ServiceValidatorManager.class);
+
+ private static final String EPR_ATTR = "epr";
+ private static final String DYNAMIC_REPLY_TO_ATTR = "dynamicReplyTo";
+
+ private static final String OUTPUT_NODE = "output";
+ private static final String INPUT_NODE = "input";
+ private static final String SERVICE_NODE = "service";
+ private static final String ACTIVE_ATTR = "active";
+ private static final String MODE_ATTR = "mode";
+ private static final String REPLY_TO_TIMEOUT_ATTR = "replyToTimeout";
+ private static final String VALIDATOR_NODE = "validator";
+
+ private static final String CONFIG_FILE = "validator-config.xml";
+ private static final String MODEL_ATTR="model";
+ private static final String ROLE_ATTR="role";
+ private static final String VALIDATE_ATTR="validate";
+
+ private static ServiceValidatorManager m_instance=null;
+ private java.io.File m_validatorConfigFile=null;
+ private java.io.File m_modelsDir=null;
+ private java.util.Map<ValidatorName,ServiceValidator> m_serviceValidators=
+ new java.util.HashMap<ValidatorName,ServiceValidator>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Set<Endpoint> m_inputDynaReplyTos=new java.util.HashSet<Endpoint>();
+ private java.util.Set<Endpoint> m_outputDynaReplyTos=new java.util.HashSet<Endpoint>();
+ private boolean m_managedMode=false;
+ private DynamicReplyToEndpointManager m_replyToManager=new DynamicReplyToEndpointManager();
+
+ /**
+ * This class is responsible for monitoring the models folder,
+ * within the overlord validator ESB bundle, to determine when
+ * the configuration has changed.
+ */
+ public class ValidatorConfigChangeMonitor implements java.lang.Runnable {
+
+ public ValidatorConfigChangeMonitor() {
+ // Do initial check for updates, so monitors
+ // initialized before returning from construct,
+ // as remainder of checks will be in a separate
+ // thread - so we need to ensure that the monitors
+ // are configured before the first message is
+ // passed through the filter.
+ checkForUpdates();
+ }
+
+ public void run() {
+
+ while (true) {
+ checkForUpdates();
+
+ try {
+ synchronized(ValidatorConfigChangeMonitor.this) {
+ wait(30000);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected void checkForUpdates() {
+ logger.debug("Checking for config updates");
+
+ // Get last update time
+ long lastUpdate=getLastUpdate();
+
+ if (lastUpdate > m_lastUpdate) {
+
+ updateConfigurations();
+
+ m_lastUpdate = lastUpdate;
+ }
+ }
+
+ protected long getLastUpdate() {
+ long ret=0;
+
+ if (m_validatorConfigFile != null) {
+ ret = m_validatorConfigFile.lastModified();
+ }
+
+ if (m_modelsDir != null) {
+ java.io.File[] files=m_modelsDir.listFiles();
+
+ for (int i=0; i < files.length; i++) {
+ if (files[i].getName().endsWith(".cdm") &&
+ ret < files[i].lastModified()) {
+ ret = files[i].lastModified();
+ }
+ }
+
+ if (ret < m_modelsDir.lastModified()) {
+ ret = m_modelsDir.lastModified();
+ }
+ }
+
+ return(ret);
+ }
+
+ private long m_lastUpdate=0;
+ }
+
+ public class DynamicReplyToEndpointManager extends Thread {
+
+ /**
+ * The default constructor
+ */
+ public DynamicReplyToEndpointManager() {
+ setDaemon(true);
+
+ start();
+ }
+
+ /**
+ * The run method is responsible for ensuring the dynamic
+ * 'reply-to' endpoints are cleaned up periodically.
+ */
+ public void run() {
+
+ while(true) {
+
+ try {
+ synchronized(this) {
+ wait(m_replyToTimeout);
+ }
+ } catch(Exception e) {
+ logger.error("Failed to wait");
+ }
+
+ // Shift main entries to an emptied 'pending delete'
+ // map
+ synchronized(m_inputs) {
+ if (logger.isDebugEnabled()) {
+ java.util.Iterator<Endpoint> iter=
+ m_inputsPendingDelete.keySet().iterator();
+ while (iter.hasNext()) {
+ Endpoint endpoint=iter.next();
+ java.util.List<ServiceValidator> validators=
+ m_inputsPendingDelete.get(endpoint);
+ logger.debug("Deleting input (reply-to) validators '"+
+ endpoint+"': "+validators);
+ }
+ }
+
+ m_inputsPendingDelete.clear();
+ m_inputsPendingDelete.putAll(m_inputs);
+ m_inputs.clear();
+ }
+
+ synchronized(m_outputs) {
+ if (logger.isDebugEnabled()) {
+ java.util.Iterator<Endpoint> iter=
+ m_outputsPendingDelete.keySet().iterator();
+ while (iter.hasNext()) {
+ Endpoint endpoint=iter.next();
+ java.util.List<ServiceValidator> validators=
+ m_outputsPendingDelete.get(endpoint);
+ logger.debug("Deleting output (reply-to) validators '"+
+ endpoint+"': "+validators);
+ }
+ }
+
+ m_outputsPendingDelete.clear();
+ m_outputsPendingDelete.putAll(m_outputs);
+ m_outputs.clear();
+ }
+ }
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with the dynamic reply-to endpoint.
+ *
+ * @param endpoint The input endpoint
+ * @return The list of service validators, or null if
+ * not found
+ */
+ public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=null;
+
+ synchronized(m_inputs) {
+ ret = m_inputs.get(endpoint);
+
+ if (ret == null) {
+ ret = m_inputsPendingDelete.get(endpoint);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return input (reply-to) validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of service validators
+ * associated with the dynamic reply-to endpoint.
+ *
+ * @param endpoint The output endpoint
+ * @return The list of service validators, or null if
+ * not found
+ */
+ public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
+ java.util.List<ServiceValidator> ret=null;
+
+ synchronized(m_outputs) {
+ ret = m_outputs.get(endpoint);
+
+ if (ret == null) {
+ ret = m_outputsPendingDelete.get(endpoint);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Return output (reply-to) validators '"+endpoint+"': "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerInputDynamicReplyTo(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ synchronized(m_inputs) {
+ m_inputs.put(endpoint, validators);
+
+ // May not be necessary, as entry would not be
+ // used - but could save memory?
+ m_inputsPendingDelete.remove(endpoint);
+ }
+ }
+
+ /**
+ * This method registers a list of service validators against
+ * a dynamic 'reply-to' endpoint.
+ *
+ * @param endpoint The endpoint
+ * @param validators The list of service validators
+ */
+ public void registerOutputDynamicReplyTo(Endpoint endpoint,
+ java.util.List<ServiceValidator> validators) {
+
+ synchronized(m_outputs) {
+ m_outputs.put(endpoint, validators);
+
+ // May not be necessary, as entry would not be
+ // used - but could save memory?
+ m_outputsPendingDelete.remove(endpoint);
+ }
+ }
+
+ /**
+ * This method sets the timeout period for purging the
+ * cache of reply-to endpoints.
+ *
+ * @param timeoutValue The timeout value
+ */
+ public void setReplyToTimeout(long timeoutValue) {
+ m_replyToTimeout = timeoutValue;
+ }
+
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputs=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputs=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputsPendingDelete=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputsPendingDelete=
+ new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
+ private long m_replyToTimeout=10000;
+ }
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfig.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfig.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfig.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfig.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * This interface represents a configuration that will be used for
+ * validation against a stream of ESB based messages.
+ */
+public interface ValidatorConfig {
+
+ /**
+ * This method returns the type of the model associated
+ * with this validator configuration. This will
+ * general be based on the file extension of the model
+ * file.
+ *
+ * @return The model type
+ */
+ public String getModelType();
+
+ /**
+ * This method returns the validator configuration
+ * associated with the model.
+ *
+ * @return The validator model
+ */
+ public org.w3c.dom.Element getConfiguration();
+
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigFactory.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigFactory.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigFactory.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigFactory.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,97 @@
+/*
+ * 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;
+
+import org.apache.log4j.Logger;
+
+/**
+ * This class provides a factory for ValidatorConfig objects
+ * based on supplied model file details.
+ */
+public class ValidatorConfigFactory {
+
+ /**
+ * This method retrieves a validator config associated with
+ * the supplied file. If the model associated with the
+ * file is not supported, then a null will be returned.
+ *
+ * @param file The file containing the model
+ * @return The validator config, or null if an unsupported type
+ * @exception IOException Failed to load supported model type
+ */
+ public static ValidatorConfig getValidatorConfig(java.io.File file)
+ throws java.io.IOException {
+ ValidatorConfig ret=null;
+
+ String modelType=null;
+
+ if (file != null && (modelType=getModelType(file.getName())) != null) {
+ ValidatorConfigLoader loader=null;
+
+ for (int i=0; loader == null &&
+ i < m_loaders.size(); i++) {
+
+ if (m_loaders.get(i).isSupported(modelType)) {
+ loader = m_loaders.get(i);
+ }
+ }
+
+ if (loader != null) {
+ java.io.FileInputStream fis=new java.io.FileInputStream(file);
+
+ ret = loader.loadValidatorConfig(fis, file.getName());
+
+ fis.close();
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Returning validator config for "+
+ file.getName()+": "+ret);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines the model type associated with the
+ * supplied model filename.
+ *
+ * @param name The model filename
+ * @return The model type, or null if not known
+ */
+ protected static String getModelType(String name) {
+ String ret=null;
+ int pos=name.lastIndexOf('.');
+
+ if (pos != -1) {
+ ret = name.substring(pos+1);
+ }
+
+ return(ret);
+ }
+
+ private static final Logger logger = Logger.getLogger(ValidatorConfigFactory.class);
+
+ private static java.util.List<ValidatorConfigLoader> m_loaders=
+ new java.util.Vector<ValidatorConfigLoader>();
+
+ static {
+ m_loaders.add(new org.jboss.savara.validator.pi4soa.Pi4SOAValidatorConfigLoader());
+ }
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigLoader.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigLoader.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigLoader.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorConfigLoader.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * This interface is implemented by model specific loaders, to
+ * load a ValidatorConfig for the particular model type.
+ */
+public interface ValidatorConfigLoader {
+
+ /**
+ * This method determines if the validator config loader
+ * implementation supports the supplied model type.
+ *
+ * @param modelType The model type
+ * @return Whether the loader supports the model type
+ */
+ public boolean isSupported(String modelType);
+
+ /**
+ * This method loads the validator config, contained within
+ * the supplied input stream representing a model of the
+ * supported type.
+ *
+ * @param is The input stream
+ * @param modelPath The path to the model file
+ * @return The validator config
+ * @throws java.io.IOException Failed to load validator config
+ */
+ public ValidatorConfig loadValidatorConfig(java.io.InputStream is,
+ String modelPath) throws java.io.IOException;
+
+}
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorName.java (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorName.java)
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorName.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/ValidatorName.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,134 @@
+/*
+ * 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;
+
+/**
+ * This class represents a key for looking up a service validator.
+ */
+public class ValidatorName {
+
+ /**
+ * This constructor is initialized with the details used to
+ * identify the validator.
+ *
+ * @param role The role
+ */
+ public ValidatorName(String role) {
+ m_role = role;
+ m_validate = false;
+ }
+
+ /**
+ * This constructor is initialized with the details used to
+ * identify the validator.
+ *
+ * @param modelName The model name
+ * @param role The role
+ * @param validate Whether to validate, or simply record
+ */
+ public ValidatorName(String modelName, String role) {
+ m_modelName = modelName;
+ m_role = role;
+ m_validate = true;
+ }
+
+ /**
+ * This method returns the model name associated with the
+ * service validator.
+ *
+ * @return The model name
+ */
+ public String getModelName() {
+ return(m_modelName);
+ }
+
+ /**
+ * This method returns the type associated with the model.
+ * If no model has been defined for the validator name,
+ * as in the case of a validator in record mode, then
+ * this method will return ValidatorName.NO_MODEL_TYPE.
+ *
+ * @return The model type
+ */
+ public String getModelType() {
+ String ret=null;
+ int pos=0;
+
+ if (m_modelName != null &&
+ (pos=m_modelName.lastIndexOf('.')) != -1) {
+ ret = m_modelName.substring(pos+1);
+ } else {
+ ret = NO_MODEL_TYPE;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the role associated with the Service
+ * Validator.
+ *
+ * @return The role
+ */
+ public String getRole() {
+ return(m_role);
+ }
+
+ /**
+ * This method determines whether the associated service
+ * validator is in validation or record mode.
+ *
+ * @return Whether in validation or record mode
+ */
+ public boolean isValidate() {
+ return(m_validate);
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof ValidatorName) {
+ ret = (obj.toString().equals(toString()) &&
+ ((ValidatorName)obj).m_validate == m_validate);
+ }
+
+ return(ret);
+ }
+
+ public int hashCode() {
+ return(toString().hashCode());
+ }
+
+ public String toString() {
+ String ret=null;
+
+ if (isValidate()) {
+ ret = m_modelName+":"+m_role;
+ } else {
+ ret = m_role;
+ }
+
+ return(ret);
+ }
+
+ public static final String NO_MODEL_TYPE="NoModelType";
+
+ private String m_modelName=null;
+ private String m_role=null;
+ private boolean m_validate=false;
+}
\ No newline at end of file
Copied: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa (from rev 369, trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/pi4soa)
Modified: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/pi4soa/Pi4SOAServiceRecorder.java 2010-08-26 18:16:29 UTC (rev 369)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -15,12 +15,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.jboss.savara.validator.jbossesb.pi4soa;
+package org.jboss.savara.validator.pi4soa;
import org.apache.log4j.Logger;
-import org.jboss.savara.validator.jbossesb.*;
-import org.jboss.soa.esb.message.Message;
+import org.jboss.savara.validator.AbstractServiceValidator;
+import org.jboss.savara.validator.ValidatorName;
import org.pi4soa.common.util.MessageUtil;
import org.pi4soa.service.ServiceException;
import org.pi4soa.service.behavior.*;
@@ -97,18 +97,17 @@
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(Message msg) throws Exception {
- java.io.Serializable value=ESBUtil.getMessage(msg);
-
- if (value == null) {
+ public void messageSent(java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(value);
+ String mesgType=MessageUtil.getMessageType(msg);
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
- null, null, value, null, null);
+ null, null, msg, null, null);
synchronized(m_monitor) {
m_monitor.messageSent(mesg);
@@ -122,18 +121,17 @@
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(Message msg) throws Exception {
- java.io.Serializable value=ESBUtil.getMessage(msg);
-
- if (value == null) {
+ public void messageReceived(java.io.Serializable msg) throws Exception {
+
+ if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(value);
+ String mesgType=MessageUtil.getMessageType(msg);
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
- null, null, value, null, null);
+ null, null, msg, null, null);
synchronized(m_monitor) {
m_monitor.messageReceived(mesg);
Modified: 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/pi4soa/Pi4SOAServiceValidator.java 2010-08-26 18:16:29 UTC (rev 369)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -15,12 +15,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.jboss.savara.validator.jbossesb.pi4soa;
+package org.jboss.savara.validator.pi4soa;
import org.apache.log4j.Logger;
-import org.jboss.savara.validator.jbossesb.*;
-import org.jboss.soa.esb.message.Message;
+import org.jboss.savara.validator.AbstractServiceValidator;
+import org.jboss.savara.validator.ValidatorName;
import org.pi4soa.common.util.MessageUtil;
import org.pi4soa.service.ServiceException;
import org.pi4soa.service.behavior.*;
@@ -158,18 +158,17 @@
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(Message msg) throws Exception {
- java.io.Serializable value=ESBUtil.getMessage(msg);
+ public void messageSent(java.io.Serializable msg) throws Exception {
- if (value == null) {
+ if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(value);
+ String mesgType=MessageUtil.getMessageType(msg);
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
- null, null, value, null, null);
+ null, null, msg, null, null);
synchronized(m_monitor) {
m_monitor.messageSent(mesg);
@@ -183,18 +182,17 @@
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(Message msg) throws Exception {
- java.io.Serializable value=ESBUtil.getMessage(msg);
+ public void messageReceived(java.io.Serializable msg) throws Exception {
- if (value == null) {
+ if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
- String mesgType=MessageUtil.getMessageType(value);
+ String mesgType=MessageUtil.getMessageType(msg);
org.pi4soa.service.Message mesg=
m_monitor.createMessage(mesgType,
- null, null, value, null, null);
+ null, null, msg, null, null);
synchronized(m_monitor) {
m_monitor.messageReceived(mesg);
Modified: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/pi4soa/Pi4SOAValidatorConfigLoader.java 2010-08-26 18:16:29 UTC (rev 369)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/Pi4SOAValidatorConfigLoader.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -15,10 +15,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.jboss.savara.validator.jbossesb.pi4soa;
+package org.jboss.savara.validator.pi4soa;
-import org.jboss.savara.validator.jbossesb.*;
-import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.savara.validator.DefaultValidatorConfig;
+import org.jboss.savara.validator.ValidatorConfig;
+import org.jboss.savara.validator.ValidatorConfigLoader;
/**
* This class provides the pi4soa implementation of the
@@ -62,7 +63,7 @@
generator.generate(cdlpack, modelPath);
ret = new DefaultValidatorConfig(PI4SOA_MODEL_TYPE,
- ConfigTree.fromElement(validator));
+ validator);
return(ret);
}
Modified: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/pi4soa/ValidatorConfigGenerator.java 2010-08-26 18:16:29 UTC (rev 369)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/pi4soa/ValidatorConfigGenerator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -15,7 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.jboss.savara.validator.jbossesb.pi4soa;
+package org.jboss.savara.validator.pi4soa;
import java.util.Collections;
import org.apache.log4j.Logger;
Added: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorService.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorService.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorService.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.service;
+
+import java.util.logging.Logger;
+
+import org.jboss.savara.validator.ServiceValidator;
+import org.jboss.savara.validator.ServiceValidatorManager;
+import org.jboss.util.naming.NonSerializableFactory;
+
+import javax.naming.*;
+
+/**
+ * This is the JBoss Savara Service Validator Service managing the Service Validator.
+ *
+ * @author gbrown
+ *
+ */
+public class ServiceValidatorService extends org.jboss.system.ServiceMBeanSupport implements ServiceValidatorServiceMBean {
+
+ private final static Logger logger = Logger.getLogger(ServiceValidatorService.class.getName());
+
+ private String m_jndiName=null;
+ private ServiceValidatorManager m_serviceValidatorManager=null;
+
+ /**
+ * The default constructor.
+ */
+ public ServiceValidatorService() {
+ }
+
+ /**
+ * This method starts the service, instantiating the
+ * Service Validation Manager and registering it with JNDI.
+ */
+ protected void startService() throws Exception {
+ logger.info("Starting JBoss Savara Service Validator Manager");
+
+ m_serviceValidatorManager = new ServiceValidatorManager();
+
+ rebind();
+ }
+
+ /**
+ * This method stops the service, closing the
+ * Service Validation Manager and unregistering it from JNDI.
+ */
+ protected void stopService() throws Exception {
+ logger.info("Stopping JBoss Savara Service Validator Manager");
+
+ unbind(m_jndiName);
+
+ m_serviceValidatorManager.close();
+
+ m_serviceValidatorManager = null;
+ }
+
+ /**
+ * This method returns the JNDI name used to register the
+ * Service Validation Manager.
+ */
+ public String getJndiName() {
+ return m_jndiName;
+ }
+
+ /**
+ * This method sets the JNDI name associated with the
+ * BPEL engine.
+ *
+ * @param jndiName The JNDI name
+ * @throws NamingException Failed to register BPEL engine against
+ * the JNDI name
+ */
+ public void setJndiName(String jndiName) throws NamingException {
+ String oldName = m_jndiName;
+ m_jndiName = jndiName;
+
+ if (super.getState() == STARTED) {
+ unbind(oldName);
+ try {
+ rebind();
+ } catch(Exception e) {
+ NamingException ne = new NamingException("Failed to update jndiName");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ }
+
+ private void rebind() throws NamingException {
+ InitialContext rootCtx = new InitialContext();
+ Name fullName = rootCtx.getNameParser("").parse(m_jndiName);
+ logger.info("fullName="+fullName);
+ NonSerializableFactory.rebind(fullName, m_serviceValidatorManager, true);
+ }
+
+ private void unbind(String jndiName) {
+ try {
+ InitialContext rootCtx = new InitialContext();
+ rootCtx.unbind(jndiName);
+ NonSerializableFactory.unbind(jndiName);
+ } catch(NamingException e) {
+ logger.severe("Failed to unbind map: "+e);
+ }
+ }
+}
Added: trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorServiceMBean.java
===================================================================
--- trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorServiceMBean.java (rev 0)
+++ trunk/validators/jboss/common/src/main/java/org/jboss/savara/validator/service/ServiceValidatorServiceMBean.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.service;
+
+import javax.naming.NamingException;
+
+import org.jboss.system.ServiceMBean;
+
+/**
+ * The MBean for the Service Validator Service.
+ *
+ * @author gbrown
+ *
+ */
+public interface ServiceValidatorServiceMBean extends ServiceMBean {
+
+ /**
+ * This method returns the JNDI name used to register the
+ * Service Validator.
+ */
+ public String getJndiName();
+
+ /**
+ * This method sets the JNDI name associated with the
+ * Service Validator.
+ *
+ * @param jndiName The JNDI name
+ * @throws NamingException Failed to register Service Validator against
+ * the JNDI name
+ */
+ public void setJndiName(String jndiName) throws javax.naming.NamingException;
+
+}
Modified: trunk/validators/jboss/esb/pom.xml
===================================================================
--- trunk/validators/jboss/esb/pom.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/pom.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -16,6 +16,11 @@
<dependencies>
<dependency>
+ <groupId>org.jboss.savara.validators</groupId>
+ <artifactId>savara-validator-jboss</artifactId>
+ <version>${savara.version}</version>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
Modified: trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/deployment.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbossesb-deployment>
<depends>jboss.esb:deployment=jbossesb.esb</depends>
- <depends>jboss.messaging.destination:service=Topic,name=tracker</depends>
+ <depends>jboss.savara:service=ServiceValidatorManager</depends>
</jbossesb-deployment>
Deleted: trunk/validators/jboss/esb/src/main/configs/META-INF/jbm-queue-service.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/META-INF/jbm-queue-service.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/configs/META-INF/jbm-queue-service.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<server>
-
- <mbean code="org.jboss.jms.server.destination.TopicService"
- name="jboss.messaging.destination:service=Topic,name=tracker"
- xmbean-dd="xmdesc/Topic-xmbean.xml">
- <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
- <depends>jboss.messaging:service=PostOffice</depends>
- </mbean>
-
-</server>
Deleted: trunk/validators/jboss/esb/src/main/configs/pi4soa.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/pi4soa.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/configs/pi4soa.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,38 +0,0 @@
-<!--
-/*
-# * Copyright 2005-8 Pi4 Technologies Ltd
-# *
-# * Licensed under the Apache License, Version 2.0 (the "License");
-# * you may not use this file except in compliance with the License.
-# * You may obtain a copy of the License at
-# *
-# * http://www.apache.org/licenses/LICENSE-2.0
-# *
-# * Unless required by applicable law or agreed to in writing, software
-# * distributed under the License is distributed on an "AS IS" BASIS,
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# * See the License for the specific language governing permissions and
-# * limitations under the License.
-# *
-# *
-# * Change History:
-# * 16, June 2008: Initial version created by gary
-# */
--->
-
-<pi4soa>
- <container>
- <serviceTracker class="org.pi4soa.service.tracker.jms.JMSServiceTracker" >
- <jmsConnectionFactory>ConnectionFactory</jmsConnectionFactory>
- <jmsDestination>topic/tracker</jmsDestination>
- <recordMessagePayload>true</recordMessagePayload>
- </serviceTracker>
- </container>
- <monitor>
- <serviceTracker class="org.pi4soa.service.tracker.jms.JMSServiceTracker" >
- <jmsConnectionFactory>ConnectionFactory</jmsConnectionFactory>
- <jmsDestination>topic/tracker</jmsDestination>
- <recordMessagePayload>true</recordMessagePayload>
- </serviceTracker>
- </monitor>
-</pi4soa>
\ No newline at end of file
Deleted: trunk/validators/jboss/esb/src/main/configs/validator-config.xml
===================================================================
--- trunk/validators/jboss/esb/src/main/configs/validator-config.xml 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/configs/validator-config.xml 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,2 +0,0 @@
-<validator mode="monitor" replyToTimeout="10000" >
-</validator>
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/AbstractServiceValidator.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/AbstractServiceValidator.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/AbstractServiceValidator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,70 +0,0 @@
-/*
- * 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;
-
-/**
- * Abstract base class representing the ServiceValidator.
- */
-public abstract class AbstractServiceValidator implements ServiceValidator {
-
- private static final String MODELS_PATH = "models/";
-
- /**
- * This is the constructor for the abstract
- * service validator, initialised with the validator
- * name.
- *
- * @param name The validator name
- */
- public AbstractServiceValidator(ValidatorName name) {
- m_name = name;
- }
-
- /**
- * This method returns the validator name.
- *
- * @return The validator name
- */
- public ValidatorName getValidatorName() {
- return(m_name);
- }
-
- /**
- * This method returns the input stream associated
- * with the model. Once the input stream has been
- * used, it is the caller's responsibility to close
- * the stream.
- *
- * @return The model's input stream, or null if
- * not found
- */
- protected java.io.InputStream getModel() {
- String filePath=MODELS_PATH+getValidatorName().getModelName();
-
- java.io.InputStream ret = AbstractServiceValidator.class.
- getClassLoader().getResourceAsStream(filePath);
-
- return(ret);
- }
-
- public String toString() {
- return("ServiceValidator["+getValidatorName()+"]");
- }
-
- private ValidatorName m_name=null;
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/DefaultValidatorConfig.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/DefaultValidatorConfig.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/DefaultValidatorConfig.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,63 +0,0 @@
-/*
- * 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 org.jboss.soa.esb.helpers.*;
-
-/**
- * This class represents a default configuration that will be used for
- * validation against a stream of ESB based messages.
- */
-public class DefaultValidatorConfig implements ValidatorConfig {
-
- /**
- * This is the constructor for the default validator model.
- *
- * @param modeType The model type
- * @param config The configuration
- */
- public DefaultValidatorConfig(String modelType, ConfigTree config) {
- m_modelType = modelType;
- m_configuration = config;
- }
-
- /**
- * This method returns the type of the model associated
- * with this validator configuration. This will
- * general be based on the file extension of the model
- * file.
- *
- * @return The model type
- */
- public String getModelType() {
- return(m_modelType);
- }
-
- /**
- * This method returns the validator configuration
- * associated with the model.
- *
- * @return The validator model
- */
- public ConfigTree getConfiguration() {
- return(m_configuration);
- }
-
- private String m_modelType=null;
- private ConfigTree m_configuration=null;
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/Endpoint.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/Endpoint.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/Endpoint.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,87 +0,0 @@
-/*
- * 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;
-
-/**
- * This class represents an endpoint being monitored by one
- * or more service validator.
- */
-public class Endpoint {
-
- /**
- * This is the constructor for the endpoint, supplying
- * the destination associated with the endpoint.
- *
- * @param destination The destination
- */
- public Endpoint(String destination) {
- m_destination = destination;
- }
-
- /**
- * This method returns the destination for the endpoint.
- *
- * @return The destination
- */
- public String getDestination() {
- return(m_destination);
- }
-
- /**
- * This method returns the list of service validators
- * associated with this endpoint.
- *
- * @return The list of service validators for this endpoint
- */
- public java.util.List<ServiceValidator> getServiceValidators() {
- return(m_validators);
- }
-
- public boolean equals(Object obj) {
- boolean ret=false;
-
- if (obj instanceof Endpoint) {
- Endpoint ep=(Endpoint)obj;
-
- if (ep.getDestination() != null &&
- ep.getDestination().equals(m_destination)) {
- ret = true;
- }
- }
-
- return(ret);
- }
-
- public int hashCode() {
- int ret=0;
-
- if (m_destination != null) {
- ret = m_destination.hashCode();
- }
-
- return(ret);
- }
-
- public String toString() {
- return("Endpoint["+m_destination+"]");
- }
-
- private String m_destination=null;
- private java.util.List<ServiceValidator> m_validators=
- new java.util.Vector<ServiceValidator>();
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidator.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidator.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidator.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,68 +0,0 @@
-/*
- * 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 org.jboss.soa.esb.message.Message;
-
-/**
- * This interface represents a service validator responsible for
- * validing a stream of ESB messages against a model.
- */
-public interface ServiceValidator {
-
- /**
- * This method returns the validator name.
- *
- * @return The validator name
- */
- public ValidatorName getValidatorName();
-
- /**
- * This method processes a sent message against a service
- * behavioural description.
- *
- * @param msg The message
- * @throws Exception Failed to process sent message
- */
- public void messageSent(Message msg) throws Exception;
-
- /**
- * This method processes a received message against a service
- * behavioural description.
- *
- * @param msg The message
- * @throws Exception Failed to process received message
- */
- public void messageReceived(Message msg) throws Exception;
-
- /**
- * This method is called to update the model associated
- * with the service validator.
- *
- * @throws Exception Failed to update the service validator
- */
- public void update() throws Exception;
-
- /**
- * This method closes the service validator.
- *
- * @throws Exception Failed to close the service validator
- */
- public void close() throws Exception;
-
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorFactory.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorFactory.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorFactory.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,71 +0,0 @@
-/*
- * 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 java.lang.reflect.Constructor;
-import org.apache.log4j.Logger;
-
-/**
- * This class provides a factory for Service Validators.
- */
-public class ServiceValidatorFactory {
-
- /**
- * This method returns the Service Validator appropriate
- * for the supplied validator name.
- *
- * @param name The validator name
- * @return The service validator
- * @exception IOException Failed to create the service validator
- */
- public static ServiceValidator getServiceValidator(ValidatorName name)
- throws Exception {
- ServiceValidator ret=null;
-
- String modelType=name.getModelType();
-
- if (modelType != null &&
- m_validatorClasses.containsKey(modelType)) {
- Class<?> cls=m_validatorClasses.get(modelType);
-
- Constructor<?> con=cls.getConstructor(
- new Class[]{ValidatorName.class});
-
- ret = (ServiceValidator)con.newInstance(new Object[]{name});
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Returning service validator for "+
- name+": "+ret);
- }
-
- return(ret);
- }
-
- private static final Logger logger = Logger.getLogger(ServiceValidatorFactory.class);
-
- private static java.util.Map<String,Class<?>> m_validatorClasses=
- new java.util.HashMap<String,Class<?>>();
-
- static {
- m_validatorClasses.put(org.jboss.savara.validator.jbossesb.pi4soa.Pi4SOAServiceRecorder.getModelType(),
- org.jboss.savara.validator.jbossesb.pi4soa.Pi4SOAServiceRecorder.class);
- m_validatorClasses.put(org.jboss.savara.validator.jbossesb.pi4soa.Pi4SOAServiceValidator.getModelType(),
- org.jboss.savara.validator.jbossesb.pi4soa.Pi4SOAServiceValidator.class);
- }
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorManager.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorManager.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ServiceValidatorManager.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,966 +0,0 @@
-/*
- * 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 org.apache.log4j.Logger;
-
-import org.jboss.soa.esb.helpers.ConfigTree;
-
-/**
- * This class is responsible for managing the active
- * service validators, the mapping of endpoints to the service
- * validators and updating the configuration when changes
- * are detected.
- */
-public class ServiceValidatorManager {
-
- /**
- * Default constructor for the service validator manager.
- */
- private ServiceValidatorManager() {
- initialize();
- }
-
- /**
- * This method returns the singleton ValidatorConfigurationManager.
- *
- * @return The singleton
- */
- public synchronized static ServiceValidatorManager instance() {
- if (m_instance == null) {
- m_instance = new ServiceValidatorManager();
- }
-
- return(m_instance);
- }
-
- /**
- * This method initializes the service validator manager on
- * startup.
- */
- protected void initialize() {
-
- java.net.URL url=
- ValidatorFilter.class.getClassLoader().getResource(CONFIG_FILE);
-
- if (url != null) {
- m_validatorConfigFile = new java.io.File(url.getFile());
-
- java.io.File[] files=m_validatorConfigFile.getParentFile().listFiles();
-
- for (int i=0; m_modelsDir == null && i < files.length; i++) {
- if (files[i].getName().equals("models") &&
- files[i].isDirectory()) {
- m_modelsDir = files[i];
- }
- }
-
- if (m_modelsDir != null) {
- ValidatorConfigChangeMonitor mon=
- new ValidatorConfigChangeMonitor();
-
- new Thread(mon).start();
- }
- }
- }
-
- /**
- * This method returns the list of service validators associated
- * with the supplied input endpoint.
- *
- * @param endpoint The input endpoint
- * @return The list of service validators, or null if the endpoint
- * is unknown
- */
- public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
- java.util.List<ServiceValidator> ret=
- m_inputValidators.get(endpoint);
-
- if (ret == null) {
- ret = m_replyToManager.getInputServiceValidators(endpoint);
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Return input validators '"+endpoint+"': "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether the supplied endpoint will be
- * associated with a dynamic reply-to endpoint.
- *
- * @param endpoint The endpoint
- * @return Whether the endpoint has a dynamic reply-to
- */
- public boolean isInputDynamicReplyTo(Endpoint endpoint) {
- boolean ret=m_inputDynaReplyTos.contains(endpoint);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Is input endpoint '"+endpoint+
- "' a dynamic reply-to: "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the list of service validators associated
- * with the supplied output endpoint.
- *
- * @param endpoint The output endpoint
- * @return The list of service validators, or null if the endpoint
- * is unknown
- */
- public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
- java.util.List<ServiceValidator> ret=
- m_outputValidators.get(endpoint);
-
- if (ret == null) {
- ret = m_replyToManager.getOutputServiceValidators(endpoint);
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Return output validators '"+endpoint+"': "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method determines whether the supplied endpoint will be
- * associated with a dynamic reply-to endpoint.
- *
- * @param endpoint The endpoint
- * @return Whether the endpoint has a dynamic reply-to
- */
- public boolean isOutputDynamicReplyTo(Endpoint endpoint) {
- boolean ret=m_outputDynaReplyTos.contains(endpoint);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Is output endpoint '"+endpoint+
- "' a dynamic reply-to: "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method registers a list of service validators against
- * a dynamic 'reply-to' endpoint.
- *
- * @param endpoint The endpoint
- * @param validators The list of service validators
- */
- public void registerInputReplyToValidators(Endpoint endpoint,
- java.util.List<ServiceValidator> validators) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Register input reply-to '"+endpoint+"': "+validators);
- }
-
- m_replyToManager.registerInputDynamicReplyTo(endpoint, validators);
- }
-
- /**
- * This method registers a list of service validators against
- * a dynamic 'reply-to' endpoint.
- *
- * @param endpoint The endpoint
- * @param validators The list of service validators
- */
- public void registerOutputReplyToValidators(Endpoint endpoint,
- java.util.List<ServiceValidator> validators) {
- if (logger.isDebugEnabled()) {
- logger.debug("Register output reply-to '"+endpoint+"': "+validators);
- }
-
- m_replyToManager.registerOutputDynamicReplyTo(endpoint, validators);
- }
-
- /**
- * This method returns a ServiceValidator associated with the
- * supplied validator name.
- *
- * @param name The validator name
- * @return The service validator
- * @throws Exception Failed to create service validator
- */
- public ServiceValidator createServiceValidator(ValidatorName name)
- throws Exception {
- ServiceValidator ret=null;
-
- synchronized(m_serviceValidators) {
- ret = m_serviceValidators.get(name);
-
- // If does not exist, then create, else update
- // the existing service validator
- if (ret == null) {
- ret = ServiceValidatorFactory.getServiceValidator(name);
-
- m_serviceValidators.put(name, ret);
- } else {
-
- // Update the description
- ret.update();
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Created Service Validator '"+name+"': "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method removes the service validator associated with
- * the supplied validator name.
- *
- * @param name The validator name
- * @throws Exception Failed to remove the service validator
- */
- protected void removeServiceValidator(ValidatorName name)
- throws Exception {
- synchronized(m_serviceValidators) {
- ServiceValidator validator=(ServiceValidator)
- m_serviceValidators.remove(name);
-
- // Check if validator should be removed from
- // input/output endpoint mappings
- java.util.Iterator<Endpoint> iter=m_inputValidators.keySet().iterator();
-
- while (iter.hasNext()) {
- Endpoint ep=iter.next();
- java.util.List<ServiceValidator> list=
- m_inputValidators.get(ep);
-
- if (list.contains(validator)) {
- list.remove(validator);
-
- if (list.size() == 0) {
- logger.error("Input validator list, associated with endpoint '"+
- ep+"' contains no entries after removal of validator '"+
- name+"' - this Endpoint should have previously been removed");
- }
- }
- }
-
- iter=m_outputValidators.keySet().iterator();
-
- while (iter.hasNext()) {
- Endpoint ep=iter.next();
- java.util.List<ServiceValidator> list=
- m_outputValidators.get(ep);
-
- if (list.contains(validator)) {
- list.remove(validator);
-
- if (list.size() == 0) {
- logger.error("Output validator list, associated with endpoint '"+
- ep+"' contains no entries after removal of validator '"+
- name+"' - this Endpoint should have previously been removed");
- }
- }
- }
-
- if (validator != null) {
- validator.close();
- }
- }
- }
-
- /**
- * This method returns the set of currently configured
- * service validator names.
- *
- * @return The set of validator names
- */
- protected java.util.Set<ValidatorName> getServiceValidatorNames() {
- java.util.Set<ValidatorName> ret=new java.util.HashSet<ValidatorName>();
-
- ret.addAll(m_serviceValidators.keySet());
-
- return(ret);
- }
-
- /**
- * This method updates the configuration of the service
- * validators and endpoint mappings.
- */
- protected void updateConfigurations() {
- java.util.Set<ValidatorName> existingValidatorNames=
- getServiceValidatorNames();
-
- java.util.Set<Endpoint> existingInputEndpoints=
- new java.util.HashSet<Endpoint>(m_inputValidators.keySet());
-
- java.util.Set<Endpoint> existingOutputEndpoints=
- new java.util.HashSet<Endpoint>(m_outputValidators.keySet());
-
- java.util.Set<Endpoint> existingInputDynaReplyTos=
- new java.util.HashSet<Endpoint>(m_inputDynaReplyTos);
-
- java.util.Set<Endpoint> existingOutputDynaReplyTos=
- new java.util.HashSet<Endpoint>(m_outputDynaReplyTos);
-
- java.io.InputStream is=ValidatorFilter.class.getClassLoader().
- getResourceAsStream(CONFIG_FILE);
-
- if (logger.isDebugEnabled()) {
- logger.debug("ValidationFilter: config="+CONFIG_FILE+" is="+is);
- }
-
- try {
- ConfigTree config=ConfigTree.fromInputStream(is);
-
- if (config.getName().equals(VALIDATOR_NODE)) {
- // Old 'active' attribute is now 'mode'
- String active=config.getAttribute(ACTIVE_ATTR);
-
- if (active != null && active.equalsIgnoreCase("true")) {
- m_managedMode = true;
- }
-
- String mode=config.getAttribute(MODE_ATTR);
-
- if (mode != null) {
- if (mode.equals("manage")) {
- m_managedMode = true;
- } else if (mode.equals("monitor")) {
- m_managedMode = false; // will override active=true
- } else {
- logger.error("Unknown mode '"+mode+"' - setting to 'monitor'");
- m_managedMode = false;
- }
- }
-
- if (m_managedMode) {
- logger.debug("Setting validators in 'manage' mode");
- } else {
- logger.debug("Setting validators in 'monitor' mode");
- }
-
- // Check for dynamic replyTo endpoint timeout
- String timeoutValue=config.getAttribute(REPLY_TO_TIMEOUT_ATTR);
-
- if (timeoutValue != null) {
- try {
- long tv=Long.parseLong(timeoutValue);
-
- m_replyToManager.setReplyToTimeout(tv);
- } catch(Exception e) {
- logger.error("Unable to set 'reply to' timeout", e);
- }
- }
- }
-
- updateConfiguration(config, existingValidatorNames,
- existingInputEndpoints, existingOutputEndpoints,
- existingInputDynaReplyTos, existingOutputDynaReplyTos);
-
- // Work through choreography files in the models directory
- java.io.File[] files=m_modelsDir.listFiles();
-
- for (int i=0; i < files.length; i++) {
-
- // Check if a ValidatorModel exists for the
- // file
- try {
- ValidatorConfig vm=
- ValidatorConfigFactory.getValidatorConfig(files[i]);
-
- if (vm != null) {
- ConfigTree vConfig=vm.getConfiguration();
-
- if (vConfig != null) {
- updateConfiguration(vConfig,
- existingValidatorNames,
- existingInputEndpoints,
- existingOutputEndpoints,
- existingInputDynaReplyTos,
- existingOutputDynaReplyTos);
- } else {
- logger.error("Failed to obtain configuration for model '"+
- files[i].getName()+"'");
- }
- }
- } catch(Exception e) {
- logger.error("Failed to update configuration for model '"+
- files[i].getName()+"'", e);
- }
- }
-
- // Any remaining input keys need to be removed
- java.util.Iterator<Endpoint> iter=
- existingInputEndpoints.iterator();
-
- while (iter.hasNext()) {
- Endpoint key=iter.next();
- m_inputValidators.remove(key);
- }
-
- iter = existingInputDynaReplyTos.iterator();
-
- while (iter.hasNext()) {
- Endpoint key=iter.next();
- m_inputDynaReplyTos.remove(key);
- }
-
- // Any remaining output keys need to be removed
- iter = existingOutputEndpoints.iterator();
-
- while (iter.hasNext()) {
- Endpoint key=iter.next();
- m_outputValidators.remove(key);
- }
-
- iter = existingOutputDynaReplyTos.iterator();
-
- while (iter.hasNext()) {
- Endpoint key=iter.next();
- m_outputDynaReplyTos.remove(key);
- }
-
- // Any remaining service description names need to
- // have their associated monitors removed
- java.util.Iterator<ValidatorName> sviter=
- existingValidatorNames.iterator();
-
- while (sviter.hasNext()) {
- ValidatorName svkey=sviter.next();
-
- try {
- logger.debug("Removing service validator: "+svkey);
- removeServiceValidator(svkey);
- } catch(Exception e) {
- logger.error(
- "Failed to remove service validator: "+svkey, e);
- }
- }
- } catch(Exception e) {
- logger.error("Failed to update configuration from input stream", e);
- }
- }
-
- /**
- * This method performs the update of the configuration of
- * service monitors, based on the information in the validator
- * configuration XML file, and the choreographies defined in the
- * models folder.
- *
- * @param config The configuration
- * @param existingValidatorNames The list of validator names
- * @param existingInputEndpoints The list of input endpoints
- * @param existingOutputEndpoints The list of output endpoints
- * @param existingInputDynaReplyTos The set of input dynamic replyTo endpoints
- * @param existingOutputDynaReplyTos The set of output dynamic replyTo endpoints
- */
- protected void updateConfiguration(ConfigTree config,
- java.util.Set<ValidatorName> existingValidatorNames,
- java.util.Set<Endpoint> existingInputEndpoints,
- java.util.Set<Endpoint> existingOutputEndpoints,
- java.util.Set<Endpoint> existingInputDynaReplyTos,
- java.util.Set<Endpoint> existingOutputDynaReplyTos) {
- logger.debug("Update Service Validator Configuration");
-
- if (config != null) {
- try {
- if (config.getName().equals(VALIDATOR_NODE)) {
- String active=config.getAttribute(ACTIVE_ATTR);
-
- if (active != null && active.equalsIgnoreCase("true")) {
-
- logger.debug("Setting validator into active mode");
- m_managedMode = true;
- }
- }
-
- ConfigTree[] services=config.getChildren(SERVICE_NODE);
-
- if (logger.isDebugEnabled()) {
- if (services != null) {
- logger.debug("ValidationFilter: services="+services.length);
- } else {
- logger.debug("ValidationFilter: services null");
- }
- }
-
- for (int i=0; i < services.length; i++) {
- ServiceValidator sm=null;
-
- // Create service monitor for service
- String modelName=
- services[i].getAttribute(MODEL_ATTR);
- String role=
- services[i].getAttribute(ROLE_ATTR);
- boolean validate=
- services[i].getBooleanAttribute(VALIDATE_ATTR, true);
-
- // Check for old attribute names, for
- // backward compatibility - only support
- // for a limited time
- if (role == null) {
- role = services[i].getAttribute("participantType");
- }
-
- if (modelName == null) {
- modelName = services[i].getAttribute("cdmFilePath");
-
- if (modelName != null) {
- // Remove path
- int pos=modelName.lastIndexOf('/');
- if (pos != -1) {
- modelName = modelName.substring(pos+1);
- }
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Initialize service validator for: model="+
- modelName+" role="+role+" validate="+validate);
- }
-
- if (role != null) {
-
- if (modelName != null ||
- validate == false) {
- ValidatorName name=null;
-
- if (validate) {
- name = new ValidatorName(modelName, role);
- } else {
- name = new ValidatorName(role);
-
- }
-
- try {
- // Obtain the service container
- sm = createServiceValidator(name);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Service validator for '"+modelName+
- "' and role '"+role+"' = "+sm);
- }
-
- // Remove validator name from list
- existingValidatorNames.remove(sm.getValidatorName());
- } catch(Exception e) {
- logger.error(
- "Failed to create service validator '"+
- name+"'", e);
- }
- } else {
- logger.error("Model name must be specified in validation mode");
- }
- } else {
- logger.error("Role must be specified");
- }
-
- if (sm != null) {
- // Map inputs to service
- ConfigTree[] inputs=services[i].getChildren(INPUT_NODE);
-
- for (int j=0; j < inputs.length; j++) {
- String epr=inputs[j].getAttribute(EPR_ATTR);
-
- if (epr != null) {
- Endpoint endpoint=new Endpoint(epr);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Storing input endpoint '"+
- endpoint+"' against validator: "+sm);
- }
-
- // Check if existing list
- java.util.List<ServiceValidator> svs=
- m_inputValidators.get(endpoint);
-
- if (svs == null) {
- svs = new java.util.Vector<ServiceValidator>();
- m_inputValidators.put(endpoint, svs);
- }
-
- if (svs.contains(sm) == false) {
- svs.add(sm);
- }
-
- existingInputEndpoints.remove(endpoint);
-
- // Check if dynamic replyTo
- if (inputs[j].getAttribute(DYNAMIC_REPLY_TO_ATTR,
- "false").equalsIgnoreCase("true")) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Input endpoint '"+
- endpoint+"' has dynamic replyTo destination");
- }
-
- m_inputDynaReplyTos.add(endpoint);
-
- existingInputDynaReplyTos.remove(endpoint);
- }
- }
- }
-
- // Map outputs to service
- ConfigTree[] outputs=services[i].getChildren(OUTPUT_NODE);
-
- for (int j=0; j < outputs.length; j++) {
- String epr=outputs[j].getAttribute(EPR_ATTR);
-
- if (epr != null) {
- Endpoint endpoint=new Endpoint(epr);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Storing output endpoint '"+
- endpoint+"' against validator: "+sm);
- }
-
- // Check if existing list
- java.util.List<ServiceValidator> svs=
- m_outputValidators.get(endpoint);
-
- if (svs == null) {
- svs = new java.util.Vector<ServiceValidator>();
- m_outputValidators.put(endpoint, svs);
- }
-
- if (svs.contains(sm) == false) {
- svs.add(sm);
- }
-
- existingOutputEndpoints.remove(endpoint);
-
- // Check if dynamic replyTo
- if (outputs[j].getAttribute(DYNAMIC_REPLY_TO_ATTR,
- "false").equalsIgnoreCase("true")) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Output endpoint '"+
- endpoint+"' has dynamic replyTo destination");
- }
-
- m_outputDynaReplyTos.add(endpoint);
-
- existingOutputDynaReplyTos.remove(endpoint);
- }
- }
- }
- }
- }
- } catch(Exception e) {
- logger.error("Failed to load validator config", e);
- }
- }
- }
-
- /**
- * This method returns whether the service validator configuration
- * is in 'manage' mode. If yes, then invalid messages will
- * be blocked from being delivered to their destination.
- *
- * @return Whether the service validator is in 'manage' mode
- */
- public boolean isManagedMode() {
- return(m_managedMode);
- }
-
- private static final Logger logger = Logger.getLogger(ServiceValidatorManager.class);
-
- private static final String EPR_ATTR = "epr";
- private static final String DYNAMIC_REPLY_TO_ATTR = "dynamicReplyTo";
-
- private static final String OUTPUT_NODE = "output";
- private static final String INPUT_NODE = "input";
- private static final String SERVICE_NODE = "service";
- private static final String ACTIVE_ATTR = "active";
- private static final String MODE_ATTR = "mode";
- private static final String REPLY_TO_TIMEOUT_ATTR = "replyToTimeout";
- private static final String VALIDATOR_NODE = "validator";
-
- private static final String CONFIG_FILE = "validator-config.xml";
- private static final String MODEL_ATTR="model";
- private static final String ROLE_ATTR="role";
- private static final String VALIDATE_ATTR="validate";
-
- private static ServiceValidatorManager m_instance=null;
- private java.io.File m_validatorConfigFile=null;
- private java.io.File m_modelsDir=null;
- private java.util.Map<ValidatorName,ServiceValidator> m_serviceValidators=
- new java.util.HashMap<ValidatorName,ServiceValidator>();
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputValidators=new java.util.Hashtable<Endpoint,java.util.List<ServiceValidator>>();
- private java.util.Set<Endpoint> m_inputDynaReplyTos=new java.util.HashSet<Endpoint>();
- private java.util.Set<Endpoint> m_outputDynaReplyTos=new java.util.HashSet<Endpoint>();
- private boolean m_managedMode=false;
- private DynamicReplyToEndpointManager m_replyToManager=new DynamicReplyToEndpointManager();
-
- /**
- * This class is responsible for monitoring the models folder,
- * within the overlord validator ESB bundle, to determine when
- * the configuration has changed.
- */
- public class ValidatorConfigChangeMonitor implements java.lang.Runnable {
-
- public ValidatorConfigChangeMonitor() {
- // Do initial check for updates, so monitors
- // initialized before returning from construct,
- // as remainder of checks will be in a separate
- // thread - so we need to ensure that the monitors
- // are configured before the first message is
- // passed through the filter.
- checkForUpdates();
- }
-
- public void run() {
-
- while (true) {
- checkForUpdates();
-
- try {
- synchronized(ValidatorConfigChangeMonitor.this) {
- wait(30000);
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- protected void checkForUpdates() {
- logger.debug("Checking for config updates");
-
- // Get last update time
- long lastUpdate=getLastUpdate();
-
- if (lastUpdate > m_lastUpdate) {
-
- updateConfigurations();
-
- m_lastUpdate = lastUpdate;
- }
- }
-
- protected long getLastUpdate() {
- long ret=0;
-
- if (m_validatorConfigFile != null) {
- ret = m_validatorConfigFile.lastModified();
- }
-
- if (m_modelsDir != null) {
- java.io.File[] files=m_modelsDir.listFiles();
-
- for (int i=0; i < files.length; i++) {
- if (files[i].getName().endsWith(".cdm") &&
- ret < files[i].lastModified()) {
- ret = files[i].lastModified();
- }
- }
-
- if (ret < m_modelsDir.lastModified()) {
- ret = m_modelsDir.lastModified();
- }
- }
-
- return(ret);
- }
-
- private long m_lastUpdate=0;
- }
-
- public class DynamicReplyToEndpointManager extends Thread {
-
- /**
- * The default constructor
- */
- public DynamicReplyToEndpointManager() {
- setDaemon(true);
-
- start();
- }
-
- /**
- * The run method is responsible for ensuring the dynamic
- * 'reply-to' endpoints are cleaned up periodically.
- */
- public void run() {
-
- while(true) {
-
- try {
- synchronized(this) {
- wait(m_replyToTimeout);
- }
- } catch(Exception e) {
- logger.error("Failed to wait");
- }
-
- // Shift main entries to an emptied 'pending delete'
- // map
- synchronized(m_inputs) {
- if (logger.isDebugEnabled()) {
- java.util.Iterator<Endpoint> iter=
- m_inputsPendingDelete.keySet().iterator();
- while (iter.hasNext()) {
- Endpoint endpoint=iter.next();
- java.util.List<ServiceValidator> validators=
- m_inputsPendingDelete.get(endpoint);
- logger.debug("Deleting input (reply-to) validators '"+
- endpoint+"': "+validators);
- }
- }
-
- m_inputsPendingDelete.clear();
- m_inputsPendingDelete.putAll(m_inputs);
- m_inputs.clear();
- }
-
- synchronized(m_outputs) {
- if (logger.isDebugEnabled()) {
- java.util.Iterator<Endpoint> iter=
- m_outputsPendingDelete.keySet().iterator();
- while (iter.hasNext()) {
- Endpoint endpoint=iter.next();
- java.util.List<ServiceValidator> validators=
- m_outputsPendingDelete.get(endpoint);
- logger.debug("Deleting output (reply-to) validators '"+
- endpoint+"': "+validators);
- }
- }
-
- m_outputsPendingDelete.clear();
- m_outputsPendingDelete.putAll(m_outputs);
- m_outputs.clear();
- }
- }
- }
-
- /**
- * This method returns the list of service validators
- * associated with the dynamic reply-to endpoint.
- *
- * @param endpoint The input endpoint
- * @return The list of service validators, or null if
- * not found
- */
- public java.util.List<ServiceValidator> getInputServiceValidators(Endpoint endpoint) {
- java.util.List<ServiceValidator> ret=null;
-
- synchronized(m_inputs) {
- ret = m_inputs.get(endpoint);
-
- if (ret == null) {
- ret = m_inputsPendingDelete.get(endpoint);
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Return input (reply-to) validators '"+endpoint+"': "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method returns the list of service validators
- * associated with the dynamic reply-to endpoint.
- *
- * @param endpoint The output endpoint
- * @return The list of service validators, or null if
- * not found
- */
- public java.util.List<ServiceValidator> getOutputServiceValidators(Endpoint endpoint) {
- java.util.List<ServiceValidator> ret=null;
-
- synchronized(m_outputs) {
- ret = m_outputs.get(endpoint);
-
- if (ret == null) {
- ret = m_outputsPendingDelete.get(endpoint);
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Return output (reply-to) validators '"+endpoint+"': "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method registers a list of service validators against
- * a dynamic 'reply-to' endpoint.
- *
- * @param endpoint The endpoint
- * @param validators The list of service validators
- */
- public void registerInputDynamicReplyTo(Endpoint endpoint,
- java.util.List<ServiceValidator> validators) {
-
- synchronized(m_inputs) {
- m_inputs.put(endpoint, validators);
-
- // May not be necessary, as entry would not be
- // used - but could save memory?
- m_inputsPendingDelete.remove(endpoint);
- }
- }
-
- /**
- * This method registers a list of service validators against
- * a dynamic 'reply-to' endpoint.
- *
- * @param endpoint The endpoint
- * @param validators The list of service validators
- */
- public void registerOutputDynamicReplyTo(Endpoint endpoint,
- java.util.List<ServiceValidator> validators) {
-
- synchronized(m_outputs) {
- m_outputs.put(endpoint, validators);
-
- // May not be necessary, as entry would not be
- // used - but could save memory?
- m_outputsPendingDelete.remove(endpoint);
- }
- }
-
- /**
- * This method sets the timeout period for purging the
- * cache of reply-to endpoints.
- *
- * @param timeoutValue The timeout value
- */
- public void setReplyToTimeout(long timeoutValue) {
- m_replyToTimeout = timeoutValue;
- }
-
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputs=
- new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputs=
- new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_inputsPendingDelete=
- new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
- private java.util.Map<Endpoint,java.util.List<ServiceValidator>> m_outputsPendingDelete=
- new java.util.HashMap<Endpoint,java.util.List<ServiceValidator>>();
- private long m_replyToTimeout=10000;
- }
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfig.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfig.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfig.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,46 +0,0 @@
-/*
- * 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 org.jboss.soa.esb.helpers.*;
-
-/**
- * This interface represents a configuration that will be used for
- * validation against a stream of ESB based messages.
- */
-public interface ValidatorConfig {
-
- /**
- * This method returns the type of the model associated
- * with this validator configuration. This will
- * general be based on the file extension of the model
- * file.
- *
- * @return The model type
- */
- public String getModelType();
-
- /**
- * This method returns the validator configuration
- * associated with the model.
- *
- * @return The validator model
- */
- public ConfigTree getConfiguration();
-
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigFactory.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigFactory.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigFactory.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,97 +0,0 @@
-/*
- * 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 org.apache.log4j.Logger;
-
-/**
- * This class provides a factory for ValidatorConfig objects
- * based on supplied model file details.
- */
-public class ValidatorConfigFactory {
-
- /**
- * This method retrieves a validator config associated with
- * the supplied file. If the model associated with the
- * file is not supported, then a null will be returned.
- *
- * @param file The file containing the model
- * @return The validator config, or null if an unsupported type
- * @exception IOException Failed to load supported model type
- */
- public static ValidatorConfig getValidatorConfig(java.io.File file)
- throws java.io.IOException {
- ValidatorConfig ret=null;
-
- String modelType=null;
-
- if (file != null && (modelType=getModelType(file.getName())) != null) {
- ValidatorConfigLoader loader=null;
-
- for (int i=0; loader == null &&
- i < m_loaders.size(); i++) {
-
- if (m_loaders.get(i).isSupported(modelType)) {
- loader = m_loaders.get(i);
- }
- }
-
- if (loader != null) {
- java.io.FileInputStream fis=new java.io.FileInputStream(file);
-
- ret = loader.loadValidatorConfig(fis, file.getName());
-
- fis.close();
- }
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Returning validator config for "+
- file.getName()+": "+ret);
- }
-
- return(ret);
- }
-
- /**
- * This method determines the model type associated with the
- * supplied model filename.
- *
- * @param name The model filename
- * @return The model type, or null if not known
- */
- protected static String getModelType(String name) {
- String ret=null;
- int pos=name.lastIndexOf('.');
-
- if (pos != -1) {
- ret = name.substring(pos+1);
- }
-
- return(ret);
- }
-
- private static final Logger logger = Logger.getLogger(ValidatorConfigFactory.class);
-
- private static java.util.List<ValidatorConfigLoader> m_loaders=
- new java.util.Vector<ValidatorConfigLoader>();
-
- static {
- m_loaders.add(new org.jboss.savara.validator.jbossesb.pi4soa.Pi4SOAValidatorConfigLoader());
- }
-}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigLoader.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigLoader.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorConfigLoader.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-/**
- * This interface is implemented by model specific loaders, to
- * load a ValidatorConfig for the particular model type.
- */
-public interface ValidatorConfigLoader {
-
- /**
- * This method determines if the validator config loader
- * implementation supports the supplied model type.
- *
- * @param modelType The model type
- * @return Whether the loader supports the model type
- */
- public boolean isSupported(String modelType);
-
- /**
- * This method loads the validator config, contained within
- * the supplied input stream representing a model of the
- * supported type.
- *
- * @param is The input stream
- * @param modelPath The path to the model file
- * @return The validator config
- * @throws java.io.IOException Failed to load validator config
- */
- public ValidatorConfig loadValidatorConfig(java.io.InputStream is,
- String modelPath) throws java.io.IOException;
-
-}
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-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorFilter.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -17,8 +17,14 @@
*/
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.*;
@@ -31,7 +37,11 @@
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.
*/
@@ -39,6 +49,25 @@
}
/**
+ * 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.
*
@@ -53,7 +82,7 @@
if (endpoint != null) {
java.util.List<ServiceValidator> validators=
- ServiceValidatorManager.instance().getOutputServiceValidators(endpoint);
+ getServiceValidatorManager().getOutputServiceValidators(endpoint);
if (validators != null && validators.size() > 0) {
boolean validated=false;
@@ -62,7 +91,7 @@
for (int i=0; validators != null &&
i < validators.size(); i++) {
try {
- validators.get(i).messageSent(msg);
+ validators.get(i).messageSent(ESBUtil.getMessage(msg));
validated = true;
} catch(Exception t) {
// Ignore
@@ -90,20 +119,20 @@
logger.debug("Invalid sent message", ex);
}
- if (ServiceValidatorManager.instance().isManagedMode()) {
+ 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 (ServiceValidatorManager.instance().isOutputDynamicReplyTo(endpoint)) {
+ if (getServiceValidatorManager().isOutputDynamicReplyTo(endpoint)) {
// Register interest in the 'reply-to' endpoint
Endpoint replyTo=getReplyToEndpoint(msg);
if (replyTo != null) {
- ServiceValidatorManager.instance().registerInputReplyToValidators(replyTo,
+ getServiceValidatorManager().registerInputReplyToValidators(replyTo,
validators);
} else {
logger.error("Unable to get 'reply-to' endpoint for message: "+msg);
@@ -131,7 +160,7 @@
if (endpoint != null) {
java.util.List<ServiceValidator> validators=
- ServiceValidatorManager.instance().getInputServiceValidators(endpoint);
+ getServiceValidatorManager().getInputServiceValidators(endpoint);
if (validators != null && validators.size() > 0) {
boolean validated=false;
@@ -140,7 +169,7 @@
for (int i=0; validators != null &&
i < validators.size(); i++) {
try {
- validators.get(i).messageReceived(msg);
+ validators.get(i).messageReceived(ESBUtil.getMessage(msg));
validated = true;
} catch(Exception t) {
// Ignore
@@ -168,20 +197,20 @@
logger.debug("Invalid received message", ex);
}
- if (ServiceValidatorManager.instance().isManagedMode()) {
+ 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 (ServiceValidatorManager.instance().isInputDynamicReplyTo(endpoint)) {
+ if (getServiceValidatorManager().isInputDynamicReplyTo(endpoint)) {
// Register interest in the 'reply-to' endpoint
Endpoint replyTo=getReplyToEndpoint(msg);
if (replyTo != null) {
- ServiceValidatorManager.instance().registerOutputReplyToValidators(replyTo,
+ getServiceValidatorManager().registerOutputReplyToValidators(replyTo,
validators);
} else {
logger.error("Unable to get 'reply-to' endpoint for message: "+msg);
@@ -253,6 +282,4 @@
return(ret);
}
-
- private static final Logger logger = Logger.getLogger(ValidatorFilter.class);
}
Deleted: trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorName.java
===================================================================
--- trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorName.java 2010-08-27 13:27:51 UTC (rev 377)
+++ trunk/validators/jboss/esb/src/main/java/org/jboss/savara/validator/jbossesb/ValidatorName.java 2010-08-27 16:49:51 UTC (rev 378)
@@ -1,134 +0,0 @@
-/*
- * 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;
-
-/**
- * This class represents a key for looking up a service validator.
- */
-public class ValidatorName {
-
- /**
- * This constructor is initialized with the details used to
- * identify the validator.
- *
- * @param role The role
- */
- public ValidatorName(String role) {
- m_role = role;
- m_validate = false;
- }
-
- /**
- * This constructor is initialized with the details used to
- * identify the validator.
- *
- * @param modelName The model name
- * @param role The role
- * @param validate Whether to validate, or simply record
- */
- public ValidatorName(String modelName, String role) {
- m_modelName = modelName;
- m_role = role;
- m_validate = true;
- }
-
- /**
- * This method returns the model name associated with the
- * service validator.
- *
- * @return The model name
- */
- public String getModelName() {
- return(m_modelName);
- }
-
- /**
- * This method returns the type associated with the model.
- * If no model has been defined for the validator name,
- * as in the case of a validator in record mode, then
- * this method will return ValidatorName.NO_MODEL_TYPE.
- *
- * @return The model type
- */
- public String getModelType() {
- String ret=null;
- int pos=0;
-
- if (m_modelName != null &&
- (pos=m_modelName.lastIndexOf('.')) != -1) {
- ret = m_modelName.substring(pos+1);
- } else {
- ret = NO_MODEL_TYPE;
- }
-
- return(ret);
- }
-
- /**
- * This method returns the role associated with the Service
- * Validator.
- *
- * @return The role
- */
- public String getRole() {
- return(m_role);
- }
-
- /**
- * This method determines whether the associated service
- * validator is in validation or record mode.
- *
- * @return Whether in validation or record mode
- */
- public boolean isValidate() {
- return(m_validate);
- }
-
- public boolean equals(Object obj) {
- boolean ret=false;
-
- if (obj instanceof ValidatorName) {
- ret = (obj.toString().equals(toString()) &&
- ((ValidatorName)obj).m_validate == m_validate);
- }
-
- return(ret);
- }
-
- public int hashCode() {
- return(toString().hashCode());
- }
-
- public String toString() {
- String ret=null;
-
- if (isValidate()) {
- ret = m_modelName+":"+m_role;
- } else {
- ret = m_role;
- }
-
- return(ret);
- }
-
- public static final String NO_MODEL_TYPE="NoModelType";
-
- private String m_modelName=null;
- private String m_role=null;
- private boolean m_validate=false;
-}
\ No newline at end of file