1 16 17 package org.apache.axis2.deployment; 18 19 import org.apache.axis2.deployment.util.DeploymentData; 20 import org.apache.axis2.description.*; 21 import org.apache.axis2.engine.AxisConfigurationImpl; 22 import org.apache.axis2.engine.AxisFault; 23 import org.apache.axis2.engine.MessageReceiver; 24 import org.apache.axis2.transport.TransportListener; 25 import org.apache.axis2.transport.TransportSender; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import javax.xml.namespace.QName ; 30 import javax.xml.stream.XMLInputFactory; 31 import javax.xml.stream.XMLStreamConstants; 32 import javax.xml.stream.XMLStreamException; 33 import javax.xml.stream.XMLStreamReader; 34 import java.io.InputStream ; 35 import java.util.ArrayList ; 36 37 46 public class DeploymentParser implements DeploymentConstants { 47 48 private Log log = LogFactory.getLog(getClass()); 49 private static final String MODULEXMLST = "module"; 51 private static final String SERVICEXMLST = "service"; 53 54 private XMLStreamReader pullparser; 55 56 59 private DeploymentEngine dpengine; 60 61 67 public DeploymentParser(InputStream inputStream, DeploymentEngine engine) 68 throws XMLStreamException { 69 this.dpengine = engine; 70 pullparser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream); 71 } 72 73 public void parseServiceXML(ServiceDescription axisService) throws DeploymentException { 74 boolean END_DOCUMENT = false; 76 try { 78 while (!END_DOCUMENT) { 79 int eventType = pullparser.next(); 80 if (eventType == XMLStreamConstants.END_DOCUMENT) { 81 END_DOCUMENT = true; 82 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 83 String ST = pullparser.getLocalName(); 84 if (ST.equals(SERVICEXMLST)) { 85 procesServiceXML(axisService); 86 } 87 break; 88 } 89 } 90 } catch (XMLStreamException e) { 91 throw new DeploymentException("parser Exception", e); 92 } 93 } 94 95 98 public void processGlobalConfig(AxisConfigurationImpl axisGlobal, String starttag) 99 throws DeploymentException { 100 String START_TAG = starttag; 101 try { 102 boolean END_DOCUMENT = false; 103 while (!END_DOCUMENT) { 104 int eventType = pullparser.next(); 105 if (eventType == XMLStreamConstants.END_DOCUMENT) { 106 END_DOCUMENT = true; 108 break; 109 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 110 String ST = pullparser.getLocalName(); if (START_TAG.equals(ST)) { 112 } else if (PARAMETERST.equals(ST)) { 114 Parameter parameter = processParameter(); 115 axisGlobal.addParameter(parameter); 116 } else if (TRANSPORTSENDER.equals(ST)) { 117 TransportOutDescription transportout = proccessTrasnsportOUT(); 118 dpengine.getAxisConfig().addTransportOut(transportout); 119 } else if (TRANSPORTRECEIVER.equals(ST)) { 120 TransportInDescription transportin = proccessTrasnsportIN(); 121 dpengine.getAxisConfig().addTransportIn(transportin); 122 } else if (TYPEMAPPINGST.equals(ST)) { 123 throw new UnsupportedOperationException ("Type Mappings are not allowed in axis2.xml"); 124 } else if (MESSAGERECEIVER.equals(ST)) { 125 int attribCount = pullparser.getAttributeCount(); 126 if (attribCount == 2) { 127 String attname = pullparser.getAttributeLocalName(0); 128 String attvalue = pullparser.getAttributeValue(0); 129 if (MEP.equals(attname)) { 130 String name = attvalue; 131 attname = pullparser.getAttributeLocalName(1); 132 attvalue = pullparser.getAttributeValue(1); 133 if (CLASSNAME.equals(attname)) { 134 try { 135 Class messageReceiver = null; 136 ClassLoader loader1 = 137 Thread.currentThread().getContextClassLoader(); 138 if (attvalue != null && !"".equals(attvalue)) { 139 messageReceiver = 140 Class.forName(attvalue, true, loader1); 141 axisGlobal.addMessageReceiver( 142 name, 143 (MessageReceiver) messageReceiver.newInstance()); 144 } 145 } catch (ClassNotFoundException e) { 146 throw new DeploymentException( 147 "Error in loading messageRecivers " , e); 148 } catch (IllegalAccessException e) { 149 throw new DeploymentException( 150 "Error in loading messageRecivers " , e); 151 } catch (InstantiationException e) { 152 throw new DeploymentException( 153 "Error in loading messageRecivers " , e); 154 } 155 } else 156 throw new UnsupportedOperationException ( 157 "invalid attributes in axis2.xml (messageReceiver elemet) " 158 + attname); 159 } else 160 throw new UnsupportedOperationException ( 161 "invalid attributes in axis2.xml (messageReceiver elemet) " 162 + attname); 163 } else 164 throw new UnsupportedOperationException ("invalid attributes in axis2.xml (messageReceiver elemet)"); 165 166 } else if (MODULEST.equals(ST)) { 167 int attribCount = pullparser.getAttributeCount(); 168 if (attribCount > 0) { 169 for (int i = 0; i < attribCount; i++) { 170 String attname = pullparser.getAttributeLocalName(i); 171 String attvalue = pullparser.getAttributeValue(i); 172 if (REF.equals(attname)) { 173 DeploymentData.getInstance().addModule(new QName (attvalue)); 174 } 175 } 176 } 177 } else if (PHASE_ORDER.equals(ST)) { 178 int attribCount = pullparser.getAttributeCount(); 179 DeploymentData tempdata = DeploymentData.getInstance(); 180 if (attribCount > 0) { 181 for (int i = 0; i < attribCount; i++) { 182 String attname = pullparser.getAttributeLocalName(i); 183 String attvalue = pullparser.getAttributeValue(i); 184 if (TYPE.equals(attname)) { 185 if (INFLOWST.equals(attvalue)) { 186 tempdata.setINPhases(processPhaseOrder()); 187 } else if (OUTFLOWST.equals(attvalue)) { 188 tempdata.setOUTPhases(processPhaseOrder()); 189 } else if (IN_FAILTFLOW.equals(attvalue)) { 190 tempdata.setIN_FaultPhases(processPhaseOrder()); 191 } else if (OUT_FAILTFLOW.equals(attvalue)) { 192 tempdata.setOUT_FaultPhases(processPhaseOrder()); 193 } else { 194 throw new DeploymentException( 195 "un defined flow type " + ST); 196 } 197 } 198 } 199 } else { 200 throw new DeploymentException( 201 "Flow type is a required attribute in " + ST); 202 } 203 } else { 204 throw new UnsupportedOperationException ( 205 ST + " element is not allowed in the axis2.xml"); 206 } 207 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 208 String endtagname = pullparser.getLocalName(); 209 if (START_TAG.equals(endtagname)) { 210 END_DOCUMENT = true; 211 break; 212 } 213 } 214 } 215 } catch (XMLStreamException e) { 216 throw new DeploymentException("parser Exception", e); 217 } catch (AxisFault e) { 218 throw new DeploymentException(e); 219 } 220 } 221 222 public TransportInDescription proccessTrasnsportIN() throws DeploymentException { 223 TransportInDescription transportin = null; 224 String attname = pullparser.getAttributeLocalName(0); 225 String attvalue = pullparser.getAttributeValue(0); 226 227 int attribCount = pullparser.getAttributeCount(); 228 for (int i = 0; i < attribCount; i++) { 229 attname = pullparser.getAttributeLocalName(i); 230 attvalue = pullparser.getAttributeValue(i); 231 if (ATTNAME.equals(attname)) { 232 transportin = new TransportInDescription(new QName (attvalue)); 233 } else if (transportin != null && CLASSNAME.equals(attname)) { 234 Class reciever = null; 235 try { 236 reciever = 237 Class.forName( 238 attvalue, 239 true, 240 Thread.currentThread().getContextClassLoader()); 241 TransportListener trnsrecievr = (TransportListener) reciever.newInstance(); 242 transportin.setReciver(trnsrecievr); 243 } catch (ClassNotFoundException e) { 244 throw new DeploymentException(e); 245 } catch (IllegalAccessException e) { 246 throw new DeploymentException(e); 247 } catch (InstantiationException e) { 248 throw new DeploymentException(e); 249 } 250 } 251 } 252 boolean END_TRANSPORTS = false; 253 try { 254 while (!END_TRANSPORTS) { 255 int eventType = pullparser.next(); 256 if (eventType == XMLStreamConstants.END_DOCUMENT) { 257 END_TRANSPORTS = true; 258 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 259 String tagnae = pullparser.getLocalName(); 260 if (transportin != null && PARAMETERST.equals(tagnae)) { 261 Parameter parameter = processParameter(); 262 transportin.addParameter(parameter); 263 } else if (transportin != null && INFLOWST.equals(tagnae)) { 264 Flow inFlow = processInFlow(); 265 transportin.setInFlow(inFlow); 266 } else if (transportin != null && OUTFLOWST.equals(tagnae)) { 267 throw new DeploymentException( 268 "OUTFlow dose not support in AxisTransportIN " + tagnae); 269 } else if (transportin != null && IN_FAILTFLOW.equals(tagnae)) { 270 Flow faultFlow = processInFaultFlow(); 271 transportin.setFaultFlow(faultFlow); 272 } else { 273 throw new DeploymentException("Unknown element " + tagnae); 274 } 275 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 276 String endtagname = pullparser.getLocalName(); 277 if (TRANSPORTRECEIVER.equals(endtagname)) { 278 END_TRANSPORTS = true; 279 break; 280 } 281 } 282 } 283 } catch (XMLStreamException e) { 284 throw new DeploymentException("parser Exception", e); 285 } catch (Exception e) { 286 throw new DeploymentException(e); 287 } 288 return transportin; 289 } 290 291 public TransportOutDescription proccessTrasnsportOUT() throws DeploymentException { 292 TransportOutDescription transportout = null; 293 String attname; 294 String attvalue; 295 int attribCount = pullparser.getAttributeCount(); 296 for (int i = 0; i < attribCount; i++) { 297 attname = pullparser.getAttributeLocalName(i); 298 attvalue = pullparser.getAttributeValue(i); 299 if (ATTNAME.equals(attname)) { 300 transportout = new TransportOutDescription(new QName (attvalue)); 301 } else if (transportout != null && CLASSNAME.equals(attname)) { 302 Class sender = null; 303 try { 304 sender = 305 Class.forName( 306 attvalue, 307 true, 308 Thread.currentThread().getContextClassLoader()); 309 TransportSender transportSender = (TransportSender) sender.newInstance(); 310 transportout.setSender(transportSender); 311 } catch (ClassNotFoundException e) { 312 throw new DeploymentException(e); 313 } catch (IllegalAccessException e) { 314 throw new DeploymentException(e); 315 } catch (InstantiationException e) { 316 throw new DeploymentException(e); 317 } 318 } 319 } 320 boolean END_TRANSPORTS = false; 321 try { 322 while (!END_TRANSPORTS) { 323 int eventType = pullparser.next(); 324 if (eventType == XMLStreamConstants.END_DOCUMENT) { 325 END_TRANSPORTS = true; 326 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 327 String tagnae = pullparser.getLocalName(); 328 if (transportout != null && PARAMETERST.equals(tagnae)) { 329 Parameter parameter = processParameter(); 330 transportout.addParameter(parameter); 331 } else if (transportout != null && INFLOWST.equals(tagnae)) { 332 throw new DeploymentException( 333 "InFlow dose not support in TransportOutDescription " + tagnae); 334 } else if (transportout != null && OUTFLOWST.equals(tagnae)) { 335 Flow outFlow = processOutFlow(); 336 transportout.setOutFlow(outFlow); 337 } else if (transportout != null && OUT_FAILTFLOW.equals(tagnae)) { 338 Flow faultFlow = processOutFaultFlow(); 339 transportout.setFaultFlow(faultFlow); 340 } else { 341 throw new DeploymentException("Unknown element " + tagnae); 342 } 343 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 344 String endtagname = pullparser.getLocalName(); 345 if (TRANSPORTSENDER.equals(endtagname)) { 346 END_TRANSPORTS = true; 347 break; 348 } 349 } 350 } 351 } catch (XMLStreamException e) { 352 throw new DeploymentException("parser Exception", e); 353 } catch (Exception e) { 354 throw new DeploymentException(e); 355 } 356 return transportout; 357 } 358 359 362 private void procesServiceXML(ServiceDescription axisService) throws DeploymentException { 363 int attribCount = pullparser.getAttributeCount(); 364 if (attribCount >= 1) { 365 for (int i = 0; i < attribCount; i++) { 366 String attname = pullparser.getAttributeLocalName(i); 367 String attvalue = pullparser.getAttributeValue(i); 368 if (ATQNAME.equals(attname)) { 369 if (attvalue == null || attvalue.trim().equals("")) { 370 axisService.setName( 371 new QName ( 372 getAxisServiceName( 373 dpengine.getCurrentFileItem().getServiceName()))); 374 } else { 375 axisService.setName(new QName (attvalue)); 376 } 377 } else { 378 throw new DeploymentException( 379 attname 380 + " Bad arguments for the service" 381 + getAxisServiceName(dpengine.getCurrentFileItem().getServiceName())); 382 } 383 } 384 } else { 385 axisService.setName( 387 new QName (getAxisServiceName(dpengine.getCurrentFileItem().getServiceName()))); 388 } 389 boolean END_DOCUMENT = false; 390 try { 391 while (!END_DOCUMENT) { 392 int eventType = pullparser.next(); 393 if (eventType == XMLStreamConstants.END_DOCUMENT) { 394 END_DOCUMENT = true; 396 break; 397 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 398 String ST = pullparser.getLocalName(); if (PARAMETERST.equals(ST)) { 400 Parameter parameter = processParameter(); 401 axisService.addParameter(parameter); 402 } else if (DESCRIPTION.equals(ST)) { 404 String desc = processDescription(); 405 axisService.setServiceDescription(desc); 406 } else if (TYPEMAPPINGST.equals(ST)) { 407 throw new UnsupportedOperationException ("Type mapping dose not implemented yet "); 408 } else if (BEANMAPPINGST.equals(ST)) { 410 throw new UnsupportedOperationException ("Bean mapping dose not implemented yet "); 411 } else if (OPRATIONST.equals(ST)) { 413 OperationDescription operation = processOperation(axisService); 414 DeploymentData.getInstance().setOperationPhases(operation); 415 if (operation.getMessageReciever() == null) { 416 try { 417 420 ClassLoader loader1 = 421 Thread.currentThread().getContextClassLoader(); 422 Class messageReceiver = 423 Class.forName( 424 "org.apache.axis2.receivers.RawXMLINOutMessageReceiver", 425 true, 426 loader1); 427 operation.setMessageReciever( 428 (MessageReceiver) messageReceiver.newInstance()); 429 } catch (ClassNotFoundException e) { 430 throw new DeploymentException( 431 "Error in loading messageRecivers " + e.getMessage()); 432 } catch (IllegalAccessException e) { 433 throw new DeploymentException( 434 "Error in loading messageRecivers " + e.getMessage()); 435 } catch (InstantiationException e) { 436 throw new DeploymentException( 437 "Error in loading messageRecivers " + e.getMessage()); 438 } 439 } 440 axisService.addOperation(operation); 441 } else if (INFLOWST.equals(ST)) { 442 Flow inFlow = processInFlow(); 443 axisService.setInFlow(inFlow); 444 } else if (OUTFLOWST.equals(ST)) { 445 Flow outFlow = processOutFlow(); 446 axisService.setOutFlow(outFlow); 447 } else if (IN_FAILTFLOW.equals(ST)) { 448 Flow faultFlow = processInFaultFlow(); 449 axisService.setFaultInFlow(faultFlow); 450 } else if (OUT_FAILTFLOW.equals(ST)) { 451 Flow faultFlow = processOutFaultFlow(); 452 axisService.setFaultOutFlow(faultFlow); 453 } else if (MODULEST.equals(ST)) { 454 attribCount = pullparser.getAttributeCount(); 455 if (attribCount > 0) { 456 for (int i = 0; i < attribCount; i++) { 457 String attname = pullparser.getAttributeLocalName(i); 458 String attvalue = pullparser.getAttributeValue(i); 459 if (REF.equals(attname)) { 460 if (dpengine.getModule(new QName (attvalue)) == null) { 461 throw new DeploymentException( 462 ST 463 + " module is invalid or dose not have bean deployed"); 464 } else { 465 dpengine.getCurrentFileItem().addModule( 466 new QName (attvalue)); 467 } 468 } 469 } 470 } 471 472 } else { 473 throw new DeploymentException( 474 "parser Exception : un supported element" + ST); 475 } 476 } 477 } 478 } catch (XMLStreamException e) { 479 throw new DeploymentException("parser Exception", e); 480 } catch (AxisFault axisFault) { 481 throw new DeploymentException(axisFault); 482 } 483 } 484 485 private String processDescription() throws DeploymentException { 486 String desc = ""; 487 boolean END_DESC = false; 488 try { 489 while (!END_DESC) { 490 int eventType = pullparser.next(); 491 if (eventType == XMLStreamConstants.END_DOCUMENT) { 492 END_DESC = true; 493 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 494 String endtagname = pullparser.getLocalName(); 495 if (DESCRIPTION.equals(endtagname)) { 496 END_DESC = true; 497 break; 498 } 499 500 } else if (eventType == XMLStreamConstants.CHARACTERS) { 501 desc += pullparser.getText(); 502 } 503 } 504 } catch (XMLStreamException e) { 505 throw new DeploymentException("parser Exception", e); 506 } catch (Exception e) { 507 throw new DeploymentException(e); 508 } 509 return desc; 510 } 511 512 private Parameter processParameter() throws DeploymentException { 513 Parameter parameter = new ParameterImpl(); 514 int attribCount = pullparser.getAttributeCount(); 515 if (attribCount == 2) { for (int i = 0; i < attribCount; i++) { 517 String attname = pullparser.getAttributeLocalName(i); 518 String attvalue = pullparser.getAttributeValue(i); 519 if (ATTNAME.equals(attname)) { 520 parameter.setName(attvalue); 521 } else if (ATTLOCKED.equals(attname)) { 522 String boolval = getValue(attvalue); 523 if (boolval.equals("true")) { 524 parameter.setLocked(true); 525 } else if (boolval.equals("false")) { 526 parameter.setLocked(false); 527 } 528 } 529 530 } 531 } else { 532 throw new DeploymentException("bad parameter arguments"); 533 } 534 535 boolean END_PARAMETER = false; 536 String element = ""; try { 538 while (!END_PARAMETER) { 539 int eventType = pullparser.next(); 540 if (eventType == XMLStreamConstants.END_DOCUMENT) { 541 END_PARAMETER = true; 544 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 545 String endtagname = pullparser.getLocalName(); 546 if (PARAMETERST.equals(endtagname)) { 547 END_PARAMETER = true; 548 break; 549 } 550 } else if (eventType == XMLStreamConstants.CHARACTERS) { 551 element += pullparser.getText(); 552 } 553 } 554 } catch (XMLStreamException e) { 555 throw new DeploymentException("parser Exception", e); 556 } catch (Exception e) { 557 throw new DeploymentException(e); 558 } 559 parameter.setValue(element); 561 return parameter; 562 } 563 564 571 private HandlerDescription processHandler() throws DeploymentException { 572 boolean ref_name = false; 574 HandlerDescription handler = new HandlerDescription(); 575 int attribCount = pullparser.getAttributeCount(); 576 577 for (int i = 0; i < attribCount; i++) { 578 String attname = pullparser.getAttributeLocalName(i); 579 String attvalue = pullparser.getAttributeValue(i); 580 581 if (CLASSNAME.equals(attname)) { 582 handler.setClassName(attvalue); 583 } else if (ATTNAME.equals(attname)) { 584 if (ref_name) { 585 throw new DeploymentException( 586 "Hanlder canot have both name and ref " + attvalue); 587 } else { 588 handler.setName(new QName (attvalue)); 589 ref_name = true; 590 } 591 } else if (REF.equals(attname)) { 592 if (ref_name) { 593 throw new DeploymentException( 594 "Hanlder canot have both name and ref " + attvalue); 595 } else { 596 ref_name = true; 597 throw new UnsupportedOperationException ("This should be implmented"); 598 } 599 } 600 } 601 602 boolean END_HANDLER = false; 603 try { 604 while (!END_HANDLER) { 605 int eventType = pullparser.next(); 606 if (eventType == XMLStreamConstants.END_DOCUMENT) { 607 END_HANDLER = true; 610 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 611 String tagnae = pullparser.getLocalName(); 612 if (ORDER.equals(tagnae)) { 613 attribCount = pullparser.getAttributeCount(); 614 for (int i = 0; i < attribCount; i++) { 615 String attname = pullparser.getAttributeLocalName(i); 616 String attvalue = pullparser.getAttributeValue(i); 617 618 if (AFTER.equals(attname)) { 619 handler.getRules().setAfter(attvalue); 620 } else if (BEFORE.equals(attname)) { 621 handler.getRules().setBefore(attvalue); 622 } else if (PHASE.equals(attname)) { 623 handler.getRules().setPhaseName(attvalue); 624 } else if (PHASEFIRST.equals(attname)) { 625 String boolval = getValue(attvalue); 626 if (boolval.equals("true")) { 627 handler.getRules().setPhaseFirst(true); 628 } else if (boolval.equals("false")) { 629 handler.getRules().setPhaseFirst(false); 630 } 631 } else if (PHASELAST.equals(attname)) { 632 String boolval = getValue(attvalue); 633 if (boolval.equals("true")) { 634 handler.getRules().setPhaseLast(true); 635 } else if (boolval.equals("false")) { 636 handler.getRules().setPhaseLast(false); 637 } 638 } 639 640 } 641 } else if (tagnae.equals(PARAMETERST)) { 642 Parameter parameter = processParameter(); 643 handler.addParameter(parameter); 644 } else { 645 throw new DeploymentException( 646 "parser Exception : un supported element" + tagnae); 647 } 648 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 649 String endtagname = pullparser.getLocalName(); 650 if (HANDERST.equals(endtagname)) { 651 END_HANDLER = true; 652 break; 653 } 654 } 655 } 656 } catch (XMLStreamException e) { 657 throw new DeploymentException("parser Exception", e); 658 } catch (Exception e) { 659 throw new DeploymentException(e); 660 } 661 return handler; 663 } 664 665 672 public void processTypeMapping() throws DeploymentException { 673 boolean END_TYPEMAPPING = false; 674 try { 675 while (!END_TYPEMAPPING) { 676 int eventType = pullparser.next(); 677 if (eventType == XMLStreamConstants.END_DOCUMENT) { 678 END_TYPEMAPPING = true; 681 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 682 String endtagname = pullparser.getLocalName(); 683 if (TYPEMAPPINGST.equals(endtagname)) { 684 END_TYPEMAPPING = true; 685 break; 686 } 687 } 688 } 689 } catch (XMLStreamException e) { 690 throw new DeploymentException("parser Exception", e); 691 } catch (Exception e) { 692 throw new DeploymentException(e); 693 } 694 } 695 696 private OperationDescription processOperation(ServiceDescription axisService) throws DeploymentException { 697 OperationDescription operation = null; int attribCount = pullparser.getAttributeCount(); 700 if (attribCount > 0) { for (int i = 0; i < attribCount; i++) { 702 String attname = pullparser.getAttributeLocalName(i); 703 String attvalue = pullparser.getAttributeValue(i); 704 if (ATTNAME.equals(attname)) { 705 if(axisService !=null){ 706 operation = axisService.getOperation(attvalue); 707 } 708 if(operation == null){ 709 operation = new OperationDescription(); 710 operation.setName(new QName (attvalue)); 711 log.info(attvalue + " Operation Name not found in WSDL"); 712 } 713 714 } else if(MEP.equals(attname)){ 715 operation.setMessageExchangePattern(attvalue); 716 }else 717 throw new DeploymentException("bad attribute in operation " + attname); 718 } 719 } 720 boolean END_OPERATION = false; 721 try { 722 while (!END_OPERATION) { 723 int eventType = pullparser.next(); 724 if (eventType == XMLStreamConstants.END_DOCUMENT) { 725 END_OPERATION = true; 726 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 727 String ST = pullparser.getLocalName(); 728 if (MODULEXMLST.equals(ST)) { 729 attribCount = pullparser.getAttributeCount(); 730 if (attribCount > 0) { 731 for (int i = 0; i < attribCount; i++) { 732 String attname = pullparser.getAttributeLocalName(i); 733 String attvalue = pullparser.getAttributeValue(i); 734 if (REF.equals(attname)) { 735 if (dpengine.getModule(new QName (attvalue)) == null) { 736 throw new DeploymentException( 737 ST 738 + " module is invalid or dose not have bean deployed"); 739 } else { 740 operation.addModule(new QName (attvalue)); 741 } 742 } 743 } 744 } 745 }else if(PARAMETERST.equals(ST)){ 746 Parameter parameter = processParameter(); 747 operation.addParameter(parameter); 748 }else if (IN_FAILTFLOW.equals(ST)) { 749 throw new UnsupportedOperationException ("nexted elements are not allowed for M1"); 750 } else if (INFLOWST.equals(ST)) { 751 throw new UnsupportedOperationException ("nexted elements are not allowed for M1"); 752 } else if (OUTFLOWST.equals(ST)) { 753 throw new UnsupportedOperationException ("nexted elements are not allowed for M1"); 754 } else if (MESSAGERECEIVER.equals(ST)) { 755 attribCount = pullparser.getAttributeCount(); 756 if (attribCount > 0) { 757 String attname = pullparser.getAttributeLocalName(0); 758 String attvalue = pullparser.getAttributeValue(0); 759 if (CLASSNAME.equals(attname)) { 760 try { 761 Class messageReceiver = null; 762 ClassLoader loader1= dpengine.getCurrentFileItem().getClassLoader(); 763 if (attvalue != null && !"".equals(attvalue)) { 766 messageReceiver = Class.forName(attvalue, true, loader1); 767 operation.setMessageReciever( 768 (MessageReceiver) messageReceiver.newInstance()); 769 } 770 } catch (ClassNotFoundException e) { 771 throw new DeploymentException( 772 "Error in loading messageRecivers " , e); 773 } catch (IllegalAccessException e) { 774 throw new DeploymentException( 775 "Error in loading messageRecivers " , e); 776 } catch (InstantiationException e) { 777 throw new DeploymentException( 778 "Error in loading messageRecivers " , e); 779 } 780 } else { 781 throw new UnsupportedOperationException ( 782 attname + " is not allowed in messageRecievr element"); 783 } 784 } 785 } 786 787 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 788 String endtagname = pullparser.getLocalName(); 789 if (OPRATIONST.equals(endtagname)) { 790 END_OPERATION = true; 791 break; 792 } 793 } 794 } 795 } catch (XMLStreamException e) { 796 throw new DeploymentException("parser Exception", e); 797 } catch (AxisFault e) { 798 throw new DeploymentException("Axis fault", e); 799 } 800 return operation; 801 } 802 803 810 public void processBeanMapping() throws DeploymentException { 811 boolean END_BEANMAPPING = false; 812 try { 813 while (!END_BEANMAPPING) { 814 int eventType = pullparser.next(); 815 if (eventType == XMLStreamConstants.END_DOCUMENT) { 816 END_BEANMAPPING = true; 819 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 820 String endtagname = pullparser.getLocalName(); 821 if (BEANMAPPINGST.equals(endtagname)) { 822 END_BEANMAPPING = true; 823 break; 824 } 825 } 826 } 827 } catch (XMLStreamException e) { 828 throw new DeploymentException("parser Exception", e); 829 } 830 } 831 832 public void processModule(ModuleDescription module) throws DeploymentException { 833 int attribCount = pullparser.getAttributeCount(); 834 boolean ref_name = false; 835 if (attribCount > 0) { 837 for (int i = 0; i < attribCount; i++) { 838 String attname = pullparser.getAttributeLocalName(i); 839 String attvalue = pullparser.getAttributeValue(i); 840 841 if (ATTNAME.equals(attname)) { 842 if (ref_name) { 843 throw new DeploymentException( 844 "Module canot have both name and ref " + attvalue); 845 } else { 846 module.setName(new QName (attvalue)); 847 ref_name = true; 848 } 849 } else if (CLASSNAME.equals(attname)) { 850 dpengine.getCurrentFileItem().setModuleClass(attvalue); 852 } else if (REF.equals(attname)) { 853 if (ref_name) { 854 throw new DeploymentException( 855 "Module canot have both name and ref " + attvalue); 856 } else { 857 ref_name = true; 859 throw new UnsupportedOperationException ("This should be implemented"); 860 } 861 } 862 } 863 } 864 867 boolean END_MODULE = false; 868 try { 869 while (!END_MODULE) { 870 int eventType = pullparser.next(); 871 if (eventType == XMLStreamConstants.END_DOCUMENT) { 872 END_MODULE = true; 875 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 876 String ST = pullparser.getLocalName(); 877 if (PARAMETERST.equals(ST)) { 878 Parameter parameter = processParameter(); 879 module.addParameter(parameter); 880 } else if (IN_FAILTFLOW.equals(ST)) { 881 Flow faultFlow = processInFaultFlow(); 882 module.setFaultInFlow(faultFlow); 883 } else if (OUT_FAILTFLOW.equals(ST)) { 884 Flow faultFlow = processOutFaultFlow(); 885 module.setFaultOutFlow(faultFlow); 886 } else if (INFLOWST.equals(ST)) { 887 Flow inFlow = processInFlow(); 888 module.setInFlow(inFlow); 889 } else if (OUTFLOWST.equals(ST)) { 890 Flow outFlow = processOutFlow(); 891 module.setOutFlow(outFlow); 892 } else if (OPRATIONST.equals(ST)) { 893 OperationDescription operation = processOperation(null); 894 DeploymentData.getInstance().setOperationPhases(operation); 895 if (operation.getMessageReciever() == null) { 896 try { 897 900 ClassLoader loader1 = 901 Thread.currentThread().getContextClassLoader(); 902 Class messageReceiver = 903 Class.forName( 904 "org.apache.axis2.receivers.RawXMLINOutMessageReceiver", 905 true, 906 loader1); 907 operation.setMessageReciever( 908 (MessageReceiver) messageReceiver.newInstance()); 909 } catch (ClassNotFoundException e) { 910 throw new DeploymentException( 911 "Error in loading messageRecivers " , e); 912 } catch (IllegalAccessException e) { 913 throw new DeploymentException( 914 "Error in loading messageRecivers " , e); 915 } catch (InstantiationException e) { 916 throw new DeploymentException( 917 "Error in loading messageRecivers " , e); 918 } 919 } 920 module.addOperation(operation); 921 } else { 922 throw new UnsupportedOperationException ( 923 ST + "elment is not allowed in module.xml"); 924 } 925 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 927 String endtagname = pullparser.getLocalName(); 928 if (MODULEXMLST.equals(endtagname)) { 929 END_MODULE = true; 930 break; 931 } 932 } 933 } 934 } catch (XMLStreamException e) { 935 throw new DeploymentException("parser Exception", e); 936 } catch (Exception e) { 937 throw new DeploymentException(e); 938 } 939 940 } 941 942 public Flow processInFlow() throws DeploymentException { 943 Flow inFlow = new FlowImpl(); 944 boolean END_INFLOW = false; 945 try { 946 while (!END_INFLOW) { 947 pullparser.next(); 948 int eventType = pullparser.getEventType(); 949 if (eventType == XMLStreamConstants.END_DOCUMENT) { 950 END_INFLOW = true; 953 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 954 String tagnae = pullparser.getLocalName(); 955 if (HANDERST.equals(tagnae)) { 956 HandlerDescription handler = processHandler(); 957 inFlow.addHandler(handler); 958 } else { 959 throw new DeploymentException( 960 "parser Exception : un supported element" + tagnae); 961 } 962 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 963 String endtagname = pullparser.getLocalName(); 964 if (INFLOWST.equals(endtagname)) { 965 END_INFLOW = true; 966 break; 967 } 968 } 969 } 970 } catch (XMLStreamException e) { 971 throw new DeploymentException("parser Exception", e); 972 } catch (Exception e) { 973 throw new DeploymentException(e); 974 } 975 return inFlow; 976 } 977 978 public Flow processOutFlow() throws DeploymentException { 979 Flow outFlow = new FlowImpl(); 980 boolean END_OUTFLOW = false; 981 try { 982 while (!END_OUTFLOW) { 983 int eventType = pullparser.next(); 984 if (eventType == XMLStreamConstants.END_DOCUMENT) { 985 END_OUTFLOW = true; 988 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 989 String tagnae = pullparser.getLocalName(); 990 if (HANDERST.equals(tagnae)) { 991 HandlerDescription handler = processHandler(); 992 outFlow.addHandler(handler); 993 } else { 994 throw new DeploymentException( 995 "parser Exception : un supported element" + tagnae); 996 } 997 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 998 String endtagname = pullparser.getLocalName(); 999 if (OUTFLOWST.equals(endtagname)) { 1000 END_OUTFLOW = true; 1001 break; 1002 } 1003 } 1004 } 1005 } catch (XMLStreamException e) { 1006 throw new DeploymentException("parser Exception", e); 1007 } catch (Exception e) { 1008 throw new DeploymentException(e); 1009 } 1010 1011 return outFlow; 1012 } 1013 1014 public Flow processInFaultFlow() throws DeploymentException { 1015 Flow faultFlow = new FlowImpl(); 1016 boolean END_FAULTFLOW = false; 1017 try { 1018 while (!END_FAULTFLOW) { 1019 int eventType = pullparser.next(); 1020 if (eventType == XMLStreamConstants.END_DOCUMENT) { 1021 END_FAULTFLOW = true; 1024 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 1025 String tagnae = pullparser.getLocalName(); 1026 if (HANDERST.equals(tagnae)) { 1027 HandlerDescription handler = processHandler(); 1028 faultFlow.addHandler(handler); 1029 } else { 1030 throw new DeploymentException( 1031 "parser Exception : un supported element" + tagnae); 1032 } 1033 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 1034 String endtagname = pullparser.getLocalName(); 1035 if (IN_FAILTFLOW.equals(endtagname)) { 1036 END_FAULTFLOW = true; 1037 break; 1038 } 1039 } 1040 } 1041 } catch (XMLStreamException e) { 1042 throw new DeploymentException("parser Exception", e); 1043 } catch (Exception e) { 1044 throw new DeploymentException(e); 1045 } 1046 return faultFlow; 1047 } 1048 1049 public Flow processOutFaultFlow() throws DeploymentException { 1050 Flow faultFlow = new FlowImpl(); 1051 boolean END_FAULTFLOW = false; 1052 try { 1053 while (!END_FAULTFLOW) { 1054 int eventType = pullparser.next(); 1055 if (eventType == XMLStreamConstants.END_DOCUMENT) { 1056 END_FAULTFLOW = true; 1059 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 1060 String tagnae = pullparser.getLocalName(); 1061 if (HANDERST.equals(tagnae)) { 1062 HandlerDescription handler = processHandler(); 1063 faultFlow.addHandler(handler); 1064 } else { 1065 throw new DeploymentException( 1066 "parser Exception : un supported element" + tagnae); 1067 } 1068 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 1069 String endtagname = pullparser.getLocalName(); 1070 if (OUT_FAILTFLOW.equals(endtagname)) { 1071 END_FAULTFLOW = true; 1072 break; 1073 } 1074 } 1075 } 1076 } catch (XMLStreamException e) { 1077 throw new DeploymentException("parser Exception", e); 1078 } catch (Exception e) { 1079 throw new DeploymentException(e); 1080 } 1081 return faultFlow; 1082 } 1083 1084 public ArrayList processPhaseOrder() throws DeploymentException { 1085 boolean END_PHASEORDER = false; 1086 ArrayList pahseList = new ArrayList (); 1087 try { 1088 while (!END_PHASEORDER) { 1089 int eventType = pullparser.next(); 1090 if (eventType == XMLStreamConstants.END_DOCUMENT) { 1091 END_PHASEORDER = true; 1092 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 1093 String tagnae = pullparser.getLocalName(); 1094 if (PHASEST.equals(tagnae)) { 1095 String attname = pullparser.getAttributeLocalName(0); 1096 String attvalue = pullparser.getAttributeValue(0); 1097 if (ATTNAME.equals(attname)) { 1098 pahseList.add(attvalue); 1099 } 1100 } else { 1101 throw new DeploymentException( 1102 "parser Exception : un supported element" + tagnae); 1103 } 1104 } else if (eventType == XMLStreamConstants.END_ELEMENT) { 1105 String endtagname = pullparser.getLocalName(); 1106 if (PHASE_ORDER.equals(endtagname)) { 1107 END_PHASEORDER = true; 1108 break; 1109 } 1110 } 1111 } 1112 } catch (XMLStreamException e) { 1113 throw new DeploymentException("parser Exception", e); 1114 } catch (Exception e) { 1115 throw new DeploymentException(e); 1116 } 1117 return pahseList; 1118 } 1119 1120 1126 private String getValue(String in) { 1127 char seperator = ':'; 1128 String value = null; 1129 int index = in.indexOf(seperator); 1130 if (index > 0) { 1131 value = in.substring(index + 1, in.length()); 1132 return value; 1133 } 1134 return in; 1135 } 1136 1137 1144 private String getAxisServiceName(String fileName) { 1145 char seperator = '.'; 1146 String value = null; 1147 int index = fileName.indexOf(seperator); 1148 if (index > 0) { 1149 value = fileName.substring(0, index); 1150 return value; 1151 } 1152 return fileName; 1153 } 1154 1155 1158 public void procesModuleXML(ModuleDescription module) throws DeploymentException { 1159 boolean END_DOCUMENT = false; 1160 try { 1161 while (!END_DOCUMENT) { 1162 int eventType = pullparser.next(); 1163 if (eventType == XMLStreamConstants.END_DOCUMENT) { 1164 END_DOCUMENT = true; 1166 } else if (eventType == XMLStreamConstants.START_ELEMENT) { 1167 String ST = pullparser.getLocalName(); 1168 if (MODULEXMLST.equals(ST)) { 1169 processModule(module); 1170 } else { 1173 throw new DeploymentException( 1174 "parser Exception : un supported element" + ST); 1175 } 1176 break; 1178 } 1179 } 1180 } catch (XMLStreamException e) { 1181 throw new DeploymentException("parser Exception", e); 1182 } 1183 } 1184} 1185 | Popular Tags |