01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.framework.spec;
20:
21: import org.dom4j.Element;
22: import org.mactor.framework.MactorException;
23: import org.mactor.framework.ParseUtil;
24:
25: public class MessageReceiveSpec extends ContainerSpec {
26: private int maxMessageCount;
27: private int minMessageCount;
28: private int maxTimeoutSeconds;
29: private boolean blockUntilTimeout;
30: private String messageSubscribeNodeName;
31: private boolean hasResponseNode = false;
32:
33: public boolean hasResponseNode() {
34: return hasResponseNode;
35: }
36:
37: public String getMessageSubscribeNodeName() {
38: return messageSubscribeNodeName;
39: }
40:
41: public int getMaxTimeoutSeconds() {
42: return maxTimeoutSeconds;
43: }
44:
45: public int getMaxMessageCount() {
46: return maxMessageCount;
47: }
48:
49: public int getMinMessageCount() {
50: return minMessageCount;
51: }
52:
53: public boolean isBlockUntilTimeout() {
54: return blockUntilTimeout;
55: }
56:
57: public static MessageReceiveSpec loadSpec(Element element)
58: throws MactorException {
59: if (element == null)
60: return null;
61: MessageReceiveSpec s = new MessageReceiveSpec();
62: s.name = element.attributeValue("name");
63: s.messageSubscribeNodeName = element
64: .attributeValue("message_subscribe_node_name");
65: s.minMessageCount = ParseUtil.tryParseIntVal(element
66: .attributeValue("min_message_count"));
67: s.maxMessageCount = ParseUtil.tryParseIntVal(element
68: .attributeValue("max_message_count"));
69: s.maxTimeoutSeconds = ParseUtil.tryParseIntVal(element
70: .attributeValue("max_timeout_seconds"));
71: s.blockUntilTimeout = Boolean.parseBoolean(element
72: .attributeValue("block_until_timeout"));
73: s.loadContainedNodes(element);
74: for (SpecNode n : s.getSpecNodes()) {
75: if (n instanceof MessageRespondSpec) {
76: s.hasResponseNode = true;
77: break;
78: }
79: }
80: return s;
81: }
82:
83: public String getShortDescription() {
84: return "Receiver node - '" + name + "'";
85: }
86:
87: public String getDescription() {
88: return "Refered subscriber node:" + messageSubscribeNodeName
89: + ". Max message count:" + maxMessageCount
90: + ". Min message count" + minMessageCount
91: + ". Max timeout (seconds):" + maxTimeoutSeconds
92: + ". Block until timeout:" + blockUntilTimeout;
93: }
94: }
|