[jbosscache-commits] JBoss Cache SVN: r6217 - in core/trunk/src: test/java/org/jboss/cache/config/parsing and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Jul 8 12:49:09 EDT 2008
Author: mircea.markus
Date: 2008-07-08 12:49:09 -0400 (Tue, 08 Jul 2008)
New Revision: 6217
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java
Log:
added javadocs where missing
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache.config.parsing;
import org.w3c.dom.Document;
@@ -22,7 +43,11 @@
*/
public class ConfigFilesConvertor
{
-
+ /**
+ * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
+ * as <b>is</b>. Transformation is performed according to the <b>xsltFile</b>. The xslt file is looked up using a
+ * {@link org.jboss.cache.config.parsing.FileLookup}
+ */
public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception
{
InputStream xsltInStream = new FileLookup().lookupFile(xsltFile);
@@ -38,6 +63,11 @@
xsltInStream.close();
}
+ /**
+ * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
+ * as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he xslt
+ * file are looked up using a {@link org.jboss.cache.config.parsing.FileLookup}
+ */
public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception
{
InputStream stream = new FileLookup().lookupFile(inputFile);
@@ -49,26 +79,13 @@
}
}
- private Transformer getTransformer(InputStream xsltInStream)
- throws TransformerConfigurationException
- {
- TransformerFactory tFactory = TransformerFactory.newInstance();
- StreamSource stylesource = new StreamSource(xsltInStream);
- return tFactory.newTransformer(stylesource);
- }
-
- private Document getInputDocument(InputStream is)
- throws ParserConfigurationException, SAXException, IOException
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- return builder.parse(is);
- }
-
+ /**
+ * usage : java org.jboss.cache.config.parsing.ConfigFilesConvertor -Dsource=config-2.x.xml -Ddestination=config-3.x.xnl
+ */
public static void main(String[] argv) throws Exception
{
String sourceName = System.getProperty("source");
- if (sourceName == null)
+ if (sourceName == null)
{
System.err.println("Missing property 'source'.");
System.exit(1);
@@ -88,10 +105,26 @@
ConfigFilesConvertor convertor = new ConfigFilesConvertor();
File destination = new File(destinationName);
if (!destination.exists()) destination.createNewFile();
-
+
FileInputStream is = new FileInputStream(oldConfig);
FileOutputStream fos = new FileOutputStream(destinationName);
convertor.parse(is, fos, "config2to3.xslt");
is.close();
}
+
+ private Transformer getTransformer(InputStream xsltInStream)
+ throws TransformerConfigurationException
+ {
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ StreamSource stylesource = new StreamSource(xsltInStream);
+ return tFactory.newTransformer(stylesource);
+ }
+
+ private Document getInputDocument(InputStream is)
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse(is);
+ }
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/FileLookup.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -21,13 +21,12 @@
*/
package org.jboss.cache.config.parsing;
-import org.jboss.cache.config.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.InputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.InputStream;
/**
* Holds the logic of looking up a file, in the following sequence:
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache.config.parsing;
import org.w3c.dom.Attr;
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache.config.parsing;
import org.w3c.dom.Element;
@@ -5,6 +26,8 @@
import java.util.Map;
/**
+ * Helper class for holding attributes defined in configuration file.
+ *
* @author Mircea.Markus at jboss.com
* @since 3.0
*/
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache.config.parsing;
import org.apache.commons.logging.Log;
@@ -4,21 +25,19 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.*;
import org.jboss.cache.config.parsing.element.BuddyElementParser;
+import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.lock.IsolationLevel;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -27,7 +46,7 @@
* Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object.
* By default this class uses a validating parser (configurable).
* <p/>
- * Implementation node: this class is stateful and one instance should be used for parsing a single configuration file.
+ * Implementation note: this class is stateful and one instance should be used for parsing a single configuration file.
* todo mmarkus - allow disabling parser validation through -Djbc.config.validation=false
*
* @author Mircea.Markus at jboss.com
@@ -74,14 +93,12 @@
}
/**
- * 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.
+ * Parses an XML file and returns a new configuration.
+ * For looking up the file, {@link org.jboss.cache.config.parsing.FileLookup} is used.
+ * @see org.jboss.cache.config.parsing.FileLookup
*/
- //todo mmarkus this is duplicated code from 2x parser, extract it in an FileLookup class
public Configuration parseFile(String filename)
{
-
InputStream is = new FileLookup().lookupFile(filename);
if (is == null)
{
@@ -90,13 +107,18 @@
return parseStream(is);
}
-
+ /**
+ * Similar to {@link #parseFile(String)}, just that it does not create the input stream.
+ */
public Configuration parseStream(InputStream configStream)
{
readRoot(configStream);
return processElements();
}
+ /**
+ * Root should be the <b>jbosscache</b> element in the configuration file.
+ */
public Configuration parseElement(Element root)
{
this.root = root;
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.cache.config.parsing;
import org.w3c.dom.Element;
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -41,7 +41,7 @@
}
/**
- *
+ * test an happy flow.
*/
public void testNormalConfig()
{
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -10,10 +10,13 @@
import java.util.List;
/**
+ * Parses a 'normal' configuration file and makes sure that the resulted <b>Configuration</b> object has
+ * the expected state.
+ *
* @author Mircea.Markus at jboss.com
* @since 3.0
*/
- at Test(groups = "unit")
+ at Test(groups = "functional")
public class XmlConfigurationParserTest
{
Configuration config;
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java 2008-07-08 16:29:58 UTC (rev 6216)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlSchemaTest.java 2008-07-08 16:49:09 UTC (rev 6217)
@@ -10,12 +10,12 @@
import java.util.List;
/**
- * Class that tests how schema works.
+ * Tests that all the xml file used within tests are correct with respect to the schema definition.
*
* @author Mircea.Markus at jboss.com
* @since 3.0
*/
- at Test (groups = "unit")
+ at Test (groups = "functional")
public class XmlSchemaTest
{
public static final String BASE_DIR_FOR_CONFIG = "./configs";
@@ -50,6 +50,14 @@
}
}
+ /**
+ *
+ */
+ public void testValidationDisbaledOnSystemProperty()
+ {
+
+ }
+
private static class EceptionCountingErrorHanlder implements ErrorHandler
{
List<SAXParseException> exceptionList = new ArrayList<SAXParseException>();
More information about the jbosscache-commits
mailing list