1 23 24 package com.sun.enterprise.connectors; 25 26 import java.util.logging.*; 27 import java.util.*; 28 29 import javax.resource.spi.*; 30 import javax.resource.*; 31 import javax.naming.NamingException ; 32 import com.sun.enterprise.deployment.*; 33 import com.sun.logging.LogDomains; 34 import com.sun.enterprise.config.serverbeans.*; 35 import com.sun.enterprise.connectors.util.*; 36 import com.sun.enterprise.connectors.system.*; 37 import com.sun.enterprise.connectors.authentication.*; 38 import java.sql.Connection ; 39 import java.sql.SQLException ; 40 41 50 51 52 public final class ConnectorRuntime implements ConnectorConstants { 53 static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 54 55 private static ConnectorRegistry _registry = null; 56 57 private static ConnectorRuntime _runtime; 58 59 60 private boolean debug=true; 61 private int environment = CLIENT; 62 63 private static ConnectorAdminObjectAdminServiceImpl 64 adminObjectAdmService = null; 65 private static ConnectorConfigurationParserServiceImpl 66 configParserAdmService =null; 67 private static ConnectorConnectionPoolAdminServiceImpl 68 ccPoolAdmService =null; 69 private static ConnectorResourceAdminServiceImpl 70 connectorResourceAdmService =null; 71 private static ConnectorSecurityAdminServiceImpl 72 connectorSecurityAdmService =null; 73 private static ResourceAdapterAdminServiceImpl 74 resourceAdapterAdmService = null; 75 private static ConnectorServiceImpl connectorService=null; 76 77 78 85 86 public static ConnectorRuntime getRuntime() { 87 if (_runtime == null) { 88 _runtime = new ConnectorRuntime(); 89 com.sun.enterprise.util.Utility.setDataDirectProperty(); 90 createServices(); 91 } 92 return _runtime; 93 } 94 95 102 103 public void initialize(int environment) { 104 this.environment = environment; 105 initServices(); 106 } 107 108 114 115 public int getEnviron() { 116 return environment; 117 } 118 119 122 123 private ConnectorRuntime() { 124 _registry = ConnectorRegistry.getInstance(); 125 } 126 127 private static void createServices() { 128 adminObjectAdmService = (ConnectorAdminObjectAdminServiceImpl) 129 ConnectorAdminServicesFactory.getService(ConnectorAdminService.AOR); 130 ccPoolAdmService = ( ConnectorConnectionPoolAdminServiceImpl) 131 ConnectorAdminServicesFactory.getService(ConnectorAdminService.CCP); 132 connectorResourceAdmService = ( ConnectorResourceAdminServiceImpl) 133 ConnectorAdminServicesFactory.getService(ConnectorAdminService.CR); 134 connectorSecurityAdmService = ( ConnectorSecurityAdminServiceImpl) 135 ConnectorAdminServicesFactory.getService(ConnectorAdminService.SEC); 136 resourceAdapterAdmService = ( ResourceAdapterAdminServiceImpl) 137 ConnectorAdminServicesFactory.getService(ConnectorAdminService.RA); 138 configParserAdmService = new ConnectorConfigurationParserServiceImpl(); 139 connectorService = new ConnectorServiceImpl(); 140 } 141 142 private void initServices() { 143 connectorService.initialize(getEnviron()); 144 } 145 146 156 157 public void destroyActiveResourceAdapter(String moduleName) 158 throws ConnectorRuntimeException 159 { 160 resourceAdapterAdmService.destroyActiveResourceAdapter(moduleName); 161 } 162 163 182 183 public void destroyActiveResourceAdapter(String moduleName,boolean cascade) 184 throws ConnectorRuntimeException 185 { 186 resourceAdapterAdmService.destroyActiveResourceAdapter( 187 moduleName,cascade); 188 } 189 190 201 202 public void createActiveResourceAdapter( 203 ConnectorDescriptor connectorDescriptor, 204 String moduleName, 205 String moduleDir, 206 boolean writeSunDescriptor) throws ConnectorRuntimeException 207 { 208 resourceAdapterAdmService.createActiveResourceAdapter( 209 connectorDescriptor,moduleName,moduleDir,writeSunDescriptor); 210 211 } 212 213 222 223 public void createActiveResourceAdapter(String moduleDir , 224 String moduleName, 225 boolean writeSunDescriptor) throws ConnectorRuntimeException 226 { 227 resourceAdapterAdmService.createActiveResourceAdapter( 228 moduleDir,moduleName,writeSunDescriptor); 229 } 230 231 public ConnectionManager obtainConnectionManager(String poolName) 232 throws ConnectorRuntimeException 233 { 234 return this.obtainConnectionManager( poolName, false ); 235 } 236 237 public ConnectionManager obtainConnectionManager(String poolName, 238 boolean forceNoLazyAssoc) 239 throws ConnectorRuntimeException 240 { 241 ConnectionManager mgr = ConnectionManagerFactory. 242 getAvailableConnectionManager(poolName, forceNoLazyAssoc); 243 return mgr; 244 } 245 253 254 public ManagedConnectionFactory obtainManagedConnectionFactory( 255 String poolName) throws ConnectorRuntimeException 256 { 257 return ccPoolAdmService.obtainManagedConnectionFactory(poolName); 258 } 259 260 271 272 public void createConnectorConnectionPool(ConnectorConnectionPool ccp, 273 String connectionDefinitionName , String rarName, 274 com.sun.enterprise.config.serverbeans.ElementProperty[] props, 275 com.sun.enterprise.config.serverbeans.SecurityMap[] securityMaps) 276 throws ConnectorRuntimeException 277 { 278 ccPoolAdmService.createConnectorConnectionPool( 279 ccp,connectionDefinitionName,rarName,props,securityMaps); 280 } 281 282 289 290 public void createConnectorConnectionPool(ConnectorConnectionPool ccp, 291 ConnectionDefDescriptor cdd, String rarName) 292 throws ConnectorRuntimeException 293 { 294 ccPoolAdmService.createConnectorConnectionPool(ccp,cdd,rarName); 295 296 } 297 298 303 304 public void createConnectorConnectionPool( 305 ConnectorConnectionPool connectorPoolObj ) 306 throws ConnectorRuntimeException 307 { 308 ccPoolAdmService.createConnectorConnectionPool( 309 connectorPoolObj); 310 } 311 312 320 321 public void createConnectorConnectionPool( 322 ConnectorConnectionPool connectorPoolObj, String security, 323 Set configProperties) throws ConnectorRuntimeException 324 { 325 ccPoolAdmService.createConnectorConnectionPool( 326 connectorPoolObj,security,configProperties); 327 } 328 329 336 337 public void createConnectorResource(String jndiName, String poolName, 338 String resourceType) throws ConnectorRuntimeException 339 { 340 341 connectorResourceAdmService.createConnectorResource( 342 jndiName,poolName,resourceType); 343 } 344 345 350 351 public String getDefaultPoolName(String jndiName) { 352 return connectorService.getDefaultPoolName(jndiName); 353 } 354 355 public static boolean isJmsRa() { 356 return ResourceAdapterAdminServiceImpl.isJmsRa(); 357 } 358 359 366 367 public String getDefaultPoolName(String moduleName, 368 String connectionDefName) { 369 return connectorService.getDefaultPoolName( 370 moduleName,connectionDefName); 371 } 372 373 380 381 public String getDefaultResourceName(String moduleName, 382 String connectionDefName) { 383 return connectorService.getDefaultResourceName( 384 moduleName,connectionDefName); 385 } 386 387 public void addAdminObject ( 388 String appName, 389 String connectorName, 390 String jndiName, 391 String adminObjectType, 392 Properties props) 393 throws ConnectorRuntimeException 394 { 395 adminObjectAdmService.addAdminObject( 396 appName,connectorName,jndiName,adminObjectType,props); 397 } 398 399 public void deleteAdminObject(String jndiName) 400 throws ConnectorRuntimeException 401 { 402 adminObjectAdmService.deleteAdminObject(jndiName); 403 404 } 405 406 410 411 public void deleteConnectorConnectionPool(String poolName) 412 throws ConnectorRuntimeException 413 { 414 ccPoolAdmService.deleteConnectorConnectionPool(poolName); 415 } 416 417 426 427 public void deleteConnectorConnectionPool(String poolName,boolean cascade) 428 throws ConnectorRuntimeException 429 { 430 431 ccPoolAdmService.deleteConnectorConnectionPool(poolName,cascade); 432 } 433 434 439 440 public void deleteConnectorResource(String jndiName) 441 throws ConnectorRuntimeException 442 { 443 connectorResourceAdmService.deleteConnectorResource(jndiName); 444 445 } 446 447 454 455 public AuthenticationService getAuthenticationService(String rarName, 456 String poolName) { 457 458 return connectorSecurityAdmService.getAuthenticationService( 459 rarName,poolName); 460 } 461 462 463 public JmsRaMapping getJmsRaMapping() { 464 return resourceAdapterAdmService.getJmsRaMapping(); 465 } 466 467 475 476 public String getSecurityPermissionSpec(String moduleName) 477 throws ConnectorRuntimeException 478 { 479 return configParserAdmService.getSecurityPermissionSpec(moduleName); 480 } 481 482 483 499 public boolean testConnectionPool( String poolName ) 500 throws ResourceException { 501 502 return ccPoolAdmService.testConnectionPool(poolName); 503 } 504 505 510 515 516 521 522 public boolean isRarDeployed(String moduleName) { 523 524 return resourceAdapterAdmService.isRarDeployed(moduleName); 525 } 526 527 534 535 public void reCreateActiveResourceAdapter(String moduleName) 536 throws ConnectorRuntimeException { 537 resourceAdapterAdmService.reCreateActiveResourceAdapter(moduleName); 538 } 539 540 547 548 public boolean stopAndRemoveActiveResourceAdapter(String moduleName) { 549 550 return resourceAdapterAdmService.stopAndRemoveActiveResourceAdapter( 551 moduleName); 552 } 553 554 558 559 public void killAllPools(String moduleName) { 560 ccPoolAdmService.killAllPools(moduleName); 561 } 562 563 567 568 public void killPool(String poolName) { 569 ccPoolAdmService.killPool(poolName); 570 } 571 572 577 578 public void addResourceAdapterConfig(String rarName, 579 ResourceAdapterConfig raConfig) throws ConnectorRuntimeException { 580 resourceAdapterAdmService.addResourceAdapterConfig(rarName,raConfig); 581 } 582 583 586 587 public void deleteResourceAdapterConfig(String rarName) { 588 resourceAdapterAdmService.deleteResourceAdapterConfig(rarName); 589 } 590 591 604 public boolean reconfigureConnectorConnectionPool( ConnectorConnectionPool 605 ccp ) throws ConnectorRuntimeException 606 { 607 return ccPoolAdmService.reconfigureConnectorConnectionPool(ccp); 608 } 609 610 625 public boolean reconfigureConnectorConnectionPool( ConnectorConnectionPool 626 ccp, Set excludedProps ) throws ConnectorRuntimeException 627 { 628 return ccPoolAdmService.reconfigureConnectorConnectionPool( 629 ccp,excludedProps); 630 } 631 632 641 642 public void recreateConnectorConnectionPool( ConnectorConnectionPool ccp) 643 throws ConnectorRuntimeException 644 { 645 ccPoolAdmService.recreateConnectorConnectionPool(ccp); 646 } 647 648 652 653 public String [] getConnectionDefinitionNames(String rarName) 654 throws ConnectorRuntimeException 655 { 656 return configParserAdmService.getConnectionDefinitionNames(rarName); 657 } 658 659 663 664 public String [] getAdminObjectInterfaceNames(String rarName) 665 throws ConnectorRuntimeException 666 { 667 return configParserAdmService.getAdminObjectInterfaceNames(rarName); 668 } 669 681 682 public Properties getResourceAdapterConfigProps(String rarName) 683 throws ConnectorRuntimeException 684 { 685 return 686 rarName.indexOf( ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER ) == -1 687 ? configParserAdmService.getResourceAdapterConfigProps(rarName) 688 : new Properties(); 689 } 690 691 704 705 public Properties getMCFConfigProps( 706 String rarName,String connectionDefName) throws ConnectorRuntimeException 707 { 708 return 709 rarName.indexOf( ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER ) == -1 710 ? configParserAdmService.getMCFConfigProps( 711 rarName,connectionDefName) 712 : new Properties(); 713 } 714 715 728 729 public Properties getAdminObjectConfigProps( 730 String rarName,String adminObjectIntf) throws ConnectorRuntimeException 731 { 732 return 733 rarName.indexOf( ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER ) == -1 734 ? configParserAdmService.getAdminObjectConfigProps( 735 rarName,adminObjectIntf) 736 : new Properties(); 737 } 738 739 753 754 public Properties getConnectorConfigJavaBeans(String rarName, 755 String connectionDefName,String type) throws ConnectorRuntimeException 756 { 757 758 return configParserAdmService.getConnectorConfigJavaBeans( 759 rarName,connectionDefName,type); 760 } 761 762 769 770 public String getActivationSpecClass( String rarName, 771 String messageListenerType) throws ConnectorRuntimeException 772 { 773 return configParserAdmService.getActivationSpecClass( 774 rarName,messageListenerType); 775 } 776 777 785 786 public String [] getMessageListenerTypes(String rarName) 787 throws ConnectorRuntimeException 788 { 789 return configParserAdmService.getMessageListenerTypes( rarName); 790 } 791 792 820 821 public Properties getMessageListenerConfigProps(String rarName, 822 String messageListenerType)throws ConnectorRuntimeException 823 { 824 return 825 rarName.indexOf( ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER ) == -1 826 ? configParserAdmService.getMessageListenerConfigProps( 827 rarName,messageListenerType) 828 : new Properties(); 829 } 830 831 843 844 public Properties getMessageListenerConfigPropTypes(String rarName, 845 String messageListenerType) throws ConnectorRuntimeException 846 { 847 return configParserAdmService.getMessageListenerConfigPropTypes( 848 rarName,messageListenerType); 849 } 850 851 855 856 public static boolean isServer() { 857 return connectorService.isServer(); 858 } 859 860 public void loadDeferredResourceAdapter(String rarName) 861 throws ConnectorRuntimeException { 862 connectorService.loadDeferredResourceAdapter(rarName); 863 } 864 865 public boolean checkAndLoadResource(String resName) { 866 return connectorService.checkAndLoadResource(resName); 867 } 868 869 public boolean checkAccessibility(String rarName, ClassLoader loader) { 870 return connectorService.checkAccessibility(rarName, loader); 871 } 872 873 882 public static Set getConnectionDefinitionProperties(String connectionDefinitionClassName) { 883 return ccPoolAdmService.getConnectionDefinitionProperties( 884 connectionDefinitionClassName); 885 } 886 887 897 public static Map getConnectionDefinitionPropertiesAndDefaults(String connectionDefinitionClassName) { 898 return ccPoolAdmService.getConnectionDefinitionPropertiesAndDefaults( 899 connectionDefinitionClassName); 900 } 901 902 906 public ConnectorNamingEventNotifier getResourceRebindEventNotifier(){ 907 return connectorResourceAdmService.getResourceRebindEventNotifier(); 908 } 909 910 918 public void switchOnMatching (String rarName, String poolName) { 919 connectorService.switchOnMatching(rarName, poolName); 920 } 921 922 928 public void switchOnMatchingInJndi (String poolName) 929 throws ConnectorRuntimeException { 930 ccPoolAdmService.switchOnMatching(poolName); 931 } 932 933 941 public ConnectorDescriptor getConnectorDescriptor( String rarName ) 942 throws ConnectorRuntimeException 943 { 944 return connectorService.getConnectorDescriptor( rarName ); 945 946 } 947 948 951 public static void stopAllActiveResourceAdapters(){ 952 resourceAdapterAdmService.stopAllActiveResourceAdapters(); 953 } 954 955 964 public Map getResourceAdapterBeanProperties(String pathToDeployableUnit) throws ConnectorRuntimeException{ 965 return configParserAdmService.getRABeanProperties(pathToDeployableUnit); 966 } 967 968 972 public void initializeConnectorMonitoring() { 973 connectorService.initializeConnectorMonitoring(); 974 } 975 976 977 978 996 public Connection getConnection(String jndiName, String user, String password) 997 throws SQLException 998 { 999 1000 1001 return ccPoolAdmService.getConnection( jndiName, user, password ); 1002 } 1003 1004 1020 public Connection getConnection(String jndiName) 1021 throws SQLException 1022 { 1023 return ccPoolAdmService.getConnection( jndiName ); 1024 } 1025 1026 1032 public boolean isConnectorConnectionPoolDeployed(String poolName) { 1033 return ccPoolAdmService.isConnectorConnectionPoolDeployed(poolName); 1034 } 1035 1036 1039 public MQJMXConnectorInfo[] getMQJMXConnectorInfo(String target) throws 1040 ConnectorRuntimeException { 1041 1049 return MQJMXConnectorHelper.getMQJMXConnectorInfo(target); 1050 } 1051 1052 1055 public boolean isValidJndiSuffix(String name) { 1056 return connectorResourceAdmService.isValidJndiSuffix(name); 1057 } 1058 1059 1065 public Object lookupPMResource(String name) throws NamingException { 1066 return connectorResourceAdmService.lookup(name+PM_JNDI_SUFFIX); 1067 } 1068 1069 1075 public Object lookupNonTxResource(String name) throws NamingException { 1076 return connectorResourceAdmService.lookup(name+NON_TX_JNDI_SUFFIX); 1077 } 1078 1079 1085 public Object lookup(String name) throws NamingException { 1086 return connectorResourceAdmService.lookup(name); 1087 } 1088 1089 1092 public String [] getSystemConnectorsAllowingPoolCreation(){ 1093 return new String [] { 1094 ConnectorConstants.DEFAULT_JMS_ADAPTER, 1095 ConnectorConstants.JAXR_RA_NAME}; 1096 } 1097 1098 1099} 1100 | Popular Tags |