1 57 package org.apache.wsif.providers.jca; 58 59 import javax.resource.*; 60 import org.apache.wsif.logging.*; 61 import org.apache.wsif.providers.*; 62 import org.apache.wsif.*; 63 import org.apache.wsif.base.*; 64 import org.apache.wsif.util.*; 65 import javax.resource.*; 66 import javax.resource.cci.*; 67 import javax.wsdl.extensions.*; 68 import javax.wsdl.*; 69 import java.net.URL ; 70 import java.util.*; 71 import javax.resource.cci.*; 72 import java.io.Serializable ; 73 import java.util.*; 74 75 83 public class WSIFOperation_JCA implements WSIFOperation { 84 85 private static final long serialVersionUID = 1L; 86 protected Connection fieldConnection; 87 protected InteractionSpec fieldInteractionSpec; 88 protected Definition fieldDefinition; 89 protected Binding fieldBinding; 90 protected String fieldOperationName; 91 protected String fieldInputName; 92 protected String fieldOutputName; 93 protected Operation fieldOperation; 94 protected WSIFProviderJCAExtensions fieldFactory = null; 95 private final static String crlf = System.getProperty("line.separator"); 96 private org.apache.wsif.providers.WSIFDynamicTypeMap fieldTypeMap; 97 private Port fieldPort; 98 private Service fieldService; 99 private WSIFPort_JCA fieldJcaPort; 100 101 116 public WSIFOperation_JCA( 117 Definition aDefinition, 118 Service aService, 119 Port aPort, 120 String aOperationName, 121 String aInputName, 122 String aOutputName, 123 org.apache.wsif.providers.WSIFDynamicTypeMap typeMap, 124 WSIFPort_JCA jcaPort, 125 WSIFProviderJCAExtensions aFactory, 126 Connection aConnection, 127 InteractionSpec aInteractionSpec) { 128 129 super(); 130 this.fieldDefinition = aDefinition; 131 this.fieldInteractionSpec = aInteractionSpec; 132 this.fieldConnection = aConnection; 133 this.fieldFactory = aFactory; 134 this.fieldBinding = aPort.getBinding(); 135 this.fieldOperationName = aOperationName; 136 this.fieldInputName = aInputName; 137 this.fieldOutputName = aOutputName; 138 this.fieldTypeMap = typeMap; 139 this.fieldPort = aPort; 140 this.fieldService = aService; 141 this.fieldJcaPort = jcaPort; 142 } 143 144 157 public boolean executeRequestResponseOperation(WSIFMessage input, WSIFMessage output, WSIFMessage fault) throws WSIFException { 158 159 Trc.entry(this, input, output, fault); 160 if (!input.getParts().hasNext()) 161 input = null; 162 try { 163 fieldFactory.updateInteractionSpec(input, fieldBinding, fieldOperationName, fieldInputName, fieldOutputName, fieldInteractionSpec); 164 if (this.fieldConnection == null){ 165 this.fieldConnection = this.fieldFactory.createConnection(input, this.fieldDefinition, this.fieldService, this.fieldPort, this.fieldTypeMap, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 166 fieldJcaPort.setConnection(fieldConnection); 167 } 168 Interaction interaction = this.fieldConnection.createInteraction(); 169 interaction.execute(this.fieldInteractionSpec, (javax.resource.cci.Record ) input, (javax.resource.cci.Record ) output); 170 interaction.close(); 171 if (output instanceof WSIFMessage_JCA) { 172 ((WSIFMessage_JCA) output).setInteractionSpec(this.fieldInteractionSpec); 173 } 174 fieldFactory.updateOutputMessage(output, fieldBinding, fieldOperationName, fieldInputName, fieldOutputName, fieldInteractionSpec); 175 } 176 catch (ResourceException exn1) { 177 WSIFException newExn = new WSIFException(WSIFResource_JCA.get("WSIF1000E")); 178 newExn.setTargetException(exn1); 179 Trc.exception(exn1); 180 throw newExn; 181 } 182 catch (Throwable exn3) { 183 WSIFException newExn = new WSIFException(WSIFResource_JCA.get("WSIF1008E", exn3.getLocalizedMessage())); 184 newExn.setTargetException(exn3); 185 Trc.exception(newExn); 186 throw newExn; 187 } 188 Trc.exit(); 189 return true; 190 } 191 192 204 public void executeInputOnlyOperation(WSIFMessage input) throws WSIFException { 205 206 Trc.entry(this, input); 207 if (!input.getParts().hasNext()) 208 input = null; 209 try { 210 fieldFactory.updateInteractionSpec(input, fieldBinding, fieldOperationName, fieldInputName, fieldOutputName, fieldInteractionSpec); 211 if (fieldConnection == null){ 212 fieldConnection = this.fieldFactory.createConnection(input, this.fieldDefinition, this.fieldService, this.fieldPort, this.fieldTypeMap, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 213 fieldJcaPort.setConnection(fieldConnection); 214 } 215 Interaction interaction = fieldConnection.createInteraction(); 216 interaction.execute(fieldInteractionSpec, (javax.resource.cci.Record ) input); 217 interaction.close(); 218 } 219 catch (ResourceException exn1) { 220 WSIFException newExn = new WSIFException(WSIFResource_JCA.get("WSIF1000E")); 221 Trc.exception(exn1); 222 newExn.setTargetException(exn1); 223 throw newExn; 224 } 225 catch (Throwable exn3) { 226 WSIFException newExn = new WSIFException(WSIFResource_JCA.get("WSIF1008E", exn3.getLocalizedMessage())); 227 newExn.setTargetException(exn3); 228 Trc.exception(newExn); 229 throw newExn; 230 } 231 Trc.exit(); 232 } 233 234 239 240 public WSIFMessage createFaultMessage() { 241 242 Trc.entry(this); 243 WSIFMessage message = this.fieldFactory.createFaultMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 244 if (message != null) 245 return message; 246 return new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.FAULT_MESSAGE); 247 } 248 249 254 public WSIFMessage createFaultMessage(String name) { 255 256 Trc.entry(this, name); 257 258 WSIFMessage message = this.fieldFactory.createFaultMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 259 if (message != null) { 260 message.setName(name); 261 return message; 262 } 263 message = new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.FAULT_MESSAGE); 264 message.setName(name); 265 return message; 266 } 267 268 273 public WSIFMessage createInputMessage() { 274 275 Trc.entry(this); 276 WSIFMessage message = this.fieldFactory.createInputMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 277 if (message != null) 278 return message; 279 return new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.INPUT_MESSAGE); 280 } 281 282 287 public WSIFMessage createInputMessage(String name) { 288 289 Trc.entry(this, name); 290 WSIFMessage message = this.fieldFactory.createInputMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 291 if (message != null) { 292 message.setName(name); 293 return message; 294 } 295 message = new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.INPUT_MESSAGE); 296 message.setName(name); 297 return message; 298 } 299 300 305 public WSIFMessage createOutputMessage() { 306 307 Trc.entry(this); 308 WSIFMessage message = this.fieldFactory.createOutputMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 309 if (message != null) 310 return message; 311 return new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.OUTPUT_MESSAGE); 312 } 313 314 319 public WSIFMessage createOutputMessage(String name) { 320 321 Trc.entry(this, name); 322 WSIFMessage message = this.fieldFactory.createOutputMessage(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName); 323 if (message != null) { 324 message.setName(name); 325 return message; 326 } 327 message = new WSIFMessage_JCAStreamable(this.fieldDefinition, this.fieldBinding, this.fieldOperationName, this.fieldInputName, this.fieldOutputName, WSIFMessage_JCA.OUTPUT_MESSAGE); 328 message.setName(name); 329 return message; 330 } 331 332 336 public InteractionSpec getInteractionSpec() { 337 return fieldInteractionSpec; 338 } 339 340 344 public void setInteractionSpec(InteractionSpec interactionSpec) { 345 fieldInteractionSpec = interactionSpec; 346 } 347 348 public String toString() { 349 350 StringBuffer buffer = new StringBuffer (); 351 buffer.append(crlf + "[JCAOperation" + crlf); 352 try { 353 if (fieldConnection != null) 354 buffer.append("\tConnection: " + fieldConnection.toString() + crlf); 355 else 356 buffer.append("\tConnection: null" + crlf); 357 358 if (fieldInteractionSpec != null) 359 buffer.append("\tInteractionSpec: " + fieldInteractionSpec.toString() + crlf); 360 else 361 buffer.append("\tInteractionSpec: null" + crlf); 362 363 if (fieldBinding != null) 364 buffer.append("\tBinding: " + fieldBinding.toString() + crlf); 365 else 366 buffer.append("\tBinding: null" + crlf); 367 368 if (fieldOperation != null) 369 buffer.append("\tOperation: " + fieldOperation.toString() + crlf); 370 else 371 buffer.append("\tOperation: null" + crlf); 372 373 if (fieldFactory != null) 374 buffer.append("\tFactory: " + fieldFactory.toString() + crlf); 375 else 376 buffer.append("\tFactory: null" + crlf); 377 378 if (fieldOperationName != null) 379 buffer.append("\tOperationName: " + fieldOperationName + crlf); 380 else 381 buffer.append("\tOperationName: null" + crlf); 382 383 if (fieldInputName != null) 384 buffer.append("\tInputName: " + fieldInputName + crlf); 385 else 386 buffer.append("\tInputName: null" + crlf); 387 388 if (fieldOutputName != null) 389 buffer.append("\tOutputName: " + fieldOutputName + crlf); 390 else 391 buffer.append("\tOutputName: null" + crlf); 392 393 buffer.append("]" + crlf); 394 } 395 catch (Throwable exn) { 396 } 397 return buffer.toString(); 398 } 399 400 403 public WSIFCorrelationId executeRequestResponseAsync(WSIFMessage input, WSIFResponseHandler handler) throws WSIFException { 404 return null; 405 } 406 407 410 public WSIFCorrelationId executeRequestResponseAsync(WSIFMessage input) throws WSIFException { 411 return null; 412 } 413 414 417 public void fireAsyncResponse(Object response) throws WSIFException { 418 419 } 420 423 public boolean processAsyncResponse(Object response, WSIFMessage output, WSIFMessage fault) throws WSIFException { 424 return false; 425 } 426 427 430 public void setContext(WSIFMessage context) { 431 432 } 433 434 437 public WSIFMessage getContext() { 438 439 return null; 440 } 441 442 } | Popular Tags |