源代码备份

This commit is contained in:
TC999
2024-08-20 16:54:35 +08:00
parent c4db18da39
commit e2a5f92e23
791 changed files with 90314 additions and 2 deletions

1
AriaCompiler/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,13 @@
apply plugin: 'com.novoda.bintray-release'
publish {
// artifactId = 'aria-compiler'
// uploadName = 'AriaCompiler'
artifactId = 'compiler'
uploadName = 'Compiler'
userOrg = rootProject.ext.userOrg
groupId = rootProject.ext.groupId
publishVersion = rootProject.ext.publishVersion
desc = rootProject.ext.desc
website = rootProject.ext.website
licences = rootProject.ext.licences
}

22
AriaCompiler/build.gradle Normal file
View File

@ -0,0 +1,22 @@
apply plugin: 'java'
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.auto:auto-common:0.10'
implementation 'com.google.auto.service:auto-service:1.0-rc6'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc6'
implementation 'com.squareup:javapoet:1.9.0'
implementation project(':AriaAnnotations')
}
//apply from: 'bintray-release.gradle'
ext{
PUBLISH_ARTIFACT_ID = 'compiler'
}
apply from: '../gradle/mavenCentral-release.gradle'

View File

@ -0,0 +1,111 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.annotations.M3U8;
import com.arialyy.annotations.Upload;
import com.google.auto.service.AutoService;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
/**
* Created by lyy on 2017/6/6.
* 事件注解扫描器
*/
@AutoService(Processor.class) public class AriaProcessor extends AbstractProcessor {
ElementHandler mHandler;
@Override public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
PrintLog.init(processingEnv.getMessager());
mHandler = new ElementHandler(processingEnv.getFiler(), processingEnv.getElementUtils());
}
@Override public Set<String> getSupportedAnnotationTypes() {
Set<String> annotataions = new LinkedHashSet<>();
//单任务下载的注解
annotataions.add(Download.onWait.class.getCanonicalName());
annotataions.add(Download.onPre.class.getCanonicalName());
annotataions.add(Download.onNoSupportBreakPoint.class.getCanonicalName());
annotataions.add(Download.onTaskCancel.class.getCanonicalName());
annotataions.add(Download.onTaskComplete.class.getCanonicalName());
annotataions.add(Download.onTaskFail.class.getCanonicalName());
annotataions.add(Download.onTaskPre.class.getCanonicalName());
annotataions.add(Download.onTaskResume.class.getCanonicalName());
annotataions.add(Download.onTaskRunning.class.getCanonicalName());
annotataions.add(Download.onTaskStart.class.getCanonicalName());
annotataions.add(Download.onTaskStop.class.getCanonicalName());
//下载任务组的注解
annotataions.add(DownloadGroup.onWait.class.getCanonicalName());
annotataions.add(DownloadGroup.onPre.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskCancel.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskComplete.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskFail.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskPre.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskResume.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskRunning.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskStart.class.getCanonicalName());
annotataions.add(DownloadGroup.onTaskStop.class.getCanonicalName());
//任务组子任务的注解
annotataions.add(DownloadGroup.onSubTaskPre.class.getCanonicalName());
//annotataions.add(DownloadGroup.onSubTaskCancel.class.getCanonicalName());
annotataions.add(DownloadGroup.onSubTaskComplete.class.getCanonicalName());
annotataions.add(DownloadGroup.onSubTaskFail.class.getCanonicalName());
annotataions.add(DownloadGroup.onSubTaskRunning.class.getCanonicalName());
annotataions.add(DownloadGroup.onSubTaskStart.class.getCanonicalName());
annotataions.add(DownloadGroup.onSubTaskStop.class.getCanonicalName());
//上传任务的注解
annotataions.add(Upload.onWait.class.getCanonicalName());
annotataions.add(Upload.onPre.class.getCanonicalName());
annotataions.add(Upload.onNoSupportBreakPoint.class.getCanonicalName());
annotataions.add(Upload.onTaskCancel.class.getCanonicalName());
annotataions.add(Upload.onTaskComplete.class.getCanonicalName());
annotataions.add(Upload.onTaskFail.class.getCanonicalName());
annotataions.add(Upload.onTaskResume.class.getCanonicalName());
annotataions.add(Upload.onTaskRunning.class.getCanonicalName());
annotataions.add(Upload.onTaskStart.class.getCanonicalName());
annotataions.add(Upload.onTaskStop.class.getCanonicalName());
// M3U8切片事件
annotataions.add(M3U8.onPeerStart.class.getCanonicalName());
annotataions.add(M3U8.onPeerComplete.class.getCanonicalName());
annotataions.add(M3U8.onPeerFail.class.getCanonicalName());
return annotataions;
}
@Override public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
mHandler.clean();
mHandler.handleDownload(roundEnv);
mHandler.handleDownloadGroup(roundEnv);
mHandler.handleDownloadGroupSub(roundEnv);
mHandler.handleUpload(roundEnv);
mHandler.handleM3U8(roundEnv);
mHandler.createProxyFile();
return true;
}
}

View File

@ -0,0 +1,168 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.annotations.M3U8;
import com.arialyy.annotations.TaskEnum;
import com.arialyy.annotations.Upload;
import java.io.IOException;
import javax.annotation.processing.Filer;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.util.Elements;
/**
* Created by lyy on 2017/6/6.
* 元素处理
*/
class ElementHandler {
private Filer mFiler;
private ParamObtainUtil mPbUtil;
ElementHandler(Filer filer, Elements elements) {
mFiler = filer;
mPbUtil = new ParamObtainUtil(elements);
}
/**
* VariableElement 一般代表成员变量
* ExecutableElement 一般代表类中的方法
* TypeElement 一般代表代表类
* PackageElement 一般代表Package
*/
void handleDownload(RoundEnvironment roundEnv) {
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onWait.class, ProxyConstance.WAIT);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onNoSupportBreakPoint.class,
ProxyConstance.TASK_NO_SUPPORT_BREAKPOINT);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onPre.class, ProxyConstance.PRE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskCancel.class,
ProxyConstance.TASK_CANCEL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskComplete.class,
ProxyConstance.TASK_COMPLETE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskFail.class,
ProxyConstance.TASK_FAIL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskPre.class,
ProxyConstance.TASK_PRE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskResume.class,
ProxyConstance.TASK_RESUME);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskRunning.class,
ProxyConstance.TASK_RUNNING);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskStart.class,
ProxyConstance.TASK_START);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD, roundEnv, Download.onTaskStop.class,
ProxyConstance.TASK_STOP);
}
/**
* 处理搜索到的下载任务组注解
*/
void handleDownloadGroup(RoundEnvironment roundEnv) {
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onWait.class,
ProxyConstance.WAIT);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onPre.class,
ProxyConstance.PRE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskCancel.class,
ProxyConstance.TASK_CANCEL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskComplete.class,
ProxyConstance.TASK_COMPLETE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskFail.class,
ProxyConstance.TASK_FAIL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskPre.class,
ProxyConstance.TASK_PRE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskResume.class,
ProxyConstance.TASK_RESUME);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskRunning.class,
ProxyConstance.TASK_RUNNING);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskStart.class,
ProxyConstance.TASK_START);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP, roundEnv, DownloadGroup.onTaskStop.class,
ProxyConstance.TASK_STOP);
}
/**
* 处理搜索到的下载任务组子任务注解
*/
void handleDownloadGroupSub(RoundEnvironment roundEnv) {
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskPre.class,
ProxyConstance.TASK_PRE);
//mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskCancel.class,
// ProxyConstance.TASK_CANCEL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskComplete.class,
ProxyConstance.TASK_COMPLETE);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskFail.class,
ProxyConstance.TASK_FAIL);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskRunning.class,
ProxyConstance.TASK_RUNNING);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskStart.class,
ProxyConstance.TASK_START);
mPbUtil.saveMethod(TaskEnum.DOWNLOAD_GROUP_SUB, roundEnv, DownloadGroup.onSubTaskStop.class,
ProxyConstance.TASK_STOP);
}
/**
* 处理搜索到的上传注解
*/
void handleUpload(RoundEnvironment roundEnv) {
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onWait.class, ProxyConstance.WAIT);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onNoSupportBreakPoint.class,
ProxyConstance.TASK_NO_SUPPORT_BREAKPOINT);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onPre.class, ProxyConstance.PRE);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskCancel.class,
ProxyConstance.TASK_CANCEL);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskComplete.class,
ProxyConstance.TASK_COMPLETE);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskFail.class,
ProxyConstance.TASK_FAIL);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskResume.class,
ProxyConstance.TASK_RESUME);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskRunning.class,
ProxyConstance.TASK_RUNNING);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskStart.class,
ProxyConstance.TASK_START);
mPbUtil.saveMethod(TaskEnum.UPLOAD, roundEnv, Upload.onTaskStop.class,
ProxyConstance.TASK_STOP);
}
/**
* 处理搜索到到m3u8切片注解
*/
void handleM3U8(RoundEnvironment roundEnv) {
mPbUtil.saveMethod(TaskEnum.M3U8_PEER, roundEnv, M3U8.onPeerStart.class,
ProxyConstance.TASK_START);
mPbUtil.saveMethod(TaskEnum.M3U8_PEER, roundEnv, M3U8.onPeerComplete.class,
ProxyConstance.TASK_COMPLETE);
mPbUtil.saveMethod(TaskEnum.M3U8_PEER, roundEnv, M3U8.onPeerFail.class,
ProxyConstance.TASK_FAIL);
}
/**
* 在build文件夹中生成代理文件
*/
void createProxyFile() {
try {
new EventProxyFiler(mFiler, mPbUtil).createEventProxyFile();
//new CountFiler(mFiler, mPbUtil).createCountFile();
} catch (IOException e) {
e.printStackTrace();
}
}
void clean() {
mPbUtil.getMethodParams().clear();
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
/**
* Created by lyy on 2019/6/25.
* 实体信息
*/
enum EntityInfo {
NORMAL("com.arialyy.aria.core.common", "AbsNormalEntity"),
DOWNLOAD("com.arialyy.aria.core.download", "DownloadEntity"),
UPLOAD("com.arialyy.aria.core.upload", "UploadEntity");
String pkg, className;
public String getClassName() {
return className;
}
public String getPkg() {
return pkg;
}
/**
* @param pkg 包名
* @param className 对应到任务类名
*/
EntityInfo(String pkg, String className) {
this.pkg = pkg;
this.className = className;
}
}

View File

@ -0,0 +1,264 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.annotations.M3U8;
import com.arialyy.annotations.TaskEnum;
import com.arialyy.annotations.Upload;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeSpec;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.Filer;
import javax.lang.model.element.Modifier;
/**
* Created by lyy on 2017/9/6. 任务事件代理文件
*
* <pre>
* <code>
* package com.arialyy.simple.core.download;
*
* import com.arialyy.aria.core.download.DownloadTask;
* import com.arialyy.aria.core.scheduler.AbsSchedulerListener;
*
* public final class SingleTaskActivity$$DownloadListenerProxy extends
* AbsSchedulerListener<DownloadTask> {
* private SingleTaskActivity obj;
*
* public void onPre(final DownloadTask task) {
* obj.onPre((DownloadTask)task);
* }
*
* public void onTaskStart(final DownloadTask task) {
* obj.onStart((DownloadTask)task);
* }
*
* public void setListener(final Object obj) {
* this.obj = (SingleTaskActivity)obj;
* }
* }
* </code>
* </pre>
*/
final class EventProxyFiler {
private Filer mFiler;
private ParamObtainUtil mPbUtil;
EventProxyFiler(Filer filer, ParamObtainUtil pbUtil) {
mFiler = filer;
mPbUtil = pbUtil;
}
/**
* 创建任务事件代理文件
*/
void createEventProxyFile() throws IOException {
Set<String> keys = mPbUtil.getMethodParams().keySet();
for (String key : keys) {
ProxyClassParam entity = mPbUtil.getMethodParams().get(key);
JavaFile jf = JavaFile.builder(entity.packageName, createProxyClass(entity)).build();
createFile(jf);
}
}
/**
* 创建M3u8切片的代理方法
*
* @param taskEnum 任务类型枚举{@link TaskEnum}
* @param annotation {@link Download}、{@link Upload}、{@link M3U8}
* @param methodInfo 被代理类注解的方法信息
*/
private MethodSpec createM3U8PeerMethod(TaskEnum taskEnum, Class<? extends Annotation> annotation,
MethodInfo methodInfo) {
String sb = String.format("obj.%s(m3u8Url, peerPath, peerIndex);\n", methodInfo.methodName);
MethodSpec.Builder builder = MethodSpec.methodBuilder(annotation.getSimpleName())
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
.addParameter(String.class, "m3u8Url", Modifier.FINAL)
.addParameter(String.class, "peerPath", Modifier.FINAL)
.addParameter(int.class, "peerIndex", Modifier.FINAL)
.addAnnotation(Override.class)
.addCode(sb);
return builder.build();
}
/**
* 创建任务的代理方法
*
* @param taskEnum 任务类型枚举{@link TaskEnum}
* @param annotation {@link Download}、{@link Upload}
* @param methodInfo 被代理类注解的方法信息
*/
private MethodSpec createTaskMethod(TaskEnum taskEnum, Class<? extends Annotation> annotation,
MethodInfo methodInfo) {
ClassName task = ClassName.get(taskEnum.pkg, taskEnum.className);
String callCode;
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
if (methodInfo.params.get(methodInfo.params.size() - 1)
.asType()
.toString()
.equals(Exception.class.getName())
&& annotation == DownloadGroup.onSubTaskFail.class) {
callCode = "task, subEntity, e";
} else {
callCode = "task, subEntity";
}
} else {
if (methodInfo.params.get(methodInfo.params.size() - 1)
.asType()
.toString()
.equals(Exception.class.getName())
&& (annotation == Download.onTaskFail.class
|| annotation == Upload.onTaskFail.class
|| annotation == DownloadGroup.onTaskFail.class)) {
callCode = "task, e";
} else {
callCode = "task";
}
}
String sb = String.format("obj.%s((%s)%s);\n",
methodInfo.methodName, taskEnum.className, callCode);
ParameterSpec taskParam =
ParameterSpec.builder(task, "task").addModifiers(Modifier.FINAL).build();
MethodSpec.Builder builder = MethodSpec.methodBuilder(annotation.getSimpleName())
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
.addParameter(taskParam)
.addAnnotation(Override.class)
.addCode(sb);
//任务组接口
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
ClassName subTask =
ClassName.get(EntityInfo.DOWNLOAD.pkg, EntityInfo.DOWNLOAD.className);
ParameterSpec subTaskParam =
ParameterSpec.builder(subTask, "subEntity").addModifiers(Modifier.FINAL).build();
builder.addParameter(subTaskParam);
}
if (annotation == Download.onTaskFail.class
|| annotation == Upload.onTaskFail.class
|| annotation == DownloadGroup.onTaskFail.class
|| annotation == DownloadGroup.onSubTaskFail.class) {
ParameterSpec exception = ParameterSpec.builder(Exception.class, "e").build();
builder.addParameter(exception);
}
return builder.build();
}
/**
* 创建代理类
*/
private TypeSpec createProxyClass(ProxyClassParam entity) {
TypeSpec.Builder builder =
TypeSpec.classBuilder(entity.proxyClassName).addModifiers(Modifier.PUBLIC, Modifier.FINAL);
//添加被代理的类的字段
ClassName obj = ClassName.get(entity.packageName, entity.className);
FieldSpec observerField = FieldSpec.builder(obj, "obj").addModifiers(Modifier.PRIVATE).build();
builder.addField(observerField);
//添加注解方法
for (TaskEnum te : entity.methods.keySet()) {
Map<Class<? extends Annotation>, MethodInfo> methodInfoMap = entity.methods.get(te);
if (methodInfoMap != null) {
for (Class<? extends Annotation> annotation : methodInfoMap.keySet()) {
if (te == TaskEnum.DOWNLOAD
|| te == TaskEnum.DOWNLOAD_GROUP
|| te == TaskEnum.DOWNLOAD_GROUP_SUB
|| te == TaskEnum.UPLOAD) {
MethodSpec method = createTaskMethod(te, annotation, methodInfoMap.get(annotation));
builder.addMethod(method);
} else if (te == TaskEnum.M3U8_PEER) {
MethodSpec method = createM3U8PeerMethod(te, annotation, methodInfoMap.get(annotation));
builder.addMethod(method);
}
}
}
}
MethodSpec structure = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).build();
builder.addMethod(structure);
//添加设置代理的类
ParameterSpec parameterSpec =
ParameterSpec.builder(Object.class, "obj").addModifiers(Modifier.FINAL).build();
MethodSpec listener = MethodSpec.methodBuilder(ProxyConstance.SET_LISTENER)
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
.addParameter(parameterSpec)
.addAnnotation(Override.class)
.addCode("this.obj = (" + entity.className + ")obj;\n")
.build();
builder.addJavadoc("该文件为Aria自动生成的代理文件请不要修改该文件的任何代码\n");
//创建父类参数
ClassName superClass =
ClassName.get("com.arialyy.aria.core.scheduler", entity.mainTaskEnum.proxySuperClass);
if (entity.mainTaskEnum == TaskEnum.DOWNLOAD
|| entity.mainTaskEnum == TaskEnum.UPLOAD
|| entity.mainTaskEnum == TaskEnum.DOWNLOAD_GROUP) {
ClassName taskTypeVariable =
ClassName.get(entity.mainTaskEnum.pkg, entity.mainTaskEnum.className);
builder.superclass(ParameterizedTypeName.get(superClass, taskTypeVariable));
} else if (entity.mainTaskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
ClassName taskTypeVariable =
ClassName.get(entity.mainTaskEnum.pkg, entity.mainTaskEnum.className);
//子任务泛型参数
ClassName subTaskTypeVariable =
ClassName.get(entity.subTaskEnum.pkg, entity.subTaskEnum.className);
builder.superclass(
ParameterizedTypeName.get(superClass, taskTypeVariable, subTaskTypeVariable));
} else if (entity.mainTaskEnum == TaskEnum.M3U8_PEER) {
builder.superclass(superClass);
}
builder.addMethod(listener);
return builder.build();
}
private void createFile(JavaFile jf) throws IOException {
if (ProxyConstance.DEBUG) {
// 如果需要在控制台打印生成的文件,则去掉下面的注释
jf.writeTo(System.out);
} else {
jf.writeTo(mFiler);
}
}
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import java.util.List;
import javax.lang.model.element.VariableElement;
/**
* 方法信息
*/
final class MethodInfo {
String methodName;
List<VariableElement> params;
}

View File

@ -0,0 +1,276 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.annotations.TaskEnum;
import com.arialyy.annotations.Upload;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;
/**
* Created by lyy on 2017/9/6.
* 构建代理文件的参数获取工具
*/
class ParamObtainUtil {
private Map<String, ProxyClassParam> mMethodParams = new HashMap<>();
private Elements mElementUtil;
ParamObtainUtil(Elements elements) {
mElementUtil = elements;
}
/**
* 获取搜索到的代理方法参数
*/
Map<String, ProxyClassParam> getMethodParams() {
return mMethodParams;
}
/**
* 查找并保存扫描到的方法
*/
void saveMethod(TaskEnum taskEnum, RoundEnvironment roundEnv,
Class<? extends Annotation> annotationClazz, int annotationType) {
for (Element element : roundEnv.getElementsAnnotatedWith(annotationClazz)) {
ElementKind kind = element.getKind();
if (kind == ElementKind.METHOD) {
ExecutableElement method = (ExecutableElement) element;
TypeElement classElement = (TypeElement) method.getEnclosingElement();
PackageElement packageElement = mElementUtil.getPackageOf(classElement);
String methodName = method.getSimpleName().toString();
String className = method.getEnclosingElement().toString(); //全类名
String key = className + taskEnum.proxySuffix;
ProxyClassParam proxyEntity = mMethodParams.get(key);
MethodInfo methodInfo = new MethodInfo();
methodInfo.methodName = methodName;
methodInfo.params = (List<VariableElement>) method.getParameters();
if (taskEnum == TaskEnum.M3U8_PEER) {
checkM3U8PeerMethod(method, methodInfo.params);
} else {
checkTaskMethod(taskEnum, method, annotationClazz, methodInfo.params);
}
if (proxyEntity == null) {
proxyEntity = new ProxyClassParam();
proxyEntity.taskEnums = new HashSet<>();
proxyEntity.packageName = packageElement.getQualifiedName().toString();
proxyEntity.className = classElement.getSimpleName().toString();
proxyEntity.proxyClassName = proxyEntity.className + taskEnum.proxySuffix;
proxyEntity.mainTaskEnum = taskEnum;
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB || taskEnum == TaskEnum.DOWNLOAD_GROUP) {
proxyEntity.subTaskEnum = EntityInfo.DOWNLOAD;
}
mMethodParams.put(key, proxyEntity);
}
proxyEntity.taskEnums.add(taskEnum);
if (proxyEntity.methods.get(taskEnum) == null) {
proxyEntity.methods.put(taskEnum, new HashMap<Class<? extends Annotation>, MethodInfo>());
}
proxyEntity.methods.get(taskEnum).put(annotationClazz, methodInfo);
proxyEntity.keyMappings.put(methodName, getValues(taskEnum, method, annotationType));
}
}
}
/**
* 获取注解的内容
*/
private Set<String> getValues(TaskEnum taskEnum, ExecutableElement method, int annotationType) {
String[] keys = null;
switch (taskEnum) {
case DOWNLOAD:
keys = ValuesUtil.getDownloadValues(method, annotationType);
break;
case UPLOAD:
keys = ValuesUtil.getUploadValues(method, annotationType);
break;
case DOWNLOAD_GROUP:
keys = ValuesUtil.getDownloadGroupValues(method, annotationType);
break;
case DOWNLOAD_GROUP_SUB:
keys = ValuesUtil.getDownloadGroupSubValues(method, annotationType);
break;
case M3U8_PEER:
keys = ValuesUtil.getM3U8PeerValues(method, annotationType);
break;
}
return keys == null ? null : convertSet(keys);
}
/**
* 检查m3u8注解方法参数
*/
private void checkM3U8PeerMethod(ExecutableElement method, List<VariableElement> params) {
String methodName = method.getSimpleName().toString();
String className = method.getEnclosingElement().toString();
Set<Modifier> modifiers = method.getModifiers();
if (modifiers.contains(Modifier.PRIVATE)) {
throw new IllegalAccessError(String.format("%s.%s, 不能为private方法", className, methodName));
}
if (params.size() != 3
|| !params.get(0).asType().toString().equals(String.class.getName())
|| !params.get(1).asType().toString().equals(String.class.getName())
|| !params.get(2).asType().toString().equals("int")) {
throw new IllegalArgumentException(
String.format("%s.%s 的参数错误该方法需要的参数为String, String, int", className,
methodName));
}
}
/**
* 检查任务注解的相关参数如果被注解的方法为private或参数不合法或参数错误停止任务
*/
private void checkTaskMethod(TaskEnum taskEnum, ExecutableElement method,
Class<? extends Annotation> annotationClazz, List<VariableElement> params) {
String methodName = method.getSimpleName().toString();
String className = method.getEnclosingElement().toString();
Set<Modifier> modifiers = method.getModifiers();
if (modifiers.contains(Modifier.PRIVATE)) {
throw new IllegalAccessError(String.format("%s.%s, 不能为private方法", className, methodName));
}
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
if (isFailAnnotation(annotationClazz)) {
if (params.size() < 2 || params.size() > 3) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能是两个或三个,第一个参数是:%s第二个参数是%s第三个参数可选%s", className,
methodName,
getCheckParams(taskEnum), getCheckSubParams(taskEnum),
Exception.class.getSimpleName()));
}
if (params.size() == 2
&& (!params.get(0).asType().toString().equals(getCheckParams(taskEnum))
|| !params.get(1).asType().toString().equals(getCheckSubParams(taskEnum)))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能是两个或三个,第一个参数是:%s第二个参数是%s第三个参数可选%s", className,
methodName,
getCheckParams(taskEnum), getCheckSubParams(taskEnum),
Exception.class.getSimpleName()));
}
if (params.size() == 3
&& (!params.get(0).asType().toString().equals(getCheckParams(taskEnum))
|| !params.get(1).asType().toString().equals(getCheckSubParams(taskEnum))
|| !params.get(2).asType().toString().equals(Exception.class.getName()))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能是两个或三个,第一个参数是:%s第二个参数是%s第三个参数可选%s", className,
methodName,
getCheckParams(taskEnum), getCheckSubParams(taskEnum),
Exception.class.getSimpleName()));
}
} else {
if (params.size() == 2
&& (!params.get(0).asType().toString().equals(getCheckParams(taskEnum))
|| !params.get(1).asType().toString().equals(getCheckSubParams(taskEnum)))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能是两个或三个,第一个参数是:%s第二个参数是%s", className,
methodName,
getCheckParams(taskEnum), getCheckSubParams(taskEnum)));
}
}
} else {
if (isFailAnnotation(annotationClazz)) {
if (params.size() < 1 || params.size() > 2) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能有一个或两个,第一个参数是:%s第二个参数可选%s", className, methodName,
getCheckParams(taskEnum), Exception.class.getSimpleName()));
}
if (params.size() == 1
&& (!params.get(0).asType().toString().equals(getCheckParams(taskEnum)))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能有一个或两个,第一个参数是:%s第二个参数可选%s", className, methodName,
getCheckParams(taskEnum), Exception.class.getSimpleName()));
}
if (params.size() == 2
&& (!params.get(0).asType().toString().equals(getCheckParams(taskEnum))
|| !params.get(1).asType().toString().equals(Exception.class.getName()))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能有一个或两个,第一个参数是:%s第二个参数可选%s", className, methodName,
getCheckParams(taskEnum), Exception.class.getSimpleName()));
}
} else {
if (params.size() != 1
&& !params.get(0).asType().toString().equals(getCheckParams(taskEnum))) {
throw new IllegalArgumentException(
String.format("%s.%s参数错误, 参数只能有一个,且参数必须是:%s", className, methodName,
getCheckParams(taskEnum)));
}
}
}
}
/**
* 判断是否是任务失败的回调注解
*
* @return @code true是任务失败的回调注解
*/
private boolean isFailAnnotation(Class<? extends Annotation> annotationClazz) {
return annotationClazz == Download.onTaskFail.class
|| annotationClazz == DownloadGroup.onTaskFail.class
|| annotationClazz == DownloadGroup.onSubTaskFail.class
|| annotationClazz == Upload.onTaskFail.class;
}
/**
* 字符串数组转set
*
* @param keys 注解中查到的key
*/
private Set<String> convertSet(final String[] keys) {
if (keys == null || keys.length == 0) {
return null;
}
if (keys[0].isEmpty()) return null;
Set<String> set = new HashSet<>();
Collections.addAll(set, keys);
return set;
}
private String getCheckParams(TaskEnum taskEnum) {
return taskEnum.pkg + "." + taskEnum.className;
}
/**
* 检查任务组子任务第二个参数
*/
private String getCheckSubParams(TaskEnum taskEnum) {
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
return EntityInfo.DOWNLOAD.pkg + "." + EntityInfo.DOWNLOAD.className;
}
return "";
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.tools.Diagnostic;
/**
* Created by lyy on 2017/6/6.
*/
class PrintLog {
private volatile static PrintLog INSTANCE = null;
private Messager mMessager;
public static PrintLog init(Messager msg) {
if (INSTANCE == null) {
synchronized (PrintLog.class) {
INSTANCE = new PrintLog(msg);
}
}
return INSTANCE;
}
public static PrintLog getInstance() {
return INSTANCE;
}
private PrintLog() {
}
private PrintLog(Messager msg) {
mMessager = msg;
}
public void error(Element e, String msg, Object... args) {
mMessager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args), e);
}
public void error(String msg, Object... args) {
mMessager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args));
}
public void warning(String msg) {
mMessager.printMessage(Diagnostic.Kind.WARNING, msg);
}
public void error(String msg) {
mMessager.printMessage(Diagnostic.Kind.ERROR, msg);
}
public void info(String str) {
mMessager.printMessage(Diagnostic.Kind.NOTE, str);
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.TaskEnum;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Created by lyy on 2017/6/7.
* 代理类参数
*/
class ProxyClassParam {
/**
* 代理文件名
*/
String proxyClassName;
/**
* 被代理的类所在的包
*/
String packageName;
/**
* 被代理的类
*/
String className;
/**
* 主任务泛型参数
*/
TaskEnum mainTaskEnum;
/**
* 子任务泛型参数
*/
EntityInfo subTaskEnum = EntityInfo.NORMAL;
Set<TaskEnum> taskEnums;
Map<String, Set<String>> keyMappings = new HashMap<>();
Map<TaskEnum, Map<Class<? extends Annotation>, MethodInfo>> methods = new HashMap<>();
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
/**
* Created by lyy on 2017/6/7.
* 扫描器常量
*/
interface ProxyConstance {
boolean DEBUG = false;
/**
* 设置观察者的方法
*/
String SET_LISTENER = "setListener";
int WAIT = 0X10;
int PRE = 0X11;
int TASK_PRE = 0X12;
int TASK_RESUME = 0X13;
int TASK_START = 0X14;
int TASK_STOP = 0X15;
int TASK_CANCEL = 0X16;
int TASK_FAIL = 0X17;
int TASK_COMPLETE = 0X18;
int TASK_RUNNING = 0X19;
int TASK_NO_SUPPORT_BREAKPOINT = 0X1A;
}

View File

@ -0,0 +1,196 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.compiler;
import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.annotations.M3U8;
import com.arialyy.annotations.Upload;
import javax.lang.model.element.ExecutableElement;
/**
* Created by lyy on 2017/9/6.
* 获取注解value工具
*/
final class ValuesUtil {
/**
* 获取m3u8切片注解信息
*/
static String[] getM3U8PeerValues(ExecutableElement method, int annotationType) {
String[] values = null;
switch (annotationType) {
case ProxyConstance.TASK_START:
values = method.getAnnotation(M3U8.onPeerStart.class).value();
break;
case ProxyConstance.TASK_COMPLETE:
values = method.getAnnotation(M3U8.onPeerComplete.class).value();
break;
case ProxyConstance.TASK_FAIL:
values = method.getAnnotation(M3U8.onPeerFail.class).value();
break;
}
return values;
}
/**
* 获取下载任务组子任务的的注解数据
*/
static String[] getDownloadGroupSubValues(ExecutableElement method, int annotationType) {
String[] values = null;
switch (annotationType) {
case ProxyConstance.TASK_PRE:
values = method.getAnnotation(DownloadGroup.onSubTaskPre.class).value();
break;
case ProxyConstance.TASK_START:
values = method.getAnnotation(DownloadGroup.onSubTaskStart.class).value();
break;
case ProxyConstance.TASK_RUNNING:
values = method.getAnnotation(DownloadGroup.onSubTaskRunning.class).value();
break;
case ProxyConstance.TASK_STOP:
values = method.getAnnotation(DownloadGroup.onSubTaskStop.class).value();
break;
case ProxyConstance.TASK_COMPLETE:
values = method.getAnnotation(DownloadGroup.onSubTaskComplete.class).value();
break;
case ProxyConstance.TASK_CANCEL:
//values = method.getAnnotation(DownloadGroup.onSubTaskCancel.class).value();
break;
case ProxyConstance.TASK_FAIL:
values = method.getAnnotation(DownloadGroup.onSubTaskFail.class).value();
break;
}
return values;
}
/**
* 获取下载任务组的注解数据
*/
static String[] getDownloadGroupValues(ExecutableElement method, int annotationType) {
String[] values = null;
switch (annotationType) {
case ProxyConstance.PRE:
values = method.getAnnotation(DownloadGroup.onPre.class).value();
break;
case ProxyConstance.TASK_PRE:
values = method.getAnnotation(DownloadGroup.onTaskPre.class).value();
break;
case ProxyConstance.TASK_RESUME:
values = method.getAnnotation(DownloadGroup.onTaskResume.class).value();
break;
case ProxyConstance.TASK_START:
values = method.getAnnotation(DownloadGroup.onTaskStart.class).value();
break;
case ProxyConstance.TASK_RUNNING:
values = method.getAnnotation(DownloadGroup.onTaskRunning.class).value();
break;
case ProxyConstance.TASK_STOP:
values = method.getAnnotation(DownloadGroup.onTaskStop.class).value();
break;
case ProxyConstance.TASK_COMPLETE:
values = method.getAnnotation(DownloadGroup.onTaskComplete.class).value();
break;
case ProxyConstance.TASK_CANCEL:
values = method.getAnnotation(DownloadGroup.onTaskCancel.class).value();
break;
case ProxyConstance.TASK_FAIL:
values = method.getAnnotation(DownloadGroup.onTaskFail.class).value();
break;
}
return values;
}
/**
* 获取上传的注解数据
*/
static String[] getUploadValues(ExecutableElement method, int annotationType) {
String[] values = null;
switch (annotationType) {
case ProxyConstance.PRE:
values = method.getAnnotation(Upload.onPre.class).value();
break;
case ProxyConstance.TASK_PRE:
//values = method.getAnnotation(Upload.onTaskPre.class).value();
break;
case ProxyConstance.TASK_RESUME:
values = method.getAnnotation(Upload.onTaskResume.class).value();
break;
case ProxyConstance.TASK_START:
values = method.getAnnotation(Upload.onTaskStart.class).value();
break;
case ProxyConstance.TASK_RUNNING:
values = method.getAnnotation(Upload.onTaskRunning.class).value();
break;
case ProxyConstance.TASK_STOP:
values = method.getAnnotation(Upload.onTaskStop.class).value();
break;
case ProxyConstance.TASK_COMPLETE:
values = method.getAnnotation(Upload.onTaskComplete.class).value();
break;
case ProxyConstance.TASK_CANCEL:
values = method.getAnnotation(Upload.onTaskCancel.class).value();
break;
case ProxyConstance.TASK_FAIL:
values = method.getAnnotation(Upload.onTaskFail.class).value();
break;
case ProxyConstance.TASK_NO_SUPPORT_BREAKPOINT:
//values = method.getAnnotation(Upload.onNoSupportBreakPoint.class).value();
break;
}
return values;
}
/**
* 获取下载的注解数据
*/
static String[] getDownloadValues(ExecutableElement method, int annotationType) {
String[] values = null;
switch (annotationType) {
case ProxyConstance.PRE:
values = method.getAnnotation(Download.onPre.class).value();
break;
case ProxyConstance.TASK_PRE:
values = method.getAnnotation(Download.onTaskPre.class).value();
break;
case ProxyConstance.TASK_RESUME:
values = method.getAnnotation(Download.onTaskResume.class).value();
break;
case ProxyConstance.TASK_START:
values = method.getAnnotation(Download.onTaskStart.class).value();
break;
case ProxyConstance.TASK_RUNNING:
values = method.getAnnotation(Download.onTaskRunning.class).value();
break;
case ProxyConstance.TASK_STOP:
values = method.getAnnotation(Download.onTaskStop.class).value();
break;
case ProxyConstance.TASK_COMPLETE:
values = method.getAnnotation(Download.onTaskComplete.class).value();
break;
case ProxyConstance.TASK_CANCEL:
values = method.getAnnotation(Download.onTaskCancel.class).value();
break;
case ProxyConstance.TASK_FAIL:
values = method.getAnnotation(Download.onTaskFail.class).value();
break;
case ProxyConstance.TASK_NO_SUPPORT_BREAKPOINT:
values = method.getAnnotation(Download.onNoSupportBreakPoint.class).value();
break;
}
return values;
}
}