提交 46fd462d 编写于 作者: K kohsuke

added more convenient constructor for saving typing

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@35364 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8b1e071d
......@@ -113,7 +113,7 @@ public class OldDataMonitor extends AdministrativeMonitor {
};
@Extension
public static final RunListener<Run> runDeleteListener = new RunListener<Run>(Run.class) {
public static final RunListener<Run> runDeleteListener = new RunListener<Run>() {
@Override
public void onDeleted(Run run) {
remove(run, true);
......
......@@ -31,6 +31,10 @@ import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.model.Hudson;
import hudson.util.CopyOnWriteList;
import org.jvnet.tiger_types.Types;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* Receives notifications about builds.
......@@ -52,6 +56,14 @@ public abstract class RunListener<R extends Run> implements ExtensionPoint {
this.targetType = targetType;
}
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType)
targetType = Types.erasure(Types.getTypeArgument(type,0));
else
throw new IllegalStateException(getClass()+" uses the raw type for extending RunListener");
}
/**
* Called after a build is completed.
*
......
......@@ -272,10 +272,6 @@ public class AggregatedTestResultPublisher extends Recorder {
@Extension
public static class RunListenerImpl extends RunListener<Run> {
public RunListenerImpl() {
super(Run.class);
}
@Override
public void onCompleted(Run run, TaskListener listener) {
lastChanged = System.currentTimeMillis();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册