Author: swd847
Date: 2010-02-28 23:47:41 -0500 (Sun, 28 Feb 2010)
New Revision: 12084
Added:
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/AdvancedTimer.java
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/DependencyTest.java
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/SimpleTimer.java
modules/xml/trunk/src/test/resources/org/jboss/seam/xml/test/dependency/
modules/xml/trunk/src/test/resources/org/jboss/seam/xml/test/dependency/dependency-beans.xml
Modified:
modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
Log:
added simple conditional deployment to seam-xml. This allows you to prevent beans being
installed if their dependencies are not on the classpath.
Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-03-01
01:07:15 UTC (rev 12083)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/XmlItemType.java 2010-03-01
04:47:41 UTC (rev 12084)
@@ -6,5 +6,5 @@
public enum XmlItemType
{
- CLASS, METHOD, FIELD, ANNOTATION, VALUE, VETO, ENTRY, KEY, DEPENDENCY, PARAMETER,
ARRAY;
+ CLASS, METHOD, FIELD, ANNOTATION, VALUE, VETO, ENTRY, KEY, DEPENDENCY, PARAMETER,
ARRAY, OVERRIDE;
}
Modified:
modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
===================================================================
---
modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-03-01
01:07:15 UTC (rev 12083)
+++
modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java 2010-03-01
04:47:41 UTC (rev 12084)
@@ -6,6 +6,7 @@
import org.jboss.seam.xml.model.ArrayXmlItem;
import org.jboss.seam.xml.model.ClassXmlItem;
+import org.jboss.seam.xml.model.DependsXmlItem;
import org.jboss.seam.xml.model.EntryXmlItem;
import org.jboss.seam.xml.model.KeyXmlItem;
import org.jboss.seam.xml.model.ParameterXmlItem;
@@ -58,6 +59,11 @@
{
return new VetoXmlItem(parent, node.getDocument(), node.getLineNo());
}
+ else if (item.equals("depends"))
+ {
+ return new DependsXmlItem(parent, node.getInnerText(), node.getDocument(),
node.getLineNo());
+ }
+
// now deal with primitive types
Class primType = null;
Added:
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/AdvancedTimer.java
===================================================================
--- modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/AdvancedTimer.java
(rev 0)
+++
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/AdvancedTimer.java 2010-03-01
04:47:41 UTC (rev 12084)
@@ -0,0 +1,11 @@
+package org.jboss.seam.xml.test.dependency;
+
+
+public class AdvancedTimer extends SimpleTimer
+{
+
+ public String getType()
+ {
+ return "advanced";
+ }
+}
Added:
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/DependencyTest.java
===================================================================
---
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/DependencyTest.java
(rev 0)
+++
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/DependencyTest.java 2010-03-01
04:47:41 UTC (rev 12084)
@@ -0,0 +1,21 @@
+package org.jboss.seam.xml.test.dependency;
+
+import org.jboss.seam.xml.test.AbstractXMLTest;
+import org.testng.annotations.Test;
+
+public class DependencyTest extends AbstractXMLTest
+{
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return "dependency-beans.xml";
+ }
+
+ @Test
+ public void testDependencies()
+ {
+ SimpleTimer timer = getReference(SimpleTimer.class);
+ assert timer.getType().equals("simple");
+ }
+}
Added:
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/SimpleTimer.java
===================================================================
--- modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/SimpleTimer.java
(rev 0)
+++
modules/xml/trunk/src/test/java/org/jboss/seam/xml/test/dependency/SimpleTimer.java 2010-03-01
04:47:41 UTC (rev 12084)
@@ -0,0 +1,9 @@
+package org.jboss.seam.xml.test.dependency;
+
+public class SimpleTimer
+{
+ public String getType()
+ {
+ return "simple";
+ }
+}
Added:
modules/xml/trunk/src/test/resources/org/jboss/seam/xml/test/dependency/dependency-beans.xml
===================================================================
---
modules/xml/trunk/src/test/resources/org/jboss/seam/xml/test/dependency/dependency-beans.xml
(rev 0)
+++
modules/xml/trunk/src/test/resources/org/jboss/seam/xml/test/dependency/dependency-beans.xml 2010-03-01
04:47:41 UTC (rev 12084)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Beans xmlns="urn:seam:core"
+ xmlns:test="urn:java:org.jboss.seam.xml.test.dependency">
+ <veto>
+ <test:AdvancedTimer/>
+ </veto>
+
+ <test:AdvancedTimer>
+ <Specializes/>
+
<depends>com.advanced.timer.server.that.is.not.on.the.ClassPath</depends>
+ </test:AdvancedTimer>
+
+</Beans>
\ No newline at end of file
Show replies by date