1 23 24 26 27 package com.sun.enterprise.management.config; 28 29 import java.util.Set ; 30 import java.util.Map ; 31 import java.util.HashMap ; 32 33 import javax.management.ObjectName ; 34 import javax.management.AttributeList ; 35 36 import com.sun.appserv.management.config.AMXConfig; 37 38 import com.sun.appserv.management.base.Util; 39 import com.sun.appserv.management.base.XTypes; 40 41 import com.sun.appserv.management.config.ResourceRefConfig; 42 import com.sun.appserv.management.config.ResourceConfigKeys; 43 import com.sun.appserv.management.util.misc.MapUtil; 44 import com.sun.appserv.management.util.misc.GSetUtil; 45 import com.sun.appserv.management.util.jmx.JMXUtil; 46 47 import com.sun.enterprise.management.support.oldconfig.OldServerMBean; 48 49 50 public class ResourceRefConfigFactory extends ConfigFactory 51 { 52 public 53 ResourceRefConfigFactory( final ConfigFactoryCallback callbacks ) 54 { 55 super( callbacks ); 56 } 57 58 protected Map <String ,String > 59 getParamNameOverrides() 60 { 61 return( MapUtil.newMap( AMXConfig.NAME_KEY, "ref" ) ); 62 } 63 64 65 public ObjectName 66 create( 67 final String referencedResourceName, 68 final Map <String ,String > optional) 69 { 70 final String j2eeType = getFactoryContainer().getJ2EEType(); 71 final String containerName = getFactoryContainer().getName(); 72 73 getOldResourcesMBean().createResourceReference(containerName, true, 74 referencedResourceName); 75 76 ObjectName pattern = null; 77 if( XTypes.STANDALONE_SERVER_CONFIG.equals(j2eeType) ) 78 { 79 pattern = Util.newObjectNamePattern( "com.sun.appserv", 80 "type=resource-ref,ref=" + referencedResourceName + 81 ",server=" + containerName); 82 } 83 else 84 { 85 pattern = Util.newObjectNamePattern( "com.sun.appserv", 86 "type=resource-ref,ref=" + referencedResourceName + 87 ",cluster=" + containerName); 88 } 89 90 final Set <ObjectName > oldNames = 91 JMXUtil.queryNames( getCallbacks().getMBeanServer(), pattern, null ); 92 final ObjectName oldObjectName = GSetUtil.getSingleton( oldNames ); 93 94 final ObjectName amxName = syncNewAMXMBeanWithOld( oldObjectName ); 95 96 return( amxName ); 97 } 98 99 public ObjectName 100 create(final String referencedResourceName) 101 { 102 return create(referencedResourceName, null); 103 } 104 105 106 public ObjectName 107 create( 108 final String referencedResourceName, 109 final boolean enabled) 110 { 111 final Map <String ,String > optionalParams = new HashMap <String ,String >(); 112 optionalParams.put( ResourceConfigKeys.ENABLED_KEY,Boolean.toString(enabled)); 113 114 return create(referencedResourceName, optionalParams); 115 } 116 117 protected void 118 internalRemove( final ObjectName objectName ) 119 { 120 final String containerName = getFactoryContainer().getName(); 121 122 getOldResourcesMBean().deleteResourceReference( containerName, Util.getName( objectName )); 123 } 124 } 125 126 127 128 129 130 131 132 133 | Popular Tags |