[jboss-svn-commits] JBoss Common SVN: r2046 - in common-old/branches/Branch_1_0: . src/main/org/jboss/util/state src/main/org/jboss/util/state/xml tools/etc/buildmagic
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 20 17:11:14 EDT 2006
Author: dimitris at jboss.org
Date: 2006-09-20 17:11:05 -0400 (Wed, 20 Sep 2006)
New Revision: 2046
Modified:
common-old/branches/Branch_1_0/.classpath
common-old/branches/Branch_1_0/build-compile.xml
common-old/branches/Branch_1_0/build-thirdparty.xml
common-old/branches/Branch_1_0/src/main/org/jboss/util/state/State.java
common-old/branches/Branch_1_0/src/main/org/jboss/util/state/StateMachine.java
common-old/branches/Branch_1_0/src/main/org/jboss/util/state/xml/StateMachineParser.java
common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent
common-old/branches/Branch_1_0/tools/etc/buildmagic/version-info.xml
Log:
JBCOMMON-9, remove dom4j dependency
Modified: common-old/branches/Branch_1_0/.classpath
===================================================================
--- common-old/branches/Branch_1_0/.classpath 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/.classpath 2006-09-20 21:11:05 UTC (rev 2046)
@@ -7,7 +7,6 @@
<classpathentry kind="lib" path="/thirdparty/apache-slide/lib/webdavlib.jar"/>
<classpathentry kind="lib" path="/thirdparty/wutka-dtdparser/lib/dtdparser121.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-jaxme/lib/jaxmexs.jar"/>
- <classpathentry kind="lib" path="/thirdparty/dom4j/lib/dom4j.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-xerces/lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-xerces/lib/resolver.jar"/>
Modified: common-old/branches/Branch_1_0/build-compile.xml
===================================================================
--- common-old/branches/Branch_1_0/build-compile.xml 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/build-compile.xml 2006-09-20 21:11:05 UTC (rev 2046)
@@ -17,7 +17,6 @@
<path refid="apache.jaxme.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="apache.slide.classpath"/>
- <path refid="dom4j.dom4j.classpath"/>
<path refid="wutka.dtdparser.classpath"/>
<path refid="oswego.concurrent.classpath"/>
<path refid="sun.jaf.classpath"/>
Modified: common-old/branches/Branch_1_0/build-thirdparty.xml
===================================================================
--- common-old/branches/Branch_1_0/build-thirdparty.xml 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/build-thirdparty.xml 2006-09-20 21:11:05 UTC (rev 2046)
@@ -47,7 +47,6 @@
<componentref name="apache-xerces" version="2.7.1"/>
<componentref name="apache-log4j" version="1.2.8"/>
<componentref name="apache-slide" version="1.0.16"/>
- <componentref name="dom4j" version="1.6.1jboss"/>
<componentref name="wutka-dtdparser" version="1.2.1"/>
<componentref name="oswego-concurrent" version="1.3.4"/>
<componentref name="sun-jaf" version="1.0.2"/>
Modified: common-old/branches/Branch_1_0/src/main/org/jboss/util/state/State.java
===================================================================
--- common-old/branches/Branch_1_0/src/main/org/jboss/util/state/State.java 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/src/main/org/jboss/util/state/State.java 2006-09-20 21:11:05 UTC (rev 2046)
@@ -108,17 +108,15 @@
{
StringBuffer tmp = new StringBuffer("State(name=");
tmp.append(name);
- tmp.append("\n");
Iterator i = allowedTransitions.entrySet().iterator();
while( i.hasNext() )
{
Map.Entry e = (Map.Entry) i.next();
- tmp.append("\t on: ");
+ tmp.append("\n\t on: ");
tmp.append(e.getKey());
Transition t = (Transition) e.getValue();
tmp.append(" go to: ");
tmp.append(t.getTarget().getName());
- tmp.append('\n');
}
tmp.append(')');
return tmp.toString();
Modified: common-old/branches/Branch_1_0/src/main/org/jboss/util/state/StateMachine.java
===================================================================
--- common-old/branches/Branch_1_0/src/main/org/jboss/util/state/StateMachine.java 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/src/main/org/jboss/util/state/StateMachine.java 2006-09-20 21:11:05 UTC (rev 2046)
@@ -145,11 +145,10 @@
{
StringBuffer tmp = new StringBuffer("StateMachine[:\n");
tmp.append("\tCurrentState: "+currentState.getName());
- tmp.append('\n');
Iterator i = states.iterator();
while( i.hasNext() )
{
- tmp.append(i.next());
+ tmp.append('\n').append(i.next());
}
tmp.append(']');
return tmp.toString();
Modified: common-old/branches/Branch_1_0/src/main/org/jboss/util/state/xml/StateMachineParser.java
===================================================================
--- common-old/branches/Branch_1_0/src/main/org/jboss/util/state/xml/StateMachineParser.java 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/src/main/org/jboss/util/state/xml/StateMachineParser.java 2006-09-20 21:11:05 UTC (rev 2046)
@@ -1,41 +1,40 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.util.state.xml;
+import java.io.InputStream;
import java.net.URL;
-import java.util.Iterator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
-import org.dom4j.io.SAXReader;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-
import org.jboss.logging.Logger;
+import org.jboss.util.state.State;
import org.jboss.util.state.StateMachine;
-import org.jboss.util.state.State;
import org.jboss.util.state.Transition;
-import org.jboss.util.xml.JBossEntityResolver;
+import org.jboss.util.xml.DOMUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/** Parse an xml representation of a state machine. A sample document is:
@@ -69,6 +68,7 @@
</state-machine>
@author Scott.Stark at jboss.org
+ @author Dimitris.Andreadis at jboss.org
@version $Revision$
*/
public class StateMachineParser
@@ -76,62 +76,70 @@
private static Logger log = Logger.getLogger(StateMachineParser.class);
/**
- *
- * @param source
- * @return
- * @throws DocumentException
- */
- public StateMachine parse(URL source) throws DocumentException
+ * Parse an xml description of the state machine
+ */
+ public StateMachine parse(URL source) throws Exception
{
- SAXReader saxReader = new SAXReader();
- saxReader.setEntityResolver(new JBossEntityResolver());
+ // parse the XML document into a DOM structure
+ InputStream in = source.openConnection().getInputStream();
+ Element root = DOMUtils.parse(in);
- Document document = saxReader.read(source);
- Element root = document.getRootElement();
- String description = root.attributeValue("description");
- Iterator i = root.elementIterator();
+ String description = root.getAttribute("description");
HashMap nameToStateMap = new HashMap();
HashMap nameToTransitionsMap = new HashMap();
HashSet states = new HashSet();
State startState = null;
- while( i.hasNext() )
+
+ // parse states
+ NodeList stateList = root.getChildNodes();
+ for (int i = 0; i < stateList.getLength(); i++)
{
- Element stateElement = (Element) i.next();
- String stateName = stateElement.attributeValue("name");
- State s = new State(stateName);
- states.add(s);
- nameToStateMap.put(stateName, s);
- HashMap transitions = new HashMap();
- Iterator it = stateElement.elementIterator();
- while( it.hasNext() )
+ Node stateNode = stateList.item(i);
+ if (stateNode.getNodeName().equals("state"))
{
- Element transElement = (Element) it.next();
- String name = transElement.attributeValue("name");
- String targetName = transElement.attributeValue("target");
- transitions.put(name, targetName);
+ Element stateElement = (Element)stateNode;
+ String stateName = stateElement.getAttribute("name");
+ State s = new State(stateName);
+ states.add(s);
+ nameToStateMap.put(stateName, s);
+ HashMap transitions = new HashMap();
+
+ // parse transitions
+ NodeList transitionList = stateElement.getChildNodes();
+ for (int j = 0; j < transitionList.getLength(); j++)
+ {
+ Node transitionNode = transitionList.item(j);
+ if (transitionNode.getNodeName().equals("transition"))
+ {
+ Element transitionElement = (Element)transitionNode;
+ String name = transitionElement.getAttribute("name");
+ String targetName = transitionElement.getAttribute("target");
+ transitions.put(name, targetName);
+ }
+ }
+ nameToTransitionsMap.put(stateName, transitions);
+ if (Boolean.valueOf(stateElement.getAttribute("isStartState")) == Boolean.TRUE)
+ startState = s;
}
- nameToTransitionsMap.put(stateName, transitions);
- if( Boolean.valueOf(stateElement.attributeValue("isStartState")) == Boolean.TRUE )
- startState = s;
}
-
+
// Resolve all transition targets
Iterator transitions = nameToTransitionsMap.keySet().iterator();
StringBuffer resolveFailed = new StringBuffer();
- while( transitions.hasNext() )
+ while (transitions.hasNext())
{
- String stateName = (String) transitions.next();
- State s = (State) nameToStateMap.get(stateName);
- HashMap stateTransitions = (HashMap) nameToTransitionsMap.get(stateName);
+ String stateName = (String)transitions.next();
+ State s = (State)nameToStateMap.get(stateName);
+ HashMap stateTransitions = (HashMap)nameToTransitionsMap.get(stateName);
Iterator it = stateTransitions.keySet().iterator();
- while( it.hasNext() )
+ while (it.hasNext())
{
- String name = (String) it.next();
- String targetName = (String) stateTransitions.get(name);
- State target = (State) nameToStateMap.get(targetName);
- if( target == null )
+ String name = (String)it.next();
+ String targetName = (String)stateTransitions.get(name);
+ State target = (State)nameToStateMap.get(targetName);
+ if (target == null)
{
- String msg = "Failed to resolve target state: "+targetName+" for transition: "+name;
+ String msg = "Failed to resolve target state: " + targetName + " for transition: " + name;
resolveFailed.append(msg);
log.debug(msg);
}
@@ -140,8 +148,8 @@
}
}
- if( resolveFailed.length() > 0 )
- throw new DocumentException("Failed to resolve transition targets: "+resolveFailed);
+ if (resolveFailed.length() > 0)
+ throw new Exception("Failed to resolve transition targets: " + resolveFailed);
StateMachine sm = new StateMachine(states, startState, description);
return sm;
Modified: common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent
===================================================================
--- common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/tools/etc/buildmagic/buildmagic.ent 2006-09-20 21:11:05 UTC (rev 2046)
@@ -103,7 +103,7 @@
<property name="version.major" value="1"/>
<property name="version.minor" value="0"/>
<property name="version.revision" value="0"/>
- <property name="version.tag" value="CR1"/>
+ <property name="version.tag" value="GA"/>
<property name="version.name" value="Zion"/>
<!-- This must be set to the CVS tag for any release -->
<property name="version.cvstag" value="Branch_1_0"/>
Modified: common-old/branches/Branch_1_0/tools/etc/buildmagic/version-info.xml
===================================================================
--- common-old/branches/Branch_1_0/tools/etc/buildmagic/version-info.xml 2006-09-20 13:50:53 UTC (rev 2045)
+++ common-old/branches/Branch_1_0/tools/etc/buildmagic/version-info.xml 2006-09-20 21:11:05 UTC (rev 2046)
@@ -17,7 +17,7 @@
<property name="version.major" value="1"/>
<property name="version.minor" value="0"/>
<property name="version.revision" value="0"/>
- <property name="version.tag" value="CR1"/>
+ <property name="version.tag" value="GA"/>
<property name="version.name" value="Zion"/>
<!-- This must be set to the CVS tag for any release -->
<property name="version.cvstag" value="Branch_1_0"/>
More information about the jboss-svn-commits
mailing list