1 package com.sourceforge.jpatterns.patterns.bhv.chain;
2
3 import java.io.Serializable;
4
5 /**
6 * This interface is going to be used as the DTO between different actors of "chain of responsibility" patterns implemented here. It
7 * could be used at both "hierarchical" and "chainable" implementations of this patterns. todo: check this statement
8 * <br/>
9 * It identifies all the necessary methods for working with the chain of responsibility.
10 * <ul>
11 * <li>identifying the type of message</li>
12 * <li>allow to pass the input objects</li>
13 * <li>allows to check the output of chain</li>
14 * </ul>
15 * <p/>
16 * Also the important feature is it allows to identify the handlers/hierarchy items which added/extended/initialized the inputs
17 * and outputs. todo: check this statement
18 * <p/>
19 * todo: what about rmi/ejb/jta/jms communication? COuld this message used here??
20 * todo: why we need it cloneable???
21 * todo: which other interfaces it should extend
22 *
23 * todo: think over forwards/includes at the chain handlers etc.
24 *
25 * $Author:: zmicer $<br/>
26 */
27 public interface IChainMessage extends Serializable, Cloneable
28 {
29 /**
30 * @return the type of message. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
31 */
32 String getType();
33
34 /**
35 * @return returns the constant allowing us to determine the status of message (if it is under construction or was proceed by the
36 * certain handlers/items etc ) todo: check this statement, introduce constants + introduce configuration os the system
37 * to do it
38 */
39 String getStatus();
40
41 /**
42 * The type of message. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
43 * <br/>
44 * The method allowing us to setup the item of the message (in simply words to modify the state of object is intended just to be
45 * used at the initialization of the message). At the base class of this interface the status would be analyzed using the
46 * {@link IChainMessage#getStatus()} method to understand if we could change the status.
47 * <br/>
48 * So it would be allowed only if the message is mutatable (configuration of the system allows us to do it - e.g. some handler
49 * changing the type of the message during sending it to the another handler/item. todo: check this statement) or
50 * it is under construction (was not send and was not processed yet).
51 *
52 * @throws IllegalStateException in the case the message is not at the appropriate state to be set with the typ
53 */
54 void setType(String type) throws IllegalStateException;
55
56 /**
57 * Get unout param by its name.
58 * todo: method allowing to determine inouts param by the id/items/handler could(shoul????) be added
59 * todo: should we allow to remove the input params?? system configuration???
60 * todo: where input params could be changed - at the handlers/items/inner runners etc??
61 * todo: permissions for reading/writing here???
62 * <p/>
63 * Note: the configuration system of implementation may restrict the usage of this method (it is unpermissed)
64 *
65 * @param name name of the input param. Can not be null (otherwise <code>IllegalArgumentException</code> would appear).
66 *
67 * @return Object, some informatino which was put as input param
68 *
69 * @throws UnsupportedOperationException in the case the message could not return the input params
70 *
71 * @java5 consider java5 here
72 */
73 Object getInputParam(String name) throws UnsupportedOperationException;
74
75 /**
76 * Get the info which was put to that <code>IChainMessage</code> object.
77 * todo: all the todos of above mentioned method have power here.
78 * <p/>
79 * <p/>
80 * Note: the configuration system of implementation may restrict the usage of this method (it is unpermissed)
81 *
82 * @param param the name of param using which the object should be obtained. Can not be null (otherwise
83 * <code>IllegalArgumentException</code> would appear).
84 *
85 * @return the Object, output result.
86 *
87 * @throws UnsupportedOperationException in the case the message could not return the input params
88 *
89 * @java5 consider java5 here
90 */
91 Object getOutputInfo(String param) throws UnsupportedOperationException;
92 }