Java 类hudson.model.Describable 实例源码

项目:yaml-project-plugin    文件:Binder.java   
/** {@inheritDoc} */
@Override
public <T extends Describable> T bind(JSONObject json)
    throws IOException, FormException {
  final String clazz = checkNotNull(json.optString("$class", null));

  final Descriptor descriptor = getDescriptor(clazz);

  final Stapler stapler = getStapler();
  final StaplerRequest request = getRequest(stapler, json);

  // We do this instead of 'request.bindJson' because this doesn't
  // require a DataBoundConstructor.
  // TODO(mattmoor): Should we do the rewrite of describable lists
  // here as well?
  return (T) descriptor.newInstance(request, json);
}
项目:yaml-project-plugin    文件:Binder.java   
/**
 * Gets the {@link Descriptor} of the {@link Describable} we are
 * looking to instantiate.
 */
@VisibleForTesting
Descriptor getDescriptor(String clazzName) throws IOException {
  Class<? extends Describable<?>> implClass;
  try {
    implClass = (Class<? extends Describable<?>>) getClassLoader()
        .loadClass(clazzName);
  } catch (ClassNotFoundException ex) {
    throw new BadTypeException(
        Messages.DefaultBinder_CannotLoadClass(clazzName));
  }

  final Descriptor descriptor =
      checkNotNull(Jenkins.getInstance()).getDescriptor(implClass);
  if (descriptor == null) {
    throw new BadTypeException(
        Messages.DefaultBinder_NoDescriptor(implClass.getName()));
  }
  return descriptor;
}
项目:Jenkins-Plugin-Examples    文件:CoreStep.java   
private <T extends Describable<T>,D extends Descriptor<T>> void populate(List<Descriptor<?>> r, Class<T> c) {
    for (Descriptor<?> d : Jenkins.getActiveInstance().getDescriptorList(c)) {
        if (SimpleBuildStep.class.isAssignableFrom(d.clazz)) {
            r.add(d);
        }
    }
}
项目:gitlab-auth-plugin    文件:MockFolderBuilder.java   
@Override
protected final Folder createMockItem() throws Exception {
    // mock the common item methods
    Folder folder = super.createMockItem();

    // mock the property list
    DescribableList propertyList = createMock(DescribableList.class);
    expect(folder.getProperties()).andReturn(propertyList).anyTimes();

    // mock adding properties
    folder.addProperty(anyObject(FolderProperty.class));
    expectLastCall().andAnswer(new IAnswer<Void>() {
        public Void answer() throws Throwable {
            addProperty((FolderProperty)getCurrentArguments()[0]);
            return null;
        }
    }).anyTimes();

    // mock getting properties
    expect(propertyList.get(anyObject(Class.class))).andAnswer(new IAnswer<Describable>() {
        public Describable answer() throws Throwable {
            return getProperty((Class)getCurrentArguments()[0]);
        }
    }).anyTimes();

    replay(propertyList);

    return folder;
}
项目:DotCi    文件:DotCiExtensionsHelper.java   
private <T extends Describable<T>, D extends Descriptor<T>> List<Descriptor<?>> getClassList(Class<T> c) {
    ArrayList<Descriptor<?>> r = new ArrayList<Descriptor<?>>();
    if (jenkins == null) {
        return new ArrayList<Descriptor<?>>();
    }
    for (Descriptor<?> d : jenkins.getDescriptorList(c)) {
        if (SimpleBuildStep.class.isAssignableFrom(d.clazz)) {
            r.add(d);
        }
    }
    return r;
}
项目:jenkins.py    文件:BuildWrapperDescriptorPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(16)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins.py    文件:ProjectNamingStrategyDescriptorPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(16)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins.py    文件:PropertyDescriptorPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(17)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins.py    文件:GlobalConfigurationPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(19)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins.py    文件:BuildStepDescriptorPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(16)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins.py    文件:GlobalConfigurationPW.java   
@Override
public void addHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    initPython();
    if (pexec.isImplemented(19)) {
        pexec.execPythonVoid("add_help_file_redirect", fieldName, owner, fieldNameToRedirectTo);
    } else {
        super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
    }
}
项目:jenkins-inheritance-plugin    文件:InheritanceGovernor.java   
protected static <R extends Describable<R>> DescribableList<R, Descriptor<R>> reduceDescribableByMerge(
        Deque<DescribableList<R, Descriptor<R>>> list) {
    if (list == null) {
        return new DescribableList<R, Descriptor<R>>(NOOP);
    }

    List<R> merge = new LinkedList<R>();
    for (DescribableList<R, Descriptor<R>> sub : list) {
        for (R item : sub) {
            merge.add(item);
        }
    }

    return new DescribableList<R, Descriptor<R>>(NOOP, merge);
}
项目:jenkins-inheritance-plugin    文件:InheritanceGovernor.java   
protected static <R extends Describable<R>> DescribableList<R, Descriptor<R>> reduceDescribableByMergeWithoutDuplicates(
        Deque<DescribableList<R, Descriptor<R>>> list) {

        // set for keeping track of found classes
        Set<Class<?>> seen = new HashSet<Class<?>>();

        if (list == null) {
            return new DescribableList<R, Descriptor<R>>(NOOP);
        }

        // result list
        List<R> merge = new LinkedList<R>();

        // descending order for keeping the last buildwrapper that was set = lower in the inheritance tree
        Iterator<DescribableList<R, Descriptor<R>>> rIter = list.descendingIterator();
        while (rIter.hasNext()) {
            DescribableList<R, Descriptor<R>> sub = rIter.next();

            for (R item : sub) {
                Class<?> clazz = item.getClass();

                if (!seen.contains(clazz)) {
                    merge.add(item);
                    seen.add(clazz);
                }
            }
        }

        return new DescribableList<R, Descriptor<R>>(NOOP, merge);
}
项目:jenkins-inheritance-plugin    文件:InheritanceGovernor.java   
@SuppressWarnings("unchecked")
protected static <R extends Describable<R>> DescribableList<R, Descriptor<R>> castToDescribableList(Object o) {
    try {
        if (o instanceof DescribableList) {
            return ((DescribableList<R, Descriptor<R>>) o);
        }
        return null;
    } catch (ClassCastException ex) {
        return null;
    }
}
项目:restricted-register-plugin    文件:IJenkinsDescriptor.java   
@Nonnull
<E extends Describable<E>, T extends Descriptor<E>> T getDescriptorForType(E describable);
项目:restricted-register-plugin    文件:JenkinsDescriptorImpl.java   
@Nonnull
@Override
public <E extends Describable<E>, T extends Descriptor<E>> T getDescriptorForType(E describable) {
    //noinspection unchecked
    return (T) getJenkinsInstanceOrDie().getDescriptor(describable.getClass());
}
项目:restricted-register-plugin    文件:MockJenkinsDescriptor.java   
@Nonnull
@Override
public <E extends Describable<E>, T extends Descriptor<E>> T getDescriptorForType(E describable) {
    throw new UnsupportedOperationException("");
}
项目:jenkins-deployment-manager-plugin    文件:BuildStepDetailsProvider.java   
protected static String defaultName(BuildStep bs) {
  return bs instanceof Describable<?> ? ((Describable<?>) bs).getDescriptor().getDisplayName()
      : null;
}
项目:jenkins.py    文件:BuildWrapperDescriptorPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:jenkins.py    文件:ProjectNamingStrategyDescriptorPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:jenkins.py    文件:PropertyDescriptorPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:jenkins.py    文件:GlobalConfigurationPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:jenkins.py    文件:BuildStepDescriptorPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:jenkins.py    文件:GlobalConfigurationPW.java   
public void superAddHelpFileRedirect(String fieldName, Class<? extends Describable> owner, String fieldNameToRedirectTo) {
    super.addHelpFileRedirect(fieldName, owner, fieldNameToRedirectTo);
}
项目:support-core-plugin    文件:AboutJenkins.java   
private static String getDescriptorName(@CheckForNull Describable<?> d) {
    if (d == null) {
        return "(none)";
    }
    return "`" + d.getClass().getName() + "`";
}
项目:yaml-project-plugin    文件:Binder.java   
/**
 * Bind the {@link JSONObject} to the specified type.
 *
 * @param <T> The type to which we are binding the JSON.
 * @param json The serialized object we are instantiating
 * @return The object of the specified type, from the JSON.
 */
<T extends Describable> T bind(JSONObject json)
    throws IOException, FormException;