package com.vci.client.omd.attribpool.ui;
|
|
import java.awt.Dimension;
|
import java.awt.Toolkit;
|
import javax.swing.JFrame;
|
import javax.swing.JPanel;
|
|
import com.vci.client.omd.attribpool.toOutside.InterAP;
|
import com.vci.client.omd.attribpool.toOutside.InterAPManager;
|
import com.vci.client.omd.inter.ClasspathConfig;
|
import com.vci.client.ui.frame.UIConstructorInterface;
|
import com.vci.client.common.ClientLog4j;
|
import com.vci.client.common.datatype.VTBoolean;
|
import com.vci.client.common.datatype.VTDouble;
|
import com.vci.client.common.datatype.VTString;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.atm.AttPoolServicePrx;
|
|
public class APClient implements UIConstructorInterface{
|
|
private static AttPoolServicePrx apService = null;
|
private static APClient apClient = null;
|
|
private static APClient getInstance(){
|
if(apClient == null){
|
apClient = new APClient();
|
}
|
return apClient;
|
}
|
|
/**
|
* @param args
|
*/
|
public static void main(String[] args) {
|
try {
|
getInstance().init();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
setVTTypeDef();
|
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
|
JFrame frame = new JFrame();
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setTitle("属性池");
|
frame.setBounds(d.width/4, d.height/4, d.width/2, d.height/2);
|
|
AttribPoolPanel apPanel = null;
|
|
try {
|
apPanel = (AttribPoolPanel)getInstance().start();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
frame.add(apPanel);
|
frame.setVisible(true);
|
}
|
|
/**
|
* 设置VTType的默认值
|
*/
|
public static void setVTTypeDef(){
|
VTString.lenInMode = Integer.valueOf(VTTypeDefConfig.getProperty("VTString.lenInMode"));
|
VTString.lenDefault = Integer.valueOf(VTTypeDefConfig.getProperty("VTString.lenDefault"));
|
VTString.lenMax = Integer.valueOf(VTTypeDefConfig.getProperty("VTString.lenMax"));
|
|
VTDouble.accInMode = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.accInMode"));
|
VTDouble.accDefault = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.accDefault"));
|
VTDouble.accMax = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.accMax"));
|
VTDouble.lenInMode = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.lenInMode"));
|
VTDouble.lenDefault = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.lenDefault"));
|
VTDouble.lenMax = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.lenMax"));
|
VTDouble.defVInMode = Integer.valueOf(VTTypeDefConfig.getProperty("VTDouble.defVInMode"));
|
VTDouble.defaultValue = Double.valueOf(VTTypeDefConfig.getProperty("VTDouble.defaultValue"));
|
|
VTBoolean.defVInMode = Integer.valueOf(VTTypeDefConfig.getProperty("VTBoolean.defVInMode"));
|
VTBoolean.defaultValue = Boolean.valueOf(VTTypeDefConfig.getProperty("VTBoolean.defaultValue"));
|
}
|
|
@Override
|
public void destory() throws VCIError {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void init() throws VCIError {
|
if(apService != null){
|
return;
|
}
|
if(inject()){
|
ClientLog4j.logger.info("注入外界对属性池中接口的实现成功");
|
}else{
|
ClientLog4j.logger.info("注入外界对属性池中接口的实现失败");
|
}
|
try {
|
apService = ServiceProvider.getOMDService().getAttributeService();
|
} catch (Exception e) {
|
throw new VCIError("", new String[0]);
|
}
|
}
|
|
@Override
|
public JPanel start() throws VCIError {
|
setVTTypeDef();
|
AttribPoolPanel.cleanInstance();
|
AttribPoolPanel apPanel = AttribPoolPanel.getInstance();
|
return apPanel;
|
}
|
|
public static AttPoolServicePrx getService(){
|
if(apService == null){
|
try {
|
APClient.getInstance().init();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
return apService;
|
}
|
|
/**
|
* 注入外界对属性池中接口的实现
|
*/
|
private boolean inject(){
|
boolean flag = false;
|
String impls = ClasspathConfig.getProperty("interAPImpl");
|
String[] implArray = impls.split(";");
|
for(int i = 0; i < implArray.length; i++){
|
InterAP interAP = null;
|
try {
|
String classpath = implArray[i];
|
if(classpath == null || classpath.equals("")){
|
continue;
|
}
|
interAP = (InterAP)Class.forName(classpath).newInstance();
|
} catch (InstantiationException e) {
|
e.printStackTrace();
|
return flag;
|
} catch (IllegalAccessException e) {
|
e.printStackTrace();
|
return flag;
|
} catch (ClassNotFoundException e) {
|
e.printStackTrace();
|
return flag;
|
}
|
InterAPManager.getInstance().registerInter(interAP);
|
flag = true;
|
}
|
return flag;
|
}
|
}
|