1 package org.enhydra.shark.corbaclient.workflowadmin.instantiation; 2 3 import java.sql.Timestamp ; 4 import java.util.*; 5 6 import org.enhydra.shark.corba.WorkflowService.ExecutionAdministration; 7 import org.enhydra.shark.corbaclient.*; 8 9 import org.omg.WfBase.*; 10 import org.omg.WorkflowModel.*; 11 12 15 public class ProcessInstantiatorCORBA extends _WfRequesterImplBase implements ProcessInstantiatorInterface { 16 17 static List instantiators=new ArrayList(); 18 19 public static List getInstantiators () { 20 return instantiators; 21 } 22 23 private List performers=new ArrayList(); 24 25 26 public ProcessInstantiatorCORBA() { 27 instantiators.add(this); 28 } 29 30 public void addPerformer (WfProcess pr) { 31 try { 32 performers.add(pr.key()); 33 } catch (Exception ex) {} 34 } 35 38 public int how_many_performer () throws BaseException { 39 return performers.size(); 40 } 41 42 44 public WfProcessIterator get_iterator_performer () throws BaseException { 45 throw new BaseException(); 46 } 47 48 52 public WfProcess[] get_sequence_performer (int max_number) throws BaseException { 53 WfProcess[] processes=new WfProcess[performers.size()]; 54 for (int i=0; i<processes.length; i++) { 55 try { 56 processes[i]=SharkClient.getExecAmin().getProcess(performers.get(i).toString()); 57 } catch (Exception ex) {} 58 } 59 return processes; 60 } 61 62 67 public boolean is_member_of_performer (WfProcess member) throws BaseException { 68 return performers.contains(member); 69 } 70 71 74 public void receive_event (WfEventAudit event) throws BaseException, InvalidPerformer { 75 try { 76 String msg="ProcessInstantiator -> Event received:"+ 77 " \n\tevent time --> "+new Timestamp (event.time_stamp().time)+ 78 " \n\tprocess id --> "+event.process_key()+ 79 " \n\tevent type --> "+event.event_type(); 80 System.out.println(msg); 81 SharkClient.getServer().doneWith(event); 82 } catch (Throwable ex) { 83 } 84 } 85 86 public void releaseProcesses() { 88 ExecutionAdministration ea=SharkClient.getExecAmin(); 89 Iterator it=performers.iterator(); 90 while (it.hasNext()) { 91 String procId=(String )it.next(); 92 try { 93 ea.removeProcessRequester(procId); 94 } catch (Exception ex) { 95 } 96 } 97 } 98 99 } 100 | Popular Tags |