com.sourceforge.jpatterns.patterns
Class PatternBase

java.lang.Object
  extended by com.sourceforge.jpatterns.patterns.PatternBase
All Implemented Interfaces:
IJPattern, com.zmicer.utils.model.ICheckable, Serializable
Direct Known Subclasses:
JPConfigImpl, JPFactoryImpl

public abstract class PatternBase
extends Object
implements IJPattern

The abstratc class to implement the IJPattern - provides base facilities for all the IJPattern implementations. todo [zmicer]: tests redesign - move from JPFactoryImpl to this class test $Author:: $
$Rev:: $
$Date:: $

See Also:
Serialized Form

Field Summary
static org.apache.log4j.Logger LOG
          Logger instance.
protected  com.sourceforge.jpatterns.schema.CastorSectionType m_castorSection
          The castor config object used for the storing business info.
protected  JPatternsConfigsBean m_configBean
          The config bean - is a wrapper under the Factory castor config bean.
 
Constructor Summary
PatternBase()
           
 
Method Summary
 boolean check()
           
abstract  boolean checkCastorConfig(com.sourceforge.jpatterns.schema.CastorSectionType castorSectionType)
          Make the check this type of the castor config fits the pattern
protected  String getActualScope(String scope, com.sourceforge.jpatterns.schema.CastorSectionType section)
          Get the actual scope.
 void init(com.sourceforge.jpatterns.schema.CastorSectionType castorSectionType, JPatternsConfigsBean configBean)
          Perform the initialization of the JPatterns with the appropriate child instance of CastorSectionType castor config class and the JPatternsConfigsBean bean storing all the consumer configuration.
protected  void logAndThrow(String message)
          Log the message and then throw it.
protected  com.sourceforge.jpatterns.schema.Item retrieveItem(Object nameStorage, String scope)
          Retrieve the item object from the castor factory storing in this model factory object using the provided information: the name of the business item and the scope provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Logger instance.


m_castorSection

protected com.sourceforge.jpatterns.schema.CastorSectionType m_castorSection
The castor config object used for the storing business info.
For now we use only the name of the section which is get from this castor object, still it is necessary for us in any case - potentially we could start use it but not the JPatternsConfigsBean which is the JPatterns consumer configuration entry point.


m_configBean

protected JPatternsConfigsBean m_configBean
The config bean - is a wrapper under the Factory castor config bean. We would use it for all the "get" operations. It is convenient as allow us access the sections and business items using the path: section name and business item name.

Constructor Detail

PatternBase

public PatternBase()
Method Detail

checkCastorConfig

public abstract boolean checkCastorConfig(com.sourceforge.jpatterns.schema.CastorSectionType castorSectionType)
Description copied from interface: IJPattern
Make the check this type of the castor config fits the pattern

Specified by:
checkCastorConfig in interface IJPattern
Parameters:
castorSectionType - the castor config object which is the root configuration storage for all the patterns (according to the XSD scheme)
Returns:
true if this fits to the pattern implementation nature, and false otherwise
See Also:
IJPattern.checkCastorConfig(com.sourceforge.jpatterns.schema.CastorSectionType)

init

public void init(com.sourceforge.jpatterns.schema.CastorSectionType castorSectionType,
                 JPatternsConfigsBean configBean)
Description copied from interface: IJPattern
Perform the initialization of the JPatterns with the appropriate child instance of CastorSectionType castor config class and the JPatternsConfigsBean bean storing all the consumer configuration.

Specified by:
init in interface IJPattern
Parameters:
castorSectionType - castor config object of CastorSectionType class. Can not be null (otherwise IllegalArgumentException would appear).
configBean - JPatternsConfigsBean config bean with all the JPatterns consumer configuration. Can not be null (otherwise IllegalArgumentException would appear).
See Also:
IJPattern.init(com.sourceforge.jpatterns.schema.CastorSectionType, com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigsBean)

check

public boolean check()
Specified by:
check in interface com.zmicer.utils.model.ICheckable
See Also:
ICheckable.check()

getActualScope

protected String getActualScope(String scope,
                                com.sourceforge.jpatterns.schema.CastorSectionType section)
Get the actual scope. In the case the provided scope variable is not null - it would be returned, otherwise - the scope of the provided CastorSectionType.

Parameters:
scope - the scope variable to be checked. Could be null, in this case we would deal with the scope of the section type
section - the castor section scope of which would be used (in any case this object and its scope can not be null)
Returns:
the actual scope to be used

retrieveItem

protected com.sourceforge.jpatterns.schema.Item retrieveItem(Object nameStorage,
                                                             String scope)
Retrieve the item object from the castor factory storing in this model factory object using the provided information: the name of the business item and the scope provided. In the case scope is blank we use the default scope defined at the castor factory type. note [zmicer]: the CastorNameScopePriorityType item is got here is validated (it has not blank name). The composition of validation could be adjusted.

Parameters:
nameStorage - the name of the Item to be retrieved. Can not be null (otherwise IllegalArgumentException would appear).
scope - the scope we need to use, could be null.
Returns:
the Item we would use later for the concrete IJPFactory implementation

logAndThrow

protected void logAndThrow(String message)
                    throws JPConfigException
Log the message and then throw it. todo [zmicer]: possible it would be adjusted as it should throw the exception of the two types - depending on the category

Parameters:
message - the not emopty message to be thrown and logged
Throws:
JPConfigException - always, using message


Copyright © 2007 jzmicer.team. All Rights Reserved.