org.apache.cocoon.components.validation.impl
Class DefaultValidator

java.lang.Object
  extended by org.apache.cocoon.components.validation.impl.AbstractValidator
      extended by org.apache.cocoon.components.validation.impl.DefaultValidator
All Implemented Interfaces:
Disposable, Initializable, Configurable, Contextualizable, LogEnabled, Serviceable, ServiceSelector, ThreadSafe, Validator
Direct Known Subclasses:
CachingValidator

public class DefaultValidator
extends AbstractValidator
implements ServiceSelector, ThreadSafe, Contextualizable, Initializable, Disposable, Configurable

The default implementation of the Validator interface provides core management for a number of SchemaParser instances.

Given the simplicity of this implementation, only SchemaParsers implementing the ThreadSafe interface can be managed, and they can be accessed directly (via its name) through the methods specified by the ServiceSelector interface.

That said, normally selection would occur using the methods declared by the AbstractValidator class and implemented here.


Field Summary
 
Fields inherited from class org.apache.cocoon.components.validation.impl.AbstractValidator
logger, manager, resolver
 
Fields inherited from interface org.apache.cocoon.components.validation.Validator
GRAMMAR_ISO_SCHEMATRON, GRAMMAR_RELAX_CORE, GRAMMAR_RELAX_NG, GRAMMAR_RELAX_NS, GRAMMAR_SCHEMATRON, GRAMMAR_TREX, GRAMMAR_XML_DTD, GRAMMAR_XML_SCHEMA, ROLE
 
Constructor Summary
DefaultValidator()
          Create a new DefaultValidator instance.
 
Method Summary
 void configure(Configuration conf)
          Configure this instance.
 void contextualize(Context context)
          Contextualize this instance.
 void dispose()
          Dispose of this instance.
 void initialize()
          Initialize this instance.
 boolean isSelectable(Object selectionKey)
          Check whether a subcomponent (SchemaParser) associated with the specified selection key (its configured "name") is selectable in this ServiceSelector instance.
protected  SchemaParser lookupParserByGrammar(String grammar)
          Attempt to acquire a SchemaParser interface able to understand the grammar language specified.
protected  SchemaParser lookupParserByName(String name)
          Attempt to acquire a SchemaParser interface associated with the specified instance name.
 void release(Object component)
          Release a subcomponent (SchemaParser) instance previously selected from this ServiceSelector instance.
protected  void releaseParser(SchemaParser parser)
          Release a previously acquired SchemaParser instance back to its original component manager.
 Object select(Object selectionKey)
          Select a subcomponent (SchemaParser) associated with the specified selection key (its configured "name").
 
Methods inherited from class org.apache.cocoon.components.validation.impl.AbstractValidator
detectGrammar, enableLogging, getSchema, getValidationHandler, getValidationHandler, getValidationHandler, getValidationHandler, getValidationHandler, getValidationHandler, getValidationHandler, getValidationHandler, service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultValidator

public DefaultValidator()

Create a new DefaultValidator instance.

Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException

Contextualize this instance.

Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

configure

public void configure(Configuration conf)
               throws ConfigurationException

Configure this instance.

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

initialize

public void initialize()
                throws Exception

Initialize this instance.

Specified by:
initialize in interface Initializable
Throws:
Exception

dispose

public void dispose()

Dispose of this instance.

All sub-components initialized previously will be disposed of when this method is called.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractValidator

lookupParserByGrammar

protected SchemaParser lookupParserByGrammar(String grammar)

Attempt to acquire a SchemaParser interface able to understand the grammar language specified.

Specified by:
lookupParserByGrammar in class AbstractValidator
Parameters:
grammar - the grammar language that must be understood by the returned SchemaParser
Returns:
a SchemaParser instance or null if none was found able to understand the specified grammar language.

lookupParserByName

protected SchemaParser lookupParserByName(String name)

Attempt to acquire a SchemaParser interface associated with the specified instance name.

Specified by:
lookupParserByName in class AbstractValidator
Parameters:
name - the name associated with the SchemaParser to be returned.
Returns:
a SchemaParser instance or null if none was found.

releaseParser

protected void releaseParser(SchemaParser parser)

Release a previously acquired SchemaParser instance back to its original component manager.

This method is supplied in case solid implementations of this class relied on the ServiceManager to manage SchemaParsers instances.

Specified by:
releaseParser in class AbstractValidator
Parameters:
parser - the SchemaParser whose instance is to be released.

select

public Object select(Object selectionKey)
              throws ServiceException

Select a subcomponent (SchemaParser) associated with the specified selection key (its configured "name").

Specified by:
select in interface ServiceSelector
Throws:
ServiceException

isSelectable

public boolean isSelectable(Object selectionKey)

Check whether a subcomponent (SchemaParser) associated with the specified selection key (its configured "name") is selectable in this ServiceSelector instance.

Specified by:
isSelectable in interface ServiceSelector

release

public void release(Object component)

Release a subcomponent (SchemaParser) instance previously selected from this ServiceSelector instance.

Specified by:
release in interface ServiceSelector


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.