Public Member Functions | |
ControllerFactory (String args[]) | |
void | setUpByXml (String filename) throws Exception |
Controller | getController () throws Exception |
void | setUpJmx () throws JmxException |
void | setUpSecurity (ControllerSecurityManager security) |
void | setUpVirtualDatabase (String filePath, String virtualName, int autoLoad, String checkPoint) |
Static Public Attributes | |
final String | RMI_PORT = "rmiPort" |
final String | JMX_PORT = "jmxPort" |
final String | JMX_ENABLE = "jmxEnable" |
final String | XML_FILE = "xmlFile" |
final String | CONTROLLER_IP = "controllerIP" |
final String | CONTROLLER_PORT = "controllerPort" |
final String | CONTROLLER_BACKLOG = "controllerBackLogSize" |
final String | ADD_DRIVER_ENABLE = "addDriverEnable" |
Static Package Attributes | |
Trace | logger |
ControllerFactory
class prepares a Controller
object by configurating ports, security, loaded databases.
Definition at line 65 of file ControllerFactory.java.
|
Configure the controller with parameters
Definition at line 106 of file ControllerFactory.java. References org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_BACKLOG, org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_IP, org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_PORT, org.objectweb.cjdbc.controller.core.ControllerFactory.JMX_ENABLE, org.objectweb.cjdbc.controller.core.ControllerFactory.JMX_PORT, org.objectweb.cjdbc.controller.core.ControllerFactory.logger, org.objectweb.cjdbc.controller.core.ControllerFactory.RMI_PORT, and org.objectweb.cjdbc.controller.core.ControllerFactory.XML_FILE. 00107 { 00108 System.setProperty("org.xml.sax.driver", 00109 "org.apache.crimson.parser.XMLReaderImpl"); 00110 00111 URL defaultControllerXmlFile = ControllerFactory.class.getResource("/" 00112 + ControllerConstants.DEFAULT_CONFIG_FILE); 00113 if (defaultControllerXmlFile == null) 00114 logger 00115 .warn("Unable to find default controller.xml configuration file in CLASSPATH."); 00116 else 00117 { 00118 String file = URLDecoder.decode(defaultControllerXmlFile.getFile()); 00119 this.put(XML_FILE, file); 00120 } 00121 this.put(CONTROLLER_IP, ControllerConstants.DEFAULT_IP); 00122 this.put(CONTROLLER_PORT, "" + ControllerConstants.DEFAULT_PORT); 00123 this.put(CONTROLLER_BACKLOG, "" + ControllerConstants.DEFAULT_BACKLOG_SIZE); 00124 00125 // Create options object 00126 Options options = createOptions(); 00127 00128 // Parse command line 00129 CommandLineParser parser = new GnuParser(); 00130 CommandLine commandLine = null; 00131 try 00132 { 00133 commandLine = parser.parse(options, args); 00134 } 00135 catch (ParseException e) 00136 { 00137 logger.fatal(Translate.get("controller.configure.commandline.error", e), 00138 e); 00139 printUsage(options); 00140 Runtime.getRuntime().exit(1); 00141 } 00142 00143 // Non-recognized options 00144 int n = commandLine.getArgs().length; 00145 for (int i = 0; i < n; i++) 00146 { 00147 logger.fatal(Translate.get("controller.configure.unknown.option", 00148 commandLine.getArgs()[i])); 00149 printUsage(options); 00150 Runtime.getRuntime().exit(1); 00151 } 00152 // Handle --help option 00153 if (commandLine.hasOption('h')) 00154 { 00155 if (commandLine.getOptions().length > 1) 00156 logger.fatal(Translate.get("controller.configure.commandline.error")); 00157 00158 printUsage(options); 00159 Runtime.getRuntime().exit(1); 00160 } 00161 00162 // Handle --version option 00163 if (commandLine.hasOption('v')) 00164 { 00165 if (commandLine.getOptions().length > 1) 00166 { 00167 logger.fatal(Translate.get("controller.configure.commandline.error")); 00168 printUsage(options); 00169 } 00170 else 00171 logger.info(Controller.getVersion()); 00172 Runtime.getRuntime().exit(1); 00173 } 00174 00175 // Handle -rmi option 00176 if (commandLine.hasOption('r')) 00177 { 00178 String s = commandLine.getOptionValue('r'); 00179 if (s != null) 00180 { 00181 this.put(JMX_ENABLE, "true"); 00182 this.put(RMI_PORT, s); 00183 this.put(JmxConstants.ADAPTOR_TYPE_RMI, s); 00184 } 00185 } 00186 00187 // Handle -jmx option 00188 if (commandLine.hasOption('j')) 00189 { 00190 String s = commandLine.getOptionValue('j'); 00191 if (s != null) 00192 { 00193 this.put(JMX_ENABLE, "true"); 00194 this.put(JMX_PORT, s); 00195 this.put(JmxConstants.ADAPTOR_TYPE_HTTP, s); 00196 } 00197 } 00198 00199 // Handle --ip option 00200 if (commandLine.hasOption('i')) 00201 { 00202 String ipAddress = commandLine.getOptionValue('i'); 00203 if (ipAddress != null) 00204 this.put(CONTROLLER_IP, ipAddress); 00205 } 00206 00207 // Handle --port option 00208 if (commandLine.hasOption('p')) 00209 { 00210 String port = commandLine.getOptionValue('p'); 00211 if (port != null) 00212 this.put(CONTROLLER_PORT, port); 00213 } 00214 00215 // Handle -f option 00216 if (commandLine.hasOption('f')) 00217 { 00218 // If a config file is specified we ignore the default file. 00219 this.remove(XML_FILE); 00220 String filePath = commandLine.getOptionValue('f'); 00221 File f = new File(filePath); 00222 logger.debug(f.getAbsolutePath()); 00223 if (f.exists() == false || f.isFile() == false) 00224 logger 00225 .warn(Translate.get("controller.configure.optional.file.invalid")); 00226 else 00227 this.put(XML_FILE, filePath); 00228 } 00229 }
|
|
Retrieve the controller associated with this
Definition at line 310 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.Controller.main(). 00311 { 00312 if (controller == null) 00313 setup(); 00314 return this.controller; 00315 }
|
|
This method is going to call a
Definition at line 240 of file ControllerFactory.java. References org.objectweb.cjdbc.controller.core.ControllerFactory.logger, and org.objectweb.cjdbc.controller.xml.ControllerParser.readXML(). 00241 { 00242 logger.info(Translate.get("controller.configure.loading.file", filename)); 00243 FileReader fileReader = null; 00244 try 00245 { 00246 fileReader = new FileReader(filename); 00247 ControllerParser cparser = new ControllerParser(this); 00248 cparser.readXML(fileReader, true); 00249 fileReader.close(); 00250 } 00251 catch (Exception e) 00252 { 00253 00254 logger.warn(Translate.get("controller.configure.xml.file.error", e), e); 00255 throw e; 00256 } 00257 finally 00258 { 00259 if (fileReader != null) 00260 fileReader.close(); 00261 } 00262 }
|
|
Start up the jmx services if enabled.
Definition at line 322 of file ControllerFactory.java. References org.objectweb.cjdbc.controller.core.Controller.getIPAddress(), org.objectweb.cjdbc.controller.jmx.RmiConnector.start(), and org.objectweb.cjdbc.controller.jmx.HttpAdaptor.start(). 00323 { 00324 boolean jmxEnable = new Boolean((String) get(JMX_ENABLE)).booleanValue(); 00325 if (jmxEnable == false) 00326 { 00327 MBeanServerManager.setJmxEnabled(false); 00328 logger.info(Translate.get("jmx.configure.disabled")); 00329 } 00330 else 00331 { 00332 MBeanServerManager.setJmxEnabled(true); 00333 logger.info(Translate.get("jmx.configure.enabled")); 00334 // Create and start the JMX agent 00335 try 00336 { 00337 new DataCollector(controller); 00338 String hostIP = controller.getIPAddress(); 00339 00340 logger.info(Translate.get("controller.configure.start.jmx", hostIP)); 00341 00342 if (this.containsKey(JmxConstants.ADAPTOR_TYPE_HTTP)) 00343 { 00344 int port = Integer.parseInt((String) this 00345 .get(JmxConstants.ADAPTOR_TYPE_HTTP)); 00346 HttpAdaptor http = new HttpAdaptor(hostIP, port, null, null); 00347 http.start(); 00348 } 00349 if (this.containsKey(JmxConstants.ADAPTOR_TYPE_RMI)) 00350 { 00351 SSLConfiguration ssl = null; 00352 PasswordAuthenticator authenticator = null; 00353 int port = Integer.parseInt((String) this 00354 .get(JmxConstants.ADAPTOR_TYPE_RMI)); 00355 if (this.containsKey(JmxConstants.CONNECTOR_AUTH_USERNAME)) 00356 { 00357 String username = (String) this 00358 .get(JmxConstants.CONNECTOR_AUTH_USERNAME); 00359 String password = (String) this 00360 .get(JmxConstants.CONNECTOR_AUTH_PASSWORD); 00361 authenticator = new PasswordAuthenticator(username, password); 00362 } 00363 if (this.containsKey(JmxConstants.CONNECTOR_RMI_SSL)) 00364 { 00365 ssl = (SSLConfiguration) this.get(JmxConstants.CONNECTOR_RMI_SSL); 00366 } 00367 RmiConnector rmi = new RmiConnector(controller.getControllerName(), hostIP, 00368 port, authenticator, ssl); 00369 rmi.start(); 00370 } 00371 logger.debug(Translate.get("controller.configure.jmx.started")); 00372 } 00373 catch (Exception e) 00374 { 00375 logger 00376 .error(Translate.get("controller.configure.jmx.fail.start", e), e); 00377 } 00378 } 00379 controller.setJmxEnable(jmxEnable); 00380 }
|
|
Set up security settings if needed here.
Definition at line 387 of file ControllerFactory.java. 00388 { 00389 controller.setSecurity(security); 00390 }
|
|
Will load the
Definition at line 401 of file ControllerFactory.java. 00403 { 00404 try 00405 { 00406 controller.loadXmlConfiguration(filePath, virtualName, autoLoad, 00407 checkPoint); 00408 if (logger.isDebugEnabled()) 00409 logger.debug(Translate.get("controller.configure.file.autoload", 00410 new String[]{filePath, "" + autoLoad})); 00411 00412 } 00413 catch (Exception e) 00414 { 00415 logger.error(Translate.get("controller.configure.load.file.failed", 00416 new String[]{filePath, e.getMessage()}), e); 00417 } 00418 }
|
|
Add driver enable Definition at line 92 of file ControllerFactory.java. |
|
The controller backlog size Definition at line 89 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
The NIC IP address to bind the controller to Definition at line 83 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
The controller port number Definition at line 86 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
The jmx enable value Definition at line 77 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
The jmx port value Definition at line 74 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
Initial value: Trace .getLogger(Controller.class .getName()) Definition at line 95 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), and org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml(). |
|
The Rmi port value Definition at line 71 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |
|
The xml file possibly used to configure controller Definition at line 80 of file ControllerFactory.java. Referenced by org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(). |