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.core;
014
015 import java.util.Collections;
016 import java.util.Set;
017
018 /**
019 * Defines the components of a JAX-RS application and supplies additional
020 * metadata. A JAX-RS application or implementation supplies a concrete
021 * subclass of this abstract class.
022 *
023 * <p>The implementation-created instance of an Application subclass may be
024 * injected into resource classes and providers using
025 * {@link javax.ws.rs.core.Context}.<p>
026 *
027 */
028 public class Application {
029 private static final Set<Object> emptyObjectSet = Collections.emptySet();
030 private static final Set<Class<?>> emptyClassSet = Collections.emptySet();
031
032 /**
033 * Get a set of root resource and provider classes. The default lifecycle
034 * for resource class instances is per-request. The default lifecycle for
035 * providers is singleton.
036 *
037 * <p>Implementations should warn about and ignore classes that do not
038 * conform to the requirements of root resource or provider classes.
039 * Implementations should warn about and ignore classes for which
040 * {@link #getSingletons()} returns an instance. Implementations MUST
041 * NOT modify the returned set.</p>
042 *
043 * <p>The default implementation returns an empty set.</p>
044 *
045 * @return a set of root resource and provider classes. Returning null
046 * is equivalent to returning an empty set.
047 */
048 public Set<Class<?>> getClasses() {
049 return emptyClassSet;
050 }
051
052 /**
053 * Get a set of root resource and provider instances. Fields and properties
054 * of returned instances are injected with their declared dependencies
055 * (see {@link Context}) by the runtime prior to use.
056 *
057 * <p>Implementations should warn about and ignore classes that do not
058 * conform to the requirements of root resource or provider classes.
059 * Implementations should flag an error if the returned set includes
060 * more than one instance of the same class. Implementations MUST
061 * NOT modify the returned set.</p>
062 *
063 * <p>The default implementation returns an empty set.</p>
064 *
065 * @return a set of root resource and provider instances. Returning null
066 * is equivalent to returning an empty set.
067 */
068 public Set<Object> getSingletons() {
069 return emptyObjectSet;
070 }
071
072 }