1 14 15 package org.quickserver.util.xmlreader; 16 17 import org.quickserver.net.server.QuickServer; 18 import org.quickserver.net.qsadmin.QSAdminServer; 19 20 29 public class QSAdminServerConfig extends BasicServerConfig { 30 31 private String commandPlugin; 32 private String commandShellEnabled = "false"; 33 private String commandShellPromptName = "QSAdmin"; 34 35 public QSAdminServerConfig() { 36 setName("QSAdminServer v " + QSAdminServer.getVersion()); 37 setPort(9877); 38 setBindAddr("127.0.0.1"); 39 setClientCommandHandler("org.quickserver.net.qsadmin.CommandHandler"); 40 setClientEventHandler("org.quickserver.net.qsadmin.CommandHandler"); 41 setClientAuthenticationHandler("org.quickserver.net.qsadmin.Authenticator"); 42 setClientData("org.quickserver.net.qsadmin.Data"); 43 setMaxConnection(1); 44 getServerMode().setBlocking(false); 45 } 46 47 48 53 public void setCommandPlugin(String plugin) { 54 if(plugin!=null && plugin.equals("")==false) 55 commandPlugin = plugin; 56 } 57 61 public String getCommandPlugin() { 62 return commandPlugin; 63 } 64 65 66 72 public void setCommandShellEnable(String enable) { 73 if(enable!=null && enable.equals("")==false) 74 commandShellEnabled = enable; 75 } 76 80 public String getCommandShellEnable() { 81 return commandShellEnabled; 82 } 83 84 90 public void setCommandShellPromptName(String commandShellPromptName) { 91 if(commandShellPromptName!=null && commandShellPromptName.equals("")==false) 92 this.commandShellPromptName = commandShellPromptName; 93 } 94 98 public String getCommandShellPromptName() { 99 return commandShellPromptName; 100 } 101 102 103 107 public String toXML(String pad) { 108 if(pad==null) pad=""; 109 110 StringBuffer sb = new StringBuffer (); 111 sb.append(pad+"<qsadmin-server>\n"); 112 113 if(getName()!=null) 114 sb.append(pad+"\t<name>"+getName()+"</name>\n"); 115 if(getServerBanner()!=null) 116 sb.append(pad+"\t<server-banner>"+getServerBanner()+"</server-banner>\n"); 117 sb.append(pad+"\t<port>"+getPort()+"</port>\n"); 118 sb.append(pad+"\t<bind-address>"+getBindAddr()+"</bind-address>\n"); 119 120 sb.append( getServerMode().toXML(pad+"\t") ); 121 122 if(getClientEventHandler()!=null) 123 sb.append(pad+"\t<client-event-handler>"+getClientEventHandler()+"</client-event-handler>\n"); 124 if(getClientCommandHandler()!=null) 125 sb.append(pad+"\t<client-command-handler>"+getClientCommandHandler()+"</client-command-handler>\n"); 126 if(getClientObjectHandler()!=null) 127 sb.append(pad+"\t<client-object-handler>"+getClientObjectHandler()+"</client-object-handler>\n"); 128 if(getClientBinaryHandler()!=null) 129 sb.append(pad+"\t<client-binary-handler>"+getClientBinaryHandler()+"</client-binary-handler>\n"); 130 if(getClientWriteHandler()!=null) 131 sb.append(pad+"\t<client-write-handler>"+getClientWriteHandler()+"</client-write-handler>\n"); 132 if(getClientAuthenticationHandler()!=null) 133 sb.append(pad+"\t<client-authentication-handler>"+getClientAuthenticationHandler()+"</client-authentication-handler>\n"); 134 else if(getAuthenticator()!=null) 135 sb.append(pad+"\t<authenticator>"+getAuthenticator()+"</authenticator>\n"); 136 if(getClientData()!=null) 137 sb.append(pad+"\t<client-data>"+getClientData()+"</client-data>\n"); 138 if(getClientExtendedEventHandler()!=null) 139 sb.append(pad+"\t<client-extended-event-handler>"+getClientExtendedEventHandler()+"</client-extended-event-handler>\n"); 140 141 sb.append(pad+"\t<timeout>"+getTimeout()+"</timeout>\n"); 142 if(getTimeoutMsg()!=null) 143 sb.append(pad+"\t<timeout-msg>"+getTimeoutMsg()+"</timeout-msg>\n"); 144 145 sb.append(pad+"\t<max-auth-try>"+getMaxAuthTry()+"</max-auth-try>\n"); 146 if(getMaxAuthTryMsg()!=null) 147 sb.append(pad+"\t<max-auth-try-msg>"+getMaxAuthTryMsg()+"</max-auth-try-msg>\n"); 148 149 sb.append(pad+"\t<max-connection>"+getMaxConnection()+"</max-connection>\n"); 150 if(getMaxConnectionMsg()!=null) 151 sb.append(pad+"\t<max-connection-msg>"+getMaxConnectionMsg()+"</max-connection-msg>\n"); 152 153 160 161 sb.append(getObjectPoolConfig().toXML(pad+"\t")); 162 163 sb.append(pad+"\t<communication-logging>\n"); 164 sb.append(pad+"\t\t<enable>"+getCommunicationLogging()+"</enable>\n"); 165 sb.append(pad+"\t</communication-logging>\n"); 166 167 if(getCommandPlugin()!=null) 168 sb.append(pad+"\t<command-plugin>"+getCommandPlugin()+"</command-plugin>\n"); 169 170 sb.append(pad+"\t<command-shell>\n"); 171 sb.append(pad+"\t\t<enable>"+getCommandShellEnable()+"</enable>\n"); 172 sb.append(pad+"\t\t<prompt-name>"+getCommandShellPromptName()+"</prompt-name>\n"); 173 sb.append(pad+"\t</command-shell>\n"); 174 175 if(getAccessConstraintConfig()!=null) { 176 sb.append(getAccessConstraintConfig().toXML(pad+"\t")); 177 } 178 179 if(getServerHooks()!=null) { 180 sb.append( getServerHooks().toXML(pad+"\t") ); 181 } 182 183 sb.append( getSecure().toXML(pad+"\t") ); 184 sb.append( getAdvancedSettings().toXML(pad+"\t") ); 185 186 sb.append(pad+"</qsadmin-server>\n"); 187 return sb.toString(); 188 } 189 190 public String toString() { 191 return toXML(null); 192 } 193 } 194 | Popular Tags |