1 23 24 package com.sun.enterprise.management.config; 25 26 import java.util.Map ; 27 import java.util.HashMap ; 28 29 import com.sun.appserv.management.DomainRoot; 30 31 import com.sun.appserv.management.config.ConfigConfig; 32 import com.sun.appserv.management.config.StandaloneServerConfig; 33 import com.sun.appserv.management.config.DomainConfig; 34 import com.sun.appserv.management.config.ServerConfigKeys; 35 36 37 39 public final class ConfigSetup 40 { 41 final DomainRoot mDomainRoot; 42 43 public static final String TEST_SERVER_NAME = "testServer"; 44 public static final String TEST_CONFIG_NAME = TEST_SERVER_NAME + "-config"; 45 46 public 47 ConfigSetup( final DomainRoot domainRoot ) 48 { 49 mDomainRoot = domainRoot; 50 } 51 52 public DomainConfig 53 getDomainConfig() 54 { 55 return mDomainRoot.getDomainConfig(); 56 } 57 58 public ConfigConfig 59 createConfig( final String name) 60 { 61 final Map <String ,String > options = new HashMap <String ,String >(); 62 63 final ConfigConfig config = 64 getDomainConfig().createConfigConfig( name, options ); 65 66 return config; 67 } 68 69 public boolean 70 removeConfig( final String name) 71 { 72 boolean exists = getDomainConfig().getConfigConfigMap().get( name ) != null; 73 74 if ( exists ) 75 { 76 getDomainConfig().removeConfigConfig( name ); 77 } 78 79 return exists; 80 } 81 82 public void 83 setupServerPorts( 84 final Map <String ,String > options, 85 final int basePort ) 86 { 87 options.put( ServerConfigKeys.HTTP_LISTENER_1_PORT_KEY, "" + (basePort + 0) ); 88 options.put( ServerConfigKeys.HTTP_LISTENER_2_PORT_KEY, "" + (basePort + 1) ); 89 options.put( ServerConfigKeys.ORB_LISTENER_1_PORT_KEY, "" + (basePort + 2) ); 90 options.put( ServerConfigKeys.SSL_PORT_KEY, "" + (basePort + 3) ); 91 options.put( ServerConfigKeys.SSL_MUTUALAUTH_PORT_KEY, "" + (basePort + 4) ); 92 options.put( ServerConfigKeys.JMX_SYSTEM_CONNECTOR_PORT_KEY, "" + (basePort + 5) ); 93 options.put( ServerConfigKeys.JMS_PROVIDER_PORT_KEY, "" + (basePort + 6) ); 94 options.put( ServerConfigKeys.ADMIN_LISTENER_PORT_KEY, "" + (basePort + 7) ); 95 } 96 97 public StandaloneServerConfig 98 createServer( 99 final String name, 100 int basePort, 101 final String nodeAgentName, 102 final String configName ) 103 { 104 final Map <String ,String > options = new HashMap <String ,String >(); 105 106 setupServerPorts( options, basePort ); 107 108 final StandaloneServerConfig server = 109 getDomainConfig().createStandaloneServerConfig( 110 name, nodeAgentName, configName, options ); 111 112 return server; 113 } 114 115 116 public boolean 117 removeServer( final String name ) 118 { 119 boolean exists = getDomainConfig().getStandaloneServerConfigMap().get( name ) != null; 120 121 if ( exists ) 122 { 123 getDomainConfig().removeStandaloneServerConfig( name ); 124 } 125 126 return exists; 127 } 128 } 129 130 131 132 133 134 135 | Popular Tags |