Author: objectiser
Date: 2011-01-27 18:06:35 -0500 (Thu, 27 Jan 2011)
New Revision: 630
Added:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorResult.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DescriptionCache.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/MessageCriteria.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolId.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolUnknownException.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/ProtocolRepository.java
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/impl/
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/impl/InMemoryProtocolRepository.java
Removed:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolId.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolRepository.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolUnknownException.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMessage.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryProtocolRepository.java
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/META-INF/MANIFEST.MF
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/src/main/java/org/savara/monitor/sstore/rdbms/RDBMSSessionStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF
branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml
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/SessionStore.java
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/InMemorySessionStore.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/DefaultMonitorTest.java
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java
branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF
Log:
Restructuring the extract the repository API into the org.savara.protocol bundle to enable
it to be used in contexts other than monitoring.
Modified: 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 2011-01-27
20:48:24 UTC (rev 629)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/META-INF/MANIFEST.MF 2011-01-27
23:06:35 UTC (rev 630)
@@ -9,6 +9,8 @@
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: org.scribble.protocol.monitor,
org.junit,
- org.savara.common
+ org.savara.common,
+ org.scribble.protocol.export.monitor,
+ org.savara.protocol
Export-Package: org.savara.monitor,
org.savara.monitor.impl
Modified: branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml 2011-01-27 20:48:24 UTC
(rev 629)
+++ branches/experimental/2.0.x/bundles/org.savara.monitor/pom.xml 2011-01-27 23:06:35 UTC
(rev 630)
@@ -30,10 +30,20 @@
<version>${scribble.version}</version>
</dependency>
<dependency>
+ <groupId>org.scribble.bundles</groupId>
+ <artifactId>org.scribble.protocol.export.monitor</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.savara.bundles</groupId>
+ <artifactId>org.savara.protocol</artifactId>
+ <version>${savara.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
Modified:
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 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Message.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -21,6 +21,117 @@
* This class represents a message to be monitored.
*
*/
-public interface Message extends org.scribble.protocol.monitor.Message {
+public class Message extends org.scribble.protocol.monitor.DefaultMessage {
+ //implements org.savara.protocol.MessageCriteria {
+ private String m_endpointAddress=null;
+ private String m_endpointType=null;
+ private Style m_style=Style.Request;
+ private Direction m_direction=Direction.Outbound;
+
+ /**
+ * This method provides the endpoint address of the component that
+ * is the subject of the interaction.
+ *
+ * If not specified, then the endpoint type must be defined.
+ *
+ * @return The endpoint address, or null if not known
+ */
+ public String getEndpointAddress() {
+ return(m_endpointAddress);
+ }
+
+ /**
+ * This method sets the endpoint address.
+ *
+ * @param address The endpoint address
+ */
+ public void setEndpointAddress(String address) {
+ m_endpointAddress = address;
+ }
+
+ /**
+ * This method returns the endpoint type of the component that is
+ * the subject of the interaction.
+ *
+ * If not specified, then the endpoint address must be defined.
+ *
+ * @return The enpdoint type, or null if not known
+ */
+ public String getEndpointType() {
+ return(m_endpointType);
+ }
+
+ /**
+ * This method sets the endpoint type.
+ *
+ * @param type The endpoint type
+ */
+ public void setEndpointType(String type) {
+ m_endpointType = type;
+ }
+
+ /**
+ * This method indicates whether the message is a request, and therefore
+ * destined for the endpoint identified by its address or type, or a
+ * response/fault.
+ *
+ * Not all communication infrastructures will support the notion of
+ * request/response, and therefore by default a message will represent
+ * a request whose destination is identified by the endpoint address
+ * and/or type.
+ *
+ * @return The message style
+ */
+ public Style getStyle() {
+ return(m_style);
+ }
+
+ /**
+ * This method sets the style of the message.
+ *
+ * @param style The style
+ */
+ public void setStyle(Style style) {
+ m_style = style;
+ }
+
+ /**
+ * This method returns the direction of the message.
+ *
+ * @return The direction
+ */
+ public Direction getDirection() {
+ return(m_direction);
+ }
+
+ /**
+ * This method sets the direction of the message.
+ *
+ * @param direction The direction
+ */
+ public void setDirection(Direction direction) {
+ m_direction = direction;
+ }
+
+ /**
+ * This enumerated class represents the style of message.
+ *
+ */
+ public enum Style {
+ Request,
+ Response,
+ Fault
+ }
+
+ /**
+ * This enumerated class represents the direction of the message,
+ * whether it is 'inbound' (i.e. received) or 'outbound'
+ * (i.e. sent).
+ *
+ */
+ public enum Direction {
+ Inbound,
+ Outbound
+ }
}
Modified:
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 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/Monitor.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -17,10 +17,20 @@
*/
package org.savara.monitor;
+import org.savara.protocol.ProtocolId;
+import org.savara.protocol.repository.ProtocolRepository;
+import org.savara.protocol.ProtocolUnknownException;
+
/**
* This interface represents a behaviour monitor, comparing a stream of messages
* against the expected behaviour associated with an endpoint protocol.
*
+ * Use cases:
+ * 1) Where a component directly uses the monitor, and knows the protocol id
+ * and/or the conversation id in advance.
+ * 2) Where used to analyse an activity stream, from within an application or
+ * server, where the events may related to multiple conversations and/or
+ * protocols.
*/
public interface Monitor {
@@ -50,8 +60,9 @@
/**
* This method is used to indicate that a message has been
- * sent and should be monitored against the configured
- * behaviour.
+ * sent or received, and should be monitored against the
+ * specified protocol id and optional conversation instance
+ * id.
*
* If the conversation instance id is not explicitly
* specified, then the protocol monitor will be responsible
@@ -64,13 +75,13 @@
* @throws ProtocolUnknownException Unknown protocol name or role
* @throws IOException Failed to create or retrieve session
*/
- public boolean sent(ProtocolId pid, ConversationInstanceId cid, Message mesg)
+ public boolean process(ProtocolId pid, ConversationInstanceId cid, Message mesg)
throws ProtocolUnknownException,
- java.io.IOException ;
+ java.io.IOException;
/**
* This method is used to indicate that a message has been
- * received and should be monitored against the configured
+ * sent or received, and should be monitored against the configured
* behaviour.
*
* If the conversation instance id is not explicitly
@@ -84,8 +95,6 @@
* @throws ProtocolUnknownException Unknown protocol name or role
* @throws IOException Failed to create or retrieve session
*/
- public boolean received(ProtocolId pid, ConversationInstanceId cid, Message mesg)
- throws ProtocolUnknownException,
- java.io.IOException ;
+ public java.util.List<MonitorResult> process(Message mesg) throws
java.io.IOException;
}
Modified:
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 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorListener.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -17,6 +17,7 @@
*/
package org.savara.monitor;
+import org.savara.protocol.ProtocolId;
import org.scribble.protocol.monitor.Result;
/**
Added:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorResult.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorResult.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/MonitorResult.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008-11, 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.savara.protocol.ProtocolId;
+
+/**
+ * This class represents a result from monitoring a message against a
+ * protocol.
+ *
+ */
+public class MonitorResult {
+
+ private ProtocolId m_protocolId=null;
+ private ConversationInstanceId m_conversationInstanceId=null;
+ private boolean m_valid=false;
+ private String m_reason=null;
+
+ /**
+ * This is the result constructor.
+ *
+ * @param pid The protocol id
+ * @param cid The conversation instance id
+ * @param valid Whether the result was valid
+ * @param reason Reason for result
+ */
+ public MonitorResult(ProtocolId pid, ConversationInstanceId cid, boolean valid,
+ String reason) {
+ m_protocolId = pid;
+ m_conversationInstanceId = cid;
+ m_valid = valid;
+ m_reason = reason;
+ }
+
+ /**
+ * This method returns the protocol id.
+ *
+ * @return The protocol id
+ */
+ public ProtocolId getProtocolId() {
+ return(m_protocolId);
+ }
+
+ /**
+ * This method returns the conversation instance id.
+ *
+ * @return The conversation instance id
+ */
+ public ConversationInstanceId getConversationInstanceId() {
+ return(m_conversationInstanceId);
+ }
+
+ /**
+ * This method indicates whether the result is valid.
+ *
+ * @return Whether the result is valid
+ */
+ public boolean isValid() {
+ return(m_valid);
+ }
+
+ /**
+ * This method provides an optional reason for the result.
+ *
+ * @return The reason, or null if not specified
+ */
+ public String getReason() {
+ return(m_reason);
+ }
+}
Deleted:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolId.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolId.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolId.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor;
-
-/**
- * This class represents a protocol id, used to identify the name
- * of the protocol used to monitor a conversation, and the role
- * being played by the endpoint.
- *
- */
-public class ProtocolId {
-
- private String m_name=null;
- private String m_role=null;
-
- /**
- * The constructor initialized with the name of the protocol
- * and the role being played.
- *
- * @param name The name
- * @param role The role
- */
- public ProtocolId(String name, String role) {
- m_name = name;
- m_role = role;
- }
-
- /**
- * The name of the protocol.
- *
- * @return The protocol name
- */
- public String getName() {
- return(m_name);
- }
-
- /**
- * The role being monitored.
- *
- * @return The role
- */
- public String getRole() {
- return(m_role);
- }
-
- public int hashCode() {
- return(m_name.hashCode());
- }
-
- public boolean equals(Object obj) {
- boolean ret=false;
-
- if (obj instanceof ProtocolId &&
- m_name != null && ((ProtocolId)obj).m_name != null &&
- m_role != null && ((ProtocolId)obj).m_role != null &&
- ((ProtocolId)obj).m_name.equals(m_name) &&
- ((ProtocolId)obj).m_role.equals(m_role)) {
- ret = true;
- }
-
- return(ret);
- }
-}
Deleted:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolRepository.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolRepository.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolRepository.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor;
-
-import org.scribble.protocol.monitor.model.Description;
-
-/**
- * This interface represents a repository containing protocol descriptions
- * used by the monitor.
- *
- */
-public interface ProtocolRepository {
-
- /**
- * This method returns the protocol description associated with
- * the supplied protocol id (name and role).
- *
- * @param pid The protocol id
- * @return The monitoring description for the protocol
- * @throws ProtocolUnknownException Failed to find protocol with the specified id
- */
- public Description getProtocol(ProtocolId pid) throws ProtocolUnknownException;
-
-}
Deleted:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolUnknownException.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolUnknownException.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolUnknownException.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor;
-
-/**
- * This exceptions indicates that the protocol name or role is unknown.
- *
- */
-public class ProtocolUnknownException extends Exception {
-
- private static final long serialVersionUID = -229297584119164988L;
-
- /**
- * This constructor initializes the exception message.
- *
- * @param mesg The message
- */
- public ProtocolUnknownException(String mesg) {
- super(mesg);
- }
-}
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/SessionStore.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -18,6 +18,7 @@
package org.savara.monitor;
import org.savara.common.config.Configuration;
+import org.savara.protocol.ProtocolId;
/**
* This interface represents a session store responsible for
Deleted:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMessage.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMessage.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMessage.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -1,23 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor.impl;
-
-public class DefaultMessage extends org.scribble.protocol.monitor.DefaultMessage
- implements org.savara.monitor.Message {
-
-}
Modified:
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 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DefaultMonitor.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -17,20 +17,28 @@
*/
package org.savara.monitor.impl;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import org.savara.monitor.ConversationInstanceId;
-import org.savara.monitor.ProtocolId;
-import org.savara.monitor.ProtocolRepository;
-import org.savara.monitor.ProtocolUnknownException;
+import org.savara.monitor.MonitorResult;
import org.savara.monitor.SessionStore;
import org.savara.monitor.Message;
import org.savara.monitor.Monitor;
import org.savara.monitor.MonitorListener;
+import org.savara.protocol.ProtocolId;
+import org.savara.protocol.repository.ProtocolRepository;
+import org.savara.protocol.ProtocolUnknownException;
+import org.scribble.common.logging.CachedJournal;
+import org.scribble.protocol.export.monitor.MonitorProtocolExporter;
+import org.scribble.protocol.model.ProtocolModel;
import org.scribble.protocol.monitor.DefaultProtocolMonitor;
import org.scribble.protocol.monitor.MonitorContext;
import org.scribble.protocol.monitor.ProtocolMonitor;
import org.scribble.protocol.monitor.Result;
import org.scribble.protocol.monitor.Session;
import org.scribble.protocol.monitor.model.Description;
+import org.scribble.protocol.monitor.util.MonitorModelUtil;
/**
* This class provides a default implementation of the
@@ -43,7 +51,12 @@
private ProtocolRepository m_protocolRepository=null;
private SessionStore m_sessionStore=null;
private ProtocolMonitor m_monitor=new DefaultProtocolMonitor();
+ private DescriptionCache m_descriptionCache=new DescriptionCache();
+ private MonitorProtocolExporter m_exporter=new MonitorProtocolExporter();
+
+ private static final Logger logger=Logger.getLogger(DefaultMonitor.class.getName());
+
/**
* This method sets the protocol monitor.
*
@@ -85,8 +98,9 @@
/**
* This method is used to indicate that a message has been
- * sent and should be monitored against the configured
- * behaviour.
+ * sent or received, and should be monitored against the
+ * specified protocol id and optional conversation instance
+ * id.
*
* If the conversation instance id is not explicitly
* specified, then the protocol monitor will be responsible
@@ -99,51 +113,9 @@
* @throws ProtocolUnknownException Unknown protocol name or role
* @throws IOException Failed to create or retrieve session
*/
- public boolean sent(ProtocolId pid, ConversationInstanceId cid, Message mesg)
+ public boolean process(ProtocolId pid, ConversationInstanceId cid, Message mesg)
throws ProtocolUnknownException,
java.io.IOException {
- return(processMessage(pid, cid, mesg, true));
- }
-
- /**
- * This method is used to indicate that a message has been
- * received and should be monitored against the configured
- * behaviour.
- *
- * If the conversation instance id is not explicitly
- * specified, then the protocol monitor will be responsible
- * for deriving the appropriate value.
- *
- * @param pid The protocol id
- * @param cid The optional conversation instance id
- * @param mesg The message
- * @return Whether the message was valid
- * @throws ProtocolUnknownException Unknown protocol name or role
- * @throws IOException Failed to create or retrieve session
- */
- public boolean received(ProtocolId pid, ConversationInstanceId cid, Message mesg)
- throws ProtocolUnknownException,
- java.io.IOException {
- return(processMessage(pid, cid, mesg, false));
- }
-
- /**
- * This method is used to process a message against a protocol monitor.
- *
- * If the conversation instance id is not explicitly
- * specified, then the protocol monitor will be responsible
- * for deriving the appropriate value.
- *
- * @param pid The protocol id
- * @param cid The optional conversation instance id
- * @param mesg The message
- * @param sent Whether to process the message as a sent message
- * @return Whether the message was valid
- * @throws ProtocolUnknownException Unknown protocol name or role
- * @throws IOException Failed to create or retrieve session
- */
- protected boolean processMessage(ProtocolId pid, ConversationInstanceId cid, Message
mesg, boolean sent)
- throws ProtocolUnknownException, java.io.IOException {
boolean ret=false;
if (pid == null) {
@@ -158,11 +130,10 @@
// Check if conversation instance id should be derived
if (cid == null) {
- // Derive conversation instance id
- // TODO: Use ex
+ // TODO: Derive conversation instance id
}
- Description desc=m_protocolRepository.getProtocol(pid);
+ Description desc=getProtocolDescription(pid);
java.io.Serializable session=m_sessionStore.find(pid, cid);
@@ -207,4 +178,78 @@
return(ret);
}
+ /**
+ * This method is used to indicate that a message has been
+ * sent or received, and should be monitored against the configured
+ * behaviour.
+ *
+ * If the conversation instance id is not explicitly
+ * specified, then the protocol monitor will be responsible
+ * for deriving the appropriate value.
+ *
+ * @param pid The protocol id
+ * @param cid The optional conversation instance id
+ * @param mesg The message
+ * @return Whether the message was valid
+ * @throws ProtocolUnknownException Unknown protocol name or role
+ * @throws IOException Failed to create or retrieve session
+ */
+ public java.util.List<MonitorResult> process(Message mesg) throws
java.io.IOException {
+ java.util.List<MonitorResult> ret=new java.util.Vector<MonitorResult>();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the protocol's monitorable description.
+ *
+ * @param pid The protocol id
+ * @return The description
+ */
+ protected Description getProtocolDescription(ProtocolId pid) {
+ Description ret=getDescriptionCache().getDescription(pid);
+
+ if (ret == null) {
+ try {
+ ProtocolModel pm=m_protocolRepository.getProtocol(pid);
+
+ // Convert protocol model to monitoring description
+ CachedJournal journal=new CachedJournal();
+ java.io.ByteArrayOutputStream os=new java.io.ByteArrayOutputStream();
+
+ m_exporter.export(pm, journal, os);
+
+ os.close();
+
+ if (journal.hasErrors()) {
+ logger.severe("Errors detected when exporting protocol '"+
+ pid+"' to monitorable description");
+ } else {
+ java.io.InputStream is=new java.io.ByteArrayInputStream(os.toByteArray());
+
+ ret = MonitorModelUtil.deserialize(is);
+
+ is.close();
+ }
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to obtain monitorable description for protocol '"+
+ pid+"'", e);
+ }
+
+ if (ret != null) {
+ getDescriptionCache().setDescription(pid, ret);
+ }
+ }
+
+ return(ret);
+ }
+
+ protected DescriptionCache getDescriptionCache() {
+ return(m_descriptionCache);
+ }
+
+ protected void setDescriptionCache(DescriptionCache dc) {
+ m_descriptionCache = dc;
+ }
}
Added:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DescriptionCache.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DescriptionCache.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/DescriptionCache.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008-11, 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.protocol.ProtocolId;
+import org.scribble.protocol.monitor.model.Description;
+
+public class DescriptionCache {
+
+ private java.util.Map<ProtocolId, Description> m_descriptions=
+ new java.util.HashMap<ProtocolId, Description>();
+
+ /**
+ * This method returns the description associated with the supplied
+ * protocol id.
+ *
+ * @param pid The protocol id
+ * @return The description, or null if not found
+ */
+ public Description getDescription(ProtocolId pid) {
+ return(m_descriptions.get(pid));
+ }
+
+ /**
+ * This method sets the monitorable description associated with
+ * the supplied protocol id.
+ *
+ * @param pid The protocol id
+ * @param description The monitorable description
+ */
+ public void setDescription(ProtocolId pid, Description description) {
+ m_descriptions.put(pid, description);
+ }
+}
Deleted:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryProtocolRepository.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryProtocolRepository.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryProtocolRepository.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-package org.savara.monitor.impl;
-
-import org.savara.monitor.ProtocolId;
-import org.savara.monitor.ProtocolRepository;
-import org.savara.monitor.ProtocolUnknownException;
-import org.scribble.protocol.monitor.model.Description;
-
-/**
- * This is the in-memory implementation of the protocol repository.
- *
- */
-public class InMemoryProtocolRepository implements ProtocolRepository {
-
- private java.util.Map<ProtocolId,Description> m_descriptions=
- new java.util.HashMap<ProtocolId,Description>();
-
- public InMemoryProtocolRepository() {
- }
-
- public void addProtocol(ProtocolId pid, Description desc) {
- m_descriptions.put(pid, desc);
- }
-
- public Description getProtocol(ProtocolId pid) throws ProtocolUnknownException {
- if (m_descriptions.containsKey(pid) == false) {
- throw new ProtocolUnknownException("Protocol '"+pid+"' not
known");
- }
-
- return(m_descriptions.get(pid));
- }
-}
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemorySessionStore.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -19,8 +19,8 @@
import org.savara.common.config.Configuration;
import org.savara.monitor.ConversationInstanceId;
-import org.savara.monitor.ProtocolId;
import org.savara.monitor.SessionStore;
+import org.savara.protocol.ProtocolId;
import org.scribble.protocol.monitor.DefaultSession;
public class InMemorySessionStore implements SessionStore {
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/DefaultMonitorTest.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/DefaultMonitorTest.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/DefaultMonitorTest.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -23,12 +23,12 @@
import org.savara.monitor.ConversationInstanceId;
import org.savara.monitor.Message;
import org.savara.monitor.MonitorListener;
-import org.savara.monitor.ProtocolId;
+import org.savara.protocol.ProtocolId;
+import org.savara.protocol.repository.impl.InMemoryProtocolRepository;
+import org.scribble.protocol.model.ProtocolModel;
import org.scribble.protocol.monitor.DefaultSession;
import org.scribble.protocol.monitor.ProtocolMonitorFactory;
import org.scribble.protocol.monitor.Result;
-import org.scribble.protocol.monitor.Session;
-import org.scribble.protocol.monitor.model.Description;
public class DefaultMonitorTest {
@@ -36,7 +36,7 @@
public void testNoProtocolRepository() {
DefaultMonitor mon=new DefaultMonitor();
- DefaultMessage mesg=new DefaultMessage();
+ Message mesg=new Message();
ProtocolId pid=new ProtocolId("name", "role");
@@ -46,7 +46,7 @@
mon.setSessionStore(new InMemorySessionStore());
try {
- mon.processMessage(pid, cid, mesg, true);
+ mon.process(pid, cid, mesg);
fail("Should have generated illegal state exception");
} catch(IllegalStateException ise) {
// Expected
@@ -59,7 +59,7 @@
public void testNoSessionStore() {
DefaultMonitor mon=new DefaultMonitor();
- DefaultMessage mesg=new DefaultMessage();
+ Message mesg=new Message();
ProtocolId pid=new ProtocolId("name", "role");
@@ -71,7 +71,7 @@
mon.setProtocolRepository(rep);
try {
- mon.processMessage(pid, cid, mesg, true);
+ mon.process(pid, cid, mesg);
fail("Should have generated illegal state exception");
} catch(IllegalStateException ise) {
// Expected
@@ -84,7 +84,7 @@
public void testProcessMessage() {
DefaultMonitor mon=new DefaultMonitor();
- DefaultMessage mesg=new DefaultMessage();
+ Message mesg=new Message();
ProtocolId pid=new ProtocolId("name", "role");
@@ -93,14 +93,14 @@
mon.setProtocolMonitor(ProtocolMonitorFactory.createProtocolMonitor());
InMemoryProtocolRepository rep=new InMemoryProtocolRepository();
- rep.addProtocol(pid, new Description());
+ rep.addProtocol(pid, new ProtocolModel());
mon.setProtocolRepository(rep);
InMemorySessionStore store=new InMemorySessionStore();
mon.setSessionStore(store);
try {
- mon.processMessage(pid, cid, mesg, true);
+ mon.process(pid, cid, mesg);
} catch(Exception e) {
fail("Unexpected: "+e);
}
@@ -110,7 +110,7 @@
public void testProcessMessageWithExistingSession() {
DefaultMonitor mon=new DefaultMonitor();
- DefaultMessage mesg=new DefaultMessage();
+ Message mesg=new Message();
ProtocolId pid=new ProtocolId("name", "role");
@@ -119,7 +119,7 @@
mon.setProtocolMonitor(ProtocolMonitorFactory.createProtocolMonitor());
InMemoryProtocolRepository rep=new InMemoryProtocolRepository();
- rep.addProtocol(pid, new Description());
+ rep.addProtocol(pid, new ProtocolModel());
mon.setProtocolRepository(rep);
InMemorySessionStore store=new InMemorySessionStore();
@@ -136,7 +136,7 @@
mon.setSessionStore(store);
try {
- mon.processMessage(pid, cid, mesg, true);
+ mon.process(pid, cid, mesg);
} catch(Exception e) {
fail("Unexpected: "+e);
}
@@ -146,7 +146,7 @@
public void testSingleMessageSession() {
DefaultMonitor mon=new DefaultMonitor();
- DefaultMessage mesg=new DefaultMessage();
+ Message mesg=new Message();
ProtocolId pid=new ProtocolId("name", "role");
@@ -155,7 +155,7 @@
mon.setProtocolMonitor(ProtocolMonitorFactory.createProtocolMonitor());
InMemoryProtocolRepository rep=new InMemoryProtocolRepository();
- rep.addProtocol(pid, new Description());
+ rep.addProtocol(pid, new ProtocolModel());
mon.setProtocolRepository(rep);
InMemorySessionStore store=new InMemorySessionStore() {
@@ -181,7 +181,7 @@
mon.setSessionStore(store);
try {
- mon.processMessage(pid, cid, mesg, true);
+ mon.process(pid, cid, mesg);
} catch(Exception e) {
fail("Unexpected: "+e);
}
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor/src/test/java/org/savara/monitor/impl/InMemorySessionStoreTest.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -21,7 +21,7 @@
import org.junit.Test;
import org.savara.monitor.ConversationInstanceId;
-import org.savara.monitor.ProtocolId;
+import org.savara.protocol.ProtocolId;
public class InMemorySessionStoreTest {
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/META-INF/MANIFEST.MF
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/META-INF/MANIFEST.MF 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/META-INF/MANIFEST.MF 2011-01-27
23:06:35 UTC (rev 630)
@@ -8,4 +8,5 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: org.savara.common,
- org.savara.monitor
+ org.savara.monitor,
+ org.savara.protocol
Modified:
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/src/main/java/org/savara/monitor/sstore/rdbms/RDBMSSessionStore.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/src/main/java/org/savara/monitor/sstore/rdbms/RDBMSSessionStore.java 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.monitor.sstore.rdbms/src/main/java/org/savara/monitor/sstore/rdbms/RDBMSSessionStore.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -19,8 +19,8 @@
import org.savara.common.config.Configuration;
import org.savara.monitor.ConversationInstanceId;
-import org.savara.monitor.ProtocolId;
import org.savara.monitor.SessionStore;
+import org.savara.protocol.ProtocolId;
/**
* This class defines the RDBMS implementation of the SessionStore
Modified: branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF 2011-01-27
20:48:24 UTC (rev 629)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/META-INF/MANIFEST.MF 2011-01-27
23:06:35 UTC (rev 630)
@@ -12,7 +12,13 @@
org.savara.common,
org.scribble.protocol.parser,
org.savara.contract
-Export-Package: org.savara.protocol.contract.generator,
+Export-Package: org.savara.protocol,
+ org.savara.protocol.contract.generator,
+ org.savara.protocol.export.text,
org.savara.protocol.model.annotation,
org.savara.protocol.model.change,
- org.savara.protocol.model.util
+ org.savara.protocol.model.util,
+ org.savara.protocol.parser,
+ org.savara.protocol.repository,
+ org.savara.protocol.repository.impl,
+ org.savara.protocol.util
Added:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/MessageCriteria.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/MessageCriteria.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/MessageCriteria.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -0,0 +1,103 @@
+/*
+ * 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.protocol;
+
+/**
+ * This interface represents the message criteria to be used to identify
+ * a protocol model.
+ *
+ */
+public interface MessageCriteria {
+
+ /**
+ * This method returns the optional operator name.
+ *
+ * @return The operator, or null if not relevant
+ */
+ public String getOperator();
+
+ /**
+ * This method returns the list of types associated with
+ * with the message.
+ *
+ * @return The types of the message parameters
+ */
+ public java.util.List<String> getTypes();
+
+ /**
+ * This method provides the endpoint address of the component that
+ * is the subject of the interaction.
+ *
+ * If not specified, then the endpoint type must be defined.
+ *
+ * @return The endpoint address, or null if not known
+ */
+ public String getEndpointAddress();
+
+ /**
+ * This method returns the endpoint type of the component that is
+ * the subject of the interaction.
+ *
+ * If not specified, then the endpoint address must be defined.
+ *
+ * @return The enpdoint type, or null if not known
+ */
+ public String getEndpointType();
+
+ /**
+ * This method indicates whether the message is a request, and therefore
+ * destined for the endpoint identified by its address or type, or a
+ * response/fault.
+ *
+ * Not all communication infrastructures will support the notion of
+ * request/response, and therefore by default a message will represent
+ * a request whose destination is identified by the endpoint address
+ * and/or type.
+ *
+ * @return The message style
+ */
+ public Style getStyle();
+
+ /**
+ * This method returns the direction of the message.
+ *
+ * @return The direction
+ */
+ public Direction getDirection();
+
+ /**
+ * This enumerated class represents the style of message.
+ *
+ */
+ public enum Style {
+ Request,
+ Response,
+ Fault
+ }
+
+ /**
+ * This enumerated class represents the direction of the message,
+ * whether it is 'inbound' (i.e. received) or 'outbound'
+ * (i.e. sent).
+ *
+ */
+ public enum Direction {
+ Inbound,
+ Outbound
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolId.java
(from rev 623,
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolId.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolId.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolId.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -0,0 +1,78 @@
+/*
+ * 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.protocol;
+
+/**
+ * This class represents a protocol id, used to identify the name
+ * of the protocol used to monitor a conversation, and the role
+ * being played by the endpoint.
+ *
+ */
+public class ProtocolId {
+
+ private String m_name=null;
+ private String m_role=null;
+
+ /**
+ * The constructor initialized with the name of the protocol
+ * and the role being played.
+ *
+ * @param name The name
+ * @param role The role
+ */
+ public ProtocolId(String name, String role) {
+ m_name = name;
+ m_role = role;
+ }
+
+ /**
+ * The name of the protocol.
+ *
+ * @return The protocol name
+ */
+ public String getName() {
+ return(m_name);
+ }
+
+ /**
+ * The role being monitored.
+ *
+ * @return The role
+ */
+ public String getRole() {
+ return(m_role);
+ }
+
+ public int hashCode() {
+ return(m_name.hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof ProtocolId &&
+ m_name != null && ((ProtocolId)obj).m_name != null &&
+ m_role != null && ((ProtocolId)obj).m_role != null &&
+ ((ProtocolId)obj).m_name.equals(m_name) &&
+ ((ProtocolId)obj).m_role.equals(m_role)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolUnknownException.java
(from rev 623,
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolUnknownException.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolUnknownException.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/ProtocolUnknownException.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.savara.protocol;
+
+/**
+ * This exceptions indicates that the protocol name or role is unknown.
+ *
+ */
+public class ProtocolUnknownException extends Exception {
+
+ private static final long serialVersionUID = -229297584119164988L;
+
+ /**
+ * This constructor initializes the exception message.
+ *
+ * @param mesg The message
+ */
+ public ProtocolUnknownException(String mesg) {
+ super(mesg);
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/ProtocolRepository.java
(from rev 623,
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/ProtocolRepository.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/ProtocolRepository.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/ProtocolRepository.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -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.protocol.repository;
+
+import org.savara.protocol.MessageCriteria;
+import org.savara.protocol.ProtocolId;
+import org.savara.protocol.ProtocolUnknownException;
+import org.scribble.protocol.model.ProtocolModel;
+
+/**
+ * This interface represents a repository containing protocol descriptions
+ * used by the monitor.
+ *
+ */
+public interface ProtocolRepository {
+
+ /**
+ * This method returns the protocol model associated with
+ * the supplied protocol id (name and role).
+ *
+ * @param pid The protocol id
+ * @return The protocol model
+ * @throws ProtocolUnknownException Failed to find protocol with the specified id
+ */
+ public ProtocolModel getProtocol(ProtocolId pid) throws ProtocolUnknownException;
+
+ /**
+ * This method determines which protocols, identified by their protocol ids,
+ * would be interested in an endpoint address, whether or not the message is inbound,
+ * and finally the message details itself.
+ *
+ * @param message The message
+ * @return The list of protocol ids interested in the message
+ */
+ public java.util.List<ProtocolId> getProtocols(MessageCriteria message);
+
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/impl/InMemoryProtocolRepository.java
(from rev 623,
branches/experimental/2.0.x/bundles/org.savara.monitor/src/main/java/org/savara/monitor/impl/InMemoryProtocolRepository.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/impl/InMemoryProtocolRepository.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.protocol/src/main/java/org/savara/protocol/repository/impl/InMemoryProtocolRepository.java 2011-01-27
23:06:35 UTC (rev 630)
@@ -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.protocol.repository.impl;
+
+import org.savara.protocol.MessageCriteria;
+import org.savara.protocol.ProtocolId;
+import org.savara.protocol.repository.ProtocolRepository;
+import org.savara.protocol.ProtocolUnknownException;
+import org.scribble.protocol.model.ProtocolModel;
+
+/**
+ * This is the in-memory implementation of the protocol repository.
+ *
+ */
+public class InMemoryProtocolRepository implements ProtocolRepository {
+
+ private java.util.Map<ProtocolId,ProtocolModel> m_protocolModels=
+ new java.util.HashMap<ProtocolId,ProtocolModel>();
+
+ public InMemoryProtocolRepository() {
+ }
+
+ /**
+ * This method adds a protocol model to the repository.
+ *
+ * @param pid The protocol id
+ * @param pm The protocol model
+ */
+ public void addProtocol(ProtocolId pid, ProtocolModel pm) {
+ m_protocolModels.put(pid, pm);
+ }
+
+ /**
+ * This method returns the protocol model associated with
+ * the supplied protocol id (name and role).
+ *
+ * @param pid The protocol id
+ * @return The protocol model
+ * @throws ProtocolUnknownException Failed to find protocol with the specified id
+ */
+ public ProtocolModel getProtocol(ProtocolId pid) throws ProtocolUnknownException {
+ if (m_protocolModels.containsKey(pid) == false) {
+ throw new ProtocolUnknownException("Protocol '"+pid+"' not
known");
+ }
+
+ return(m_protocolModels.get(pid));
+ }
+
+ /**
+ * This method determines which protocols, identified by their protocol ids,
+ * would be interested in an endpoint address, whether or not the message is inbound,
+ * and finally the message details itself.
+ *
+ * @param criteria The message criteria
+ * @return The list of protocol ids interested in the message criteria
+ */
+ public java.util.List<ProtocolId> getProtocols(MessageCriteria criteria) {
+ java.util.List<ProtocolId> ret=new java.util.Vector<ProtocolId>();
+
+ return(ret);
+ }
+}