001 /*
002 * The contents of this file are subject to the terms
003 * of the Common Development and Distribution License
004 * (the "License"). You may not use this file except
005 * in compliance with the License.
006 *
007 * You can obtain a copy of the license at
008 * http://www.opensource.org/licenses/cddl1.php
009 * See the License for the specific language governing
010 * permissions and limitations under the License.
011 */
012
013 package javax.ws.rs.ext;
014
015 /**
016 * Contract for a provider that supplies context information to resource
017 * classes and other providers. An implementation of this interface must be
018 * annotated with {@link Provider}.
019 *
020 * A <code>ContextResolver</code> implementation may be annotated
021 * with {@link javax.ws.rs.Produces} to restrict the media types for
022 * which it will be considered suitable.
023 *
024 * @see javax.ws.rs.core.Context
025 * @see Providers#getContextResolver(java.lang.Class, javax.ws.rs.core.MediaType)
026 * @see Provider
027 * @see javax.ws.rs.Produces
028 */
029 public interface ContextResolver<T> {
030
031 /**
032 * Get a context of type <code>T</code> that is applicable to the supplied
033 * type.
034 * @param type the class of object for which a context is desired
035 * @return a context for the supplied type or <code>null</code> if a
036 * context for the supplied type is not available from this provider.
037 */
038 T getContext(Class<?> type);
039 }