Return-Path: Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: (qmail 25310 invoked from network); 16 Jul 2010 07:47:14 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Jul 2010 07:47:14 -0000 Received: (qmail 11120 invoked by uid 500); 16 Jul 2010 07:47:14 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 11066 invoked by uid 500); 16 Jul 2010 07:47:13 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 11059 invoked by uid 99); 16 Jul 2010 07:47:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jul 2010 07:47:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jul 2010 07:47:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4C8482388903; Fri, 16 Jul 2010 07:45:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r964702 - in /incubator/lcf/trunk/modules/framework: core/org/apache/lcf/core/interfaces/ core/org/apache/lcf/core/system/ jetty-runner/org/apache/lcf/jettyrunner/ Date: Fri, 16 Jul 2010 07:45:45 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100716074545.4C8482388903@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Fri Jul 16 07:45:44 2010 New Revision: 964702 URL: http://svn.apache.org/viewvc?rev=964702&view=rev Log: Revise the construction methods for Configuration base class to be more JSON-agnostic, and less XML-centric. Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Configuration.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Specification.java incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCFConfiguration.java incubator/lcf/trunk/modules/framework/jetty-runner/org/apache/lcf/jettyrunner/Connectors.java Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java?rev=964702&r1=964701&r2=964702&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/ConfigParams.java Fri Jul 16 07:45:44 2010 @@ -22,7 +22,6 @@ import org.apache.lcf.core.interfaces.*; import java.util.*; import java.io.*; import org.apache.lcf.core.system.LCF; -import org.apache.lcf.core.common.XMLDoc; /** This class represents a set of configuration parameters, with structure, which is a generalized hierarchy of nodes that * can be interpreted by a repository or authority connector in an appropriate way. @@ -42,7 +41,7 @@ public class ConfigParams extends Config */ public ConfigParams() { - super(); + super("configuration"); } /** Constructor. @@ -51,7 +50,7 @@ public class ConfigParams extends Config */ public ConfigParams(Map map) { - super(); + super("configuration"); Iterator iter = map.keySet().iterator(); while (iter.hasNext()) { @@ -70,7 +69,7 @@ public class ConfigParams extends Config public ConfigParams(String xml) throws LCFException { - super(); + super("configuration"); fromXML(xml); } @@ -80,18 +79,10 @@ public class ConfigParams extends Config public ConfigParams(InputStream xmlstream) throws LCFException { - super(); + super("configuration"); fromXML(xmlstream); } - /** Return the root node type. - *@return the node type name. - */ - protected String getRootNodeLabel() - { - return "configuration"; - } - /** Create a new object of the appropriate class. */ protected Configuration createNew() Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Configuration.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Configuration.java?rev=964702&r1=964701&r2=964702&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Configuration.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Configuration.java Fri Jul 16 07:45:44 2010 @@ -36,7 +36,8 @@ public class Configuration protected static final String JSON_ATTRIBUTE = "_attribute_"; protected static final String JSON_VALUE = "_value_"; - + // The root node type + protected String rootNodeLabel; // The children protected ArrayList children = new ArrayList(); // Read-only flag @@ -46,34 +47,17 @@ public class Configuration */ public Configuration() { + rootNodeLabel = "data"; } - /** Construct from XML. - *@param xml is the input XML. - */ - public Configuration(String xml) - throws LCFException - { - fromXML(xml); - } - - /** Construct from XML. - *@param xmlstream is the input XML stream. Does NOT close the stream. + /** Constructor. + *@param rootNodeLabel is the root node label to use. */ - public Configuration(InputStream xmlstream) - throws LCFException + public Configuration(String rootNodeLabel) { - fromXML(xmlstream); + this.rootNodeLabel = rootNodeLabel; } - /** Return the root node type. - *@return the node type name. - */ - protected String getRootNodeLabel() - { - return "data"; - } - /** Create a new object of the appropriate class. *@return the newly-created configuration object. */ @@ -159,7 +143,7 @@ public class Configuration { XMLDoc doc = new XMLDoc(); // name of root node in definition - Object top = doc.createElement(null,getRootNodeLabel()); + Object top = doc.createElement(null,rootNodeLabel); // Now, go through all children int i = 0; while (i < children.size()) @@ -488,11 +472,11 @@ public class Configuration if (list.size() != 1) { - throw new LCFException("Bad xml - missing outer '"+getRootNodeLabel()+"' node - there are "+Integer.toString(list.size())+" nodes"); + throw new LCFException("Bad xml - missing outer '"+rootNodeLabel+"' node - there are "+Integer.toString(list.size())+" nodes"); } Object parent = list.get(0); - if (!doc.getNodeName(parent).equals(getRootNodeLabel())) - throw new LCFException("Bad xml - outer node is not '"+getRootNodeLabel()+"'"); + if (!doc.getNodeName(parent).equals(rootNodeLabel)) + throw new LCFException("Bad xml - outer node is not '"+rootNodeLabel+"'"); list.clear(); doc.processPath(list, "*", parent); Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Specification.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Specification.java?rev=964702&r1=964701&r2=964702&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Specification.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/interfaces/Specification.java Fri Jul 16 07:45:44 2010 @@ -20,7 +20,6 @@ package org.apache.lcf.core.interfaces; import java.util.*; import java.io.*; -import org.apache.lcf.core.common.XMLDoc; /** This class represents a specification, which is a generalized hierarchy of nodes that * can be interpreted by an appropriate connector in an appropriate way. @@ -33,7 +32,7 @@ public class Specification extends Confi */ public Specification() { - super(); + super("specification"); } /** Construct from XML. @@ -42,17 +41,10 @@ public class Specification extends Confi public Specification(String xml) throws LCFException { - super(xml); + super("specification"); + fromXML(xml); } - /** Return the root node type. - *@return the node type name. - */ - protected String getRootNodeLabel() - { - return "specification"; - } - /** Create a new object of the appropriate class. */ protected Configuration createNew() Modified: incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCFConfiguration.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCFConfiguration.java?rev=964702&r1=964701&r2=964702&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCFConfiguration.java (original) +++ incubator/lcf/trunk/modules/framework/core/org/apache/lcf/core/system/LCFConfiguration.java Fri Jul 16 07:45:44 2010 @@ -33,7 +33,7 @@ public class LCFConfiguration extends Co */ public LCFConfiguration() { - super(); + super("configuration"); } /** Construct from XML. @@ -42,17 +42,10 @@ public class LCFConfiguration extends Co public LCFConfiguration(InputStream xmlStream) throws LCFException { - super(xmlStream); + super("configuration"); + fromXML(xmlStream); } - /** Return the root node type. - *@return the node type name. - */ - protected String getRootNodeLabel() - { - return "configuration"; - } - /** Create a new object of the appropriate class. */ protected Configuration createNew() Modified: incubator/lcf/trunk/modules/framework/jetty-runner/org/apache/lcf/jettyrunner/Connectors.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/jetty-runner/org/apache/lcf/jettyrunner/Connectors.java?rev=964702&r1=964701&r2=964702&view=diff ============================================================================== --- incubator/lcf/trunk/modules/framework/jetty-runner/org/apache/lcf/jettyrunner/Connectors.java (original) +++ incubator/lcf/trunk/modules/framework/jetty-runner/org/apache/lcf/jettyrunner/Connectors.java Fri Jul 16 07:45:44 2010 @@ -33,7 +33,7 @@ public class Connectors extends Configur */ public Connectors() { - super(); + super("connectors"); } /** Construct from XML. @@ -42,17 +42,10 @@ public class Connectors extends Configur public Connectors(InputStream xmlStream) throws LCFException { - super(xmlStream); + super("connectors"); + fromXML(xmlStream); } - /** Return the root node type. - *@return the node type name. - */ - protected String getRootNodeLabel() - { - return "connectors"; - } - /** Create a new object of the appropriate class. */ protected Configuration createNew()