1 23 package com.sun.enterprise.deployment; 24 25 import java.util.*; 26 import java.util.jar.*; 27 import java.io.*; 28 import java.util.zip.*; 29 import java.util.logging.Level ; 30 import com.sun.enterprise.deployment.util.ConnectorVisitor; 31 import com.sun.enterprise.deployment.util.DescriptorVisitor; 32 import com.sun.enterprise.deployment.node.connector.ConnectorNode; 33 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 34 import com.sun.enterprise.deployment.xml.ApplicationTagNames; 35 import com.sun.enterprise.deployment.runtime.connector.SunConnector; 36 import com.sun.enterprise.deployment.util.DOLUtils; 37 import javax.enterprise.deploy.shared.ModuleType ; 38 47 public class ConnectorDescriptor extends BundleDescriptor { 48 49 private boolean isDirty = false; 50 51 private String displayName = ""; 52 private String connectorDescription = ""; 53 private String largeIcon = ""; 54 private String smallIcon = ""; 55 private String vendorName = ""; 56 private String eisType = ""; 57 private String resourceAdapterVersion = ""; 59 private LicenseDescriptor licenseDescriptor = null; 60 61 private Set configProperties; 63 private Set authMechanisms; 64 private Set securityPermissions; 65 private String managedConnectionFactoryImpl = ""; 66 private int transactionSupport = PoolManagerConstants.LOCAL_TRANSACTION; 67 private boolean reauthenticationSupport = false; 68 private String connectionInterface; 69 private String connectionClass; 70 private String connectionFactoryInterface; 71 private String connectionFactoryClass; 72 73 private String resourceAdapterClass = ""; 75 private EnvironmentProperty configProperty = null; 76 private OutboundResourceAdapter outboundRA = null; 77 private InboundResourceAdapter inboundRA = null; 78 private Set adminObjects; 79 80 private String inboundResourceAdapterClass = ""; 83 84 private Set messageListeners; 86 88 91 public ConnectorDescriptor() { 92 this.configProperties = new OrderedSet(); 93 this.authMechanisms = new OrderedSet(); 94 this.securityPermissions = new OrderedSet(); 95 this.adminObjects = new OrderedSet(); 96 97 this.messageListeners = new OrderedSet(); 99 } 100 101 102 106 public String getDefaultSpecVersion() { 107 return ConnectorNode.SPEC_VERSION; 108 } 109 110 116 119 124 127 public String getConnectionFactoryInterface() { 128 throw new UnsupportedOperationException (); 129 } 130 131 134 public void 135 setConnectionFactoryInterface(String connectionFactoryInterface) { 136 throw new UnsupportedOperationException (); 137 } 138 139 142 public String 143 getConnectionFactoryImpl() { 144 throw new UnsupportedOperationException (); 145 } 146 147 150 public void 151 setConnectionFactoryImpl(String connectionFactoryImpl) { 152 throw new UnsupportedOperationException (); 153 } 154 155 158 public String 159 getConnectionInterface() { 160 throw new UnsupportedOperationException (); 161 } 162 163 166 public void 167 setConnectionInterface(String connectionInterface) { 168 throw new UnsupportedOperationException (); 169 } 170 171 174 public String 175 getConnectionImpl() { 176 throw new UnsupportedOperationException (); 177 } 178 179 182 public void 183 setConnectionImpl(String connectionImpl) { 184 throw new UnsupportedOperationException (); 185 } 186 187 190 public String getManagedConnectionFactoryImpl() { 191 throw new UnsupportedOperationException (); 192 } 193 194 197 public void setManagedConnectionFactoryImpl(String managedConnectionFactoryImpl) { 198 throw new UnsupportedOperationException (); 199 } 200 201 204 public boolean supportsReauthentication() { 205 throw new UnsupportedOperationException (); 206 } 207 208 211 public String getReauthenticationSupport() { 212 throw new UnsupportedOperationException (); 213 } 214 215 218 public void setReauthenticationSupport(boolean reauthenticationSupport) { 219 throw new UnsupportedOperationException (); 220 } 221 222 225 public void setReauthenticationSupport(String reauthSupport) { 226 throw new UnsupportedOperationException (); 227 } 228 229 232 public String getTransSupport() { 233 throw new UnsupportedOperationException (); 234 } 235 236 239 public int getTransactionSupport() { 240 throw new UnsupportedOperationException (); 241 } 242 243 246 public void setTransactionSupport(int transactionSupport) { 247 throw new UnsupportedOperationException (); 248 } 249 250 253 public void setTransactionSupport(String support) { 254 throw new UnsupportedOperationException (); 255 } 256 257 260 public Set 261 getAuthMechanisms() { 262 throw new UnsupportedOperationException (); 263 } 264 265 269 public Set getServiceReferenceDescriptors() { 270 return new OrderedSet(); 271 } 272 273 276 public Set 277 getSecurityPermissions() 278 { 279 if (securityPermissions == null) { 280 securityPermissions = new OrderedSet(); 281 } 282 return securityPermissions; 283 } 284 285 288 public boolean 289 addAuthMechanism(AuthMechanism mech) 290 { 291 throw new UnsupportedOperationException (); 292 } 293 294 297 public boolean 298 removeAuthMechanism(AuthMechanism mech) 299 { 300 throw new UnsupportedOperationException (); 301 } 302 303 306 public boolean 307 addAuthMechanism(int mech) 308 { 309 throw new UnsupportedOperationException (); 310 } 311 312 313 316 public boolean 317 removeAuthMechanism(int mech) 318 { 319 throw new UnsupportedOperationException (); 320 } 321 322 325 public void 326 addSecurityPermission(SecurityPermission permission) 327 { 328 this.securityPermissions.add(permission); 329 this.setDirty(); 330 this.changed(); 331 } 332 333 336 public void 337 removeSecurityPermission(SecurityPermission permission) 338 { 339 this.securityPermissions.remove(permission); 340 this.setDirty(); 341 this.changed(); 342 } 343 344 350 352 public String getResourceAdapterClass() { 353 return resourceAdapterClass; 354 } 355 356 public void setResourceAdapterClass (String raClass) { 357 this.resourceAdapterClass = raClass; 358 this.setDirty(); 359 this.changed(); 360 } 361 362 364 public Set getConfigProperties() { 365 return configProperties; 366 } 367 368 370 public void addConfigProperty(EnvironmentProperty configProperty) { 371 this.configProperties.add(configProperty); 372 this.setDirty(); 373 this.changed(); 374 } 375 376 378 public void removeConfigProperty(EnvironmentProperty configProperty) { 379 this.configProperties.remove(configProperty); 380 this.setDirty(); 381 this.changed(); 382 } 383 384 public LicenseDescriptor getLicenseDescriptor() { 385 return licenseDescriptor; 386 } 387 388 public void setLicenseDescriptor (LicenseDescriptor licenseDescriptor) { 389 this.licenseDescriptor = licenseDescriptor; 390 this.setDirty(); 391 this.changed(); 392 } 393 394 public OutboundResourceAdapter getOutboundResourceAdapter() { 395 return this.outboundRA; 396 } 397 398 public void 399 setOutboundResourceAdapter (OutboundResourceAdapter outboundRA) { 400 this.outboundRA = outboundRA; 401 } 402 403 public InboundResourceAdapter getInboundResourceAdapter() { 404 return this.inboundRA; 405 } 406 407 public void 408 setInboundResourceAdapter(InboundResourceAdapter inboundRA) { 409 this.inboundRA = inboundRA; 410 } 411 412 415 public Set getAdminObjects() { 416 return this.adminObjects; 417 } 418 419 422 public void addAdminObject(AdminObject admin) { 423 this.adminObjects.add(admin); 424 this.setDirty(); 425 this.changed(); 426 } 427 428 public void removeAdminObject(AdminObject admin) { 429 this.adminObjects.remove(admin); 430 this.setDirty(); 431 this.changed(); 432 } 433 434 public boolean hasAdminObjects() { 435 return adminObjects.size() > 0; 436 } 437 438 444 445 452 453 public boolean getOutBoundDefined() { 454 return outboundRA != null; 455 } 456 457 464 465 public boolean getInBoundDefined() { 466 return inboundRA != null; 467 } 468 469 478 479 481 482 487 489 public void setDescription(String description) { 490 this.setDirty(); 491 super.setDescription(description); 492 } 493 494 496 public String getConnectorDescription() { 497 return connectorDescription; 498 } 499 500 502 public void setConnectorDescription(String description) { 503 this.connectorDescription = description; 504 this.setDirty(); 505 this.changed(); 506 } 507 508 510 public void setLargeIconUri(String largeIconUri) { 511 this.setDirty(); 512 super.setLargeIconUri(largeIconUri); 513 } 514 515 517 public void setSmallIconUri(String smallIconUri) { 518 this.setDirty(); 519 super.setSmallIconUri(smallIconUri); 520 } 521 522 524 public String getVendorName() { 525 return vendorName; 526 } 527 528 530 public void setVendorName(String vendorName) { 531 this.vendorName = vendorName; 532 this.setDirty(); 533 this.changed(); 534 } 535 536 538 public void setSpecVersion(String specVersion) { 539 super.setSpecVersion(specVersion); 540 this.setDirty(); 541 this.changed(); 542 543 } 544 545 547 public String getEisType() { 548 return eisType; 549 } 550 551 552 554 public void setEisType(String eisType) { 555 this.eisType = eisType; 556 this.setDirty(); 557 this.changed(); 558 } 559 560 562 public String getVersion() { 563 throw new UnsupportedOperationException (); 565 } 566 567 569 public void setVersion(String version) { 570 573 throw new UnsupportedOperationException (); 574 } 575 576 578 public String getResourceAdapterVersion() { 579 return resourceAdapterVersion; 580 } 581 582 584 public void setResourceAdapterVersion(String resourceAdapterVersion) { 585 this.resourceAdapterVersion = resourceAdapterVersion; 586 this.setDirty(); 587 this.changed(); 588 } 589 590 594 596 public String getDeployName() { 597 return getModuleDescriptor().getArchiveUri(); 598 } 599 600 603 public boolean isDirty() { 604 return this.isDirty; 605 } 606 607 private void setDirty() { 608 this.isDirty = true; 609 } 610 611 void doneOpening() { 612 this.isDirty = false; 613 this.changed(); 614 } 615 616 void doneSaving() { 617 this.isDirty = false; 618 this.changed(); 619 } 620 621 623 public void setName(String name) { 624 if (!this.getName().equals(name)) { 625 this.setDirty(); 626 super.setName(name); 627 } 628 } 629 630 635 public void visit(DescriptorVisitor aVisitor) { 636 if (aVisitor instanceof ConnectorVisitor) { 637 visit((ConnectorVisitor) aVisitor); 638 } else { 639 super.visit(aVisitor); 640 } 641 } 642 643 648 public void visit(ConnectorVisitor aVisitor) { 649 aVisitor.accept(this); 650 } 651 652 655 private static void printEntry(ZipEntry e) throws IOException { 656 DOLUtils.getDefaultLogger().log(Level.FINE, e.getName()); 657 } 658 659 662 public ConnectionDefDescriptor 663 getConnectionDefinitionByCFType (String type) 664 { 665 return getConnectionDefinitionByCFType(type, true); 666 } 667 668 675 public ConnectionDefDescriptor 676 getConnectionDefinitionByCFType (String type, boolean useDefault) 677 { 678 Iterator it = this.outboundRA.getConnectionDefs().iterator(); 679 while (it.hasNext()) 680 { 681 ConnectionDefDescriptor desc = (ConnectionDefDescriptor) it.next(); 682 683 if (type == null) 684 { 685 if (useDefault 686 && this.outboundRA.getConnectionDefs().size() == 1) 687 return desc; 688 else 689 return null; 690 } 691 692 if (desc.getConnectionFactoryIntf().equals(type)) 693 return desc; 694 } 695 return null; 696 } 697 698 public int getNumOfSupportedCFs () 699 { 700 return outboundRA.getConnectionDefs().size(); 701 } 702 703 public AdminObject getAdminObjectByType(String type) 704 { 705 Iterator i = getAdminObjects().iterator(); 706 while (i.hasNext()) 707 { 708 AdminObject ao = (AdminObject) i.next(); 709 if (type.equals(ao.getAdminObjectInterface())) 710 return ao; 711 } 712 713 return null; 714 } 715 716 717 720 public void print(StringBuffer toStringBuffer) 721 { 722 StringBuffer buf = toStringBuffer; 723 super.print(buf); 724 725 buf.append("\n displayName : " + super.getName()); 726 buf.append("\n connector_description : " + connectorDescription); 727 buf.append("\n smallIcon : " + super.getSmallIconUri()); 728 buf.append("\n largeIcon : " + super.getLargeIconUri()); 729 buf.append("\n vendorName : " + vendorName); 730 buf.append("\n eisType : " + eisType); 731 buf.append("\n resourceadapter version : " + resourceAdapterVersion); 733 734 if (getLicenseDescriptor() != null) { 736 buf.append("\n license_description : " + getLicenseDescriptor().getDescription()); 737 buf.append("\n licenseRequired : " + getLicenseDescriptor().getLicenseRequiredValue()); 738 } 739 740 buf.append("\n resourceAdapterClass : " + resourceAdapterClass); 741 742 buf.append("\n resourceAdapterClass [" + resourceAdapterClass 743 + "] config properties :"); 744 appendConfigProperties(this.configProperties, buf); 745 746 if (this.outboundRA == null) 747 buf.append("\n Outbound Resource Adapter NOT available"); 748 else 749 { 750 buf.append("\n Outbound Resource Adapter Info : "); 751 752 buf.append("\n connection-definitions: "); 753 for (Iterator i = this.outboundRA.getConnectionDefs().iterator(); 754 i.hasNext();) 755 { 756 buf.append("\n------------\n"); 757 758 ConnectionDefDescriptor conDef = 759 (ConnectionDefDescriptor) i.next(); 760 buf.append("MCF : " 761 + conDef.getManagedConnectionFactoryImpl() + ", "); 762 buf.append("\n MCF [" + 763 conDef.getManagedConnectionFactoryImpl() 764 + "] config properties :"); 765 appendConfigProperties(conDef.getConfigProperties(), buf); 766 767 buf.append("[CF Interface : " 768 + conDef.getConnectionFactoryIntf() + "], "); 769 buf.append("[CF Class : " 770 + conDef.getConnectionFactoryImpl() + "], "); 771 buf.append("[Connection Interface : " 772 + conDef.getConnectionIntf() + "], "); 773 buf.append("[Connection Class : " 774 + conDef.getConnectionImpl() + "] "); 775 776 buf.append("\n------------\n"); 777 } 778 779 buf.append("\n transaction-support : " 780 + this.outboundRA.getTransSupport()); 781 782 buf.append("\n authentication-mechanism: "); 783 for (Iterator i = this.outboundRA.getAuthMechanisms().iterator(); 784 i.hasNext();) 785 { 786 AuthMechanism conf = (AuthMechanism) i.next(); 787 buf.append("\n------------\n"); 788 buf.append("[Type : " + conf.getAuthMechType() + "], "); 789 buf.append("[Interface : " 790 + conf.getCredentialInterface() + "]"); 791 buf.append("\n------------" ); 792 } 793 794 buf.append("\n reauthenticate-support : " 795 + this.outboundRA.getReauthenticationSupport()); 796 797 buf.append("\n security-permission : "); 798 for (Iterator i = 799 getSecurityPermissions().iterator(); 800 i.hasNext();) 801 { 802 SecurityPermission conf = (SecurityPermission) i.next(); 803 buf.append("\n------------\n"); 804 buf.append("[persmission : " + conf.getPermission() + "], "); 805 buf.append("[discription : " + conf.getDescription() + "]"); 806 buf.append("\n------------" ); 807 } 808 809 } 811 if (this.inboundRA == null) 812 buf.append("\n Inbound Resource Adapter NOT available"); 813 else 814 { 815 buf.append("\n Inbound Resource Adapter Info : "); 816 817 buf.append("\n Message Listeners Info : "); 818 for (Iterator i = this.inboundRA.getMessageListeners().iterator(); 819 i.hasNext();) 820 { 821 buf.append("\n------------\n"); 822 MessageListener l = (MessageListener) i.next(); 823 buf.append("[Type : " + l.getMessageListenerType() + "], "); 824 buf.append("[AS Class : " + l.getActivationSpecClass() + "]"); 825 buf.append("\n------------ "); 826 } 827 828 } 830 831 if (this.adminObjects.size() == 0) 832 buf.append("\n Admin Objects NOT available"); 833 else 834 { 835 buf.append("\n Admin Objects Info : "); 836 for (Iterator i = this.adminObjects.iterator(); i.hasNext();) 837 { 838 buf.append("\n------------\n"); 839 AdminObject a = (AdminObject) i.next(); 840 buf.append("[Type : " + a.getAdminObjectInterface() + "], "); 841 buf.append("[Class : " + a.getAdminObjectClass() + "]"); 842 appendConfigProperties(a.getConfigProperties(), buf); 843 buf.append("\n------------ "); 844 } 845 846 } 848 } 849 850 private StringBuffer appendConfigProperties (Set props, StringBuffer buf) 851 { 852 buf.append("\n------------"); 853 for (Iterator i = props.iterator(); i.hasNext();) 854 { 855 EnvironmentProperty config = (EnvironmentProperty) i.next(); 856 buf.append("[Name : " + config.getName() + "], "); 857 buf.append("[Value: " + config.getValue() + "], "); 858 buf.append("[Type : " + config.getType() + "]"); 859 } 860 buf.append("\n------------"); 861 return buf; 862 } 863 864 867 public ModuleType getModuleType() { 868 return ModuleType.RAR; 869 } 870 871 874 public MessageListener getSupportedMessageListener(String type) { 875 if (this.inboundRA == null) { 876 return null; 877 } 878 879 Iterator i = this.inboundRA.getMessageListeners().iterator(); 880 while (i.hasNext()) { 881 MessageListener l = (MessageListener) i.next(); 882 if ((l.getMessageListenerType()).equals(type)) { 883 return l; 884 } 885 } 886 return null; 887 } 888 889 892 public boolean isMessageListenerSupported(String type) { 893 throw new UnsupportedOperationException (); 894 } 895 896 902 903 private SunConnector sunConnector = null; 904 905 910 public SunConnector getSunDescriptor(){ 911 return sunConnector; 912 } 913 914 919 public void setSunDescriptor(SunConnector connector){ 920 this.sunConnector = connector; 921 } 922 923 927 } 928 929 | Popular Tags |