1 19 package org.netbeans.modules.j2ee.sun.bridge.apis; 20 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 import javax.enterprise.deploy.spi.DeploymentManager ; 26 import javax.management.Attribute ; 27 import javax.management.ObjectName ; 28 import org.netbeans.modules.j2ee.sun.ide.controllers.*; 29 30 import org.netbeans.modules.j2ee.sun.util.NodeTypes; 31 32 import com.sun.appserv.management.base.AMX; 33 import com.sun.appserv.management.base.Util; 34 import com.sun.appserv.management.client.AppserverConnectionSource; 35 import com.sun.appserv.management.config.AdminObjectResourceConfig; 36 import com.sun.appserv.management.config.ConfigConfig; 37 import com.sun.appserv.management.config.ConnectorConnectionPoolConfig; 38 import com.sun.appserv.management.config.ConnectorResourceConfig; 39 import com.sun.appserv.management.config.CustomResourceConfig; 40 import com.sun.appserv.management.config.DomainConfig; 41 import com.sun.appserv.management.config.J2EEApplicationConfig; 42 import com.sun.appserv.management.config.JDBCConnectionPoolConfig; 43 import com.sun.appserv.management.config.JDBCResourceConfig; 44 import com.sun.appserv.management.config.JNDIResourceConfig; 45 import com.sun.appserv.management.config.JavaConfig; 46 import com.sun.appserv.management.config.LogServiceConfig; 47 import com.sun.appserv.management.config.MailResourceConfig; 48 import com.sun.appserv.management.config.ModuleLogLevelsConfig; 49 import com.sun.appserv.management.config.PersistenceManagerFactoryResourceConfig; 50 import com.sun.appserv.management.config.ResourceConfig; 51 import com.sun.appserv.management.config.StandaloneServerConfig; 52 import com.sun.appserv.management.config.WebModuleConfig; 53 import com.sun.appserv.management.j2ee.J2EEServer; 54 55 56 57 63 public class AppserverMgmtController extends AppserverMgmtControllerBase { 64 65 66 75 public AppserverMgmtController(final DeploymentManager deployMgr, 76 final AppserverConnectionSource connection) { 77 super(deployMgr, connection); 78 } 79 80 81 89 public J2EEServerMgmtController getJ2EEServerMgmtController() { 90 return getJ2EEServerMgmtController(DAS_SERVER_NAME); 91 } 92 93 94 103 public J2EEServerMgmtController getJ2EEServerMgmtController( 104 final String serverName) { 105 Map serverMap = getJ2EEDomain().getServerMap(); 106 J2EEServer j2eeServer = 107 (J2EEServer) ControllerUtil.getAMXComponentFromMap( 108 serverMap, serverName); 109 return new J2EEServerMgmtController(j2eeServer, getDeploymentManager(), 110 appMgmtConnection); 111 } 112 113 114 117 public String [] getJDBCResources() { 118 return getComponentNamesFromMap(getDomainConfig(). 119 getJDBCResourceConfigMap()); 120 } 121 122 123 126 public String [] getJDBCConnectionPools() { 127 return getComponentNamesFromMap(getDomainConfig(). 128 getJDBCConnectionPoolConfigMap()); 129 } 130 131 132 135 public String [] getJMSConnectionFactories() { 136 return getConnectorResources(); 137 } 138 139 140 143 public String [] getDestinationResources() { 144 return getAdminObjectResources(); 145 } 146 147 148 151 public String [] getJavaMailResources() { 152 return getComponentNamesFromMap( 153 getDomainConfig().getMailResourceConfigMap()); 154 } 155 156 159 public String [] getConnectorResources() { 160 return getComponentNamesFromMap( 161 getDomainConfig().getConnectorResourceConfigMap()); 162 } 163 164 167 public String [] getCustomResources() { 168 return getComponentNamesFromMap( 169 getDomainConfig().getCustomResourceConfigMap()); 170 } 171 172 175 public String [] getExternalResources() { 176 return getComponentNamesFromMap( 177 getDomainConfig().getJNDIResourceConfigMap()); 178 } 179 180 183 public String [] getConnectorConnectionPools() { 184 return getComponentNamesFromMap( 185 getDomainConfig().getConnectorConnectionPoolConfigMap()); 186 } 187 188 191 public String [] getAdminObjectResources() { 192 return getComponentNamesFromMap( 193 getDomainConfig().getAdminObjectResourceConfigMap()); 194 } 195 196 197 200 public String [] getPersistenceManagerFactoryResources() { 201 return getComponentNamesFromMap( 202 getDomainConfig().getPersistenceManagerFactoryResourceConfigMap()); 203 } 204 205 206 209 public String [] getWebModules() { 210 return getComponentNamesFromMap( 211 getDomainConfig().getWebModuleConfigMap()); 212 } 213 214 215 218 public String [] getEnterpriseApplications() { 219 return getComponentNamesFromMap( 220 getDomainConfig().getJ2EEApplicationConfigMap()); 221 } 222 223 224 230 public java.util.Map getJDBCResourceProperties( 231 final String jdbcResourceName, 232 final List propsToIgnore) { 233 JDBCResourceConfig res = getJDBCResourceConfigByName(jdbcResourceName); 234 return getPropertiesFromBackend(NodeTypes.JDBC_RESOURCE, res, 235 propsToIgnore); 236 } 237 238 239 245 public java.util.Map getJDBCConnectionPoolProperties( 246 final String jdbcConnPoolName, 247 final List propsToIgnore) { 248 JDBCConnectionPoolConfig res = 249 getJDBCConnectionPoolConfigByName(jdbcConnPoolName); 250 return getPropertiesFromBackend(NodeTypes.CONNECTION_POOL, res, 251 propsToIgnore); 252 } 253 254 255 262 public java.util.Map getJVMProperties(final String serverName, 263 final List propsToIgnore) { 264 JavaConfig javaConfig = getReferencedConfig(serverName).getJavaConfig(); 265 return getPropertiesFromBackend(NodeTypes.JVM, javaConfig, 266 propsToIgnore); 267 } 268 269 275 public java.util.Map getPersistenceManagerFactoryProperties( 276 final String pmResourceName, 277 final List propsToIgnore) { 278 PersistenceManagerFactoryResourceConfig res = 279 getPersistenceManagerResourceFactoryConfigByName(pmResourceName); 280 return getPropertiesFromBackend(NodeTypes.PM_RESOURCE, res, 281 propsToIgnore); 282 } 283 284 291 public java.util.Map getJMSConnectionFactoryProperties( 292 final String jmsConnFactoryName, 293 final List propsToIgnore) { 294 ConnectorResourceConfig res = 295 getConnectorResourceConfigByName(jmsConnFactoryName); 296 return getPropertiesFromBackend(NodeTypes.CONNECTION_FACTORY, res, 297 propsToIgnore); 298 } 299 300 301 308 public java.util.Map getDestinationResourceProperties( 309 final String destResName, 310 final List propsToIgnore) { 311 AdminObjectResourceConfig res = 312 getAdminObjectResourceConfigByName(destResName); 313 return getPropertiesFromBackend(NodeTypes.DESTINATION_RESOURCE, res, 314 propsToIgnore); 315 } 316 317 318 324 public java.util.Map getJavaMailResourceProperties( 325 final String mailResourceName, 326 final List propsToIgnore) { 327 MailResourceConfig res = getMailResourceConfigByName(mailResourceName); 328 return getPropertiesFromBackend(NodeTypes.MAIL_RESOURCE, res, 329 propsToIgnore); 330 } 331 332 333 339 public java.util.Map getConnectorConnectionPoolProperties( 340 final String poolName, 341 final List propsToIgnore) { 342 ConnectorConnectionPoolConfig res = 343 getConnectorConnectionPoolConfigByName(poolName); 344 return getPropertiesFromBackend(NodeTypes.CONNECTOR_CONNECTION_POOL, 345 res, propsToIgnore); 346 } 347 348 349 355 public java.util.Map getAdminObjectResourceProperties( 356 final String resName, 357 final List propsToIgnore) { 358 AdminObjectResourceConfig res = 359 getAdminObjectResourceConfigByName(resName); 360 return getPropertiesFromBackend(NodeTypes.ADMIN_OBJECT_RESOURCE, res, 361 propsToIgnore); 362 } 363 364 365 371 public java.util.Map getConnectorResourceProperties( 372 final String resName, 373 final List propsToIgnore) { 374 ConnectorResourceConfig res = 375 getConnectorResourceConfigByName(resName); 376 return getPropertiesFromBackend(NodeTypes.CONNECTOR_RESOURCE, res, 377 propsToIgnore); 378 } 379 380 381 387 public java.util.Map getCustomResourceProperties( 388 final String resName, 389 final List propsToIgnore) { 390 CustomResourceConfig res = 391 getCustomResourceConfigByName(resName); 392 return getPropertiesFromBackend(NodeTypes.CUSTOM_RESOURCE, res, 393 propsToIgnore); 394 } 395 396 402 public java.util.Map getExternalResourceProperties( 403 final String moduleName, 404 final List propsToIgnore) { 405 JNDIResourceConfig res = 406 getJNDIResourceConfigByName(moduleName); 407 return getPropertiesFromBackend(NodeTypes.EXTERNAL_RESOURCE, res, 408 propsToIgnore); 409 } 410 411 412 416 public Attribute setExternalResourceProperty(String resName, String attributeName, 417 Object value) { 418 419 testIfServerInDebug(); 420 421 JNDIResourceConfig res = 422 getJNDIResourceConfigByName(resName); 423 Attribute attr = ControllerUtil.setAttributeValue(res, attributeName, value, 424 getMBeanServerConnection()); 425 return attr; 426 } 427 428 429 433 public String [] getClusters() { 434 return getComponentNamesFromMap(getClustersMap()); 435 } 436 437 438 StandaloneServerConfig getStandaloneServerConfigByName( 439 String serverName) { 440 java.util.Map map = getStandaloneServerInstancesMap(); 441 return (StandaloneServerConfig)map.get(serverName); 442 } 443 444 445 448 JDBCResourceConfig getJDBCResourceConfigByName( 449 String jdbcResourceName) { 450 java.util.Map map = getDomainConfig().getJDBCResourceConfigMap(); 451 return (JDBCResourceConfig)map.get(jdbcResourceName); 452 } 453 454 455 458 MailResourceConfig getMailResourceConfigByName( 459 String mailResourceName) { 460 java.util.Map map = getDomainConfig().getMailResourceConfigMap(); 461 return (MailResourceConfig)map.get(mailResourceName); 462 } 463 464 465 468 JNDIResourceConfig getJNDIResourceConfigByName( 469 String resName) { 470 java.util.Map map = getDomainConfig().getJNDIResourceConfigMap(); 471 return (JNDIResourceConfig)map.get(resName); 472 } 473 474 477 JDBCConnectionPoolConfig getJDBCConnectionPoolConfigByName( 478 String jdbcConnPoolName) { 479 java.util.Map map = getDomainConfig().getJDBCConnectionPoolConfigMap(); 480 return (JDBCConnectionPoolConfig)map.get(jdbcConnPoolName); 481 } 482 483 486 492 495 ConnectorResourceConfig getConnectorResourceConfigByName( 496 String connResourceName) { 497 java.util.Map map = 498 getDomainConfig().getConnectorResourceConfigMap(); 499 return (ConnectorResourceConfig)map.get(connResourceName); 500 } 501 502 505 ConnectorConnectionPoolConfig getConnectorConnectionPoolConfigByName( 506 String connPoolName) { 507 java.util.Map map = 508 getDomainConfig().getConnectorConnectionPoolConfigMap(); 509 return (ConnectorConnectionPoolConfig)map.get(connPoolName); 510 } 511 512 515 CustomResourceConfig getCustomResourceConfigByName(String resName) { 516 java.util.Map map = 517 getDomainConfig().getCustomResourceConfigMap(); 518 return (CustomResourceConfig)map.get(resName); 519 } 520 521 524 AdminObjectResourceConfig getAdminObjectResourceConfigByName( 525 String adminObjName) { 526 java.util.Map map = getDomainConfig().getAdminObjectResourceConfigMap(); 527 return (AdminObjectResourceConfig)map.get(adminObjName); 528 } 529 530 533 PersistenceManagerFactoryResourceConfig 534 getPersistenceManagerResourceFactoryConfigByName( 535 String pmResourceName) { 536 java.util.Map map = 537 getDomainConfig().getPersistenceManagerFactoryResourceConfigMap(); 538 return (PersistenceManagerFactoryResourceConfig)map.get(pmResourceName); 539 } 540 541 542 545 WebModuleConfig getWebModuleConfigByName(String webModuleName) { 546 java.util.Map map = getDomainConfig().getWebModuleConfigMap(); 547 return (WebModuleConfig)map.get(webModuleName); 548 } 549 550 551 554 J2EEApplicationConfig getJ2EEApplicationConfigByName(String appName) { 555 java.util.Map map = 556 getDomainConfig().getJ2EEApplicationConfigMap(); 557 return (J2EEApplicationConfig)map.get(appName); 558 } 559 560 564 private String [] getComponentNamesFromMap(java.util.Map map) { 565 return ControllerUtil.getComponentNamesFromMap(map); 566 } 567 568 572 java.util.Map getClustersMap() { 573 return getDomainConfig().getClusterConfigMap(); 574 } 575 576 580 java.util.Map getStandaloneServerInstancesMap() { 581 return getDomainConfig().getStandaloneServerConfigMap(); 582 } 583 584 585 588 public ConfigConfig getReferencedConfig(String serverName) { 589 StandaloneServerConfig serverConfig = 590 getStandaloneServerConfigByName(serverName); 591 DomainConfig config = (DomainConfig)serverConfig.getContainer(); 592 AMX component = 593 ControllerUtil.getAMXComponentFromMap(config.getConfigConfigMap(), 594 serverConfig.getReferencedConfigName()); 595 return (ConfigConfig)component; 596 } 597 598 599 603 public Attribute setJDBCResourceProperty(String jdbcName, String attributeName, 604 Object value) { 605 606 testIfServerInDebug(); 607 JDBCResourceConfig res = getJDBCResourceConfigByName(jdbcName); 608 Attribute attr = ControllerUtil.setAttributeValue(res, attributeName, value, 609 getMBeanServerConnection()); 610 return attr; 611 } 612 613 617 public Attribute setJDBCConnectionPoolProperty(String resName, 618 String attributeName, Object value) { 619 620 testIfServerInDebug(); 621 622 Attribute attr = ControllerUtil.setAttributeValue( 623 getJDBCConnectionPoolConfigByName(resName), attributeName, value, 624 getMBeanServerConnection()); 625 return attr; 626 } 627 628 629 633 public Attribute setJMSResourceProperty(String resName, 634 String attributeName, Object value) { 635 636 testIfServerInDebug(); 637 638 Attribute attr = ControllerUtil.setAttributeValue( 639 getConnectorResourceConfigByName(resName), attributeName, value, 640 getMBeanServerConnection()); 641 return attr; 642 } 643 644 648 public Attribute setDestinationResourceProperty(String resName, 649 String attributeName, Object value) { 650 651 testIfServerInDebug(); 652 653 Attribute attr = ControllerUtil.setAttributeValue( 654 getAdminObjectResourceConfigByName(resName), attributeName, value, 655 getMBeanServerConnection()); 656 return attr; 657 } 658 659 660 664 public Attribute setJavaMailResourceProperty(String resName, 665 String attributeName, Object value) { 666 667 testIfServerInDebug(); 668 669 Attribute attr = ControllerUtil.setAttributeValue( 670 this.getMailResourceConfigByName(resName), attributeName, value, 671 getMBeanServerConnection()); 672 return attr; 673 } 674 675 676 680 public Attribute setPersistenceManagerResourceFactoryProperty(String resName, 681 String attributeName, Object value) { 682 683 testIfServerInDebug(); 684 685 Attribute attr = ControllerUtil.setAttributeValue( 686 getPersistenceManagerResourceFactoryConfigByName(resName), 687 attributeName, value, getMBeanServerConnection()); 688 return attr; 689 } 690 691 695 public Attribute setConnectorResourceProperty(String resName, 696 String attributeName, Object value) { 697 Attribute attr = ControllerUtil.setAttributeValue( 698 getConnectorResourceConfigByName(resName), attributeName, 699 value, getMBeanServerConnection()); 700 return attr; 701 } 702 703 704 708 public Attribute setConnectorConnectionPoolProperty(String resName, 709 String attributeName, Object value) { 710 711 testIfServerInDebug(); 712 713 Attribute attr = ControllerUtil.setAttributeValue( 714 getConnectorConnectionPoolConfigByName(resName), attributeName, 715 value, getMBeanServerConnection()); 716 return attr; 717 } 718 719 720 724 public Attribute setAdminObjectResourceProperty(String resName, 725 String attributeName, Object value) { 726 727 testIfServerInDebug(); 728 729 Attribute attr = ControllerUtil.setAttributeValue( 730 getAdminObjectResourceConfigByName(resName), attributeName, 731 value, getMBeanServerConnection()); 732 return attr; 733 } 734 735 739 public Attribute setJVMProperty(String serverName, String attributeName, 740 Object value) { 741 742 testIfServerInDebug(); 743 744 Attribute attr = ControllerUtil.setAttributeValue( 745 getReferencedConfig(serverName).getJavaConfig(), attributeName, 746 value, getMBeanServerConnection()); 747 return attr; 748 } 749 750 751 755 public Attribute setJMSConnectionFactoryProperty(String resName, 756 String attributeName, Object value) { 757 758 testIfServerInDebug(); 759 760 Attribute attr = ControllerUtil.setAttributeValue( 761 getConnectorResourceConfigByName(resName), attributeName, value, 762 getMBeanServerConnection()); 763 return attr; 764 } 765 766 770 public Attribute setCustomResourceProperty(String resName, 771 String attributeName, Object value) { 772 773 testIfServerInDebug(); 774 775 Attribute attr = ControllerUtil.setAttributeValue( 776 getCustomResourceConfigByName(resName), attributeName, value, 777 getMBeanServerConnection()); 778 return attr; 779 } 780 781 782 787 public void deleteAdminObjectResource(final String resName) { 788 AdminObjectResourceConfig res = 789 getAdminObjectResourceConfigByName(resName); 790 if(isEightPlatform()){ 791 deleteResourceFromBackend_WorkaroundForPE( 792 NodeTypes.ADMIN_OBJECT_RESOURCE, resName); 793 }else{ 794 removeResourceRef(res, resName); 795 getDomainConfig().removeAdminObjectResourceConfig(resName); 796 } 797 798 } 799 800 801 806 public void deleteExternalResource(final String resName) { 807 JNDIResourceConfig res = 808 getJNDIResourceConfigByName(resName); 809 if(isEightPlatform()){ 810 deleteResourceFromBackend_WorkaroundForPE( 811 NodeTypes.EXTERNAL_RESOURCE, resName); 812 }else{ 813 removeResourceRef(res, resName); 814 getDomainConfig().removeJNDIResourceConfig(resName); 815 } 816 } 817 818 819 824 public void deleteCustomResource(final String resName) { 825 CustomResourceConfig res = 826 getCustomResourceConfigByName(resName); 827 if(isEightPlatform()){ 828 deleteResourceFromBackend_WorkaroundForPE( 829 NodeTypes.CUSTOM_RESOURCE, resName); 830 }else{ 831 removeResourceRef(res, resName); 832 getDomainConfig().removeCustomResourceConfig(resName); 833 } 834 } 835 836 837 842 public void deleteJMSConnectionFactory(final String resName) { 843 ConnectorResourceConfig res = 844 getConnectorResourceConfigByName(resName); 845 if(isEightPlatform()){ 846 deleteResourceFromBackend_WorkaroundForPE( 847 NodeTypes.CONNECTION_FACTORY, resName); 848 }else{ 849 removeResourceRef(res, resName); 850 getDomainConfig().removeConnectorResourceConfig(resName); 851 } 852 } 853 854 855 860 public void deleteJDBCConnectionPool(final String resName) { 861 JDBCConnectionPoolConfig res = 862 getJDBCConnectionPoolConfigByName(resName); 863 if(isEightPlatform()){ 864 deleteResourceFromBackend_WorkaroundForPE( 865 NodeTypes.CONNECTION_POOL, resName); 866 }else 867 getDomainConfig().removeJDBCConnectionPoolConfig(resName); 868 } 869 870 871 876 public void deleteConnectorConnectionPool(final String resName) { 877 ConnectorConnectionPoolConfig res = 878 getConnectorConnectionPoolConfigByName(resName); 879 if(isEightPlatform()){ 880 deleteResourceFromBackend_WorkaroundForPE( 881 NodeTypes.CONNECTOR_CONNECTION_POOL, resName); 882 }else 883 getDomainConfig().removeConnectorConnectionPoolConfig(resName); 884 } 885 886 887 892 public void deleteConnectorResource(final String resName) { 893 ConnectorResourceConfig res = 894 getConnectorResourceConfigByName(resName); 895 if(isEightPlatform()){ 896 deleteResourceFromBackend_WorkaroundForPE( 897 NodeTypes.CONNECTOR_RESOURCE, resName); 898 }else{ 899 removeResourceRef(res, resName); 900 getDomainConfig().removeConnectorResourceConfig(resName); 901 } 902 } 903 904 905 910 public void deleteDestinationResource(final String resName) { 911 AdminObjectResourceConfig res = 912 getAdminObjectResourceConfigByName(resName); 913 if(isEightPlatform()){ 914 deleteResourceFromBackend_WorkaroundForPE( 915 NodeTypes.DESTINATION_RESOURCE, resName); 916 }else{ 917 removeResourceRef(res, resName); 918 getDomainConfig().removeAdminObjectResourceConfig(resName); 919 } 920 } 921 922 923 928 public void deleteJDBCResource(final String resName) { 929 JDBCResourceConfig res = getJDBCResourceConfigByName(resName); 930 if(isEightPlatform()){ 931 deleteResourceFromBackend_WorkaroundForPE( 932 NodeTypes.JDBC_RESOURCE, resName); 933 }else{ 934 removeResourceRef(res, resName); 935 getDomainConfig().removeJDBCResourceConfig(resName); 936 } 937 } 938 939 940 945 public void deleteJavaMailResource(final String resName) { 946 MailResourceConfig res = getMailResourceConfigByName(resName); 947 if(isEightPlatform()){ 948 deleteResourceFromBackend_WorkaroundForPE( 949 NodeTypes.MAIL_RESOURCE, resName); 950 }else{ 951 removeResourceRef(res, resName); 952 getDomainConfig().removeMailResourceConfig(resName); 953 } 954 } 955 956 957 962 public void deletePersistenceManagerResourceFactory(final String resName) { 963 PersistenceManagerFactoryResourceConfig res = 964 getPersistenceManagerResourceFactoryConfigByName(resName); 965 if(isEightPlatform()){ 966 deleteResourceFromBackend_WorkaroundForPE( 967 NodeTypes.PM_RESOURCE, resName); 968 }else{ 969 removeResourceRef(res, resName); 970 getDomainConfig().removePersistenceManagerFactoryResourceConfig(resName); 971 } 972 } 973 974 975 981 public void deleteDependentJDBCResources( 982 final String jdbcConnectionPoolName) { 983 String [] jdbcResourceNames = 984 getDependentJDBCResourceNames(jdbcConnectionPoolName); 985 for(int i = 0; i < jdbcResourceNames.length; i++) { 986 deleteJDBCResource(jdbcResourceNames[i]); 987 } 988 } 989 990 991 999 public String [] getDependentJDBCResourceNames( 1000 final String jdbcConnectionPoolName) { 1001 java.util.Map jdbcResMap = 1002 getDomainConfig().getJDBCResourceConfigMap(); 1003 java.util.Vector namesToReturn = new java.util.Vector (); 1004 if(jdbcConnectionPoolName != null) { 1005 for(Iterator itr = jdbcResMap.values().iterator(); itr.hasNext(); ) { 1006 JDBCResourceConfig config = (JDBCResourceConfig) itr.next(); 1007 if(jdbcConnectionPoolName.equals(config.getPoolName())) { 1008 namesToReturn.add(config.getName()); 1009 } 1010 } 1011 } 1012 final String [] names = new String [namesToReturn.size()]; 1013 return (String []) namesToReturn.toArray(names); 1014 } 1015 1016 1017 1022 private void deleteResourceFromBackend_WorkaroundForPE( 1023 final String nodeType, final String resName) { 1024 String domainName = BACKEND_COM_SUN_APPSERV_MBEAN_DOMAIN_NAME; 1025 String props = Util.makeProp("type", "resources"); 1026 String props2 = Util.makeProp("category", "config"); 1027 props = Util.concatenateProps(props, props2); 1028 String operationName = null; 1029 ObjectName resourcesMBeanObjName = 1030 Util.newObjectName(domainName, props); 1031 operationName = NodeTypes.getDeleteResourceMethodName(nodeType); 1032 if(operationName != null) { 1033 try { 1034 getMBeanServerConnection().invoke(resourcesMBeanObjName, 1035 operationName, new Object []{resName, DAS_SERVER_NAME}, 1036 new String []{"java.lang.String", "java.lang.String"} ); 1037 } catch(Exception e) { 1038 e.printStackTrace(); 1039 } 1040 } 1041 } 1042 1043 1044 1047 public String getName() { 1048 return ""; 1049 } 1050 1051 1057 public java.util.Map getLogProperties(String serverName) { 1058 LogServiceConfig logService = getReferencedConfig(serverName).getLogServiceConfig(); 1059 ModuleLogLevelsConfig moduleLevels = 1060 logService.getModuleLogLevelsConfig(); 1061 return getLogPropertiesFromBackend(moduleLevels, moduleLevels.getAllLevels()); 1062 } 1063 1064 1068 public Attribute setLogProperties(String serverName, String attributeName, Object value) { 1069 testIfServerInDebug(); 1070 LogServiceConfig logService = getReferencedConfig(serverName).getLogServiceConfig(); 1071 ModuleLogLevelsConfig moduleLevels = 1072 logService.getModuleLogLevelsConfig(); 1073 Attribute attr = ControllerUtil.setAttributeValue( 1074 moduleLevels, attributeName, value, getMBeanServerConnection()); 1075 return attr; 1076 } 1077 1078 1082 public void updateResourceExtraProperty(String resourceName, String resourceType, Object [] props, java.util.Map oldProps) { 1083 testIfServerInDebug(); 1084 if(resourceType.equals(NodeTypes.CONNECTION_POOL)){ 1085 JDBCConnectionPoolConfig cpConfig = getJDBCConnectionPoolConfigByName(resourceName); 1086 if(cpConfig != null){ 1087 removeResourceExtraProperty(cpConfig, oldProps); 1088 ControllerUtil.setPropertyValue(cpConfig, props); 1089 } 1090 }else if(resourceType.equals(NodeTypes.CONNECTOR_CONNECTION_POOL)){ 1091 ConnectorConnectionPoolConfig connConfig = getConnectorConnectionPoolConfigByName(resourceName); 1092 if(connConfig != null){ 1093 removeResourceExtraProperty(connConfig, oldProps); 1094 ControllerUtil.setPropertyValue(connConfig, props); 1095 } 1096 }else{ 1097 ResourceConfig res = getRelevantResourceConfig(resourceName, resourceType); 1098 if(res != null){ 1099 removeResourceExtraProperty(res, oldProps); 1100 ControllerUtil.setPropertyValue(res, props); 1101 } 1102 } 1103 } 1104 1105 1109 private ResourceConfig getRelevantResourceConfig(String resourceName, String resourceType) { 1110 ResourceConfig resConfig = null; 1111 if(resourceType.equals(NodeTypes.ADMIN_OBJECT_RESOURCE) || resourceType.equals(NodeTypes.DESTINATION_RESOURCE)){ 1112 resConfig = getAdminObjectResourceConfigByName(resourceName); 1113 }else if(resourceType.equals(NodeTypes.CONNECTION_FACTORY) || resourceType.equals(NodeTypes.CONNECTOR_RESOURCE)){ 1114 resConfig = getConnectorResourceConfigByName(resourceName); 1115 }else if(resourceType.equals(NodeTypes.JDBC_RESOURCE)){ 1116 resConfig = getJDBCResourceConfigByName(resourceName); 1117 }else if(resourceType.equals(NodeTypes.CUSTOM_RESOURCE)){ 1118 resConfig = getCustomResourceConfigByName(resourceName); 1119 }else if(resourceType.equals(NodeTypes.EXTERNAL_RESOURCE)){ 1120 resConfig = getJNDIResourceConfigByName(resourceName); 1121 }else if(resourceType.equals(NodeTypes.MAIL_RESOURCE)){ 1122 resConfig = getMailResourceConfigByName(resourceName); 1123 }else if(resourceType.equals(NodeTypes.PM_RESOURCE)){ 1124 resConfig = getPersistenceManagerResourceFactoryConfigByName(resourceName); 1125 } 1126 1127 return resConfig; 1128 } 1129 1130 1134 private static void removeResourceExtraProperty(ResourceConfig res, Map oldProps) { 1135 try{ 1136 Iterator it = oldProps.keySet().iterator(); 1137 while(it.hasNext()){ 1138 res.removeProperty(it.next().toString()); 1139 } 1140 }catch(Exception ex){ 1141 return; 1142 } 1146 } 1147 1148 1152 private static void removeResourceExtraProperty(JDBCConnectionPoolConfig res, Map oldProps) { 1153 try{ 1154 Iterator it = oldProps.keySet().iterator(); 1155 while(it.hasNext()){ 1156 res.removeProperty(it.next().toString()); 1157 } 1158 }catch(Exception ex){ 1159 return; 1160 } 1164 } 1165 1166 1170 private static void removeResourceExtraProperty(ConnectorConnectionPoolConfig res, Map oldProps) { 1171 try{ 1172 Iterator it = oldProps.keySet().iterator(); 1173 while(it.hasNext()){ 1174 res.removeProperty(it.next().toString()); 1175 } 1176 }catch(Exception ex){ 1177 } 1181 } 1182 1183 1188 public String getWebModuleName(String contextRoot){ 1189 J2EEServerMgmtController controller = getJ2EEServerMgmtController(); 1190 String modname = null; 1191 if(controller != null) 1192 modname = controller.getWebModuleName(contextRoot); 1193 1194 return modname; 1195 } 1196 1197 1202 public boolean isEightPlatform(){ 1203 boolean isPlatform = true; 1204 J2EEServerMgmtController controller = getJ2EEServerMgmtController(); 1205 String serverName = controller.getServerName(); 1206 if((serverName != null) && (serverName.indexOf("Enterprise Edition 8.") != -1)) isPlatform = false; 1208 return isPlatform; 1209 } 1210 1211 1216 public boolean isGlassfish(){ 1217 boolean isGlassfish = true; 1218 J2EEServerMgmtController controller = getJ2EEServerMgmtController(); 1219 String serverName = controller.getServerName(); 1220 if((serverName != null) && (serverName.indexOf("8.") != -1)) isGlassfish = false; 1222 return isGlassfish; 1223 } 1224} 1225 | Popular Tags |