1 23 24 29 30 31 package com.sun.enterprise.management.config; 32 33 import java.util.Map ; 34 import java.util.Set ; 35 import java.util.Properties ; 36 37 import javax.management.ObjectName ; 38 import javax.management.AttributeList ; 39 40 import com.sun.appserv.management.base.Util; 41 import com.sun.appserv.management.base.QueryMgr; 42 import com.sun.appserv.management.base.XTypes; 43 import com.sun.appserv.management.base.Container; 44 45 import com.sun.appserv.management.config.CustomMBeanConfig; 46 import com.sun.appserv.management.config.DeployedItemRefConfig; 47 import com.sun.appserv.management.config.RefConfig; 48 49 import com.sun.appserv.management.helper.RefHelper; 50 51 import com.sun.appserv.management.util.misc.ExceptionUtil; 52 import com.sun.appserv.management.util.jmx.JMXUtil; 53 import com.sun.appserv.management.util.misc.GSetUtil; 54 55 import com.sun.enterprise.management.support.oldconfig.OldApplicationsConfigMBean; 56 57 import com.sun.enterprise.admin.mbeans.custom.CustomMBeanConstants; 58 59 60 public final class CustomMBeanConfigFactory extends ConfigFactory 61 { 62 public 63 CustomMBeanConfigFactory( 64 final ConfigFactoryCallback callbacks ) 65 { 66 super( callbacks ); 67 } 68 69 72 protected ObjectName 73 createOldChildConfig( 74 final AttributeList translatedAttrs ) 75 { 76 final Map <String ,String > m = 77 JMXUtil.attributeListToStringMap( translatedAttrs ); 78 79 final String DOMAIN = null; final String name = getOld().createMBean( DOMAIN, m ); 81 82 final ObjectName objectName = getOld().getMbeanByName( name ); 83 84 debug( "created custom MBean with name: " + objectName ); 85 return( objectName ); 86 } 87 88 private OldApplicationsConfigMBean 89 getOld() 90 { 91 return getOldConfigProxies().getOldApplicationsConfigMBean(); 92 } 93 94 public ObjectName 95 create( 96 final String name, 97 final String implClassname, 98 final String objectName, 99 final boolean enabled, 100 final Map <String ,String > optional ) 101 { 102 final String [] requiredParams = new String [] 103 { 104 CustomMBeanConstants.NAME_KEY, name, 105 CustomMBeanConstants.IMPL_CLASS_NAME_KEY, implClassname, 106 CustomMBeanConstants.OBJECT_NAME_KEY, objectName, 107 CustomMBeanConstants.ENABLED_KEY, "" + enabled, 108 }; 109 final Map <String ,String > params = initParams( name, requiredParams, optional ); 110 111 final ObjectName amxName = createNamedChild( name, params ); 112 return amxName; 113 } 114 115 116 private final String 117 getRefContainerName( final String name ) 118 { 119 final QueryMgr queryMgr = getDomainRoot().getQueryMgr(); 120 121 final Set <DeployedItemRefConfig> refs = 123 RefHelper.findAllRefConfigsWithName( queryMgr, XTypes.DEPLOYED_ITEM_REF_CONFIG, name ); 124 125 final RefConfig ref = GSetUtil.getSingleton( refs ); 126 final Container refContainer = ref.getContainer(); 127 128 return refContainer.getName(); 129 } 130 131 132 final public void 133 removeByName( final String name ) 134 { 135 getOld().deleteMBean( getRefContainerName( name ), name ); 137 } 138 } 139 140 141 142 143 144 | Popular Tags |