|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.management.Attribute org.archive.crawler.settings.Type org.archive.crawler.settings.ComplexType
public abstract class ComplexType
Superclass of all configurable modules.
This class is in many ways the heart of the settings framework. All modules
that should be configurable extends this class or one of its subclasses.
All subclasses of this class will automatically conform to the
JMX DynamicMBean. You could then use the getMBeanInfo()
method to
investigate which attributes this module supports and then use the
getAttribute(String)
and setAttribute(Attribute)
methods to
alter the attributes values.
Because the settings framework supports per domain/host settings there is
also available context sensitive versions of the DynamicMBean methods.
If you use the non context sensitive methods, it is the global settings
that will be altered.
Nested Class Summary | |
---|---|
(package private) class |
ComplexType.Context
|
class |
ComplexType.MBeanAttributeInfoIterator
Iterator over all MBeanAttributeInfo for this ComplexType |
Field Summary | |
---|---|
protected java.util.List<Type> |
definition
|
protected java.util.Map<java.lang.String,Type> |
definitionMap
|
Constructor Summary | |
---|---|
ComplexType(java.lang.String name,
java.lang.String description)
Creates a new instance of ComplexType. |
Method Summary | |
---|---|
Type |
addElement(CrawlerSettings settings,
Type type)
|
Type |
addElementToDefinition(Type type)
Add a new attribute to the definition of this ComplexType. |
Constraint.FailedCheck |
checkValue(CrawlerSettings settings,
java.lang.String attributeName,
java.lang.Object value)
Check an attribute to see if it fulfills all the constraints set on the definition of this attribute. |
(package private) Constraint.FailedCheck |
checkValue(CrawlerSettings settings,
java.lang.String attributeName,
Type definition,
java.lang.Object value)
|
void |
earlyInitialize(CrawlerSettings settings)
This method can be overridden in subclasses to do local initialisation. |
java.lang.String |
getAbsoluteName()
Get the absolute name of this ComplexType. |
java.lang.Object |
getAttribute(java.lang.Object context,
java.lang.String name)
Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object. |
java.lang.Object |
getAttribute(java.lang.String name)
Obtain the value of a specific attribute from the crawl order. |
java.lang.Object |
getAttribute(java.lang.String name,
CrawlURI uri)
Obtain the value of a specific attribute that is valid for a specific CrawlURI. |
javax.management.MBeanAttributeInfo |
getAttributeInfo(CrawlerSettings settings,
java.lang.String name)
Get the effective Attribute info for an element of this type from a settings object. |
javax.management.MBeanAttributeInfo |
getAttributeInfo(java.lang.String name)
Get the Attribute info for an element of this type from the global settings. |
ComplexType.MBeanAttributeInfoIterator |
getAttributeInfoIterator(java.lang.Object context)
Get an Iterator over all the MBeanAttributeInfo in this ComplexType. |
javax.management.AttributeList |
getAttributes(java.lang.String[] name)
|
protected DataContainer |
getDataContainerRecursive(ComplexType.Context context)
Get the active data container for this ComplexType for a specific settings object. |
protected DataContainer |
getDataContainerRecursive(ComplexType.Context context,
java.lang.String key)
Get the active data container for this ComplexType for a specific settings object. |
java.lang.Object |
getDefaultValue()
The default value for this type |
(package private) Type |
getDefinition(java.lang.String attributeName)
Get the content type definition for an attribute. |
java.lang.String |
getDescription()
Get the description of this type The description should be suitable for showing in a user interface. |
Type |
getElementFromDefinition(java.lang.String name)
Get an element definition from this complex type. |
java.lang.Object[] |
getLegalValues()
Get the legal values for this type. |
java.lang.Object |
getLocalAttribute(CrawlerSettings settings,
java.lang.String name)
Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object. |
javax.management.MBeanInfo |
getMBeanInfo()
|
javax.management.MBeanInfo |
getMBeanInfo(java.lang.Object context)
|
ComplexType |
getParent()
Get the parent of this ComplexType. |
protected java.lang.String[] |
getPreservedFields()
Get a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one. |
(package private) ComplexType.Context |
getSettingsFromObject(java.lang.Object o)
Get settings object valid for a URI. |
(package private) ComplexType.Context |
getSettingsFromObject(java.lang.Object o,
java.lang.String attributeName)
Get settings object valid for a URI. |
SettingsHandler |
getSettingsHandler()
|
java.lang.Object |
getUncheckedAttribute(java.lang.Object context,
java.lang.String name)
Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object. |
java.lang.Object |
getValue()
Returns this object. |
CrawlerSettings |
globalSettings()
Get the global settings object (aka order). |
java.lang.Object |
invoke(java.lang.String arg0,
java.lang.Object[] arg1,
java.lang.String[] arg2)
|
boolean |
isInitialized()
Returns true if this ComplexType is initialized. |
boolean |
isOverridden(CrawlerSettings settings,
java.lang.String name)
Returns true if an element is overridden for this settings object. |
java.util.Iterator |
iterator(java.lang.Object context)
Get an Iterator over all the attributes in this ComplexType. |
protected Type |
removeElementFromDefinition(java.lang.String name)
This method can only be called before the ComplexType has been initialized. |
protected void |
setAsOrder(SettingsHandler settingsHandler)
|
void |
setAttribute(javax.management.Attribute attribute)
Set the value of a specific attribute of the ComplexType. |
void |
setAttribute(CrawlerSettings settings,
javax.management.Attribute attribute)
Set the value of a specific attribute of the ComplexType. |
javax.management.AttributeList |
setAttributes(javax.management.AttributeList attributes)
|
void |
setDescription(java.lang.String string)
Set the description of this ComplexType The description should be suitable for showing in a user interface. |
protected void |
setPreservedFields(java.lang.String[] preservedFields)
Set a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one. |
java.lang.String |
toString()
|
java.lang.Object |
unsetAttribute(CrawlerSettings settings,
java.lang.String name)
Unset an attribute on a per host level. |
Methods inherited from class org.archive.crawler.settings.Type |
---|
addConstraint, equals, getConstraints, getLegalValueType, isExpertSetting, isOverrideable, isTransient, setExpertSetting, setLegalValueType, setOverrideable, setTransient |
Methods inherited from class javax.management.Attribute |
---|
getName, hashCode |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.util.List<Type> definition
protected final java.util.Map<java.lang.String,Type> definitionMap
Constructor Detail |
---|
public ComplexType(java.lang.String name, java.lang.String description)
name
- the name of the element.description
- the description of the element.Method Detail |
---|
protected void setAsOrder(SettingsHandler settingsHandler) throws javax.management.InvalidAttributeValueException
javax.management.InvalidAttributeValueException
public CrawlerSettings globalSettings()
public Type addElement(CrawlerSettings settings, Type type) throws javax.management.InvalidAttributeValueException
javax.management.InvalidAttributeValueException
protected void setPreservedFields(java.lang.String[] preservedFields)
preservedFields
- array of attributenames to preserve.protected java.lang.String[] getPreservedFields()
protected DataContainer getDataContainerRecursive(ComplexType.Context context)
context
- Context from which we get settings.
protected DataContainer getDataContainerRecursive(ComplexType.Context context, java.lang.String key) throws javax.management.AttributeNotFoundException
context
- the settings object for which the DataContainer
is active.key
- the key to look for.
javax.management.AttributeNotFoundException
public SettingsHandler getSettingsHandler()
public java.lang.String getAbsoluteName()
ComplexType.Context getSettingsFromObject(java.lang.Object o, java.lang.String attributeName)
CrawlURI
and then tries to get the
settings object from it. If this fails, then the global settings object
is returned.
If the requested attribute is not set on this settings
object it tries its parent until it gets a settings object where this
attribute is set is found. If nothing is found, global settings is
returned.
o
- possible CrawlURI
.attributeName
- the attribute that should have a value set on the
returned settings object.
ComplexType.Context getSettingsFromObject(java.lang.Object o)
CrawlURI
and then tries to get the settings object from it. If this fails, then
the global settings object is returned.
o
- possible CrawlURI
.
public boolean isOverridden(CrawlerSettings settings, java.lang.String name) throws javax.management.AttributeNotFoundException
settings
- the settings object to investigate.name
- the name of the element to check.
javax.management.AttributeNotFoundException
- if element doesn't exist.public java.lang.Object getAttribute(java.lang.String name) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException
getAttribute
in interface javax.management.DynamicMBean
name
- the name of the attribute to be retrieved.
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
public java.lang.Object getAttribute(java.lang.String name, CrawlURI uri) throws javax.management.AttributeNotFoundException
name
- the name of the attribute to be retrieved.uri
- the CrawlURI that this attribute should be valid for.
javax.management.AttributeNotFoundException
getAttribute(Object settings, String name)
public java.lang.Object getAttribute(java.lang.Object context, java.lang.String name) throws javax.management.AttributeNotFoundException
This method will first try to get a settings object from the supplied context, then try to look up the attribute from this settings object. If it is not found it will traverse the settings up to the order and as a last resort deliver the default value.
context
- the object to get the settings from.name
- the name of the attribute to be retrieved.
javax.management.AttributeNotFoundException
CrawlerSettings
public java.lang.Object getUncheckedAttribute(java.lang.Object context, java.lang.String name)
This method will first try to get a settings object from the supplied context, then try to look up the attribute from this settings object. If it is not found it will traverse the settings up to the order and as a last resort deliver the default value.
The only difference from the getAttribute(Object, String)
is
that this method doesn't throw any checked exceptions. If an undefined
attribute is requested from a ComplexType, it is concidered a bug and a
runtime exception is thrown instead.
context
- the object to get the settings from.name
- the name of the attribute to be retrieved.
java.lang.IllegalArgumentException
getAttribute(Object, String)
,
CrawlerSettings
public java.lang.Object getLocalAttribute(CrawlerSettings settings, java.lang.String name) throws javax.management.AttributeNotFoundException
null
and not try to investigate the hierarchy of settings.
settings
- the CrawlerSettings object to search for this attribute.name
- the name of the attribute to be retrieved.
javax.management.AttributeNotFoundException
- is thrown if the attribute doesn't
exist.CrawlerSettings
public final void setAttribute(javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException
setAttribute
in interface javax.management.DynamicMBean
attribute
- The identification of the attribute to be set and the
value it is to be set to.
javax.management.AttributeNotFoundException
- is thrown if there is no attribute
with this name.
javax.management.InvalidAttributeValueException
- is thrown if the attribute is of
wrong type and cannot be converted to the right type.
javax.management.MBeanException
- this is to conform to the MBean specification, but
this exception is never thrown, though this might change in the
future.
javax.management.ReflectionException
- this is to conform to the MBean specification, but
this exception is never thrown, though this might change in the
future.DynamicMBean.setAttribute(javax.management.Attribute)
public final void setAttribute(CrawlerSettings settings, javax.management.Attribute attribute) throws javax.management.InvalidAttributeValueException, javax.management.AttributeNotFoundException
settings
- the settings object for which this attributes value is validattribute
- The identification of the attribute to be set and the
value it is to be set to.
javax.management.AttributeNotFoundException
- is thrown if there is no attribute
with this name.
javax.management.InvalidAttributeValueException
- is thrown if the attribute is of
wrong type and cannot be converted to the right type.DynamicMBean.setAttribute(javax.management.Attribute)
Type getDefinition(java.lang.String attributeName)
attributeName
- the name of the attribute to get definition for.
public Constraint.FailedCheck checkValue(CrawlerSettings settings, java.lang.String attributeName, java.lang.Object value)
settings
- the CrawlerSettings object for which this check was
executed.attributeName
- the name of the attribute to check.value
- the value to check.
Constraint.FailedCheck checkValue(CrawlerSettings settings, java.lang.String attributeName, Type definition, java.lang.Object value)
public java.lang.Object unsetAttribute(CrawlerSettings settings, java.lang.String name) throws javax.management.AttributeNotFoundException
settings
- the settings object for which the attribute should be
unset.name
- the name of the attribute.
javax.management.AttributeNotFoundException
- is thrown if the attribute name
doesn't exist.public javax.management.AttributeList getAttributes(java.lang.String[] name)
getAttributes
in interface javax.management.DynamicMBean
public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
setAttributes
in interface javax.management.DynamicMBean
public java.lang.Object invoke(java.lang.String arg0, java.lang.Object[] arg1, java.lang.String[] arg2) throws javax.management.MBeanException, javax.management.ReflectionException
invoke
in interface javax.management.DynamicMBean
javax.management.MBeanException
javax.management.ReflectionException
public javax.management.MBeanInfo getMBeanInfo()
getMBeanInfo
in interface javax.management.DynamicMBean
public javax.management.MBeanInfo getMBeanInfo(java.lang.Object context)
public javax.management.MBeanAttributeInfo getAttributeInfo(CrawlerSettings settings, java.lang.String name)
settings
- the settings object for which the Attribute info is
effective.name
- the name of the element to get the attribute for.
public javax.management.MBeanAttributeInfo getAttributeInfo(java.lang.String name)
name
- the name of the element to get the attribute for.
public java.lang.String getDescription()
getDescription
in class Type
public ComplexType getParent()
public void setDescription(java.lang.String string)
string
- the description to set for this type.public java.lang.Object getDefaultValue()
Type
getDefaultValue
in class Type
public Type addElementToDefinition(Type type)
type
- the type to add.
public Type getElementFromDefinition(java.lang.String name)
name
- name of element to get.
protected Type removeElementFromDefinition(java.lang.String name)
name
- Name of element to remove.
public void earlyInitialize(CrawlerSettings settings)
settings
- the CrawlerSettings object for which this
complex type is defined.public boolean isInitialized()
public java.lang.Object[] getLegalValues()
Type
getLegalValues
in class Type
public java.lang.Object getValue()
Attribute
.
getValue
in class javax.management.Attribute
Attribute.getValue()
public java.util.Iterator iterator(java.lang.Object context)
context
- the context for which this set of attributes are valid.
public ComplexType.MBeanAttributeInfoIterator getAttributeInfoIterator(java.lang.Object context)
context
- the context for which this set of MBeanAttributeInfo are valid.
public java.lang.String toString()
toString
in class javax.management.Attribute
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |