1 23 package com.sun.enterprise.management.config; 24 25 import java.util.Set ; 26 import java.util.HashSet ; 27 import java.util.Map ; 28 29 import java.lang.reflect.Method ; 30 import java.lang.reflect.Constructor ; 31 import java.lang.reflect.InvocationTargetException ; 32 33 import javax.management.ObjectName ; 34 import javax.management.MBeanInfo ; 35 import javax.management.MBeanNotificationInfo ; 36 import javax.management.Attribute ; 37 import javax.management.AttributeList ; 38 import javax.management.AttributeNotFoundException ; 39 import javax.management.AttributeChangeNotification ; 40 import javax.management.MBeanException ; 41 import javax.management.ReflectionException ; 42 import javax.management.InstanceNotFoundException ; 43 44 import com.sun.appserv.management.util.misc.ClassUtil; 45 import com.sun.appserv.management.util.misc.CollectionUtil; 46 import com.sun.appserv.management.util.misc.GSetUtil; 47 import com.sun.appserv.management.util.misc.ThrowableMapper; 48 import com.sun.appserv.management.util.misc.StringUtil; 49 import com.sun.appserv.management.util.misc.ExceptionUtil; 50 import com.sun.appserv.management.util.jmx.JMXUtil; 51 52 import com.sun.appserv.management.config.PropertiesAccess; 53 import com.sun.appserv.management.config.AMXConfig; 54 import com.sun.appserv.management.config.RefConfig; 55 import com.sun.appserv.management.config.ResourceConfig; 56 import com.sun.appserv.management.config.ModuleConfig; 57 import com.sun.appserv.management.config.RefConfigReferent; 58 import com.sun.appserv.management.config.ResourceRefConfig; 59 import com.sun.appserv.management.config.ResourceRefConfigReferent; 60 import com.sun.appserv.management.config.DeployedItemRefConfigReferent; 61 import com.sun.appserv.management.config.ClusterRefConfigReferent; 62 import com.sun.appserv.management.config.ServerRefConfigReferent; 63 import com.sun.appserv.management.config.Description; 64 import com.sun.appserv.management.config.Enabled; 65 import com.sun.appserv.management.config.ObjectType; 66 67 import com.sun.appserv.management.config.DeployedItemRefConfigCR; 68 import com.sun.appserv.management.config.ServerRefConfigCR; 69 import com.sun.appserv.management.config.ClusterRefConfigCR; 70 import com.sun.appserv.management.config.ResourceRefConfigCR; 71 import com.sun.appserv.management.config.SystemPropertiesAccess; 72 73 import com.sun.appserv.management.base.XTypesMapper; 74 import com.sun.appserv.management.base.XTypes; 75 import com.sun.appserv.management.base.AMX; 76 import com.sun.appserv.management.base.AMXDebug; 77 import com.sun.appserv.management.base.Container; 78 import com.sun.appserv.management.base.Util; 79 80 import com.sun.appserv.management.helper.RefHelper; 81 82 import com.sun.enterprise.management.support.AMXImplBase; 83 import com.sun.enterprise.management.support.Delegate; 84 import com.sun.enterprise.management.support.DelegateBase; 85 import com.sun.enterprise.management.support.AMXAttributeNameMapper; 86 87 import com.sun.enterprise.management.config.ConfigFactory; 88 import com.sun.enterprise.management.support.oldconfig.OldProperties; 89 import com.sun.enterprise.management.support.oldconfig.OldSystemProperties; 90 91 95 public class AMXConfigImplBase extends AMXImplBase 96 implements AMXConfig 97 { 98 protected 99 AMXConfigImplBase( Delegate delegate ) 100 { 101 super( delegate ); 102 } 103 104 protected boolean 105 supportsProperties() 106 { 107 return PropertiesAccess.class.isAssignableFrom( getInterface() ); 108 } 109 110 protected boolean 111 supportsSystemProperties() 112 { 113 return SystemPropertiesAccess.class.isAssignableFrom( getInterface() ); 114 } 115 116 120 protected final void 121 checkPropertiesAccessSupport() 122 { 123 if ( getDelegate() != null) 124 { 125 final boolean delegateHasProperties = delegateSupportsProperties(); 126 127 if ( delegateHasProperties != supportsProperties() ) 128 { 129 final String msg = getJ2EEType() + ": " + 130 "delegateSupportsProperties=" + delegateHasProperties + 131 ", but supportsProperties=" + supportsProperties(); 132 logWarning( msg ); 134 throw new Error ( msg ); 135 } 136 } 137 else if ( supportsProperties() ) 138 { 139 final String msg = getJ2EEType() + ": " + 140 "AMX interface supports properties, but has no delegate"; 141 logSevere( msg ); 142 throw new Error ( msg ); 143 } 144 } 145 146 private boolean 147 delegateSupportsSystemProperties() 148 { 149 boolean supports = true; 150 final OldSystemProperties old = getOldSystemProperties(); 151 try 152 { 153 final AttributeList props = old.getSystemProperties(); 154 supports = true; 155 } 156 catch( Exception e ) 157 { 158 supports = false; 159 } 160 return supports; 161 } 162 163 private boolean 164 delegateSupportsProperties() 165 { 166 boolean supports = true; 167 final OldProperties old = getOldProperties(); 168 try 169 { 170 final AttributeList props = old.getProperties(); 171 supports = true; 172 } 173 catch( Exception e ) 174 { 175 supports = false; 176 } 177 return supports; 178 } 179 180 184 protected final void 185 checkSystemPropertiesAccessSupport() 186 { 187 if ( getDelegate() != null) 188 { 189 final boolean delegateSupports = delegateSupportsSystemProperties(); 190 191 if ( delegateSupports != supportsSystemProperties() ) 192 { 193 final String msg = getJ2EEType() + ": " + 194 "delegateSupportsSystemProperties=" + delegateSupports + 195 ", but supportsSystemProperties=" + supportsSystemProperties(); 196 logWarning( msg ); 198 throw new Error ( msg ); 199 } 200 } 201 else if ( supportsSystemProperties() ) 202 { 203 final String msg = getJ2EEType() + ": " + 204 "AMX interface supports system properties, but has no delegate"; 205 logSevere( msg ); 206 throw new Error ( msg ); 207 } 208 } 209 210 protected final void 211 checkInterfaceSupport( 212 final Class <?> theInterface, 213 final String attributeToCheck ) 214 { 215 if ( getDelegate() != null) 216 { 217 final boolean delegateSupports = 218 getDelegate().supportsAttribute( attributeToCheck ); 219 220 final boolean supported = theInterface.isAssignableFrom( getInterface() ); 221 222 if ( delegateSupports != supported ) 223 { 224 final String msg = "ERROR: " + getJ2EEType() + ": " + 225 "AMX interface does not match Delegate capabilities for " + 226 "interface " + theInterface.getName() + ", " + 227 "delegate support = " + delegateSupports + 228 ", AMX support = " + supported; 229 logSevere( msg ); 230 throw new Error ( msg ); 231 } 232 } 233 } 234 235 236 protected final Set <String > 237 getSuperfluousMethods() 238 { 239 final Set <String > items = super.getSuperfluousMethods(); 240 241 final Method [] methods = this.getClass().getMethods(); 242 for( final Method m : methods ) 243 { 244 final String name = m.getName(); 245 246 if ( isConfigFactoryGetter( name ) || 247 isRemoveConfig( name ) || 248 isCreateConfig( name ) ) 249 { 250 if ( m.getParameterTypes().length <= 1 ) 251 { 252 items.add( name ); 253 } 254 } 255 } 256 257 return items; 258 } 259 260 protected final void 261 implCheck() 262 { 263 super.implCheck(); 264 265 if ( ! com.sun.enterprise.management.support.BootUtil.getInstance().getOffline() ) 267 { 268 checkPropertiesAccessSupport(); 269 checkSystemPropertiesAccessSupport(); 270 } 271 272 checkInterfaceSupport( Description.class, "Description" ); 273 checkInterfaceSupport( ObjectType.class, "ObjectType" ); 274 checkInterfaceSupport( Enabled.class, "Enabled" ); 275 } 276 277 private static void 278 validatePropertyName( final String propertyName ) 279 { 280 if ( propertyName == null || 281 propertyName.length() == 0 ) 282 { 283 throw new IllegalArgumentException ( "Illegal property name: " + 284 StringUtil.quote( propertyName ) ); 285 } 286 } 287 288 protected OldSystemProperties 289 getOldSystemProperties() 290 { 291 if ( ! haveDelegate() ) 292 { 293 final String msg = "system properties not supported (no delegate) by " + 294 quote( getObjectName() ); 295 296 throw new IllegalArgumentException ( msg ); 297 } 298 299 return( new OldSystemPropertiesImpl( getDelegate() ) ); 300 } 301 302 public Map <String ,String > 303 getSystemProperties( ) 304 { 305 final AttributeList props = getOldSystemProperties().getSystemProperties(); 306 307 final Map <String ,String > result = JMXUtil.attributeListToStringMap( props ); 308 309 return result; 310 } 311 312 public String [] 313 getSystemPropertyNames( ) 314 { 315 final Set <String > names = getSystemProperties().keySet(); 316 317 return( GSetUtil.toStringArray( names ) ); 318 } 319 320 public String 321 getSystemPropertyValue( String propertyName ) 322 { 323 return( getOldSystemProperties().getSystemPropertyValue( propertyName ) ); 324 } 325 326 public final void 327 setSystemPropertyValue( 328 final String propertyName, 329 final String propertyValue ) 330 { 331 validatePropertyName( propertyName ); 332 333 if ( propertyValue == null ) 334 { 335 throw new IllegalArgumentException ( "" + null ); 336 } 337 338 final Attribute attr = new Attribute ( propertyName, propertyValue ); 339 340 getOldSystemProperties().setSystemProperty( attr ); 341 } 342 343 public final boolean 344 existsSystemProperty( String propertyName ) 345 { 346 validatePropertyName( propertyName ); 347 348 return( GSetUtil.newSet( getSystemPropertyNames() ).contains( propertyName ) ); 349 } 350 351 public final void 352 removeSystemProperty( String propertyName ) 353 { 354 validatePropertyName( propertyName ); 355 356 getOldSystemProperties().setSystemProperty( new Attribute ( propertyName, null ) ); 357 } 358 359 public final void 360 createSystemProperty( String propertyName, String propertyValue ) 361 { 362 setSystemPropertyValue( propertyName, propertyValue ); 363 } 364 365 366 367 368 371 protected OldProperties 372 getOldProperties() 373 { 374 if ( ! haveDelegate() ) 375 { 376 final String msg = "properties not supported (no delegate) by " + 377 quote( getObjectName() ); 378 379 throw new IllegalArgumentException ( msg ); 380 } 381 382 return( new OldPropertiesImpl( getDelegate() ) ); 383 } 384 385 public Map <String ,String > 386 getProperties( ) 387 { 388 final AttributeList props = getOldProperties().getProperties(); 389 390 return JMXUtil.attributeListToStringMap( props ); 391 } 392 393 394 public String [] 395 getPropertyNames( ) 396 { 397 final Set <String > names = getProperties().keySet(); 398 399 return( GSetUtil.toStringArray( names ) ); 400 } 401 402 public String 403 getPropertyValue( String propertyName ) 404 { 405 return( getOldProperties().getPropertyValue( propertyName ) ); 406 } 407 408 public final void 409 setPropertyValue( 410 final String propertyName, 411 final String propertyValue ) 412 { 413 validatePropertyName( propertyName ); 414 415 if ( propertyValue == null ) 416 { 417 throw new IllegalArgumentException ( "null" ); 418 } 419 420 final Attribute attr = new Attribute ( propertyName, propertyValue ); 421 422 getOldProperties().setProperty( attr ); 423 } 424 425 public final boolean 426 existsProperty( String propertyName ) 427 { 428 validatePropertyName( propertyName ); 429 430 return( GSetUtil.newSet( getPropertyNames() ).contains( propertyName ) ); 431 } 432 433 public final void 434 removeProperty( String propertyName ) 435 { 436 validatePropertyName( propertyName ); 437 438 getOldProperties().setProperty( new Attribute ( propertyName, null ) ); 439 } 440 441 public final void 442 createProperty( String propertyName, String propertyValue ) 443 { 444 validatePropertyName( propertyName ); 445 446 setPropertyValue( propertyName, propertyValue ); 447 } 448 449 public final String 450 getGroup() 451 { 452 return( AMX.GROUP_CONFIGURATION ); 453 } 454 455 456 public MBeanNotificationInfo [] 457 getNotificationInfo() 458 { 459 final MBeanNotificationInfo [] superInfos = super.getNotificationInfo(); 460 461 final String description = ""; 463 final String [] notifTypes = new String [] { AttributeChangeNotification.ATTRIBUTE_CHANGE }; 464 final MBeanNotificationInfo attributeChange = new MBeanNotificationInfo ( 465 notifTypes, 466 AttributeChangeNotification .class.getName(), 467 description ); 468 469 final MBeanNotificationInfo [] selfInfos = 470 new MBeanNotificationInfo [] { attributeChange }; 471 472 final MBeanNotificationInfo [] allInfos = 473 JMXUtil.mergeMBeanNotificationInfos( superInfos, selfInfos ); 474 475 return allInfos; 476 } 477 478 private String 479 getSimpleInterfaceName( final AMX amx ) 480 { 481 final String fullInterfaceName = Util.getExtra( amx ).getInterfaceName(); 482 final String interfaceName = ClassUtil.stripPackageName( fullInterfaceName ); 483 484 return interfaceName; 485 } 486 487 488 500 protected void 501 preRemove( final ObjectName objectName ) 502 { 503 final AMXConfig amxConfig = getProxy( objectName, AMXConfig.class ); 504 505 if ( amxConfig instanceof RefConfigReferent ) 506 { 507 debug( "*** Removing all references to ", objectName ); 508 509 final Set <RefConfig> failures = 510 RefHelper.removeAllRefsTo( (RefConfigReferent)amxConfig, true ); 511 if( failures.size() != 0 ) 512 { 513 debug( "FAILURE removing references to " + objectName + ": " + 514 CollectionUtil.toString( Util.toObjectNames( failures ) ) ); 515 } 516 } 517 else 518 { 519 debug( "*** not a RefConfigReferent: ", objectName ); 520 } 521 } 522 523 526 protected ObjectName 527 preRemove( 528 final Map <String ,ObjectName > items, 529 final String name ) 530 { 531 if ( name == null ) 532 { 533 throw new IllegalArgumentException ( "null name" ); 534 } 535 536 final ObjectName objectName = items.get( name ); 537 if ( objectName == null ) 538 { 539 throw new IllegalArgumentException ( "Item not found: " + name ); 540 } 541 542 preRemove( objectName ); 543 544 return objectName; 545 } 546 547 548 553 protected final boolean 554 removeConfigWithFactory( final ObjectName objectName ) 555 { 556 ConfigFactory factory = null; 557 558 boolean attempted = false; 559 try 560 { 561 final AMXConfig amxConfig = getProxy( objectName, AMXConfig.class ); 562 final String interfaceName = getSimpleInterfaceName( amxConfig ); 563 debug( "removeConfigWithFactory: " + objectName ); 564 565 factory = createConfigFactory( interfaceName ); 566 } 567 catch( Exception e ) 568 { 569 debug( ExceptionUtil.toString( e ) ); 570 } 571 572 if ( factory != null ) 573 { 574 attempted = true; 575 576 try 579 { 580 final Method m = factory.getClass().getMethod( "remove", (Class [])null ); 581 if ( m != null ) 582 { 583 m.invoke( factory, (Object [])null ); 584 } 585 } 586 catch( NoSuchMethodException e ) 587 { 588 factory.remove( objectName ); 589 } 590 catch( Exception e ) 591 { 592 throw new RuntimeException ( e ); 593 } 594 } 595 596 return attempted; 597 } 598 599 600 static private final String CREATE = "create"; 601 static private final String CREATE_PREFIX = CREATE; 602 static private final String REMOVE_PREFIX = "remove"; 603 static private final String CONFIG_SUFFIX = "Config"; 604 static private final String FACTORY_SUFFIX = "Factory"; 605 606 static private final Class [] STRING_SIG = new Class [] { String .class }; 607 608 618 protected final void 619 removeConfigWithMethod( final ObjectName objectName ) 620 { 621 final AMXConfig amxConfig = getProxy( objectName, AMXConfig.class ); 622 final String interfaceName = getSimpleInterfaceName( amxConfig ); 623 if ( ! interfaceName.endsWith( CONFIG_SUFFIX ) ) 624 { 625 throw new IllegalArgumentException ( 626 "Interface doesn't end in " + CONFIG_SUFFIX + ": " + interfaceName ); 627 } 628 629 final String operationName = REMOVE_PREFIX + interfaceName; 632 debug( "removing config generically by calling ", operationName, "()" ); 633 try 634 { 635 final Method m = 636 this.getClass().getDeclaredMethod( operationName, STRING_SIG); 637 638 m.invoke( this, amxConfig.getName() ); 639 } 640 catch( Exception e ) 641 { 642 throw new RuntimeException ( e ); 643 } 644 } 645 646 647 650 public final void 651 removeConfig( final String j2eeType, final String name ) 652 { 653 if ( name == null ) 654 { 655 throw new IllegalArgumentException (); 656 } 657 658 final Map <String ,ObjectName > items = getContaineeObjectNameMap( j2eeType ); 659 final ObjectName objectName = preRemove( items, name ); 660 661 if ( ! removeConfigWithFactory( objectName ) ) 662 { 663 debug( "removeConfigWithFactory failed, using removeConfigWithMethod" ); 664 removeConfigWithMethod( objectName ); 665 } 666 } 667 668 671 protected void 672 removeRefConfig( final String j2eeType, final String name ) 673 { 674 removeConfig( j2eeType, name ); 675 } 676 677 678 private boolean 679 isRemoveConfig( final String operationName) 680 { 681 return operationName.startsWith( REMOVE_PREFIX ) && 682 operationName.endsWith( CONFIG_SUFFIX ); 683 } 684 685 private boolean 686 isRemoveConfig( 687 String operationName, 688 Object [] args, 689 String [] types ) 690 { 691 final int numArgs = args == null ? 0 : args.length; 692 693 boolean isRemove = numArgs <= 1 && isRemoveConfig( operationName ); 694 if ( isRemove && numArgs == 1 ) 695 { 696 isRemove = types[0].equals( String .class.getName() ); 697 } 698 return isRemove; 699 } 700 701 private boolean 702 isCreateConfig( final String operationName) 703 { 704 return operationName.startsWith( CREATE_PREFIX ) && 705 operationName.endsWith( CONFIG_SUFFIX ); 706 } 707 708 private boolean 709 isConfigFactoryGetter( 710 String operationName, 711 Object [] args, 712 String [] types ) 713 { 714 final int numArgs = args == null ? 0 : args.length; 715 716 return numArgs == 0 && isConfigFactoryGetter( operationName ); 717 } 718 719 private boolean 720 isConfigFactoryGetter( final String operationName ) 721 { 722 return operationName.startsWith( GET_PREFIX ) && 723 operationName.endsWith( FACTORY_SUFFIX ) && 724 (! operationName.equals( "getProxyFactory" ) ); 725 } 726 727 protected ObjectName 728 createConfig( 729 final String simpleInterfaceName, 730 final Object [] args, 731 String [] types) 732 throws NoSuchMethodException , IllegalAccessException , 733 InvocationTargetException , ClassNotFoundException , InstantiationException 734 { 735 ObjectName result = null; 736 737 final Class [] sig = ClassUtil.signatureFromClassnames( types ); 738 739 final ConfigFactory factory = createConfigFactory( simpleInterfaceName ); 740 if ( factory == null ) 741 { 742 final String createMethodName = CREATE + simpleInterfaceName; 744 final Method m = this.getClass().getMethod( createMethodName, sig); 745 if ( m == null ) 746 { 747 throw new RuntimeException ( "Can't find ConfigFactory for " + simpleInterfaceName ); 748 } 749 } 750 else 751 { 752 final Method createMethod = 753 factory.getClass().getDeclaredMethod( CREATE, sig); 754 if ( createMethod != null ) 755 { 756 result = (ObjectName )createMethod.invoke( factory, args ); 757 } 758 else 759 { 760 final String msg = "Can't find method " + CREATE + 761 " in factory " + factory.getClass().getName(); 762 763 throw new NoSuchMethodException ( msg ); 764 } 765 } 766 767 return result; 768 } 769 770 771 private static final Set <String > CR_PREFIXES = 772 GSetUtil.newUnmodifiableStringSet( 773 "create", "remove" 774 ); 775 776 777 786 protected String 787 operationNameToSimpleClassname( final String operationName ) 788 { 789 return StringUtil.findAndStripPrefix( CR_PREFIXES, operationName ); 790 } 791 792 protected String 793 operationNameToJ2EEType( final String operationName ) 794 { 795 String j2eeType = null; 796 797 if ( isRemoveConfig( operationName ) || 798 isCreateConfig( operationName ) ) 799 { 800 j2eeType = XTypes.PREFIX + operationNameToSimpleClassname( operationName ); 801 } 802 else 803 { 804 j2eeType = super.operationNameToJ2EEType( operationName ); 805 } 806 return j2eeType; 807 } 808 809 810 813 protected void 814 removeConfig( final String operationName) 815 { 816 final String j2eeType = operationNameToJ2EEType( operationName ); 817 final ObjectName objectName = getContaineeObjectName( j2eeType ); 818 if ( objectName == null ) 819 { 820 throw new RuntimeException ( new InstanceNotFoundException ( j2eeType ) ); 821 } 822 preRemove( objectName ); 823 824 final String simpleInterfaceName = 825 operationName.substring( REMOVE_PREFIX.length(), operationName.length()); 826 827 createConfigFactory( simpleInterfaceName ).remove( objectName ); 828 } 829 830 833 protected void 834 removeConfig( 835 final String operationName, 836 final Object [] args, 837 String [] types) 838 throws InvocationTargetException 839 { 840 final String name = (String )args[ 0 ]; 841 final String simpleInterfaceName = 842 operationName.substring( REMOVE_PREFIX.length(), operationName.length()); 843 844 final Set <? extends AMX> containees = getFactoryContainer().getContaineeSet(); 845 ObjectName objectName = null; 846 for( final AMX containee : containees ) 847 { 848 if ( containee.getName().equals( name ) ) 849 { 850 debug( "removeConfig: found name match: " + Util.getObjectName( containee ) ); 851 if ( getSimpleInterfaceName( containee ).equals( simpleInterfaceName ) ) 852 { 853 objectName = Util.getObjectName( containee ); 854 break; 855 } 856 debug( getSimpleInterfaceName( containee ), " != ", simpleInterfaceName ); 857 } 858 } 859 860 if ( objectName != null ) 861 { 862 final AMX amx = getProxy( objectName, AMX.class); 863 864 removeConfig( amx.getJ2EEType(), amx.getName() ); 865 } 866 else 867 { 868 throw new IllegalArgumentException ( "Not found: " + name ); 869 } 870 } 871 872 protected String 873 getFactoryPackage() 874 { 875 return this.getClass().getPackage().getName(); 877 } 878 879 882 protected ConfigFactory 883 createConfigFactory( final String simpleClassname ) 884 { 885 ConfigFactory factory = null; 886 887 try 888 { 889 final String classname = getFactoryPackage() + "." + 890 simpleClassname + FACTORY_SUFFIX; 891 892 final Class factoryClass = ClassUtil.getClassFromName( classname ); 893 final Constructor constructor = factoryClass.getConstructor( FACTORY_CONSTRUCTOR_SIG ); 894 895 if ( constructor != null ) 896 { 897 factory = (ConfigFactory)constructor.newInstance( new Object [] { this } ); 898 } 899 else 900 { 901 throw new RuntimeException ( "No ConfigFactory found for " + classname ); 902 } 903 } 904 catch( Exception e ) 905 { 906 debug( ExceptionUtil.toString( e ) ); 907 throw new RuntimeException ( e ); 908 } 909 return factory; 910 } 911 912 913 private static final Class [] FACTORY_CONSTRUCTOR_SIG = new Class [] 914 { 915 ConfigFactoryCallback.class, 916 }; 917 918 923 protected Object 924 invokeManually( 925 String operationName, 926 Object [] args, 927 String [] types ) 928 throws MBeanException , ReflectionException , NoSuchMethodException , AttributeNotFoundException 929 { 930 final int numArgs = args == null ? 0 : args.length; 931 932 Object result = null; 933 934 debugMethod( operationName, args ); 935 936 if ( isConfigFactoryGetter( operationName, args, types ) && 937 ConfigFactoryCallback.class.isAssignableFrom( this.getClass() ) ) 938 { 939 debug( "looking for factory denoted by " + operationName ); 940 result = createConfigFactory( operationName ); 941 if ( result == null ) 942 { 943 debug( "FAILED TO FIND factory denoted by " + operationName ); 944 result = super.invokeManually( operationName, args, types ); 945 } 946 } 947 else if ( isRemoveConfig( operationName, args, types ) ) 948 { 949 try 950 { 951 if ( numArgs == 0 ) 952 { 953 removeConfig( operationName ); 955 } 956 else 957 { 958 removeConfig( operationName, args, types ); 959 } 960 } 961 catch( InvocationTargetException e ) 962 { 963 throw new MBeanException ( e ); 964 } 965 } 966 else if ( isCreateConfig( operationName ) ) 967 { 968 final String simpleInterfaceName = 970 operationName.substring( CREATE_PREFIX.length(), operationName.length() ); 971 972 try 973 { 974 result = createConfig( simpleInterfaceName, args, types); 975 } 976 catch( Exception e ) 977 { 978 throw new MBeanException ( e ); 979 } 980 } 981 else 982 { 983 result = super.invokeManually( operationName, args, types ); 984 } 985 return result; 986 } 987 988 989 994 public String 995 getConfigName() 996 { 997 return( (String )getKeyProperty( XTypes.CONFIG_CONFIG ) ); 998 } 999 1000 public void 1001 sendConfigCreatedNotification( final ObjectName configObjectName ) 1002 { 1003 sendNotification( AMXConfig.CONFIG_CREATED_NOTIFICATION_TYPE, 1004 AMXConfig.CONFIG_REMOVED_NOTIFICATION_TYPE, 1005 AMXConfig.CONFIG_OBJECT_NAME_KEY, configObjectName ); 1006 } 1007 1008 public void 1009 sendConfigRemovedNotification( final ObjectName configObjectName ) 1010 { 1011 sendNotification( AMXConfig.CONFIG_REMOVED_NOTIFICATION_TYPE, 1012 AMXConfig.CONFIG_REMOVED_NOTIFICATION_TYPE, 1013 AMXConfig.CONFIG_OBJECT_NAME_KEY, configObjectName ); 1014 } 1015} 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | Popular Tags |