tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r609119 - in /openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/config/ container/openejb-core/src/test/resources/conf/ itests/openejb-itests-beans/src/main/resources/META-INF/ itests/openejb-itests-client/src/...
Date Sat, 05 Jan 2008 10:14:57 GMT
Author: dblevins
Date: Sat Jan  5 02:14:31 2008
New Revision: 609119

URL: http://svn.apache.org/viewvc?rev=609119&view=rev
Log:
Employed CaseInsensitiveProperties
Ability to auto-config based on property names/values
Added missing resource-link elements in openejb-jar.xml

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClearEmptyMappedName.java
Removed:
    openejb/trunk/openejb3/container/openejb-core/src/test/resources/conf/
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ApplyOpenejbJar.java
    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/config/ConfigurationFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
    openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
    openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ApplyOpenejbJar.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ApplyOpenejbJar.java?rev=609119&r1=609118&r2=609119&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ApplyOpenejbJar.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ApplyOpenejbJar.java
Sat Jan  5 02:14:31 2008
@@ -45,6 +45,8 @@
                 // Get the OpenEJB deployment from openejb-jar.xml
                 EjbDeployment ejbDeployment = ejbDeployments.get(enterpriseBean.getEjbName());
 
+                enterpriseBean.setId(ejbDeployment.getDeploymentId());
+
                 // Copy all links over to mappedName
 
                 for (ResourceRef ref : enterpriseBean.getResourceRef()) {

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=609119&r1=609118&r2=609119&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
Sat Jan  5 02:14:31 2008
@@ -298,11 +298,13 @@
             ejbModule.setOpenejbJar(openejbJar);
         }
 
+        Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
+
         for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
             if (bean instanceof MessageDrivenBean) {
                 MessageDrivenBean mdb = (MessageDrivenBean) bean;
 
-                EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
+                EjbDeployment ejbDeployment = deployments.get(bean.getEjbName());
                 if (ejbDeployment == null) {
                     throw new OpenEJBException("No ejb deployment found for ejb " + bean.getEjbName());
                 }
@@ -671,8 +673,10 @@
             ejbModule.setOpenejbJar(openejbJar);
         }
 
+        Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
+
         for (EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
-            EjbDeployment ejbDeployment = openejbJar.getDeploymentsByEjbName().get(bean.getEjbName());
+            EjbDeployment ejbDeployment = deployments.get(bean.getEjbName());
             if (ejbDeployment == null) {
                 throw new OpenEJBException("No ejb deployment found for ejb " + bean.getEjbName());
             }
@@ -849,11 +853,16 @@
 
         Persistence persistence = persistenceModule.getPersistence();
         for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
-            String jtaDataSourceId = getResourceId(persistenceUnit.getName(), persistenceUnit.getJtaDataSource(),
DataSource.class.getName(), null);
+            Properties required = new Properties();
+
+            required.put("JtaManaged", "true");
+            String jtaDataSourceId = getResourceId(persistenceUnit.getName(), persistenceUnit.getJtaDataSource(),
DataSource.class.getName(), null, required);
             if (jtaDataSourceId != null) {
                 persistenceUnit.setJtaDataSource("java:openejb/Resource/" + jtaDataSourceId);
             }
-            String nonJtaDataSourceId = getResourceId(persistenceUnit.getName(), persistenceUnit.getNonJtaDataSource(),
DataSource.class.getName(), null);
+
+            required.put("JtaManaged", "false");
+            String nonJtaDataSourceId = getResourceId(persistenceUnit.getName(), persistenceUnit.getNonJtaDataSource(),
DataSource.class.getName(), null, required);
             if (nonJtaDataSourceId != null) {
                 persistenceUnit.setNonJtaDataSource("java:openejb/Resource/" + nonJtaDataSourceId);
             }
@@ -861,9 +870,14 @@
     }
 
     private String getResourceId(String beanName, String resourceId, String type, AppResources
appResources) throws OpenEJBException {
+        return getResourceId(beanName, resourceId, type, appResources, null);
+    }
+
+    private String getResourceId(String beanName, String resourceId, String type, AppResources
appResources, Properties required) throws OpenEJBException {
         if(resourceId == null){
             return null;
         }
+
         if (appResources == null) appResources = new AppResources();
 
         // skip references such as URL which are automatically handled by the server
@@ -879,7 +893,7 @@
         // check for existing resource with specified resourceId
         List<String> resourceIds = new ArrayList<String>();
         resourceIds.addAll(appResources.getResourceIds(type));
-        resourceIds.addAll(configFactory.getResourceIds(type));
+        resourceIds.addAll(configFactory.getResourceIds(type, required));
         for (String id : resourceIds) {
             if (id.equalsIgnoreCase(resourceId)) return id;
         }
@@ -893,7 +907,7 @@
         // expand search to any type -- may be asking for a reference to a sub-type
         List<String> allResourceIds = new ArrayList<String>();
         allResourceIds.addAll(appResources.getResourceIds(null));
-        allResourceIds.addAll(configFactory.getResourceIds(null));
+        allResourceIds.addAll(configFactory.getResourceIds(null, required));
         for (String id : allResourceIds) {
             if (id.equalsIgnoreCase(resourceId)) return id;
         }
@@ -923,7 +937,7 @@
         }
 
         // Auto create a resource using the first provider that can supply a resource of
the desired type
-        resourceId = ServiceUtils.getServiceProviderId(type);
+        resourceId = ServiceUtils.getServiceProviderId(type, required);
         if (resourceId == null) {
             throw new OpenEJBException("No provider available for resource-ref '" + resourceId
+ "' of type '" + type + "' for '" + beanName + "'.");
         }

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClearEmptyMappedName.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClearEmptyMappedName.java?rev=609119&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClearEmptyMappedName.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ClearEmptyMappedName.java
Sat Jan  5 02:14:31 2008
@@ -0,0 +1,62 @@
+/**
+ * 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.config;
+
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.jee.JndiConsumer;
+import org.apache.openejb.jee.JndiReference;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ClearEmptyMappedName implements DynamicDeployer {
+
+    public AppModule deploy(AppModule appModule) throws OpenEJBException {
+        for (EjbModule ejbModule : appModule.getEjbModules()) {
+            for (JndiConsumer consumer : ejbModule.getEjbJar().getEnterpriseBeans()) {
+                clearEmptyMappedName(consumer);
+            }
+        }
+        for (ClientModule clientModule : appModule.getClientModules()) {
+            clearEmptyMappedName(clientModule.getApplicationClient());
+        }
+        for (WebModule webModule : appModule.getWebModules()) {
+            clearEmptyMappedName(webModule.getWebApp());
+        }
+        return appModule;
+    }
+
+    private void clearEmptyMappedName(JndiConsumer consumer) {
+        List<JndiReference> refs = new ArrayList<JndiReference>();
+        refs.addAll(consumer.getEjbLocalRef());
+        refs.addAll(consumer.getEjbRef());
+        refs.addAll(consumer.getEnvEntry());
+        refs.addAll(consumer.getMessageDestinationRef());
+        refs.addAll(consumer.getPersistenceContextRef());
+        refs.addAll(consumer.getPersistenceUnitRef());
+        refs.addAll(consumer.getResourceEnvRef());
+        refs.addAll(consumer.getResourceRef());
+        refs.addAll(consumer.getServiceRef());
+
+        for (JndiReference ref : refs) {
+            if (ref.getMappedName() != null && ref.getMappedName().length() == 0)
ref.setMappedName(null);
+        }
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=609119&r1=609118&r2=609119&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
Sat Jan  5 02:14:31 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.config;
 
+import static org.apache.openejb.config.ServiceUtils.implies;
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.AppInfo;
 import org.apache.openejb.assembler.classic.Assembler;
@@ -64,11 +65,9 @@
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.Messages;
 import org.apache.openejb.util.URISupport;
-import org.apache.openejb.util.Join;
+import org.apache.openejb.util.CaseInsensitiveProperties;
 
 import java.io.File;
-import java.io.DataOutputStream;
-import java.io.PrintWriter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -155,6 +154,8 @@
 
         chain.add(new AnnotationDeployer());
 
+        chain.add(new ClearEmptyMappedName());
+
         boolean shouldValidate = !SystemInstance.get().getProperty("openejb.validation.skip",
"false").equalsIgnoreCase("true");
         if (shouldValidate) {
             chain.add(new ValidateModules());
@@ -193,7 +194,8 @@
         chain.add(new ApplyOpenejbJar());
 
         // TODO: How do we want this plugged in?
-        //chain.add(new OutputGeneratedDescriptors());
+        chain.add(new OutputGeneratedDescriptors());
+
         this.deployer = chain;
     }
 
@@ -525,7 +527,7 @@
 
             logger.info("configureService.configuring", service.getId(), provider.getService(),
provider.getId());
 
-            Properties props = new Properties();
+            Properties props = new CaseInsensitiveProperties();
             props.putAll(provider.getProperties());
             props.putAll(service.getProperties());
             props.putAll(getSystemProperties(service.getId(), provider.getService()));
@@ -690,12 +692,18 @@
     }
 
     protected List<String> getResourceIds(String type) {
+        return getResourceIds(type, null);
+    }
+
+    protected List<String> getResourceIds(String type, Properties required) {
         List<String> resourceIds = new ArrayList<String>();
 
+        if (required == null) required = new Properties();
+
         OpenEjbConfiguration runningConfig = getRunningConfig();
         if (runningConfig != null) {
             for (ResourceInfo resourceInfo : runningConfig.facilities.resources) {
-                if (isResourceType(resourceInfo.service, resourceInfo.types, type)) {
+                if (isResourceType(resourceInfo.service, resourceInfo.types, type) &&
implies(required, resourceInfo.properties)) {
                     resourceIds.add(resourceInfo.id);
                 }
             }
@@ -703,7 +711,7 @@
 
         if (sys != null) {
             for (ResourceInfo resourceInfo : sys.facilities.resources) {
-                if (isResourceType(resourceInfo.service, resourceInfo.types, type)) {
+                if (isResourceType(resourceInfo.service, resourceInfo.types, type) &&
implies(required, resourceInfo.properties)) {
                     resourceIds.add(resourceInfo.id);
                 }
             }
@@ -716,7 +724,7 @@
                     if (resource.getType() != null){
                         types.add(resource.getType());
                     }
-                    if (isResourceType("Resource", types, type)) {
+                    if (isResourceType("Resource", types, type) && implies(required,
resource.getProperties())) {
                         resourceIds.add(resource.getId());
                     }
                 }
@@ -796,30 +804,10 @@
             if (!provider.types.contains("Topic") && !provider.types.contains("Queue"))
return;
             if (!provider.className.matches("org.apache.activemq.command.ActiveMQ(Topic|Queue)"))
return;
 
-
-            Properties properties = provider.properties;
-            String destination = normalizePropertyName(properties, "destination");
-            if (properties.getProperty(destination) == null || properties.getProperty(destination).equals("")){
-                properties.setProperty(destination, provider.id);
+            String dest = provider.properties.getProperty("destination");
+            if (dest == null || dest.length() == 0) {
+                provider.properties.setProperty("destination", provider.id);
             }
-        }
-
-        /**
-         * Our properties are not case sensitive, so they may have specified the name
-         * under any case.  Would be super to have a case insensitive properties impl.
-         * @param properties
-         * @param property
-         * @return the property name under any corrected case
-         */
-        private static String normalizePropertyName(Properties properties, String property)
{
-            for (Object o : properties.keySet()) {
-                String name  = (String) o;
-                if (name.equalsIgnoreCase(property)){
-                    return name;
-                }
-            }
-
-            return property;
         }
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java?rev=609119&r1=609118&r2=609119&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
Sat Jan  5 02:14:31 2008
@@ -36,6 +36,8 @@
 import java.util.ArrayList;
 
 public class ServiceUtils {
+    public static final String ANY = ServiceUtils.class.getName() + "@ANY";
+
     public static final String defaultProviderURL = System.getProperty("openejb.provider.default",
"org.apache.openejb");
     private static Map<String, List<ServiceProvider>> loadedServiceJars = new
HashMap<String, List<ServiceProvider>>();
     public static Messages messages = new Messages("org.apache.openejb.util.resources");
@@ -90,7 +92,11 @@
     }
 
     public static String getServiceProviderId(String type) throws OpenEJBException {
-        ServiceProvider provider = getServiceProviderByType(type);
+        return getServiceProviderId(type, null);
+    }
+
+    public static String getServiceProviderId(String type, Properties required) throws OpenEJBException
{
+        ServiceProvider provider = getServiceProviderByType(type, required);
 
         return provider != null? provider.getId(): null;
     }
@@ -113,18 +119,38 @@
 
 
     public static ServiceProvider getServiceProviderByType(String type) throws OpenEJBException
{
+        return getServiceProviderByType(type, (Properties) null);
+    }
+
+    public static ServiceProvider getServiceProviderByType(String type, Properties required)
throws OpenEJBException {
         if (type == null) return null;
+        if (required == null) required = new Properties();
 
         List<ServiceProvider> services = getServiceProviders(defaultProviderURL);
 
         for (ServiceProvider service : services) {
-            if (service.getTypes().contains(type)) {
+            if (service.getTypes().contains(type) && implies(required, service.getProperties()))
{
                 return service;
             }
         }
 
         return null;
     }
+
+    public static boolean implies(Properties a, Properties b){
+        for (Map.Entry<Object, Object> entry : a.entrySet()) {
+            Object value = b.get(entry.getKey());
+
+            // does b have the key?
+            if (value == null) return false;
+
+            // do the values match?
+            Object expected = entry.getValue();
+            if (!expected.equals(ANY) && !expected.equals(value)) return false;
+        }
+        return true;
+    }
+
 
     public static ServiceProvider getServiceProviderByType(String providerType, String serviceType)
throws OpenEJBException {
         if (serviceType == null) return null;

Modified: openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml?rev=609119&r1=609118&r2=609119&view=diff
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
(original)
+++ openejb/trunk/openejb3/itests/openejb-itests-beans/src/main/resources/META-INF/openejb-jar.xml
Sat Jan  5 02:14:31 2008
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
 
     Licensed to the Apache Software Foundation (ASF) under one or more
@@ -136,6 +136,7 @@
   </ejb-deployment>
   <ejb-deployment ejb-name="AOBasicCmpBean" deployment-id="client/tests/entity/cmp/allowed_operations/EntityHome">
     <resource-link res-ref-name="jdbc/basic/entityDatabase" res-id="My DataSource"/>
+    <resource-link res-ref-name="stateless/references/Resource_manager_access" res-id="My
DataSource"/>
     <query>
       <query-method>
         <method-name>findByLastName</method-name>
@@ -155,6 +156,7 @@
   </ejb-deployment>
   <ejb-deployment ejb-name="AOBasicCmp2Bean" deployment-id="client/tests/entity/cmp2/allowed_operations/EntityHome">
     <resource-link res-ref-name="jdbc/basic/entityDatabase" res-id="My DataSource"/>
+    <resource-link res-ref-name="stateless/references/Resource_manager_access" res-id="My
DataSource"/>
   </ejb-deployment>
   <ejb-deployment ejb-name="EncCmpBean" deployment-id="client/tests/entity/cmp/EncBean">
     <resource-link res-ref-name="datasource" res-id="My DataSource"/>
@@ -348,5 +350,25 @@
   <ejb-deployment ejb-name="InterceptorMdbBean" deployment-id="InterceptorMdbBean">
     <resource-link res-ref-name="jms" res-id="My JMS Connection Factory"/>
   </ejb-deployment>
-  
+  <ejb-deployment ejb-name="AnnotatedFieldInjectionStatefulBean" deployment-id="AnnotatedFieldInjectionStatefulBean">
+    <resource-link res-ref-name="org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/daataSource"
res-id="My DataSource"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/coonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/queueCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateful.AnnotatedFieldInjectionStatefulBean/topicCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+  </ejb-deployment>
+  <ejb-deployment ejb-name="AnnotatedFieldInjectionStatelessBean" deployment-id="AnnotatedFieldInjectionStatelessBean">
+    <resource-link res-ref-name="org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/daataSource"
res-id="My DataSource"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/coonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/queueCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.stateless.AnnotatedFieldInjectionStatelessBean/topicCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+  </ejb-deployment>
+  <ejb-deployment ejb-name="BasicStatelessIntercepted" deployment-id="BasicStatelessIntercepted"/>
+  <ejb-deployment ejb-name="BasicStatefulIntercepted" deployment-id="BasicStatefulIntercepted"/>
+  <ejb-deployment ejb-name="AnnotatedFieldInjectionMdbBean" deployment-id="AnnotatedFieldInjectionMdbBean">
+    <resource-link res-ref-name="openejb/destination" res-id="AnnotatedFieldInjectionMdb"/>
+    <resource-link res-ref-name="org.apache.openejb.test.mdb.AnnotatedFieldInjectionMdbBean/daataSource"
res-id="My DataSource"/>
+    <resource-link res-ref-name="org.apache.openejb.test.mdb.AnnotatedFieldInjectionMdbBean/coonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.mdb.AnnotatedFieldInjectionMdbBean/queueCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+    <resource-link res-ref-name="org.apache.openejb.test.mdb.AnnotatedFieldInjectionMdbBean/topicCoonnectionFactory"
res-id="My JMS Connection Factory"/>
+  </ejb-deployment>
 </openejb-jar>

Modified: openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java?rev=609119&r1=609118&r2=609119&view=diff
==============================================================================
--- openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java
(original)
+++ openejb/trunk/openejb3/itests/openejb-itests-client/src/main/java/org/apache/openejb/test/entity/cmr/AbstractCMRTest.java
Sat Jan  5 02:14:31 2008
@@ -26,6 +26,7 @@
 import javax.sql.DataSource;
 import javax.naming.InitialContext;
 import javax.naming.Context;
+import javax.naming.NamingException;
 import java.util.Properties;
 import java.sql.SQLException;
 import java.sql.Connection;
@@ -75,7 +76,11 @@
 
         InitialContext jndiContext = new InitialContext( );
         transactionManager = (TransactionManager) jndiContext.lookup("java:openejb/TransactionManager");
-        ds = (DataSource) jndiContext.lookup("java:openejb/Resource/My DataSource");
+        try {
+            ds = (DataSource) jndiContext.lookup("java:openejb/Resource/My DataSource");
+        } catch (NamingException e) {
+            ds = (DataSource) jndiContext.lookup("java:openejb/Resource/Default JDBC Database");
+        }
     }
 
     protected static void dumpTable(DataSource ds, String table) throws SQLException {



Mime
View raw message