Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a new beginning

  • Loading branch information...
commit 30b76bba38cf28a4e3bbf9fc1f690c3617eafc2f 0 parents
Meredith Gregory authored
190 pom.xml
@@ -0,0 +1,190 @@
+<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>com.biosimilarity.validation</groupId>
+ <artifactId>trace</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <inceptionYear>2008</inceptionYear>
+ <properties>
+ <scala.version>2.8-SNAPSHOT</scala.version>
+ <scala.home>/Users/lgm/work/src/projex/biosimilarity/scala</scala.home>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </repository>
+ <repository>
+ <id>repository.codehaus.org</id>
+ <name>Codehaus</name>
+ <url>http://repository.codehaus.org/com/thoughtworks</url>
+ </repository>
+ <repository>
+ <id>mojo.codehaus.org</id>
+ <name>Codehaus-Mojo</name>
+ <url>http://repository.codehaus.org/org/codehaus/mojo</url>
+ </repository>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <id>com.eaio</id>
+ <name>eaio.com repository</name>
+ <url>http://eaio.com/maven2</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.specs</groupId>
+ <artifactId>specs</artifactId>
+ <version>1.2.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>selectivecps-library</artifactId>
+ <version>local</version>
+ </dependency>
+ <dependency>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>selectivecps-plugin</artifactId>
+ <version>local</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3_min</artifactId>
+ <version>1.1.4c</version>
+ </dependency>
+ <dependency>
+ <groupId>xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.eaio.uuid</groupId>
+ <artifactId>uuid</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <!-- Needed for schemagen -->
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <!-- Needed for schemagen -->
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <!-- Needed for schemagen -->
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jsr173_api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <version>2.0EA3</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>src/main/scala</sourceDirectory>
+ <testSourceDirectory>src/test/scala</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <scalaVersion>${scala.version}</scalaVersion>
+ <displayCmd>true</displayCmd>
+ <args>
+ <!-- arg>-target:jvm-1.5</arg -->
+ <arg>-Xplugin:${scala.home}/src/continuations/build/pack/selectivecps-plugin.jar</arg>
+ <arg>-cp</arg>
+ <arg>${scala.home}/src/continuations/build/build.library</arg>
+ </args>
+ <jvmArgs>
+ <jvmArg>-Xmx128m</jvmArg>
+ </jvmArgs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <buildcommands>
+ <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
+ </buildcommands>
+ <additionalProjectnatures>
+ <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
+ </additionalProjectnatures>
+ <classpathContainers>
+ <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
+ <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
+ </classpathContainers>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <configuration>
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
53 src/main/resources/trace.xsd
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:complexType mixed="true" name="conversationType">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="requester"/>
+ <xs:element ref="request"/>
+ <xs:element ref="waiting"/>
+ <xs:element ref="conversation"/>
+ <xs:element ref="responder"/>
+ <xs:element ref="response"/>
+ </xs:choice>
+ <xs:attributeGroup ref="attlist.conversation"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="requesterType">
+ <xs:attributeGroup ref="attlist.requester"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="responderType">
+ <xs:attributeGroup ref="attlist.responder"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="requestType">
+ <xs:attributeGroup ref="attlist.request"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="responseType">
+ <xs:attributeGroup ref="attlist.response"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="executionType">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="conversation"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="execution" type="executionType"/>
+ <xs:element name="conversation" type="conversationType"/>
+ <xs:element name="waiting" type="xs:string"/>
+ <xs:element name="requester" type="requesterType"/>
+ <xs:element name="request" type="requestType"/>
+ <xs:element name="responder" type="responderType"/>
+ <xs:element name="response" type="responseType"/>
+ <xs:attributeGroup name="attlist.requester">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.responder">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.request">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.conversation">
+ <xs:attribute name="id"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.response">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+</xs:schema>
53 src/main/resources/trace.xsd~
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+ <xs:complexType mixed="true" name="conversationType">
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="requester"/>
+ <xs:element ref="request"/>
+ <xs:element ref="waiting"/>
+ <xs:element ref="conversation"/>
+ <xs:element ref="responder"/>
+ <xs:element ref="response"/>
+ </xs:choice>
+ <xs:attributeGroup ref="attlist.conversation"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="requesterType">
+ <xs:attributeGroup ref="attlist.requester"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="responderType">
+ <xs:attributeGroup ref="attlist.responder"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="requestType">
+ <xs:attributeGroup ref="attlist.request"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="responseType">
+ <xs:attributeGroup ref="attlist.response"/>
+ </xs:complexType>
+ <xs:complexType mixed="true" name="executionType">
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="conversation"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="conversation" type="conversationType"/>
+ <xs:element name="waiting" type="xs:string"/>
+ <xs:element name="requester" type="requesterType"/>
+ <xs:element name="request" type="requestType"/>
+ <xs:element name="responder" type="responderType"/>
+ <xs:element name="response" type="responseType"/>
+ <xs:element name="execution" type="executionType"/>
+ <xs:attributeGroup name="attlist.requester">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.responder">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.request">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.conversation">
+ <xs:attribute name="id"/>
+ </xs:attributeGroup>
+ <xs:attributeGroup name="attlist.response">
+ <xs:attribute name="conversation"/>
+ </xs:attributeGroup>
+</xs:schema>
591 src/main/scala/com/biosimilarity/validation/Agent.scala
@@ -0,0 +1,591 @@
+// -*- mode: Scala;-*-
+// Filename: TheMessengers.scala
+// Authors: lgm
+// Creation: Fri Oct 16 14:23:47 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import java.net.URI
+import com.eaio.uuid.UUID
+
+import scala.collection.mutable._
+import scala.actors._
+import Actor._
+
+import com.thoughtworks.xstream._
+
+trait Socialite {
+ def name : URI
+ def requests : ListBuffer[JustifiedRequest]
+ def responses : ListBuffer[JustifiedResponse]
+ def nameSpace : Option[LinkedHashMap[URI,Socialite]]
+
+ def traceMonitor : TraceMonitor
+
+ def isJustified( request : JustifiedRequest ) : Boolean = {
+ request match {
+ case JustifiedRequest( _, _, None, _, _, _ ) => true
+ case JustifiedRequest( _, _, Some( response ), _, _, _ ) => {
+ responses.contains( response ) match {
+ case false => {
+ logError( request, UnjustifiedRequest() )
+ false
+ }
+ case true => {
+ true
+ }
+ }
+ }
+ }
+ }
+ def isJustified( response : JustifiedResponse ) : Boolean = {
+ response match {
+ case JustifiedResponse( _, _, None, _, _, _ ) => {
+ logError( response, UnjustifiedResponseNoRequest() )
+ false
+ }
+ case JustifiedResponse( _, _, Some( request ), _, _, _ ) => {
+ requests.contains( request ) match {
+ case false => {
+ logError( response, UnjustifiedResponseNoMatch() )
+ false
+ }
+ case true => {
+ true
+ }
+ }
+ }
+ }
+ }
+ def isJustified( response : InspectionRequest ) : Boolean = true
+
+ def validateTarget( msg : {def to : URI} ) : Boolean = {
+ msg.to == name
+ }
+ def validateAcquaintance( msg : {def from : URI} ) : Boolean = {
+ nameSpace match {
+ case None => false
+ case Some( map ) => {
+ map.get( msg.from ) match {
+ case None => false
+ case Some( acq ) => true
+ }
+ }
+ }
+ }
+
+ def validate( request : JustifiedRequest ) : Boolean = {
+ nameSpace match {
+ case None => {
+ logError( request, NoNamespace() )
+ false
+ }
+ case Some( map ) => {
+ ( validateAcquaintance( request ),
+ validateTarget( request ) ) match {
+ case ( false, _ ) => {
+ logError( request, UnknownRequester() )
+ false
+ }
+ case ( _, false ) => {
+ logError( request, IllTargetedRequest() )
+ false
+ }
+ case ( true, true ) => {
+ if ( isJustified( request ) ) {
+ logJustification( request )
+ true
+ }
+ else {
+ false
+ }
+ }
+ }
+ }
+ }
+ }
+
+ def validate( response : JustifiedResponse ) : Boolean = {
+ nameSpace match {
+ case None => {
+ logError( response, NoNamespace() )
+ false
+ }
+ case Some( map ) => {
+ ( validateAcquaintance( response ),
+ validateTarget( response ) ) match {
+ case ( false, _ ) => {
+ logError( response, UnknownResponder() )
+ false
+ }
+ case ( _, false ) => {
+ logError( response, IllTargetedResponse() )
+ false
+ }
+ case ( true, true ) => {
+ if ( isJustified( response ) ) {
+ logJustification( response )
+ true
+ }
+ else {
+ false
+ }
+ }
+ }
+ }
+ }
+ }
+
+ def validate( request : InspectionRequest ) : Boolean = {
+ ( validateAcquaintance( request ), validateTarget( request ) ) match {
+ case ( false, _ ) => {
+ logError( request, UnknownRequester() )
+ false
+ }
+ case ( _, false ) => {
+ logError( request, IllTargetedRequest() )
+ false
+ }
+ case ( true, true ) => {
+ if ( isJustified( request ) ) {
+ logJustification( request )
+ true
+ }
+ else {
+ throw new Exception( "should never get here" )
+ false
+ }
+ }
+ }
+ }
+
+ def handle( request : JustifiedRequest ) : Boolean = {
+ false
+ }
+ def handle( response : JustifiedResponse ) : Boolean = {
+ false
+ }
+ def handle( request : InspectRequests ) : Boolean = {
+ println( "*** Requests ***" )
+ for (req <- requests) yield {
+ println( req )
+ }
+ println( "*** Requests ***" )
+ true
+ }
+ def handle( request : InspectResponses ) : Boolean = {
+ println( "*** Responses ***" )
+ for (rsp <- responses) yield {
+ println( rsp )
+ }
+ println( "*** Responses ***" )
+ true
+ }
+ def handle( request : InspectNamespace ) : Boolean = {
+ println( "*** Namespace ***" )
+ for (pair <- nameSpace) yield {
+ println( pair )
+ }
+ println( "*** Namespace ***" )
+ true
+ }
+
+ def likes( dsg : URI, acq : Socialite ) : Boolean
+
+ def introduce( dsg : URI, acq : Socialite ) : Boolean = {
+ if ( likes( dsg, acq ) ) {
+ nameSpace match {
+ case None => {
+ logError( dsg, acq, NoNamespace() )
+ }
+ case Some( map ) => {
+ map.update( dsg, acq )
+ }
+ }
+ true
+ }
+ else { false }
+ }
+
+ // Record messages for justification
+
+ def markRequest( req : JustifiedRequest ) : Boolean = {
+ requests += req
+ true
+ }
+ def markRequest( req : InspectionRequest ) : Boolean = {
+ //requests += req
+ true
+ }
+ def markResponse( rsp : JustifiedResponse ) : Boolean = {
+ responses += rsp
+ true
+ }
+
+ // Logging
+
+ trait FauxPas
+ case class NoNamespace() extends FauxPas
+ case class IllTargetedRequest() extends FauxPas
+ case class UnjustifiedRequest() extends FauxPas
+ case class UnknownRequester() extends FauxPas
+ case class IllTargetedResponse() extends FauxPas
+ case class UnjustifiedResponseNoRequest() extends FauxPas
+ case class UnjustifiedResponseNoMatch() extends FauxPas
+ case class UnknownResponder() extends FauxPas
+
+ // Error logging
+
+ def logError(
+ request : JustifiedRequest,
+ error : NoNamespace
+ ) : Boolean = {
+ (traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "No namespace supplied!"
+ ))
+ true
+ }
+
+ def logError(
+ request : JustifiedRequest,
+ error : UnknownRequester
+ ) : Boolean = {
+ (traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "Message from unknown sender!"
+ ))
+ true
+ }
+
+ def logError(
+ request : JustifiedRequest,
+ error : IllTargetedRequest
+ ) : Boolean = {
+ (traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + "Message intended for "
+ + request.to.getFragment
+ + " sent to wrong recipient!"
+ )
+ ))
+ true
+ }
+
+ def logError(
+ request : JustifiedRequest,
+ error : UnjustifiedRequest
+ ) : Boolean = {
+ (traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + request.from.getFragment
+ + " requested "
+ + request.body
+ + " without valid justification : "
+ + request.deeper
+ )
+ ))
+ true
+ }
+
+ def logError(
+ request : JustifiedResponse,
+ error : NoNamespace
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "No namespace supplied!"
+ )
+ true
+ }
+
+ def logError(
+ response : JustifiedResponse,
+ error : UnknownResponder
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "Message from unknown sender!"
+ )
+ true
+ }
+
+ def logError(
+ response : JustifiedResponse,
+ error : IllTargetedResponse
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + "Message intended for "
+ + response.to.getFragment
+ + " sent to wrong recipient!"
+ )
+ )
+ true
+ }
+
+ def logError(
+ response : JustifiedResponse,
+ error : UnjustifiedResponseNoRequest
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + response.from.getFragment
+ + " requested "
+ + response.body
+ + " without valid justification : "
+ + response.deeper
+ )
+ )
+ true
+ }
+
+ def logError(
+ response : JustifiedResponse,
+ error : UnjustifiedResponseNoMatch
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + response.from.getFragment
+ + " requested "
+ + response.body
+ + " without valid justification : "
+ + response.deeper
+ )
+ )
+ true
+ }
+
+ def logError(
+ request : InspectionRequest,
+ error : NoNamespace
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "No namespace supplied!"
+ )
+ true
+ }
+
+ def logError(
+ dsg : URI,
+ agent : Socialite,
+ error : NoNamespace
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ dsg.getFragment + ": " + "No namespace supplied!"
+ )
+ true
+ }
+
+ def logError(
+ request : InspectionRequest,
+ error : UnknownRequester
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ name.getFragment + ": " + "Message from unknown sender!"
+ )
+ true
+ }
+
+ def logError(
+ request : InspectionRequest,
+ error : IllTargetedRequest
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + "Message intended for "
+ + request.to.getFragment
+ + " sent to wrong recipient!"
+ )
+ )
+ true
+ }
+
+ // Justification logging
+
+ def useBraceNotation : Boolean
+
+ def logJustification(
+ request : JustifiedRequest
+ ) : Boolean = {
+ if ( useBraceNotation ) {
+ traceMonitor.traceEvent(
+ this,
+ (
+ "<" + "conversation " + "id=\"" + request.color + "\">"
+ + "<requester " + "conversation=\"" + request.color + "\">"
+ + request.from.getFragment
+ + "</requester>"
+ + "<request " + "conversation=\"" + request.color + "\">"
+ + request.body
+ + "</request>"
+ )
+ )
+ }
+ else {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + request.from.getFragment
+ + " requested "
+ + request.body
+ + " justified by "
+ + (request.deeper match {
+ case None =>
+ "the right to open a conversation"
+ case x => x
+ })
+ )
+ )
+ }
+ true
+ }
+ def logJustification(
+ response : JustifiedResponse
+ ) : Boolean = {
+ if ( useBraceNotation ) {
+ traceMonitor.traceEvent(
+ this,
+ (
+ "<responder " + "conversation=\"" + response.color + "\">"
+ + response.from.getFragment
+ + "</responder>"
+ + "<response " + "conversation=\"" + response.color + "\">"
+ + response.body
+ + "</response>"
+ + "<" + "/" + "conversation" + ">"
+ )
+ )
+ }
+ else {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + response.from.getFragment
+ + " responded "
+ + response.body
+ + " justified by "
+ + (response.deeper match {
+ case None =>
+ throw new Exception( "should never get here" )
+ case x => x
+ })
+ )
+ )
+ }
+ true
+ }
+ def logJustification(
+ request : InspectionRequest
+ ) : Boolean = {
+ traceMonitor.traceEvent(
+ this,
+ (
+ name.getFragment
+ + ": "
+ + request.from.getFragment
+ + " requested "
+ + request.body
+ + " justified by "
+ + (request.deeper match {
+ case None =>
+ "the right to inspect"
+ case x => x
+ })
+ )
+ )
+ true
+ }
+}
+
+case class Messenger(
+ name : URI,
+ requests : ListBuffer[JustifiedRequest],
+ responses : ListBuffer[JustifiedResponse],
+ nameSpace : Option[LinkedHashMap[URI,Socialite]],
+ traceMonitor : TraceMonitor
+) extends Actor with Socialite {
+ override def useBraceNotation : Boolean = false
+ def likes( dsg : URI, acq : Socialite ) : Boolean = true
+ def act () {
+ nameSpace match {
+ case None => {
+ logError( name, this, NoNamespace() )
+ }
+ case Some( map ) => {
+ receive {
+ case JustifiedRequest( m, p, d, t, f, c ) => {
+ val jr = JustifiedRequest( m, p, d, t, f, c )
+ if ( validate( jr ) ) {
+ println( "calling handle on " + jr )
+ handle( jr )
+ }
+ act()
+ }
+ case JustifiedResponse( m, p, d, t, f, c ) => {
+ val jr = JustifiedResponse( m, p, d, t, f, c )
+ if ( validate( jr ) ) {
+ println( "calling handle on " + jr )
+ handle( jr )
+ }
+ act()
+ }
+ case InspectRequests( t, f ) => {
+ val ir = InspectRequests( t, f )
+ if ( validate( ir ) ) {
+ println( "calling handle on " + ir )
+ handle( ir )
+ }
+ act()
+ }
+ case InspectResponses( t, f ) => {
+ val ir = InspectResponses( t, f )
+ if ( validate( ir ) ) {
+ println( "calling handle on " + ir )
+ handle( ir )
+ }
+ act()
+ }
+ case InspectNamespace( t, f ) => {
+ val ir = InspectNamespace( t, f )
+ if ( validate( ir ) ) {
+ println( "calling handle on " + ir )
+ handle( ir )
+ }
+ act()
+ }
+ }
+ }
+ }
+ }
+}
+
+
93 src/main/scala/com/biosimilarity/validation/Message.scala
@@ -0,0 +1,93 @@
+// -*- mode: Scala;-*-
+// Filename: TheMessage.scala
+// Authors: lgm
+// Creation: Fri Oct 16 14:18:12 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import java.net.URI
+import com.eaio.uuid.UUID
+
+trait Message[Justfication] {
+ def magic : Int
+ def body : String
+ def deeper : Option[Justfication]
+ def to : URI
+ def from : URI
+ def color : UUID
+}
+
+abstract class Request[Response](
+ magic : Int,
+ body : String,
+ deeper : Option[Response],
+ to : URI,
+ from : URI,
+ color : UUID
+) extends Message[Response]
+
+trait InspectionRequest extends Message[Unit] {
+ val color : UUID = new UUID()
+}
+
+case class JustifiedRequest(
+ magic : Int,
+ body : String,
+ deeper : Option[Response[JustifiedRequest]],
+ to : URI,
+ from : URI,
+ color : UUID
+) extends Request[Response[JustifiedRequest]](
+ magic, body, deeper, to, from, color
+)
+
+case class InspectRequests( to : URI, from : URI )
+ extends InspectionRequest {
+ override def magic = 1001
+ override def body = "InspectRequests"
+ override def deeper = None
+ }
+
+case class InspectResponses( to : URI, from : URI )
+ extends InspectionRequest {
+ override def magic = 1002
+ override def body = "InspectResponses"
+ override def deeper = None
+ }
+
+case class InspectNamespace( to : URI, from : URI )
+ extends InspectionRequest {
+ override def magic = 1003
+ override def body = "InspectNamespace"
+ override def deeper = None
+ }
+
+abstract class Response[Request](
+ magic : Int,
+ body : String,
+ deeper : Option[Request],
+ to : URI,
+ from : URI,
+ color : UUID
+) extends Message[Request]
+
+trait InspectionResponse[Request] extends Message[Request]
+
+case class JustifiedResponse(
+ magic : Int,
+ body : String,
+ deeper : Option[Request[JustifiedResponse]],
+ to : URI,
+ from : URI,
+ color : UUID
+) extends Response[Request[JustifiedResponse]](
+ magic, body, deeper, to, from, color
+)
+
+
+
+
+
181 src/main/scala/com/biosimilarity/validation/TraceMonitor.scala
@@ -0,0 +1,181 @@
+// -*- mode: Scala;-*-
+// Filename: TheScribe.scala
+// Authors: lgm
+// Creation: Mon Oct 19 01:28:27 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import scala.collection.mutable._
+import scala.xml._
+import scala.actors._
+import Actor._
+
+trait LogAction
+trait Report {
+ def agent : Socialite
+ def message : String
+}
+case class TraceEvent( agent : Socialite, msg : String )
+ extends LogAction with Report {
+ override def message = msg
+ }
+case class TraceXmlEvent( agent : Socialite, msg : Elem )
+ extends LogAction with Report {
+ override def message = msg.toString
+ }
+case class ShowLog() extends LogAction
+
+trait SessionStatus
+case class OpenSession( agent : Socialite )
+ extends LogAction with SessionStatus
+case class CloseSession( agent : Socialite )
+ extends LogAction with SessionStatus
+
+trait DebuggingLevel
+case class Naked() extends DebuggingLevel
+case class FullyClothed() extends DebuggingLevel
+
+class TraceMonitor extends Actor {
+ var debuggingLevel : DebuggingLevel = Naked()
+ //var debuggingLevel : DebuggingLevel = FullyClothed()
+ val sessions : LinkedHashMap[Socialite,SessionStatus] =
+ new LinkedHashMap[Socialite,SessionStatus]()
+ val messageLog : ListBuffer[Report] =
+ new ListBuffer[Report]()
+
+ def dumpLogToString : String =
+ dumpLogToWriter( new java.io.StringWriter() )
+ def dumpLogToXML : Sequence[Node] = {
+ messageLog.map(
+ {
+ case TraceEvent( a, s ) => {
+ <entry>{s}</entry>
+ }
+ }
+ )
+ }
+ def dumpLogToWriter( sw : java.io.StringWriter ) : String = {
+ messageLog.map( { case TraceEvent( a, s ) => sw.write( s ) } )
+ sw.toString()
+ }
+ def showLog() : Unit = {
+ println(
+ preamble + dumpLogToString + postScript
+ )
+ }
+ def getFinalLog() : String = {
+ while ( inSession ) {
+ Thread.sleep( 500 )
+ }
+ preamble + dumpLogToString + postScript
+ }
+
+ def sessionStatus( agent : Socialite ) : Option[SessionStatus] = {
+ sessions.get( agent )
+ }
+ def openMonitoringSession( agent : Socialite ) : OpenSession = {
+ sessions.get( agent ) match {
+ case Some( agent ) => {
+ throw new Exception( "already in session" )
+ }
+ case None => {
+ val session = OpenSession( agent )
+ sessions.update( agent, session )
+ session
+ }
+ }
+ }
+ def closeMonitoringSession( agent : Socialite ) : CloseSession = {
+ sessions.get( agent ) match {
+ case Some( session ) => {
+ val session = CloseSession( agent )
+ sessions.update( agent, session )
+ session
+ }
+ case None => {
+ throw new Exception( "Not in session" )
+ }
+ }
+ }
+
+ def inSession : Boolean = {
+ ( false /: sessions.values )(
+ { ( acc, session ) => {
+ session match {
+ case CloseSession( _ ) => acc
+ case OpenSession( _ ) => true
+ }
+ }
+ }
+ )
+ }
+
+ def traceEvent( agent : Socialite, msg : String ) : Unit = {
+ traceEvent( TraceEvent( agent, msg ) )
+ }
+
+ def traceEvent( report : Report ) : Unit = {
+ debuggingLevel match {
+ case Naked() => {
+ println( "logging event to console: " + report.message )
+ }
+ }
+ sessions.get( report.agent ) match {
+ case Some( OpenSession( a ) ) => {
+ messageLog += report
+ }
+ case Some( CloseSession( a ) ) => {
+ throw new Exception( "Monitoring against a closed session!" )
+ }
+ case None => {
+ throw new Exception( "Monitoring without opening a session" )
+ }
+ }
+ }
+
+ def preamble : String = {
+ //"<execution xmlns=\"http://conversation.biosimilarity.com/validate/0.0.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://conversation.biosimilarity.com/validate/0.0.1 http://conversation.biosimilarity.com/validate-v0_0_0.xsd\">"
+ "<execution>"
+ }
+ def postScript : String = {
+ "</execution>"
+ }
+ def xmlContainer : Elem = {
+ <execution xmlns="http://conversation.biosimilarity.com/validate/0.0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://conversation.biosimilarity.com/validate/0.0.1 http://conversation.biosimilarity.com/validate-v0_0_0.xsd">
+ {dumpLogToXML}:_*
+ </execution>
+ }
+
+ // Be very careful with this interface. Essentially all interaction
+ // with a monitor must be a transaction/function-call. Otherwise,
+ // you will encounter surprising race conditions.
+ def act () {
+ receive {
+ case OpenSession( agent ) => {
+ openMonitoringSession( agent )
+ act()
+ }
+ case CloseSession( agent ) => {
+ closeMonitoringSession( agent )
+ act()
+ }
+ case TraceEvent( agent, msg ) => {
+ traceEvent( TraceEvent( agent, msg ) )
+ act()
+ }
+ case TraceXmlEvent( agent, msg ) => {
+ traceEvent( TraceXmlEvent( agent, msg ) )
+ act()
+ }
+ case ShowLog() => {
+ showLog()
+ act()
+ }
+ }
+ }
+}
+
+object ATraceMonitor extends TraceMonitor
66 src/main/scala/com/biosimilarity/validation/TraceValidator.scala
@@ -0,0 +1,66 @@
+// -*- mode: Scala;-*-
+// Filename: TraceValidator.scala
+// Authors: lgm
+// Creation: Tue Oct 20 14:42:45 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import java.net.URI
+import java.net.URL
+import java.io._
+import javax.xml.transform.Source
+import javax.xml.transform.stream.StreamSource
+import javax.xml.validation._
+import org.xml.sax.SAXException
+
+import com.eaio.uuid.UUID
+
+trait TraceValidation {
+ def validateTrace( property : String, trace : String ) : Boolean = {
+
+ // 1. Lookup a factory for the W3C XML Schema language
+ val factory : SchemaFactory =
+ SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema")
+
+ // 2. Compile the schema.
+ // Here the schema is loaded from a java.io.File, but you could use
+ // a java.net.URL or a javax.xml.transform.Source instead.
+ val schemaLocation : File = new File( property )
+ val schema : Schema = factory.newSchema( schemaLocation )
+
+ // 3. Get a validator from the schema.
+ val validator : Validator = schema.newValidator()
+
+ // 4. Parse the document you want to check.
+ val source : Source = new StreamSource( new StringReader( trace ) )
+
+ // 5. Check the document
+ try {
+ validator.validate( source )
+ //println( trace + " is valid.")
+ true
+ }
+ catch {
+ case ex : SAXException => {
+ println( trace + " is not valid because ")
+ println( ex.getMessage() )
+ false
+ }
+ }
+
+ }
+
+}
+
+class TraceValidator( monitor : TraceMonitor )
+extends TraceValidation
+{
+ def validate( property : String ) : Boolean = {
+ validateTrace( property, monitor.getFinalLog )
+ }
+}
+
+case object ATraceValidator extends TraceValidator( ATraceMonitor )
457 src/main/scala/com/biosimilarity/validation/Wizard.scala
@@ -0,0 +1,457 @@
+// -*- mode: Scala;-*-
+// Filename: Wizard.scala
+// Authors: lgm
+// Creation: Mon Oct 19 13:15:47 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import java.net.URI
+import com.eaio.uuid.UUID
+
+import scala.collection.mutable._
+import scala.actors._
+import Actor._
+
+import com.thoughtworks.xstream._
+
+object Cabal {
+ // Identities
+ val harrysName : URI =
+ new URI( "wizard", "Hogwarts", "Harry" )
+ val ronsName : URI =
+ new URI( "wizard", "Hogwarts", "Ron" )
+ val hermionesName : URI =
+ new URI( "wizard", "Hogwarts", "Herminone" )
+ val dracosName : URI =
+ new URI( "wizard", "Hogwarts", "Draco" )
+
+ // Conversations
+ val attraction : UUID = new UUID()
+ val friendship : UUID = new UUID()
+ val magicalAttack : UUID = new UUID()
+ val magicalAttackTwo : UUID = new UUID()
+ val magicalDefense : UUID = new UUID()
+ val magicalDefenseTwo : UUID = new UUID()
+
+ // Messages
+
+ val pickUpLine : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "chocolateFrog?",
+ None,
+ hermionesName,
+ ronsName,
+ attraction
+ )
+ val friendlyOverture : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "bean?",
+ None,
+ hermionesName,
+ harrysName,
+ friendship
+ )
+ val expelliarmus : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "expelliarmus",
+ None,
+ dracosName,
+ harrysName,
+ magicalDefense
+ )
+// val expectoPatronum : JustifiedRequest =
+// JustifiedRequest( 0, "expectoPatronum", None, dracosName, harrysName )
+ val confundo : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "confundo",
+ None,
+ harrysName,
+ dracosName,
+ magicalAttack
+ )
+ val impedimenta : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "impedimenta",
+ None,
+ ronsName,
+ harrysName,
+ magicalAttackTwo
+ )
+ val finiteIncantatem : JustifiedResponse =
+ JustifiedResponse(
+ 0,
+ "finiteIncantatem",
+ Some( expelliarmus.asInstanceOf[Request[JustifiedResponse]] ),
+ harrysName,
+ dracosName,
+ magicalDefenseTwo
+ )
+
+ val flirt : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "chocolateFrog!",
+ Some( pickUpLine.asInstanceOf[Request[JustifiedResponse]] ),
+ ronsName,
+ hermionesName,
+ attraction
+ )
+ val friendlyResponse : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "bean.",
+ Some( friendlyOverture.asInstanceOf[Request[JustifiedResponse]] ),
+ harrysName,
+ hermionesName,
+ friendship
+ )
+
+ case object MessengerOne
+ extends Messenger(
+ harrysName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ val responsesReceived : ListBuffer[JustifiedResponse] =
+ new ListBuffer[JustifiedResponse]()
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( friendlyOverture )
+ MessengerThree ! friendlyOverture
+ markRequest( expelliarmus )
+ MessengerFour ! expelliarmus
+ }
+ override def handle( response : JustifiedResponse ) = {
+ //println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ mgc, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ //println( "matched response case!" )
+ respondersName.getFragment match {
+ case "Ron" => {
+ //println( "matched Ron case!" )
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerOne )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "matched Herminone case!" )
+ //println( "closing monitor session" )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ responsesReceived.length match {
+ case 1 => {
+ responsesReceived += response
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case _ => {
+ responsesReceived += response
+ // traceMonitor.traceEvent(
+// this,
+// "<waiting>Draco " + responses.length + "</waiting>"
+// )
+ }
+ }
+ }
+ case "Draco" => {
+ //println( "matched Draco case!" )
+ //throw new Exception( "shouldn't get here!" )
+ responsesReceived.length match {
+ case 1 => {
+ responsesReceived += response
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case _ => {
+ responsesReceived += response
+ // traceMonitor.traceEvent(
+// this,
+// "<waiting>Hermione " + responses.length + "</waiting>"
+// )
+ }
+ }
+ }
+ case x => {
+ //println( "unexpected name" + x )
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => {
+ //println( "matched exception case!" )
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerTwo
+ extends Messenger(
+ ronsName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( pickUpLine )
+ MessengerThree ! pickUpLine
+ }
+ override def handle( response : JustifiedResponse ) = {
+ //println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ mgc, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ respondersName.getFragment match {
+ case "Harry" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerTwo )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Draco" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => {
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerThree
+ extends Messenger(
+ hermionesName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( request : JustifiedRequest ) = {
+ //println( "handling: " + request )
+ request match {
+ case JustifiedRequest(
+ 0, content, None,
+ _,
+ suitorsName,
+ color
+ ) => {
+ suitorsName.getFragment match {
+ case "Ron" => {
+ //println( "case Ron" )
+ markResponse( flirt )
+ MessengerTwo ! flirt
+ responses.length match {
+ case 2 => {
+ // traceMonitor ! CloseSession( MessengerThree )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Harry " + responses.length + "</waiting>"
+ )
+ }
+ }
+ }
+ case "Harry" => {
+ //println( "case Harry" )
+ markResponse( friendlyResponse )
+ MessengerOne ! friendlyResponse
+ responses.length match {
+ case 2 => {
+ //traceMonitor ! CloseSession( MessengerThree )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Ron " + responses.length + "</waiting>"
+ )
+ }
+ }
+ }
+ }
+ }
+ case _ => {
+ //println( "case got some other kind of message" )
+ throw new Exception( "That's no way to talk to a witch!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerFour
+ extends Messenger(
+ dracosName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( request : JustifiedRequest ) = {
+ println( "handling: " + request )
+ request match {
+ case JustifiedRequest(
+ mgc, content, None,
+ _,
+ requestersName,
+ color
+ ) => {
+ requestersName.getFragment match {
+ case "Harry" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ println( "matched Harry case" )
+ markResponse( finiteIncantatem )
+ MessengerOne ! finiteIncantatem
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Herminone" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Ron" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ }
+ }
+ case _ => {
+ //println( "Draco exception case" )
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ def hookup() = {
+ // MessengerOne learns his name is Harry
+ MessengerOne.introduce( harrysName, MessengerOne )
+ // Harry is introduced to MessengerTwo known as Ron
+ MessengerOne.introduce( ronsName, MessengerTwo )
+ // Harry is introduced to MessengerThree known as Herminone
+ MessengerOne.introduce( hermionesName, MessengerThree )
+ // Harry is introduced to MessengerFour known as Draco
+ MessengerOne.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerOne )
+
+ // MessengerTwo learns his name is Ron
+ MessengerTwo.introduce( ronsName, MessengerTwo )
+ // Ron is introduced to MessengerOne known as Harry
+ MessengerTwo.introduce( harrysName, MessengerOne )
+ // Ron is introduced to MessengerThree known as Herminone
+ MessengerTwo.introduce( hermionesName, MessengerThree )
+ // Ron is introduced to MessengerFour known as Draco
+ MessengerTwo.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerTwo )
+
+ // MessengerThree learns her name is Hermione
+ MessengerThree.introduce( hermionesName, MessengerThree )
+ // Hermione is introduced to MessengerOne known as Harry
+ MessengerThree.introduce( harrysName, MessengerOne )
+ // Hermione is introduced to MessengerTwo known as Ron
+ MessengerThree.introduce( ronsName, MessengerTwo )
+ // Hermione is introduced to MessengerFour known as Draco
+ MessengerThree.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerThree )
+
+ // MessengerFour learns his name is Draco
+ MessengerFour.introduce( dracosName, MessengerFour )
+ // Draco is introduced to MessengerOne known as Harry
+ MessengerFour.introduce( harrysName, MessengerOne )
+ // Draco is introduced to MessengerTwo known as Ron
+ MessengerFour.introduce( ronsName, MessengerTwo )
+ // Draco is introduced to MessengerThree known as Hermione
+ MessengerFour.introduce( hermionesName, MessengerThree )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerFour )
+ }
+
+ def activate() = {
+ MessengerOne.start
+ MessengerTwo.start
+ MessengerThree.start
+ MessengerFour.start
+ ATraceMonitor.start
+ }
+
+ def mix() = {
+ MessengerOne.script()
+ MessengerTwo.script()
+ MessengerThree.script()
+ MessengerFour.script()
+ // traceMonitor ! ShowLog()
+ }
+}
+
+
+
+
451 src/test/scala/com/biosimilarity/validation/Wizard.scala
@@ -0,0 +1,451 @@
+// -*- mode: Scala;-*-
+// Filename: Wizard.scala
+// Authors: lgm
+// Creation: Mon Oct 19 13:15:47 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation
+
+import org.junit._
+import Assert._
+
+import java.net.URI
+import com.eaio.uuid.UUID
+
+import scala.collection.mutable._
+import scala.actors._
+import Actor._
+
+import com.thoughtworks.xstream._
+
+object Coven {
+ // Identities
+ val harrysName : URI =
+ new URI( "wizard", "Hogwarts", "Harry" )
+ val ronsName : URI =
+ new URI( "wizard", "Hogwarts", "Ron" )
+ val hermionesName : URI =
+ new URI( "wizard", "Hogwarts", "Herminone" )
+ val dracosName : URI =
+ new URI( "wizard", "Hogwarts", "Draco" )
+
+ // Conversations
+ val attraction : UUID = new UUID()
+ val friendship : UUID = new UUID()
+ val magicalAttack : UUID = new UUID()
+ val magicalAttackTwo : UUID = new UUID()
+ val magicalDefense : UUID = new UUID()
+ val magicalDefenseTwo : UUID = new UUID()
+
+ // Messages
+
+ val pickUpLine : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "chocolateFrog?",
+ None,
+ hermionesName,
+ ronsName,
+ attraction
+ )
+ val friendlyOverture : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "bean?",
+ None,
+ hermionesName,
+ harrysName,
+ friendship
+ )
+ val expelliarmus : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "expelliarmus",
+ None,
+ dracosName,
+ harrysName,
+ magicalDefense
+ )
+// val expectoPatronum : JustifiedRequest =
+// JustifiedRequest( 0, "expectoPatronum", None, dracosName, harrysName )
+ val confundo : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "confundo",
+ None,
+ harrysName,
+ dracosName,
+ magicalAttack
+ )
+ val impedimenta : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "impedimenta",
+ None,
+ ronsName,
+ harrysName,
+ magicalAttackTwo
+ )
+ val finiteIncantatem : JustifiedResponse =
+ JustifiedResponse(
+ 0,
+ "finiteIncantatem",
+ None,
+ ronsName,
+ harrysName,
+ magicalDefenseTwo
+ )
+
+ val flirt : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "chocolateFrog!",
+ Some( pickUpLine.asInstanceOf[Request[JustifiedResponse]] ),
+ ronsName,
+ hermionesName,
+ attraction
+ )
+ val friendlyResponse : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "bean.",
+ Some( friendlyOverture.asInstanceOf[Request[JustifiedResponse]] ),
+ harrysName,
+ hermionesName,
+ friendship
+ )
+
+ case object MessengerOne
+ extends Messenger(
+ harrysName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( friendlyOverture )
+ MessengerThree ! friendlyOverture
+ markRequest( expelliarmus )
+ MessengerFour ! expelliarmus
+ }
+ override def handle( response : JustifiedResponse ) = {
+ //println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ mgc, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ //println( "matched response case!" )
+ respondersName.getFragment match {
+ case "Ron" => {
+ //println( "matched Ron case!" )
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerOne )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "matched Herminone case!" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Draco" => {
+ //println( "matched Draco case!" )
+ throw new Exception( "shouldn't get here!" )
+ }
+ case x => {
+ //println( "unexpected name" + x )
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => {
+ //println( "matched exception case!" )
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerTwo
+ extends Messenger(
+ ronsName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( pickUpLine )
+ MessengerThree ! pickUpLine
+ }
+ override def handle( response : JustifiedResponse ) = {
+ //println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ mgc, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ respondersName.getFragment match {
+ case "Harry" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerTwo )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Draco" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => {
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerThree
+ extends Messenger(
+ hermionesName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( request : JustifiedRequest ) = {
+ //println( "handling: " + request )
+ request match {
+ case JustifiedRequest(
+ 0, content, None,
+ _,
+ suitorsName,
+ color
+ ) => {
+ suitorsName.getFragment match {
+ case "Ron" => {
+ //println( "case Ron" )
+ markResponse( flirt )
+ MessengerTwo ! flirt
+ responses.length match {
+ case 2 => {
+ // traceMonitor ! CloseSession( MessengerThree )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Harry " + responses.length + "</waiting>"
+ )
+ }
+ }
+ }
+ case "Harry" => {
+ //println( "case Harry" )
+ markResponse( friendlyResponse )
+ MessengerOne ! friendlyResponse
+ responses.length match {
+ case 2 => {
+ //traceMonitor ! CloseSession( MessengerThree )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Ron " + responses.length + "</waiting>"
+ )
+ }
+ }
+ }
+ }
+ }
+ case _ => {
+ //println( "case got some other kind of message" )
+ throw new Exception( "That's no way to talk to a witch!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerFour
+ extends Messenger(
+ dracosName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( request : JustifiedRequest ) = {
+ //println( "handling: " + request )
+ request match {
+ case JustifiedRequest(
+ mgc, content, None,
+ _,
+ requestersName,
+ color
+ ) => {
+ requestersName.getFragment match {
+ case "Harry" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Herminone" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ case "Ron" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ //println( "closing monitor session" )
+ traceMonitor.closeMonitoringSession( this )
+ // println(
+// "session status : " + traceMonitor.sessionStatus( this )
+// )
+ }
+ }
+ }
+ case _ => {
+ //println( "Draco exception case" )
+ throw new Exception( "That's no way to talk to a wizard!" )
+ }
+ }
+ true
+ }
+ }
+
+ def hookup() = {
+ // MessengerOne learns his name is Harry
+ MessengerOne.introduce( harrysName, MessengerOne )
+ // Harry is introduced to MessengerTwo known as Ron
+ MessengerOne.introduce( ronsName, MessengerTwo )
+ // Harry is introduced to MessengerThree known as Herminone
+ MessengerOne.introduce( hermionesName, MessengerThree )
+ // Harry is introduced to MessengerFour known as Draco
+ MessengerOne.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerOne )
+
+ // MessengerTwo learns his name is Ron
+ MessengerTwo.introduce( ronsName, MessengerTwo )
+ // Ron is introduced to MessengerOne known as Harry
+ MessengerTwo.introduce( harrysName, MessengerOne )
+ // Ron is introduced to MessengerThree known as Herminone
+ MessengerTwo.introduce( hermionesName, MessengerThree )
+ // Ron is introduced to MessengerFour known as Draco
+ MessengerTwo.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerTwo )
+
+ // MessengerThree learns her name is Hermione
+ MessengerThree.introduce( hermionesName, MessengerThree )
+ // Hermione is introduced to MessengerOne known as Harry
+ MessengerThree.introduce( harrysName, MessengerOne )
+ // Hermione is introduced to MessengerTwo known as Ron
+ MessengerThree.introduce( ronsName, MessengerTwo )
+ // Hermione is introduced to MessengerFour known as Draco
+ MessengerThree.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerThree )
+
+ // MessengerFour learns his name is Draco
+ MessengerFour.introduce( dracosName, MessengerFour )
+ // Draco is introduced to MessengerOne known as Harry
+ MessengerFour.introduce( harrysName, MessengerOne )
+ // Draco is introduced to MessengerTwo known as Ron
+ MessengerFour.introduce( ronsName, MessengerTwo )
+ // Draco is introduced to MessengerThree known as Hermione
+ MessengerFour.introduce( hermionesName, MessengerThree )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerFour )
+ }
+
+ def activate() = {
+ MessengerOne.start
+ MessengerTwo.start
+ MessengerThree.start
+ MessengerFour.start
+ ATraceMonitor.start
+ }
+
+ def mix() = {
+ MessengerOne.script()
+ MessengerTwo.script()
+ MessengerThree.script()
+ MessengerFour.script()
+ // traceMonitor ! ShowLog()
+ }
+}
+
+@Test
+class TraceTest {
+ val expectedFinalLogString : String =
+ "<execution xmlns=\"http://conversation.biosimilarity.com/validate/0.0.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://conversation.biosimilarity.com/validate/0.0.1 http://conversation.biosimilarity.com/validate-v0_0_0.xsd\"><conversation id=\"f7d43d34-bddc-11de-b344-001f5bf23e38\"><requester conversation=\"f7d43d34-bddc-11de-b344-001f5bf23e38\">Harry</requester><request conversation=\"f7d43d34-bddc-11de-b344-001f5bf23e38\">expelliarmus</request><conversation id=\"f7d43d31-bddc-11de-b344-001f5bf23e38\"><requester conversation=\"f7d43d31-bddc-11de-b344-001f5bf23e38\">Harry</requester><request conversation=\"f7d43d31-bddc-11de-b344-001f5bf23e38\">bean?</request><waiting>Ron 1</waiting><conversation id=\"f7d43d30-bddc-11de-b344-001f5bf23e38\"><requester conversation=\"f7d43d30-bddc-11de-b344-001f5bf23e38\">Ron</requester><request conversation=\"f7d43d30-bddc-11de-b344-001f5bf23e38\">chocolateFrog?</request><responder conversation=\"f7d43d30-bddc-11de-b344-001f5bf23e38\">Herminone</responder><response conversation=\"f7d43d30-bddc-11de-b344-001f5bf23e38\">chocolateFrog!</response></conversation><responder conversation=\"f7d43d31-bddc-11de-b344-001f5bf23e38\">Herminone</responder><response conversation=\"f7d43d31-bddc-11de-b344-001f5bf23e38\">bean.</response></conversation></execution>"
+
+ @Test
+ def testTracing() = {
+ Coven.hookup()
+ Coven.activate()
+ Coven.mix()
+ val actualFinalLogString : String =
+ ATraceMonitor.getFinalLog()
+ println( "final log:" )
+ println( actualFinalLogString )
+ assertTrue(true)
+ }
+
+// @Test
+// def testKO() = assertTrue(false)
+
+}
+
+
397 src/test/scala/com/biosimilarity/validation/Wizard.scala~
@@ -0,0 +1,397 @@
+// -*- mode: Scala;-*-
+// Filename: Wizard.scala
+// Authors: lgm
+// Creation: Mon Oct 19 13:15:47 2009
+// Copyright: Not supplied
+// Description:
+// ------------------------------------------------------------------------
+
+package com.biosimilarity.validation.test
+
+import org.junit._
+import Assert._
+
+import java.net.URI
+import com.eaio.uuid.UUID
+
+import scala.collection.mutable._
+import scala.actors._
+import Actor._
+
+import com.thoughtworks.xstream._
+
+object Coven {
+ // Identities
+ val harrysName : URI =
+ new URI( "wizard", "Hogwarts", "Harry" )
+ val ronsName : URI =
+ new URI( "wizard", "Hogwarts", "Ron" )
+ val hermionesName : URI =
+ new URI( "wizard", "Hogwarts", "Herminone" )
+ val dracosName : URI =
+ new URI( "wizard", "Hogwarts", "Draco" )
+
+ // Conversations
+ val attraction : UUID = new UUID()
+ val friendship : UUID = new UUID()
+ val magicalAttack : UUID = new UUID()
+ val magicalAttackTwo : UUID = new UUID()
+ val magicalDefense : UUID = new UUID()
+ val magicalDefenseTwo : UUID = new UUID()
+
+ // Messages
+
+ val pickUpLine : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "chocolateFrog?",
+ None,
+ hermionesName,
+ ronsName,
+ attraction
+ )
+ val friendlyOverture : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "bean?",
+ None,
+ hermionesName,
+ harrysName,
+ friendship
+ )
+ val expelliarmus : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "expelliarmus",
+ None,
+ dracosName,
+ harrysName,
+ magicalDefense
+ )
+// val expectoPatronum : JustifiedRequest =
+// JustifiedRequest( 0, "expectoPatronum", None, dracosName, harrysName )
+ val confundo : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "confundo",
+ None,
+ harrysName,
+ dracosName,
+ magicalAttack
+ )
+ val impedimenta : JustifiedRequest =
+ JustifiedRequest(
+ 0,
+ "impedimenta",
+ None,
+ ronsName,
+ harrysName,
+ magicalAttackTwo
+ )
+ val finiteIncantatem : JustifiedResponse =
+ JustifiedResponse(
+ 0,
+ "finiteIncantatem",
+ None,
+ ronsName,
+ harrysName,
+ magicalDefenseTwo
+ )
+
+ val flirt : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "chocolateFrog!",
+ Some( pickUpLine.asInstanceOf[Request[JustifiedResponse]] ),
+ ronsName,
+ hermionesName,
+ attraction
+ )
+ val friendlyResponse : JustifiedResponse =
+ JustifiedResponse(
+ 1,
+ "bean.",
+ Some( friendlyOverture.asInstanceOf[Request[JustifiedResponse]] ),
+ harrysName,
+ hermionesName,
+ friendship
+ )
+
+ case object MessengerOne
+ extends Messenger(
+ harrysName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( friendlyOverture )
+ MessengerThree ! friendlyOverture
+ }
+ override def handle( response : JustifiedResponse ) = {
+ println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ 0, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ respondersName.getFragment match {
+ case "Ron" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerOne )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case "Draco" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => throw new Exception( "That's no way to talk to a witch!" )
+ }
+ true
+ }
+ }
+
+ case object MessengerTwo
+ extends Messenger(
+ ronsName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ markRequest( pickUpLine )
+ MessengerThree ! pickUpLine
+ }
+ override def handle( response : JustifiedResponse ) = {
+ println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ 0, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ respondersName.getFragment match {
+ case "Harry" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ case "Herminone" => {
+ // traceMonitor ! CloseSession( MessengerTwo )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case "Draco" => {
+ throw new Exception( "shouldn't get here!" )
+ }
+ }
+ }
+ case _ => throw new Exception( "That's no way to talk to a witch!" )
+ }
+ true
+ }
+ }
+
+ case object MessengerThree
+ extends Messenger(
+ hermionesName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( request : JustifiedRequest ) = {
+ println( "handling: " + request )
+ request match {
+ case JustifiedRequest(
+ 0, content, None,
+ _,
+ suitorsName,
+ color
+ ) => {
+ suitorsName.getFragment match {
+ case "Ron" => {
+ println( "case Ron" )
+ markResponse( flirt )
+ MessengerTwo ! flirt
+ requests.length match {
+ case 2 => {
+ // traceMonitor ! CloseSession( MessengerThree )
+ // traceMonitor ! LogMessage( this, "Should close log" )
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Harry</waiting>"
+ )
+ }
+ }
+ }
+ case "Harry" => {
+ println( "case Harry" )
+ markResponse( friendlyResponse )
+ MessengerOne ! friendlyResponse
+ requests.length match {
+ case 2 => {
+ //traceMonitor ! CloseSession( MessengerThree )
+ //traceMonitor.traceEvent( this, "Should close log" )
+ traceMonitor.closeMonitoringSession( this )
+ }
+ case _ => {
+ traceMonitor.traceEvent(
+ this,
+ "<waiting>Ron</waiting>"
+ )
+ }
+ }
+ }
+ }
+ }
+ case _ => {
+ println( "case got some other kind of message" )
+ throw new Exception( "That's no way to talk to a witch!" )
+ }
+ }
+ true
+ }
+ }
+
+ case object MessengerFour
+ extends Messenger(
+ dracosName,
+ new ListBuffer[JustifiedRequest](),
+ new ListBuffer[JustifiedResponse](),
+ Some( new LinkedHashMap[URI,Socialite]() ),
+ ATraceMonitor
+ ) {
+ override def useBraceNotation : Boolean = true
+ def script() = {
+ //markRequest( pickUpLine )
+ //MessengerThree ! pickUpLine
+ }
+ override def handle( response : JustifiedResponse ) = {
+ println( "handling: " + response )
+ response match {
+ case JustifiedResponse(
+ 0, content, Some( req ),
+ _,
+ respondersName,
+ color
+ ) => {
+ respondersName.getFragment match {
+ case "Harry" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ traceMonitor.traceEvent( this, "Should close log" )
+ }
+ case "Herminone" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ traceMonitor.traceEvent( this, "Should close log" )
+ }
+ case "Ron" => {
+ //traceMonitor ! CloseSession( MessengerFour )
+ traceMonitor.traceEvent( this, "Should close log" )
+ }
+ }
+ }
+ case _ => throw new Exception( "That's no way to talk to a witch!" )
+ }
+ true
+ }
+ }
+
+ def hookup() = {
+ // MessengerOne learns his name is Harry
+ MessengerOne.introduce( harrysName, MessengerOne )
+ // Harry is introduced to MessengerTwo known as Ron
+ MessengerOne.introduce( ronsName, MessengerTwo )
+ // Harry is introduced to MessengerThree known as Herminone
+ MessengerOne.introduce( hermionesName, MessengerThree )
+ // Harry is introduced to MessengerFour known as Draco
+ MessengerOne.introduce( dracosName, MessengerFour )
+ // Connect to log
+ ATraceMonitor.openMonitoringSession( MessengerOne )
+