クラス org.objectweb.cjdbc.controller.core.ControllerFactory

org.objectweb.cjdbc.controller.core.ControllerFactoryのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

説明

The ControllerFactory class prepares a Controller object by configurating ports, security, loaded databases.

作者:
Emmanuel Cecchet

Nicolas Modrzyk

Duncan Smith

バージョン:
1.0

ControllerFactory.java65 行で定義されています。

Public メソッド

 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 変数

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"

スタティック変数

Trace logger = Trace.getLogger(Controller.class.getName())

Private メソッド

Controller setup () throws Exception

Static Private メソッド

void printUsage (Options options)
Options createOptions ()

Private 変数

Controller controller = null


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory String  args[]  ) 
 

Configure the controller with parameters

引数:
args parameters from the command line
ControllerFactory.java103 行で定義されています。

参照先 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.createOptions(), 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.printUsage(), org.objectweb.cjdbc.controller.core.ControllerFactory.RMI_PORT, と org.objectweb.cjdbc.controller.core.ControllerFactory.XML_FILE.

00103 { 00104 System.setProperty("org.xml.sax.driver", 00105 "org.apache.crimson.parser.XMLReaderImpl"); 00106 00107 URL defaultControllerXmlFile = ControllerFactory.class.getResource("/" 00108 + ControllerConstants.DEFAULT_CONFIG_FILE); 00109 if (defaultControllerXmlFile == null) 00110 logger 00111 .warn("Unable to find default controller.xml configuration file in CLASSPATH."); 00112 else { 00113 String file = URLDecoder.decode(defaultControllerXmlFile.getFile()); 00114 this.put(XML_FILE, file); 00115 } 00116 this.put(CONTROLLER_IP, ControllerConstants.DEFAULT_IP); 00117 this.put(CONTROLLER_PORT, "" + ControllerConstants.DEFAULT_PORT); 00118 this.put(CONTROLLER_BACKLOG, "" 00119 + ControllerConstants.DEFAULT_BACKLOG_SIZE); 00120 00121 // Create options object 00122 Options options = createOptions(); 00123 00124 // Parse command line 00125 CommandLineParser parser = new GnuParser(); 00126 CommandLine commandLine = null; 00127 try { 00128 commandLine = parser.parse(options, args); 00129 } catch (ParseException e) { 00130 logger.fatal(Translate.get( 00131 "controller.configure.commandline.error", e), e); 00132 printUsage(options); 00133 Runtime.getRuntime().exit(1); 00134 } 00135 00136 // Non-recognized options 00137 int n = commandLine.getArgs().length; 00138 for (int i = 0; i < n; i++) { 00139 logger.fatal(Translate.get("controller.configure.unknown.option", 00140 commandLine.getArgs()[i])); 00141 printUsage(options); 00142 Runtime.getRuntime().exit(1); 00143 } 00144 // Handle --help option 00145 if (commandLine.hasOption('h')) { 00146 if (commandLine.getOptions().length > 1) 00147 logger.fatal(Translate 00148 .get("controller.configure.commandline.error")); 00149 00150 printUsage(options); 00151 Runtime.getRuntime().exit(1); 00152 } 00153 00154 // Handle --version option 00155 if (commandLine.hasOption('v')) { 00156 if (commandLine.getOptions().length > 1) { 00157 logger.fatal(Translate 00158 .get("controller.configure.commandline.error")); 00159 printUsage(options); 00160 } else 00161 logger.info(Controller.getVersion()); 00162 Runtime.getRuntime().exit(1); 00163 } 00164 00165 // Handle -rmi option 00166 if (commandLine.hasOption('r')) { 00167 String s = commandLine.getOptionValue('r'); 00168 if (s != null) { 00169 this.put(JMX_ENABLE, "true"); 00170 this.put(RMI_PORT, s); 00171 this.put(JmxConstants.ADAPTOR_TYPE_RMI, s); 00172 } 00173 } 00174 00175 // Handle -jmx option 00176 if (commandLine.hasOption('j')) { 00177 String s = commandLine.getOptionValue('j'); 00178 if (s != null) { 00179 this.put(JMX_ENABLE, "true"); 00180 this.put(JMX_PORT, s); 00181 this.put(JmxConstants.ADAPTOR_TYPE_HTTP, s); 00182 } 00183 } 00184 00185 // Handle --ip option 00186 if (commandLine.hasOption('i')) { 00187 String ipAddress = commandLine.getOptionValue('i'); 00188 if (ipAddress != null) 00189 this.put(CONTROLLER_IP, ipAddress); 00190 } 00191 00192 // Handle --port option 00193 if (commandLine.hasOption('p')) { 00194 String port = commandLine.getOptionValue('p'); 00195 if (port != null) 00196 this.put(CONTROLLER_PORT, port); 00197 } 00198 00199 // Handle -f option 00200 if (commandLine.hasOption('f')) { 00201 // If a config file is specified we ignore the default file. 00202 this.remove(XML_FILE); 00203 String filePath = commandLine.getOptionValue('f'); 00204 File f = new File(filePath); 00205 logger.debug(f.getAbsolutePath()); 00206 if (f.exists() == false || f.isFile() == false) 00207 logger.warn(Translate 00208 .get("controller.configure.optional.file.invalid")); 00209 else 00210 this.put(XML_FILE, filePath); 00211 } 00212 }


メソッド

Options org.objectweb.cjdbc.controller.core.ControllerFactory.createOptions  )  [static, private]
 

Creates Options object that contains all available options that can be used launching C-JDBC controller.

戻り値:
an Options instance
ControllerFactory.java400 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory().

00400 { 00401 Options options = new Options(); 00402 OptionGroup group = new OptionGroup(); 00403 00404 // help and verbose options 00405 group.addOption(new Option("h", "help", false, Translate 00406 .get("controller.commandline.option.help"))); 00407 group.addOption(new Option("v", "version", false, Translate 00408 .get("controller.commandline.option.version"))); 00409 options.addOptionGroup(group); 00410 00411 // RMI port option 00412 options.addOption(new Option("r", "rmi", true, Translate.get( 00413 "controller.commandline.option.rmi", "" 00414 + JmxConstants.DEFAULT_JMX_RMI_PORT))); 00415 // JMX port option 00416 options.addOption(new Option("j", "jmx", true, Translate.get( 00417 "controller.commandline.option.jmx", "" 00418 + JmxConstants.DEFAULT_JMX_HTTP_PORT))); 00419 00420 // IP option 00421 String defaultIp = "127.0.0.1"; 00422 try { 00423 defaultIp = InetAddress.getLocalHost().getHostAddress(); 00424 } catch (UnknownHostException e) { 00425 00426 } 00427 options.addOption(new Option("i", "ip", true, Translate.get( 00428 "controller.commandline.option.ip", "" + defaultIp))); 00429 00430 // Port options 00431 options.addOption(new Option("p", "port", true, Translate.get( 00432 "controller.commandline.option.port", "" 00433 + ControllerConstants.DEFAULT_PORT))); 00434 00435 // configuration file option 00436 options.addOption(new Option("f", "file", true, Translate 00437 .get("controller.commandline.option.file"))); 00438 00439 return options; 00440 }

Controller org.objectweb.cjdbc.controller.core.ControllerFactory.getController  )  throws Exception
 

Retrieve the controller associated with this ControllerFactory instance.

戻り値:
Controller object. Can be null if this method is called before setup
例外:
Exception if an error occurs
ControllerFactory.java281 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.Controller.main().

00281 { 00282 if (controller == null) 00283 setup(); 00284 return this.controller; 00285 }

void org.objectweb.cjdbc.controller.core.ControllerFactory.printUsage Options  options  )  [static, private]
 

Displays usage message.

引数:
options available command line options
ControllerFactory.java384 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory().

00384 { 00385 String header = Translate.get("controller.commandline.header"); 00386 header += System.getProperty("line.separator"); 00387 header += Translate.get("controller.commandline.options"); 00388 String footer = Translate.get("controller.commandline.footer"); 00389 00390 (new HelpFormatter()).printHelp(80, "controller(.sh|.bat) [options]", 00391 header, options, footer); 00392 }

Controller org.objectweb.cjdbc.controller.core.ControllerFactory.setup  )  throws Exception [private]
 

Test if there is a file to take configuration from, if so call <method> setUpByXml() </method>

戻り値:
an instanciated and configured object of class Controller
例外:
Exception if configuration fails
ControllerFactory.java245 行で定義されています。

参照先 org.objectweb.cjdbc.controller.core.ControllerFactory.controller, 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.logger, org.objectweb.cjdbc.controller.core.Controller.setConfiguration(), org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml(), と org.objectweb.cjdbc.controller.core.ControllerFactory.XML_FILE.

00245 { 00246 String xml = (String) this.get(XML_FILE); 00247 00248 int portNumber = Integer.parseInt((String) this.get(CONTROLLER_PORT)); 00249 int backlog = Integer.parseInt((String) this.get(CONTROLLER_BACKLOG)); 00250 String ipAddress = (String) this.get(CONTROLLER_IP); 00251 00252 controller = new Controller(ipAddress, portNumber, backlog); 00253 controller.setConfiguration(this); 00254 00255 if (xml != null) { 00256 try { 00257 setUpByXml(xml); 00258 } catch (Exception e) { 00259 logger 00260 .error( 00261 Translate 00262 .get( 00263 "controller.configure.load.file.failed.minimum.configuration", 00264 new String[] { xml, 00265 e.getMessage() }), e); 00266 } 00267 } else 00268 setUpJmx(); 00269 00270 return this.controller; 00271 }

void org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml String  filename  )  throws Exception
 

This method is going to call a ControllerParser object to configure controller while parsing file. This method will call <method> setUpRmi() </method> and <method>setUpJmx() </method> as well as <method> setUpVirtualDatabases </method> while parsing.

引数:
filename path to the xml file to parse from
例外:
Exception if configuration fails
ControllerFactory.java223 行で定義されています。

参照先 org.objectweb.cjdbc.controller.core.ControllerFactory.logger, と org.objectweb.cjdbc.controller.xml.ControllerParser.readXML().

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.setup().

00223 { 00224 logger.info(Translate 00225 .get("controller.configure.loading.file", filename)); 00226 try { 00227 FileReader fileReader = new FileReader(filename); 00228 ControllerParser cparser = new ControllerParser(this); 00229 cparser.readXML(fileReader, true); 00230 } catch (Exception e) { 00231 logger.warn( 00232 Translate.get("controller.configure.xml.file.error", e), e); 00233 throw e; 00234 } 00235 }

void org.objectweb.cjdbc.controller.core.ControllerFactory.setUpJmx  )  throws JmxException
 

Start up the jmx services if enabled.

例外:
JmxException an exception
ControllerFactory.java292 行で定義されています。

参照先 org.objectweb.cjdbc.controller.jmx.RmiConnector.start(), と org.objectweb.cjdbc.controller.jmx.HttpAdaptor.start().

00292 { 00293 boolean jmxEnable = new Boolean((String) get(JMX_ENABLE)) 00294 .booleanValue(); 00295 if (jmxEnable == false) { 00296 MBeanServerManager.setJmxEnabled(false); 00297 logger.info(Translate.get("jmx.configure.disabled")); 00298 } else { 00299 MBeanServerManager.setJmxEnabled(true); 00300 logger.info(Translate.get("jmx.configure.enabled")); 00301 // Create and start the JMX agent 00302 try { 00303 new DataCollector(controller); 00304 String hostIP = controller.getIPAddress(); 00305 00306 logger.info(Translate.get("controller.configure.start.jmx", 00307 hostIP)); 00308 00309 if (this.containsKey(JmxConstants.ADAPTOR_TYPE_HTTP)) { 00310 int port = Integer.parseInt((String) this 00311 .get(JmxConstants.ADAPTOR_TYPE_HTTP)); 00312 HttpAdaptor http = new HttpAdaptor(hostIP, port, null, null); 00313 http.start(); 00314 } 00315 if (this.containsKey(JmxConstants.ADAPTOR_TYPE_RMI)) { 00316 SSLConfiguration ssl = null; 00317 PasswordAuthenticator authenticator = null; 00318 int port = Integer.parseInt((String) this 00319 .get(JmxConstants.ADAPTOR_TYPE_RMI)); 00320 if (this.containsKey(JmxConstants.CONNECTOR_AUTH_USERNAME)) { 00321 String username = (String) this 00322 .get(JmxConstants.CONNECTOR_AUTH_USERNAME); 00323 String password = (String) this 00324 .get(JmxConstants.CONNECTOR_AUTH_PASSWORD); 00325 authenticator = new PasswordAuthenticator(username, 00326 password); 00327 } 00328 if (this.containsKey(JmxConstants.CONNECTOR_RMI_SSL)) { 00329 ssl = (SSLConfiguration) this 00330 .get(JmxConstants.CONNECTOR_RMI_SSL); 00331 } 00332 RmiConnector rmi = new RmiConnector(controller.getName(), 00333 hostIP, port, authenticator, ssl); 00334 rmi.start(); 00335 } 00336 logger.debug(Translate.get("controller.configure.jmx.started")); 00337 } catch (Exception e) { 00338 logger.error(Translate.get( 00339 "controller.configure.jmx.fail.start", e), e); 00340 } 00341 } 00342 controller.setJmxEnable(jmxEnable); 00343 }

void org.objectweb.cjdbc.controller.core.ControllerFactory.setUpSecurity ControllerSecurityManager  security  ) 
 

Set up security settings if needed here.

引数:
security to enforce
ControllerFactory.java350 行で定義されています。
00350 { 00351 controller.setSecurity(security); 00352 }

void org.objectweb.cjdbc.controller.core.ControllerFactory.setUpVirtualDatabase String  filePath,
String  virtualName,
int  autoLoad,
String  checkPoint
 

Will load the VirtualDatabase configuration into the controller.

引数:
filePath the path to xml definition of the virtual database
virtualName the name of the virtualDatabase to load
autoLoad specified if backend should be enabled.
checkPoint the check point to load the database from.
ControllerFactory.java363 行で定義されています。
00364 { 00365 try { 00366 controller.loadXmlConfiguration(filePath, virtualName, autoLoad, 00367 checkPoint); 00368 if (logger.isDebugEnabled()) 00369 logger.debug(Translate.get( 00370 "controller.configure.file.autoload", new String[] { 00371 filePath, "" + autoLoad })); 00372 00373 } catch (Exception e) { 00374 logger.error(Translate.get("controller.configure.load.file.failed", 00375 new String[] { filePath, e.getMessage() }), e); 00376 } 00377 }


変数

final String org.objectweb.cjdbc.controller.core.ControllerFactory.ADD_DRIVER_ENABLE = "addDriverEnable" [static]
 

Add driver enable ControllerFactory.java91 行で定義されています。

Controller org.objectweb.cjdbc.controller.core.ControllerFactory.controller = null [private]
 

ControllerFactory.java96 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.setup().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_BACKLOG = "controllerBackLogSize" [static]
 

The controller backlog size ControllerFactory.java88 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), と org.objectweb.cjdbc.controller.core.ControllerFactory.setup().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_IP = "controllerIP" [static]
 

The NIC IP address to bind the controller to ControllerFactory.java82 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), と org.objectweb.cjdbc.controller.core.ControllerFactory.setup().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.CONTROLLER_PORT = "controllerPort" [static]
 

The controller port number ControllerFactory.java85 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), と org.objectweb.cjdbc.controller.core.ControllerFactory.setup().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.JMX_ENABLE = "jmxEnable" [static]
 

The jmx enable value ControllerFactory.java76 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.JMX_PORT = "jmxPort" [static]
 

The jmx port value ControllerFactory.java73 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory().

Trace org.objectweb.cjdbc.controller.core.ControllerFactory.logger = Trace.getLogger(Controller.class.getName()) [static, package]
 

Logger instance. ControllerFactory.java94 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), org.objectweb.cjdbc.controller.core.ControllerFactory.setup(), と org.objectweb.cjdbc.controller.core.ControllerFactory.setUpByXml().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.RMI_PORT = "rmiPort" [static]
 

The Rmi port value ControllerFactory.java70 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory().

final String org.objectweb.cjdbc.controller.core.ControllerFactory.XML_FILE = "xmlFile" [static]
 

The xml file possibly used to configure controller ControllerFactory.java79 行で定義されています。

参照元 org.objectweb.cjdbc.controller.core.ControllerFactory.ControllerFactory(), と org.objectweb.cjdbc.controller.core.ControllerFactory.setup().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:41 2004に生成されました。 doxygen 1.3.8