[savara-commits] savara SVN: r577 - in branches/experimental/2.0.x/bundles: org.savara.monitor and 18 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jan 14 12:25:27 EST 2011


Author: objectiser
Date: 2011-01-14 12:25:26 -0500 (Fri, 14 Jan 2011)
New Revision: 577

Added:
   branches/experimental/2.0.x/bundles/org.savara.monitor/
   branches/experimental/2.0.x/bundles/org.savara.monitor/.classpath
   branches/experimental/2.0.x/bundles/org.savara.monitor/.project
   branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/
   branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.jdt.core.prefs
   branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.pde.core.prefs
   branches/experimental/2.0.x/bundles/org.savara.monitor/Copyright.txt
   branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/
   branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF
   branches/experimental/2.0.x/bundles/org.savara.monitor/build.properties
   branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationId.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Message.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorListener.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/osgi/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/osgi/Activator.java
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/
   branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java
   branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/DefaultScenarioSimulator.java
   branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulatorFactory.java
Modified:
   branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF
Log:
Initial savara monitor and simulator modules.

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/.classpath
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/.classpath	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/.classpath	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/.project
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/.project	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/.project	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.savara.monitor</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.jdt.core.prefs	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,8 @@
+#Fri Jan 14 11:34:01 GMT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.pde.core.prefs
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.pde.core.prefs	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/.settings/org.eclipse.pde.core.prefs	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,5 @@
+#Fri Jan 14 11:34:01 GMT 2011
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/Copyright.txt
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/Copyright.txt	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/Copyright.txt	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SAVARA Monitor
+Bundle-SymbolicName: org.savara.monitor
+Bundle-Version: 2.0.0.SNAPSHOT
+Bundle-Activator: org.savara.monitor.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.protocol.monitor,
+ org.junit

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/build.properties
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/build.properties	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/build.properties	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,44 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.savara.bundles</groupId>
+	<artifactId>org.savara.monitor</artifactId> 
+	<version>2.0.0-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>Savara::Bundles::Monitor</name>
+
+	<parent>
+		<groupId>org.savara</groupId>
+		<artifactId>bundles</artifactId>
+		<version>2.0.0-SNAPSHOT</version>
+	</parent>
+  
+	<dependencies>
+		<dependency>
+			<groupId>org.scribble.bundles</groupId>
+			<artifactId>org.scribble.common</artifactId>
+			<version>${scribble.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.scribble.bundles</groupId>
+			<artifactId>org.scribble.protocol</artifactId>
+			<version>${scribble.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.savara.bundles</groupId>
+			<artifactId>org.savara.common</artifactId>
+			<version>${savara.version}</version>
+		</dependency>
+	    <dependency>
+	      <groupId>org.apache.felix</groupId>
+	      <artifactId>org.osgi.core</artifactId>
+	      <version>${osgi.version}</version>
+	    </dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+           	<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+   </dependencies>
+</project>

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationId.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationId.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationId.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,52 @@
+/*
+ * 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.monitor;
+
+import java.util.UUID;
+
+/**
+ * This class represents a conversation id.
+ *
+ */
+public class ConversationId {
+
+	private String m_id=null;
+	
+	public ConversationId() {
+		m_id = UUID.randomUUID().toString();
+	}
+	
+	public ConversationId(String id) {
+		m_id = id;
+	}
+	
+	public int hashCode() {
+		return(m_id.hashCode());
+	}
+	
+	public boolean equals(Object obj) {
+		boolean ret=false;
+		
+		if (obj instanceof ConversationId &&
+				((ConversationId)obj).m_id.equals(m_id)) {
+			ret = true;
+		}
+		
+		return(ret);
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ConversationStore.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,77 @@
+/*
+ * 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.monitor;
+
+import org.scribble.protocol.monitor.Conversation;
+
+/**
+ * This interface represents a conversation store responsible for
+ * persisting information about conversation instances being
+ * monitored.
+ *
+ */
+public interface ConversationStore {
+
+	/**
+	 * This method returns a new conversation associated with
+	 * the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @return The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid
+	 * @throws IOException Failed to create new conversation
+	 */
+	public Conversation create(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException;
+	
+	/**
+	 * This method returns an existing conversation associated with
+	 * the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @return The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid
+	 * @throws IOException Failed to retrieve conversation
+	 */
+	public Conversation find(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException;
+	
+	/**
+	 * This method removes an existing conversation associated
+	 * with the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @throws IllegalArgumentException Conversation id is invalid or unknown
+	 * @throws java.io.IOException Failed to remove existing conversation
+	 */
+	public void remove(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException;
+	
+	/**
+	 * This method updates an existing conversation associated
+	 * with the supplied conversation id.
+	 * 
+	 * @param id The id
+	 * @param conv The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid or unknown
+	 * @throws java.io.IOException Failed to update existing conversation
+	 */
+	public void update(ConversationId id, Conversation conv) throws IllegalArgumentException,
+									java.io.IOException;
+	
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Message.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Message.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Message.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,26 @@
+/*
+ * 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.monitor;
+
+/**
+ * This class represents a message to be monitored.
+ *
+ */
+public class Message extends org.scribble.protocol.monitor.DefaultMessage {
+
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,58 @@
+/*
+ * 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.monitor;
+
+public interface Monitor {
+
+	/**
+	 * This method sets the monitor listener used to handle
+	 * activity information produced while monitoring.
+	 * 
+	 * @param l The monitor listener
+	 */
+	public void setMonitorListener(MonitorListener l);
+	
+	/**
+	 * This method sets the conversation store to use when
+	 * monitoring.
+	 * 
+	 * @param store The conversation store
+	 */
+	public void setConversationStore(ConversationStore store);
+	
+	/**
+	 * This method is used to indicate that a message has been
+	 * sent and should be monitored against the configured
+	 * behaviour.
+	 * 
+	 * @param mesg The message
+	 * @return Whether the message was valid
+	 */
+	public boolean sent(Message mesg);
+	
+	/**
+	 * This method is used to indicate that a message has been
+	 * received and should be monitored against the configured
+	 * behaviour.
+	 * 
+	 * @param mesg The message
+	 * @return Whether the message was valid
+	 */
+	public boolean received(Message mesg);
+	
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorListener.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorListener.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorListener.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,22 @@
+/*
+ * 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.monitor;
+
+public interface MonitorListener {
+
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,94 @@
+/*
+ * 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.monitor.impl;
+
+import org.savara.monitor.ConversationStore;
+import org.savara.monitor.Message;
+import org.savara.monitor.Monitor;
+import org.savara.monitor.MonitorListener;
+import org.scribble.protocol.monitor.DefaultProtocolMonitor;
+import org.scribble.protocol.monitor.ProtocolMonitor;
+
+/**
+ * This class provides a default implementation of the
+ * Montor.
+ *
+ */
+public class DefaultMonitor implements Monitor {
+
+	private MonitorListener m_listener=null;
+	private ConversationStore m_store=null;
+	private ProtocolMonitor m_monitor=new DefaultProtocolMonitor();
+	
+	/**
+	 * This method sets the protocol monitor.
+	 * 
+	 * @param pm The protocol monitor
+	 */
+	public void setProtocolMonitor(ProtocolMonitor pm) {
+		m_monitor = pm;
+	}
+	
+	/**
+	 * This method sets the monitor listener used to handle
+	 * activity information produced while monitoring.
+	 * 
+	 * @param l The monitor listener
+	 */
+	public void setMonitorListener(MonitorListener l) {
+		m_listener = l;
+	}
+	
+	/**
+	 * This method sets the conversation store to use when
+	 * monitoring.
+	 * 
+	 * @param store The conversation store
+	 */
+	public void setConversationStore(ConversationStore store) {
+		m_store = store;
+	}
+	
+	/**
+	 * This method is used to indicate that a message has been
+	 * sent and should be monitored against the configured
+	 * behaviour.
+	 * 
+	 * @param mesg The message
+	 * @return Whether the message was valid
+	 */
+	public boolean sent(Message mesg) {
+		boolean ret=false;
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method is used to indicate that a message has been
+	 * received and should be monitored against the configured
+	 * behaviour.
+	 * 
+	 * @param mesg The message
+	 * @return Whether the message was valid
+	 */
+	public boolean received(Message mesg) {
+		boolean ret=false;
+		
+		return(ret);
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryConversationStore.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,115 @@
+/*
+ * 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.monitor.impl;
+
+import org.savara.monitor.ConversationId;
+import org.savara.monitor.ConversationStore;
+import org.scribble.protocol.monitor.Conversation;
+import org.scribble.protocol.monitor.DefaultConversation;
+
+public class InMemoryConversationStore implements ConversationStore {
+
+	private java.util.Map<ConversationId, Conversation> m_conversations=
+			new java.util.HashMap<ConversationId, Conversation>();
+	
+	/**
+	 * This method returns a new conversation associated with
+	 * the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @return The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid
+	 * @throws IOException Failed to create new conversation
+	 */
+	public Conversation create(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException {
+		if (id == null) {
+			throw new IllegalArgumentException("Id not specified");
+		} else if (m_conversations.containsKey(id)) {
+			throw new IllegalArgumentException("Conversation id already in use");
+		}
+		
+		Conversation ret=new DefaultConversation();
+		
+		m_conversations.put(id, ret);
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns an existing conversation associated with
+	 * the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @return The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid
+	 * @throws IOException Failed to retrieve conversation
+	 */
+	public Conversation find(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException {
+		
+		if (id == null) {
+			throw new IllegalArgumentException("Id not specified");
+		} else if (m_conversations.containsKey(id) == false) {
+			throw new IllegalArgumentException("Conversation id is unknown");
+		}
+		
+		return(m_conversations.get(id));
+	}
+	
+	/**
+	 * This method removes an existing conversation associated
+	 * with the supplied conversation id.
+	 * 
+	 * @param id The conversation id
+	 * @throws IllegalArgumentException Conversation id is invalid or unknown
+	 * @throws java.io.IOException Failed to remove existing conversation
+	 */
+	public void remove(ConversationId id) throws IllegalArgumentException,
+									java.io.IOException {
+		if (id == null) {
+			throw new IllegalArgumentException("Id not specified");
+		} else if (m_conversations.containsKey(id) == false) {
+			throw new IllegalArgumentException("Conversation id is unknown");
+		}
+		
+		m_conversations.remove(id);
+	}
+	
+	/**
+	 * This method updates an existing conversation associated
+	 * with the supplied conversation id.
+	 * 
+	 * @param id The id
+	 * @param conv The conversation
+	 * @throws IllegalArgumentException Conversation id is invalid or unknown
+	 * @throws java.io.IOException Failed to update existing conversation
+	 */
+	public void update(ConversationId id, Conversation conv) throws IllegalArgumentException,
+									java.io.IOException {
+		
+		if (id == null) {
+			throw new IllegalArgumentException("Id not specified");
+		} else if (m_conversations.containsKey(id) == false) {
+			throw new IllegalArgumentException("Conversation id unknown");
+		}
+		
+		m_conversations.put(id, conv);
+	}
+	
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/osgi/Activator.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/osgi/Activator.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/osgi/Activator.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,30 @@
+package org.savara.monitor.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	private static BundleContext context;
+
+	static BundleContext getContext() {
+		return context;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext bundleContext) throws Exception {
+		Activator.context = bundleContext;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext bundleContext) throws Exception {
+		Activator.context = null;
+	}
+
+}

Added: branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemoryConversationStoreTest.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,185 @@
+/*
+ * 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.monitor.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.savara.monitor.ConversationId;
+import org.scribble.protocol.monitor.Conversation;
+
+public class InMemoryConversationStoreTest {
+
+	@Test
+	public void testCreateConversationContextNoId() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			store.create(null);
+			
+			fail("Should have thrown IllegalArgumentException");
+		} catch(IllegalArgumentException iae) {
+			// Expected
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+
+	@Test
+	public void testCreateConversationContextDuplicateInvalidId() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			ConversationId id=new ConversationId("1");
+			
+			try {
+				store.create(id);
+			} catch(Exception inner) {
+				fail("Should not have failed");
+			}
+			
+			store.create(id);
+			
+			fail("Should have thrown IllegalArgumentException");
+		} catch(IllegalArgumentException iae) {
+			// Expected
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+
+	@Test
+	public void testCreateConversationContext() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			ConversationId id=new ConversationId("1");
+
+			if (store.create(id) == null) {
+				fail("No context created");
+			}
+
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+
+	@Test
+	public void testRemoveConversation() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			ConversationId id=new ConversationId("1");
+
+			if (store.create(id) == null) {
+				fail("No context created");
+			}
+			
+			Conversation c1=store.find(id);
+			
+			if (c1 == null) {
+				fail("Should not be null");
+			}
+			
+			store.remove(id);
+			
+			try {
+				store.find(id);
+				
+				fail("Should not find the conversation");
+			} catch(IllegalArgumentException inner) {
+				// Ignore
+			}
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+
+	@Test
+	public void testFindConversation() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			ConversationId id1=new ConversationId("1");
+
+			Conversation c1=null;
+			
+			if ((c1=store.create(id1)) == null) {
+				fail("No context created for id 1");
+			}
+			
+			ConversationId id2=new ConversationId("2");
+
+			Conversation c2=null;
+			
+			if ((c2=store.create(id2)) == null) {
+				fail("No context created for id 2");
+			}
+			
+			Conversation result=store.find(id1);
+
+			if (result == null) {
+				fail("Result is null");
+			}
+			
+			if (result != c1) {
+				fail("Conversation 1 was not returned");
+			}
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+
+	@Test
+	public void testUpdateConversation() {
+		InMemoryConversationStore store=new InMemoryConversationStore();
+		
+		try {
+			ConversationId id1=new ConversationId("1");
+
+			Conversation c1=null;
+			
+			if ((c1=store.create(id1)) == null) {
+				fail("No context created for id 1");
+			}
+			
+			ConversationId id2=new ConversationId("2");
+
+			Conversation c2=null;
+			
+			if ((c2=store.create(id2)) == null) {
+				fail("No context created for id 2");
+			}
+			
+			// Update context for id1 with context for id2
+			store.update(id1, c2);
+			
+			Conversation result=store.find(id1);
+
+			if (result == null) {
+				fail("Result is null");
+			}
+			
+			if (result != c2) {
+				fail("Conversation context 2 was not returned");
+			}
+		} catch(Exception e) {
+			fail("Not expecting: "+e);
+		}
+	}
+}

Modified: branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF	2011-01-13 22:30:18 UTC (rev 576)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/META-INF/MANIFEST.MF	2011-01-14 17:25:26 UTC (rev 577)
@@ -9,7 +9,8 @@
 Import-Package: org.junit,
  org.osgi.framework
 Require-Bundle: org.scribble.common,
- org.savara.common
+ org.savara.common,
+ org.scribble.protocol.monitor
 Export-Package: org.savara.scenario.model,
  org.savara.scenario.simulation,
  org.savara.scenario.util

Added: branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/DefaultScenarioSimulator.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/DefaultScenarioSimulator.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/DefaultScenarioSimulator.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,54 @@
+/*
+ * 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.scenario.simulation;
+
+import org.scribble.protocol.monitor.DefaultConversationContext;
+import org.scribble.protocol.monitor.DefaultMessage;
+import org.scribble.protocol.monitor.DefaultProtocolMonitor;
+import org.scribble.protocol.monitor.ProtocolMonitor;
+
+/**
+ * This class provides the default implementation of the Scenario Simulator interface.
+ *
+ */
+public class DefaultScenarioSimulator implements ScenarioSimulator {
+
+	private ProtocolMonitor m_monitor=new DefaultProtocolMonitor();
+	
+	public void run() {
+		
+		/*
+		DefaultConversationContext context=new DefaultConversationContext();
+		monitor.initialize(pd, context);
+		
+		DefaultMessage message=new DefaultMessage();
+		message.setType(ORDER_MESSAGE_TYPE);
+		
+		if (monitor.receiveMessage(pd, context, null, message) == false) {
+			fail("Receive Order failed");
+		}
+		
+		message=new DefaultMessage();
+		message.setType(CREDIT_CHECK_MESSAGE_TYPE);
+		
+		if (monitor.sendMessage(pd, context, null, message) == false) {
+			fail("Credit check failed");
+		}
+*/
+	}
+}

Added: branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulatorFactory.java
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulatorFactory.java	                        (rev 0)
+++ branches/experimental/2.0.x/bundles/org.savara.scenario/src/main/java/org/savara/scenario/simulation/ScenarioSimulatorFactory.java	2011-01-14 17:25:26 UTC (rev 577)
@@ -0,0 +1,35 @@
+/*
+ * 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.scenario.simulation;
+
+/**
+ * This class provides a factory for the scenario simulator.
+ *
+ */
+public class ScenarioSimulatorFactory {
+
+	/**
+	 * This method returns an instance of the scenario simulator.
+	 * 
+	 * @return The scenario simulator
+	 */
+	public static ScenarioSimulator createScenarioSimulator() {
+		return(new DefaultScenarioSimulator());
+	}
+	
+}



More information about the savara-commits mailing list