forked from hugh/demo-connection-provider
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.8 KiB
69 lines
1.8 KiB
package com.tptj.demo.hg.connection.conn; |
|
|
|
import com.fanruan.api.conf.HolderKit; |
|
import com.fanruan.api.data.open.BaseConnection; |
|
import com.fanruan.api.i18n.I18nKit; |
|
import com.fanruan.api.util.StringKit; |
|
import com.fr.config.holder.Conf; |
|
import com.fr.stable.xml.XMLPrintWriter; |
|
import com.fr.stable.xml.XMLableReader; |
|
import com.fr.third.ibm.icu.impl.Assert; |
|
import com.tptj.demo.hg.connection.store.Store; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2021-03-31 |
|
**/ |
|
public class DemoConnection extends BaseConnection { |
|
|
|
private Conf<String> key = HolderKit.simple(StringKit.EMPTY); |
|
|
|
public String getKey() { |
|
return key.get(); |
|
} |
|
|
|
public void setKey(String key) { |
|
this.key.set(key); |
|
} |
|
|
|
@Override |
|
public void testConnection() throws Exception { |
|
Assert.assrt( Store.getInstance().contains(getKey()) ); |
|
} |
|
|
|
@Override |
|
public String connectMessage(boolean status) { |
|
return I18nKit.getLocText(status?"Fine-Core_Datasource_Connection_Successfully":"Fine-Design_Database_Connection_Failed"); |
|
} |
|
|
|
@Override |
|
public String getDriver() { |
|
return null; |
|
} |
|
|
|
@Override |
|
public void readXML(XMLableReader reader) { |
|
super.readXML(reader); |
|
if (reader.isChildNode()) { |
|
String tagName = reader.getTagName(); |
|
if ("Attr".equals(tagName)) { |
|
setKey(reader.getAttrAsString("key", StringKit.EMPTY)); |
|
} |
|
} |
|
} |
|
|
|
@Override |
|
public void writeXML(XMLPrintWriter writer) { |
|
super.writeXML(writer); |
|
writer.startTAG("Attr").attr("key", getKey()).end(); |
|
} |
|
|
|
@Override |
|
public Object clone() throws CloneNotSupportedException { |
|
DemoConnection cloned = (DemoConnection) super.clone(); |
|
cloned.key = (Conf<String>) key.clone(); |
|
return cloned; |
|
} |
|
|
|
}
|
|
|