Class RuntimeResource
- java.lang.Object
-
- org.glassfish.jersey.server.model.RuntimeResource
-
- All Implemented Interfaces:
ResourceModelComponent
public class RuntimeResource extends java.lang.Object implements ResourceModelComponent
Runtime resource is a group ofresourceswith the samepathregular expression. Runtime resource is constructed fromresourcescreating theresource model. Runtime resource can have child runtime resources which are groups of child resources of all resources constructing this runtime resource. The following example shows how Runtime resource structure is built from Resource model:@Path("{foo}") public class TemplateResourceFoo { @GET @Path("child") public String getFoo() {...} @Path("{x}") @GET public String getX() {...} @Path("{y}") @POST public String postY(String entity) {...} } @Path("{bar}") public class TemplateResourceBar { @Path("{z}") @PUT public String putZ(String entity) {...} }Will be represented by RuntimeResources:line RuntimeResource regex Grouped Resources (paths) Parent RuntimeResource (line) 1 "/([^/]+?)" Resource("{foo}"), Resource("{bar}") no parent 2 "child" Child Resource("child") 1 3 "/([^/]+?)" Child Resource("{x}"), Child Resource("{y}"), Child Resource("{z}") 1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRuntimeResource.BuilderRuntime Resource builder.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<RuntimeResource>childRuntimeResourcesstatic java.util.Comparator<RuntimeResource>COMPARATORComparator of RuntimeResources based on rules respecting resource matching algorithm.private RuntimeResourceparentprivate PathPatternpathPatternprivate java.lang.Stringregexprivate java.util.List<ResourceMethod>resourceLocatorsprivate java.util.List<ResourceMethod>resourceMethodsprivate java.util.List<Resource>resources
-
Constructor Summary
Constructors Modifier Constructor Description privateRuntimeResource(java.util.List<Resource> resources, java.util.List<RuntimeResource.Builder> childRuntimeResourceBuilders, RuntimeResource parent, java.lang.String regex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ResourceModelVisitor visitor)A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.java.util.List<RuntimeResource>getChildRuntimeResources()Get child runtime resources of this resource.java.util.List<? extends ResourceModelComponent>getComponents()Should return all existing resource model sub-components.java.lang.StringgetFullPathRegex()Get full regular expression of this runtime resource prefixed by regular expression of parent if present.RuntimeResourcegetParent()Get parent of this runtime resource.java.util.List<Resource>getParentResources()PathPatterngetPathPattern()Get path pattern for matching purposes.java.lang.StringgetRegex()Get regular expression of path pattern of this runtime resource.ResourceMethodgetResourceLocator()Return the resource locator of this resource.java.util.List<ResourceMethod>getResourceLocators()Get resource locators of allresourcesof this runtime resource.java.util.List<ResourceMethod>getResourceMethods()Get resource methods (excluding resource locators) of allresourcesof this runtime resource.java.util.List<Resource>getResources()Get resources creating this runtime resource.
-
-
-
Field Detail
-
COMPARATOR
public static final java.util.Comparator<RuntimeResource> COMPARATOR
Comparator of RuntimeResources based on rules respecting resource matching algorithm.
-
regex
private final java.lang.String regex
-
resourceMethods
private final java.util.List<ResourceMethod> resourceMethods
-
resourceLocators
private final java.util.List<ResourceMethod> resourceLocators
-
childRuntimeResources
private final java.util.List<RuntimeResource> childRuntimeResources
-
resources
private final java.util.List<Resource> resources
-
parent
private final RuntimeResource parent
-
pathPattern
private final PathPattern pathPattern
-
-
Constructor Detail
-
RuntimeResource
private RuntimeResource(java.util.List<Resource> resources, java.util.List<RuntimeResource.Builder> childRuntimeResourceBuilders, RuntimeResource parent, java.lang.String regex)
-
-
Method Detail
-
getChildRuntimeResources
public java.util.List<RuntimeResource> getChildRuntimeResources()
Get child runtime resources of this resource.- Returns:
- List of child runtime resource.
-
getRegex
public java.lang.String getRegex()
Get regular expression of path pattern of this runtime resource.- Returns:
- Matching regular expression.
-
getResourceMethods
public java.util.List<ResourceMethod> getResourceMethods()
Get resource methods (excluding resource locators) of allresourcesof this runtime resource.- Returns:
- List of resource methods.
-
getResourceLocators
public java.util.List<ResourceMethod> getResourceLocators()
Get resource locators of allresourcesof this runtime resource. Note that valid RuntimeResource should have only one resource locator. This method is used for validation purposes.- Returns:
- List of resource locators.
-
getResourceLocator
public ResourceMethod getResourceLocator()
Return the resource locator of this resource.- Returns:
- Resource locator of this runtime resource.
-
getParent
public RuntimeResource getParent()
Get parent of this runtime resource.- Returns:
- Parent runtime resource if this runtime resource is a child resource, null otherwise.
-
getPathPattern
public PathPattern getPathPattern()
Get path pattern for matching purposes.- Returns:
- Path pattern.
-
getFullPathRegex
public java.lang.String getFullPathRegex()
Get full regular expression of this runtime resource prefixed by regular expression of parent if present.- Returns:
- Full resource regular expression.
-
getParentResources
public java.util.List<Resource> getParentResources()
Return parentresourcesofresourcesfrom this runtime resource. The returned list is ordered so that the position of the parent resource in the returned list is the same as position of its child resource in list returned bygetResources(). Simply said the order of lists returned fromgetParentResources()andgetResources()from parent-child point of view is the same. If the resource has no parent then the elementnullis in the list.- Returns:
- Parent resource list with resources if this runtime resource is child resource or
nullelements if this runtime resource is the parent resource.
-
getResources
public java.util.List<Resource> getResources()
Get resources creating this runtime resource.- Returns:
- List of resources with same path regular expression which this resource is based on.
-
accept
public void accept(ResourceModelVisitor visitor)
Description copied from interface:ResourceModelComponentA component should call the visitor back with an appropriate visitor interface method to give it a chance to process.- Specified by:
acceptin interfaceResourceModelComponent- Parameters:
visitor- resource model visitor.
-
getComponents
public java.util.List<? extends ResourceModelComponent> getComponents()
Description copied from interface:ResourceModelComponentShould return all existing resource model sub-components.- Specified by:
getComponentsin interfaceResourceModelComponent- Returns:
- list of all sub-components
-
-