dubbo逻辑完成(不含依赖项)

This commit is contained in:
Jered Ye 2024-02-19 13:21:34 +08:00
parent cc990900f2
commit 755e238e6f
8 changed files with 419 additions and 179 deletions

View File

@ -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 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=LangSelector.getCompilerPath("C++",compiler);
} else if (language.equals("java")) {
//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 = System.getProperty("user.dir") + Const.MinGWDir;
dir=LangSelector.getCompilerPath("C++",null);
} else if (language.equals("java")) {
dir = System.getProperty("user.dir") + Const.JavaCompilerDir;
//dir = System.getProperty("user.dir") + Const.JavaCompilerDir;
dir=LangSelector.getCompilerPath("Java",null);
}
return dir;
}

View File

@ -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<String> getCompilerNames(String languageName){
ArrayList<String>arrayListStr=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);

View File

@ -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);
// 根据problemId查出problems和problemtestcases的相关信息转换成xml格式
public byte[] wsGetProblem(String userName, String password,int examId, int problemId);
// 根据examId查出examProblems的相关信息转换成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);
}

View File

@ -27,7 +27,10 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="10" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -43,9 +46,8 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jTabbedPane1" min="-2" pref="958" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jTabbedPane1" min="-2" pref="958" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -73,24 +75,30 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSeparator2" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="buttonCompilersConfig" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonCompilersConfig1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboCppCompiler" min="-2" pref="110" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="comboJavaCompiler" min="-2" pref="110" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="distributorIP" min="-2" pref="211" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="distributorIP" min="-2" pref="173" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="distributorPort" min="-2" pref="211" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="207" max="-2" attributes="0"/>
<Component id="distributorPort" min="-2" pref="166" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="button_Start" min="-2" max="-2" attributes="0"/>
@ -104,24 +112,23 @@
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="156" max="-2" attributes="0"/>
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="jComboBox1" min="-2" pref="32" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="button_StartThread" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="87" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="threadManagerTabb" min="-2" pref="955" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
<Component id="jSeparator1" max="32767" attributes="0"/>
<Component id="jSeparator1" pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -131,15 +138,17 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonCompilersConfig" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="distributorIP" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCompilersConfig1" alignment="1" max="32767" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboCppCompiler" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboJavaCompiler" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="distributorPort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="distributorIP" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
@ -181,18 +190,6 @@
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator2">
</Component>
<Component class="javax.swing.JButton" name="buttonCompilersConfig">
<Properties>
<Property name="text" type="java.lang.String" value="C/C++&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfigActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="buttonStop">
<Properties>
<Property name="text" type="java.lang.String" value="&#x505c;&#x6b62;"/>
@ -508,18 +505,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCompilersConfig1">
<Properties>
<Property name="text" type="java.lang.String" value="JAVA&#x7f16;&#x8bd1;&#x5668;&#x914d;&#x7f6e;"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCompilersConfig1ActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Properties>
<Property name="text" type="java.lang.String" value="&#x7f16;&#x8f91;&#x914d;&#x7f6e;&#x6587;&#x4ef6;"/>
@ -531,6 +516,40 @@
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="C/C++&#x7f16;&#x8bd1;&#x5668;:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboCppCompiler">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="text" type="java.lang.String" value="Java&#x7f16;&#x8bd1;&#x5668;:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboJavaCompiler">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@ -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<String> cppCompilers=LangSelector.getCompilerNames("C++");
for(int i=0;i<cppCompilers.size();++i){
comboCppCompiler.addItem(cppCompilers.get(i));
}
List<String> javaCompilers=LangSelector.getCompilerNames("Java");
for(int i=0;i<javaCompilers.size();++i){
comboJavaCompiler.addItem(javaCompilers.get(i));
}
}
/**
@ -83,7 +96,6 @@ public class MainFrame extends javax.swing.JFrame {
button_Start = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
buttonCompilersConfig = new javax.swing.JButton();
buttonStop = new javax.swing.JButton();
distributorIP = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
@ -113,8 +125,11 @@ public class MainFrame extends javax.swing.JFrame {
jCheckBox1 = new javax.swing.JCheckBox();
jLabel17 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
buttonCompilersConfig1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
comboCppCompiler = new javax.swing.JComboBox();
jLabel10 = new javax.swing.JLabel();
comboJavaCompiler = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -125,14 +140,6 @@ public class MainFrame extends javax.swing.JFrame {
}
});
buttonCompilersConfig.setText("C/C++编译器配置");
buttonCompilersConfig.setEnabled(false);
buttonCompilersConfig.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCompilersConfigActionPerformed(evt);
}
});
buttonStop.setText("停止");
buttonStop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -267,14 +274,6 @@ public class MainFrame extends javax.swing.JFrame {
}
});
buttonCompilersConfig1.setText("JAVA编译器配置");
buttonCompilersConfig1.setEnabled(false);
buttonCompilersConfig1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCompilersConfig1ActionPerformed(evt);
}
});
jButton2.setText("编辑配置文件");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -282,29 +281,43 @@ public class MainFrame extends javax.swing.JFrame {
}
});
jLabel8.setText("C/C++±àÒëÆ÷:");
comboCppCompiler.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel10.setText("Java±àÒëÆ÷:");
comboJavaCompiler.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator2)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(buttonCompilersConfig)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonCompilersConfig1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(9, 9, 9)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(207, 207, 207))
.addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(20, 20, 20))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(button_Start)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -317,21 +330,19 @@ public class MainFrame extends javax.swing.JFrame {
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(156, 156, 156)
.addComponent(jLabel17)
.addGap(18, 18, 18)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addComponent(button_StartThread)
.addGap(18, 18, 18)
.addComponent(jLabel17)
.addGap(87, 87, 87))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button_StartThread))))
.addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(49, 49, 49)
.addComponent(jSeparator1))
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -339,14 +350,16 @@ public class MainFrame extends javax.swing.JFrame {
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonCompilersConfig)
.addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jButton2)
.addComponent(buttonCompilersConfig1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel8)
.addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
@ -380,9 +393,8 @@ public class MainFrame extends javax.swing.JFrame {
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 958, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 958, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -393,7 +405,9 @@ public class MainFrame extends javax.swing.JFrame {
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 10, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -413,13 +427,6 @@ public class MainFrame extends javax.swing.JFrame {
}
}//GEN-LAST:event_buttonStopActionPerformed
private void buttonCompilersConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfigActionPerformed
JOptionPane.showMessageDialog(this, "请直接在配置文件中修改!");
// NewCompileSetting cConfig = new NewCompileSetting("c", this, true);
// cConfig.setVisible(true);
// Config.freshConfig();
}//GEN-LAST:event_buttonCompilersConfigActionPerformed
private void button_StartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_StartActionPerformed
try {
LangSelector.init();
@ -442,6 +449,10 @@ public class MainFrame extends javax.swing.JFrame {
this.button_Start.setEnabled(false);
this.buttonStop.setEnabled(true);
this.button_StartThread.setEnabled(true);
// if(!Dubboservice.running){
// Dubboservice.main(null);
// Dubboservice.running=true;
// }
//this.jLabel14.setText("正在运行");
}
}//GEN-LAST:event_button_StartActionPerformed
@ -459,7 +470,7 @@ public class MainFrame extends javax.swing.JFrame {
}//GEN-LAST:event_jLabel17MouseClicked
private boolean checkForCompile() {
String tmp = null;
tmp = Config.getCompilerDir("c");
tmp = Config.getCompilerDir("c",comboCppCompiler.getSelectedItem().toString());
if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "gcc.exe") || !FileFinder.isExistFile(tmp + File.separator + "g++.exe")) {
//弹窗设置保存
@ -469,7 +480,7 @@ public class MainFrame extends javax.swing.JFrame {
return false;
}
tmp = Config.getCompilerDir("java");
tmp = Config.getCompilerDir("java",comboJavaCompiler.getSelectedItem().toString());
if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "javac.exe")) {
JOptionPane.showMessageDialog(this, "请先配置Java编译器");
@ -494,13 +505,6 @@ public class MainFrame extends javax.swing.JFrame {
}//GEN-LAST:event_jButton1ActionPerformed
private void buttonCompilersConfig1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCompilersConfig1ActionPerformed
// TODO add your handling code here:
JOptionPane.showMessageDialog(this, "请直接在配置文件中修改!");
// NewCompileSetting javaConfig = new NewCompileSetting("java", this, true);
// javaConfig.setVisible(true);
}//GEN-LAST:event_buttonCompilersConfig1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
Desktop desktop = Desktop.getDesktop();
@ -587,18 +591,19 @@ public class MainFrame extends javax.swing.JFrame {
// Variables declaration - do not modify//GEN-BEGIN:variables
javax.swing.JButton buttonCompilersConfig;
javax.swing.JButton buttonCompilersConfig1;
private javax.swing.ButtonGroup buttonGroup1;
javax.swing.JButton buttonStop;
private javax.swing.JButton button_Start;
javax.swing.JButton button_StartThread;
private javax.swing.JComboBox comboCppCompiler;
private javax.swing.JComboBox comboJavaCompiler;
private javax.swing.JTextField distributorIP;
private javax.swing.JTextField distributorPort;
private javax.swing.JButton jButton1;
javax.swing.JButton jButton2;
private javax.swing.JCheckBox jCheckBox1;
javax.swing.JComboBox<String> 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;

View File

@ -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);
}
}

View File

@ -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<OJWS> reference = new ReferenceConfig<>();
reference.setApplication(application);
reference.setInterface(OJWS.class);
reference.setUrl(url); // 设置远程服务的 URL
// 初始化
return reference.get();
}
public Webservice(){
webs = new OJWS_Service();
try{
servicePort = webs.getOJWSImplPort();
}
public Webservice(URL url,QName qname){
catch(Exception e){}
try
{
String url = "dubbo://192.168.0.101:20880/edu.dhu.ws.OJWS";//todo:需要改成用户自己输入
dubboPort = initDubboPort(url);
}
catch(Exception e){
e.printStackTrace();
}
if(dubboPort!=null){
servicePort=dubboPort;
}
//如果能使用dubbo服务就使用不能的话就用原来的
}
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"));
}
}

View File

@ -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;