General use:
guzz_app.properties is used to store configuration information for each part of the system, most commonly for database configuration and service configuration.
The
guzz_app.properties file organizes a configuration file similar to MySQL, with each behavior 1 configuration items, beginning with # as comments.
[GroupName] is used to mark the beginning of a configuration group, this tag and the next [xxx] above each line, for the GroupName 1 configuration items, such as:
1 [masterdb] 2 xxx=xxx3 xxx=xxx45[slavedb] 6 .....
GroupName group name, also called configuration (information) group, group name can be repeated, used to define multiple sets of configurations for a configuration group, the most common scenario is to configure multiple [Slavedb] to be set to multiple from the database source.
The following is a typical configuration example:
1 #guzz app config file.2 3 #master DB4 [Masterdb]5Guzz.identifer=Blogmasterdb6Guzz. ip=localhost7guzz.maxload=1208driverclass=Com.mysql.jdbc.Driver9Jdbcurl=jdbc:mysql://localhost:3306/blog?useunicode=true&characterencoding=utf-8&useserverprepstmts=trueTenUser=Root Onepassword=Root Aacquireincrement=10 -Idleconnectiontestperiod=60 - the [Updatemasterdb] -Guzz.identifer=incUpdateDB1 -Guzz. ip=localhost -Guzz.maxload=20 +driverclass=Com.mysql.jdbc.Driver -Jdbcurl=jdbc:mysql://localhost:3306/guzzslowupdate?useunicode=true&Characterencoding=utf-8 +User=slowupdate Apassword=slowupdate atacquireincrement=10 -Idleconnectiontestperiod=60 - - [Logmasterdb] -Guzz.identifer=logUpdateDB1 -Guzz. ip=localhost inGuzz.maxload=20 -driverclass=Com.mysql.jdbc.Driver toJdbcurl=jdbc:mysql://localhost:3306/guzzlogdb?useunicode=true&characterencoding=utf-8&useserverprepstmts=true +User=LogUser -password=LogUser theacquireincrement=10 *Idleconnectiontestperiod=60 $ Panax Notoginseng [guzzslowupdate] - #max size of cached queue thequeuesize=20480 +batchsize=2048 A the [Guzzslowupdateserver] + #max size of cached queue -Batchsize=50 $Pagesize=40 $combinepagecount=10 - - [guzzdblogserviceclient] the #max size of cached queue -batchsize=2048Wuyiqueuesize=20480 the - #debug Settings Wu [Guzzdebug] -#runMode =debug/production AboutRunmode=Debug $#onError =Halt/log/ignore -Onerror=Halt -Printsql=false -printsqlparams=false AIgnoredemonthreadsql=true + the - ############################### Fundamental Services ##################### $#other Services ' configurations go here ...
Use multiple properties Profiles:
Properties configuration file with Guzz.xml
1 <Config-server>2 <Serverclass= "Org.guzz.config.LocalFileConfigServer">3 <paramname= "Resource"value= "Guzz_app.properties" />4 </Server>5 </Config-server>
Specified. You can specify more than one file as a profile at a time, or you can specify that some files are optional profiles, which are loaded and merged Guzz at startup.
An optional profile is a file that is loaded if it exists, or automatically ignored if the file does not exist.
The default configuration implementation, which allows for up to 4 properties general profiles and up to 4 optional configuration files. The complete configuration is as follows:
1 <Config-server>2 <Serverclass= "Org.guzz.config.LocalFileConfigServer">3 <paramname= "Resource"value= "Guzz_app.properties" />4 <paramname= "Resource1"value= "Guzz_app1.properties" />5 <paramname= "Resource2"value= "Guzz_app2.properties" />6 <paramname= "Resource3"value= "Guzz_app3.properties" />7 8 <paramname= "Optionalresource"value= "Guzz_app4.properties" />9 <paramname= "OptionalResource1"value= "Guzz_app5.properties" />Ten <paramname= "OptionalResource2"value= "Guzz_app6.properties" /> One <paramname= "OptionalResource3"value= "Guzz_app7.properties" /> A </Server> - </Config-server>
Configure using the Properties file list:
In this way, the properties configuration file that actually needs to be loaded is specified in a properties file in the form of a file name list.
Used to keep the consistency of the Guzz.xml file in the context of changing the properties configuration file.
Examples are as follows:
1 <Config-server>2 <Serverclass= "Org.guzz.config.LocalFileConfigServer">3 <paramname= "Resourcelist"value= "Resources_list.properties" />4 </Server>5 </Config-server>
Resources_list.properties content examples are as follows:
1 #basic config files 2 guzz_app.properties 3 4 #DBs 5 guzz_app_databases.properties 6 7 #guzz Task config file. 8 */root/optional_properties.properties
In this configuration, Guzz loads the configuration entries for Guzz_app.properties,guzz_app_databases.properties and/root/optional_properties.properties.
/root/optional_properties.properties *indicates that this file is an optional configuration file. Loaded if it exists, or automatically ignored if it does not exist.
Integration with Configuration Management Server
The
configuration Management Server can complete the unified management of all system profiles and push notifications to the app when configuration changes occur. Currently, Guzz has not developed a default standalone configuration Management Server and only provides support for reading the configuration from the local properties file (as described above).
to implement your own configuration management, you need to implement the following interfaces:
1 org.guzz.config.ConfigServer
and configured as your own implementation class in Guzz.xml:
<Config-server> <Serverclass= "Your config server ' s client implementation"> <paramname= "param1"value= "Somevalue" /> <paramname= "Param2"value= "Somevalue2" /> </Server></Config-server>
Guzz initializes the implementation class defined here, and injects the Param parameter into the implementation class JavaBean. Name is the implementation class property, and value is values. In the Configserver implementation class, the incoming parameter type of the Setxxx () method is allowed to be java.lang.String or Org.guzz.io.Resource. With Org.guzz.io.Resource, Guzz generates resource resources, such as file IO streams, based on the current directory situation, based on the configured somevalue, such as the filename of a relative path. The resource does not need to be closed when it is finished.
the injection method for the Resouce parameter in the default localfileconfigserver is:
1 Public void Setresource (Org.guzz.io.Resource R);
After all configuration injections are complete, Guzz calls Configserver startup () to start. Call the Shutdown () method to close when Guzz exits.
Configure Guzz_app.properties