KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > swingclient > workflowadmin > instantiation > ProcessInstantiator


1 package org.enhydra.shark.swingclient.workflowadmin.instantiation;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.enhydra.shark.api.SharkTransaction;
7 import org.enhydra.shark.api.client.wfbase.BaseException;
8 import org.enhydra.shark.api.client.wfmodel.InvalidPerformer;
9 import org.enhydra.shark.api.client.wfmodel.WfDataEventAudit;
10 import org.enhydra.shark.api.client.wfmodel.WfEventAudit;
11 import org.enhydra.shark.api.client.wfmodel.WfProcess;
12 import org.enhydra.shark.api.client.wfmodel.WfProcessIterator;
13 import org.enhydra.shark.api.client.wfmodel.WfRequester;
14 import org.enhydra.shark.api.client.wfmodel.WfStateEventAudit;
15 import org.enhydra.shark.swingclient.SharkClient;
16
17 /**
18  * Required to crate the process.
19  */

20 public class ProcessInstantiator implements WfRequester {
21
22    private List JavaDoc performers=new ArrayList JavaDoc();
23
24    /** Create a new WfRequester */
25    public ProcessInstantiator() {
26    }
27
28    public void addPerformer (WfProcess pr) {
29       try {
30          performers.add(pr.key());
31       } catch (Exception JavaDoc ex) {}
32    }
33    /**
34     * Gets the number of processes.
35     */

36    public int how_many_performer () throws BaseException {
37       return performers.size();
38    }
39
40    public int how_many_performer (SharkTransaction t) throws BaseException {
41       return performers.size();
42    }
43
44    /** Gets an iterator of processes.
45     */

46    public WfProcessIterator get_iterator_performer () throws BaseException {
47       throw new BaseException("Not implemented");
48    }
49
50    public WfProcessIterator get_iterator_performer (SharkTransaction t) throws BaseException {
51       throw new BaseException("Not implemented");
52    }
53
54    /**
55     * A list of processes
56     * @param max_number
57     */

58    public WfProcess[] get_sequence_performer (int max_number) throws BaseException {
59       return get_sequence_performer(null,max_number);
60    }
61
62    public WfProcess[] get_sequence_performer (SharkTransaction t,int max_number) throws BaseException {
63       WfProcess[] processes=new WfProcess[performers.size()];
64       for (int i=0; i<processes.length; i++) {
65          try {
66             processes[i]=SharkClient.getExecAmin().getProcess(performers.get(i).toString());
67          } catch (Exception JavaDoc ex) {}
68       }
69       return processes;
70    }
71
72    /**
73     * Checks if a WfProcess is associated with this requester object
74     * @param member
75     * @return true if the process is found.
76     */

77    public boolean is_member_of_performer (WfProcess member) throws BaseException {
78       return performers.contains(member);
79    }
80
81    public boolean is_member_of_performer (SharkTransaction t,WfProcess member) throws BaseException {
82       return performers.contains(member);
83    }
84
85    /**
86     * Receives notice of event status changes
87     */

88    public void receive_event (WfEventAudit event) throws BaseException, InvalidPerformer {
89       throw new BaseException("Not implemented");
90    }
91
92    public void receive_event (SharkTransaction t,WfEventAudit event) throws BaseException, InvalidPerformer {
93       try {
94          String JavaDoc msg="ProcessInstantiator -> Event received:"+
95             " \n\tevent time --> "+event.time_stamp().getTimestamp()+
96             " \n\tprocess id --> "+event.process_key()+
97             " \n\tevent type --> "+event.event_type();
98          if (event instanceof WfStateEventAudit) {
99             msg+=" \n\told state --> "+((WfStateEventAudit)event).old_state();
100             msg+=" \n\tnew state --> "+((WfStateEventAudit)event).new_state();
101          }
102          if (event instanceof WfDataEventAudit) {
103             msg+=" \n\told data --> "+((WfDataEventAudit)event).old_data();
104             msg+=" \n\tnew data --> "+((WfDataEventAudit)event).new_data();
105          }
106          System.out.println(msg);
107       } catch (Exception JavaDoc ex) {
108          ex.printStackTrace();
109       }
110    }
111
112 }
113
Popular Tags