1
2
3
4
5
6 package net.kwfgrid.gworkflowdl.protocol.server;
7
8 import net.kwfgrid.gworkflowdl.protocol.structure.ProtocolWorkflow;
9 import net.kwfgrid.gworkflowdl.protocol.IncompatibleVersionsException;
10 import net.kwfgrid.gworkflowdl.protocol.IllegalModificationException;
11 import net.kwfgrid.gworkflowdl.structure.Workflow;
12
13 /***
14 Implementation of <code>Workflow</code> interface for the server side of a distributed workflow structure.
15 The implementation is as lightweight as possible. The <code>ServerWorkflow</code> just manages all information
16 needed on a per-workflow-instance basis. All the protocol-logic is delegated to the implementation of
17 <code>IServerDelegate</code> (see <code>DefaultServerDelegate</code>).
18 */
19 public class ServerWorkflow extends ProtocolWorkflow implements IServerRootObject {
20 protected IServerDelegate _protocoldelegate;
21 protected int _versionnumber;
22 protected ModificationBuffer _buffer;
23 protected String _xml;
24 protected boolean _xmlvalid;
25 protected boolean _updateoccured;
26
27 /***
28 Constructor.
29 @param delegate The workflow implementation used as a delegate by this workflow.
30 @param protocoldelegate The delegate to use for protocol operations.
31 */
32 protected ServerWorkflow(Workflow delegate, IServerDelegate protocoldelegate) {
33 super(delegate, protocoldelegate);
34 _protocoldelegate = protocoldelegate;
35 _versionnumber = 0;
36 _buffer = new ModificationBuffer(_versionnumber);
37 _xml = null;
38 _xmlvalid = false;
39 _updateoccured = false;
40 }
41
42 public int getVersionNumber() {
43 return _versionnumber;
44 }
45
46 public int incrementVersionNumber() {
47 return ++_versionnumber;
48 }
49
50 public String getXML() {
51 return _protocoldelegate.getXML(this, _xml);
52 }
53
54 public void setXML(String xml) {
55 _xml = xml;
56 }
57
58 public void setXMLValid(boolean valid) {
59 _xmlvalid = valid;
60 }
61
62 public boolean isXMLValid() {
63 return _xmlvalid;
64 }
65
66 public ModificationBuffer getModificationBuffer() {
67 return _buffer;
68 }
69
70 public boolean getClientUpdateOccured() {
71 return _updateoccured;
72 }
73
74 public void setClientUpdateOccured() {
75 _updateoccured = true;
76 }
77
78 public String[][] getModificationsForUpdate(int clientversion) {
79 return _protocoldelegate.getModificationsForUpdate(this, clientversion);
80 }
81
82 public int commitModification(int clientversion, String modification) throws IncompatibleVersionsException, IllegalModificationException {
83 return _protocoldelegate.commitModification(this, clientversion, modification);
84 }
85 }