[webbeans-commits] Webbeans SVN: r2074 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/util/xml and 1 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Mar 17 13:43:38 EDT 2009
Author: vitold
Date: 2009-03-17 13:43:38 -0400 (Tue, 17 Mar 2009)
New Revision: 2074
Modified:
ri/trunk/impl/pom.xml
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/AnnotatedItemReceiver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlConstants.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlParserImpl.java
ri/trunk/version-matrix/pom.xml
Log:
add a jms resource receiving
Modified: ri/trunk/impl/pom.xml
===================================================================
--- ri/trunk/impl/pom.xml 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/impl/pom.xml 2009-03-17 17:43:38 UTC (rev 2074)
@@ -90,6 +90,11 @@
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ </dependency>
<dependency>
<groupId>javax.el</groupId>
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/AnnotatedItemReceiver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/AnnotatedItemReceiver.java 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/AnnotatedItemReceiver.java 2009-03-17 17:43:38 UTC (rev 2074)
@@ -8,5 +8,5 @@
{
boolean accept(Element element);
- AnnotatedItem<?, ?> reciveAnnotatedItem(Element element);
+ AnnotatedItem<?, ?> receiveAnnotatedItem(Element element);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/ParseXmlHelper.java 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/ParseXmlHelper.java 2009-03-17 17:43:38 UTC (rev 2074)
@@ -8,6 +8,9 @@
import java.util.Set;
import javax.inject.DefinitionException;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.Topic;
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
@@ -34,18 +37,18 @@
Set<AnnotatedItem<?, ?>> result = new HashSet<AnnotatedItem<?, ?>>();
for (Element bean : beans)
- result.add(reciveBeanItem(bean));
+ result.add(receiveBeanItem(bean));
return result;
}
- private static AnnotatedItem<?, ?> reciveBeanItem(Element element)
+ private static AnnotatedItem<?, ?> receiveBeanItem(Element element)
{
for (AnnotatedItemReceiver receiver : receivers)
{
if (receiver.accept(element))
{
- return receiver.reciveAnnotatedItem(element);
+ return receiver.receiveAnnotatedItem(element);
}
}
@@ -63,9 +66,9 @@
return isJMSResource(element);
}
- public AnnotatedItem<?, ?> reciveAnnotatedItem(Element element)
+ public AnnotatedItem<?, ?> receiveAnnotatedItem(Element element)
{
- return reciveJMSResourceItem(element);
+ return receiveJMSResourceItem(element);
}
};
@@ -76,9 +79,9 @@
return isResource(element);
}
- public AnnotatedItem<?, ?> reciveAnnotatedItem(Element element)
+ public AnnotatedItem<?, ?> receiveAnnotatedItem(Element element)
{
- return reciveResourceItem(element);
+ return receiveResourceItem(element);
}
};
@@ -89,9 +92,9 @@
return isSessionBean(element);
}
- public AnnotatedItem<?, ?> reciveAnnotatedItem(Element element)
+ public AnnotatedItem<?, ?> receiveAnnotatedItem(Element element)
{
- return reciveSessionBeanItem(element);
+ return receiveSessionBeanItem(element);
}
};
@@ -102,9 +105,9 @@
return isSimpleBean(element);
}
- public AnnotatedItem<?, ?> reciveAnnotatedItem(Element element)
+ public AnnotatedItem<?, ?> receiveAnnotatedItem(Element element)
{
- return reciveSimpleBeanItem(element);
+ return receiveSimpleBeanItem(element);
}
};
@@ -120,17 +123,39 @@
private static boolean isJMSResource(Element element)
{
- if (element.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE) &&
+ if (isJavaEeNamespace(element) &&
(element.getName().equalsIgnoreCase(XmlConstants.TOPIC) ||
element.getName().equalsIgnoreCase(XmlConstants.QUEUE)))
return true;
return false;
}
- private static AnnotatedItem<?, ?> reciveJMSResourceItem(Element element)
+ private static AnnotatedItem<?, ?> receiveJMSResourceItem(Element element)
{
- // TODO:
- return null;
+ final Element jmsElement = element;
+
+ if(jmsElement.getName().equalsIgnoreCase(XmlConstants.QUEUE))
+ {
+ Queue queue = new Queue()
+ {
+ public String getQueueName() throws JMSException
+ {
+ return getJmsResourceName(jmsElement);
+ }
+ };
+
+ return AnnotatedClassImpl.of(queue.getClass());
+ }
+
+ Topic topic = new Topic()
+ {
+ public String getTopicName() throws JMSException
+ {
+ return getJmsResourceName(jmsElement);
+ }
+ };
+
+ return AnnotatedClassImpl.of(topic.getClass());
}
private static boolean isResource(Element element)
@@ -139,7 +164,7 @@
while (elIterator.hasNext())
{
Element child = (Element) elIterator.next();
- if (child.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE) &&
+ if (isJavaEeNamespace(child) &&
(child.getName().equalsIgnoreCase(XmlConstants.RESOURCE) ||
child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_CONTEXT) ||
child.getName().equalsIgnoreCase(XmlConstants.PERSISTENCE_UNIT) ||
@@ -150,7 +175,7 @@
return false;
}
- private static AnnotatedItem<?, ?> reciveResourceItem(Element element)
+ private static AnnotatedItem<?, ?> receiveResourceItem(Element element)
{
// TODO:
return null;
@@ -165,7 +190,7 @@
return false;
}
- private static AnnotatedItem<?, ?> reciveSessionBeanItem(Element element)
+ private static AnnotatedItem<?, ?> receiveSessionBeanItem(Element element)
{
// TODO:
return null;
@@ -182,11 +207,12 @@
return false;
}
- private static AnnotatedItem<?, ?> reciveSimpleBeanItem(Element element)
+ private static AnnotatedItem<?, ?> receiveSimpleBeanItem(Element element)
{
Class<?> beanClass = loadClass(element);
- if (!Modifier.isStatic(beanClass.getModifiers()) && beanClass.isMemberClass())
+ if (!Modifier.isStatic(beanClass.getModifiers()) &&
+ beanClass.isMemberClass())
throw new DefinitionException("class " + beanClass + " is a non-static inner class");
// if (beanClass.getTypeParameters().length > 0)
@@ -209,4 +235,34 @@
String classPath = packageName + "." + element.getName();
return resourceLoader.classForName(classPath);
}
+
+ private static String getJmsResourceName(Element element)
+ {
+ Iterator<?> elIterator = element.elementIterator();
+ while (elIterator.hasNext())
+ {
+ Element child = (Element) elIterator.next();
+ if (isJavaEeNamespace(child) &&
+ child.getName().equalsIgnoreCase(XmlConstants.RESOURCE))
+ {
+ Iterator<?> chIterator = child.elementIterator();
+ while(chIterator.hasNext())
+ {
+ Element chChild = (Element) chIterator.next();
+ if (isJavaEeNamespace(chChild) &&
+ (chChild.getName().equalsIgnoreCase(XmlConstants.NAME) ||
+ chChild.getName().equalsIgnoreCase(XmlConstants.MAPPED_NAME)))
+ {
+ return chChild.getName();
+ }
+ }
+ }
+ }
+ throw new DefinitionException("Incorrect JMSResource declaration for " + element.getName());
+ }
+
+ public static boolean isJavaEeNamespace(Element element)
+ {
+ return element.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE);
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlConstants.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlConstants.java 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlConstants.java 2009-03-17 17:43:38 UTC (rev 2074)
@@ -33,4 +33,8 @@
public static final String QUEUE = "Queue";
public static final String URN_PREFIX = "urn:java:";
+
+ public static final String NAME = "name";
+
+ public static final String MAPPED_NAME = "mappedName";
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlParserImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlParserImpl.java 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/xml/XmlParserImpl.java 2009-03-17 17:43:38 UTC (rev 2074)
@@ -2,7 +2,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.AnnotatedElement;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
@@ -69,7 +68,7 @@
private boolean checkElementName(Element element)
{
- if (element.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE) &&
+ if (ParseXmlHelper.isJavaEeNamespace(element) &&
(element.getName().equalsIgnoreCase(XmlConstants.DEPLOY) ||
element.getName().equalsIgnoreCase(XmlConstants.INTERCEPTORS) ||
element.getName().equalsIgnoreCase(XmlConstants.DECORATORS)))
@@ -83,7 +82,7 @@
while (elIterator.hasNext())
{
Element child = (Element) elIterator.next();
- if (child.getNamespace().getURI().equalsIgnoreCase(XmlConstants.JAVA_EE_NAMESPACE) &&
+ if (ParseXmlHelper.isJavaEeNamespace(child) &&
(child.getName().equalsIgnoreCase(XmlConstants.BINDING_TYPE) ||
child.getName().equalsIgnoreCase(XmlConstants.INTERCEPTOR_BINDING_TYPE) ||
child.getName().equalsIgnoreCase(XmlConstants.STEREOTYPE)))
Modified: ri/trunk/version-matrix/pom.xml
===================================================================
--- ri/trunk/version-matrix/pom.xml 2009-03-17 17:16:38 UTC (rev 2073)
+++ ri/trunk/version-matrix/pom.xml 2009-03-17 17:43:38 UTC (rev 2074)
@@ -122,6 +122,12 @@
</dependency>
<dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>1.2</version>
More information about the weld-commits
mailing list