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.Collections ; 36 37 38 import javax.management.ObjectName ; 39 import javax.management.AttributeList ; 40 41 import com.sun.appserv.management.base.XTypes; 42 import com.sun.appserv.management.util.misc.MapUtil; 43 import com.sun.appserv.management.util.misc.GSetUtil; 44 45 import com.sun.appserv.management.config.MailResourceConfigKeys; 46 import com.sun.appserv.management.config.ResourceConfigKeys; 47 import com.sun.appserv.management.config.ResourceRefConfig; 48 import com.sun.appserv.management.config.Description; 49 50 public final class MailResourceConfigFactory extends ResourceFactoryImplBase 51 { 52 public 53 MailResourceConfigFactory( 54 final ConfigFactoryCallback callbacks ) 55 { 56 super( callbacks ); 57 } 58 59 60 private final Set <String > LEGAL_OPTIONAL_KEYS = 61 GSetUtil.newUnmodifiableStringSet( 62 MailResourceConfigKeys.STORE_PROTOCOL_KEY, 63 MailResourceConfigKeys.STORE_PROTOCOL_CLASS_KEY, 64 MailResourceConfigKeys.TRANSPORT_PROTOCOL_KEY, 65 MailResourceConfigKeys.TRANSPORT_PROTOCOL_CLASS_KEY, 66 MailResourceConfigKeys.DEBUG_KEY, 67 Description.DESCRIPTION_KEY, 68 ResourceConfigKeys.ENABLED_KEY ); 69 70 protected Set <String > 71 getLegalOptionalCreateKeys() 72 { 73 return( LEGAL_OPTIONAL_KEYS ); 74 } 75 76 77 public static final String HOST_KEY = "Host"; 78 public static final String USER_KEY = "User"; 79 public static final String FROM_KEY = "From"; 80 81 82 protected Map <String ,String > 83 getParamNameOverrides() 84 { 85 return( MapUtil.newMap( CONFIG_NAME_KEY, "jndi-name" ) ); 86 } 87 88 89 92 protected ObjectName 93 createOldChildConfig( 94 final AttributeList translatedAttrs ) 95 { 96 trace( "MailResourceConfigFactory.createOldChildConfig: creating using: " + 97 stringify( translatedAttrs ) ); 98 99 final ObjectName objectName = 100 getOldResourcesMBean().createMailResource( translatedAttrs ); 101 102 return( objectName ); 103 } 104 105 106 115 public ObjectName 116 create( String jndiName, 117 String host, 118 String user, 119 String from, 120 Map <String ,String > optional) 121 { 122 final String [] requiredParams = new String [] 123 { 124 HOST_KEY, host, 125 USER_KEY, user, 126 FROM_KEY, from, 127 }; 128 129 final Map <String ,String > params = initParams( jndiName, requiredParams, optional ); 130 131 final ObjectName amxName = createNamedChild( jndiName, params ); 132 133 return( amxName ); 134 } 135 136 final protected void 137 removeByName( String name ) 138 { 139 final Set <ResourceRefConfig> refs = 140 findAllRefConfigs( XTypes.MAIL_RESOURCE_CONFIG, name ); 141 142 if ( refs.size() == 0 ) 143 { 144 getOldResourcesMBean().removeMailResourceByJndiName( name ); 145 } 146 else 147 { 148 for( final ResourceRefConfig ref : refs ) 149 { 150 final String target = ref.getContainer().getName(); 151 getOldResourcesMBean().deleteMailResource( name, target ); 152 } 153 } 154 } 155 156 157 158 } 159 160 | Popular Tags |