All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.tasks.UserNameResolver Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 *
 * Copyright (c) 2004-2009 Oracle Corporation.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * 
 *    Kohsuke Kawaguchi, Tom Huybrechts
 *
 *
 *******************************************************************************/ 

package hudson.tasks;

import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionListView;
import hudson.ExtensionPoint;
import hudson.model.Hudson;
import hudson.model.User;

import java.util.List;

/**
 * Finds full name off the user when none is specified.
 *
 * 

This is an extension point of Hudson. Plugins tha contribute new * implementation of this class should use {@link Extension} to register the * instance into Hudson, like this: * *

 * @Extension
 * class MyserNameResolver extends UserNameResolver {
 *   ...
 * }
 * 
* * @author Kohsuke Kawaguchi * @since 1.192 */ public abstract class UserNameResolver implements ExtensionPoint { /** * Finds full name of the given user. * *

This method is called when a {@link User} without explicitly name is * used. * *

When multiple resolvers are installed, they are consulted in order * and the search will be over when a name is found by someoene. * *

Since {@link UserNameResolver} is singleton, this method can be * invoked concurrently from multiple threads. * * @return null if the inference failed. */ public abstract String findNameFor(User u); public static String resolve(User u) { for (UserNameResolver r : all()) { String name = r.findNameFor(u); if (name != null) { return name; } } return null; } /** * Returns all the registered {@link UserNameResolver} descriptors. */ public static ExtensionList all() { return Hudson.getInstance().getExtensionList(UserNameResolver.class); } /** * All registered {@link UserNameResolver} implementations. * * @deprecated since 2009-02-24. Use {@link #all()} for read access, and use * {@link Extension} for registration. */ public static final List LIST = ExtensionListView.createList(UserNameResolver.class); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy