[webbeans-commits] Webbeans SVN: r2618 - examples/trunk/tomcat/WebContent/WEB-INF.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-23 20:37:10 -0400 (Thu, 23 Apr 2009)
New Revision: 2618
Added:
examples/trunk/tomcat/WebContent/WEB-INF/jetty-env.xml
Log:
add configuration to bind Manager to JNDI in Jetty
Added: examples/trunk/tomcat/WebContent/WEB-INF/jetty-env.xml
===================================================================
--- examples/trunk/tomcat/WebContent/WEB-INF/jetty-env.xml (rev 0)
+++ examples/trunk/tomcat/WebContent/WEB-INF/jetty-env.xml 2009-04-24 00:37:10 UTC (rev 2618)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
+ "http://jetty.mortbay.org/configure.dtd">
+<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
+ <New id="appManager" class="org.mortbay.jetty.plus.naming.Resource">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>app/Manager</Arg>
+ <Arg>
+ <New class="javax.naming.Reference">
+ <Arg>javax.inject.manager.Manager</Arg>
+ <Arg>org.jboss.webbeans.resources.ManagerObjectFactory</Arg>
+ <Arg/>
+ </New>
+ </Arg>
+ </New>
+</Configure>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2617 - doc/trunk/reference/en-US.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-23 18:52:45 -0400 (Thu, 23 Apr 2009)
New Revision: 2617
Modified:
doc/trunk/reference/en-US/environments.xml
Log:
fix typo
Modified: doc/trunk/reference/en-US/environments.xml
===================================================================
--- doc/trunk/reference/en-US/environments.xml 2009-04-23 22:50:49 UTC (rev 2616)
+++ doc/trunk/reference/en-US/environments.xml 2009-04-23 22:52:45 UTC (rev 2617)
@@ -186,7 +186,7 @@
<programlisting role="XML"><![CDATA[<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
- <New id="jdciManager" class="org.mortbay.jetty.plus.naming.Resource">
+ <New id="appManager" class="org.mortbay.jetty.plus.naming.Resource">
<Arg><Ref id="webAppCtx"/></Arg>
<Arg>app/Manager</Arg>
<Arg>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2616 - doc/trunk/reference/en-US.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-23 18:50:49 -0400 (Thu, 23 Apr 2009)
New Revision: 2616
Modified:
doc/trunk/reference/en-US/environments.xml
Log:
WBX-31
Modified: doc/trunk/reference/en-US/environments.xml
===================================================================
--- doc/trunk/reference/en-US/environments.xml 2009-04-22 18:42:57 UTC (rev 2615)
+++ doc/trunk/reference/en-US/environments.xml 2009-04-23 22:50:49 UTC (rev 2616)
@@ -45,7 +45,7 @@
</section>
<section>
- <title>Glassfish</title>
+ <title>GlassFish</title>
<para>TODO</para>
</section>
@@ -65,11 +65,11 @@
</note>
<para>
- Web Beans should be used as a web application library in a servlet
- container. You should place <literal>webbeans-servlet.jar</literal> in
- <literal>WEB-INF/lib</literal>. <literal>webbeans-serv;et.jar</literal>
- is an "uber-jar" provided for your convenience. Instead, you could use
- its component jars:
+ Web Beans should be used as a web application library in a servlet
+ container. You should place <literal>webbeans-servlet.jar</literal>
+ in <literal>WEB-INF/lib</literal>.
+ <literal>webbeans-servlet.jar</literal> is an "uber-jar" provided for
+ your convenience. Alternatively, you could use its component jars:
</para>
<itemizedlist>
@@ -117,41 +117,43 @@
<para>
You also need to explicitly specify the servlet listener (used to
- boot Web Beans, and control its interaction with requests) in
+ boot Web Beans, and control its interaction with requests) in
<literal>web.xml</literal>:
</para>
- <programlisting><![CDATA[<listener>
+ <programlisting role="XML"><![CDATA[<listener>
<listener-class>org.jboss.webbeans.environment.servlet.Listener</listener-class>
</listener>]]></programlisting>
<section>
<title>Tomcat</title>
- <para>
- Tomcat has a read-only JNDI, so Web Beans can't automatically bind
- the Manager. To bind the Manager into JNDI, you should add the
- following to your <literal>META-INF/context.xml</literal>:
- </para>
+ <para>
+ Tomcat has a read-only JNDI, so Web Beans can't automatically bind
+ the Manager. To bind the Manager into JNDI, you should populate
+ <literal>META-INF/context.xml</literal> with the following
+ contents:
+ </para>
- <programlisting><![CDATA[<Resource name="app/Manager"
- auth="Container"
- type="javax.inject.manager.Manager"
- factory="org.jboss.webbeans.resources.ManagerObjectFactory"/>
-]]></programlisting>
+ <programlisting role="XML"><![CDATA[<Context>
+ <Resource name="app/Manager"
+ auth="Container"
+ type="javax.inject.manager.Manager"
+ factory="org.jboss.webbeans.resources.ManagerObjectFactory"/>
+</Context>]]></programlisting>
<para>
- and make it available to your deployment by adding this to
- <literal>web.xml</literal>:
+ and make it available to your deployment by adding this to
+ the bottom of <literal>web.xml</literal>:
</para>
- <programlisting><![CDATA[<resource-env-ref>
- <resource-env-ref-name>
- app/Manager
- </resource-env-ref-name>
- <resource-env-ref-type>
- javax.inject.manager.Manager
- </resource-env-ref-type>
+ <programlisting role="XML"><![CDATA[<resource-env-ref>
+ <resource-env-ref-name>
+ app/Manager
+ </resource-env-ref-name>
+ <resource-env-ref-type>
+ javax.inject.manager.Manager
+ </resource-env-ref-type>
</resource-env-ref>]]></programlisting>
<para>
@@ -163,14 +165,59 @@
<para>
Web Beans also supports Servlet injection in Tomcat. To enable this,
place the <literal>webbeans-tomcat-support.jar</literal> in
- <literal>$TOMCAT_HOME/lib</literal>, and add the following to your
- <literal>META-INF/context.xml</literal>:
+ <literal>$TOMCAT_HOME/lib</literal>, and add the following to your
+ <literal>META-INF/context.xml</literal>:
</para>
- <programlisting><![CDATA[<Listener className="org.jboss.webbeans.environment.tomcat.WebBeansLifecycleListener" />]]></programlisting>
+ <programlisting role="XML"><![CDATA[<Listener className="org.jboss.webbeans.environment.tomcat.WebBeansLifecycleListener"/>]]></programlisting>
</section>
+ <section>
+ <title>Jetty</title>
+
+ <para>
+ Like Tomcat, Jetty has a read-only JNDI, so Web Beans can't
+ automatically bind the Manager. To bind the Manager to JNDI, you
+ should populate <literal>WEB-INF/jetty-env.xml</literal> with the
+ following contents:
+ </para>
+
+ <programlisting role="XML"><![CDATA[<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
+ "http://jetty.mortbay.org/configure.dtd">
+<Configure id="webAppCtx" class="org.mortbay.jetty.webapp.WebAppContext">
+ <New id="jdciManager" class="org.mortbay.jetty.plus.naming.Resource">
+ <Arg><Ref id="webAppCtx"/></Arg>
+ <Arg>app/Manager</Arg>
+ <Arg>
+ <New class="javax.naming.Reference">
+ <Arg>javax.inject.manager.Manager</Arg>
+ <Arg>org.jboss.webbeans.resources.ManagerObjectFactory</Arg>
+ <Arg/>
+ </New>
+ </Arg>
+ </New>
+</Configure>]]></programlisting>
+
+ <para>
+ Notice that Jetty doesn't not have built-in support for an
+ <literal>javax.naming.spi.ObjectFactory</literal> like Tomcat, so
+ it's necessary to manually create the
+ <literal>javax.naming.Reference</literal> to wrap around it.
+ </para>
+
+ <para>
+ Jetty only allows you to bind entries to
+ <literal>java:comp/env</literal>, so the Manager will be available
+ at <literal>java:comp/env/app/Manager</literal>
+ </para>
+
+ <para>
+ Web Beans does not currently support Servlet injection in Jetty.
+ </para>
+
+ </section>
+
</section>
<section>
@@ -286,4 +333,4 @@
</section>
-</chapter>
\ No newline at end of file
+</chapter>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2615 - examples/trunk/translator.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-22 14:42:57 -0400 (Wed, 22 Apr 2009)
New Revision: 2615
Modified:
examples/trunk/translator/build.xml
Log:
rename build from Numberguess to Translator
Modified: examples/trunk/translator/build.xml
===================================================================
--- examples/trunk/translator/build.xml 2009-04-22 09:41:20 UTC (rev 2614)
+++ examples/trunk/translator/build.xml 2009-04-22 18:42:57 UTC (rev 2615)
@@ -1,8 +1,8 @@
-<project basedir="." name="Numberguess Example Build" default="restart">
+<project basedir="." name="Translator Example Build" default="restart">
<property name="example.name" value="webbeans-translator" />
<property name="type" value="ear" />
<import file="../build.xml" />
-</project>
\ No newline at end of file
+</project>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2614 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle and 10 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-04-22 05:41:20 -0400 (Wed, 22 Apr 2009)
New Revision: 2614
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/beans.xml
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/beans.xml
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/persistence.xml
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/ic/
Log:
Implemented various resource injection tests for simple beans.
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.inject.manager.Bean;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * EJB injection tests for simple beans.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+(a)Packaging(PackagingType.EAR)
+@IntegrationTest
+@Resources({
+ @Resource(source="web.xml", destination="WEB-INF/web.xml")
+})
+@BeansXml("beans.xml")
+public class EjbInjectionTest extends AbstractJSR299Test
+{
+ @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "6.4", id = "b")
+ public void testInjectionOfEjbs()
+ {
+ Bean<SimpleBean> simpleBeanBean = getCurrentManager().resolveByType(SimpleBean.class).iterator().next();
+ SimpleBean simpleBean = simpleBeanBean.create(new MyCreationalContext<SimpleBean>());
+ assert !simpleBean.isMyEjbExists() : "Ejb was injected too early";
+ assert simpleBean.getMyEjb() != null : "Ejb was not injected into bean";
+ assert simpleBean.getMyEjb().hello().equals("hi!");
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/EjbInjectionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/MyCreationalContext.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/MyCreationalContext.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.context.CreationalContext;
+
+class MyCreationalContext<T> implements CreationalContext<T>
+{
+ public void push(T incompleteInstance)
+ {
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/xml/resource/ejb/RemoteEjb.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjb.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.ejb.Stateless;
+
+@Stateless(name="MyRemoteEjb", mappedName="ejb/MyRemoteEjb")
+public class RemoteEjb implements RemoteEjbInterface
+{
+
+ public String hello()
+ {
+ return "hi!";
+ }
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/xml/resource/ejb/RemoteEjbInterface.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/RemoteEjbInterface.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.ejb.Remote;
+
+@Remote
+public interface RemoteEjbInterface
+{
+ public String hello();
+}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,25 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb;
+
+import javax.ejb.EJB;
+
+class SimpleBean
+{
+ @EJB
+ private RemoteEjb myEjb;
+ private boolean myEjbExists;
+
+ public SimpleBean()
+ {
+ myEjbExists = myEjb != null;
+ }
+
+ public RemoteEjb getMyEjb()
+ {
+ return myEjb;
+ }
+
+ public boolean isMyEjbExists()
+ {
+ return myEjbExists;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/SimpleBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import javax.context.CreationalContext;
+
+class MyCreationalContext<T> implements CreationalContext<T>
+{
+ public void push(T incompleteInstance)
+ {
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/MyCreationalContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/xml/resource/persistenceContext/DeclarationOfPersistenceUnitAndContextTest.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,59 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import javax.inject.manager.Bean;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * Injection of persistence related objects.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+(a)Packaging(PackagingType.WAR)
+@IntegrationTest
+@Resources({
+ @Resource(source="persistence.xml", destination="WEB-INF/persistence.xml")
+})
+@BeansXml("beans.xml")
+public class PersistenceContextInjectionTest extends AbstractJSR299Test
+{
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertions( {
+ @SpecAssertion(section = "6.4", id = "c")
+ })
+ public void testInjectionOfPersistenceContext()
+ {
+ Bean<SimpleBean> simpleBeanBean = getCurrentManager().resolveByType(SimpleBean.class).iterator().next();
+ SimpleBean simpleBean = simpleBeanBean.create(new MyCreationalContext<SimpleBean>());
+ EntityManager entityManager = simpleBean.getPersistenceContext();
+ assert !simpleBean.isPersistenceContextExistsDuringConstruction() : "Persistence context injected too early";
+ assert entityManager != null : "Persistence context was not injected into bean";
+ assert entityManager.isOpen() : "persistence context not open injected into bean";
+ }
+
+ @Test(groups = { "broken", "beanLifecycle", "commonAnnotations", "integration" })
+ public void testInjectionOfPersistenceUnit()
+ {
+ //TODO There is no spec assertion for this test and it does not work, but there is bean support for persistence units
+ Bean<SimpleBean> simpleBeanBean = getCurrentManager().resolveByType(SimpleBean.class).iterator().next();
+ SimpleBean simpleBean = simpleBeanBean.create(new MyCreationalContext<SimpleBean>());
+ EntityManagerFactory entityManagerFactory = simpleBean.getPersistenceUnit();
+ assert !simpleBean.isPersistenceUnitExistsDuringConstruction() : "Persistence unit injected too early";
+ assert entityManagerFactory != null : "Persistence unit was not injected into bean";
+ assert entityManagerFactory.isOpen() : "persistence unit not open injected into bean";
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,43 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.persistenceContext;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+class SimpleBean
+{
+ @PersistenceContext
+ private EntityManager persistenceContext;
+ private boolean persistenceContextExistsDuringConstruction;
+
+ @PersistenceUnit
+ private EntityManagerFactory persistenceUnit;
+ private boolean persistenceUnitExistsDuringConstruction;
+
+ public SimpleBean()
+ {
+ persistenceContextExistsDuringConstruction = persistenceContext != null;
+ persistenceUnitExistsDuringConstruction = persistenceUnit != null;
+ }
+
+ public EntityManager getPersistenceContext()
+ {
+ return persistenceContext;
+ }
+
+ public EntityManagerFactory getPersistenceUnit()
+ {
+ return persistenceUnit;
+ }
+
+ public boolean isPersistenceContextExistsDuringConstruction()
+ {
+ return persistenceContextExistsDuringConstruction;
+ }
+
+ public boolean isPersistenceUnitExistsDuringConstruction()
+ {
+ return persistenceUnitExistsDuringConstruction;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/SimpleBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/xml/resource/resource/Another.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/Another.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Another
+{
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java (from rev 2611, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/xml/resource/resource/DeclarationOfResourceTest.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,32 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import javax.inject.manager.Bean;
+import javax.inject.manager.Manager;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+@Artifact
+(a)Packaging(PackagingType.WAR)
+@IntegrationTest
+@BeansXml("beans.xml")
+public class InjectionOfResourceTest extends AbstractJSR299Test
+{
+ @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
+ @SpecAssertion(section = "6.4", id = "d")
+ public void testInjectionOfResource()
+ {
+ Bean<SimpleBean> simpleBeanBean = getCurrentManager().resolveByType(SimpleBean.class).iterator().next();
+ SimpleBean simpleBean = simpleBeanBean.create(new MyCreationalContext<SimpleBean>());
+ Manager manager = simpleBean.getManager();
+ assert !simpleBean.isManagerInjected() : "Manager injected too early";
+ assert manager != null : "@Another Manager not found";
+ assert manager.equals(getCurrentManager()): "Wrong manager found";
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/InjectionOfResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import javax.context.CreationalContext;
+
+class MyCreationalContext<T> implements CreationalContext<T>
+{
+ public void push(T incompleteInstance)
+ {
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/MyCreationalContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,26 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.resource.resource;
+
+import javax.annotation.Resource;
+import javax.inject.manager.Manager;
+
+class SimpleBean
+{
+ @Resource
+ private Manager manager;
+ private boolean managerInjected;
+
+ public SimpleBean()
+ {
+ managerInjected = manager != null;
+ }
+
+ public Manager getManager()
+ {
+ return manager;
+ }
+
+ public boolean isManagerInjected()
+ {
+ return managerInjected;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/SimpleBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/beans.xml (from rev 2611, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/xml/resource/ejb/beans.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/beans.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/beans.xml 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,12 @@
+<Beans xmlns="urn:java:ee"
+ xmlns:test="urn:java:org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb">
+ <Deploy>
+ <Standard />
+ <Production />
+ </Deploy>
+ <test:RemoteEjbInterface>
+ <EJB>
+ <mappedName>ejb/MyRemoteEjb</mappedName>
+ </EJB>
+ </test:RemoteEjbInterface>
+</Beans>
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml (from rev 2611, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/xml/resource/ejb/web.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/ejb/web.xml 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <description>EJB references for Simple Beans.</description>
+ <display-name>EJB Injection Tests</display-name>
+
+ <ejb-ref>
+ <ejb-ref-name>ejb/MyRemoteEjb</ejb-ref-name>
+ <ejb-ref-type>Session</ejb-ref-type>
+ <remote>org.jboss.jsr299.tck.tests.implementation.simple.resource.ejb.RemoteEjbInterface</remote>
+ </ejb-ref>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
\ No newline at end of file
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/beans.xml (from rev 2611, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/xml/resource/persistenceContext/beans.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/beans.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/beans.xml 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,13 @@
+<Beans xmlns="urn:java:ee">
+ <EntityManager>
+ <PersistenceContext>
+ <unitName>test</unitName>
+ </PersistenceContext>
+ </EntityManager>
+
+ <EntityManagerFactory>
+ <PersistenceUnit>
+ <unitName>test</unitName>
+ </PersistenceUnit>
+ </EntityManagerFactory>
+</Beans>
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/persistence.xml (from rev 2611, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/xml/resource/persistenceContext/persistence.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/persistence.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/persistence.xml 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="test">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ </persistence-unit>
+</persistence>
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml (from rev 2613, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/xml/resource/resource/beans.xml)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/implementation/simple/resource/resource/beans.xml 2009-04-22 09:41:20 UTC (rev 2614)
@@ -0,0 +1,11 @@
+<Beans xmlns="urn:java:ee"
+ xmlns:app="urn:java:org.jboss.jsr299.tck.tests.implementation.simple.resource.resource"
+ xmlns:m="urn:java:javax.inject.manager">
+
+ <m:Manager>
+ <Resource>
+ <mappedName>java:app/Manager</mappedName>
+ </Resource>
+ <app:Another />
+ </m:Manager>
+</Beans>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2613 - doc/trunk/reference/it-IT.
by webbeans-commits@lists.jboss.org
Author: nico.ben
Date: 2009-04-21 14:55:10 -0400 (Tue, 21 Apr 2009)
New Revision: 2613
Modified:
doc/trunk/reference/it-IT/extensions.po
doc/trunk/reference/it-IT/gettingstarted.po
doc/trunk/reference/it-IT/ri-spi.po
Log:
Italian translation
Modified: doc/trunk/reference/it-IT/extensions.po
===================================================================
--- doc/trunk/reference/it-IT/extensions.po 2009-04-21 15:38:27 UTC (rev 2612)
+++ doc/trunk/reference/it-IT/extensions.po 2009-04-21 18:55:10 UTC (rev 2613)
@@ -6,7 +6,7 @@
"Project-Id-Version: Web_Beans:_Java_Contexts_and_Dependency_Injection VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-04-19 20:36+0000\n"
-"PO-Revision-Date: 2009-04-20 22:07+0100\n"
+"PO-Revision-Date: 2009-04-21 20:36+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -35,7 +35,7 @@
#: extensions.xml:17
#, no-c-format
msgid "Adding logging to your application is now even easier with simple injection of a logger object into any JSR-299 bean. Simply annotate a org.jboss.webbeans.log.Log type member with <emphasis>@Logger</emphasis> and an appropriate logger object will be injected into any instance of the bean."
-msgstr ""
+msgstr "Aggiungere la parte di logging alla propria applicazione adesso è facilissimo con la semplice injection di un oggetto logger in un qualsiasi bean JSR-299. Semplicemente si annoti un membro di tipo org.jboss.webbeans.log.Log con <emphasis>@Logger</emphasis> ed un oggetto logger appropriato verrà iniettato in una qualsiasi istanza del bean."
#. Tag: programlisting
#: extensions.xml:25
@@ -75,19 +75,19 @@
#: extensions.xml:27
#, no-c-format
msgid "The example shows how objects can be interpolated into a message. This interpolation is done using <emphasis>java.text.MessageFormat</emphasis>, so see the JavaDoc for that class for more details. In this case, the ShoppingCart should have implemented the <emphasis>toString()</emphasis> method to produce a human readable value that is meaningful in messages. Normally, this call would have involved evaluating cart.toString() with String concatenation to produce a single String argument. Thus it was necessary to surround the call with an if-statement using the condition <emphasis>log.isDebugEnabled()</emphasis> to avoid the expensive String concatenation if the message was not actually going to be used. However, when using @Logger injected logging, the conditional test can be left out since the object arguments are not evaluated unless the message is going to be logged."
-msgstr ""
+msgstr "L'esempio mostra come un oggetto può essere interpolato in un messaggio. Quest'interpolazione è fatta usando <emphasis>java.text.MessageFormat</emphasis>, quindi si veda JavaDoc di questa class per ulteriori dettagli. In questo caso ShoppingCart dovrebbe aver implementato il metodo <emphasis>toString()</emphasis> per produrre un valore leggibile che sia significativo nei messaggi.Normalmente questa chiamata comporterebbe la valutazione di cart.toString() con una concatenazione di stringa per produrre un singolo argomento stringa. Questo è necessario per racchiudere la chiamata con uno statement if usando la condizione <emphasis>log.isDebugEnabled()</emphasis>per evitare la costosa concatenazione stringa se il messaggio in realtà non viene usato. Comunque quando si usa il logging iniettato con @Logger, il test condizionale può essere tralasciato poiché gli argomenti dell'oggetto non vengono valutati amenoché il messaggio non venga loggato."
#. Tag: para
#: extensions.xml:44
#, no-c-format
msgid "You can add the Web Beans Logger to your project by including webbeans-logger.jar and webbeans-logging.jar to your project. Alternatively, express a dependency on the <literal>org.jboss.webbeans:webbeans-logger</literal> Maven artifact."
-msgstr ""
+msgstr "Si può aggiungere il Logger Web Bean al proprio progetto includendo nel progetto webbeans-logger.jar e webbeans-logging.jar. In alternativa, si può esprimere un dipendenza nell'artifact Maven <literal>org.jboss.webbeans:webbeans-logger</literal>."
#. Tag: para
#: extensions.xml:51
#, no-c-format
msgid "If you are using Web Beans as your JSR-299 implementation, there is no need to include <literal>webbeans-logging.jar</literal> as it's already included."
-msgstr ""
+msgstr "Se si usa Web Beans come implementazione JSR-299, non c'è alcun bisogno di includere <literal>webbeans-logging.jar</literal> poiché lo è già."
#~ msgid "TODO"
#~ msgstr "DA FARE"
Modified: doc/trunk/reference/it-IT/gettingstarted.po
===================================================================
--- doc/trunk/reference/it-IT/gettingstarted.po 2009-04-21 15:38:27 UTC (rev 2612)
+++ doc/trunk/reference/it-IT/gettingstarted.po 2009-04-21 18:55:10 UTC (rev 2613)
@@ -6,7 +6,7 @@
"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-04-19 20:36+0000\n"
-"PO-Revision-Date: 2009-04-20 22:17+0100\n"
+"PO-Revision-Date: 2009-04-21 20:44+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -15,9 +15,9 @@
#. Tag: title
#: gettingstarted.xml:4
-#, fuzzy, no-c-format
+#, no-c-format
msgid "Getting started with Web Beans, the Reference Implementation of JSR-299"
-msgstr "Implementazione di riferimento di Web Beans JSR-299"
+msgstr "Iniziare con Web Beans, l'implementazione di riferimento di JSR-299"
#. Tag: para
#: gettingstarted.xml:6
@@ -896,15 +896,15 @@
#. Tag: title
#: gettingstarted.xml:431
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The numberguess example in Tomcat"
-msgstr "Esempio Indovina Numero per Tomcat"
+msgstr "Esempio Indovina Numero in Tomcat"
#. Tag: para
#: gettingstarted.xml:433
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The numberguess for Tomcat differs in a couple of ways. Firstly, Web Beans should be deployed as a Web Application library in <literal>WEB-INF/lib</literal>. For your convenience we provide a single jar suitable for running Web Beans in any servlet container <literal>webbeans-servlet.jar</literal>."
-msgstr "L'Indovina Numero di Tomcat differisce in un paio di punti. Innanzitutto Web Beans dovrebbe essere deployato come libreria Web Application in <literal>WEB-INF/lib</literal>. Per comodità viene fornito un singolo jar <literal>webbeans-tomcat.jar</literal> adatto per Web Beans in Tomcat."
+msgstr "L'Indovina Numero per Tomcat differisce in un paio di punti. Innanzitutto Web Beans dovrebbe essere deployato come libreria Web Application in <literal>WEB-INF/lib</literal>. Per comodità viene fornito un singolo jar <literal>webbeans-servlet.jar</literal> per eseguire Web Beans in un qualsiasi servlet container."
#. Tag: para
#: gettingstarted.xml:442
@@ -914,7 +914,7 @@
#. Tag: para
#: gettingstarted.xml:449
-#, fuzzy, no-c-format
+#, no-c-format
msgid "Secondly, we need to explicitly specify the servlet listener (used to boot Web Beans, and control it's interaction with requests) in <literal>web.xml</literal>:"
msgstr "In secondo luogo, occorre specificare esplicitamente il servlet listener di Tomcat (usato per avviare Web Beans, e controllare la sua interazione con le richieste) in <literal>web.xml</literal>:"
@@ -932,21 +932,21 @@
#. Tag: title
#: gettingstarted.xml:460
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The numberguess example for Apache Wicket"
-msgstr "Esempio Indovina Numero per Tomcat"
+msgstr "Esempio Indovina Numero per Apache Wicket"
#. Tag: para
#: gettingstarted.xml:461
#, no-c-format
msgid "Whilst JSR-299 specifies integration with Java ServerFaces, Web Beans allows you to inject into Wicket components, and also allows you to use a conversation context with Wicket. In this section, we'll walk you through the Wicket version of the numberguess example."
-msgstr ""
+msgstr "Mentre JSR-299 specifica l'integrazione con Java ServerFaces, Web Beans consente di iniettare nei componenti Wicket e di usare un contesto conversazione con Wicket. In questa sezione si analizzerà la versione dell'esempio Indovina Numero per Wicket."
#. Tag: para
#: gettingstarted.xml:470
#, no-c-format
msgid "You may want to review the Wicket documentation at <ulink url=\"http://wicket.apache.org/\">http://wicket.apache.org/</ulink>."
-msgstr ""
+msgstr "Per vedere la documentazione Wicket si vada a <ulink url=\"http://wicket.apache.org/\">http://wicket.apache.org/</ulink>."
#. Tag: para
#: gettingstarted.xml:476
@@ -964,13 +964,13 @@
#: gettingstarted.xml:493
#, no-c-format
msgid "Creating the Eclipse project"
-msgstr ""
+msgstr "Creazione di un progetto Eclipse"
#. Tag: para
#: gettingstarted.xml:495
#, no-c-format
msgid "To generate an Eclipse project from the example:"
-msgstr ""
+msgstr "Per generare un progetto Eclipse dall'esempio:"
#. Tag: programlisting
#: gettingstarted.xml:499
@@ -992,7 +992,7 @@
#: gettingstarted.xml:516
#, no-c-format
msgid "Running the example from Eclipse"
-msgstr ""
+msgstr "Esecuzione dell'esempio da Eclipse"
#. Tag: para
#: gettingstarted.xml:518
@@ -1016,7 +1016,7 @@
#: gettingstarted.xml:549
#, no-c-format
msgid "Understanding the code"
-msgstr ""
+msgstr "Comprendere il codice"
#. Tag: para
#: gettingstarted.xml:551
@@ -1034,7 +1034,7 @@
#: gettingstarted.xml:568
#, no-c-format
msgid "Differences are:"
-msgstr ""
+msgstr "Le differenze sono:"
#. Tag: para
#: gettingstarted.xml:573
@@ -1168,9 +1168,9 @@
#. Tag: title
#: gettingstarted.xml:645
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The numberguess example for Java SE with Swing"
-msgstr "Esempio Indovina Numero per Tomcat"
+msgstr "Esempio Indovina Numero per Java SE con Swing"
#. Tag: para
#: gettingstarted.xml:647
@@ -1216,9 +1216,9 @@
#. Tag: para
#: gettingstarted.xml:686
-#, fuzzy, no-c-format
+#, no-c-format
msgid "There is an empty <literal>beans.xml</literal> file in the root package (<literal>src/main/resources/beans.xml</literal>), which marks this application as a Web Beans application."
-msgstr "Vi è un file vuoto <literal>web-beans.xml</literal>, che identifica l'applicazione come applicazione Web Beans."
+msgstr "Vi è un file vuoto <literal>beans.xml</literal> nel pacchetto radice (<literal>src/main/resources/beans.xml</literal>), che identifica l'applicazione come applicazione Web Beans."
#. Tag: para
#: gettingstarted.xml:692
@@ -1412,6 +1412,187 @@
"\n"
"}]]></programlisting> <calloutlist> <callout arearefs=\"gameIn\"> <para> The injected instance of the game (logic and state). </para> </callout> <callout arearefs=\"messagesIn\"> <para> The injected message generator for UI messages. </para> </callout> <callout arearefs=\"start\"> <para> This application is started in the usual Web Beans SE way, by observing the <literal>@Deployed Manager</literal> event. </para> </callout> <callout arearefs=\"init\"> <para> This method initialises all of the Swing components. Note the use of the <literal>msgGenerator</literal>. </para> </callout> <callout arearefs=\"guess1\"> <para> <literal>guessButtonActionPerformed</literal> is called when the 'Guess' button is clicked, and it does the following: </para> <itemizedlist> <listitem> <para> Gets the guess entered by the user and sets it as the current guess in the <literal>Game</literal> </para> </listitem> <listitem> <para> Calls <literal>game.check()</literal> to validate and perform one!
'turn' of the game </para> </listitem> <listitem> <para> Calls <literal>refreshUI</literal>. If there were validation errors with the input, this will have been captured during <literal>game.check()</literal> and as such will be reflected in the messeges returned by <literal>MessageGenerator</literal> and subsequently presented to the user. If there are no validation errors then the user will be told to guess again (higher or lower) or that the game has ended either in a win (correct guess) or a loss (ran out of guesses). </para> </listitem> </itemizedlist> </callout> <callout arearefs=\"replay\"> <para> <literal>replayBtnActionPerformed</literal> simply calls <literal>game.reset()</literal> to start a new game and refreshes the messages in the UI. </para> </callout> <callout arearefs=\"refresh\"> <para> <literal>refreshUI</literal> uses the <literal>MessageGenerator</literal> to update the messages to the user based on the current state of the Game. </para> </callout> </c!
alloutlist> </programlistingco>"
msgstr ""
+"<programlistingco> <areaspec> <area id=\"scope\" coords=\"1\"/> <area id=\"name\" coords=\"1\"/> <area id=\"messages1\" coords=\"26\"/> <area id=\"validation\" coords=\"39\"/> <area id=\"reset\" coords=\"68\"/> </areaspec> <programlisting role=\"JAVA\"><![CDATA[@ApplicationScoped\n"
+"public class Game implements Serializable\n"
+"{\n"
+"\n"
+" private int number;\n"
+" private int guess;\n"
+" private int smallest;\n"
+"\n"
+" @MaxNumber\n"
+" private int maxNumber;\n"
+"\n"
+" private int biggest;\n"
+" private int remainingGuesses;\n"
+" private boolean validNumberRange = true;\n"
+"\n"
+" @Current Generator rndGenerator;\n"
+"\n"
+" ...\n"
+"\n"
+" public boolean isValidNumberRange()\n"
+" {\n"
+" return validNumberRange;\n"
+" }\n"
+"\n"
+" public boolean isGameWon()\n"
+" {\n"
+" return guess == number;\n"
+" }\n"
+"\n"
+" public boolean isGameLost()\n"
+" {\n"
+" return guess != number && remainingGuesses <= 0;\n"
+" }\n"
+"\n"
+" public boolean check()\n"
+" {\n"
+" boolean result = false;\n"
+"\n"
+" if ( checkNewNumberRangeIsValid() )\n"
+" {\n"
+" if ( guess > number )\n"
+" {\n"
+" biggest = guess - 1;\n"
+" }\n"
+"\n"
+" if ( guess < number )\n"
+" {\n"
+" smallest = guess + 1;\n"
+" }\n"
+"\n"
+" if ( guess == number )\n"
+" {\n"
+" result = true;\n"
+" }\n"
+"\n"
+" remainingGuesses--;\n"
+" }\n"
+"\n"
+" return result;\n"
+" }\n"
+"\n"
+" private boolean checkNewNumberRangeIsValid()\n"
+" {\n"
+" return validNumberRange = ( ( guess >= smallest ) && ( guess <= biggest ) );\n"
+" }\n"
+"\n"
+" @PostConstruct\n"
+" public void reset()\n"
+" {\n"
+" this.smallest = 0;\n"
+" ...\n"
+" this.number = rndGenerator.next();\n"
+" }\n"
+"}]]></programlisting> <calloutlist> <callout arearefs=\"scope\"> <para> The bean is application scoped instead of session scoped, since an instance of the application represents a single 'session'. </para> </callout> <callout arearefs=\"name\"> <para> The bean is not named, since it doesn't need to be accessed via EL </para> </callout> <callout arearefs=\"messages1\"> <para> There is no JSF <literal>FacesContext</literal> to add messages to. Instead the <literal>Game</literal> class provides additional information about the state of the current game including: </para> <itemizedlist> <listitem> <para> If the game has been won or lost </para> </listitem> <listitem> <para> If the most recent guess was invalid </para> </listitem> </itemizedlist> <para> This allows the Swing UI to query the state of the game, which it does indirectly via a class called <literal>MessageGenerator,</literal> in order to determine the appropriate messages to display to the user during the game. </p!
ara> </callout> <callout arearefs=\"validation\"> <para> Validation of user input is performed during the <literal>check()</literal> method, since there is no dedicated validation phase </para> </callout> <callout arearefs=\"reset\"> <para> The <literal>reset()</literal> method makes a call to the injected <literal>rndGenerator</literal> in order to get the random number at the start of each game. It cannot use <literal>manager.getInstanceByType(Integer.class, new AnnotationLiteral<Random>(){})</literal> as the JSF example does because there will not be any active contexts like there is during a JSF request. </para> </callout> </calloutlist> </programlistingco> <para> The <literal>MessageGenerator</literal> class depends on the current instance of <literal>Game</literal>, and queries its state in order to determine the appropriate messages to provide as the prompt for the user's next guess and the response to the previous guess. The code for <literal>MessageGenerator<!
/literal> is as follows: </para> <programlistingco> <areaspec> <area i
d=\"game\" coords=\"3\"/> <area id=\"challenge\" coords=\"5\"/> <area id=\"result\" coords=\"16\"/> </areaspec> <programlisting role=\"JAVA\"><![CDATA[public class MessageGenerator\n"
+"{\n"
+" @Current Game game;\n"
+"\n"
+" public String getChallengeMessage()\n"
+" {\n"
+" StringBuilder challengeMsg = new StringBuilder( \"I'm thinking of a number between \" );\n"
+" challengeMsg.append( game.getSmallest() );\n"
+" challengeMsg.append( \" and \" );\n"
+" challengeMsg.append( game.getBiggest() );\n"
+" challengeMsg.append( \". Can you guess what it is?\" );\n"
+"\n"
+" return challengeMsg.toString();\n"
+" }\n"
+"\n"
+" public String getResultMessage()\n"
+" {\n"
+" if ( game.isGameWon() )\n"
+" {\n"
+" return \"You guess it! The number was \" + game.getNumber();\n"
+" } else if ( game.isGameLost() )\n"
+" {\n"
+" return \"You are fail! The number was \" + game.getNumber();\n"
+" } else if ( ! game.isValidNumberRange() )\n"
+" {\n"
+" return \"Invalid number range!\";\n"
+" } else if ( game.getRemainingGuesses() == Game.MAX_NUM_GUESSES )\n"
+" {\n"
+" return \"What is your first guess?\";\n"
+" } else\n"
+" {\n"
+" String direction = null;\n"
+"\n"
+" if ( game.getGuess() < game.getNumber() )\n"
+" {\n"
+" direction = \"Higher\";\n"
+" } else\n"
+" {\n"
+" direction = \"Lower\";\n"
+" }\n"
+"\n"
+" return direction + \"! You have \" + game.getRemainingGuesses() + \" guesses left.\";\n"
+" }\n"
+" }\n"
+"}]]></programlisting> <calloutlist> <callout arearefs=\"game\"> <para> The instance of <literal>Game</literal> for the application is injected here. </para> </callout> <callout arearefs=\"challenge\"> <para> The <literal>Game</literal>'s state is interrogated to determine the appropriate challenge message. </para> </callout> <callout arearefs=\"result\"> <para> And again to determine whether to congratulate, console or encourage the user to continue. </para> </callout> </calloutlist> </programlistingco> <para> Finally we come to the <literal>NumberGuessFrame</literal> class which provides the Swing front end to our guessing game. </para> <programlistingco> <areaspec> <area id=\"gameIn\" coords=\"3\"/> <area id=\"messagesIn\" coords=\"4\"/> <area id=\"start\" coords=\"6\"/> <area id=\"init\" coords=\"18\"/> <area id=\"guess1\" coords=\"34\"/> <area id=\"replay\" coords=\"44\"/> <area id=\"refresh\" coords=\"50\"/> </areaspec> <programlisting role=\"JAVA\"><![CDATA[public cl!
ass NumberGuessFrame extends javax.swing.JFrame\n"
+"{\n"
+" private @Current Game game;\n"
+" private @Current MessageGenerator msgGenerator;\n"
+"\n"
+" public void start( @Observes @Deployed Manager manager )\n"
+" {\n"
+" java.awt.EventQueue.invokeLater( new Runnable()\n"
+" {\n"
+" public void run()\n"
+" {\n"
+" initComponents();\n"
+" setVisible( true );\n"
+" }\n"
+" } );\n"
+" }\n"
+"\n"
+" private void initComponents() {\n"
+"\n"
+" buttonPanel = new javax.swing.JPanel();\n"
+" mainMsgPanel = new javax.swing.JPanel();\n"
+" mainLabel = new javax.swing.JLabel();\n"
+" messageLabel = new javax.swing.JLabel();\n"
+" guessText = new javax.swing.JTextField();\n"
+" ...\n"
+" mainLabel.setText(msgGenerator.getChallengeMessage());\n"
+" mainMsgPanel.add(mainLabel);\n"
+"\n"
+" messageLabel.setText(msgGenerator.getResultMessage());\n"
+" mainMsgPanel.add(messageLabel);\n"
+" ...\n"
+" }\n"
+"\n"
+" private void guessButtonActionPerformed( java.awt.event.ActionEvent evt )\n"
+" {\n"
+" int guess = Integer.parseInt(guessText.getText());\n"
+"\n"
+" game.setGuess( guess );\n"
+" game.check();\n"
+" refreshUI();\n"
+"\n"
+" }\n"
+"\n"
+" private void replayBtnActionPerformed( java.awt.event.ActionEvent evt )\n"
+" {\n"
+" game.reset();\n"
+" refreshUI();\n"
+" }\n"
+"\n"
+" private void refreshUI()\n"
+" {\n"
+" mainLabel.setText( msgGenerator.getChallengeMessage() );\n"
+" messageLabel.setText( msgGenerator.getResultMessage() );\n"
+" guessText.setText( \"\" );\n"
+" guessesLeftBar.setValue( game.getRemainingGuesses() );\n"
+" guessText.requestFocus();\n"
+" }\n"
+"\n"
+" // swing components\n"
+" private javax.swing.JPanel borderPanel;\n"
+" ...\n"
+" private javax.swing.JButton replayBtn;\n"
+"\n"
+"}]]></programlisting> <calloutlist> <callout arearefs=\"gameIn\"> <para> The injected instance of the game (logic and state). </para> </callout> <callout arearefs=\"messagesIn\"> <para> The injected message generator for UI messages. </para> </callout> <callout arearefs=\"start\"> <para> This application is started in the usual Web Beans SE way, by observing the <literal>@Deployed Manager</literal> event. </para> </callout> <callout arearefs=\"init\"> <para> This method initialises all of the Swing components. Note the use of the <literal>msgGenerator</literal>. </para> </callout> <callout arearefs=\"guess1\"> <para> <literal>guessButtonActionPerformed</literal> is called when the 'Guess' button is clicked, and it does the following: </para> <itemizedlist> <listitem> <para> Gets the guess entered by the user and sets it as the current guess in the <literal>Game</literal> </para> </listitem> <listitem> <para> Calls <literal>game.check()</literal> to validate and perform one!
'turn' of the game </para> </listitem> <listitem> <para> Calls <literal>refreshUI</literal>. If there were validation errors with the input, this will have been captured during <literal>game.check()</literal> and as such will be reflected in the messeges returned by <literal>MessageGenerator</literal> and subsequently presented to the user. If there are no validation errors then the user will be told to guess again (higher or lower) or that the game has ended either in a win (correct guess) or a loss (ran out of guesses). </para> </listitem> </itemizedlist> </callout> <callout arearefs=\"replay\"> <para> <literal>replayBtnActionPerformed</literal> simply calls <literal>game.reset()</literal> to start a new game and refreshes the messages in the UI. </para> </callout> <callout arearefs=\"refresh\"> <para> <literal>refreshUI</literal> uses the <literal>MessageGenerator</literal> to update the messages to the user based on the current state of the Game. </para> </callout> </c!
alloutlist> </programlistingco>"
#. Tag: title
#: gettingstarted.xml:904
Modified: doc/trunk/reference/it-IT/ri-spi.po
===================================================================
--- doc/trunk/reference/it-IT/ri-spi.po 2009-04-21 15:38:27 UTC (rev 2612)
+++ doc/trunk/reference/it-IT/ri-spi.po 2009-04-21 18:55:10 UTC (rev 2613)
@@ -6,7 +6,7 @@
"Project-Id-Version: master.xml\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2009-04-19 20:36+0000\n"
-"PO-Revision-Date: 2009-04-20 22:14+0100\n"
+"PO-Revision-Date: 2009-04-21 20:54+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -299,9 +299,9 @@
#. Tag: para
#: ri-spi.xml:131
-#, fuzzy, no-c-format
+#, no-c-format
msgid "Web Beans must delegate JTA activities to the container. The SPI provides a couple hooks to easily achieve this with the <literal>TransactionServices</literal> interface."
-msgstr "Web Beans RI deve delegare le attività JTA al container. SPI fornisce un paio di modi per ottenere ciò tramite l'interfaccia <literal>TransactionServices</literal>."
+msgstr "Web Beans deve delegare le attività JTA al container. SPI fornisce un paio di modi per ottenere ciò tramite l'interfaccia <literal>TransactionServices</literal>."
#. Tag: programlisting
#: ri-spi.xml:137
@@ -403,9 +403,9 @@
#. Tag: para
#: ri-spi.xml:180
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The resolution of <literal>@Resource</literal> (for injection into simple beans) and the resolution of resources (for injection as a Java EE resource) is delegated to the container. You must provide an implementation of <literal>ResourceServices</literal> which provides these operations. For resolving the <literal>@Resource</literal> injection, Web Beans will provide the <literal>InjectionPoint</literal>; and for Java EE resources, the <literal>jndiName</literal> or <literal>mappedName</literal> will be provided."
-msgstr "La risoluzione di <literal>@EJB</literal> e <literal>@Resource</literal> è delegata al container. Occorre fornire un'implementazione di <literal>org.jboss.webbeans.ejb.spi.EjbServices</literal> che rende disponibili queste operazioni. Web Beans passa nel <literal>javax.inject.manager.InjectionPoint</literal> la risoluzione, anche come <literal>NamingContext</literal>, che è in uso per ogni richiesta di risoluzione."
+msgstr "La risoluzione di <literal>@Resource</literal> (per l'injection in bean semplici) e la risoluzione delle risorse (per l'injection come risorsa Java EE) è delegata al container. Occorre fornire un'implementazione di <literal>ResourceServices</literal> che rende disponibili queste operazioni. Per la risoluzione dell'injection <literal>@Resource</literal>, Web Beans fornirà l'<literal>InjectionPoint</literal>; e per le risorse Java EE, verrà fornito <literal>jndiName</literal> o <literal>mappedName</literal>"
#. Tag: title
#: ri-spi.xml:194
@@ -415,9 +415,9 @@
#. Tag: para
#: ri-spi.xml:196
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The resolution of web service references (for injection as a Java EE resource) is delegated to the container. You must provide an implementation of <literal>WebServices</literal> whichprovides this operation. For resolving the Java EE resource, the <literal>jndiName</literal> or <literal>mappedName</literal> will be provided."
-msgstr "La risoluzione di <literal>@EJB</literal> e <literal>@Resource</literal> è delegata al container. Occorre fornire un'implementazione di <literal>org.jboss.webbeans.ejb.spi.EjbServices</literal> che rende disponibili queste operazioni. Web Beans passa nel <literal>javax.inject.manager.InjectionPoint</literal> la risoluzione, anche come <literal>NamingContext</literal>, che è in uso per ogni richiesta di risoluzione."
+msgstr "La risoluzione di di riferimenti web service (per l'iniezione come risorse Java EE) è delegata al container. Occorre fornire un'implementazione di <literal>WebServices</literal> che rende disponibili queste operazioni. Per risolvere la risorsa Java EE verrà fornito <literal>jndiName</literal> o <literal>mappedName</literal>"
#. Tag: title
#: ri-spi.xml:207
@@ -427,9 +427,9 @@
#. Tag: para
#: ri-spi.xml:209
-#, fuzzy, no-c-format
+#, no-c-format
msgid "Web Beans uses a map like structure to store bean instances - <literal>org.jboss.webbeans.context.api.BeanStore</literal>. You may find <literal>org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore</literal> useful."
-msgstr "Web Beans si aspetta che l'Application Server od un altro container fornisca la memorizzazione per ogni contesto applicazione. <literal>org.jboss.webbeans.context.api.BeanStore</literal> dovrebbe essere implementato per fornire uno storage con scope applicazione. Si può trovare molto utile <literal>org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore</literal>."
+msgstr "Web Beans utilizza una mappa come struttura per memorizzare le istanze bean - <literal>org.jboss.webbeans.context.api.BeanStore</literal>. Si potrebbe trovare molto utile <literal>org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore</literal>."
#. Tag: title
#: ri-spi.xml:219
@@ -439,9 +439,9 @@
#. Tag: para
#: ri-spi.xml:221
-#, fuzzy, no-c-format
+#, no-c-format
msgid "Web Beans expects the Application Server or other container to provide the storage for each application's context. The <literal>org.jboss.webbeans.context.api.BeanStore</literal> should be implemented to provide an application scoped storage."
-msgstr "Web Beans si aspetta che l'Application Server od un altro container fornisca la memorizzazione per ogni contesto applicazione. <literal>org.jboss.webbeans.context.api.BeanStore</literal> dovrebbe essere implementato per fornire uno storage con scope applicazione. Si può trovare molto utile <literal>org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore</literal>."
+msgstr "Web Beans si aspetta che l'Application Server od un altro container fornisca la memorizzazione per ogni contesto applicazione. <literal>org.jboss.webbeans.context.api.BeanStore</literal> dovrebbe essere implementato per fornire uno storage con scope applicazione."
#. Tag: title
#: ri-spi.xml:231
@@ -463,9 +463,9 @@
#. Tag: para
#: ri-spi.xml:249
-#, fuzzy, no-c-format
+#, no-c-format
msgid "The bootstrap supports multiple environments. An environment is defined by an implementation of the <literal>Environment</literal> interface. A number of standard envrionments are built in as the enumeration <literal>Environments</literal>. Different environments require different services to be present (for example servlet doesn't require transaction, EJB or JPA services). By default an EE environment is assumed, but you can adjust the environment by calling <literal>bootstrap.setEnvironment()</literal>."
-msgstr "Il bootstrap supporta più ambienti. Diversi ambienti richiedono diversi servizi presenti (per esempio servlet non richiede i servizi di transazione, EJB o JPA). Di default viene assunto un ambiente EE, ma si può impostare un ambiente chiamando <literal>bootstrap.setEnvironment()</literal>."
+msgstr "Il bootstrap supporta più ambienti. Un ambiente viene definito da un'implementazione dell'interfaccia <literal>Environment</literal>. Un numero di ambienti standard sono predefiniti nell'enumeration <literal>Environments</literal>. Diversi ambienti richiedono diversi servizi presenti (per esempio servlet non richiede i servizi di transazione, EJB o JPA). Di default viene assunto un ambiente EE, ma si può impostare un ambiente chiamando <literal>bootstrap.setEnvironment()</literal>."
#. Tag: para
#: ri-spi.xml:260
@@ -643,7 +643,7 @@
#: ri-spi.xml:379
#, no-c-format
msgid "Servlet"
-msgstr ""
+msgstr "Servlet"
#. Tag: para
#: ri-spi.xml:383
@@ -673,7 +673,7 @@
#: ri-spi.xml:421
#, no-c-format
msgid "Web Beans only supports JSF 1.2 and above."
-msgstr ""
+msgstr "Web Beans supporta solo JSF 1.2 e superiori."
#. Tag: term
#: ri-spi.xml:428
@@ -709,7 +709,7 @@
#: ri-spi.xml:464
#, no-c-format
msgid "Binding the manager in JNDI"
-msgstr ""
+msgstr "Associare il manager a JNDI"
#. Tag: para
#: ri-spi.xml:468
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2612 - in ri/trunk/impl/src/main/java/org/jboss/webbeans/xml: checker/beanchildren and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: vitold
Date: 2009-04-21 11:38:27 -0400 (Tue, 21 Apr 2009)
New Revision: 2612
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlConstants.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/ResourceBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/BeanElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/JmsResourceElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/NotSimpleBeanElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/ResourceElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SessionBeanElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SimpleBeanElementRegistrator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/impl/BeanElementRegistratorImpl.java
Log:
formatting code
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -29,28 +29,30 @@
{
public static boolean isJavaEeNamespace(Element element)
{
- return element.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE);
+ return XmlConstants.JAVA_EE_NAMESPACE.equalsIgnoreCase(element.getNamespace().getURI());
}
- public static <T> AnnotatedClass<? extends T> loadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ public static <T> AnnotatedClass<? extends T> loadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment,
+ Map<String, Set<String>> packagesMap)
{
List<AnnotatedClass<? extends T>> classesList = tryLoadElementClass(element, expectedType, environment, packagesMap);
String className = element.getName();
if (classesList.size() == 0)
throw new DefinitionException("Could not find '" + className + "'");
-
+
return classesList.get(0);
}
-
- public static <T> List<AnnotatedClass<? extends T>> tryLoadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+
+ public static <T> List<AnnotatedClass<? extends T>> tryLoadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment,
+ Map<String, Set<String>> packagesMap)
{
List<AnnotatedClass<? extends T>> classesList = new ArrayList<AnnotatedClass<? extends T>>();
String prefix = element.getNamespacePrefix();
for (Map.Entry<String, Set<String>> packagesEntry : packagesMap.entrySet())
{
- if (prefix.equalsIgnoreCase(packagesEntry.getKey()))
+ if (packagesEntry.getKey().equalsIgnoreCase(prefix))
{
Set<String> packages = packagesEntry.getValue();
for (String packageName : packages)
@@ -67,14 +69,15 @@
}
}
}
-
- if(classesList.size() > 1)
+
+ if (classesList.size() > 1)
throw new DefinitionException("There are multiple packages containing a Java type with the same name '" + element.getName() + "'");
-
+
return classesList;
}
-
- public static <T extends Annotation> Class<? extends T> loadAnnotationClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+
+ public static <T extends Annotation> Class<? extends T> loadAnnotationClass(Element element, Class<T> expectedType, XmlEnvironment environment,
+ Map<String, Set<String>> packagesMap)
{
List<Class<? extends T>> classesList = new ArrayList<Class<? extends T>>();
String className = element.getName();
@@ -82,7 +85,7 @@
for (Map.Entry<String, Set<String>> packagesEntry : packagesMap.entrySet())
{
- if (prefix.equalsIgnoreCase(packagesEntry.getKey()))
+ if (packagesEntry.getKey().equalsIgnoreCase(prefix))
{
Set<String> packages = packagesEntry.getValue();
for (String packageName : packages)
@@ -94,7 +97,7 @@
}
catch (ResourceLoadingException e)
{
- //work with this when 'classesList.size() == 0'
+ // work with this when 'classesList.size() == 0'
}
catch (ClassCastException e)
{
@@ -130,7 +133,7 @@
{
urn = attrVal;
URL namespaceFile = environment.loadFileByUrn(urn, XmlConstants.NAMESPACE_FILE_NAME);
-
+
if (namespaceFile != null)
{
packagesSet.addAll(parseNamespaceFile(namespaceFile));
@@ -141,11 +144,13 @@
packagesSet.add(packageName);
}
}
- if (attribute.getName().equalsIgnoreCase(XmlConstants.SCHEMA_LOCATION) && attrVal.startsWith(XmlConstants.HTTP_PREFIX) && urn.trim().length() > 0)
+ if (XmlConstants.SCHEMA_LOCATION.equalsIgnoreCase(attribute.getName()) &&
+ attrVal.startsWith(XmlConstants.HTTP_PREFIX) && urn.trim().length() > 0)
{
URL schemaUrl = environment.loadFileByUrn(urn, XmlConstants.SCHEMA_FILE_NAME);
if (schemaUrl == null)
- throw new DefinitionException("Could not find '" + XmlConstants.SCHEMA_FILE_NAME + "' file according to specified URN '" + urn + "'");
+ throw new DefinitionException("Could not find '" + XmlConstants.SCHEMA_FILE_NAME +
+ "' file according to specified URN '" + urn + "'");
validateXmlWithXsd(xmlUrl, schemaUrl);
}
}
@@ -162,15 +167,15 @@
Namespace namespace = (Namespace) namespacesIterator.next();
String prefix = namespace.getPrefix();
String uri = namespace.getURI();
-
+
if (uri.startsWith(XmlConstants.URN_PREFIX))
{
Set<String> packagesSet = new HashSet<String>();
URL schemaUrl = environment.loadFileByUrn(uri, XmlConstants.SCHEMA_FILE_NAME);
- if(schemaUrl != null)
+ if (schemaUrl != null)
validateXmlWithXsd(xmlUrl, schemaUrl);
-
+
URL namespaceFile = environment.loadFileByUrn(uri, XmlConstants.NAMESPACE_FILE_NAME);
if (namespaceFile != null)
{
@@ -186,9 +191,9 @@
}
}
}
-
+
private static void validateXmlWithXsd(URL xmlUrl, URL schemaUrl)
- {
+ {
try
{
final StreamSource stream = new StreamSource(xmlUrl.toExternalForm());
@@ -197,12 +202,12 @@
final Validator validator = schema.newValidator();
validator.validate(stream);
}
- catch(SAXException e)
+ catch (SAXException e)
{
String message = "SAXException while validate " + xmlUrl + " with " + schemaUrl;
throw new DefinitionException(message, e);
}
- catch(IOException e)
+ catch (IOException e)
{
String message = "IOException while validate " + xmlUrl + " with " + schemaUrl;
throw new DefinitionException(message, e);
@@ -213,22 +218,22 @@
{
String elementPrefix = "";
String elementUri = XmlConstants.JAVA_EE_NAMESPACE;
-
+
return findElements(elementParent, elementName, elementPrefix, elementUri);
}
-
+
public static List<Element> findElements(Element elementParent, String elementName, String elementPrefix, String elementUri)
{
List<Element> elements = new ArrayList<Element>();
Namespace elementNamespace = new Namespace(elementPrefix, elementUri);
QName qName = new QName(elementName, elementNamespace);
Iterator<?> elementIterator = elementParent.elementIterator(qName);
- while(elementIterator.hasNext())
+ while (elementIterator.hasNext())
{
- Element element = (Element)elementIterator.next();
+ Element element = (Element) elementIterator.next();
elements.add(element);
}
-
+
return elements;
}
@@ -271,11 +276,12 @@
packagesMap.put(prefix, packagesSet);
}
}
-
- public static void checkForUniqueElements(List<Class<? extends Annotation>> list){
+
+ public static void checkForUniqueElements(List<Class<? extends Annotation>> list)
+ {
Set<Class<? extends Annotation>> set = new HashSet<Class<? extends Annotation>>(list);
- if(list.size() != set.size())
- throw new DefinitionException("A certain annotation type is declared more than once as a binding type, " +
- "interceptor binding type or stereotype using XML");
+ if (list.size() != set.size())
+ throw new DefinitionException("A certain annotation type is declared more than once as a binding type, " +
+ "interceptor binding type or stereotype using XML");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlConstants.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlConstants.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlConstants.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -7,11 +7,11 @@
public static final String DEPLOY = "Deploy";
public static final String INTERCEPTORS = "Interceptors";
-
+
public static final String INTERCEPTOR = "Interceptor";
public static final String DECORATORS = "Decorators";
-
+
public static final String DECORATOR = "Decorator";
public static final String BINDING_TYPE = "BindingType";
@@ -29,11 +29,11 @@
public static final String EJB = "EJB";
public static final String EJB_NAME = "ejbName";
-
+
public static final String EJB_LINK = "ejbLink";
public static final String WEB_SERVICE_REF = "WebServiceRef";
-
+
public static final String WSDL_LOCATION = "wsdlLocation";
public static final String TOPIC = "Topic";
@@ -41,32 +41,32 @@
public static final String QUEUE = "Queue";
public static final String URN_PREFIX = "urn:java:";
-
+
public static final String HTTP_PREFIX = "http://";
-
+
public static final String SCHEMA_LOCATION = "schemaLocation";
public static final String MAPPED_NAME = "mappedName";
-
+
public static final String UNIT_NAME = "unitName";
public static final String STANDARD = "Standard";
public static final String NAMESPACE_FILE_NAME = "namespace";
-
+
public static final String SCHEMA_FILE_NAME = "schema.xsd";
-
+
public static final String NAMESPACE_FILE_DELIMETER = " ";
-
+
public static final String PRODUCES = "Produces";
-
+
public static final String VALUE = "value";
-
+
public static final String ARRAY = "Array";
-
+
public static final String JNDI_NAME = "name";
-
+
public static final String JAVA_GLOBAL = "java:global/";
-
+
public static final String JAVA_APP = "java:app/";
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -37,20 +37,20 @@
public class XmlParser
{
private static Log log = Logging.getLog(XmlParser.class);
-
+
private final XmlEnvironment environment;
-
+
private List<BeanElementRegistrator> beanElementRegistrators = new ArrayList<BeanElementRegistrator>();
-
+
private boolean haveAnyDeployElement = false;
-
+
private Map<String, Set<String>> packagesMap = new HashMap<String, Set<String>>();
-
+
public XmlParser(XmlEnvironment environment)
{
- this.environment = environment;
+ this.environment = environment;
}
-
+
public void parse()
{
for (URL url : environment.getBeansXmlUrls())
@@ -65,52 +65,53 @@
}
}
}
-
+
private void parseForArrays(Document document)
{
Element root = document.getRootElement();
checkChildrenForArray(root);
}
-
+
private void checkChildrenForArray(Element element)
{
Iterator<?> childIterator = element.elementIterator();
- while(childIterator.hasNext())
+ while (childIterator.hasNext())
{
- Element child = (Element)childIterator.next();
-
- if(child.getName().equalsIgnoreCase(XmlConstants.ARRAY))
+ Element child = (Element) childIterator.next();
+
+ if (XmlConstants.ARRAY.equalsIgnoreCase(child.getName()))
{
boolean haveNotAnnotation = false;
Iterator<?> arrayIterator = child.elementIterator();
- while(arrayIterator.hasNext())
+ while (arrayIterator.hasNext())
{
- Element arrayChild = (Element)arrayIterator.next();
- AnnotatedClass<?> arrayChildType = ParseXmlHelper.loadElementClass(arrayChild, Object.class, environment, packagesMap);
+ Element arrayChild = (Element) arrayIterator.next();
+ AnnotatedClass<?> arrayChildType = ParseXmlHelper.loadElementClass(arrayChild, Object.class, environment, packagesMap);
boolean isAnnotation = arrayChildType.getRawType().isAnnotation();
- if(!isAnnotation)
+ if (!isAnnotation)
{
- if(haveNotAnnotation)
- throw new DefinitionException("<Array> element have second child which is not annotation, it is '" + arrayChild.getName() + "'");
+ if (haveNotAnnotation)
+ throw new DefinitionException("<Array> element have second child which is not annotation, it is '" +
+ arrayChild.getName() + "'");
haveNotAnnotation = true;
}
}
- if(!haveNotAnnotation)
+ if (!haveNotAnnotation)
throw new DefinitionException("<Array> element must have one child elemen which is not annotation");
}
else
checkChildrenForArray(child);
}
}
-
+
private void parseForAnnotationTypes(Document document)
{
- Element root = document.getRootElement();
-
+ Element root = document.getRootElement();
+
List<Class<? extends Annotation>> bindingTypes = new ArrayList<Class<? extends Annotation>>();
List<Class<? extends Annotation>> interceptorBindingTypes = new ArrayList<Class<? extends Annotation>>();
List<Class<? extends Annotation>> stereotypes = new ArrayList<Class<? extends Annotation>>();
-
+
Iterator<?> elIterator = root.elementIterator();
while (elIterator.hasNext())
{
@@ -118,18 +119,18 @@
boolean isBindingType = ParseXmlHelper.findElementsInEeNamespace(element, XmlConstants.BINDING_TYPE).size() > 0;
boolean isInterceptorBindingType = ParseXmlHelper.findElementsInEeNamespace(element, XmlConstants.INTERCEPTOR_BINDING_TYPE).size() > 0;
boolean isStereotype = ParseXmlHelper.findElementsInEeNamespace(element, XmlConstants.STEREOTYPE).size() > 0;
-
- if(isBindingType || isInterceptorBindingType || isStereotype)
+
+ if (isBindingType || isInterceptorBindingType || isStereotype)
{
Class<? extends Annotation> annotationType = ParseXmlHelper.loadAnnotationClass(element, Annotation.class, environment, packagesMap);
- if(isBindingType)
+ if (isBindingType)
bindingTypes.add(annotationType);
- if(isInterceptorBindingType)
+ if (isInterceptorBindingType)
{
interceptorBindingTypes.add(annotationType);
checkForInterceptorBindingTypeChildren(element);
}
- if(isStereotype)
+ if (isStereotype)
{
stereotypes.add(annotationType);
checkForStereotypeChildren(element);
@@ -140,31 +141,30 @@
ParseXmlHelper.checkForUniqueElements(interceptorBindingTypes);
ParseXmlHelper.checkForUniqueElements(stereotypes);
}
-
+
private void parseForBeans(Document document)
{
- List<Element> beanElements = findBeans(document);
+ List<Element> beanElements = findBeans(document);
for (Element beanElement : beanElements)
{
AnnotatedClass<?> beanClass = ParseXmlHelper.loadElementClass(beanElement, Object.class, environment, packagesMap);
checkBeanElement(beanElement, beanClass);
}
}
-
+
private void parseForDeploy(Document document)
- {
- Element root = document.getRootElement();
-
+ {
+ Element root = document.getRootElement();
+
Iterator<?> elIterator = root.elementIterator();
while (elIterator.hasNext())
{
Element element = (Element) elIterator.next();
- if (ParseXmlHelper.isJavaEeNamespace(element) &&
- element.getName().equalsIgnoreCase(XmlConstants.DEPLOY))
+ if (ParseXmlHelper.isJavaEeNamespace(element) && XmlConstants.DEPLOY.equalsIgnoreCase(element.getName()))
environment.getEnabledDeploymentTypes().addAll(obtainDeploymentTypes(element));
}
- }
-
+ }
+
private Document createDocument(URL url)
{
try
@@ -194,38 +194,37 @@
throw new DefinitionException(message, e);
}
}
-
+
private void checkForInterceptorBindingTypeChildren(Element element)
{
Iterator<?> elIterator = element.elementIterator();
while (elIterator.hasNext())
{
- Element child = (Element)elIterator.next();
+ Element child = (Element) elIterator.next();
Class<? extends Annotation> clazz = ParseXmlHelper.loadAnnotationClass(child, Annotation.class, environment, packagesMap);
- if(!child.getName().equalsIgnoreCase(XmlConstants.INTERCEPTOR_BINDING_TYPE) &&
+ if (!XmlConstants.INTERCEPTOR_BINDING_TYPE.equalsIgnoreCase(child.getName()) &&
!clazz.isAnnotationPresent(InterceptorBindingType.class))
- throw new DefinitionException("Direct child <" + child.getName() + "> of interceptor binding type <" + element.getName() +
- "> declaration must be interceptor binding type");
-
+ throw new DefinitionException("Direct child <" + child.getName() + "> of interceptor binding type <" +
+ element.getName() + "> declaration must be interceptor binding type");
+
}
}
-
+
private void checkForStereotypeChildren(Element stereotypeElement)
{
Iterator<?> elIterator = stereotypeElement.elementIterator();
while (elIterator.hasNext())
{
- Element stereotypeChild = (Element)elIterator.next();
+ Element stereotypeChild = (Element) elIterator.next();
Class<? extends Annotation> stereotypeClass = ParseXmlHelper.loadAnnotationClass(stereotypeChild, Annotation.class, environment, packagesMap);
- if(stereotypeChild.getName().equalsIgnoreCase(XmlConstants.STEREOTYPE) ||
+ if (XmlConstants.STEREOTYPE.equalsIgnoreCase(stereotypeChild.getName()) ||
stereotypeClass.isAnnotationPresent(ScopeType.class) ||
stereotypeClass.isAnnotationPresent(DeploymentType.class) ||
- stereotypeClass.isAnnotationPresent(InterceptorBindingType.class) ||
+ stereotypeClass.isAnnotationPresent(InterceptorBindingType.class) ||
stereotypeClass.isAnnotationPresent(Named.class))
continue;
throw new DefinitionException("Direct child <" + stereotypeChild.getName() + "> of stereotype <" + stereotypeElement.getName() +
"> declaration must be scope type, or deployment type, or interceptor binding type, or javax.annotation.Named");
-
}
}
@@ -239,25 +238,23 @@
while (elIterator.hasNext())
{
Element element = (Element) elIterator.next();
- if (checkBeanElementName(element) &&
- checkBeanElementChildrenNames(element))
+ if (checkBeanElementName(element) && checkBeanElementChildrenNames(element))
beans.add(element);
}
return beans;
- }
+ }
private boolean checkBeanElementName(Element element)
{
if (ParseXmlHelper.isJavaEeNamespace(element) &&
- (element.getName().equalsIgnoreCase(XmlConstants.DEPLOY) ||
- element.getName().equalsIgnoreCase(XmlConstants.INTERCEPTORS) ||
- element.getName().equalsIgnoreCase(XmlConstants.DECORATORS)))
+ (XmlConstants.DEPLOY.equalsIgnoreCase(element.getName()) ||
+ XmlConstants.INTERCEPTORS.equalsIgnoreCase(element.getName()) ||
+ XmlConstants.DECORATORS.equalsIgnoreCase(element.getName())))
return false;
return true;
}
-
private boolean checkBeanElementChildrenNames(Element element)
{
Iterator<?> elIterator = element.elementIterator();
@@ -265,14 +262,14 @@
{
Element child = (Element) elIterator.next();
if (ParseXmlHelper.isJavaEeNamespace(child) &&
- (child.getName().equalsIgnoreCase(XmlConstants.BINDING_TYPE) ||
- child.getName().equalsIgnoreCase(XmlConstants.INTERCEPTOR_BINDING_TYPE) ||
- child.getName().equalsIgnoreCase(XmlConstants.STEREOTYPE)))
+ (XmlConstants.BINDING_TYPE.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.INTERCEPTOR_BINDING_TYPE.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.STEREOTYPE.equalsIgnoreCase(child.getName())))
return false;
}
return true;
}
-
+
// TODO Make this object orientated
private List<Class<? extends Annotation>> obtainDeploymentTypes(Element element)
{
@@ -281,57 +278,57 @@
List<Element> standardElements = ParseXmlHelper.findElementsInEeNamespace(element, XmlConstants.STANDARD);
if (standardElements.size() == 0)
- throw new DeploymentException("The @Standard deployment type must be declared");
-
+ throw new DeploymentException("The @Standard deployment type must be declared");
+
List<Class<? extends Annotation>> deploymentClasses = new ArrayList<Class<? extends Annotation>>();
Iterator<?> deployIterator = element.elementIterator();
- while(deployIterator.hasNext())
+ while (deployIterator.hasNext())
{
- Element deploymentElement = (Element)deployIterator.next();
-
+ Element deploymentElement = (Element) deployIterator.next();
+
String elementName = deploymentElement.getName();
String elementPrefix = deploymentElement.getNamespacePrefix();
String elementUri = deploymentElement.getNamespaceURI();
List<Element> deploymentElements = ParseXmlHelper.findElements(element, elementName, elementPrefix, elementUri);
- if(deploymentElements.size() != 1)
+ if (deploymentElements.size() != 1)
throw new DefinitionException("The same deployment type '" + deploymentElement.getName() + "' is declared more than once");
-
+
Class<? extends Annotation> deploymentClass = ParseXmlHelper.loadAnnotationClass(deploymentElement, Annotation.class, environment, packagesMap);
-
- if(!deploymentClass.isAnnotationPresent(DeploymentType.class))
+
+ if (!deploymentClass.isAnnotationPresent(DeploymentType.class))
throw new DefinitionException("<Deploy> child '" + deploymentElement.getName() + "' must be a deployment type");
-
+
deploymentClasses.add(deploymentClass);
}
haveAnyDeployElement = true;
return deploymentClasses;
}
-
+
private void checkBeanElement(Element beanElement, AnnotatedClass<?> beanClass)
{
beanElementRegistrators.add(new JmsResourceElementRegistrator(new NotSimpleBeanChildrenChecker(environment, packagesMap)));
beanElementRegistrators.add(new ResourceElementRegistrator(new ResourceBeanChildrenChecker(environment, packagesMap)));
beanElementRegistrators.add(new SessionBeanElementRegistrator(new NotSimpleBeanChildrenChecker(environment, packagesMap), environment.getEjbDescriptors()));
beanElementRegistrators.add(new SimpleBeanElementRegistrator(new SimpleBeanChildrenChecker(environment, packagesMap), environment.getEjbDescriptors()));
-
+
boolean isValidType = false;
- for(BeanElementRegistrator beanElementRegistrator : beanElementRegistrators)
+ for (BeanElementRegistrator beanElementRegistrator : beanElementRegistrators)
{
- if(beanElementRegistrator.accept(beanElement, beanClass))
+ if (beanElementRegistrator.accept(beanElement, beanClass))
{
beanElementRegistrator.registerBeanElement(beanElement, beanClass);
isValidType = true;
break;
}
}
-
- if(!isValidType)
+
+ if (!isValidType)
throw new DefinitionException("Can't determine type of bean element <" + beanElement.getName() + ">");
}
-
+
private void fullFillPackagesMap(Document document, URL xmlUrl)
{
- Element root = document.getRootElement();
+ Element root = document.getRootElement();
ParseXmlHelper.checkRootAttributes(root, packagesMap, environment, xmlUrl);
ParseXmlHelper.checkRootDeclaredNamespaces(root, packagesMap, environment, xmlUrl);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/BeanChildrenChecker.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -8,10 +8,10 @@
import org.jboss.webbeans.xml.XmlEnvironment;
public interface BeanChildrenChecker
-{
+{
void checkChildren(Element beanElement, AnnotatedClass<?> beanClass);
-
+
XmlEnvironment getXmlEnvironment();
-
+
Map<String, Set<String>> getPackagesMap();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -37,75 +37,75 @@
public abstract class AbstractBeanChildrenChecker extends BeanChildrenCheckerImpl
{
-
+
private Set<AnnotatedField<?>> beanFields;
-
- private List<Method> beanMethods;
-
+
+ private List<Method> beanMethods;
+
private boolean haveBeanDeploymentTypeDeclaration = false;
-
+
private boolean haveBeanScopeTypeDeclaration = false;
-
+
protected boolean haveBeanInterceptorDeclaration = false;
-
+
protected boolean haveBeanDecoratorDeclaration = false;
-
+
protected List<AnnotatedClass<?>> constructorParameters = new ArrayList<AnnotatedClass<?>>();
-
+
protected abstract void checkForInterceptorChild(Element beanElement);
-
+
protected abstract void checkForDecoratorChild(Element beanElement);
-
+
protected abstract void checkChildForInterceptorType(Element beanElement);
-
+
protected abstract void checkChildForDecoratorType(Element beanElement);
-
+
protected abstract void checkForConstructor(Element beanElement, AnnotatedClass<?> beanClass);
-
+
protected abstract void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass);
-
+
protected AbstractBeanChildrenChecker(XmlEnvironment environment, Map<String, Set<String>> packagesMap)
{
super(environment, packagesMap);
}
-
+
public void checkChildren(Element beanElement, AnnotatedClass<?> beanClass)
{
beanFields = beanClass.getFields();
beanMethods = Arrays.asList(beanClass.getRawType().getDeclaredMethods());
-
+
checkForInterceptorChild(beanElement);
checkForDecoratorChild(beanElement);
-
+
haveBeanDeploymentTypeDeclaration = false;
haveBeanScopeTypeDeclaration = false;
haveBeanInterceptorDeclaration = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 0;
haveBeanDecoratorDeclaration = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 0;
-
+
Iterator<?> beanIterator = beanElement.elementIterator();
- while(beanIterator.hasNext())
+ while (beanIterator.hasNext())
{
- Element beanChildElement = (Element)beanIterator.next();
+ Element beanChildElement = (Element) beanIterator.next();
checkBeanChild(beanChildElement, beanClass);
}
checkForConstructor(beanElement, beanClass);
}
-
+
private void checkBeanChild(Element beanChildElement, AnnotatedClass<?> beanClass)
{
- if(beanChildElement.getName().equalsIgnoreCase(XmlConstants.ARRAY))
+ if (XmlConstants.ARRAY.equalsIgnoreCase(beanChildElement.getName()))
return;
-
+
List<AnnotatedClass<?>> beanChildClassList = ParseXmlHelper.tryLoadElementClass(beanChildElement, Object.class, environment, packagesMap);
-
- if(beanChildClassList.size() == 0)
- {
+
+ if (beanChildClassList.size() == 0)
+ {
Element beanElement = beanChildElement.getParent();
Namespace beanNamespace = beanElement.getNamespace();
Namespace beanChildNamespace = beanChildElement.getNamespace();
- if(beanChildNamespace.equals(beanNamespace))
+ if (beanChildNamespace.equals(beanNamespace))
{
- //bean child element declaring a method or field of the bean.
+ // bean child element declaring a method or field of the bean.
checkFieldOrMethodChild(beanChildElement, beanClass);
return;
}
@@ -116,137 +116,131 @@
Class<?> beanChildType = beanChildClass.getRawType();
boolean isJavaClass = !beanChildType.isEnum() && !beanChildType.isPrimitive() && !beanChildType.isInterface();
boolean isInterface = beanChildType.isInterface() && !beanChildType.isAnnotation();
- if(beanChildType.isAnnotation())
+ if (beanChildType.isAnnotation())
{
- //bean child element declaring type-level metadata
+ // bean child element declaring type-level metadata
checkAnnotationChild(beanChildElement, beanChildClass, beanClass);
return;
}
- if(isJavaClass || isInterface)
+ if (isJavaClass || isInterface)
{
- //bean child element declaring a parameter of the bean constructor
+ // bean child element declaring a parameter of the bean constructor
constructorParameters.add(beanChildClass);
return;
}
}
-
- throw new DefinitionException("Can't determine type of element <" + beanChildElement.getName() + "> in bean '" +
- beanChildElement.getParent().getName() + "'");
+
+ throw new DefinitionException("Can't determine type of element <" + beanChildElement.getName() + "> in bean '" + beanChildElement.getParent().getName() + "'");
}
-
+
private void checkAnnotationChild(Element beanChildElement, AnnotatedClass<?> beanChildClass, AnnotatedClass<?> beanClass)
{
- if(beanChildClass.isAnnotationPresent(DeploymentType.class))
+ if (beanChildClass.isAnnotationPresent(DeploymentType.class))
{
- if(haveBeanDeploymentTypeDeclaration)
- throw new DefinitionException("Only one deployment type declaration allowed for bean '" +
- beanChildElement.getParent().getName() + "'");
+ if (haveBeanDeploymentTypeDeclaration)
+ throw new DefinitionException("Only one deployment type declaration allowed for bean '" + beanChildElement.getParent().getName() + "'");
haveBeanDeploymentTypeDeclaration = true;
return;
}
- if(beanChildClass.isAnnotationPresent(ScopeType.class))
+ if (beanChildClass.isAnnotationPresent(ScopeType.class))
{
- if(haveBeanScopeTypeDeclaration)
- throw new DefinitionException("Only one scope type declaration allowed for bean '" +
- beanChildElement.getParent().getName() + "'");
+ if (haveBeanScopeTypeDeclaration)
+ throw new DefinitionException("Only one scope type declaration allowed for bean '" + beanChildElement.getParent().getName() + "'");
haveBeanScopeTypeDeclaration = true;
return;
}
- if(beanChildClass.isAnnotationPresent(Interceptor.class))
+ if (beanChildClass.isAnnotationPresent(Interceptor.class))
{
checkChildForInterceptorType(beanChildElement);
return;
}
- if(beanChildClass.isAnnotationPresent(Decorator.class))
+ if (beanChildClass.isAnnotationPresent(Decorator.class))
{
checkChildForDecoratorType(beanChildElement);
return;
}
- if(beanChildClass.isAnnotationPresent(BindingType.class) || beanChildClass.isAnnotationPresent(InterceptorBindingType.class) ||
+ if (beanChildClass.isAnnotationPresent(BindingType.class) || beanChildClass.isAnnotationPresent(InterceptorBindingType.class) ||
beanChildClass.isAnnotationPresent(Stereotype.class) || beanChildClass.isAnnotationPresent(Named.class) ||
- beanChildClass.isAnnotationPresent(Specializes.class) || beanChildClass.isAnnotationPresent(Realizes.class) ||
+ beanChildClass.isAnnotationPresent(Specializes.class) || beanChildClass.isAnnotationPresent(Realizes.class) ||
beanChildClass.getRawType().equals(BindingType.class) || beanChildClass.getRawType().equals(InterceptorBindingType.class) ||
beanChildClass.getRawType().equals(Stereotype.class) || beanChildClass.getRawType().equals(Named.class) ||
- beanChildClass.getRawType().equals(Specializes.class) || beanChildClass.getRawType().equals(Realizes.class) ||
- beanChildClass.isAnnotationPresent(Resource.class) || beanChildClass.isAnnotationPresent(EJB.class) ||
+ beanChildClass.getRawType().equals(Specializes.class) || beanChildClass.getRawType().equals(Realizes.class) ||
+ beanChildClass.isAnnotationPresent(Resource.class) || beanChildClass.isAnnotationPresent(EJB.class)||
beanChildClass.isAnnotationPresent(WebServiceRef.class) || beanChildClass.isAnnotationPresent(PersistenceContext.class) ||
beanChildClass.isAnnotationPresent(PersistenceUnit.class))
return;
- if(beanChildClass.getRawType().equals(Resource.class) || beanChildClass.getRawType().equals(EJB.class) ||
+ if (beanChildClass.getRawType().equals(Resource.class) || beanChildClass.getRawType().equals(EJB.class) ||
beanChildClass.getRawType().equals(WebServiceRef.class) || beanChildClass.getRawType().equals(PersistenceContext.class) ||
beanChildClass.getRawType().equals(PersistenceUnit.class))
{
checkRIBean(beanChildElement.getParent(), beanClass);
return;
- }
-
- throw new DefinitionException("Can't determine annotation type of <" + beanChildElement.getName() + "> element in bean '" +
- beanChildElement.getParent().getName() + "'");
+ }
+
+ throw new DefinitionException("Can't determine annotation type of <" + beanChildElement.getName() + "> element in bean '" + beanChildElement.getParent().getName() + "'");
}
-
+
private void checkFieldOrMethodChild(Element beanChildElement, AnnotatedClass<?> beanClass)
- { //TODO: not finished
+ { // TODO: not finished
boolean isField = false;
boolean isMethod = false;
-
- for(AnnotatedField<?> field : beanFields)
+
+ for (AnnotatedField<?> field : beanFields)
{
- if(beanChildElement.getName().equalsIgnoreCase(field.getName()))
+ if (field.getName().equalsIgnoreCase(beanChildElement.getName()))
{
- if(isField)
- throw new DefinitionException("Bean class '" + beanClass.getName() + "' does not have exactly one field " +
- "with the specified name '" + beanChildElement.getName() + "'");
+ if (isField)
+ throw new DefinitionException("Bean class '" + beanClass.getName() + "' does not have exactly one field " + "with the specified name '" + beanChildElement.getName() + "'");
isField = true;
}
}
-
- for(Method method : beanMethods)
+
+ for (Method method : beanMethods)
{
- if(beanChildElement.getName().equalsIgnoreCase(method.getName()))
+ if (method.getName().equalsIgnoreCase(beanChildElement.getName()))
isMethod = true;
}
-
- if(isField && isMethod)
+
+ if (isField && isMethod)
throw new DefinitionException("The name of the child element <" + beanChildElement.getName() +
"> matches the name of both a method and a field of the bean class '" + beanClass.getName() + "'");
-
- if(isField)
+
+ if (isField)
{
checkFieldChild(beanChildElement, beanClass);
return;
}
-
- if(isMethod)
+
+ if (isMethod)
{
checkMethodChild(beanChildElement, beanClass);
return;
}
-
+
throw new DefinitionException("The name of the child element <" + beanChildElement.getName() +
"> not matches the name of a method or a field of the bean class '" + beanClass.getName() + "'");
}
-
+
private void checkFieldChild(Element beanChildElement, AnnotatedClass<?> beanClass)
- {//TODO: not finished
+ {// TODO: not finished
Element elementParent = beanChildElement.getParent();
String elementName = beanChildElement.getName();
String elementPrefix = beanChildElement.getNamespacePrefix();
String elementUri = beanChildElement.getNamespaceURI();
-
- if(ParseXmlHelper.findElements(elementParent, elementName, elementPrefix, elementUri).size() > 1)
+
+ if (ParseXmlHelper.findElements(elementParent, elementName, elementPrefix, elementUri).size() > 1)
throw new DefinitionException("More than one child element of a bean '" + elementParent.getName() +
"' declaration represents the same field'" + elementName + "'");
-
- if(beanChildElement.elements().size() > 1 &&
+
+ if (beanChildElement.elements().size() > 1 &&
beanChildElement.elements().size() != ParseXmlHelper.findElementsInEeNamespace(beanChildElement, XmlConstants.VALUE).size())
- throw new DefinitionException("Declaration of a field '" + beanChildElement.getName() + "' has more than one direct child element, " +
- "and at least one of these elements is something other than a <value> element in the Java EE namespace");
-
-
+ throw new DefinitionException("Declaration of a field '" + beanChildElement.getName() + "' has more than one direct child element, " +
+ "and at least one of these elements is something other than a <value> element in the Java EE namespace");
+
}
-
+
private void checkMethodChild(Element beanChildElement, AnnotatedClass<?> beanClass)
{
- //TODO: not finished
+ // TODO: not finished
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/NotSimpleBeanChildrenChecker.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -20,36 +20,37 @@
protected void checkForInterceptorChild(Element beanElement)
{
- if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
+ if (ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
throw new DefinitionException("Not a simple bean '" + beanElement.getName() + "' contains direct child <" +
- XmlConstants.INTERCEPTOR + ">");
+ XmlConstants.INTERCEPTOR + ">");
}
-
+
protected void checkForDecoratorChild(Element beanElement)
{
- if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
+ if (ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
throw new DefinitionException("Not a simple bean '" + beanElement.getName() + "' contains direct child <" +
XmlConstants.DECORATOR + ">");
}
-
+
protected void checkChildForInterceptorType(Element beanChildElement)
{
throw new DefinitionException("Declaration of not a simple bean '" + beanChildElement.getParent().getName() +
- "' contains a child <" + beanChildElement.getName() + "> which type is javax.interceptor.Interceptor");
+ "' contains a child <" + beanChildElement.getName() + "> which type is javax.interceptor.Interceptor");
}
-
+
protected void checkChildForDecoratorType(Element beanChildElement)
{
throw new DefinitionException("Declaration of not a simple bean '" + beanChildElement.getParent().getName() +
- "' contains a child <" + beanChildElement.getName() + "> which type is javax.decorator.Decorator");
+ "' contains a child <" + beanChildElement.getName() + "> which type is javax.decorator.Decorator");
}
-
+
protected void checkForConstructor(Element beanElement, AnnotatedClass<?> beanClass)
{
- //There is nothing to validate
+ // There is nothing to validate
}
-
- protected void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass){
+
+ protected void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass)
+ {
throw new DefinitionException("It is impossible determine some kind of resource in not Resource Bean");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/ResourceBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/ResourceBeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/ResourceBeanChildrenChecker.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -22,130 +22,130 @@
protected void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass)
{
List<Element> resourceElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.RESOURCE);
- if(resourceElements.size() > 0)
+ if (resourceElements.size() > 0)
{
checkResourceElements(resourceElements);
return;
}
-
+
List<Element> persContextElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.PERSISTENCE_CONTEXT);
- if(persContextElements.size() > 0)
+ if (persContextElements.size() > 0)
{
checkPersContextElements(persContextElements);
return;
}
-
+
List<Element> persUnitElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.PERSISTENCE_UNIT);
- if(persUnitElements.size() > 0)
+ if (persUnitElements.size() > 0)
{
checkPersUnitElements(persUnitElements);
return;
}
-
+
List<Element> ejbElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.EJB);
- if(ejbElements.size() > 0)
+ if (ejbElements.size() > 0)
{
checkEjbElements(ejbElements);
return;
}
-
+
List<Element> webServiceRefElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.WEB_SERVICE_REF);
- if(webServiceRefElements.size() > 0)
+ if (webServiceRefElements.size() > 0)
{
checkWebServiceRefElements(webServiceRefElements);
return;
- }
+ }
}
-
+
private void checkResourceElements(List<Element> resourceElements)
{
Element resourceElement = resourceElements.get(0);
-
- if(resourceElements.size() > 1)
+
+ if (resourceElements.size() > 1)
throw new DefinitionException("There is more than one <Resource> elements in '" + resourceElement.getParent().getName() + "'");
-
+
List<Element> nameElements = ParseXmlHelper.findElementsInEeNamespace(resourceElement, XmlConstants.JNDI_NAME);
List<Element> mappedNameElements = ParseXmlHelper.findElementsInEeNamespace(resourceElement, XmlConstants.MAPPED_NAME);
-
- if(nameElements.size() + mappedNameElements.size() != 1)
- throw new DefinitionException("For a Java EE resource '" + resourceElement.getParent().getName() + "', JNDI name " +
+
+ if (nameElements.size() + mappedNameElements.size() != 1)
+ throw new DefinitionException("For a Java EE resource '" + resourceElement.getParent().getName() + "', JNDI name " +
"or mapped name must be specified using the <name> or <mappedName> child elements of the <Resource> element");
-
- if(nameElements.size() == 1)
+
+ if (nameElements.size() == 1)
checkJndiNameElementValue(nameElements.get(0));
}
-
+
private void checkPersContextElements(List<Element> persContextElements)
{
Element persContextElement = persContextElements.get(0);
-
- if(persContextElements.size() > 1)
+
+ if (persContextElements.size() > 1)
throw new DefinitionException("There is more than one <PersistenceContext> elements in '" +
persContextElement.getParent().getName() + "'");
-
+
List<Element> unitNameElements = ParseXmlHelper.findElementsInEeNamespace(persContextElement, XmlConstants.UNIT_NAME);
-
- if(unitNameElements.size() != 1)
- throw new DefinitionException("For a persistence context '" + persContextElement.getParent().getName() + "', " +
+
+ if (unitNameElements.size() != 1)
+ throw new DefinitionException("For a persistence context '" + persContextElement.getParent().getName() + "', " +
"a persistence unit name must be specified using the <unitName> child element of the <PersistenceContext> element");
}
-
+
private void checkPersUnitElements(List<Element> persUnitElements)
{
Element persUnitElement = persUnitElements.get(0);
-
- if(persUnitElements.size() > 1)
+
+ if (persUnitElements.size() > 1)
throw new DefinitionException("There is more than one <PersistenceUnit> elements in '" + persUnitElement.getParent().getName() + "'");
-
+
List<Element> unitNameElements = ParseXmlHelper.findElementsInEeNamespace(persUnitElement, XmlConstants.UNIT_NAME);
- if(unitNameElements.size() != 1)
- throw new DefinitionException("For a persistence unit '" + persUnitElement.getParent().getName() + "', " +
+ if (unitNameElements.size() != 1)
+ throw new DefinitionException("For a persistence unit '" + persUnitElement.getParent().getName() + "', " +
"a persistence unit name must be specified using the <unitName> child element of the <PersistenceUnit> element");
}
-
+
private void checkEjbElements(List<Element> ejbElements)
{
Element ejbElement = ejbElements.get(0);
-
- if(ejbElements.size() > 1)
+
+ if (ejbElements.size() > 1)
throw new DefinitionException("There is more than one <EJB> elements in '" + ejbElement.getParent().getName() + "'");
-
+
List<Element> nameElements = ParseXmlHelper.findElementsInEeNamespace(ejbElement, XmlConstants.JNDI_NAME);
List<Element> mappedNameElements = ParseXmlHelper.findElementsInEeNamespace(ejbElement, XmlConstants.MAPPED_NAME);
List<Element> ejbLinkElements = ParseXmlHelper.findElementsInEeNamespace(ejbElement, XmlConstants.EJB_LINK);
-
- if(nameElements.size() + mappedNameElements.size() + ejbLinkElements.size() != 1)
- throw new DefinitionException("For a remote EJB '" + ejbElement.getParent().getName() + "', JNDI name, mapped name or EJB link " +
+
+ if (nameElements.size() + mappedNameElements.size() + ejbLinkElements.size() != 1)
+ throw new DefinitionException("For a remote EJB '" + ejbElement.getParent().getName() + "', JNDI name, mapped name or EJB link " +
"must be specified using the <name>, <mappedName> or <ejbLink> child elements of the <EJB> element");
-
- if(nameElements.size() == 1)
+
+ if (nameElements.size() == 1)
checkJndiNameElementValue(nameElements.get(0));
}
-
+
private void checkWebServiceRefElements(List<Element> webServiceRefElements)
{
Element webServiceRefElement = webServiceRefElements.get(0);
-
- if(webServiceRefElements.size() > 1)
- throw new DefinitionException("There is more than one <WebServiceRef> elements in '" +
- webServiceRefElement.getParent().getName() + "'");
-
+
+ if (webServiceRefElements.size() > 1)
+ throw new DefinitionException("There is more than one <WebServiceRef> elements in '" + webServiceRefElement.getParent().getName() + "'");
+
List<Element> nameElements = ParseXmlHelper.findElementsInEeNamespace(webServiceRefElement, XmlConstants.JNDI_NAME);
List<Element> mappedNameElements = ParseXmlHelper.findElementsInEeNamespace(webServiceRefElement, XmlConstants.MAPPED_NAME);
-
- if(nameElements.size() == 0 && mappedNameElements.size() == 0)
- throw new DefinitionException("For a web service '" + webServiceRefElement.getParent().getName() + "', JNDI name " +
+
+ if (nameElements.size() == 0 && mappedNameElements.size() == 0)
+ throw new DefinitionException("For a web service '" + webServiceRefElement.getParent().getName() + "', JNDI name " +
"or mapped name must be specified using the <name> or <mappedName> child elements of the <WebServiceRef> element");
-
- if(nameElements.size() == 1)
+
+ if (nameElements.size() == 1)
checkJndiNameElementValue(nameElements.get(0));
}
-
+
private void checkJndiNameElementValue(Element nameElement)
{
String nameValue = nameElement.getData().toString();
- if(!nameValue.startsWith(XmlConstants.JAVA_GLOBAL) && !nameValue.startsWith(XmlConstants.JAVA_APP))
- throw new DefinitionException("The JNDI name specified by the <name> element in <" + nameElement.getParent().getName() + "> for '" +
- nameElement.getParent().getParent().getName() + "' must be a name in the global java:global or application java:app naming context");
+ if (!nameValue.startsWith(XmlConstants.JAVA_GLOBAL) && !nameValue.startsWith(XmlConstants.JAVA_APP))
+ throw new DefinitionException("The JNDI name specified by the <name> element in <" + nameElement.getParent().getName() +
+ "> for '" + nameElement.getParent().getParent().getName() +
+ "' must be a name in the global java:global or application java:app naming context");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -24,73 +24,74 @@
protected void checkForDecoratorChild(Element beanElement)
{
- if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
+ if (ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() > 1)
throw new DefinitionException("A simple bean element <" + beanElement.getName() + "> has more than one direct child <" +
- XmlConstants.INTERCEPTOR + ">");
+ XmlConstants.INTERCEPTOR + ">");
}
-
+
protected void checkForInterceptorChild(Element beanElement)
{
- if(ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
+ if (ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() > 1)
throw new DefinitionException("A simple bean element <" + beanElement.getName() + "> has more than one direct child <" +
XmlConstants.DECORATOR + ">");
}
-
+
protected void checkChildForInterceptorType(Element beanChildElement)
{
- if(haveBeanInterceptorDeclaration)
+ if (haveBeanInterceptorDeclaration)
throw new DefinitionException("There is second element of interceptor type <" + beanChildElement.getName() +
"> in bean '" + beanChildElement.getParent().getName() + "'");
- haveBeanInterceptorDeclaration = true;
+ haveBeanInterceptorDeclaration = true;
}
-
+
protected void checkChildForDecoratorType(Element beanChildElement)
{
- if(haveBeanDecoratorDeclaration)
+ if (haveBeanDecoratorDeclaration)
throw new DefinitionException("There is second element of decorator type <" + beanChildElement.getName() +
"> in bean '" + beanChildElement.getParent().getName() + "'");
- haveBeanDecoratorDeclaration = true;
+ haveBeanDecoratorDeclaration = true;
}
-
+
protected void checkForConstructor(Element beanElement, AnnotatedClass<?> beanClass)
{
- if(constructorParameters.size() == 0)
+ if (constructorParameters.size() == 0)
return;
-
- List<AnnotatedConstructor<?>> matchableConstructors = new ArrayList<AnnotatedConstructor<?>>();
-
- for(AnnotatedConstructor<?> constructor : beanClass.getConstructors())
+
+ List<AnnotatedConstructor<?>> matchableConstructors = new ArrayList<AnnotatedConstructor<?>>();
+
+ for (AnnotatedConstructor<?> constructor : beanClass.getConstructors())
{
- List<? extends AnnotatedParameter<?>> parameters = constructor.getParameters();
-
- if(parameters.size() != constructorParameters.size())
+ List<? extends AnnotatedParameter<?>> parameters = constructor.getParameters();
+
+ if (parameters.size() != constructorParameters.size())
continue;
-
+
boolean isMacthable = true;
-
- for(int i = 0; i < parameters.size(); i++)
+
+ for (int i = 0; i < parameters.size(); i++)
{
- if(!parameters.get(i).isAssignableFrom(constructorParameters.get(i)))
+ if (!parameters.get(i).isAssignableFrom(constructorParameters.get(i)))
{
isMacthable = false;
break;
- }
+ }
}
-
- if(isMacthable)
+
+ if (isMacthable)
matchableConstructors.add(constructor);
}
-
- if(matchableConstructors.size() == 0)
+
+ if (matchableConstructors.size() == 0)
throw new DefinitionException("There is no constructor of the simple bean '" + beanElement.getName() +
"' with the same number and types of parameters as declared");
-
- if(matchableConstructors.size() > 1)
+
+ if (matchableConstructors.size() > 1)
throw new DefinitionException("There is more than one constructor of the simple bean '" + beanElement.getName() +
"' with the same number and types of parameters as declared");
}
-
- protected void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass){
+
+ protected void checkRIBean(Element beanElement, AnnotatedClass<?> beanClass)
+ {
throw new DefinitionException("It is impossible determine some kind of resource in not Resource Bean");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/impl/BeanChildrenCheckerImpl.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -9,20 +9,20 @@
public abstract class BeanChildrenCheckerImpl implements BeanChildrenChecker
{
protected final XmlEnvironment environment;
-
+
protected final Map<String, Set<String>> packagesMap;
-
+
public BeanChildrenCheckerImpl(XmlEnvironment environment, Map<String, Set<String>> packagesMap)
{
this.environment = environment;
this.packagesMap = packagesMap;
}
-
+
public XmlEnvironment getXmlEnvironment()
{
return this.environment;
}
-
+
public Map<String, Set<String>> getPackagesMap()
{
return this.packagesMap;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/BeanElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/BeanElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/BeanElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -6,6 +6,6 @@
public interface BeanElementRegistrator
{
boolean accept(Element beanElement, AnnotatedClass<?> beanClass);
-
+
void registerBeanElement(Element beanElement, AnnotatedClass<?> beanClass);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/JmsResourceElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/JmsResourceElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/JmsResourceElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -16,8 +16,8 @@
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
if (ParseXmlHelper.isJavaEeNamespace(beanElement) &&
- (beanElement.getName().equalsIgnoreCase(XmlConstants.TOPIC) ||
- beanElement.getName().equalsIgnoreCase(XmlConstants.QUEUE)))
+ (XmlConstants.TOPIC.equalsIgnoreCase(beanElement.getName()) ||
+ XmlConstants.QUEUE.equalsIgnoreCase(beanElement.getName())))
return true;
return false;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/NotSimpleBeanElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/NotSimpleBeanElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/NotSimpleBeanElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -11,9 +11,9 @@
{
super(childrenChecker);
}
-
+
protected void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass)
{
- // There is nothing to validate
+ // There is nothing to validate
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/ResourceElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/ResourceElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/ResourceElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -43,63 +43,63 @@
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
if (ParseXmlHelper.isJavaEeNamespace(beanElement) &&
- (beanElement.getName().equalsIgnoreCase(XmlConstants.TOPIC) ||
- beanElement.getName().equalsIgnoreCase(XmlConstants.QUEUE)))
+ (XmlConstants.TOPIC.equalsIgnoreCase(beanElement.getName()) ||
+ XmlConstants.QUEUE.equalsIgnoreCase(beanElement.getName())))
return false;
-
+
Iterator<?> elIterator = beanElement.elementIterator();
while (elIterator.hasNext())
{
Element child = (Element) elIterator.next();
if (ParseXmlHelper.isJavaEeNamespace(child) &&
- (child.getName().equalsIgnoreCase(XmlConstants.RESOURCE) ||
- child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_CONTEXT) ||
- child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_UNIT) ||
- child.getName().equalsIgnoreCase(XmlConstants.EJB) ||
- child.getName().equalsIgnoreCase(XmlConstants.WEB_SERVICE_REF)))
+ (XmlConstants.RESOURCE.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.PERSISTENCE_CONTEXT.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.PERSISTENCE_UNIT.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.EJB.equalsIgnoreCase(child.getName()) ||
+ XmlConstants.WEB_SERVICE_REF.equalsIgnoreCase(child.getName())))
return true;
}
return false;
}
-
+
protected void register(Element beanElement, AnnotatedClass<?> beanClass)
- {
+ {
List<Element> resourceElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.RESOURCE);
- if(resourceElements.size() > 0)
+ if (resourceElements.size() > 0)
{
registerResourceBean(resourceElements.get(0), beanClass);
return;
}
-
+
List<Element> persContextElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.PERSISTENCE_CONTEXT);
- if(persContextElements.size() > 0)
+ if (persContextElements.size() > 0)
{
registerPersContextBean(persContextElements.get(0), beanClass);
return;
}
-
+
List<Element> persUnitElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.PERSISTENCE_UNIT);
- if(persUnitElements.size() > 0)
+ if (persUnitElements.size() > 0)
{
registerPersUnitBean(persUnitElements.get(0), beanClass);
return;
}
-
+
List<Element> ejbElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.EJB);
- if(ejbElements.size() > 0)
+ if (ejbElements.size() > 0)
{
registerEjbBean(ejbElements.get(0), beanClass);
return;
}
-
+
List<Element> webServiceRefElements = ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.WEB_SERVICE_REF);
- if(webServiceRefElements.size() > 0)
+ if (webServiceRefElements.size() > 0)
{
registerWebServiceRefBean(webServiceRefElements.get(0), beanClass);
return;
}
}
-
+
private void registerResourceBean(Element resourceElement, AnnotatedClass<?> beanClass)
{
Class<? extends Annotation> deploymentType = obtainDeploymentType(resourceElement.getParent());
@@ -107,43 +107,43 @@
Class<?> type = beanClass.getRawType();
String jndiName = obtainElementValue(resourceElement, XmlConstants.JNDI_NAME);
String mappedName = obtainElementValue(resourceElement, XmlConstants.MAPPED_NAME);
-
+
RIBean<?> bean = new ResourceBean(environment.getManager(), deploymentType, bindings, type, jndiName, mappedName);
-
+
if (environment.getServices().contains(ResourceServices.class))
{
environment.getResourceBeans().add((AbstractJavaEEResourceBean<?>) bean);
}
}
-
+
private void registerPersContextBean(Element persContextElement, AnnotatedClass<?> beanClass)
{
Class<? extends Annotation> deploymentType = obtainDeploymentType(persContextElement.getParent());
Set<Annotation> bindings = obtainBindings(persContextElement.getParent());
String unitName = obtainElementValue(persContextElement, XmlConstants.UNIT_NAME);
-
+
RIBean<?> bean = new PersistenceContextBean(environment.getManager(), deploymentType, bindings, unitName);
-
+
if (environment.getServices().contains(JpaServices.class))
{
environment.getResourceBeans().add((AbstractJavaEEResourceBean<?>) bean);
- }
+ }
}
-
+
private void registerPersUnitBean(Element persUnitElement, AnnotatedClass<?> beanClass)
{
Class<? extends Annotation> deploymentType = obtainDeploymentType(persUnitElement.getParent());
Set<Annotation> bindings = obtainBindings(persUnitElement.getParent());
String unitName = obtainElementValue(persUnitElement, XmlConstants.UNIT_NAME);
-
+
RIBean<?> bean = new PersistenceUnitBean(environment.getManager(), deploymentType, bindings, unitName);
-
+
if (environment.getServices().contains(JpaServices.class))
{
environment.getResourceBeans().add((AbstractJavaEEResourceBean<?>) bean);
}
}
-
+
private void registerEjbBean(Element ejbElement, AnnotatedClass<?> beanClass)
{
Class<? extends Annotation> deploymentType = obtainDeploymentType(ejbElement.getParent());
@@ -151,16 +151,17 @@
Class<?> type = beanClass.getRawType();
String jndiName = obtainElementValue(ejbElement, XmlConstants.JNDI_NAME);
String mappedName = obtainElementValue(ejbElement, XmlConstants.MAPPED_NAME);
- String ejbLink = obtainElementValue(ejbElement, XmlConstants.EJB_LINK);;
-
+ String ejbLink = obtainElementValue(ejbElement, XmlConstants.EJB_LINK);
+ ;
+
RIBean<?> bean = new RemoteEjbBean(environment.getManager(), deploymentType, bindings, type, jndiName, mappedName, ejbLink);
-
+
if (environment.getServices().contains(EjbServices.class))
{
environment.getResourceBeans().add((AbstractJavaEEResourceBean<?>) bean);
}
}
-
+
private void registerWebServiceRefBean(Element webServiceRefElement, AnnotatedClass<?> beanClass)
{
Class<? extends Annotation> deploymentType = obtainDeploymentType(webServiceRefElement.getParent());
@@ -169,15 +170,15 @@
String jndiName = obtainElementValue(webServiceRefElement, XmlConstants.JNDI_NAME);
String mappedName = obtainElementValue(webServiceRefElement, XmlConstants.MAPPED_NAME);
String wsdlLocation = obtainElementValue(webServiceRefElement, XmlConstants.WSDL_LOCATION);
-
+
RIBean<?> bean = new WebServiceBean(environment.getManager(), deploymentType, bindings, type, jndiName, mappedName, wsdlLocation);
-
+
if (environment.getServices().contains(WebServices.class))
{
environment.getResourceBeans().add((AbstractJavaEEResourceBean<?>) bean);
}
}
-
+
private Class<? extends Annotation> obtainDeploymentType(Element beanElement)
{
Iterator<?> elIterator = beanElement.elementIterator();
@@ -185,26 +186,23 @@
{
Element childElement = (Element) elIterator.next();
AnnotatedClass<?> childClass = ParseXmlHelper.loadElementClass(childElement, Object.class, environment, packagesMap);
- if(childClass.getRawType().isAnnotation() && childClass.isAnnotationPresent(DeploymentType.class))
+ if (childClass.getRawType().isAnnotation() && childClass.isAnnotationPresent(DeploymentType.class))
return ParseXmlHelper.loadAnnotationClass(childElement, Annotation.class, environment, packagesMap);
}
-
+
return null;
}
-
+
private Set<Annotation> obtainBindings(Element beanElement)
{
Set<Annotation> result = new HashSet<Annotation>();
-
+
Iterator<?> elIterator = beanElement.elementIterator();
while (elIterator.hasNext())
{
Element childElement = (Element) elIterator.next();
AnnotatedClass<?> childClass = ParseXmlHelper.loadElementClass(childElement, Object.class, environment, packagesMap);
- if(childClass.getRawType().isAnnotation() && !childClass.isAnnotationPresent(DeploymentType.class) &&
- !childClass.getRawType().equals(Resource.class) && !childClass.getRawType().equals(PersistenceContext.class) &&
- !childClass.getRawType().equals(PersistenceUnit.class) && !childClass.getRawType().equals(EJB.class) &&
- !childClass.getRawType().equals(WebServiceRef.class))
+ if (childClass.getRawType().isAnnotation() && !childClass.isAnnotationPresent(DeploymentType.class) && !childClass.getRawType().equals(Resource.class) && !childClass.getRawType().equals(PersistenceContext.class) && !childClass.getRawType().equals(PersistenceUnit.class) && !childClass.getRawType().equals(EJB.class) && !childClass.getRawType().equals(WebServiceRef.class))
{
Class<?> annotationClass = childClass.getRawType();
Method[] annotationMethods = annotationClass.getDeclaredMethods();
@@ -212,22 +210,22 @@
result.add(annotation);
}
}
-
- if(result.size() == 0)
- {
+
+ if (result.size() == 0)
+ {
Class<?> annotationClass = Current.class;
Method[] annotationMethods = annotationClass.getDeclaredMethods();
AnnotationImpl annotation = new AnnotationImpl(annotationClass, annotationMethods);
result.add(annotation);
}
-
+
return result;
}
-
+
private String obtainElementValue(Element elementParent, String elementName)
{
List<Element> elements = ParseXmlHelper.findElementsInEeNamespace(elementParent, elementName);
- if(elements.size() > 0)
+ if (elements.size() > 0)
{
Element element = elements.get(0);
return element.getData().toString();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SessionBeanElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SessionBeanElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SessionBeanElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -9,7 +9,7 @@
public class SessionBeanElementRegistrator extends NotSimpleBeanElementRegistrator
{
private final EjbDescriptorCache ejbDescriptors;
-
+
public SessionBeanElementRegistrator(BeanChildrenChecker childrenChecker, EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
@@ -18,7 +18,7 @@
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- if (ejbDescriptors.containsKey(beanElement.getName()) ||
+ if (ejbDescriptors.containsKey(beanElement.getName()) ||
beanElement.attribute(XmlConstants.EJB_NAME) != null)
{
return true;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SimpleBeanElementRegistrator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SimpleBeanElementRegistrator.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/ext/SimpleBeanElementRegistrator.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -15,7 +15,7 @@
public class SimpleBeanElementRegistrator extends BeanElementRegistratorImpl
{
private final EjbDescriptorCache ejbDescriptors;
-
+
public SimpleBeanElementRegistrator(BeanChildrenChecker childrenChecker, EjbDescriptorCache ejbDescriptors)
{
super(childrenChecker);
@@ -24,9 +24,8 @@
public boolean accept(Element beanElement, AnnotatedClass<?> beanClass)
{
- boolean isSessionBean = ejbDescriptors.containsKey(beanElement.getName()) ||
- beanElement.attribute(XmlConstants.EJB_NAME) != null;
-
+ boolean isSessionBean = ejbDescriptors.containsKey(beanElement.getName()) || beanElement.attribute(XmlConstants.EJB_NAME) != null;
+
if (!beanClass.isAbstract() && !isSessionBean && !beanClass.isParameterizedType())
{
return true;
@@ -37,18 +36,18 @@
protected void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass)
{
- if(beanClass.isNonStaticMemberClass())
- throw new DefinitionException("Bean class '" + beanClass.getName() + "' of a simple bean <" + beanElement.getName() +
- "> is a non static member class");
-
- if(beanClass.getRawType().isAnnotationPresent(Interceptor.class) &&
+ if (beanClass.isNonStaticMemberClass())
+ throw new DefinitionException("Bean class '" + beanClass.getName() + "' of a simple bean <" +
+ beanElement.getName() + "> is a non static member class");
+
+ if (beanClass.getRawType().isAnnotationPresent(Interceptor.class) &&
ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.INTERCEPTOR).size() != 1)
- throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
+ throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
beanClass.getName() + "' annotated @Interceptor and is not declared as an interceptor in XML");
-
- if(beanClass.getRawType().isAnnotationPresent(Decorator.class) &&
+
+ if (beanClass.getRawType().isAnnotationPresent(Decorator.class) &&
ParseXmlHelper.findElementsInEeNamespace(beanElement, XmlConstants.DECORATOR).size() != 1)
- throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
+ throw new DefinitionException("A simple bean defined in XML as <" + beanElement.getName() + "> has a bean class '" +
beanClass.getName() + "' annotated @Decorator and is not declared as an decorator in XML");
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/impl/BeanElementRegistratorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/impl/BeanElementRegistratorImpl.java 2009-04-21 09:33:17 UTC (rev 2611)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/registrator/bean/impl/BeanElementRegistratorImpl.java 2009-04-21 15:38:27 UTC (rev 2612)
@@ -22,26 +22,25 @@
import org.jboss.webbeans.xml.checker.beanchildren.BeanChildrenChecker;
import org.jboss.webbeans.xml.registrator.bean.BeanElementRegistrator;
-
public abstract class BeanElementRegistratorImpl implements BeanElementRegistrator
{
protected final BeanChildrenChecker childrenChecker;
-
+
protected final XmlEnvironment environment;
-
+
protected final Map<String, Set<String>> packagesMap;
-
+
protected BeanElementRegistratorImpl(BeanChildrenChecker childrenChecker)
{
this.childrenChecker = childrenChecker;
this.environment = childrenChecker.getXmlEnvironment();
this.packagesMap = childrenChecker.getPackagesMap();
}
-
+
public abstract boolean accept(Element beanElement, AnnotatedClass<?> beanClass);
protected abstract void checkElementDeclaration(Element beanElement, AnnotatedClass<?> beanClass);
-
+
public void registerBeanElement(Element beanElement, AnnotatedClass<?> beanClass)
{
checkElementDeclaration(beanElement, beanClass);
@@ -49,113 +48,115 @@
checkProduces(beanElement, beanClass);
register(beanElement, beanClass);
}
-
+
protected void register(Element beanElement, AnnotatedClass<?> beanClass)
{
environment.getClasses().add(beanClass);
}
-
+
private void checkProduces(Element beanElement, AnnotatedClass<?> beanClass)
- {//TODO: will refactor
+ {// TODO: will refactor
Iterator<?> beanIterator = beanElement.elementIterator();
- while(beanIterator.hasNext())
+ while (beanIterator.hasNext())
{
- Element beanChild = (Element)beanIterator.next();
+ Element beanChild = (Element) beanIterator.next();
List<Element> producesElements = ParseXmlHelper.findElementsInEeNamespace(beanChild, XmlConstants.PRODUCES);
-
- if(producesElements.size() == 0)
+
+ if (producesElements.size() == 0)
continue;
-
- if(producesElements.size() > 1)
- throw new DefinitionException("There is more than one child <Produces> element for <" + beanChild.getName() + "> element");
-
+
+ if (producesElements.size() > 1)
+ throw new DefinitionException("There is more than one child <Produces> element for <" + beanChild.getName() + "> element");
+
List<AnnotatedClass<?>> producesChildTypes = new ArrayList<AnnotatedClass<?>>();
-
+
Element producesElement = producesElements.get(0);
Iterator<?> producesIt = producesElement.elementIterator();
- while(producesIt.hasNext())
+ while (producesIt.hasNext())
{
- Element producesChild = (Element)producesIt.next();
+ Element producesChild = (Element) producesIt.next();
AnnotatedClass<?> producesChildClass = ParseXmlHelper.loadElementClass(producesChild, Object.class, environment, packagesMap);
Class<?> producesChildType = producesChildClass.getRawType();
boolean isJavaClass = !producesChildType.isEnum() && !producesChildType.isPrimitive() && !producesChildType.isInterface();
boolean isInterface = producesChildType.isInterface() && !producesChildType.isAnnotation();
- if(isJavaClass || isInterface)
+ if (isJavaClass || isInterface)
{
producesChildTypes.add(producesChildClass);
continue;
}
- if(producesChildType.isAnnotation())
+ if (producesChildType.isAnnotation())
{
- if(producesChildClass.isAnnotationPresent(DeploymentType.class) ||
+ if (producesChildClass.isAnnotationPresent(DeploymentType.class) ||
producesChildClass.isAnnotationPresent(ScopeType.class) ||
- producesChildClass.isAnnotationPresent(Stereotype.class) ||
+ producesChildClass.isAnnotationPresent(Stereotype.class) ||
producesChildClass.isAnnotationPresent(Named.class))
continue;
-
- throw new DefinitionException("<" + producesChild.getName() + "> direct child of <Produces> element for <" + beanChild.getName()
- + "> in bean" + beanElement.getName() + "must be DeploymentType or ScopeType or Stereotype or Named");
+
+ throw new DefinitionException("<" + producesChild.getName() + "> direct child of <Produces> element for <" +
+ beanChild.getName() + "> in bean" + beanElement.getName() + "must be DeploymentType or ScopeType or Stereotype or Named");
}
- throw new DefinitionException("Only Java class, interface type and Java annotation type can be " +
+ throw new DefinitionException("Only Java class, interface type and Java annotation type can be " +
"direct child of <Produces> element for <" + beanChild.getName() + "> in bean" + beanElement.getName() +
". Element <" + producesChild.getName() + "> is incorrect");
}
-
- if(producesChildTypes.size() != 1)
- throw new DefinitionException("More than one or no one child element of <Produces> element for <" + beanChild.getName() +
- "> in bean" + beanElement.getName() + " represents a Java class or interface type");
-
+
+ if (producesChildTypes.size() != 1)
+ throw new DefinitionException("More than one or no one child element of <Produces> element for <" +
+ beanChild.getName() + "> in bean" + beanElement.getName() + " represents a Java class or interface type");
+
AnnotatedClass<?> expectedType = producesChildTypes.get(0);
-
- Method beanMethod = null;
+
+ Method beanMethod = null;
AnnotatedField<?> beanField = beanClass.getDeclaredField(beanChild.getName(), expectedType);
try
{
List<Class<?>> paramClassesList = new ArrayList<Class<?>>();
Iterator<?> beanChildIt = beanChild.elementIterator();
- while(beanChildIt.hasNext())
+ while (beanChildIt.hasNext())
{
- Element methodChild = (Element)beanChildIt.next();
- if(methodChild.getName().equalsIgnoreCase(XmlConstants.PRODUCES))
+ Element methodChild = (Element) beanChildIt.next();
+ if (XmlConstants.PRODUCES.equalsIgnoreCase(methodChild.getName()))
continue;
paramClassesList.add(ParseXmlHelper.loadElementClass(methodChild, Object.class, environment, packagesMap).getRawType());
}
- Class<?>[] paramClasses = (Class<?>[])paramClassesList.toArray(new Class[0]);
+ Class<?>[] paramClasses = (Class<?>[]) paramClassesList.toArray(new Class[0]);
beanMethod = beanClass.getRawType().getDeclaredMethod(beanChild.getName(), paramClasses);
}
catch (SecurityException e)
- {}
+ {
+ }
catch (NoSuchMethodException e)
- {}
-
- if(beanField != null && beanMethod != null)
+ {
+ }
+
+ if (beanField != null && beanMethod != null)
throw new DefinitionException("Class '" + beanClass.getName() + "' has produser field and method with the same name '" +
beanField.getName() + "'");
-
- if(beanField != null)
+
+ if (beanField != null)
{
- if(beanChild.elements().size() > 1)
+ if (beanChild.elements().size() > 1)
throw new DefinitionException("There is more than one direct child element for producer field <" + beanChild.getName() + ">");
continue;
}
-
- if(beanMethod != null)
+
+ if (beanMethod != null)
{
Iterator<?> beanChildIt = beanChild.elementIterator();
- while(beanChildIt.hasNext())
+ while (beanChildIt.hasNext())
{
- Element element = (Element)beanChildIt.next();
- if(!element.getName().equalsIgnoreCase(XmlConstants.PRODUCES) &&
+ Element element = (Element) beanChildIt.next();
+ if (!XmlConstants.PRODUCES.equalsIgnoreCase(element.getName()) &&
ParseXmlHelper.findElementsInEeNamespace(beanChild, XmlConstants.INTERCEPTOR).size() == 0)
- throw new DefinitionException("Only Produces and interceptor binding types can be direct childs of a producer " +
+ throw new DefinitionException("Only Produces and interceptor binding types can be direct childs of a producer " +
"method '" + beanChild.getName() + "' declaration in bean '" + beanElement.getName() + "'");
}
continue;
}
-
- throw new DefinitionException("A producer '" + beanChild.getName() + "' doesn't declared in '" + beanElement.getName() +
- "' class file as method or field");
- }
+
+ throw new DefinitionException("A producer '" + beanChild.getName() + "' isn't declared in '" + beanClass.getName() +
+ "' as method or field");
+ }
}
}
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2611 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: vitold
Date: 2009-04-21 05:33:17 -0400 (Tue, 21 Apr 2009)
New Revision: 2611
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/deploy/user-defined-beans.xml
Log:
some methods refactoring
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-04-21 09:09:34 UTC (rev 2610)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-04-21 09:33:17 UTC (rev 2611)
@@ -34,8 +34,18 @@
public static <T> AnnotatedClass<? extends T> loadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
{
+ List<AnnotatedClass<? extends T>> classesList = tryLoadElementClass(element, expectedType, environment, packagesMap);
+ String className = element.getName();
+
+ if (classesList.size() == 0)
+ throw new DefinitionException("Could not find '" + className + "'");
+
+ return classesList.get(0);
+ }
+
+ public static <T> List<AnnotatedClass<? extends T>> tryLoadElementClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
List<AnnotatedClass<? extends T>> classesList = new ArrayList<AnnotatedClass<? extends T>>();
- String className = element.getName();
String prefix = element.getNamespacePrefix();
for (Map.Entry<String, Set<String>> packagesEntry : packagesMap.entrySet())
@@ -57,14 +67,11 @@
}
}
}
-
- if (classesList.size() == 0)
- throw new DefinitionException("Could not find '" + className + "'", new DefinitionException(className + " not a Java type"));
-
- if (classesList.size() == 1)
- return classesList.get(0);
-
- throw new DefinitionException("There are multiple packages containing a Java type with the same name '" + className + "'");
+
+ if(classesList.size() > 1)
+ throw new DefinitionException("There are multiple packages containing a Java type with the same name '" + element.getName() + "'");
+
+ return classesList;
}
public static <T extends Annotation> Class<? extends T> loadAnnotationClass(Element element, Class<T> expectedType, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
@@ -258,7 +265,6 @@
{
Set<String> packages = packagesMap.get(prefix);
packages.addAll(packagesSet);
- packagesMap.put(prefix, packages);
}
else
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-04-21 09:09:34 UTC (rev 2610)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-04-21 09:33:17 UTC (rev 2611)
@@ -93,11 +93,26 @@
private void checkBeanChild(Element beanChildElement, AnnotatedClass<?> beanClass)
{
- try
- {
- if(beanChildElement.getName().equalsIgnoreCase(XmlConstants.ARRAY))
+ if(beanChildElement.getName().equalsIgnoreCase(XmlConstants.ARRAY))
+ return;
+
+ List<AnnotatedClass<?>> beanChildClassList = ParseXmlHelper.tryLoadElementClass(beanChildElement, Object.class, environment, packagesMap);
+
+ if(beanChildClassList.size() == 0)
+ {
+ Element beanElement = beanChildElement.getParent();
+ Namespace beanNamespace = beanElement.getNamespace();
+ Namespace beanChildNamespace = beanChildElement.getNamespace();
+ if(beanChildNamespace.equals(beanNamespace))
+ {
+ //bean child element declaring a method or field of the bean.
+ checkFieldOrMethodChild(beanChildElement, beanClass);
return;
- AnnotatedClass<?> beanChildClass = ParseXmlHelper.loadElementClass(beanChildElement, Object.class, environment, packagesMap);
+ }
+ }
+ else
+ {
+ AnnotatedClass<?> beanChildClass = beanChildClassList.get(0);
Class<?> beanChildType = beanChildClass.getRawType();
boolean isJavaClass = !beanChildType.isEnum() && !beanChildType.isPrimitive() && !beanChildType.isInterface();
boolean isInterface = beanChildType.isInterface() && !beanChildType.isAnnotation();
@@ -113,27 +128,10 @@
constructorParameters.add(beanChildClass);
return;
}
- throw new DefinitionException(new DefinitionException(beanChildElement.getName() + " can't be interpreted as a Java class or interface or Java Annotation type"));
}
- catch(DefinitionException e)
- {
- if(!(e.getCause() instanceof DefinitionException))
- {
- throw new DefinitionException(e);
- }
-
- Element beanElement = beanChildElement.getParent();
- Namespace beanNamespace = beanElement.getNamespace();
- Namespace beanChildNamespace = beanChildElement.getNamespace();
- if(beanChildNamespace.equals(beanNamespace))
- {
- //bean child element declaring a method or field of the bean.
- checkFieldOrMethodChild(beanChildElement, beanClass);
- return;
- }
- throw new DefinitionException("Can't determine type of element <" + beanChildElement.getName() + "> in bean '" +
- beanElement.getName() + "'");
- }
+
+ throw new DefinitionException("Can't determine type of element <" + beanChildElement.getName() + "> in bean '" +
+ beanChildElement.getParent().getName() + "'");
}
private void checkAnnotationChild(Element beanChildElement, AnnotatedClass<?> beanChildClass, AnnotatedClass<?> beanClass)
Modified: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/deploy/user-defined-beans.xml
===================================================================
--- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/deploy/user-defined-beans.xml 2009-04-21 09:09:34 UTC (rev 2610)
+++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/deploy/user-defined-beans.xml 2009-04-21 09:33:17 UTC (rev 2611)
@@ -1,4 +1,4 @@
-<Beans xmlns="urn:java:ee" xmlns:myapp="urn:java:org.jboss.webbeans.test.unit.xml.beans"
+<Beans xmlns="urn:java:ee"
xmlns:test="urn:java:org.jboss.webbeans.test.unit.xml.deploy">
<Deploy>
<Standard />
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2610 - examples/trunk.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-21 05:09:34 -0400 (Tue, 21 Apr 2009)
New Revision: 2610
Modified:
examples/trunk/pom.xml
Log:
WBRI-242
Modified: examples/trunk/pom.xml
===================================================================
--- examples/trunk/pom.xml 2009-04-21 09:07:49 UTC (rev 2609)
+++ examples/trunk/pom.xml 2009-04-21 09:09:34 UTC (rev 2610)
@@ -17,6 +17,32 @@
</description>
<url>http://www.seamframework.org/WebBeans</url>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>http://snapshots.jboss.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
<developers>
<developer>
15 years, 7 months
[webbeans-commits] Webbeans SVN: r2609 - examples/tags/1.0.0.PREVIEW1.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-21 05:07:49 -0400 (Tue, 21 Apr 2009)
New Revision: 2609
Modified:
examples/tags/1.0.0.PREVIEW1/pom.xml
Log:
WBRI-242
Modified: examples/tags/1.0.0.PREVIEW1/pom.xml
===================================================================
--- examples/tags/1.0.0.PREVIEW1/pom.xml 2009-04-20 22:39:06 UTC (rev 2608)
+++ examples/tags/1.0.0.PREVIEW1/pom.xml 2009-04-21 09:07:49 UTC (rev 2609)
@@ -18,6 +18,32 @@
<url>http://www.seamframework.org/WebBeans</url>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>http://snapshots.jboss.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+
<developers>
<developer>
<name>Pete Muir</name>
15 years, 7 months