1 package org.enhydra.shark.corba.poa; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import org.enhydra.shark.api.SharkTransaction; 7 import org.enhydra.shark.corba.poa.Collective; 8 import org.enhydra.shark.corba.poa.SharkCORBAUtilities; 9 import org.omg.CORBA.ORB ; 10 import org.omg.WorkflowModel.WfRequester; 11 import org.omg.CORBA.ORB ; 12 13 16 public class WfLinkingRequesterForCORBA implements 17 org.enhydra.shark.api.client.wfmodel.WfRequester { 18 19 20 21 private ORB orb; 23 24 static ORB the_orb; 25 26 static Map requesters=new HashMap (); 27 28 static Map collectives=new HashMap (); 29 30 static boolean ignoreProblematicRequester=true; 31 32 public WfLinkingRequesterForCORBA() { 33 34 } 35 36 public WfLinkingRequesterForCORBA(ORB orb) { 37 this.orb = orb; 38 } 39 40 public static void setOrb(ORB the_Orb) { 41 the_orb = the_Orb; 42 } 43 44 public static synchronized void setIgnoreProblematicRequesterProcess (boolean ignore) { 45 ignoreProblematicRequester=ignore; 46 } 47 48 public static synchronized void setCORBARequester (String procId,WfRequester myCORBARequester) { 49 requesters.put(procId, myCORBARequester); 50 } 51 52 53 65 public static synchronized void removeCORBARequester (String procId) { 66 requesters.remove(procId); 67 68 } 69 70 public static WfRequester getCORBARequester(String procId) { 71 return (WfRequester)requesters.get(procId); 72 } 73 74 public static synchronized void addCollective (String pId,Collective c) { 75 collectives.put(pId,c); 76 } 77 78 public static synchronized void emptyCollective (String pId,ORB orb) { 79 Collective c=(Collective)collectives.remove(pId); 80 if (c!=null) { 81 c.__disband(orb); 82 } 83 } 84 85 88 public int how_many_performer() throws org.enhydra.shark.api.client.wfbase.BaseException { 89 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 90 } 91 92 public int how_many_performer(SharkTransaction t) throws org.enhydra.shark.api.client.wfbase.BaseException { 93 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 94 } 95 96 99 public org.enhydra.shark.api.client.wfmodel.WfProcessIterator get_iterator_performer() throws org.enhydra.shark.api.client.wfbase.BaseException { 100 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 101 } 102 103 public org.enhydra.shark.api.client.wfmodel.WfProcessIterator get_iterator_performer(SharkTransaction t) throws org.enhydra.shark.api.client.wfbase.BaseException { 104 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 105 } 106 107 112 public org.enhydra.shark.api.client.wfmodel.WfProcess[] get_sequence_performer(int max_number) throws org.enhydra.shark.api.client.wfbase.BaseException { 113 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 114 } 115 116 public org.enhydra.shark.api.client.wfmodel.WfProcess[] get_sequence_performer(SharkTransaction t, 117 int max_number) throws org.enhydra.shark.api.client.wfbase.BaseException { 118 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 119 } 120 121 126 public boolean is_member_of_performer(org.enhydra.shark.api.client.wfmodel.WfProcess member) throws org.enhydra.shark.api.client.wfbase.BaseException { 127 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 128 } 129 130 public boolean is_member_of_performer(SharkTransaction t, 131 org.enhydra.shark.api.client.wfmodel.WfProcess member) throws org.enhydra.shark.api.client.wfbase.BaseException { 132 throw new org.enhydra.shark.api.client.wfbase.BaseException(); 133 } 134 135 public void receive_event(org.enhydra.shark.api.client.wfmodel.WfEventAudit event) throws org.enhydra.shark.api.client.wfbase.BaseException, 136 org.enhydra.shark.api.client.wfmodel.InvalidPerformer { 137 try { 138 139 WfRequester req=getCORBARequester(event.process_key()); 140 if (req!=null) { 141 Collective __collective = new Collective.CollectiveCORBA(); 142 WfLinkingRequesterForCORBA.addCollective(event.process_key(),__collective); 143 if (orb == null) orb = the_orb; 144 req.receive_event(SharkCORBAUtilities.makeCORBAEventAudit(__collective,event)); 145 } else { 146 } 147 148 } catch (Throwable ex) {} 149 } 150 151 public void receive_event(SharkTransaction t, 152 org.enhydra.shark.api.client.wfmodel.WfEventAudit event) throws org.enhydra.shark.api.client.wfbase.BaseException, 153 org.enhydra.shark.api.client.wfmodel.InvalidPerformer { 154 String procId=null; 155 boolean ne=false; 156 boolean excH=false; 157 try { 158 159 procId=event.process_key(); 160 WfRequester req=WfLinkingRequesterForCORBA.getCORBARequester(procId); 161 if (req!=null) { 162 try { 163 ne=req._non_existent(); 164 } catch (Exception ex) { 165 ne=true; 166 } 167 if (!ne) { 168 Collective __collective = new Collective.CollectiveCORBA(); 169 WfLinkingRequesterForCORBA.addCollective(procId,__collective); 170 if (orb == null) orb = the_orb; 171 req.receive_event(SharkCORBAUtilities.makeCORBAEventAudit(__collective,event)); 172 System.out.println("External requester for process "+procId+" notified."); 173 } else { 174 String msg="External CORBA requester for process "+procId+" can't be found due to some network problem or client application shutdown"; 175 if (ignoreProblematicRequester) { 176 msg+=" - it'll be further ignored!"; 177 } else { 178 msg+="!"; 179 } 180 System.out.println(msg); 181 } 182 } else { 183 String msg="Can't find CORBA external requester for process "+procId+". It might be caused by shark CORBA server shutdown, shark cluster usage,..."; 184 if (ignoreProblematicRequester) { 185 msg+=" or because shark CORBA setup to ignore requester notification if some problem previously occured."; 186 } 187 System.out.println(msg); 188 } 189 } catch (Throwable ex) { 190 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."; 191 if (ignoreProblematicRequester) { 192 msg+=" - it'll be further ignored!"; 193 } else { 194 msg+="!"; 195 } 196 System.out.println(msg); 197 excH=true; 198 } 199 if (ignoreProblematicRequester && (ne || excH)) { 200 WfLinkingRequesterForCORBA.removeCORBARequester(procId); 201 } 202 203 } 204 205 206 } 207 208 | Popular Tags |