Author: swd847
Date: 2010-03-08 20:52:36 -0500 (Mon, 08 Mar 2010)
New Revision: 12126
Removed:
modules/xml/trunk/core/src/test/resources/META-INF/seam-beans.xml
Modified:
modules/xml/trunk/core/src/main/java/org/jboss/seam/xml/bootstrap/ClassPathXmlDocumentProvider.java
modules/xml/trunk/core/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorBean.java
modules/xml/trunk/core/src/test/resources/META-INF/beans.xml
modules/xml/trunk/docs/en-US/xml-general.xml
Log:
changed xml extensions to allow use of beans.xml
Modified:
modules/xml/trunk/core/src/main/java/org/jboss/seam/xml/bootstrap/ClassPathXmlDocumentProvider.java
===================================================================
---
modules/xml/trunk/core/src/main/java/org/jboss/seam/xml/bootstrap/ClassPathXmlDocumentProvider.java 2010-03-08
23:27:43 UTC (rev 12125)
+++
modules/xml/trunk/core/src/main/java/org/jboss/seam/xml/bootstrap/ClassPathXmlDocumentProvider.java 2010-03-09
01:52:36 UTC (rev 12126)
@@ -27,7 +27,7 @@
public class ClassPathXmlDocumentProvider implements XmlDocumentProvider
{
- static final String[] DEFAULT_RESOURCES = { "seam-beans.xml",
"META-INF/seam-beans.xml", "WEB-INF/seam-beans.xml" };
+ static final String[] DEFAULT_RESOURCES = { "seam-beans.xml",
"META-INF/seam-beans.xml", "WEB-INF/seam-beans.xml" ,
"META-INF/beans.xml", "WEB-INF/beans.xml"};
final String[] resources;
@@ -113,34 +113,53 @@
e.printStackTrace();
}
}
- if (!iterator.hasNext())
- {
- return null;
- }
+
try
{
- final URL url = iterator.next();
- return new XmlDocument()
+ while(iterator.hasNext())
{
-
- public InputSource getInputSource()
+ final URL url = iterator.next();
+ //ignore empty files
+ InputStream test = null;
+ try
{
- try
+ test = url.openStream();
+ if(test.available() == 0)
+ {
+ break;
+ }
+ }
+ finally
+ {
+ if(test != null)
{
- stream = url.openStream();
- return new InputSource(stream);
+ test.close();
}
- catch (IOException e)
+ }
+
+ return new XmlDocument()
+ {
+
+ public InputSource getInputSource()
{
- throw new RuntimeException(e);
+ try
+ {
+ stream = url.openStream();
+ return new InputSource(stream);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
}
- }
-
- public String getFileUrl()
- {
- return url.toString();
- }
- };
+
+ public String getFileUrl()
+ {
+ return url.toString();
+ }
+ };
+ }
+ return null;
}
catch (Exception e)
{
Modified:
modules/xml/trunk/core/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorBean.java
===================================================================
---
modules/xml/trunk/core/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorBean.java 2010-03-08
23:27:43 UTC (rev 12125)
+++
modules/xml/trunk/core/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorBean.java 2010-03-09
01:52:36 UTC (rev 12126)
@@ -4,13 +4,10 @@
*/
package org.jboss.seam.xml.test.interceptor;
-import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class InterceptorBean
{
-
- @AroundInvoke
public Object myMethod(InvocationContext context) throws Exception
{
return context.proceed().toString() + " world";
Modified: modules/xml/trunk/core/src/test/resources/META-INF/beans.xml
===================================================================
--- modules/xml/trunk/core/src/test/resources/META-INF/beans.xml 2010-03-08 23:27:43 UTC
(rev 12125)
+++ modules/xml/trunk/core/src/test/resources/META-INF/beans.xml 2010-03-09 01:52:36 UTC
(rev 12126)
@@ -1,9 +1,24 @@
<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:s="urn:seam:core"
+ xmlns:test="urn:java:org.jboss.seam.xml.test.interceptor"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<interceptors>
<class>org.jboss.seam.xml.test.interceptor.InterceptorBean</class>
</interceptors>
+
+ <test:InterceptorBinding>
+ <s:InterceptorBinding/>
+ </test:InterceptorBinding>
+
+ <test:InterceptorBean>
+ <s:override/>
+ <s:Interceptor/>
+ <test:InterceptorBinding/>
+ <test:myMethod>
+ <s:AroundInvoke/>
+ </test:myMethod>
+ </test:InterceptorBean>
</beans>
Deleted: modules/xml/trunk/core/src/test/resources/META-INF/seam-beans.xml
===================================================================
--- modules/xml/trunk/core/src/test/resources/META-INF/seam-beans.xml 2010-03-08 23:27:43
UTC (rev 12125)
+++ modules/xml/trunk/core/src/test/resources/META-INF/seam-beans.xml 2010-03-09 01:52:36
UTC (rev 12126)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="urn:seam:core"
- xmlns:test="urn:java:org.jboss.seam.xml.test.interceptor">
-
- <test:InterceptorBinding>
- <InterceptorBinding/>
- </test:InterceptorBinding>
-
- <test:InterceptorBean>
- <override/>
- <Interceptor/>
- <test:InterceptorBinding/>
- <test:myMethod>
- <!-- AroundInvoke does not actually work due to what appears to be a weld
bug -->
- <AroundInvoke/>
- </test:myMethod>
- </test:InterceptorBean>
-
-</beans>
\ No newline at end of file
Modified: modules/xml/trunk/docs/en-US/xml-general.xml
===================================================================
--- modules/xml/trunk/docs/en-US/xml-general.xml 2010-03-08 23:27:43 UTC (rev 12125)
+++ modules/xml/trunk/docs/en-US/xml-general.xml 2010-03-09 01:52:36 UTC (rev 12126)
@@ -10,18 +10,23 @@
<section>
<title>Configuration</title>
- <para>No special configuration is required to use seam-xml, all that is
required is to include the jar file in your deployment. </para>
+ <para>No special configuration is required to use seam-xml, all that is
required is to include the jar file and the weld extensions jar in your deployment.
</para>
</section>
<section>
<title>Getting Started</title>
- <para>By default XML files are discovered from the classpath. The extension
looks for an XML file named <literal>seam-bean.xml</literal> in the following
locations: </para>
+ <para>By default XML files are discovered from the classpath. The extension
looks for an XML file in the following locations:</para>
<itemizedlist>
- <listitem><para>The root of an archive</para></listitem>
-
<listitem><para><literal>WEB-INF</literal></para></listitem>
-
<listitem><para><literal>META-INF</literal></para></listitem>
+
<listitem><para><literal>/WEB-INF/beans.xml</literal></para></listitem>
+
<listitem><para><literal>/META-INF/beans.xml</literal></para></listitem>
+ <listitem><para>/seam-beans.xml</para></listitem>
+
<listitem><para><literal>/WEB-INF/seam-beans.xml</literal></para></listitem>
+
<listitem><para><literal>/META-INF/seam-beans.xml</literal></para></listitem>
</itemizedlist>
+ <para>The syntax for beans.xml and seam-beans.xml is slightly different. Unless
otherwise noted all example in this document
+ use the seam-beans.xml format. Using beans.xml may cause problems with some JSR-299
implmentations.</para>
+
<para>Lets start with a simple example</para>
<programlisting>
<![CDATA[
@@ -353,6 +358,44 @@
</section>
<section>
+ <title>Using beans.xml instead of seam-beans.xml</title>
+ <para>
+ As the format is beans.xml is defined by the specification the format is
slightly different:
+ </para>
+ <programlisting>
+ <![CDATA[
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:s="urn:seam:core"
+ xmlns:test="urn:java:org.jboss.seam.xml.test.interceptor"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+ <interceptors>
+ <class>org.jboss.seam.xml.test.interceptor.InterceptorBean</class>
+ </interceptors>
+
+ <test:InterceptorBinding>
+ <s:InterceptorBinding/>
+ </test:InterceptorBinding>
+
+ <test:InterceptorBean>
+ <s:override/>
+ <s:Interceptor/>
+ <test:InterceptorBinding/>
+ <test:myMethod>
+ <s:AroundInvoke/>
+ </test:myMethod>
+ </test:InterceptorBean>
+
+</beans>
+]]>
+ </programlisting>
+ <para>As you can see from the example above the beans.xml uses a different
root namespace, so all elements in <literal>urn:seam:core </literal>
+ must be qualified. It is possible that some JST-299 implementations will not
support this, so for maximum compatibility it is recommended that
+ seam-beans.xml be used instead.</para>
+ </section>
+
+ <section>
<title>More Information</title>
<para>For further information look at the units tests in the seam-xml
distribution, also the JSR-299
public review draft section on XML Configuration was the base for this extension,