You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2010/02/02 14:46:24 UTC
svn commit: r905632 [1/2] - in /openejb/trunk/openejb3: ./ container/
container/openejb-activemq4/ container/openejb-activemq4/src/
container/openejb-activemq4/src/main/
container/openejb-activemq4/src/main/java/
container/openejb-activemq4/src/main/ja...
Author: jlmonteiro
Date: Tue Feb 2 13:46:09 2010
New Revision: 905632
URL: http://svn.apache.org/viewvc?rev=905632&view=rev
Log:
OPENEJB-1227: Active MQ 5 support. Thanks a lot Andy for providing this patch. Backward compatibility provided to connect the old openejb: prefix to the new ActiveMQ5factory. BTW, we have two prefixes to manage ActiveMQ factory selection: amq4factory, activemq5factory and openejb (for backward compatibility).
Added:
openejb/trunk/openejb3/container/openejb-activemq4/
openejb/trunk/openejb3/container/openejb-activemq4/pom.xml
openejb/trunk/openejb3/container/openejb-activemq4/src/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ4Factory.java
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.instantdb.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.logging.conf
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.openejb.conf
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/embedded.logging.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/groups.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/logging.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/login.config
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/openejb-version.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/users.properties
openejb/trunk/openejb3/container/openejb-activemq4/src/test/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/AmqXmlTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/CustomMdbContainerTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsMdbContainerTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbInvoker.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbProxy.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbUtil.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/QuartzMdbContainerTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/resource/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/resource/activemq/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/core/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/core/mdb/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/core/mdb/activemq.xml
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/util/
openejb/trunk/openejb3/container/openejb-activemq4/src/test/resources/org/apache/openejb/util/test.properties
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ5Factory.java
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQFactory.java
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory
Removed:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactory.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java
openejb/trunk/openejb3/container/openejb-core/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
openejb/trunk/openejb3/container/openejb-osgi/src/main/filtered-resources/features.xml
openejb/trunk/openejb3/container/openejb-osgi/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb
openejb/trunk/openejb3/container/pom.xml
openejb/trunk/openejb3/pom.xml
Added: openejb/trunk/openejb3/container/openejb-activemq4/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/pom.xml?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/pom.xml (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/pom.xml Tue Feb 2 13:46:09 2010
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+
+<!-- $Rev: 895326 $ $Date: 2010-01-03 03:39:14 +0100 (So, 03 Jan 2010) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>container</artifactId>
+ <groupId>org.apache.openejb</groupId>
+ <version>3.1.3-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>openejb-activemq4</artifactId>
+ <packaging>jar</packaging>
+ <name>OpenEJB :: Container :: ActiveMQ4</name>
+ <properties>
+ <openejb.osgi.import.pkg>
+ org.apache.activemq.ra;resolution:=optional
+ </openejb.osgi.import.pkg>
+ <openejb.osgi.export/>
+ </properties>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-javaagent</artifactId>
+ <version>${version}</version>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <argLine>-Xmx256m "-javaagent:${basedir}/target/openejb-javaagent-${version}.jar" -enableassertions</argLine>
+ <workingDirectory>${basedir}/target</workingDirectory>
+ <systemProperties>
+ <property>
+ <name>openejb.home</name>
+ <value>${basedir}/target/test-classes</value>
+ </property>
+ <property>
+ <name>log4j.configuration</name>
+ <value>file:///${basedir}/target/classes/embedded.logging.properties</value>
+ </property>
+ </systemProperties>
+ <excludes>
+ <exclude>**/TestHandler.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <tstamp>
+ <format property="TSTAMP" pattern="hh:mm"/>
+ </tstamp>
+ <replace file="target/classes/openejb-version.properties" token="@DATE-REPLACED-BY-MAVEN@" value="${DSTAMP}"/>
+ <replace file="target/classes/openejb-version.properties" token="@TIME-REPLACED-BY-MAVEN@" value="${TSTAMP}"/>
+ <property name="compile_classpath" refid="maven.compile.classpath"/>
+ <java classname="org.apache.openejb.util.MakeTxLookup">
+ <arg value="${project.build.directory}"/>
+ <classpath>
+ <pathelement path="${compile_classpath}"/>
+ </classpath>
+ </java>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass/>
+ <!--<addClasspath>true</addClasspath>-->
+ </manifest>
+ <manifestEntries/>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rat-maven-plugin</artifactId>
+ <configuration>
+ <excludes/>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>${version}</version>
+ <exclusions>
+ <!-- Ignore ActiveMQ 5.x-->
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-ra</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- ActiveMQ -->
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-ra</artifactId>
+ <version>4.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>4.1.1</version>
+ </dependency>
+ <!-- End ActiveMQ -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <version>2.5.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-spring</artifactId>
+ <version>3.4.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>openejb.debug</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>pertest</forkMode>
+ <argLine>"-javaagent:${basedir}/target/openejb-javaagent-${version}.jar" -Xdebug -Xnoagent -Djava.compiler=NONE
+ -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
+ </argLine>
+ <workingDirectory>${basedir}/target</workingDirectory>
+ <systemProperties>
+ <property>
+ <name>openejb.home</name>
+ <value>${basedir}/target/test-classes</value>
+ </property>
+ <property>
+ <name>log4j.configuration</name>
+ <value>file:///${basedir}/target/classes/embedded.logging.properties</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
+
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ4Factory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ4Factory.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ4Factory.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/java/org/apache/openejb/resource/activemq/ActiveMQ4Factory.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,99 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.resource.activemq;
+
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.net.URI;
+import java.util.Map;
+import java.util.Properties;
+
+public class ActiveMQ4Factory implements BrokerFactory.BrokerFactoryHandler {
+ private static final ThreadLocal<Properties> threadProperties = new ThreadLocal<Properties>();
+
+ public static void setThreadProperties(Properties value) {
+ threadProperties.set(value);
+ }
+
+ public BrokerService createBroker(URI brokerURI) throws Exception {
+ URI uri = new URI(brokerURI.getRawSchemeSpecificPart());
+ BrokerService broker = BrokerFactory.createBroker(uri);
+
+ Properties properties = getLowerCaseProperties();
+
+ Object value = properties.get("datasource");
+ if (value instanceof String && value.toString().length() == 0) {
+ value = null;
+ }
+
+ if (value != null) {
+ DataSource dataSource;
+ if (value instanceof DataSource) {
+ dataSource = (DataSource) value;
+ } else {
+ String resouceId = (String) value;
+
+ try {
+ ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+ Context context = containerSystem.getJNDIContext();
+ Object obj = context.lookup("openejb/Resource/" + resouceId);
+ if (!(obj instanceof DataSource)) {
+ throw new IllegalArgumentException("Resource with id " + resouceId +
+ " is not a DataSource, but is " + obj.getClass().getName());
+ }
+ dataSource = (DataSource) obj;
+ } catch (NamingException e) {
+ throw new IllegalArgumentException("Unknown datasource " + resouceId);
+ }
+ }
+
+ JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter();
+ persistenceAdapter.setDataSource(dataSource);
+ broker.setPersistenceAdapter(persistenceAdapter);
+ } else {
+ MemoryPersistenceAdapter persistenceAdapter = new MemoryPersistenceAdapter();
+ broker.setPersistenceAdapter(persistenceAdapter);
+ }
+
+ return broker;
+ }
+
+
+ private Properties getLowerCaseProperties() {
+ Properties properties = threadProperties.get();
+ Properties newProperties = new Properties();
+ if (properties != null) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ Object key = entry.getKey();
+ if (key instanceof String) {
+ key = ((String) key).toLowerCase();
+ }
+ newProperties.put(key, entry.getValue());
+ }
+ }
+ return newProperties;
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq4factory Tue Feb 2 13:46:09 2010
@@ -0,0 +1 @@
+class=org.apache.openejb.resource.activemq.ActiveMQ4Factory
\ No newline at end of file
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/amq5factory Tue Feb 2 13:46:09 2010
@@ -0,0 +1 @@
+class=org.apache.openejb.resource.activemq.ActiveMQ5Factory
\ No newline at end of file
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/META-INF/services/org/apache/activemq/broker/openejb Tue Feb 2 13:46:09 2010
@@ -0,0 +1 @@
+class=org.apache.openejb.resource.activemq.ActiveMQ5Factory
\ No newline at end of file
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.instantdb.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.instantdb.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.instantdb.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.instantdb.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,332 @@
+!---------------------------------------------------------------------
+! Licensed to the Apache Software Foundation (ASF) under one or more
+! contributor license agreements. See the NOTICE file distributed with
+! this work for additional information regarding copyright ownership.
+! The ASF licenses this file to You 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.
+!---------------------------------------------------------------------
+!---------------------------------------------------------------------
+!
+! BASIC PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! Path where index tables are held. Can be absolute or relative
+! to the properties file. Defaults to tablePath.
+!
+indexPath=./database/indexes
+!
+! Path where system tables are held. Can be absolute or relative to
+! the properties file. Defaults to tablePath.
+!
+systemPath=./database/system
+!
+! Path where database tables are held. Can be absolute or relative
+! to the properties file. Defaults to "current" directory.
+!
+tablePath=./database/tables
+!
+! Path where results set tables are held. Can be absolute or relative
+! to the properties file. Defaults to tablePath.
+!
+tmpPath=./database/tmp
+!
+! Non-zero means paths are relative to the properties file.
+! Default is absolute paths for files.
+!
+relativeToProperties=1
+!
+! Alternative partitions can be defined so that tables can be placed
+! in multiple locations. Each partition is numbered: 1, 2, 3,... Tables
+! can be created on partitions using the syntax
+!
+! CREATE TABLE <name> ON PARTITION <number>...
+!
+! The partition count has to be supplied.
+!
+!partitionCount=2
+!
+! The locations of each partition must be supplied. These are always
+! absolute path names.
+!
+!partition1=d:/petes
+!partition2=c:/temp
+
+
+!---------------------------------------------------------------------
+!
+! TUNING PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! The amount of each column to cache, expressed either as an absolute
+! number of rows or as a percentage figure. Defaults to 256 or 10 respectively.
+!
+! This value applies only when tables are first created. It has no effect
+! when a table is being re-opened.
+!
+cacheAmount=512
+!
+! CACHE_ROWS Must be one of CACHE_ROWS or CACHE_PERCENT. Determines whether
+! to cache columns in tables based on an absolute number of rows, or the
+! percentage number of rows in the table.
+!
+! This value applies only when tables are first created. It has no effect
+! when a table is being re-opened.
+!
+cacheCondition=CACHE_ROWS
+!
+! The amount of the system tables to be cached. Defaults to 100.
+!
+! This value applies only when tables are first created. It has no effect
+! when a table is being re-opened.
+!
+!systemCacheSize=10
+!
+! Similar to cacheCondition, but applies only to the system tables.
+!
+! This value applies only when tables are first created. It has no effect
+! when a table is being re-opened.
+!
+!systemCacheCondition=CACHE_ROWS
+!
+! The percentage cache hit improvement required in order to move the
+! cache to a new location in a column.
+!
+! (Currently not implemented).
+!
+cacheResetPercent=10
+!
+! Non-zero means that database changes do not get written to the
+! database immediately. See tuning.html.
+!
+fastUpdate=0
+!
+! Percentage of free space in an index that must be present before
+! the index reorganises itself. High values means frequent index
+! reorganisation. Low values means slow index inserts.
+!
+indexLoad=5
+!
+! The number of cache misses to include in calculations of the next
+! base for the cache.
+!
+! (Currently not implemented).
+!
+missesInCacheStats=100
+!
+! Non-zero means that results sets get instantiated on disk. By default
+! InstantDB holds results sets emtirely in memory (apart from Binary
+! columns). For large results sets this can be a problem. This property
+! forces all results sets to be held on disk.
+!
+resultsOnDisk=0
+!
+! Similar to cacheCondition but applies only to disk based
+! results sets. Default is CACHE_ROWS.
+!
+resultsSetCache=CACHE_ROWS
+!
+! Similar to cacheAmount but applies only to disk based
+! results sets. Default is 100.
+!
+resultsSetCacheAmount=100
+!
+! Number of rows to read into the disk read ahead buffer.
+! Recommended to be set somewhere around 128 to 256.
+! Default is 20.
+!
+rowCacheSize=128
+!
+! The read ahead buffer is effective at speeding up full
+! table scans. However for indexed lookups or multiple
+! simultaneous scans it is better to read a single row at
+! a time. Each table holds a small number of single row
+! buffers to improve such operations. Default is 8.
+!
+!singleRowCount=4
+!
+! Sometimes the look ahead buffer can be held by a single
+! thread even though it is not retrieveing many values from it.
+! If too many lookups retrieve data from the single row
+! buffers then it is better to flush the look ahead buffer and
+! make it available for re-use. Default is 128.
+!
+!flushAfterCacheMisses=64
+!
+! Number of rows to read ahead for system tables. By default
+! system tables cache everything, so it is wasteful to have large
+! read ahead buffers since they will very rarely be used. This
+! allows the size of the system read ahead buffers to be reduced
+! if necessary. Defaults to rowCacheSize.
+!
+!systemRows=20
+!
+! The control column in all tables normally has a large cache
+! since this speeds up all operation on that table. This can be
+! varied to either improve performance or to reduce space.
+! default is 8192.
+!
+! This value applies only when tables are first created. It has no effect
+! when a table is being re-opened.
+!
+!controlColCacheSize=512
+!
+! By default, InstantDB only does a cursory search for deleted rows during
+! UPDATE statements. Setting searchDeletes=1 causes more detailed searches
+! for deleted rows. This slows down UPDATE executions, but reults in more
+! compact tables. Default is 0.
+!
+searchDeletes=0
+!
+! The interval, in milliseconds, between checks for statement execution
+! timeouts. Default is 5000.
+!
+!timerCheck=5000
+
+!---------------------------------------------------------------------
+!
+! LOGGING AND DEBUGGING PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! Non-zero means include SQL statements in the export file.
+!
+exportSQL=0
+!
+! Non-zero means trace output also directed to console.
+! Defaults to 0.
+!
+traceConsole=0
+!
+! Relative or absolute path where exporting and tracing goes.
+!
+!traceFile=./logs/trace.log
+!
+! Bitmap of various items that can be traced. See debug.html.
+! Defaults to 0.
+!
+traceLevel=0
+
+!---------------------------------------------------------------------
+!
+! TRANSACTION AND RECOVERY PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! 0 means do not perform recovery on startup.
+! 1 means perform automatic recovery
+! 2 (default) means prompt the user using standard in
+!
+recoveryPolicy=1
+!
+! Sets the level of transaction journalling. See trans.html.
+! Defaults to 1.
+!
+! 0 - No journalling takes place.
+! 1 - Normal journalling (default).
+! 2 - Full journalling.
+!
+transLevel=2
+!
+! When doing an import, defines the number of rows imported
+! before the transaction is committed. Recommended value 8192.
+! defaults to 100.
+!
+transImports=100
+
+!---------------------------------------------------------------------
+!
+! DATE, TIME AND CURRENCY PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! Number of digits after decimal point in currency outputs. Defaults to 2.
+!
+currencyDecimal=2
+!
+! Currency symbol used in currency outputs. Defaults to $.
+!
+currencySymbol=$
+!
+! Default format for date columns. Defaults to "yyyy-mm-dd".
+!
+dateFormat=yyyy-mm-dd
+!
+! Default format for timestamp columns. Defaults to "yyyy-mm-dd hh:mm:ss.lll".
+!
+dateTimeFormat=yyyy-mm-dd hh:mm:ss.lll
+!
+! If set, then all two digit dates less than its value are interpreted
+! as 21st century dates.
+!
+!milleniumBoundary=50
+!
+! Set to 1 causes the date string "now" to store a full timestamp.
+! Default is to store only the date for fields with now hour in the
+! format string.
+!
+nowMeansTime=0
+
+!---------------------------------------------------------------------
+!
+! STRING HANDLING PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! If set to 1 then String hashes use the JDK Object.hashCode() function.
+! By default, uses InstantDB's String hashing.
+!
+altStringHashing=0
+!
+! Set to 1 to cause LIKE clauses to always perform case insensitive
+! comparisons.
+!
+likeIgnoreCase=0
+!
+! Same as SET LITERAL STRICT_ON. Prevents string literals being interpreted
+! as column names or numbers. Default is 0.
+!
+strictLiterals=0
+!
+! Set this value to 1 (one) if you would like PreparedStatement.setString()
+! to ignore "\" (backslash) characters when proceesing string constants.
+! When set, InstantDB will not attempt to interpret \ as the start of an
+! escape sequence. Default is 0.
+!
+!prepareIgnoresEscapes=1
+
+!---------------------------------------------------------------------
+!
+! MISCELLANEOUS PROPERTIES
+!
+!---------------------------------------------------------------------
+
+!
+! Allows selected InstantDB keywords to be un-reserved.
+! e.g. ignoreKeywords=url,quote would allow the keywords
+! url and quote to be used as table or column names.
+!
+! This faciliy is provided for compatatbility reasons only.
+! It's use is not recommended AND IS NOT SUPPORTED.
+!
+!ignoreKeywords
+!
+! Non-zero means database is opened in read only mode.
+!
+readOnly=0
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.logging.conf
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.logging.conf?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.logging.conf (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.logging.conf Tue Feb 2 13:46:09 2010
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+
+<!-- $Rev: 602704 $ $Date: 2007-12-09 18:58:22 +0100 (So, 09 Dez 2007) $ -->
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.openejb.conf
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.openejb.conf?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.openejb.conf (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/default.openejb.conf Tue Feb 2 13:46:09 2010
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openejb>
+
+<Container id="My CMP Container" type="CMP_ENTITY">
+ # This container can service CMP 1.1 and 2.x Entity Beans
+ #
+ # Persistence is achived by taking the entity beans deployed
+ # and internally readapting them to the new EJB 3.0 JPA (Java
+ # Persistence API) specification. It is possible, though
+ # not well documented, to mix in newer JPA concepts with
+ # old style Entity beans allowing you to slowly transition
+ # your entities to JPA. Aggressively inquiring on the
+ # users@openejb.apache.org about this feature will help
+ # us generate better documentation.
+ # ---------
+
+</Container>
+
+
+<Container id="My BMP Container" type="BMP_ENTITY">
+
+ # Specifies the size of the bean pools for this
+ # bmp entity container.
+
+ PoolSize 10
+
+</Container>
+
+
+<Container id="My Stateful Container" type="STATEFUL">
+ # The passivator is responsible for writing beans to disk
+ # at passivation time. Different passivators can be used
+ # by setting this property to the fully qualified class name
+ # of the PassivationStrategy implementation. The passivator
+ # is not responsible for invoking any callbacks or other
+ # processing, its only responsibly is to write the bean state
+ # to disk.
+ #
+ # Known implementations:
+ # org.apache.openejb.core.stateful.RAFPassivater
+ # org.apache.openejb.core.stateful.SimplePassivater
+
+ Passivator org.apache.openejb.core.stateful.SimplePassivater
+
+ # Specifies the time to wait between invocations. This
+ # value is measured in minutes. A value of 5 would
+ # result in a time-out of 5 minutes between invocations.
+ # A value of zero would mean no timeout.
+
+ TimeOut 20
+
+ # Specifies the size of the bean pools for this
+ # stateful SessionBean container.
+
+ Capacity 1000
+
+ # Property name that specifies the number of instances
+ # to passivate at one time when doing bulk passivation.
+ # Must be less than the PoolSize.
+
+ BulkPassivate 100
+
+</Container>
+
+
+<Container id="My Stateless Container" type="STATELESS">
+ # Specifies the time to wait between invocations. This
+ # value is measured in milliseconds. A value of 5 would
+ # result in a time-out of 5 milliseconds between invocations.
+ # A value of zero would mean no timeout.
+
+ TimeOut 0
+
+ # Specifies the size of the bean pools for this
+ # stateless SessionBean container.
+
+ PoolSize 10
+
+ # StrictPooling tells the container what to do when the pool
+ # reaches it's maximum size and there are incoming requests
+ # that need instances.
+ #
+ # With strict pooling, requests will have to wait for instances
+ # to become available. The pool size will never grow beyond the
+ # the set PoolSize value.
+ #
+ # Without strict pooling, the container will create temporary
+ # instances to meet demand. The instances will last for just one
+ # method invocation and then are removed.
+
+ StrictPooling true
+
+</Container>
+
+
+<Container id="My MDB Container" type="MESSAGE">
+
+ # The resource adapter delivers messages to the container
+
+ ResourceAdapter My JMS Resource Adapter
+
+ # Specifies the message listener interface handled by this container
+
+ MessageListenerInterface javax.jms.MessageListener
+
+ # Specifies the activation spec class
+
+ ActivationSpecClass org.apache.activemq.ra.ActiveMQActivationSpec
+
+ # Specifies the maximum number of bean instances that are
+ # allowed to exist for each MDB deployment.
+
+ InstanceLimit 10
+
+</Container>
+
+
+<!--
+# For more examples of database configuration see:
+# http://openejb.apache.org/3.0/databases.html
+-->
+
+<Resource id="My DataSource" type="DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb
+ UserName sa
+ Password
+ JtaManaged true
+</Resource>
+
+
+<Resource id="My Unmanaged DataSource" type="DataSource">
+ JdbcDriver org.hsqldb.jdbcDriver
+ JdbcUrl jdbc:hsqldb:file:data/hsqldb/hsqldb
+ UserName sa
+ Password
+ JtaManaged false
+</Resource>
+
+
+<Resource id="My JMS Resource Adapter" type="ActiveMQResourceAdapter">
+ # Broker configuration URI as defined by ActiveMQ
+ # see http://activemq.apache.org/broker-configuration-uri.html
+
+ BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false
+
+ # Broker address
+
+ ServerUrl vm://localhost?async=true
+
+ # DataSource for persistence messages
+
+ DataSource My Unmanaged DataSource
+</Resource>
+
+
+<Connector id="My JMS Connection Factory" type="javax.jms.ConnectionFactory">
+
+ ResourceAdapter My JMS Resource Adapter
+
+ # Specifies if the connection is enrolled in global transaction
+ # allowed values: xa, local or none
+
+ TransactionSupport xa
+
+ # Maximum number of physical connection to the ActiveMQ broker
+
+ PoolMaxSize 10
+
+ # Minimum number of physical connection to the ActiveMQ broker
+
+ PoolMinSize 0
+
+ # Maximum amount of time to wait for a connection
+
+ ConnectionMaxWaitMilliseconds 5000
+
+ # Maximum amount of time a connection can be idle before being reclaimed
+
+ ConnectionMaxIdleMinutes 15
+
+</Connector>
+
+<!--
+#
+# The <Deployments> element can be used to configure file
+# paths where OpenEJB should look for ejb jars or ear files.
+#
+# See http://openejb.apache.org/deployments.html
+#
+# The below entry is simply a default and can be changed or deleted
+-->
+<Deployments dir="apps/" />
+
+</openejb>
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/embedded.logging.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/embedded.logging.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/embedded.logging.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/embedded.logging.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,65 @@
+# =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+# =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
+# Configuration file for logging in OpenEJB
+#
+# OpenEJB uses Apache Log4j to provide logging services
+# to the container system.
+#
+# This file configures log4j using the properties file
+# format declared by the class PropertyConfigurator
+#
+# For a complete reference on log4j property
+# configuration, visit:
+#
+# http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/PropertyConfigurator.html
+#
+# This file is designated as the log4j configuration file
+# when the system property, log4j.configuration, is set
+# as follows:
+#
+# java -Dlog4j.configuration=file:conf/logging.conf
+#
+# Any other file could be set as the log4j configuration
+# file using that file name instead. For example, to
+# set the logging configuration using logging.xml, set
+# the log4j.configuration system property as follows:
+#
+# java -Dlog4j.configuration=file:conf/logging.xml
+#
+# For more information on specifying log4j configuration
+# files, visit:
+#
+# http://jakarta.apache.org/log4j/docs/manual.html
+#
+# =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
+
+log4j.rootLogger = fatal,C
+log4j.category.OpenEJB = warn
+log4j.category.OpenEJB.options = info
+log4j.category.OpenEJB.server = info
+log4j.category.OpenEJB.startup = info
+log4j.category.OpenEJB.startup.service = warn
+log4j.category.OpenEJB.startup.config = info
+log4j.category.OpenEJB.hsql = info
+log4j.category.CORBA-Adapter = info
+log4j.category.Transaction = warn
+log4j.category.org.apache.activemq = error
+log4j.category.org.apache.geronimo = error
+log4j.category.openjpa = error
+
+log4j.appender.C = org.apache.log4j.ConsoleAppender
+log4j.appender.C.layout = org.apache.log4j.SimpleLayout
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/groups.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/groups.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/groups.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/groups.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,3 @@
+committer=jonathan
+contributor=daniel
+community=jonathan,daniel
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/logging.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/logging.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/logging.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/logging.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,67 @@
+# ---------------------------------------------------
+# The configuration below is good for standalone
+# scenarios. There's a log file and everything is
+# time stamped and settings are slightly more verbose.
+#
+# For embedded scenarios the commented out configuration
+# below is a much better fit.
+#
+log4j.category.OpenEJB = warn,R
+log4j.category.OpenEJB.options = info
+log4j.category.OpenEJB.server = info
+log4j.category.OpenEJB.startup = info
+log4j.category.OpenEJB.startup.service = info
+log4j.category.OpenEJB.startup.config = info
+log4j.category.OpenEJB.hsql = info
+log4j.category.OpenEJB.ws = info
+log4j.category.OpenEJB.tomcat = info
+log4j.category.CORBA-Adapter = error,R
+log4j.category.Transaction = warn,TX
+log4j.category.org.apache.activemq = error,R
+log4j.category.org.apache.geronimo = error,R
+log4j.category.openjpa = error,R
+log4j.category.axis = info,R
+log4j.category.axis2 = info,R
+log4j.category.cxf = info,R
+log4j.category.org.apache.cxf = info,R
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.MaxFileSize=1000KB
+log4j.appender.R.MaxBackupIndex=7
+log4j.appender.R.File=logs/openejb.log
+log4j.appender.R.layout.ConversionPattern=%d - %-5p - %m%n
+
+log4j.appender.TX=org.apache.log4j.RollingFileAppender
+log4j.appender.TX.layout=org.apache.log4j.PatternLayout
+log4j.appender.TX.MaxFileSize=1000KB
+log4j.appender.TX.MaxBackupIndex=100
+log4j.appender.TX.File=logs/transaction.log
+log4j.appender.TX.layout.ConversionPattern=%d - %-5p - %m%n
+
+
+## ---------------------------------------------------
+## Nice alternate configuration for embedded testing
+##
+## Output is slightly more terse and sent to System.out
+##
+## Simply comment out the above declarations and
+## uncomment the configuration below.
+##
+#
+#log4j.rootLogger = fatal,C
+#log4j.category.OpenEJB = warn
+#log4j.category.OpenEJB.options = info
+#log4j.category.OpenEJB.server = info
+#log4j.category.OpenEJB.startup = info
+#log4j.category.OpenEJB.startup.service = warn
+#log4j.category.OpenEJB.startup.config = info
+#log4j.category.OpenEJB.hsql = info
+#log4j.category.CORBA-Adapter = info
+#log4j.category.Transaction = warn
+#log4j.category.org.apache.activemq = error
+#log4j.category.org.apache.geronimo = error
+#log4j.category.openjpa = error
+#
+#log4j.appender.C = org.apache.log4j.ConsoleAppender
+#log4j.appender.C.layout = org.apache.log4j.SimpleLayout
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/login.config
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/login.config?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/login.config (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/login.config Tue Feb 2 13:46:09 2010
@@ -0,0 +1,12 @@
+PropertiesLogin {
+ org.apache.openejb.core.security.jaas.PropertiesLoginModule required
+ Debug=true
+ UsersFile="users.properties"
+ GroupsFile="groups.properties";
+};
+SQLLogin {
+ org.apache.openejb.core.security.jaas.SQLLoginModule required
+ jdbcURL="jdbc:hsqldb:mem:sqltest"
+ userSelect="SELECT user, password FROM users WHERE user = ?"
+ groupSelect="SELECT user, grp FROM groups WHERE user = ?";
+};
\ No newline at end of file
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/openejb-version.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/openejb-version.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/openejb-version.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/openejb-version.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+# $Rev: 829242 $ $Date: 2009-10-23 23:17:48 +0200 (Fr, 23 Okt 2009) $
+#
+copyright=Copyright 1999-2009 (C) Apache OpenEJB Project, All Rights Reserved.
+url=http://openejb.apache.org/
+version=${pom.version}
+date=@DATE-REPLACED-BY-MAVEN@
+time=@TIME-REPLACED-BY-MAVEN@
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/users.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/users.properties?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/users.properties (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/main/resources/users.properties Tue Feb 2 13:46:09 2010
@@ -0,0 +1,2 @@
+jonathan=secret
+daniel=password
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/AmqXmlTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/AmqXmlTest.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/AmqXmlTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/AmqXmlTest.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,25 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+public class AmqXmlTest extends JmsProxyTest {
+ protected String getBrokerXmlConfig() {
+ // note activemq uses classpath xml loader
+ return "xbean:org/apache/openejb/core/mdb/activemq.xml";
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/CustomMdbContainerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/CustomMdbContainerTest.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/CustomMdbContainerTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/CustomMdbContainerTest.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,223 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.ConnectorModule;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.MessageDrivenBean;
+import org.apache.openejb.jee.Connector;
+import org.apache.openejb.jee.ResourceAdapter;
+import org.apache.openejb.jee.InboundResource;
+import org.apache.openejb.jee.MessageAdapter;
+import org.apache.openejb.jee.MessageListener;
+import org.apache.openejb.util.Join;
+
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.annotation.Resource;
+import javax.annotation.PostConstruct;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.MessageDriven;
+import javax.ejb.ActivationConfigProperty;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.InvalidPropertyException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.ResourceException;
+import javax.transaction.xa.XAResource;
+import java.util.Stack;
+import java.util.List;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.Condition;
+
+/**
+ * @version $Rev: 710022 $ $Date: 2008-11-03 09:40:14 +0100 (Mo, 03 Nov 2008) $
+ */
+public class CustomMdbContainerTest extends TestCase {
+ public void test() throws Exception {
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+
+ ConfigurationFactory config = new ConfigurationFactory();
+ Assembler assembler = new Assembler();
+
+ assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+ assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+ // Setup the descriptor information
+
+ EmailBean.lifecycle.clear();
+
+
+ AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
+
+ Connector connector = new Connector("email-ra");
+ ResourceAdapter adapter = connector.setResourceAdapter(new ResourceAdapter(EmailResourceAdapter.class));
+ InboundResource inbound = adapter.setInboundResourceAdapter(new InboundResource());
+ MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
+ MessageListener listener = messageAdapter.addMessageListener(new MessageListener(EmailConsumer.class, EmailAccountInfo.class));
+ listener.getActivationSpec().addRequiredConfigProperty("address");
+ app.getResourceModules().add(new ConnectorModule(connector));
+
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new MessageDrivenBean(EmailBean.class));
+ app.getEjbModules().add(new EjbModule(ejbJar));
+
+ AppInfo appInfo = config.configureApplication(app);
+ assembler.createApplication(appInfo);
+
+ InitialContext initialContext = new InitialContext();
+
+ EmailResourceAdapter ra = (EmailResourceAdapter) initialContext.lookup("java:openejb/Resource/email-raRA");
+
+ Properties headers = new Properties();
+ headers.put("To", "dblevins@apache.org");
+ headers.put("From", "dblevins@visi.com");
+ headers.put("Subject", "Hello");
+
+ ra.deliverEmail(headers, "How's it going?");
+
+ Stack<Lifecycle> lifecycle = EmailBean.lifecycle;
+
+ List expected = Arrays.asList(Lifecycle.values());
+
+ Assert.assertEquals(Join.join("\n", expected), Join.join("\n", lifecycle));
+
+ }
+
+ public static enum Lifecycle {
+ CONSTRUCTOR, INJECTION, POST_CONSTRUCT, ON_MESSAGE
+ }
+
+ @MessageDriven(activationConfig = {@ActivationConfigProperty(propertyName = "address", propertyValue = "dblevins@apache.org")})
+ public static class EmailBean implements EmailConsumer {
+
+ public static Lock lock = new ReentrantLock();
+ public static Condition messageRecieved = lock.newCondition();
+
+ private static Stack<Lifecycle> lifecycle = new Stack<Lifecycle>();
+
+ public EmailBean() {
+ lifecycle.push(Lifecycle.CONSTRUCTOR);
+ }
+
+ @Resource
+ public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) {
+ lifecycle.push(Lifecycle.INJECTION);
+ }
+
+ @PostConstruct
+ public void init() {
+ lifecycle.push(Lifecycle.POST_CONSTRUCT);
+ }
+
+ public void receiveEmail(Properties headers, String body) {
+ lifecycle.push(Lifecycle.ON_MESSAGE);
+ }
+ }
+
+ public static interface EmailConsumer {
+ public void receiveEmail(Properties headers, String body);
+ }
+
+ public static class EmailResourceAdapter implements javax.resource.spi.ResourceAdapter {
+ public boolean started;
+
+ private final Map<String, EmailConsumer> consumers = new HashMap<String, EmailConsumer>();
+
+ public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
+ }
+
+ public void stop() {
+ }
+
+ public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
+ EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;
+
+ EmailConsumer emailConsumer = (EmailConsumer) messageEndpointFactory.createEndpoint(null);
+ consumers.put(accountInfo.getAddress(), emailConsumer);
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
+ EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;
+
+ EmailConsumer emailConsumer = consumers.remove(accountInfo.getAddress());
+ MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;
+ endpoint.release();
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
+ return new XAResource[0];
+ }
+
+ public void deliverEmail(Properties headers, String body) throws Exception {
+ String to = headers.getProperty("To");
+
+ EmailConsumer emailConsumer = consumers.get(to);
+
+ if (emailConsumer == null) throw new Exception("No such account");
+
+ MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;
+
+ endpoint.beforeDelivery(EmailConsumer.class.getMethod("receiveEmail", Properties.class, String.class));
+ emailConsumer.receiveEmail(headers, body);
+ endpoint.afterDelivery();
+ }
+ }
+
+ public static class EmailAccountInfo implements ActivationSpec {
+ private EmailResourceAdapter emailResourceAdapter;
+
+ private String address;
+
+ public void validate() throws InvalidPropertyException {
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public EmailResourceAdapter getResourceAdapter() {
+ return emailResourceAdapter;
+ }
+
+ public void setResourceAdapter(javax.resource.spi.ResourceAdapter resourceAdapter) {
+ this.emailResourceAdapter = (EmailResourceAdapter) resourceAdapter;
+ }
+ }
+
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsMdbContainerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsMdbContainerTest.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsMdbContainerTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsMdbContainerTest.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,153 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+import junit.framework.TestCase;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.core.ivm.naming.InitContextFactory;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.MessageDrivenBean;
+import static org.apache.openejb.util.Join.join;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.MessageDrivenContext;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Stack;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * @version $Rev: 710022 $ $Date: 2008-11-03 09:40:14 +0100 (Mo, 03 Nov 2008) $
+ */
+public class JmsMdbContainerTest extends TestCase {
+ public void test() throws Exception {
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
+
+ ConfigurationFactory config = new ConfigurationFactory();
+ Assembler assembler = new Assembler();
+
+ assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+ assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+ // Setup the descriptor information
+
+ WidgetBean.lifecycle.clear();
+
+ EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new MessageDrivenBean(WidgetBean.class));
+
+ assembler.createApplication(config.configureApplication(ejbJar));
+
+ InitialContext initialContext = new InitialContext();
+
+ ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("java:openejb/Resource/Default JMS Connection Factory");
+
+ sendMessage(connectionFactory, "WidgetBean", "test");
+
+ Stack<Lifecycle> lifecycle = WidgetBean.lifecycle;
+
+ List expected = Arrays.asList(Lifecycle.values());
+
+ assertEquals(join("\n", expected), join("\n", lifecycle));
+
+ }
+
+ private void sendMessage(ConnectionFactory connectionFactory, String bean, String text) throws JMSException, InterruptedException {
+ WidgetBean.lock.lock();
+
+ try {
+ Connection connection = connectionFactory.createConnection();
+ connection.start();
+
+ // Create a Session
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue(bean);
+
+ // Create a MessageProducer from the Session to the Topic or Queue
+ MessageProducer producer = session.createProducer(queue);
+ producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ // Create a message
+ TextMessage message = session.createTextMessage(text);
+
+ // Tell the producer to send the message
+ producer.send(message);
+
+ WidgetBean.messageRecieved.await();
+ } finally {
+ WidgetBean.lock.unlock();
+ }
+ }
+
+ public static enum Lifecycle {
+ CONSTRUCTOR, INJECTION, POST_CONSTRUCT, ON_MESSAGE
+ }
+
+ public static class WidgetBean implements javax.jms.MessageListener {
+
+ public static Lock lock = new ReentrantLock();
+ public static Condition messageRecieved = lock.newCondition();
+
+ private static Stack<Lifecycle> lifecycle = new Stack<Lifecycle>();
+
+ @Resource
+ ConnectionFactory connectionFactory;
+
+ public WidgetBean() {
+ lifecycle.push(Lifecycle.CONSTRUCTOR);
+ }
+
+ @Resource
+ public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) {
+ lifecycle.push(Lifecycle.INJECTION);
+ }
+
+ @PostConstruct
+ public void init() {
+ lifecycle.push(Lifecycle.POST_CONSTRUCT);
+ }
+
+ public void onMessage(Message message) {
+ lifecycle.push(Lifecycle.ON_MESSAGE);
+
+ lock.lock();
+ try {
+ messageRecieved.signalAll();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,129 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.work.WorkManager;
+
+import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.geronimo.connector.GeronimoBootstrapContext;
+import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.resource.activemq.ActiveMQResourceAdapter;
+
+public class JmsProxyTest extends TestCase {
+ private static final String REQUEST_QUEUE_NAME = "request";
+ private ConnectionFactory connectionFactory;
+ private ActiveMQResourceAdapter ra;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // create a transaction manager
+ GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
+
+ // create the ActiveMQ resource adapter instance
+ ra = new ActiveMQResourceAdapter();
+
+ // initialize properties
+ ra.setServerUrl("tcp://localhost:61616");
+ ra.setBrokerXmlConfig(getBrokerXmlConfig());
+
+ // create a thead pool for ActiveMQ
+ Executor threadPool = Executors.newFixedThreadPool(30);
+
+ // create a work manager which ActiveMQ uses to dispatch message delivery jobs
+ WorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, transactionManager);
+
+ // wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
+ BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, transactionManager);
+
+ // start the resource adapter
+ try {
+ ra.start(bootstrapContext);
+ } catch (ResourceAdapterInternalException e) {
+ throw new OpenEJBException(e);
+ }
+ // Create a ConnectionFactory
+ connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
+ }
+
+ protected String getBrokerXmlConfig() {
+ return "broker:(tcp://localhost:61616)?useJmx=false";
+ }
+
+ protected void tearDown() throws Exception {
+ connectionFactory = null;
+ if (ra != null) {
+ ra.stop();
+ ra = null;
+ }
+ super.tearDown();
+ }
+
+ public void testProxy() throws Exception {
+ // create reciever object
+ JmsProxyTest.TestObject testObject = new JmsProxyTest.TestObject("foo");
+ MdbInvoker mdbInvoker = new MdbInvoker(connectionFactory, testObject);
+
+ // Create a Session
+ Connection connection = connectionFactory.createConnection();
+ connection.start();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create the request Queue
+ Destination requestQueue = session.createQueue(REQUEST_QUEUE_NAME);
+ MessageConsumer consumer = session.createConsumer(requestQueue);
+ consumer.setMessageListener(mdbInvoker);
+
+ // create in invoker
+ JmsProxyTest.TestInterface testInterface = MdbProxy.newProxyInstance(JmsProxyTest.TestInterface.class, connectionFactory, REQUEST_QUEUE_NAME);
+ assertEquals("foobar", testInterface.echo("bar"));
+ assertEquals("foobar", testInterface.echo("bar"));
+ assertEquals("foobar", testInterface.echo("bar"));
+ assertEquals("foobar", testInterface.echo("bar"));
+ assertEquals("foobar", testInterface.echo("bar"));
+ }
+
+ public static interface TestInterface {
+ String echo(String msg);
+ }
+
+ public static class TestObject implements JmsProxyTest.TestInterface {
+ private final String prefix;
+
+
+ public TestObject(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String echo(String msg) {
+ return prefix + msg;
+ }
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsTest.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/JmsTest.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,197 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.work.WorkManager;
+
+import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.geronimo.connector.GeronimoBootstrapContext;
+import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.resource.activemq.ActiveMQResourceAdapter;
+
+public class JmsTest extends TestCase {
+ private ConnectionFactory connectionFactory;
+ private static final String REQUEST_QUEUE_NAME = "request";
+ private ActiveMQResourceAdapter ra;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // create a transaction manager
+ GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
+
+ // create the ActiveMQ resource adapter instance
+ ra = new ActiveMQResourceAdapter();
+
+ // initialize properties
+ ra.setServerUrl("tcp://localhost:61616");
+ ra.setBrokerXmlConfig("broker:(tcp://localhost:61616)?useJmx=false");
+
+
+ // create a thead pool for ActiveMQ
+ Executor threadPool = Executors.newFixedThreadPool(30);
+
+ // create a work manager which ActiveMQ uses to dispatch message delivery jobs
+ WorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, transactionManager);
+
+ // wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
+ BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, transactionManager);
+
+ // start the resource adapter
+ try {
+ ra.start(bootstrapContext);
+ } catch (ResourceAdapterInternalException e) {
+ throw new OpenEJBException(e);
+ }
+ // Create a ConnectionFactory
+ connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
+ }
+
+ protected void tearDown() throws Exception {
+ connectionFactory = null;
+ if (ra != null) {
+ ra.stop();
+ ra = null;
+ }
+ super.tearDown();
+ }
+
+ public void testProxy() throws Exception {
+ // Create a Session
+ Connection connection = connectionFactory.createConnection();
+ try {
+ connection.start();
+
+ Destination requestQueue = createListener(connection);
+
+ createSender(connection, requestQueue);
+ } finally {
+ MdbUtil.close(connection);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void createSender(Connection connection, Destination requestQueue) throws JMSException {
+ Session session = null;
+ MessageProducer producer = null;
+ MessageConsumer consumer = null;
+ try {
+ // create request
+ Map<String, Object> request = new TreeMap<String, Object>();
+ request.put("args", new Object[]{"cheese"});
+
+ // create a new temp response queue
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination responseQueue = session.createTemporaryQueue();
+
+ // Create a request messages
+ ObjectMessage requestMessage = session.createObjectMessage();
+ requestMessage.setJMSReplyTo(responseQueue);
+ requestMessage.setObject((Serializable) request);
+
+ // Send the request message
+ producer = session.createProducer(requestQueue);
+ producer.send(requestMessage);
+
+ // wait for the response message
+ consumer = session.createConsumer(responseQueue);
+ Message message = consumer.receive(1000);
+
+ // verify message
+ assertNotNull("Did not get a response message", message);
+ assertTrue("Response message is not an ObjectMessage", message instanceof ObjectMessage);
+ ObjectMessage responseMessage = (ObjectMessage) message;
+ Serializable object = responseMessage.getObject();
+ assertNotNull("Response ObjectMessage contains a null object");
+ assertTrue("Response ObjectMessage does not contain an instance of Map", object instanceof Map);
+ Map<String, String> response = (Map<String, String>) object;
+
+ // process results
+ String returnValue = (String) response.get("return");
+ assertEquals("test-cheese", returnValue);
+ } finally {
+ MdbUtil.close(consumer);
+ MdbUtil.close(producer);
+ MdbUtil.close(session);
+ }
+ }
+
+
+ private Destination createListener(Connection connection) throws JMSException {
+ final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Create the request Queue
+ Destination requestQueue = session.createQueue(REQUEST_QUEUE_NAME);
+ MessageConsumer consumer = session.createConsumer(requestQueue);
+ consumer.setMessageListener(new MessageListener() {
+ @SuppressWarnings("unchecked")
+ public void onMessage(Message message) {
+ // if we got a dummy (non ObjectMessage) return
+ if (!(message instanceof ObjectMessage)) return;
+
+ MessageProducer producer = null;
+ try {
+ // process request
+ ObjectMessage requestMessage = (ObjectMessage) message;
+ Map<String, Object[]> request = (Map<String, Object[]>) requestMessage.getObject();
+ Object[] args = (Object[]) request.get("args");
+ String returnValue = "test-" + args[0];
+
+ // create response map
+ Map<String, Object> response = new TreeMap<String, Object>();
+ response.put("return", returnValue);
+
+ // create response message
+ ObjectMessage responseMessage = session.createObjectMessage();
+ responseMessage.setJMSCorrelationID(requestMessage.getJMSCorrelationID());
+ responseMessage.setObject((Serializable) response);
+
+ // send response message
+ producer = session.createProducer(requestMessage.getJMSReplyTo());
+ producer.send(responseMessage);
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ } finally {
+ MdbUtil.close(producer);
+ }
+ }
+ });
+ return requestQueue;
+ }
+}
Added: openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbInvoker.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbInvoker.java?rev=905632&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbInvoker.java (added)
+++ openejb/trunk/openejb3/container/openejb-activemq4/src/test/java/org/apache/openejb/core/mdb/MdbInvoker.java Tue Feb 2 13:46:09 2010
@@ -0,0 +1,125 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.core.mdb;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class MdbInvoker implements MessageListener {
+ private final Map<String, Method> signatures = new TreeMap<String, Method>();
+ private final Object target;
+ private Connection connection;
+ private Session session;
+ private ConnectionFactory connectionFactory;
+
+ public MdbInvoker(ConnectionFactory connectionFactory, Object target) throws JMSException {
+ this.target = target;
+ this.connectionFactory = connectionFactory;
+ for (Method method : target.getClass().getMethods()) {
+ String signature = MdbUtil.getSignature(method);
+ signatures.put(signature, method);
+ }
+ }
+
+ public synchronized void destroy() {
+ MdbUtil.close(session);
+ session = null;
+ MdbUtil.close(connection);
+ connection = null;
+ }
+
+ private synchronized Session getSession() throws JMSException {
+ connection = connectionFactory.createConnection();
+ connection.start();
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ return session;
+ }
+
+ public void onMessage(Message message) {
+ if (!(message instanceof ObjectMessage)) return;
+
+ try {
+ Session session = getSession();
+ if (session == null) throw new IllegalStateException("Invoker has been destroyed");
+
+ if (message == null) throw new NullPointerException("request message is null");
+ if (!(message instanceof ObjectMessage)) throw new IllegalArgumentException("Expected a ObjectMessage request but got a " + message.getClass().getName());
+ ObjectMessage objectMessage = (ObjectMessage) message;
+ Serializable object = objectMessage.getObject();
+ if (object == null) throw new NullPointerException("object in ObjectMessage is null");
+ if (!(object instanceof Map)) {
+ if (message instanceof ObjectMessage) throw new IllegalArgumentException("Expected a Map contained in the ObjectMessage request but got a " + object.getClass().getName());
+ }
+ Map request = (Map) object;
+
+ String signature = (String) request.get("method");
+ Method method = signatures.get(signature);
+ Object[] args = (Object[]) request.get("args");
+
+ boolean exception = false;
+ Object result = null;
+ try {
+ result = method.invoke(target, args);
+ } catch (IllegalAccessException e) {
+ result = e;
+ exception = true;
+ } catch (InvocationTargetException e) {
+ result = e.getCause();
+ if (result == null) result = e;
+ exception = true;
+ }
+
+ MessageProducer producer = null;
+ try {
+ // create response
+ Map<String, Object> response = new TreeMap<String, Object>();
+ if (exception) {
+ response.put("exception", "true");
+ }
+ response.put("return", result);
+
+ // create response message
+ ObjectMessage resMessage = session.createObjectMessage();
+ resMessage.setJMSCorrelationID(objectMessage.getJMSCorrelationID());
+ resMessage.setObject((Serializable) response);
+
+ // send response message
+ producer = session.createProducer(objectMessage.getJMSReplyTo());
+ producer.send(resMessage);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ MdbUtil.close(producer);
+ destroy();
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}