@@ -418,6 +418,9 @@ def __get_attributes_offline_only(self, mbean_instance):
418418 return generator_utils .sort_dict (attribute_map )
419419
420420 def create_security_type (self , mbean_type ):
421+ _method_name = 'create_security_type'
422+ self .__logger .entering (mbean_type , class_name = self .__class_name , method_name = _method_name )
423+
421424 folder_dict = PyOrderedDict ()
422425 folder_dict [TYPE ] = 'Provider'
423426 provider_sub_types = self ._sc_providers [mbean_type ]
@@ -426,86 +429,37 @@ def create_security_type(self, mbean_type):
426429 if singular_mbean_type .endswith ('s' ):
427430 lenm = len (mbean_type )- 1
428431 singular_mbean_type = mbean_type [0 :lenm ]
432+
433+ curr_path = generator_wlst .current_path ()
434+ existing_provider_types = generator_wlst .lsc ()
435+ existing_providers = []
436+ if mbean_type in existing_provider_types :
437+ generator_wlst .cd_mbean (curr_path + '/' + mbean_type )
438+ existing_providers = generator_wlst .lsc ()
439+ self .__logger .fine ('existing providers for mbean_type {0}: {1}' , mbean_type , existing_providers ,
440+ class_name = self .__class_name , method_name = _method_name )
441+ generator_wlst .cd_mbean (curr_path )
442+
429443 for provider_sub_type in provider_sub_types :
430444 # Remove the package name from the subclass.
431445 idx = provider_sub_type .rfind ('.' )
432- shortened_provider_sub_type = provider_sub_type [idx + 1 :]
446+ mbean_name = provider_sub_type [idx + 1 :]
447+ shortened_provider_sub_type = mbean_name
448+
449+ mbean_path = '%s/%s/%s' % (curr_path , mbean_type , mbean_name )
450+ if mbean_name not in existing_providers :
451+ mbean_instance = generator_wlst .create_security_provider (mbean_name , provider_sub_type ,
452+ singular_mbean_type )
453+ else :
454+ mbean_instance = generator_wlst .get_mbean_proxy (mbean_path )
433455
434- mbean_name = shortened_provider_sub_type
435- mbean_instance = \
436- generator_wlst .create_security_provider (mbean_name , shortened_provider_sub_type , singular_mbean_type )
437- orig = generator_wlst .current_path ()
456+ generator_wlst .cd_mbean (mbean_path )
438457 folder_dict [shortened_provider_sub_type ] = PyOrderedDict ()
439458 folder_dict [shortened_provider_sub_type ][ATTRIBUTES ] = self .__get_attributes (mbean_instance )
440- generator_wlst .cd_mbean (orig )
441- return True , singular_mbean_type , folder_dict
442-
443- # FIXME - This is dead code
444- def _slim_maps_for_report (self , mbean_proxy , mbean_type , lsa_map , methods_map , mbean_info_map ):
445- # Unlike the slim_maps method, this report discards additional information to determine how
446- # different is the usable information in LSA, versus cmo.getClass().getMethods versus
447- # MBeanInfo PropertyDescriptor.
448- _lsa_remove_read_only (lsa_map )
449- _methods_remove_read_only (methods_map )
450- _mbean_info_remove_read_only (mbean_info_map )
451- print ('After removing read only ' )
452- print (' lsa_map size ' , len (lsa_map ), ' methods_map size ' , len (methods_map ),
453- ' mbean_info_size ' , len (mbean_info_map ))
454-
455- _remove_invalid_getters_methods (mbean_proxy , mbean_type , methods_map )
456- _remove_invalid_getters_mbean_info (mbean_proxy , mbean_type , mbean_info_map )
457- print ('After removing invalid getters from methods and mbean_info ' )
458- print (' lsa_map size ' , len (lsa_map ), ' methods_map size ' , len (methods_map ),
459- ' mbean_info_size ' , len (mbean_info_map ))
460-
461- self ._remove_should_ignores (lsa_map )
462- self ._remove_should_ignores (methods_map )
463- self ._remove_should_ignores (mbean_info_map )
464- print ('After removing alias ignores ' )
465- print (' lsa_map size ' , len (lsa_map ), ' methods_map size ' , len (methods_map ),
466- ' mbean_info_size ' , len (mbean_info_map ))
467-
468- self ._remove_subfolders (methods_map , mbean_info_map )
469- print ('After removing subfolders from methods and mbean_info ' )
470- print (' lsa_map size ' , len (lsa_map ), ' methods_map size ' , len (methods_map ),
471- ' mbean_info_size ' , len (mbean_info_map ))
472-
473- # FIXME - This is dead code
474- def _report_differences (self , mbean_proxy , mbean_type , lsa_map , methods_map , mbean_info_map ):
475- print ('*************************************************************' )
476- print ('Reporting on MBean ' , str (mbean_proxy ))
477- self ._slim_maps_for_report (mbean_proxy , mbean_type , lsa_map , methods_map , mbean_info_map )
478- print ('' )
479- lsa_keys = lsa_map .keys ()
480- lsa_keys .sort ()
481- methods_keys = methods_map .keys ()
482- methods_keys .sort ()
483- mbean_info_keys = mbean_info_map .keys ()
484- mbean_info_keys .sort ()
485- _report_lsa_not_in (lsa_keys , methods_keys , mbean_info_keys )
486-
487- _report_attribute_not_in (methods_keys , 'Method attribute ' , lsa_keys , mbean_info_keys , 'MBeanInfo ' )
488- _report_attribute_not_in (mbean_info_keys , 'MBeanInfo attribute ' , lsa_keys , methods_keys , 'Method ' )
489- print ('*************************************************************' )
490- print ('' )
491-
492- def __valid_child_folder (self , mbean_helper ):
493- _method_name = '__valid_child_folder'
494-
495- mbean_type = mbean_helper .get_name ()
496- valid = True
497- if mbean_helper .is_reference ():
498- self .__logger .finest ('Ignore MBean {0} which is a reference to an MBean at location {1}' ,
499- mbean_type , generator_wlst .current_path (),
500- class_name = self .__class_name , method_name = _method_name )
501- valid = False
502- elif self ._should_ignore (mbean_helper ):
503- self .__logger .finest ('MBean {0} found in ignore list at location {1}' ,
504- mbean_type , generator_wlst .current_path (),
505- class_name = self .__class_name , method_name = _method_name )
506- valid = False
459+ generator_wlst .cd_mbean (curr_path )
507460
508- return valid
461+ self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = singular_mbean_type )
462+ return True , singular_mbean_type , folder_dict
509463
510464 def __cd_to_mbean_name (self , mbean_type ):
511465 _method_name = '__cd_to_mbean_name'
@@ -571,29 +525,6 @@ def __find_attribute_name(self, lsa_name, mbean_map):
571525 self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = result )
572526 return found , result
573527
574- def __get_name_from_map_using_lower_case (self , attribute , mbean_map ):
575- _method_name = '__get_name_from_map_using_lower_case'
576- self .__logger .entering (attribute , class_name = self .__class_name , method_name = _method_name )
577-
578- lower_case_attribute = attribute .lower ()
579-
580- name = None
581- try :
582- found_list = [key for key in mbean_map if key .lower () == lower_case_attribute ]
583- if len (found_list ) > 0 :
584- name = found_list [0 ]
585- else :
586- self .__logger .finest ('lower case attribute {0} not found in map {1}' ,
587- lower_case_attribute , [key .lower () for key in mbean_map ],
588- class_name = self .__class_name , method_name = _method_name )
589- except (ValueError , KeyError ), e :
590- self .__logger .fine ('Attribute name {0} had error in mbean map : {1}' , attribute , str (e ),
591- class_name = self .__class_name , method_name = _method_name )
592- pass
593-
594- self .__logger .exiting (class_name = self .__class_name , method_name = _method_name , result = name )
595- return name
596-
597528 def __get_mbean_name_list (self , mbean_type , try_special = False ):
598529 _method_name = '__get_mbean_name_list'
599530 self .__logger .entering (mbean_type , class_name = self .__class_name , method_name = _method_name )
@@ -606,7 +537,7 @@ def __get_mbean_name_list(self, mbean_type, try_special=False):
606537 return mbean_type , mbean_name_list
607538
608539 def __check_how_implemented (self , mbean_proxy , search_mbean ):
609- _method_name = '_check_how_implemented '
540+ _method_name = '__check_how_implemented '
610541 self .__logger .entering (search_mbean , class_name = self .__class_name , method_name = _method_name )
611542
612543 get_method = False
@@ -762,152 +693,6 @@ def __fix_case(self, mbean_type):
762693 return return_converted , converted
763694
764695
765- def _remove_invalid_getters (mbean_instance , mbean_type , methods_map , mbean_info_map ):
766- for name , method_list in methods_map .iteritems ():
767- getter = method_list [0 ].getName ()
768- if not generator_utils .is_valid_getter (mbean_instance , mbean_type , getter , name ):
769- del methods_map [name ]
770- if name in mbean_info_map :
771- del mbean_info_map [name ]
772-
773-
774- def _remove_invalid_getters_mbean_info (mbean_proxy , mbean_type , mbean_info_map ):
775- remove_list = list ()
776- for name , descriptor in mbean_info_map .iteritems ():
777- if not generator_utils .is_valid_getter (mbean_proxy , mbean_type , descriptor .getReadMethod ().getName (), name ):
778- remove_list .append (name )
779-
780- for name in remove_list :
781- mbean_info_map .pop (name )
782-
783-
784- def _remove_invalid_getters_methods (mbean_proxy , mbean_type , method_map ):
785- remove_list = list ()
786- for name , method_list in method_map .iteritems ():
787- if not generator_utils .is_valid_getter (mbean_proxy , mbean_type , method_list [0 ].getName (), name ):
788- remove_list .append (name )
789-
790- for name in remove_list :
791- method_map .pop (name )
792-
793-
794- def _report_lsa_not_in (lsa_keys , methods_keys , mbean_info_keys ):
795- for lsa_name in lsa_keys :
796- if not _find_lsa_in_other_map (lsa_name , methods_keys ):
797- print (' LSA attribute ' , lsa_name , ' not in Methods map ' )
798- if not _find_lsa_in_other_map (lsa_name , mbean_info_keys ):
799- print (' LSA attribute ' , lsa_name , ' not in MBeanInfo map ' )
800-
801-
802- def _report_attribute_not_in (this_map_keys , this_map_type , lsa_map_keys , other_map_keys , other_map_type ):
803- for attribute in this_map_keys :
804- not_in_lsa = False
805- not_in_other = False
806- if not _find_attribute_in_lsa_map (attribute , lsa_map_keys ):
807- print (' ' , this_map_type , ' ' , attribute , ' not in LSA map' )
808- not_in_lsa = True
809- if not _find_lsa_in_other_map (attribute , other_map_keys ):
810- append = ''
811- if not not_in_lsa :
812- append = ' BUT is in LSA map'
813- print (' ' , this_map_type , ' ' , attribute , ' ** not in ' , other_map_type , append , ' **' )
814- not_in_other = True
815- if not_in_lsa and not_in_other :
816- print (' Attribute ' , attribute , '** not in LSA and not in ' , other_map_type , ' **' )
817-
818-
819- def _find_lsa_in_other_map (lsa_name , bean_map_keys ):
820- if lsa_name not in bean_map_keys and not _is_found_with_lower_case (lsa_name , bean_map_keys ):
821- if not lsa_name .endswith ('y' ) or \
822- not _is_found_with_lower_case (lsa_name [:len (lsa_name ) - 1 ] + 'ies' , bean_map_keys ):
823- if not _is_found_with_lower_case (lsa_name + 'es' , bean_map_keys ):
824- if not _is_found_with_lower_case (lsa_name + 's' , bean_map_keys ):
825- return False
826- return True
827-
828-
829- def _find_attribute_in_lsa_map (attribute_name , lsa_map_keys ):
830- if attribute_name not in lsa_map_keys and not _is_found_with_lower_case (attribute_name , lsa_map_keys ):
831- if not attribute_name .endswith ('ies' ) or \
832- not _is_found_with_lower_case (attribute_name [:len (attribute_name ) - 3 ] + 'y' , lsa_map_keys ):
833- if not attribute_name .endswith ('es' ) or \
834- not _is_found_with_lower_case (attribute_name [:len (attribute_name ) - 2 ], lsa_map_keys ):
835- if not attribute_name .endswith ('s' ) or \
836- not _is_found_with_lower_case (attribute_name [:len (attribute_name ) - 1 ],
837- lsa_map_keys ):
838- return False
839- return True
840-
841-
842- def _is_found_with_lower_case (attribute , mbean_list ):
843- found = False
844- try :
845- found = len ([key for key in mbean_list if key .lower () == attribute .lower ()]) > 0
846- except (ValueError , KeyError ):
847- pass
848-
849- return found
850-
851-
852- def _lsa_remove_read_only (lsa_map ):
853- remove_list = list ()
854- attributes_str = generator_wlst .lsa_string ()
855- for attribute_str in attributes_str .split ('\n ' ):
856- if attribute_str :
857- read_type = attribute_str [0 :4 ].strip ()
858- attr = attribute_str [7 :attribute_str .find (' ' , 7 )+ 1 ].strip ()
859- if read_type == '-r--' and attr in lsa_map :
860- remove_list .append (attr )
861-
862- for attr in remove_list :
863- lsa_map .pop (attr )
864-
865-
866- def _mbean_info_remove_read_only (mbean_info_map ):
867- remove_list = list ()
868- for attribute_name , descriptor in mbean_info_map .iteritems ():
869- if descriptor .getWriteMethod () is None :
870- remove_list .append (attribute_name )
871-
872- for attribute_name in remove_list :
873- mbean_info_map .pop (attribute_name )
874-
875-
876- def _methods_remove_read_only (methods_map ):
877- remove_list = list ()
878- for attribute_name , method_list in methods_map .iteritems ():
879- if len (method_list ) != 2 :
880- remove_list .append (attribute_name )
881-
882- for attribute_name in remove_list :
883- methods_map .pop (attribute_name )
884-
885-
886- def _remove_method_subfolders (mbean_proxy , methods_map ):
887- # already removed read_only
888- methods_list = [method .getName () for method in mbean_proxy .getClass ().getMethods ()
889- if method .getName ().startswith ('create' ) or method .getName ().startswith ('add' )]
890- remove_list = list ()
891- for attribute in methods_map :
892- if 'create' + attribute in methods_list or 'add' + attribute in methods_list :
893- remove_list .append (attribute )
894-
895- for attribute in remove_list :
896- methods_map .pop (attribute )
897-
898-
899- def _remove_mbean_info_subfolders (mbean_info ):
900- remove_list = list ()
901-
902- for attribute , descriptor in mbean_info .iteritems ():
903- relationship = descriptor .getValue ('relationship' )
904- if relationship == 'containment' or (relationship == 'reference' and descriptor .getWriteMethod () is None ):
905- remove_list .append (attribute )
906-
907- for attribute in remove_list :
908- mbean_info .pop (attribute )
909-
910-
911696def _add_restart_value (attribute_map ):
912697 attribute_map [RESTART ] = RESTART_NO_CHECK
913698
@@ -934,7 +719,3 @@ def _fix_plural_with_s(mbean_type):
934719 if mbean_type .endswith ('s' ):
935720 return True , mbean_type [:len (mbean_type )- 1 ]
936721 return False , mbean_type
937-
938-
939- def _not_at_top ():
940- return generator_wlst .current_path ().find ('/' , 1 ) > 0
0 commit comments