package com.vci.client.omd.enumManager.ui;
|
|
import java.awt.Dimension;
|
import java.awt.Toolkit;
|
import javax.swing.JFrame;
|
import javax.swing.JPanel;
|
|
import com.vci.client.omd.inter.ClasspathConfig;
|
import com.vci.client.common.ClientLog4j;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.omd.enumManager.toOutside.InterEM;
|
import com.vci.client.omd.enumManager.toOutside.InterEMManager;
|
import com.vci.client.ui.frame.UIConstructorInterface;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.etm.EnumServicePrx;
|
|
public class EnumClient implements UIConstructorInterface{
|
|
private static EnumServicePrx enumService = null;
|
private static EnumClient enumClient = null;
|
|
private static EnumClient getInstance(){
|
if(enumClient == null){
|
enumClient = new EnumClient();
|
}
|
return enumClient;
|
}
|
/**
|
* @throws VciException
|
* @param args
|
* @throws
|
*/
|
public static void main(String[] args) throws VCIError{
|
EnumClient.getInstance().init();
|
|
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);
|
|
EnumManagerPanel emPanel = null;
|
try {
|
emPanel = (EnumManagerPanel) new EnumClient().start();
|
} catch (VCIError e) {
|
throw new VCIError("", new String[0]);
|
}
|
frame.add(emPanel);
|
frame.setVisible(true);
|
}
|
|
@Override
|
public void destory() throws VCIError {
|
// TODO Auto-generated method stub
|
|
}
|
|
|
@Override
|
public void init() throws VCIError {
|
if(enumService != null){
|
return;
|
}
|
|
if(inject()){
|
ClientLog4j.logger.info("注入外界对枚举中接口的实现成功");
|
}else{
|
ClientLog4j.logger.info("注入外界对枚举中接口的实现失败");
|
}
|
try {
|
|
enumService = ServiceProvider.getOMDService().getEnumService();
|
} catch (Exception e) {
|
throw new VCIError("", new String[0]);
|
}
|
|
}
|
|
|
@Override
|
public JPanel start() throws VCIError {
|
EnumManagerPanel.cleanInstance();
|
EnumManagerPanel emPanel = EnumManagerPanel.getInstance();
|
return emPanel;
|
}
|
|
public static EnumServicePrx getService() throws VCIError{
|
if(enumService == null){
|
try {
|
EnumClient.getInstance().init();
|
} catch (VCIError e) {
|
throw new VCIError("", new String[0]);
|
}
|
}
|
return enumService;
|
}
|
|
/**
|
* 外界注入枚举接口的实现
|
*/
|
private boolean inject(){
|
boolean flag = false;
|
String impls = ClasspathConfig.getProperty("interEMImpl");
|
String[] implArray = impls.split(";");
|
for(int i = 0; i < implArray.length; i++){
|
InterEM interEM = null;
|
try {
|
String classpath = implArray[i];
|
if(classpath == null || classpath.equals("")){
|
continue;
|
}
|
interEM = (InterEM) 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;
|
}
|
InterEMManager.getInstance().registerInter(interEM);
|
flag = true;
|
}
|
return flag;
|
}
|
}
|