org.jboss.cache.factories
Class XmlConfigurationParser

java.lang.Object
  extended by org.jboss.cache.factories.XmlConfigurationParser

public class XmlConfigurationParser
extends Object

Reads in XMLconfiguration files and spits out a Configuration object. When deployed as a JBoss MBean, this role is performed by the JBoss Microcontainer. This class is only used internally in unit tests or within CacheFactory implementations for standalone JBoss Cache usage.

Since:
2.00.
Author:
Manik Surtani (manik@jboss.org), Galder Zamarreno

Field Summary
static String ATTR
           
static String NAME
           
 
Constructor Summary
XmlConfigurationParser()
           
 
Method Summary
protected static org.jboss.cache.factories.XmlConfigurationParser.ParsedAttributes extractAttributes(Element source)
           
protected  InputStream getAsInputStreamFromClassLoader(String filename)
           
protected  Element getMBeanElement(Element root)
           
protected  void handleRemovedAttributes(org.jboss.cache.factories.XmlConfigurationParser.ParsedAttributes attributes)
          Check for and remove any attributes that were supported in the 1.x releases and no longer are.
static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
           
static CacheLoaderConfig parseCacheLoaderConfig(Element element)
           
static String parseClusterConfigXml(Element config)
          Parses the cluster config which is used to start a JGroups channel
 Configuration parseConfiguration(Element configurationRoot)
           
static EvictionConfig parseEvictionConfig(Element element)
           
static void parseEvictionPolicyConfig(Element element, EvictionPolicyConfig target)
           
static EvictionRegionConfig parseEvictionRegionConfig(Element element, String defaultEvictionClass, int defaultQueueCapacity)
           
 Configuration parseFile(String filename)
          Parses an XML file and returns a new configuration.
 Configuration parseStream(InputStream stream)
          Parses an input stream containing XML text and returns a new configuration.
protected static void setValues(Object target, Map<?,?> attribs, boolean isXmlAttribs)
           
protected  void setXmlValues(Configuration conf, Map<String,Element> attribs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR

public static final String ATTR
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values
Constructor Detail

XmlConfigurationParser

public XmlConfigurationParser()
Method Detail

parseFile

public Configuration parseFile(String filename)
Parses an XML file and returns a new configuration. This method attempts to look for the file name passed in on the classpath. If not found, it will search for the file on the file system instead, treating the name as an absolute path.

Parameters:
filename - the name of the XML file to parse.
Returns:
a configured Configuration object representing the configuration in the file

parseStream

public Configuration parseStream(InputStream stream)
Parses an input stream containing XML text and returns a new configuration.

Parameters:
stream - input stream to parse. SHould not be null.
Returns:
a configured Configuration object representing the configuration in the stream
Since:
2.1.0

parseConfiguration

public Configuration parseConfiguration(Element configurationRoot)

handleRemovedAttributes

protected void handleRemovedAttributes(org.jboss.cache.factories.XmlConfigurationParser.ParsedAttributes attributes)
Check for and remove any attributes that were supported in the 1.x releases and no longer are. Log a WARN or throw a ConfigurationException if any are found. Which is done depends on the attribute:

Parameters:
attributes -

getAsInputStreamFromClassLoader

protected InputStream getAsInputStreamFromClassLoader(String filename)

getMBeanElement

protected Element getMBeanElement(Element root)

setValues

protected static void setValues(Object target,
                                Map<?,?> attribs,
                                boolean isXmlAttribs)

setXmlValues

protected void setXmlValues(Configuration conf,
                            Map<String,Element> attribs)

parseBuddyReplicationConfig

public static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)

parseCacheLoaderConfig

public static CacheLoaderConfig parseCacheLoaderConfig(Element element)

parseEvictionConfig

public static EvictionConfig parseEvictionConfig(Element element)

parseEvictionRegionConfig

public static EvictionRegionConfig parseEvictionRegionConfig(Element element,
                                                             String defaultEvictionClass,
                                                             int defaultQueueCapacity)

parseEvictionPolicyConfig

public static void parseEvictionPolicyConfig(Element element,
                                             EvictionPolicyConfig target)

parseClusterConfigXml

public static String parseClusterConfigXml(Element config)
Parses the cluster config which is used to start a JGroups channel

Parameters:
config - an old-style JGroups protocol config String

extractAttributes

protected static org.jboss.cache.factories.XmlConfigurationParser.ParsedAttributes extractAttributes(Element source)


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.