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 import org.omg.WfBase.*; 9 import org.omg.WorkflowModel.*; 10 import org.omg.CORBA.ORB ; 11 import org.omg.CORBA.ORBPackage.InvalidName ; 12 import org.omg.PortableServer.POA ; 13 import org.omg.PortableServer.POAHelper ; 14 import org.omg.PortableServer.POAPackage.ServantNotActive ; 15 import org.omg.PortableServer.POAPackage.WrongPolicy ; 16 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 17 import org.omg.PortableServer.POAManagerPackage.AdapterInactive ; 18 19 22 public class ProcessInstantiatorPOA extends WfRequesterPOA implements ProcessInstantiatorInterface { 23 static List instantiators = new ArrayList(); 24 static POA rootPOA; 25 26 public static List getInstantiators() { 27 return instantiators; 28 } 29 30 private List performers = new ArrayList(); 31 32 35 public ProcessInstantiatorPOA() { 36 37 38 try { 39 if (rootPOA == null) rootPOA = POAHelper.narrow(SharkClient.getORB().resolve_initial_references("RootPOA")); 40 rootPOA.activate_object(this); 41 } catch (InvalidName invalidName) { 42 invalidName.printStackTrace(); 43 } catch (ServantAlreadyActive servantAlreadyActive) { 44 servantAlreadyActive.printStackTrace(); 45 } catch (WrongPolicy wrongPolicy) { 46 wrongPolicy.printStackTrace(); 47 } 48 instantiators.add(this); 49 50 } 51 52 public void addPerformer(WfProcess pr) { 53 try { 54 performers.add(pr.key()); 55 } catch (Exception ex) { 56 System.err.println("addPerformer: " + ex); 57 } 58 } 59 60 63 public int how_many_performer() throws BaseException { 64 return performers.size(); 65 } 66 67 70 public WfProcessIterator get_iterator_performer() throws BaseException { 71 throw new BaseException(); 72 } 73 74 79 public WfProcess[] get_sequence_performer(int max_number) throws BaseException { 80 WfProcess[] processes = new WfProcess[performers.size()]; 81 for (int i = 0; i < processes.length; i++) { 82 try { 83 processes[i] = SharkClient.getExecAmin().getProcess(performers.get(i).toString()); 84 } catch (Exception ex) { 85 } 86 } 87 return processes; 88 } 89 90 96 public boolean is_member_of_performer(WfProcess member) throws BaseException { 97 return performers.contains(member); 98 } 99 100 103 public void receive_event(WfEventAudit event) throws BaseException, InvalidPerformer { 104 try { 105 String msg = "ProcessInstantiatorPOA -> Event received:" + 106 " \n\tevent time --> " + new Timestamp (event.time_stamp().time) + 107 " \n\tprocess id --> " + event.process_key() + 108 " \n\tevent type --> " + event.event_type(); 109 System.out.println(msg); 110 SharkClient.getServer().doneWith(event); 111 } catch (Throwable ex) { 112 } 113 } 114 115 public void releaseProcesses() { 117 ExecutionAdministration ea = SharkClient.getExecAmin(); 118 Iterator it = performers.iterator(); 119 while (it.hasNext()) { 120 String procId = (String ) it.next(); 121 try { 122 ea.removeProcessRequester(procId); 123 } catch (Exception ex) { 124 } 125 } 126 } 127 128 } 129 | Popular Tags |