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

hudson.model.UserProperty 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
 *
 *
 *******************************************************************************/ 

package hudson.model;

import hudson.ExtensionPoint;
import hudson.Plugin;
import hudson.DescriptorExtensionList;
import hudson.model.Descriptor.FormException;
import net.sf.json.JSONObject;

import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.export.ExportedBean;

/**
 * Extensible property of {@link User}.
 *
 * 

{@link Plugin}s can extend this to define custom properties for * {@link User}s. {@link UserProperty}s show up in the user configuration * screen, and they are persisted with the user object. * *

Configuration screen should be defined in config.jelly. Within * this page, the {@link UserProperty} instance is available as * instance variable (while it refers to {@link User}. See * {@link Mailer.UserProperty}'s config.jelly for an example. * * * @author Kohsuke Kawaguchi */ @ExportedBean public abstract class UserProperty implements Describable, ExtensionPoint { /** * The user object that owns this property. This value will be set by the * Hudson code. Derived classes can expect this value to be always set. */ protected transient User user; /*package*/ final void setUser(User u) { this.user = u; } // descriptor must be of the UserPropertyDescriptor type public UserPropertyDescriptor getDescriptor() { return (UserPropertyDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass()); } /** * Returns all the registered {@link UserPropertyDescriptor}s. */ public static DescriptorExtensionList all() { return Hudson.getInstance().getDescriptorList(UserProperty.class); } public UserProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { return getDescriptor().newInstance(req, form); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy