forked from fanruan/demo-tabledata-redis
zjz1993
5 years ago
44 changed files with 261 additions and 382 deletions
@ -1,99 +0,0 @@
|
||||
package com.fr.plugin.db.redis.conf; |
||||
|
||||
import com.fanruan.api.xml.XmlKit; |
||||
import com.fanruan.api.xml.comopnent.XMLFileManager; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.stable.EnvChangedListener; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLTools; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* Created by richie on 2017/6/5. |
||||
*/ |
||||
public class ShellConfigManager extends XMLFileManager implements ShellConfigManagerProvider { |
||||
|
||||
private static final String XML_TAG = "ShellConfigManager"; |
||||
|
||||
private static ShellConfigManagerProvider shellManager = null; |
||||
|
||||
|
||||
public synchronized static ShellConfigManager getInstance() { |
||||
return (ShellConfigManager) getProviderInstance(); |
||||
} |
||||
|
||||
public synchronized static ShellConfigManagerProvider getProviderInstance() { |
||||
if (shellManager == null) { |
||||
if (isClusterMember()) { |
||||
return shellManager; |
||||
} |
||||
shellManager.readXMLFile(); |
||||
} |
||||
return shellManager; |
||||
} |
||||
|
||||
private synchronized static boolean isClusterMember() { |
||||
|
||||
return false; |
||||
} |
||||
|
||||
static { |
||||
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
||||
public void envChanged() { |
||||
ShellConfigManager.envChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private synchronized static void envChanged() { |
||||
shellManager = null; |
||||
} |
||||
|
||||
private String shellText; |
||||
|
||||
@Override |
||||
public String getShellText() { |
||||
return shellText; |
||||
} |
||||
|
||||
public void setShellText(String shellText) { |
||||
this.shellText = shellText; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isAttr()) { |
||||
shellText = reader.getAttrAsString("shell", StringKit.EMPTY); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG(XML_TAG); |
||||
writer.attr("shell", shellText); |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public String fileName() { |
||||
return "redis.xml"; |
||||
} |
||||
|
||||
@Override |
||||
public void readFromInputStream(InputStream input) throws Exception { |
||||
// 服务器端新建一个对象
|
||||
ShellConfigManager manager = new ShellConfigManager(); |
||||
// 从客户端传过来的inputstream中读取对象属性
|
||||
XMLTools.readInputStreamXML(manager, input); |
||||
// 赋值给当前服务器端对象
|
||||
shellManager = manager; |
||||
} |
||||
|
||||
|
||||
public Object clone() throws CloneNotSupportedException { |
||||
return super.clone(); |
||||
} |
||||
} |
@ -1,12 +0,0 @@
|
||||
package com.fr.plugin.db.redis.conf; |
||||
|
||||
import com.fr.stable.FCloneable; |
||||
import com.fr.stable.file.RemoteXMLFileManagerProvider; |
||||
|
||||
/** |
||||
* Created by richie on 2017/6/5. |
||||
*/ |
||||
public interface ShellConfigManagerProvider extends RemoteXMLFileManagerProvider, java.io.Serializable, FCloneable { |
||||
|
||||
String getShellText(); |
||||
} |
Loading…
Reference in new issue