1 18 19 package org.apache.beehive.netui.tools.testrecorder.shared.config; 20 21 import org.apache.beehive.netui.tools.testrecorder.shared.util.StringHelper; 22 23 import java.util.List ; 24 import java.util.ArrayList ; 25 import java.util.Map ; 26 import java.util.HashMap ; 27 28 33 public class ServerDefinition { 34 35 private String name; 36 private String hostname; 37 private int port; 38 private List webappList; 39 private Map webappMap; 40 private Map testDefMap; 41 private List testDefList; 42 43 public ServerDefinition( String name, String hostname, int port ) { 44 this.name = name; 45 this.hostname = hostname; 46 this.port = port; 47 webappList = new ArrayList (); 48 webappMap = new HashMap (); 49 testDefMap = new HashMap (); 50 testDefList = new ArrayList (); 51 } 52 53 public void addWebapp( WebappDefinition webapp ) { 54 webappList.add( webapp ); 55 webappMap.put( webapp.getName(), webapp ); 56 } 57 58 public WebappDefinition getWebapp( String webappName ) { 59 return (WebappDefinition) webappMap.get( webappName ); 60 } 61 62 public WebappDefinition[] getWebapps() { 63 return (WebappDefinition[]) webappList.toArray( new WebappDefinition[webappList.size()] ); 64 } 65 66 public int getWebappCount() { 67 return webappList.size(); 68 } 69 70 public void addTestDefinitions( WebappDefinition webapp, TestDefinitions tests ) { 71 testDefMap.put( webapp, tests ); 72 testDefList.add( tests ); 73 } 74 75 public TestDefinitions getTestDefinitions( String webappName ) throws ConfigException { 76 WebappDefinition webapp = getWebapp( webappName ); 77 if ( webapp == null ) { 78 throw new ConfigException( "No webapp exists for webapp with name( " + webappName ); 79 } 80 return getTestDefinitions( webapp ); 81 } 82 83 public TestDefinitions getTestDefinitions( WebappDefinition webapp ) { 84 return (TestDefinitions) testDefMap.get( webapp ); 85 } 86 87 public TestDefinitions[] getTestDefinitions() { 88 return (TestDefinitions[]) testDefList.toArray( new TestDefinitions[testDefList.size()] ); 89 } 90 91 public int getTestDefinitionsCount() { 92 return testDefList.size(); 93 } 94 95 public String getName() { 96 return name; 97 } 98 99 public String getHostname() { 100 return hostname; 101 } 102 103 public int getPort() { 104 return port; 105 } 106 107 public String toString() { 108 StringBuffer sb = new StringBuffer ( 48 ); 109 sb.append( "[ " ); 110 sb.append( "name( " + getName() + " )" ); 111 sb.append( ", hostname( " + getHostname() + " )" ); 112 sb.append( ", port( " + getPort() + " )" ); 113 sb.append( ", webappList( " + StringHelper.toString( webappList, "\n", "\n\t" ) + " )" ); 114 sb.append( " ]" ); 115 return sb.toString(); 116 } 117 118 } 119 | Popular Tags |