Changes
parent
7859e79739
commit
d4d2741e39
|
@ -69,7 +69,7 @@ public class RuleEditionController {
|
|||
//java OSS
|
||||
UploadOss.uploadFiles(ruleEdition.getRuleEngine(), ruleEdition.getRuleKind());
|
||||
|
||||
OSSFileDownload.streamingDownload(ruleEdition.getRuleKind());
|
||||
OSSFileDownload.compile(ruleEdition.getRuleKind());
|
||||
|
||||
//对路径里的.java文件进行编译
|
||||
SourceCodeCompiler.javaCompilerPath("/home");
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.aliyun.oss.model.GetObjectRequest;
|
|||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.ToolProvider;
|
||||
import java.io.File;
|
||||
|
||||
public class OSSFileDownload {
|
||||
|
@ -21,28 +23,43 @@ public class OSSFileDownload {
|
|||
private static final String filePath = "oss/";
|
||||
|
||||
|
||||
public static Result<Object> streamingDownload(String fileName) {
|
||||
// public static Result<Object> streamingDownload(String fileName) {
|
||||
//
|
||||
// String source = null;
|
||||
// // 创建 OSSClient 实例
|
||||
// OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
// // 判断 bucket 是否存在
|
||||
// Boolean flag_bucket = ossClient.doesBucketExist(bucketName);
|
||||
// if (!flag_bucket) {
|
||||
// System.out.println("bucket不存在");
|
||||
// return Result.error("bucket不存在");
|
||||
// }
|
||||
// String objectName = fileName + ".java";
|
||||
// Boolean flag_file = ossClient.doesObjectExist(bucketName, filePath + objectName);
|
||||
// if (!flag_file) {
|
||||
// System.out.println("预下载文件不存在");
|
||||
// return Result.error("预下载文件不存在");
|
||||
// }
|
||||
// // 本地文件下载路径
|
||||
// String localPath = "home/" + objectName;
|
||||
// ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + objectName), new File(localPath));
|
||||
// System.out.println(object);
|
||||
// ossClient.shutdown();
|
||||
// return Result.success(source);
|
||||
// }
|
||||
|
||||
String source = null;
|
||||
// 创建 OSSClient 实例
|
||||
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
// 判断 bucket 是否存在
|
||||
Boolean flag_bucket = ossClient.doesBucketExist(bucketName);
|
||||
if (!flag_bucket) {
|
||||
System.out.println("bucket不存在");
|
||||
return Result.error("bucket不存在");
|
||||
public static Result<Object> compile(String fileName) {
|
||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
String[] strings = {"-classpath", "/home/lib", "-verbose", "-d", "/home/lib", fileName};
|
||||
//编译任务
|
||||
int result = compiler.run(null, null, null, strings);
|
||||
//检查编译结果
|
||||
if (result == 0) {
|
||||
System.out.println("编译成功,生成的.class文件位于源代码同目录");
|
||||
} else {
|
||||
System.out.println("编译失败");
|
||||
}
|
||||
String objectName = fileName + ".java";
|
||||
Boolean flag_file = ossClient.doesObjectExist(bucketName, filePath + objectName);
|
||||
if (!flag_file) {
|
||||
System.out.println("预下载文件不存在");
|
||||
return Result.error("预下载文件不存在");
|
||||
}
|
||||
// 本地文件下载路径
|
||||
String localPath = "home/" + objectName;
|
||||
ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + objectName), new File(localPath));
|
||||
System.out.println(object);
|
||||
ossClient.shutdown();
|
||||
return Result.success(source);
|
||||
String externalClassFilePath = "/home";
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue