public class TuzConfig
extends java.lang.Object
全局配置
所有设置都可以通过这个类去设置,tuz 中会从这个配置类中获取配置信息
Global config
This class includes all settings, and tuz will fetch setting from it
我们先以 cn.com.fishin.tuz.demo.TuzSimpleDemo2 作为切入点 先看原本的例子: //Tuz.load(new ClasspathPropertiesLoader("test.properties")); //xxxService service = DiPlugin.useInstance(xxxService.class); //service.say("Hello, Tuz!");
默认情况下,创建的对象是单例模式的 参考 cn.com.fishin.tuz.core.TuzConfig
xxxService service1 = DiPlugin.useInstance(xxxService.class); xxxService service2 = DiPlugin.useInstance(xxxService.class); System.out.println(service1 == service2); // 返回 ===> true
由于 Tuz 有一个默认的配置,里面有一个属性 获取类的实例形式,默认是 true,也就是单例模式 //private boolean singleton = true; 你可以直接设置 Tuz 中的默认配置,但是不被推荐
Tuz.getConfig().setSingleton(false);
这样获得的对象就是多例模式的
xxxService service3 = DiPlugin.useInstance(xxxService.class); xxxService service4 = DiPlugin.useInstance(xxxService.class); System.out.println(service3 == service4); // 返回 ===> false
上面说过,你可以直接设置 Tuz 中的默认配置,但是不被推荐 正确的做法是新创建一个配置对象
TuzConfig newConfig = new TuzConfig(); newConfig.setSingleton(true); // 设置为单例模式
设置配置
Tuz.setConfig(newConfig);
这样获得的对象又是单例模式啦!
xxxService service5 = DiPlugin.useInstance(xxxService.class); xxxService service6 = DiPlugin.useInstance(xxxService.class); System.out.println(service5 == service6); // 返回 ===> true
Email: fishinlove@163.com
created by 2019/03/28 22:01:35
| 构造器和说明 |
|---|
TuzConfig() |
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
getFtpControlEncoding()
获取 FTP 服务器网络通信使用的编码
Get the encoding of FTP server's net transport
|
java.lang.String |
getFtpHost()
获取 FTP 服务器主机地址
Get the host of FTP server
|
java.lang.String |
getFtpPassword()
获取 FTP 服务器登录用户密码
Get the port of FTP server login password
|
int |
getFtpPort()
获取 FTP 服务器应用端口
Get the port of FTP server application
|
java.lang.String |
getFtpUser()
获取 FTP 服务器登录用户
Get the port of FTP server login user
|
boolean |
isSingleton()
获取类的实例形式,默认是 true,也就是单例模式
Get class instance form, default is singleton
|
void |
setFtpControlEncoding(java.lang.String ftpControlEncoding)
设置 FTP 服务器网络通信使用的编码
Set the encoding of FTP server's net transport
|
void |
setFtpHost(java.lang.String ftpHost)
设置 FTP 服务器主机地址
Set the host of FTP server
|
void |
setFtpPassword(java.lang.String ftpPassword)
设置 FTP 服务器登录用户密码
Set the port of FTP server login password
|
void |
setFtpPort(int ftpPort)
设置 FTP 服务器应用端口
Set the port of FTP server application
|
void |
setFtpUser(java.lang.String ftpUser)
设置 FTP 服务器登录用户
Set the port of FTP server login user
|
void |
setSingleton(boolean singleton)
设置类的实例形式,默认是 true,也就是单例模式
Set class instance form, default is singleton
|
java.lang.String |
toString() |
public boolean isSingleton()
获取类的实例形式,默认是 true,也就是单例模式
Get class instance form, default is singleton
类的实例形式
class instance form
public void setSingleton(boolean singleton)
设置类的实例形式,默认是 true,也就是单例模式
Set class instance form, default is singleton
singleton - 类的实例形式,true 表示单例模式
class instance form, true is singleton
public java.lang.String getFtpHost()
获取 FTP 服务器主机地址
Get the host of FTP server
返回 FTP 服务器主机地址
Return the host of FTP server
public void setFtpHost(java.lang.String ftpHost)
设置 FTP 服务器主机地址
Set the host of FTP server
ftpHost - FTP 服务器主机地址
The host of FTP server
public int getFtpPort()
获取 FTP 服务器应用端口
Get the port of FTP server application
返回 FTP 服务器应用端口
Return the port of FTP server application
public void setFtpPort(int ftpPort)
设置 FTP 服务器应用端口
Set the port of FTP server application
ftpPort - FTP 服务器应用端口
The port of FTP server application
public java.lang.String getFtpUser()
获取 FTP 服务器登录用户
Get the port of FTP server login user
返回 FTP 服务器登录用户
Return the port of FTP server login user
public void setFtpUser(java.lang.String ftpUser)
设置 FTP 服务器登录用户
Set the port of FTP server login user
ftpUser - FTP 服务器登录用户
The port of FTP server login user
public java.lang.String getFtpPassword()
获取 FTP 服务器登录用户密码
Get the port of FTP server login password
返回 FTP 服务器登录用户密码
Return the port of FTP server login password
public void setFtpPassword(java.lang.String ftpPassword)
设置 FTP 服务器登录用户密码
Set the port of FTP server login password
ftpPassword - FTP 服务器登录用户密码
The port of FTP server login password
public java.lang.String getFtpControlEncoding()
获取 FTP 服务器网络通信使用的编码
Get the encoding of FTP server's net transport
返回 FTP 服务器网络通信使用的编码
Return the encoding of FTP server's net transport
FTP.setControlEncoding(String)public void setFtpControlEncoding(java.lang.String ftpControlEncoding)
设置 FTP 服务器网络通信使用的编码
Set the encoding of FTP server's net transport
ftpControlEncoding - FTP 服务器网络通信使用的编码
The encoding of FTP server's net transport
FTP.setControlEncoding(String)public java.lang.String toString()
toString 在类中 java.lang.ObjectCopyright © 2019. All Rights Reserved.