1 package org.enhydra.shark.corba; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import org.enhydra.shark.api.SharkTransaction; 7 import org.omg.CORBA.ORB ; 8 import org.omg.WorkflowModel.WfRequester; 9 10 13 public class WfLinkingRequesterForCORBA implements 14 org.enhydra.shark.api.client.wfmodel.WfRequester { 15 16 17 static Map requesters=new HashMap (); 18 19 static Map collectives=new HashMap (); 20 21 static boolean ignoreProblematicRequester=true; 22 23 public WfLinkingRequesterForCORBA() { 24 } 25 26 27 public static synchronized void setIgnoreProblematicRequesterProcess (boolean ignore) { 28 ignoreProblematicRequester=ignore; 29 } 30 31 public static synchronized void setCORBARequester (String procId,WfRequester myCORBARequester) { 32 requesters.put(procId, myCORBARequester); 33 } 34 35 public static synchronized void removeCORBARequester (String procId) { 36 requesters.remove(procId); 37 } 38 39 public static WfRequester getCORBARequester(String procId) { 40 return (WfRequester)requesters.get(procId); 41 } 42 43 public static synchronized void addCollective (String pId,Collective c) { 44 collectives.put(pId,c); 45 } 46 47 public static synchronized void emptyCollective (String pId,ORB orb) { 48 Collective c=(Collective)collectives.remove(pId); 49 if (c!=null) { 50 c.__disband(orb); 51 } 52 } 53 54 57 public int how_many_performer() throws org.enhydra.shark.api.client.wfbase.BaseException { 58 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 59 } 60 61 public int how_many_performer(SharkTransaction t) throws org.enhydra.shark.api.client.wfbase.BaseException { 62 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 63 } 64 65 68 public org.enhydra.shark.api.client.wfmodel.WfProcessIterator get_iterator_performer() throws org.enhydra.shark.api.client.wfbase.BaseException { 69 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 70 } 71 72 public org.enhydra.shark.api.client.wfmodel.WfProcessIterator get_iterator_performer(SharkTransaction t) throws org.enhydra.shark.api.client.wfbase.BaseException { 73 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 74 } 75 76 81 public org.enhydra.shark.api.client.wfmodel.WfProcess[] get_sequence_performer(int max_number) throws org.enhydra.shark.api.client.wfbase.BaseException { 82 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 83 } 84 85 public org.enhydra.shark.api.client.wfmodel.WfProcess[] get_sequence_performer(SharkTransaction t, 86 int max_number) throws org.enhydra.shark.api.client.wfbase.BaseException { 87 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 88 } 89 90 95 public boolean is_member_of_performer(org.enhydra.shark.api.client.wfmodel.WfProcess member) throws org.enhydra.shark.api.client.wfbase.BaseException { 96 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 97 } 98 99 public boolean is_member_of_performer(SharkTransaction t, 100 org.enhydra.shark.api.client.wfmodel.WfProcess member) throws org.enhydra.shark.api.client.wfbase.BaseException { 101 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 102 } 103 104 public void receive_event(org.enhydra.shark.api.client.wfmodel.WfEventAudit event) throws org.enhydra.shark.api.client.wfbase.BaseException, 105 org.enhydra.shark.api.client.wfmodel.InvalidPerformer { 106 try { 107 WfRequester req=getCORBARequester(event.process_key()); 108 if (req!=null) { 109 Collective __collective = new Collective.CollectiveCORBA(); 110 WfLinkingRequesterForCORBA.addCollective(event.process_key(),__collective); 111 req.receive_event(SharkCORBAUtilities.makeCORBAEventAudit(__collective,event)); 112 } else { 113 } 114 } catch (Throwable ex) {} 115 } 116 117 public void receive_event(SharkTransaction t, 118 org.enhydra.shark.api.client.wfmodel.WfEventAudit event) throws org.enhydra.shark.api.client.wfbase.BaseException, 119 org.enhydra.shark.api.client.wfmodel.InvalidPerformer { 120 String procId=null; 121 boolean ne=false; 122 boolean excH=false; 123 try { 124 procId=event.process_key(); 125 WfRequester req=WfLinkingRequesterForCORBA.getCORBARequester(procId); 126 if (req!=null) { 127 try { 128 ne=req._non_existent(); 129 } catch (Exception ex) { 130 ne=true; 131 } 132 if (!ne) { 133 Collective __collective = new Collective.CollectiveCORBA(); 134 WfLinkingRequesterForCORBA.addCollective(procId,__collective); 135 req.receive_event(SharkCORBAUtilities.makeCORBAEventAudit(__collective,event)); 136 System.out.println("External requester for process "+procId+" notified."); 137 } else { 138 String msg="External CORBA requester for process "+procId+" can't be found due to some network problem or client application shutdown"; 139 if (ignoreProblematicRequester) { 140 msg+=" - it'll be further ignored!"; 141 } else { 142 msg+="!"; 143 } 144 System.out.println(msg); 145 } 146 } else { 147 String msg="Can't find CORBA external requester for process "+procId+". It might be caused by shark CORBA server shutdown, shark cluster usage,..."; 148 if (ignoreProblematicRequester) { 149 msg+=" or because shark CORBA setup to ignore requester notification if some problem previously occured."; 150 } 151 System.out.println(msg); 152 } 153 } catch (Throwable ex) { 154 String msg="Problem accessing CORBA external requester for process "+procId+". Problem could be caused by some network problem or some problem in the implementation of requester's code."; 155 if (ignoreProblematicRequester) { 156 msg+=" - it'll be further ignored!"; 157 } else { 158 msg+="!"; 159 } 160 System.out.println(msg); 161 excH=true; 162 } 163 if (ignoreProblematicRequester && (ne || excH)) { 164 WfLinkingRequesterForCORBA.removeCORBARequester(procId); 165 } 166 } 167 168 169 } 170 171 | Popular Tags |