You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/12/28 19:02:57 UTC
svn commit: r607303 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/config/
main/resources/META-INF/org.apache.openejb/
test/java/org/apache/openejb/config/
Author: dblevins
Date: Fri Dec 28 10:02:56 2007
New Revision: 607303
URL: http://svn.apache.org/viewvc?rev=607303&view=rev
Log:
When configuring a queue or topic, use the id of the <Resource> tag as the destination name allowing for something like this:
<Resource id="MyQueue" type"Queue"/>
Fixes: OPENEJB-706: NullPointerException initializing activemq
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/ConfigureServiceTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=607303&r1=607302&r2=607303&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Fri Dec 28 10:02:56 2007
@@ -517,9 +517,18 @@
info.properties = props;
info.constructorArgs.addAll(parseConstructorArgs(provider));
+ specialProcessing(info);
+
+
return info;
}
+ private <T extends ServiceInfo> void specialProcessing(T info) {
+ ServiceInfo serviceInfo = info;
+ TopicOrQueueDefaults.process(serviceInfo);
+ }
+
+
@SuppressWarnings({"unchecked"})
private ServiceProvider resolveServiceProvider(Service service, Class infoType) throws OpenEJBException {
@@ -736,4 +745,37 @@
return SystemInstance.get().getComponent(OpenEjbConfiguration.class);
}
+
+ private static class TopicOrQueueDefaults {
+ public static void process(ServiceInfo provider) {
+ if (!provider.service.equals("Resource")) return;
+ if (!provider.types.contains("Topic") && !provider.types.contains("Queue")) return;
+ if (!provider.className.matches("org.apache.activemq.command.ActiveMQ(Topic|Queue)")) return;
+
+
+ Properties properties = provider.properties;
+ String destination = normalizePropertyName(properties, "destination");
+ if (properties.getProperty(destination) == null || properties.getProperty(destination).equals("")){
+ properties.setProperty(destination, provider.id);
+ }
+ }
+
+ /**
+ * Our properties are not case sensitive, so they may have specified the name
+ * under any case. Would be super to have a case insensitive properties impl.
+ * @param properties
+ * @param property
+ * @return the property name under any corrected case
+ */
+ private static String normalizePropertyName(Properties properties, String property) {
+ for (Object o : properties.keySet()) {
+ String name = (String) o;
+ if (name.equalsIgnoreCase(property)){
+ return name;
+ }
+ }
+
+ return property;
+ }
+ }
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml?rev=607303&r1=607302&r2=607303&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml Fri Dec 28 10:02:56 2007
@@ -278,7 +278,7 @@
# Default password
- Password
+ Password
# The connection properties that will be sent to the JDBC
# driver when establishing new connections
@@ -413,7 +413,7 @@
# limit.
#
# NOTE - Some drivers have limits on the number of open
- # statements, so make sure there are some resources left
+ # statements, so make sure there are some resources left
# for the other (non-prepared) statements.
MaxOpenPreparedStatements 0
@@ -434,7 +434,7 @@
#
# NOTE: Do NOT close the underlying connection, only the
# original logical connection wrapper.
-
+
AccessToUnderlyingConnectionAllowed false
</ServiceProvider>
@@ -638,7 +638,7 @@
# Broker configuration
BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false
-
+
# Broker address
ServerUrl vm://localhost?async=true
@@ -652,7 +652,7 @@
service="Resource"
types="javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, QueueConnectionFactory, TopicConnectionFactory"
class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory">
-
+
ResourceAdapter Default JMS Resource Adapter
# Specifies if the connection is enrolled in global transaction
@@ -678,7 +678,7 @@
types="javax.jms.Queue, Queue"
constructor="destination"
class-name="org.apache.activemq.command.ActiveMQQueue">
- destination destination
+ destination
</ServiceProvider>
<ServiceProvider
@@ -687,7 +687,7 @@
types="javax.jms.Topic, Topic"
constructor="destination"
class-name="org.apache.activemq.command.ActiveMQTopic">
- destination destination
+ destination
</ServiceProvider>
<!--
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/ConfigureServiceTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/ConfigureServiceTest.java?rev=607303&r1=607302&r2=607303&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/ConfigureServiceTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/ConfigureServiceTest.java Fri Dec 28 10:02:56 2007
@@ -19,6 +19,7 @@
import junit.framework.TestCase;
import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
import org.apache.openejb.assembler.classic.ContainerInfo;
+import org.apache.openejb.assembler.classic.ResourceInfo;
import org.apache.openejb.config.sys.Container;
import org.apache.openejb.config.sys.Resource;
@@ -135,5 +136,19 @@
assertNotNull(myStatelessContainer.properties.getProperty("anotherProperty"));
assertEquals("Cheese is good", myStatelessContainer.properties.getProperty("anotherProperty"));
}
+
+ public void testQueue() throws Exception {
+ ConfigurationFactory factory = new ConfigurationFactory();
+
+ ResourceInfo resourceInfo = factory.configureService(new Resource("myQueue", "Queue"), ResourceInfo.class);
+
+ assertNotNull(resourceInfo);
+ assertEquals("myQueue", resourceInfo.id);
+ assertNotNull(resourceInfo.constructorArgs);
+ assertNotNull(resourceInfo.properties);
+ assertEquals("myQueue", resourceInfo.properties.getProperty("destination"));
+ }
+
+
}