forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r703385 - in /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl: AbstractXmlStructurer.java XMLStructurer.java XMLStructurerAxiom.java
Date Fri, 10 Oct 2008 10:28:23 GMT
Author: thorsten
Date: Fri Oct 10 03:28:21 2008
New Revision: 703385

URL: http://svn.apache.org/viewvc?rev=703385&view=rev
Log:
Extracting abstract xml/stax structurer class from the common parameters and the init method.

Added:
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java
  (with props)
Modified:
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurerAxiom.java

Added: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java?rev=703385&view=auto
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java
(added)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java
Fri Oct 10 03:28:21 2008
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.dispatcher.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.forrest.dispatcher.api.Resolver;
+import org.apache.forrest.dispatcher.api.Structurer;
+import org.apache.forrest.dispatcher.config.DispatcherBean;
+import org.apache.forrest.dispatcher.factories.ContractFactory;
+import org.apache.forrest.dispatcher.impl.helper.Loggable;
+import org.apache.forrest.dispatcher.impl.helper.StAX;
+
+public abstract class AbstractXmlStructurer extends Loggable  implements Structurer {
+
+  protected final Resolver resolver;
+  protected StAX stax;
+  protected final boolean allowXmlProperties;
+  protected final ContractFactory contractRep;
+  protected boolean shrink;
+  protected Map<String, Object> param;
+
+  public AbstractXmlStructurer(DispatcherBean config, Map<String, Object> defaultProperties)
{
+    this.contractRep = new ContractFactory(config);
+    this.stax = config.getStaxHelper();
+    this.resolver = config.getResolver();
+    this.allowXmlProperties = config.isAllowXmlProperties();
+    this.shrink = config.isShrink();
+    if (defaultProperties == null){
+      param = new HashMap<String, Object>();
+    }else{
+      param = defaultProperties;
+    }
+  }
+
+}
\ No newline at end of file

Propchange: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/AbstractXmlStructurer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java?rev=703385&r1=703384&r2=703385&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
(original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurer.java
Fri Oct 10 03:28:21 2008
@@ -20,36 +20,20 @@
 import javax.xml.stream.util.XMLEventAllocator;
 
 import org.apache.forrest.dispatcher.api.Contract;
-import org.apache.forrest.dispatcher.api.Resolver;
 import org.apache.forrest.dispatcher.api.Structurer;
 import org.apache.forrest.dispatcher.config.DispatcherBean;
 import org.apache.forrest.dispatcher.exception.ContractException;
 import org.apache.forrest.dispatcher.exception.DispatcherException;
-import org.apache.forrest.dispatcher.factories.ContractFactory;
 import org.apache.forrest.dispatcher.impl.helper.Captions;
-import org.apache.forrest.dispatcher.impl.helper.Loggable;
-import org.apache.forrest.dispatcher.impl.helper.StAX;
 import org.apache.forrest.dispatcher.impl.helper.StreamHelper;
 import org.apache.forrest.dispatcher.utils.CommonString;
 
-public class XMLStructurer extends Loggable implements Structurer {
-
-  private final Resolver resolver;
-  
-  private StAX stax;
-
-  private final boolean allowXmlProperties;
-
-  private final ContractFactory contractRep;
+public class XMLStructurer extends AbstractXmlStructurer {
 
   private LinkedHashMap<String, LinkedHashSet<XMLEvent>> resultTree = new LinkedHashMap<String,
LinkedHashSet<XMLEvent>>();
 
   private String currentPath = "";
   
-  private Map<String, Object> param;
-
-  private boolean shrink;
-
   /**
    * The Streaming API for XML (StAX) is a Java based API for pull-parsing XML.
    *<p>
@@ -62,17 +46,7 @@
    * @param defaultProperties
    */
   public XMLStructurer(DispatcherBean config, Map<String, Object> defaultProperties)
{
-    this.contractRep = new ContractFactory(config);
-    this.stax = config.getStaxHelper();
-    this.resolver = config.getResolver();
-    this.allowXmlProperties = config.isAllowXmlProperties();
-    this.shrink = config.isShrink();
-    if (defaultProperties == null){
-      param = new HashMap<String, Object>();
-    }else{
-      param = defaultProperties;
-    }
-    
+    super(config, defaultProperties);
   }
 
   /*

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurerAxiom.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurerAxiom.java?rev=703385&r1=703384&r2=703385&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurerAxiom.java
(original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XMLStructurerAxiom.java
Fri Oct 10 03:28:21 2008
@@ -22,36 +22,22 @@
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.forrest.dispatcher.api.Contract;
-import org.apache.forrest.dispatcher.api.Resolver;
-import org.apache.forrest.dispatcher.api.Structurer;
 import org.apache.forrest.dispatcher.config.DispatcherBean;
 import org.apache.forrest.dispatcher.exception.ContractException;
 import org.apache.forrest.dispatcher.exception.DispatcherException;
-import org.apache.forrest.dispatcher.factories.ContractFactory;
 import org.apache.forrest.dispatcher.impl.helper.AXIOMXPathCreate;
 import org.apache.forrest.dispatcher.impl.helper.Captions;
-import org.apache.forrest.dispatcher.impl.helper.StAX;
 import org.apache.forrest.dispatcher.impl.helper.StreamHelper;
 import org.jaxen.JaxenException;
 
-public class XMLStructurerAxiom extends StAX implements Structurer {
+public class XMLStructurerAxiom extends AbstractXmlStructurer {
 
   private static final String PATH_PREFIX = "/result";
 
-  private final Resolver resolver;
-
-  private final boolean allowXmlProperties;
-
-  private final ContractFactory contractRep;
-
   private OMFactory factory;
 
   private OMElement root;
 
-  private Map<String, Object> param;
-
-  private boolean shrink;
-
   /**
    * AXIOM stands for AXis Object Model 
    * (also known as OM - Object Model) and refers to the XML
@@ -70,16 +56,8 @@
    * pass later to the contract transformation.
    */
   public XMLStructurerAxiom(DispatcherBean config, Map<String, Object> defaultProperties)
{
-    this.contractRep = new ContractFactory(config);
-    this.resolver = config.getResolver();
-    this.allowXmlProperties = config.isAllowXmlProperties();
-    this.shrink = config.isShrink();
+    super(config, defaultProperties);
     this.factory = OMAbstractFactory.getOMFactory();
-    if (defaultProperties == null){
-      param = new HashMap<String, Object>();
-    }else{
-      param = defaultProperties;
-    }
   }
 
   /*
@@ -104,7 +82,7 @@
       /*
        * Preparing the processing.
        */
-      XMLStreamReader reader = getReader(structurerStream);
+      XMLStreamReader reader = stax.getReader(structurerStream);
       StAXOMBuilder builder = new StAXOMBuilder(reader);
       OMElement strucuturer = builder.getDocumentElement();
       Iterator<OMNode> structures = strucuturer.getChildrenWithName(qIt(
@@ -311,7 +289,7 @@
   @SuppressWarnings("unchecked")
   private void processContractResult(InputStream resultStream,
       OMElement pathNode) throws XMLStreamException, JaxenException {
-    XMLStreamReader contractResultReader = getReader(resultStream);
+    XMLStreamReader contractResultReader = stax.getReader(resultStream);
     StAXOMBuilder builder = new StAXOMBuilder(contractResultReader);
     OMElement content = builder.getDocumentElement();
     /*
@@ -381,7 +359,7 @@
     String propertyName = null, propertyValue = null;
     propertyName = properties.getAttributeValue(qIt(Captions.NAME_ATT));
     propertyValue = properties.getAttributeValue(qIt(Captions.VALUE_ATT));
-    addProperties(properties.getXMLStreamReader(), param, propertyName, propertyValue, allowXmlProperties,
shrink);
+    stax.addProperties(properties.getXMLStreamReader(), param, propertyName, propertyValue,
allowXmlProperties, shrink);
   }
 
   



Mime
View raw message