incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
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 GMT
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()



Mime
View raw message