package com.vci.client.omd.versionrule;
|
|
import java.awt.Dimension;
|
import java.awt.Toolkit;
|
|
import javax.swing.JFrame;
|
import javax.swing.JPanel;
|
|
import com.vci.client.omd.versionrule.itf.InterVer;
|
import com.vci.client.common.ClientLog4j;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.omd.inter.ClasspathConfig;
|
import com.vci.client.omd.versionrule.pubimpl.InterVerManager;
|
import com.vci.client.omd.versionrule.ui.VersionRulePanel;
|
import com.vci.client.ui.frame.UIConstructorInterface;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.omd.vrm.VersionRuleServicePrx;
|
|
public class VRClientStart implements UIConstructorInterface{
|
private static VersionRuleServicePrx versionRuleService = null;
|
private static VRClientStart vRClientStart = null;
|
|
private static VRClientStart getInstance(){
|
if(vRClientStart == null){
|
vRClientStart = new VRClientStart();
|
}
|
return vRClientStart;
|
}
|
|
public static void main(String[] args) {
|
try {
|
VRClientStart.getInstance().init();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
JFrame frame = new JFrame();
|
frame.setTitle("版本号管理规则");
|
// frame.setBounds(d.width/4, d.height/4, d.width/2, d.height/2);
|
frame.setSize(d.width,d.height);
|
VersionRulePanel apPanel = null;
|
try {
|
apPanel = (VersionRulePanel) VRClientStart.getInstance().start();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
frame.add(apPanel);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setVisible(true);
|
|
}
|
|
@Override
|
public void destory() throws VCIError {
|
// TODO Auto-generated method stub
|
|
}
|
|
@Override
|
public void init() throws VCIError {
|
if(versionRuleService != null){
|
return;
|
}
|
if(inject()){
|
ClientLog4j.logger.info("注入外界对版本规则中接口的实现成功");
|
}else{
|
ClientLog4j.logger.warn("注入外界对版本规则接口的实现失败");
|
}
|
try {
|
versionRuleService = ServiceProvider.getOMDService().getVerRuleService();
|
} catch (Exception e) {
|
throw new VCIError("", new String[0]);
|
}
|
}
|
|
@Override
|
public JPanel start() throws VCIError {
|
VersionRulePanel.cleanInstance();
|
VersionRulePanel apPanel = VersionRulePanel.getInstance();
|
return apPanel;
|
}
|
|
public static VersionRuleServicePrx getService(){
|
if(versionRuleService == null){
|
try {
|
VRClientStart.getInstance().init();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
return versionRuleService;
|
}
|
|
/**
|
* 注入外界对版本规则中接口的实现
|
*/
|
private boolean inject(){
|
boolean flag = false;
|
String impls = ClasspathConfig.getProperty("interVerImpl");
|
String[] implArray = impls.split(";");
|
for(int i = 0; i < implArray.length; i++){
|
InterVer interVer = null;
|
try {
|
String classpath = implArray[i];
|
if(classpath == null || classpath.equals("")){
|
continue;
|
}
|
interVer = (InterVer)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;
|
}
|
InterVerManager.getInstance().registerInter(interVer);
|
flag = true;
|
}
|
return flag;
|
}
|
|
|
}
|