diff --git a/Common/src/common/Config.java b/Common/src/common/Config.java index 815e775..66a1900 100644 --- a/Common/src/common/Config.java +++ b/Common/src/common/Config.java @@ -113,24 +113,54 @@ public class Config { } - public static String getCompilerDir(String language) { + public static String getCompilerDir(String language,String compiler) { String dir = null; + //todo if (language.equals("c") || language.equals("cpp") || language.equals("c++")) { - dir = prop.getProperty(Const.MinGWDir); + dir=LangSelector.getCompilerPath("C++", compiler); + //dir = prop.getProperty(Const.MinGWDir); } else if (language.equals("java")) { - dir = prop.getProperty(Const.JavaCompilerDir); + dir=LangSelector.getCompilerPath("Java", compiler); + //dir = prop.getProperty(Const.JavaCompilerDir); } return dir; } - public static String CompilerDir(String language) { + public static String getCompilerDir(String language) { + String dir = null; + //todo + if (language.equals("c") || language.equals("cpp") || language.equals("c++")) { + dir=LangSelector.getCompilerPath("C++", null); + //dir = prop.getProperty(Const.MinGWDir); + } else if (language.equals("java")) { + dir=LangSelector.getCompilerPath("Java", null); + //dir = prop.getProperty(Const.JavaCompilerDir); + } + return dir; + } + public static String CompilerDir(String language,String compiler) { String dir = null; if (language.equals("c") || language.equals("cpp") || language.equals("c++")) //返回各种语言的编译器地址 { - dir = System.getProperty("user.dir") + Const.MinGWDir; + //dir = System.getProperty("user.dir") + Const.MinGWDir; + dir=LangSelector.getCompilerPath("C++",compiler); } else if (language.equals("java")) { - dir = System.getProperty("user.dir") + Const.JavaCompilerDir; + //dir = System.getProperty("user.dir") + Const.JavaCompilerDir; + dir=LangSelector.getCompilerPath("Java",compiler); + } + return dir; + } + public static String CompilerDir(String language) { + String dir = null; + + if (language.equals("c") || language.equals("cpp") || language.equals("c++")) //返回各种语言的编译器地址 + { + //dir = System.getProperty("user.dir") + Const.MinGWDir; + dir=LangSelector.getCompilerPath("C++",null); + } else if (language.equals("java")) { + //dir = System.getProperty("user.dir") + Const.JavaCompilerDir; + dir=LangSelector.getCompilerPath("Java",null); } return dir; } diff --git a/Common/src/common/LangSelector.java b/Common/src/common/LangSelector.java index efbe4cb..8f0f417 100644 --- a/Common/src/common/LangSelector.java +++ b/Common/src/common/LangSelector.java @@ -1,15 +1,22 @@ package common; import java.io.File; +import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @@ -90,7 +97,24 @@ public abstract class LangSelector { Data=doc; return doc; } + public static List getCompilerNames(String languageName){ + ArrayListarrayListStr=new ArrayList<>(); + try { + String exp="/languages/language"+ "[@id='" +languageName+ "']"+"//compiler"; + NodeList nodeList = (NodeList) xpath.evaluate(exp,Data,XPathConstants.NODESET); + + for (int i = 0; i < nodeList.getLength(); i++) { + Node childNode = nodeList.item(i); + arrayListStr.add(childNode.getAttributes().getNamedItem("name").getTextContent()); + // 如果需要获取属性值,可以使用 childNode.getAttributes().getNamedItem("attributeName").getTextContent() + } + return arrayListStr; + } catch (XPathExpressionException ex) { + Logger.getLogger(LangSelector.class.getName()).log(Level.SEVERE, null, ex); + return arrayListStr; + } + } public static String getCompilerPath(String languageName,String compilerName) { if(compilerName==null)compilerName=getDefaultCompilerName(languageName); diff --git a/JuderUI/src/edu/dhu/ws/OJWS.java b/JuderUI/src/edu/dhu/ws/OJWS.java new file mode 100644 index 0000000..b20b4dc --- /dev/null +++ b/JuderUI/src/edu/dhu/ws/OJWS.java @@ -0,0 +1,82 @@ +package edu.dhu.ws; + +public interface OJWS { + + // + public String test(String message); + // ½˵Ϣתxmlʽ + public String wsLogin(String userName, String userPassword); + + // бתxmlʽ + public String wsGetExamList(String userName, String password); + + // ͨIdбתxmlʽ + public String wsGetExamById(String userName, String password, int examId); + + // problemIdproblemsproblemtestcasesϢתxmlʽ + public byte[] wsGetProblem(String userName, String password,int examId, int problemId); + + // examIdexamProblemsϢתxmlʽ + public String wsGetExamProblems(String userName, String password, + int examId, int page, int rows); + + // û룬examIdȡexamdetailϢתxmlʽ + public String wsGetExamDetail(String userName, String password, int examId, int page, int rows); + + // ûύĴWrongCases,Solution,Problems,StudentExamDetailϢ,solutionId + public String wsSubmitCode(String userName, String password, String codeXml); + + // ύ + public String wsSubmitThisProblem(String userName, String password, + String codeXml); + + // ȡsubmittedcodeϢƶ + public String wsSubmittedCode(String userName, String password, + int problemId); + + // 鿴,ȡwrongcasesϢ + public String wsViewWrongCase(String userName, String password, + int examId, int problemId, int caseId, boolean caseInfo); + + // ȡ״̬ + public String wsGetExamProblemStatus(String userName, String password, + int examId, int problemId); + + // лȡsolutionϢ + public String wsGetSolutions(String account,String password,int number); + + // ²к󷵻صĽ + public String wsUpdateResult(String userName, String password,byte[] result); + + // Ƿ + public String wsIsPermit(String userName, String password, int examId, + String UUID); + + // лȡĿϢ + public byte[] wsGetProblem4Judge(String userName, String password, int problemId); + + + // examIdȡѵĿ + public String wsGetExamProCatagorys(String userName,String password,int examId); + + //ѵҳ"ʼ" + public String wsCanDoCategory(String userName, String password, int examId); + + //ѵҳ"Ҫ" + public byte[] wsDrawProblem(String userName, String password, int examId,int catId); + + //ѵģ¼ҳ + public String wsSubmitHistory(String userName, String password, int examId); + + //ѵģ"ύ" + public String wsItrainSubmitCode(String userName, String password,int catId,String codeXml); + + //ѵģ"ʱ" + public String wsSkipThisProblem(String userName, String password, int examId,int catId,int problemId); + + //ѵģ"ύ" + public String wsItrainSubmitThisProblem(String userName, String password,int catId,String codeXml,String continueTrain); + + //ѵģ"Ҫͨ" + public String wsPassThisCategory(String userName, String password, int examId,int catId); +} diff --git a/JuderUI/src/gui/MainFrame.form b/JuderUI/src/gui/MainFrame.form index 67a3fc3..9603eea 100644 --- a/JuderUI/src/gui/MainFrame.form +++ b/JuderUI/src/gui/MainFrame.form @@ -27,7 +27,10 @@ - + + + + @@ -43,9 +46,8 @@ - - + @@ -73,55 +75,60 @@ - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + @@ -131,15 +138,17 @@ - - - - + + + + + + @@ -181,18 +190,6 @@ - - - - - - - - - - - - @@ -508,18 +505,6 @@ - - - - - - - - - - - - @@ -531,6 +516,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JuderUI/src/gui/MainFrame.java b/JuderUI/src/gui/MainFrame.java index cf10850..f605400 100644 --- a/JuderUI/src/gui/MainFrame.java +++ b/JuderUI/src/gui/MainFrame.java @@ -15,11 +15,13 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.xml.namespace.QName; import share.gui.NewCompileSetting; +import web.Dubboservice; /** * @@ -65,6 +67,17 @@ public class MainFrame extends javax.swing.JFrame { } } }); + comboCppCompiler.removeAllItems(); + comboJavaCompiler.removeAllItems(); + List cppCompilers=LangSelector.getCompilerNames("C++"); + for(int i=0;i javaCompilers=LangSelector.getCompilerNames("Java"); + for(int i=0;i jComboBox1; + private javax.swing.JLabel jLabel10; javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; @@ -609,6 +614,7 @@ public class MainFrame extends javax.swing.JFrame { private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; diff --git a/JuderUI/src/web/Dubboservice.java b/JuderUI/src/web/Dubboservice.java new file mode 100644 index 0000000..c80ff96 --- /dev/null +++ b/JuderUI/src/web/Dubboservice.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package web; + +/** + * + * @author tange + */ +import org.apache.dubbo.config.spring.context.annotation.DubboComponentScan; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableDubbo // ɨڰӰеDubboService +@DubboComponentScan(basePackages = {"web"}) +public class Dubboservice { + public static boolean running=false; + public static void main(String[] args) { + SpringApplication.run(Dubboservice.class, args); + } + +} diff --git a/JuderUI/src/web/Webservice.java b/JuderUI/src/web/Webservice.java index ccd91f1..b825334 100644 --- a/JuderUI/src/web/Webservice.java +++ b/JuderUI/src/web/Webservice.java @@ -5,42 +5,95 @@ */ package web; +import com.alibaba.dubbo.config.ApplicationConfig; +import com.alibaba.dubbo.config.ReferenceConfig; +import com.alibaba.dubbo.config.RegistryConfig; import util.Decrypt; import edu.dhu.ws.OJWS; import edu.dhu.ws.OJWS_Service; -import java.io.UnsupportedEncodingException; import java.net.URL; +import javax.annotation.Resource; import javax.xml.namespace.QName; - +import org.apache.dubbo.config.annotation.DubboReference; +import org.apache.dubbo.config.annotation.DubboService; /** * * @author ytxlo */ -public class Webservice { +@DubboService +public class Webservice implements java.rmi.Remote{ private OJWS_Service webs; private OJWS servicePort; + //@DubboReference(url = "http://106.15.36.190:3000/edu.dhu.ws.OJWS") + //http://106.15.36.190:3000/edu.dhu.ws.OJWS + //dubbo://219.228.76.122:80/edu.dhu.ws.OJWS + //https://219.228.76.122:80/edu.dhu.ws.OJWS + //dubbo://10.10.10.1:20880/edu.dhu.ws.OJWS + + //@DubboReference(url = "dubbo://10.10.10.1:20880/edu.dhu.ws.OJWS") + //@Resource + public OJWS dubboPort; + public static OJWS initDubboPort(String url) { + // Ӧ + ApplicationConfig application = new ApplicationConfig(); + application.setName("consumer"); + + // Զ̷ + ReferenceConfig reference = new ReferenceConfig<>(); + reference.setApplication(application); + reference.setInterface(OJWS.class); + reference.setUrl(url); // Զ̷ URL + + // ʼ + return reference.get(); + } + + public Webservice(){ webs = new OJWS_Service(); - servicePort = webs.getOJWSImplPort(); + try{ + servicePort = webs.getOJWSImplPort(); + + } + catch(Exception e){} + try + { + String url = "dubbo://192.168.0.101:20880/edu.dhu.ws.OJWS";//todo:ҪijûԼ + dubboPort = initDubboPort(url); + } + catch(Exception e){ + e.printStackTrace(); + } + if(dubboPort!=null){ + + servicePort=dubboPort; + } + + //ʹdubboʹãܵĻԭ + } - public Webservice(URL url,QName qname){ + public Webservice(URL url,QName qname)throws java.rmi.RemoteException{ webs = new OJWS_Service(url,qname); servicePort = webs.getOJWSImplPort(); } - public String getSolutions(int arg0){ + public String getSolutions(int arg0)throws java.rmi.RemoteException{ String s =this.servicePort.wsGetSolutions("judge","judge123",arg0); return s; } - public String getProblem(int arg){ + public String getProblem(int arg)throws java.rmi.RemoteException{ // servicePort.wsGetProblem(arg0, arg1, arg, arg) byte[] soucre = this.servicePort.wsGetProblem4Judge("felix", "felix", arg); String result = Decrypt.decrypt("felix10000", soucre); //String prob = result.replaceFirst("GBK", "UTF-8"); return result; } - public String updateResult(String arg){ + public String updateResult(String arg)throws java.rmi.RemoteException{ byte[] data=Decrypt.encrypt("judge123", arg); String s = servicePort.wsUpdateResult("judge","judge123",data); return s; } + public static void main(String[] args) { + Webservice ws=new Webservice(); + System.out.println(ws.dubboPort.test("a")); + } } diff --git a/Judger/src/kernel/Judger.java b/Judger/src/kernel/Judger.java index 23be52d..2006dab 100644 --- a/Judger/src/kernel/Judger.java +++ b/Judger/src/kernel/Judger.java @@ -58,8 +58,8 @@ public class Judger { public Boolean checkForCompiler(){ - File file1 = new File(Config.getCompilerDir("c") + File.separator + "gcc.exe"); - File file2 = new File(Config.getCompilerDir("c") + File.separator + "gcc.exe"); + File file1 = new File(Config.getCompilerDir("c",null) + File.separator + "gcc.exe"); + File file2 = new File(Config.getCompilerDir("c",null) + File.separator + "gcc.exe"); if (!file1.exists() || !file2.exists()) { System.out.println("δҵ"); isFound = false;