org.glassfish.jersey.server
Class ResourceConfig

java.lang.Object
  extended by javax.ws.rs.core.Application
      extended by org.glassfish.jersey.server.ResourceConfig
All Implemented Interfaces:
FeaturesAndProperties

public class ResourceConfig
extends javax.ws.rs.core.Application
implements FeaturesAndProperties

The resource configuration for configuring a web application.

Author:
Paul Sandoz

Constructor Summary
ResourceConfig()
           
ResourceConfig(javax.ws.rs.core.Application application)
           
ResourceConfig(Class<?>... classes)
           
ResourceConfig(Class<? extends javax.ws.rs.core.Application> applicationClass)
           
ResourceConfig(ResourceConfig that)
           
ResourceConfig(Set<Class<?>> classes)
           
 
Method Summary
 ResourceConfig addClasses(Class<?>... classes)
          Add classes to ResourceConfig.
 ResourceConfig addClasses(Set<Class<?>> classes)
          Add classes to ResourceConfig.
 ResourceConfig addFinder(ResourceFinder resourceFinder)
          Add a ResourceFinder to ResourceConfig.
 ResourceConfig addModules(org.glassfish.hk2.Module... modules)
          Add HK2 modules to ResourceConfig.
 ResourceConfig addModules(Set<org.glassfish.hk2.Module> modules)
          Add HK2 modules to ResourceConfig.
 ResourceConfig addProperties(Map<String,Object> properties)
          Add properties to ResourceConfig.
 ResourceConfig addResources(ResourceClass... resources)
           
 ResourceConfig addResources(Set<ResourceClass> resources)
           
 ResourceConfig addSingletons(Object... singletons)
          Add singletons to ResourceConfig.
 ResourceConfig addSingletons(Set<Object> singletons)
          Add singletons to ResourceConfig.
 ResourceConfig files(String... files)
          Adds array of file names to scan for providers.
 Set<Class<?>> getClasses()
          Set of current resource and provider classes.
 ClassLoader getClassLoader()
          Get resource and provider class loader.
static String[] getElements(String[] elements)
          Get a canonical array of String elements from a String array where each entry may contain zero or more elements separated by ';'.
static String[] getElements(String[] elements, String delimiters)
          Get a canonical array of String elements from a String array where each entry may contain zero or more elements separated by characters in delimiters string.
static String[] getElements(String elements, String delimiters)
          Get a canonical array of String elements from a String that may contain zero or more elements separated by characters in delimiters string.
 Map<String,Object> getProperties()
           
 Object getProperty(String name)
           
 Set<ResourceClass> getResources()
          Get programmatically modeled resources.
 Set<Object> getSingletons()
          Set of singletons.
 boolean isProperty(String name)
           
 ResourceConfig packages(String... packages)
          Adds array of package names which will be used to scan for providers.
static ResourceBuilder resourceBuilder()
           
 ResourceConfig setClassLoader(ClassLoader classLoader)
          Set ClassLoader which will be used for resource discovery.
 ResourceConfig setProperty(String name, Object value)
          Set a ResourceConfig property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceConfig

public ResourceConfig()

ResourceConfig

public ResourceConfig(javax.ws.rs.core.Application application)

ResourceConfig

public ResourceConfig(Class<? extends javax.ws.rs.core.Application> applicationClass)

ResourceConfig

public ResourceConfig(Set<Class<?>> classes)

ResourceConfig

public ResourceConfig(Class<?>... classes)

ResourceConfig

public ResourceConfig(ResourceConfig that)
Method Detail

resourceBuilder

public static ResourceBuilder resourceBuilder()

addClasses

public ResourceConfig addClasses(Set<Class<?>> classes)
Add classes to ResourceConfig.

Parameters:
classes - list of classes to add.
Returns:
updated resource configuration instance.

addClasses

public final ResourceConfig addClasses(Class<?>... classes)
Add classes to ResourceConfig.

Parameters:
classes - Set of classes to add.
Returns:
updated resource configuration instance.

addSingletons

public ResourceConfig addSingletons(Set<Object> singletons)
Add singletons to ResourceConfig.

Parameters:
singletons - Set of instances to add.
Returns:
updated resource configuration instance.

addSingletons

public final ResourceConfig addSingletons(Object... singletons)
Add singletons to ResourceConfig.

Parameters:
singletons - list of instances to add.
Returns:
updated resource configuration instance.

addResources

public final ResourceConfig addResources(ResourceClass... resources)

addResources

public ResourceConfig addResources(Set<ResourceClass> resources)

setProperty

public ResourceConfig setProperty(String name,
                                  Object value)
Set a ResourceConfig property.

Parameters:
name - property name.
value - property value.
Returns:
updated resource configuration instance.

addProperties

public ResourceConfig addProperties(Map<String,Object> properties)
Add properties to ResourceConfig. If any of the added properties exists already, he values of the existing properties will be replaced with new values.

Parameters:
properties - properties to add.
Returns:
updated resource configuration instance.

addFinder

public ResourceConfig addFinder(ResourceFinder resourceFinder)
Add a ResourceFinder to ResourceConfig.

Parameters:
resourceFinder - ResourceFinder
Returns:
updated resource configuration instance.

addModules

public ResourceConfig addModules(Set<org.glassfish.hk2.Module> modules)
Add HK2 modules to ResourceConfig. These modules will be added when creating Services instance.

Parameters:
modules - custom modules.
Returns:
updated resource configuration instance.

addModules

public final ResourceConfig addModules(org.glassfish.hk2.Module... modules)
Add HK2 modules to ResourceConfig. These modules will be added when creating Services instance.

Parameters:
modules - custom modules.
Returns:
updated resource configuration instance..

setClassLoader

public ResourceConfig setClassLoader(ClassLoader classLoader)
Set ClassLoader which will be used for resource discovery.

Parameters:
classLoader - provided ClassLoader.
Returns:
updated resource configuration instance.

packages

public final ResourceConfig packages(String... packages)
Adds array of package names which will be used to scan for providers.

Parameters:
packages - array of package names
Returns:
updated resource configuration instance.

files

public final ResourceConfig files(String... files)
Adds array of file names to scan for providers.

Parameters:
files - array of file names.
Returns:
updated resource configuration instance.

getClasses

public final Set<Class<?>> getClasses()
Set of current resource and provider classes. Any modification to this list won't be reflected anywhere. set.

Overrides:
getClasses in class javax.ws.rs.core.Application
Returns:
Set of resource and provider classes.

getSingletons

public final Set<Object> getSingletons()
Set of singletons. Any modification to this list won't be reflected anywhere. set.

Overrides:
getSingletons in class javax.ws.rs.core.Application
Returns:
Set of singletons.

getResources

public final Set<ResourceClass> getResources()
Get programmatically modeled resources.

Returns:
programmatically modeled resources.

getClassLoader

public final ClassLoader getClassLoader()
Get resource and provider class loader.

Returns:
class loader to be used when looking up the resource classes and providers.

getProperties

public final Map<String,Object> getProperties()
Specified by:
getProperties in interface FeaturesAndProperties

getProperty

public final Object getProperty(String name)
Specified by:
getProperty in interface FeaturesAndProperties

isProperty

public final boolean isProperty(String name)
Specified by:
isProperty in interface FeaturesAndProperties

getElements

public static String[] getElements(String[] elements)
Get a canonical array of String elements from a String array where each entry may contain zero or more elements separated by ';'.

Parameters:
elements - an array where each String entry may contain zero or more ServerProperties.COMMON_DELIMITERS separated elements.
Returns:
the array of elements, each element is trimmed, the array will not contain any empty or null entries.

getElements

public static String[] getElements(String[] elements,
                                   String delimiters)
Get a canonical array of String elements from a String array where each entry may contain zero or more elements separated by characters in delimiters string.

Parameters:
elements - an array where each String entry may contain zero or more delimiters separated elements.
delimiters - string with delimiters, every character represents one delimiter.
Returns:
the array of elements, each element is trimmed, the array will not contain any empty or null entries.

getElements

public static String[] getElements(String elements,
                                   String delimiters)
Get a canonical array of String elements from a String that may contain zero or more elements separated by characters in delimiters string.

Parameters:
elements - a String that may contain zero or more delimiters separated elements.
delimiters - string with delimiters, every character represents one delimiter.
Returns:
the array of elements, each element is trimmed.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.