Author: objectiser
Date: 2011-02-16 12:09:49 -0500 (Wed, 16 Feb 2011)
New Revision: 677
Removed:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
Modified:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java
Log:
Removed the 'recorder' validator implementation, as not necessary now, and
modified the service validator interface to return the context information used for the
activity events.
Modified:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java
===================================================================
---
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java 2011-02-15
23:29:24 UTC (rev 676)
+++
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidator.java 2011-02-16
17:09:49 UTC (rev 677)
@@ -17,6 +17,8 @@
*/
package org.savara.validator;
+import org.savara.activity.model.Context;
+
/**
* This interface represents a service validator responsible for
* validing a stream of ESB messages against a model.
@@ -38,7 +40,7 @@
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(String mesgType, java.io.Serializable msg) throws Exception;
+ public java.util.List<Context> messageSent(String mesgType, java.io.Serializable
msg) throws Exception;
/**
* This method processes a received message against a service
@@ -48,7 +50,7 @@
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(String mesgType, java.io.Serializable msg) throws
Exception;
+ public java.util.List<Context> messageReceived(String mesgType,
java.io.Serializable msg) throws Exception;
/**
* This method is called to update the model associated
Modified:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java
===================================================================
---
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java 2011-02-15
23:29:24 UTC (rev 676)
+++
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/ServiceValidatorFactory.java 2011-02-16
17:09:49 UTC (rev 677)
@@ -63,8 +63,6 @@
new java.util.HashMap<String,Class<?>>();
static {
- m_validatorClasses.put(org.savara.validator.pi4soa.Pi4SOAServiceRecorder.getModelType(),
- org.savara.validator.pi4soa.Pi4SOAServiceRecorder.class);
m_validatorClasses.put(org.savara.validator.pi4soa.Pi4SOAServiceValidator.getModelType(),
org.savara.validator.pi4soa.Pi4SOAServiceValidator.class);
}
Deleted:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java
===================================================================
---
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2011-02-15
23:29:24 UTC (rev 676)
+++
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceRecorder.java 2011-02-16
17:09:49 UTC (rev 677)
@@ -1,159 +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.savara.validator.pi4soa;
-
-import org.apache.log4j.Logger;
-
-import org.savara.validator.AbstractServiceValidator;
-import org.savara.validator.ValidatorName;
-import org.pi4soa.common.util.MessageUtil;
-import org.pi4soa.service.ServiceException;
-import org.pi4soa.service.behavior.*;
-import org.pi4soa.service.monitor.*;
-
-/**
- * This class implements the pi4soa service validator responsible for
- * recording a stream of ESB messages.
- */
-public class Pi4SOAServiceRecorder extends AbstractServiceValidator {
-
- /**
- * This is the constructor for the pi4soa service
- * recorder implementation.
- *
- * @param name The validator name
- */
- public Pi4SOAServiceRecorder(ValidatorName name) {
- super(name);
-
- initialize();
- }
-
- /**
- * This method initializes the service recorder.
- */
- protected void initialize() {
- try {
- // Use XML configuration, to enable alternative
- // runtime configuration to be specified by
- // including a pi4soa.xml file in the environment
- DefaultMonitorConfiguration conf=
- new XMLMonitorConfiguration();
-
- conf.setValidateBehaviour(getValidatorName().isValidate());
-
- m_monitor = ServiceMonitorFactory.getServiceMonitor(conf);
-
- ServiceDescription sdesc=BehaviorFactory.eINSTANCE.createServiceDescription();
- sdesc.setName(getValidatorName().getRole());
-
- // Register service description
- m_monitor.getConfiguration().getServiceRepository().
- addServiceDescription(sdesc);
-
- logger.debug("Created monitor for service description
"+sdesc.getFullyQualifiedName());
-
- } catch(Exception e) {
- logger.error("Failed to initialize service monitor: "+e);
- }
- }
-
- /**
- * This method returns the model type associated with this
- * service recorder.
- *
- * @return The model type
- */
- public static String getModelType() {
- return(ValidatorName.NO_MODEL_TYPE);
- }
-
- /**
- * This method is called to update the model associated
- * with the service validator.
- */
- public void update() {
- }
-
- /**
- * This method processes a sent message against a service
- * behavioural description.
- *
- * @param mesgType The optional message type
- * @param msg The message
- * @throws Exception Failed to process sent message
- */
- public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
-
- if (msg == null) {
- throw new ServiceException("Failed to obtain value from message: "+msg);
- }
-
- if (mesgType == null) {
- mesgType = MessageUtil.getMessageType(msg);
- }
-
- org.pi4soa.service.Message mesg=
- m_monitor.createMessage(mesgType,
- null, null, msg, null, null);
-
- synchronized(m_monitor) {
- m_monitor.messageSent(mesg);
- }
- }
-
- /**
- * This method processes a received message against a service
- * behavioural description.
- *
- * @param mesgType The optional message type
- * @param msg The message
- * @throws Exception Failed to process received message
- */
- public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception
{
-
- if (msg == null) {
- throw new ServiceException("Failed to obtain value from message: "+msg);
- }
-
- if (mesgType == null) {
- mesgType = MessageUtil.getMessageType(msg);
- }
-
- org.pi4soa.service.Message mesg=
- m_monitor.createMessage(mesgType,
- null, null, msg, null, null);
-
- synchronized(m_monitor) {
- m_monitor.messageReceived(mesg);
- }
- }
-
- /**
- * This method closes the service validator.
- *
- * @throws Exception Failed to close the service validator
- */
- public void close() throws Exception {
- m_monitor.close();
- }
-
- private static final Logger logger = Logger.getLogger(Pi4SOAServiceRecorder.class);
-
- private org.pi4soa.service.monitor.ServiceMonitor m_monitor=null;
-}
Modified:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java
===================================================================
---
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2011-02-15
23:29:24 UTC (rev 676)
+++
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/pi4soa/Pi4SOAServiceValidator.java 2011-02-16
17:09:49 UTC (rev 677)
@@ -19,6 +19,7 @@
import org.apache.log4j.Logger;
+import org.savara.activity.model.Context;
import org.savara.validator.AbstractServiceValidator;
import org.savara.validator.ValidatorName;
import org.pi4soa.common.util.MessageUtil;
@@ -159,7 +160,7 @@
* @param msg The message
* @throws Exception Failed to process sent message
*/
- public void messageSent(String mesgType, java.io.Serializable msg) throws Exception {
+ public java.util.List<Context> messageSent(String mesgType, java.io.Serializable
msg) throws Exception {
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
@@ -176,6 +177,8 @@
synchronized(m_monitor) {
m_monitor.messageSent(mesg);
}
+
+ return(getContexts(mesg));
}
/**
@@ -186,8 +189,8 @@
* @param msg The message
* @throws Exception Failed to process received message
*/
- public void messageReceived(String mesgType, java.io.Serializable msg) throws Exception
{
-
+ public java.util.List<Context> messageReceived(String mesgType,
java.io.Serializable msg) throws Exception {
+
if (msg == null) {
throw new ServiceException("Failed to obtain value from message: "+msg);
}
@@ -203,8 +206,41 @@
synchronized(m_monitor) {
m_monitor.messageReceived(mesg);
}
+
+ return(getContexts(mesg));
}
+ protected java.util.List<Context> getContexts(org.pi4soa.service.Message mesg) {
+ java.util.List<Context> ret=new java.util.Vector<Context>();
+
+ for (org.pi4soa.service.Identity id : mesg.getMessageIdentities()) {
+ Context context=new Context();
+ String name=null;
+ for (String token : id.getTokens()) {
+ if (name == null) {
+ name = token;
+ } else {
+ name += ":"+token;
+ }
+ }
+ context.setName(name);
+
+ String value=null;
+ for (Object val : id.getValues()) {
+ if (value == null) {
+ value = val.toString();
+ } else {
+ value += ":"+val.toString();
+ }
+ }
+ context.setValue(value);
+
+ ret.add(context);
+ }
+
+ return(ret);
+ }
+
/**
* This method closes the service validator.
*
Modified:
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java
===================================================================
---
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java 2011-02-15
23:29:24 UTC (rev 676)
+++
branches/experimental/2.0.x/integration/jboss/common/src/main/java/org/savara/validator/service/ServiceValidatorService.java 2011-02-16
17:09:49 UTC (rev 677)
@@ -200,13 +200,14 @@
for (int i=0; validators != null &&
i < validators.size(); i++) {
boolean validated=false;
+ java.util.List<org.savara.activity.model.Context> contexts=null;
try {
if (ia.isOutbound()) {
- validators.get(i).messageSent(ia.getParameter().get(0).getType(),
+ contexts =
validators.get(i).messageSent(ia.getParameter().get(0).getType(),
ia.getParameter().get(0).getValue());
} else {
- validators.get(i).messageReceived(ia.getParameter().get(0).getType(),
+ contexts =
validators.get(i).messageReceived(ia.getParameter().get(0).getType(),
ia.getParameter().get(0).getValue());
}
validated = true;
@@ -220,6 +221,10 @@
pa.setExpected(validated);
ia.getAnalysis().add(pa);
+
+ if (contexts != null) {
+ ia.getContext().addAll(contexts);
+ }
}
}
}