forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r702472 - in /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl: XMLStructurer.java XMLStructurerAxiom.java
Date Tue, 07 Oct 2008 13:13:01 GMT
Author: thorsten
Date: Tue Oct  7 06:12:59 2008
New Revision: 702472

URL: http://svn.apache.org/viewvc?rev=702472&view=rev
Log:
FOR-1118 
Using interface map instead a concret implementation (HashMap) where ever possible. Further
updating the usage of contracts and the new propertz shrink.

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

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=702472&r1=702471&r2=702472&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
Tue Oct  7 06:12:59 2008
@@ -8,6 +8,7 @@
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.Map;
 
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLStreamConstants;
@@ -40,11 +41,22 @@
   private LinkedHashMap<String, LinkedHashSet<XMLEvent>> resultTree = new LinkedHashMap<String,
LinkedHashSet<XMLEvent>>();
 
   private String currentPath = "";
+  
+  private Map<String, Object> param;
 
-  public XMLStructurer(DispatcherBean config) {
+  private boolean shrink;
+
+  public XMLStructurer(DispatcherBean config, Map<String, Object> defaultProperties)
{
     this.contractRep = new ContractFactory(config);
     this.resolver = config.getResolver();
     this.allowXmlProperties = config.isAllowXmlProperties();
+    this.shrink = config.isShrink();
+    if (defaultProperties == null){
+      param = new HashMap<String, Object>();
+    }else{
+      param = defaultProperties;
+    }
+    
   }
 
   /*
@@ -134,12 +146,11 @@
       case XMLStreamConstants.START_ELEMENT:
         elementName = reader.getLocalName();
         if (elementName.equals(Captions.CONTRACT_ELEMENT)) {
-          log.debug("Path " + currentPath);
+          log.debug("CONTRACT " + elementName);
           processContract(reader);
         } else if (elementName.equals(Captions.HOOK_ELEMENT)) {
           log.debug("HOOKS " + elementName);
           processHook(reader, true);
-          log.info("HOOKS transformation NOT YET IMPLEMENTED");
         }
         break;
 
@@ -223,15 +234,14 @@
       dataStream = resolver.resolve(data);
     }
     Contract contract = contractRep.resolve(name);
-
-    HashMap<String, ?> param = new HashMap();
+    Map<String, Object> localParams = new HashMap<String, Object>(param);
     while (process) {
       int event = reader.next();
       switch (event) {
       case XMLStreamConstants.END_ELEMENT:
         elementName = reader.getLocalName();
         if (elementName.equals(Captions.CONTRACT_ELEMENT)) {
-          InputStream resultStream = contract.execute(dataStream, param);
+          InputStream resultStream = contract.execute(dataStream, localParams);
           StreamHelper.closeStream(dataStream);
           processContractResult(resultStream);
           StreamHelper.closeStream(resultStream);
@@ -242,7 +252,7 @@
       case XMLStreamConstants.START_ELEMENT:
         elementName = reader.getLocalName();
         if (elementName.equals(Captions.PROPERTY_ELEMENT)) {
-          processProperty(reader, param);
+          processProperty(reader, localParams);
         }
         break;
 
@@ -317,6 +327,9 @@
     }
     XMLEventAllocator allocator = getEventAllocator();
     XMLEvent currentEvent = allocator.allocate(reader);
+    if (start){
+      currentEvent = createStartElementNS(reader, currentEvent);
+    }
     pathElement.add(currentEvent);
     resultTree.put(currentPath, pathElement);
   }
@@ -348,7 +361,7 @@
     }
   }
 
-  private void processProperty(XMLStreamReader reader, HashMap param)
+  private void processProperty(XMLStreamReader reader, Map<String, Object> localParam)
       throws XMLStreamException {
     String propertyName = null, propertyValue = null;
     // Get attribute names
@@ -361,7 +374,7 @@
         propertyValue = reader.getAttributeValue(i);
       }
     }
-    addProperties(reader, param, propertyName, propertyValue,allowXmlProperties);
+    addProperties(reader, localParam, propertyName, propertyValue,allowXmlProperties, shrink);
   }
 
   private void openPaths(XMLEventWriter writer, String[] tokenizer)

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=702472&r1=702471&r2=702472&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
Tue Oct  7 06:12:59 2008
@@ -9,6 +9,7 @@
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -50,11 +51,21 @@
 
   private OMElement root;
 
-  public XMLStructurerAxiom(DispatcherBean config) {
+  private Map<String, Object> param;
+
+  private boolean shrink;
+
+  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();
     this.factory = OMAbstractFactory.getOMFactory();
+    if (defaultProperties == null){
+      param = new HashMap<String, Object>();
+    }else{
+      param = defaultProperties;
+    }
   }
 
   /*
@@ -240,15 +251,15 @@
       dataStream = resolver.resolve(data);
     }
     Contract contract = contractRep.resolve(name);
-    HashMap<String, ?> param = new HashMap();
     Iterator <OMNode> properties = component.getChildrenWithName(qIt(Captions.NS,Captions.PROPERTY_ELEMENT));
+    Map<String, Object> localParams = new HashMap<String, Object>(param);
     while (properties.hasNext()) {
       OMNode node = (OMNode) properties.next();
       if (isElement(node)){
-        processProperty((OMElement) node, param);
+        processProperty((OMElement) node, localParams);
       }
     }
-    InputStream resultStream = contract.execute(dataStream, param);
+    InputStream resultStream = contract.execute(dataStream, localParams);
     StreamHelper.closeStream(dataStream);
     processContractResult(resultStream, pathNode);
     StreamHelper.closeStream(resultStream);
@@ -327,12 +338,12 @@
    * @param param
    * @throws XMLStreamException
    */
-  private void processProperty(OMElement properties, HashMap param)
+  private void processProperty(OMElement properties, Map param)
       throws XMLStreamException {
     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);
+    addProperties(properties.getXMLStreamReader(), param, propertyName, propertyValue, allowXmlProperties,
shrink);
   }
 
   



Mime
View raw message