org.glassfish.jersey.server.model
Class ComponentModelValidator

java.lang.Object
  extended by org.glassfish.jersey.server.model.ComponentModelValidator
All Implemented Interfaces:
ResourceModelVisitor

public final class ComponentModelValidator
extends Object
implements ResourceModelVisitor

A resource model validator that checks the given resource model. This base resource model validator class implements the visitor pattern to traverse through all the resource model components to check validity of a resource model.

This validator maintains a list of all the issues found in the model. That way all the resource model components can be validated in a single call to the validate(...) method and collect all the validation issues from the model.

To check a single resource class, the the Resource builder(...) can be used to create a resource model. validate(ResourceModelComponent) method then populates the issue list, which could be then obtained by the getIssueList(). Unless the list is explicitly cleared, a subsequent calls to the validate method will add new items to the list, so that it can be used to build the issue list for more than one resource. To clear the list, the cleanIssueList() method should be called.

Author:
Jakub Podlesak (jakub.podlesak at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
ComponentModelValidator(ServiceLocator locator)
           
 
Method Summary
 void cleanIssueList()
          Removes all issues from the current issue list.
 boolean fatalIssuesFound()
          Convenience method to see if there were fatal issues found.
 List<ResourceModelIssue> getIssueList()
          Returns a list of issues found after validate(org.glassfish.jersey.server.model.ResourceModelComponent) method has been invoked.
 void validate(ResourceModelComponent component)
          The validate method validates a component and adds possible issues found to it's list.
 void visitChildResource(Resource resource)
          Start visiting a single child resource model.
 void visitInvocable(Invocable invocable)
          Visit a single resource method invocable model.
 void visitMethodHandler(MethodHandler methodHandler)
          Visit a single resource method handler model.
 void visitResource(Resource resource)
          Start visiting a single resource model.
 void visitResourceHandlerConstructor(HandlerConstructor constructor)
          Process a resource method handler constructor.
 void visitResourceMethod(ResourceMethod method)
          Visit a single resource method model.
 void visitResourceModel(ResourceModel resourceModel)
          Process a resource model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentModelValidator

public ComponentModelValidator(ServiceLocator locator)
Method Detail

getIssueList

public List<ResourceModelIssue> getIssueList()
Returns a list of issues found after validate(org.glassfish.jersey.server.model.ResourceModelComponent) method has been invoked.

Returns:
a non-null list of issues.

fatalIssuesFound

public boolean fatalIssuesFound()
Convenience method to see if there were fatal issues found.

Returns:
true if there are any fatal issues present in the current issue list.

cleanIssueList

public void cleanIssueList()
Removes all issues from the current issue list. The method could be used to re-use the same ResourceModelValidator for another resource model.


validate

public void validate(ResourceModelComponent component)
The validate method validates a component and adds possible issues found to it's list. The list of issues could be then retrieved via getIssueList method.

Parameters:
component - resource model component.

visitInvocable

public void visitInvocable(Invocable invocable)
Description copied from interface: ResourceModelVisitor
Visit a single resource method invocable model.

Specified by:
visitInvocable in interface ResourceModelVisitor
Parameters:
invocable - resource method invocable model.

visitResource

public void visitResource(Resource resource)
Description copied from interface: ResourceModelVisitor
Start visiting a single resource model.

Specified by:
visitResource in interface ResourceModelVisitor
Parameters:
resource - resource model.

visitChildResource

public void visitChildResource(Resource resource)
Description copied from interface: ResourceModelVisitor
Start visiting a single child resource model.

Specified by:
visitChildResource in interface ResourceModelVisitor
Parameters:
resource - child resource model.

visitResourceMethod

public void visitResourceMethod(ResourceMethod method)
Description copied from interface: ResourceModelVisitor
Visit a single resource method model.

Specified by:
visitResourceMethod in interface ResourceModelVisitor
Parameters:
method - resource method model.

visitMethodHandler

public void visitMethodHandler(MethodHandler methodHandler)
Description copied from interface: ResourceModelVisitor
Visit a single resource method handler model.

Specified by:
visitMethodHandler in interface ResourceModelVisitor
Parameters:
methodHandler - resource method handler model.

visitResourceHandlerConstructor

public void visitResourceHandlerConstructor(HandlerConstructor constructor)
Description copied from interface: ResourceModelVisitor
Process a resource method handler constructor. Typically a constructor of a JAX-RS annotated resource class.

Specified by:
visitResourceHandlerConstructor in interface ResourceModelVisitor
Parameters:
constructor - resource method handler constructor.

visitResourceModel

public void visitResourceModel(ResourceModel resourceModel)
Description copied from interface: ResourceModelVisitor
Process a resource model.

Specified by:
visitResourceModel in interface ResourceModelVisitor
Parameters:
resourceModel - resource model.


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