tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r610927 - in /openejb/trunk/openejb3: ./ assembly/openejb-standalone/ assembly/openejb-tomcat/openejb-tomcat-webapp/ assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/ container/openejb-core...
Date Thu, 10 Jan 2008 20:48:39 GMT
Author: dain
Date: Thu Jan 10 12:48:37 2008
New Revision: 610927

URL: http://svn.apache.org/viewvc?rev=610927&view=rev
Log:
Remove derby dependency

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEJBBrokerFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
Modified:
    openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/pom.xml
    openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
    openejb/trunk/openejb3/container/openejb-core/pom.xml
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.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/assembler/classic/MdbConfigTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java
    openejb/trunk/openejb3/pom.xml
    openejb/trunk/openejb3/server/openejb-activemq/pom.xml
    openejb/trunk/openejb3/server/openejb-derbynet/pom.xml
    openejb/trunk/openejb3/server/openejb-ejbd/pom.xml
    openejb/trunk/openejb3/server/openejb-http/pom.xml
    openejb/trunk/openejb3/server/openejb-webadmin/pom.xml

Modified: openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml Thu Jan 10 12:48:37 2008
@@ -188,10 +188,6 @@
       <version>${version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.openejb</groupId>
       <artifactId>openejb-http</artifactId>
       <version>${version}</version>

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/pom.xml (original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/pom.xml Thu Jan 10
12:48:37 2008
@@ -167,10 +167,6 @@
       <version>${version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.openejb</groupId>
       <artifactId>openejb-http</artifactId>
       <version>${version}</version>

Modified: openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
(original)
+++ openejb/trunk/openejb3/assembly/openejb-tomcat/openejb-tomcat-webapp/src/main/resources/META-INF/org.apache.openejb.tomcat/service-jar.xml
Thu Jan 10 12:48:37 2008
@@ -642,13 +642,16 @@
           id="Default JMS Resource Adapter"
           service="Resource"
           types="ActiveMQResourceAdapter"
-          class-name="org.apache.activemq.ra.ActiveMQResourceAdapter">
+          class-name="org.apache.openejb.resource.activemq.ActiveMQResourceAdapter">
 
     # Broker configuration
     BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false
 
     # Broker address
     ServerUrl vm://localhost?async=true
+
+    # DataSource for persistence messages
+    DataSource Default Unmanaged JDBC Database
 
     # Specifies the size of the thread pool available to AciveMQ.
     ThreadPoolSize 30

Modified: openejb/trunk/openejb3/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/pom.xml Thu Jan 10 12:48:37 2008
@@ -303,11 +303,6 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
       <scope>test</scope>

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
Thu Jan 10 12:48:37 2008
@@ -955,6 +955,13 @@
                 resourceInfo.properties.setProperty("ResourceAdapter", newResourceId);
             }
         }
+        String dataSourceId = resourceInfo.properties.getProperty("DataSource");
+        if (dataSourceId != null) {
+            String newResourceId = getResourceId(beanName, dataSourceId, null, null);
+            if (dataSourceId != newResourceId) {
+                resourceInfo.properties.setProperty("DataSource", newResourceId);
+            }
+        }
 
         configFactory.install(resourceInfo);
         return resourceInfo.id;

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java?rev=610927&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapter.java
Thu Jan 10 12:48:37 2008
@@ -0,0 +1,73 @@
+/**
+ *
+ * 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapterInternalException;
+
+import org.apache.openejb.util.URISupport;
+
+
+public class ActiveMQResourceAdapter extends org.apache.activemq.ra.ActiveMQResourceAdapter
{
+    private String dataSource;
+
+    public String getDataSource() {
+        return dataSource;
+    }
+
+    public void setDataSource(String dataSource) {
+        this.dataSource = dataSource;
+    }
+
+
+    public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException
{
+        Properties properties = new Properties();
+
+        // add data source property
+        if (dataSource != null) {
+            properties.put("DataSource", dataSource);
+        }
+
+        // prefix server uri with openejb: so our broker factory is used
+        String brokerXmlConfig = getBrokerXmlConfig();
+        if (brokerXmlConfig != null) {
+            try {
+                URISupport.CompositeData compositeData = URISupport.parseComposite(new URI(brokerXmlConfig));
+                compositeData.getParameters().put("persistent", "false");
+                setBrokerXmlConfig("openejb:" + compositeData.toURI());
+            } catch (URISyntaxException e) {
+                throw new ResourceAdapterInternalException("Invalid BrokerXmlConfig", e);
+            }
+        }
+
+        OpenEjbBrokerFactory.setThreadProperties(properties);
+        try {
+            super.start(bootstrapContext);
+        } finally {
+            OpenEjbBrokerFactory.setThreadProperties(null);
+
+            // reset brokerXmlConfig
+            if (brokerXmlConfig != null) {
+                setBrokerXmlConfig(brokerXmlConfig);
+            }
+        }
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEJBBrokerFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEJBBrokerFactory.java?rev=610927&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEJBBrokerFactory.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/resource/activemq/OpenEJBBrokerFactory.java
Thu Jan 10 12:48:37 2008
@@ -0,0 +1,93 @@
+/**
+ *
+ * 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 java.net.URI;
+import java.util.Map;
+import java.util.Properties;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+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;
+
+public class OpenEjbBrokerFactory 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 != null) {
+            DataSource dataSource;
+            if (value instanceof DataSource) {
+                dataSource = (DataSource) value;
+            } else {
+                String resouceId = (String) value;
+
+                try {
+                    Context context = new InitialContext();
+                    Object obj = context.lookup("java: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;
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/URISupport.java
Thu Jan 10 12:48:37 2008
@@ -23,12 +23,13 @@
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Arrays;
+import java.util.Map;
 
 /**
  * Swiped verbatim from ActiveMQ... the URI kings.
@@ -153,7 +154,7 @@
 
     public static Map<String, String> parseQuery(String uri) throws URISyntaxException{
         try{
-            Map<String, String> rc=new HashMap<String,String>();
+            Map<String, String> rc = new LinkedHashMap<String,String>();
             if(uri!=null){
                 String[] parameters=uri.split("&");
                 for(int i=0;i<parameters.length;i++){
@@ -244,7 +245,7 @@
         } else {
             if( params.length() > 0 )
                 rc.path = stripPrefix(params, "/");
-            rc.parameters = Collections.EMPTY_MAP;
+            rc.parameters = new LinkedHashMap();
         }
     }
 

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=610927&r1=610926&r2=610927&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
Thu Jan 10 12:48:37 2008
@@ -635,13 +635,16 @@
           id="Default JMS Resource Adapter"
           service="Resource"
           types="ActiveMQResourceAdapter"
-          class-name="org.apache.activemq.ra.ActiveMQResourceAdapter">
+          class-name="org.apache.openejb.resource.activemq.ActiveMQResourceAdapter">
 
     # Broker configuration
     BrokerXmlConfig broker:(tcp://localhost:61616)?useJmx=false
 
     # Broker address
     ServerUrl vm://localhost?async=true
+
+    # DataSource for persistence messages
+    DataSource Default Unmanaged JDBC Database
 
     # Specifies the size of the thread pool available to AciveMQ.
     ThreadPoolSize 30

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/MdbConfigTest.java
Thu Jan 10 12:48:37 2008
@@ -52,6 +52,11 @@
         assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
         assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
 
+        // JMS persistence datasource
+        ResourceInfo dataSourceInfo = config.configureService("Default Unmanaged JDBC Database",
ResourceInfo.class);
+        dataSourceInfo.properties.setProperty("JdbcUrl", "jdbc:hsqldb:mem:MdbConfigTest");
+        assembler.createResource(dataSourceInfo);
+
         // JMS
         assembler.createResource(config.configureService("Default JMS Resource Adapter",
ResourceInfo.class));
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsProxyTest.java
Thu Jan 10 12:48:37 2008
@@ -17,25 +17,24 @@
  */
 package org.apache.openejb.core.mdb;
 
-import junit.framework.TestCase;
-
-import javax.jms.ConnectionFactory;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
 import javax.jms.Connection;
-import javax.jms.Session;
+import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
 import javax.jms.MessageConsumer;
-import javax.resource.spi.work.WorkManager;
+import javax.jms.Session;
 import javax.resource.spi.BootstrapContext;
 import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.work.WorkManager;
 
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
+import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
-import org.apache.geronimo.connector.work.GeronimoWorkManager;
 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 java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
+import org.apache.openejb.resource.activemq.ActiveMQResourceAdapter;
 
 public class JmsProxyTest extends TestCase {
     private static final String REQUEST_QUEUE_NAME = "request";

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsTest.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/JmsTest.java
Thu Jan 10 12:48:37 2008
@@ -22,7 +22,6 @@
 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;
@@ -39,11 +38,11 @@
 
 import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
 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;

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbTest.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/MdbTest.java
Thu Jan 10 12:48:37 2008
@@ -23,7 +23,6 @@
 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;
@@ -46,11 +45,11 @@
 import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.ra.ActiveMQActivationSpec;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
 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 MdbTest extends TestCase {
     private static final String REQUEST_QUEUE_NAME = "request";

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/mdb/SimpleJmsTest.java
Thu Jan 10 12:48:37 2008
@@ -19,7 +19,6 @@
 
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Destination;
@@ -31,11 +30,11 @@
 
 import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
 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 SimpleJmsTest extends TestCase {
     private static final String REQUEST_QUEUE_NAME = "request";

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java?rev=610927&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/ActiveMQResourceAdapterTest.java
Thu Jan 10 12:48:37 2008
@@ -0,0 +1,32 @@
+/**
+ *
+ * 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 junit.framework.TestCase;
+
+public class ActiveMQResourceAdapterTest extends TestCase {
+    public void test() throws Exception {
+        ActiveMQResourceAdapter resourceAdapter = new ActiveMQResourceAdapter();
+        resourceAdapter.setServerUrl("vm://localhost?async=true");
+        resourceAdapter.setBrokerXmlConfig("broker:(tcp://localhost:61616)?useJmx=false");
+
+        //    DataSource Default Unmanaged JDBC Database
+        //
+        resourceAdapter.start(null);
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java?rev=610927&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/resource/activemq/OpenEjbBrokerFactoryTest.java
Thu Jan 10 12:48:37 2008
@@ -0,0 +1,173 @@
+/**
+ *
+ * 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.network.jms.JmsConnector;
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter;
+import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
+import org.apache.openejb.util.URISupport;
+import org.apache.xbean.naming.context.ImmutableContext;
+import org.hsqldb.jdbc.jdbcDataSource;
+
+public class OpenEjbBrokerFactoryTest extends TestCase {
+    public void testBrokerUri() throws Exception {
+        assertEquals("openejb:broker:(tcp://localhost:61616)?persistent=false",
+                getBrokerUri("broker:(tcp://localhost:61616)"));
+        assertEquals("openejb:broker:(tcp://localhost:61616)?useJmx=false&persistent=false",
+                getBrokerUri("broker:(tcp://localhost:61616)?useJmx=false"));
+        assertEquals("openejb:broker:(tcp://localhost:61616)?useJmx=false&persistent=false",
+                getBrokerUri("broker:(tcp://localhost:61616)?useJmx=false&persistent=true"));
+        assertEquals("openejb:broker:(tcp://localhost:61616)?useJmx=false&persistent=false",
+                getBrokerUri("broker:(tcp://localhost:61616)?useJmx=false&persistent=false"));
  
+    }
+
+    private String getBrokerUri(String brokerUri) throws URISyntaxException {
+        URISupport.CompositeData compositeData = URISupport.parseComposite(new URI(brokerUri));
+        compositeData.getParameters().put("persistent", "false");
+        return "openejb:" + compositeData.toURI();
+    }
+
+    public void testBrokerDoubleCreate() throws Exception {
+        BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri( "broker:(tcp://localhost:61616)?useJmx=false")));
+        stopBroker(broker);
+        
+        broker = BrokerFactory.createBroker(new URI(getBrokerUri("broker:(tcp://localhost:61616)?useJmx=false")));
+        stopBroker(broker);
+
+    }
+
+    public void testNoDataSource() throws Exception {
+        BrokerService broker = BrokerFactory.createBroker(new URI(getBrokerUri(
+                "broker:(tcp://localhost:61616)?useJmx=false")));
+        assertNotNull("broker is null", broker);
+
+        PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
+        assertNotNull("persistenceAdapter is null", persistenceAdapter);
+
+        assertTrue("persistenceAdapter should be an instance of MemoryPersistenceAdapter",
+                persistenceAdapter instanceof MemoryPersistenceAdapter);
+
+        stopBroker(broker);
+    }
+
+    public void testDirectDataSource() throws Exception {
+        Properties properties = new Properties();
+
+        DataSource dataSource = new jdbcDataSource();
+        properties.put("DataSource", dataSource);
+
+        OpenEjbBrokerFactory.setThreadProperties(properties);
+        BrokerService broker = null;
+        try {
+            broker = BrokerFactory.createBroker(new URI(getBrokerUri(
+                    "broker:(tcp://localhost:61616)?useJmx=false")));
+            assertNotNull("broker is null", broker);
+
+            PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
+            assertNotNull("persistenceAdapter is null", persistenceAdapter);
+
+            assertTrue("persistenceAdapter should be an instance of JDBCPersistenceAdapter",
+                    persistenceAdapter instanceof JDBCPersistenceAdapter);
+            JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter)persistenceAdapter;
+
+            assertSame(dataSource, jdbcPersistenceAdapter.getDataSource());
+        } finally {
+            stopBroker(broker);
+            OpenEjbBrokerFactory.setThreadProperties(null);
+        }
+    }
+
+    public void testLookupDataSource() throws Exception {
+        Properties properties = new Properties();
+
+        DataSource dataSource = new jdbcDataSource();
+        MockInitialContextFactory.install(Collections.singletonMap("java:openejb/Resource/TestDs",
dataSource));
+        assertSame(dataSource, new InitialContext().lookup("java:openejb/Resource/TestDs"));
+
+        properties.put("DataSource", "TestDs");
+
+        OpenEjbBrokerFactory.setThreadProperties(properties);
+        BrokerService broker = null;
+        try {
+            broker = BrokerFactory.createBroker(new URI(getBrokerUri(
+                    "broker:(tcp://localhost:61616)?useJmx=false")));
+            assertNotNull("broker is null", broker);
+
+            PersistenceAdapter persistenceAdapter = broker.getPersistenceAdapter();
+            assertNotNull("persistenceAdapter is null", persistenceAdapter);
+
+            assertTrue("persistenceAdapter should be an instance of JDBCPersistenceAdapter",
+                    persistenceAdapter instanceof JDBCPersistenceAdapter);
+            JDBCPersistenceAdapter jdbcPersistenceAdapter = (JDBCPersistenceAdapter)persistenceAdapter;
+
+            assertSame(dataSource, jdbcPersistenceAdapter.getDataSource());
+        } finally {
+            stopBroker(broker);
+            OpenEjbBrokerFactory.setThreadProperties(null);
+        }
+    }
+
+    public static class MockInitialContextFactory implements InitialContextFactory {
+        private static ImmutableContext immutableContext;
+
+        public static void install(Map bindings) throws NamingException {
+            immutableContext = new ImmutableContext(bindings);
+            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, MockInitialContextFactory.class.getName());
+            new InitialContext();
+        }
+
+        public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException
{
+            return immutableContext;
+        }
+    }
+
+
+    private void stopBroker(BrokerService broker) throws Exception {
+        if (broker == null) return;
+
+        if (broker.getJmsBridgeConnectors() != null) {
+            for (JmsConnector connector : broker.getJmsBridgeConnectors()) {
+                connector.stop();
+            }
+        }
+        for (Object o : broker.getTransportConnectors()) {
+            TransportConnector tc = (TransportConnector) o;
+            tc.stop();
+
+        }
+        broker.stop();
+    }
+
+}

Modified: openejb/trunk/openejb3/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/pom.xml (original)
+++ openejb/trunk/openejb3/pom.xml Thu Jan 10 12:48:37 2008
@@ -106,7 +106,6 @@
               as the maven-release-plugin will not update this value.
     <version>3.0-SNAPSHOT</version>
         -->
-    <derbyVersion>10.3.2.1</derbyVersion>
     <xbeanVersion>3.3-SNAPSHOT</xbeanVersion>
   </properties>
 
@@ -568,21 +567,6 @@
             <artifactId>nlog4j</artifactId>
           </exclusion>
         </exclusions>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.derby</groupId>
-        <artifactId>derby</artifactId>
-        <version>${derbyVersion}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.derby</groupId>
-        <artifactId>derbyclient</artifactId>
-        <version>${derbyVersion}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.derby</groupId>
-        <artifactId>derbynet</artifactId>
-        <version>${derbyVersion}</version>
       </dependency>
       <dependency>
         <groupId>org.apache.geronimo.components</groupId>

Modified: openejb/trunk/openejb3/server/openejb-activemq/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-activemq/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-activemq/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-activemq/pom.xml Thu Jan 10 12:48:37 2008
@@ -42,10 +42,6 @@
       <artifactId>activemq-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

Modified: openejb/trunk/openejb3/server/openejb-derbynet/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-derbynet/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-derbynet/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-derbynet/pom.xml Thu Jan 10 12:48:37 2008
@@ -40,10 +40,12 @@
     <dependency>
       <groupId>org.apache.derby</groupId>
       <artifactId>derby</artifactId>
+      <version>10.3.2.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.derby</groupId>
       <artifactId>derbynet</artifactId>
+      <version>10.3.2.1</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>

Modified: openejb/trunk/openejb3/server/openejb-ejbd/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-ejbd/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-ejbd/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-ejbd/pom.xml Thu Jan 10 12:48:37 2008
@@ -80,11 +80,6 @@
       <artifactId>geronimo-ejb_3.0_spec</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>idb</groupId>
       <artifactId>idb</artifactId>
       <scope>test</scope>

Modified: openejb/trunk/openejb3/server/openejb-http/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-http/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-http/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-http/pom.xml Thu Jan 10 12:48:37 2008
@@ -102,11 +102,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>idb</groupId>
       <artifactId>idb</artifactId>
       <scope>test</scope>

Modified: openejb/trunk/openejb3/server/openejb-webadmin/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webadmin/pom.xml?rev=610927&r1=610926&r2=610927&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webadmin/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-webadmin/pom.xml Thu Jan 10 12:48:37 2008
@@ -105,11 +105,6 @@
       <version>1.3</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>idb</groupId>
       <artifactId>idb</artifactId>
       <scope>test</scope>



Mime
View raw message