You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2005/07/23 05:14:19 UTC

svn commit: r224435 - in /geronimo/trunk/modules: common/src/java/org/apache/geronimo/common/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ naming-builder/src/java/org/apache/geronimo/naming/deployment/

Author: ammulder
Date: Fri Jul 22 20:14:11 2005
New Revision: 224435

URL: http://svn.apache.org/viewcvs?rev=224435&view=rev
Log:
More meaningful exceptions when resource references can't be mapped.
This plumbing could probably be used elsewhere.

Added:
    geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java   (with props)
Modified:
    geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedEJBRefException.java
    geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java
    geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java

Modified: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedEJBRefException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedEJBRefException.java?rev=224435&r1=224434&r2=224435&view=diff
==============================================================================
--- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedEJBRefException.java (original)
+++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedEJBRefException.java Fri Jul 22 20:14:11 2005
@@ -17,6 +17,8 @@
 package org.apache.geronimo.common;
 
 /**
+ * A problem with an EJB reference
+ *
  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
  */
 public class UnresolvedEJBRefException extends DeploymentException {

Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java?rev=224435&view=auto
==============================================================================
--- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java (added)
+++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java Fri Jul 22 20:14:11 2005
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.common;
+
+/**
+ * A problem with a reference of some kind (most often a resource reference).
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public class UnresolvedReferenceException extends DeploymentException {
+    private String resourceType;
+    private boolean multiple;
+    private String nameQuery;
+
+    public UnresolvedReferenceException(String resourceType, boolean multiple, String nameQuery) {
+        this.resourceType = resourceType;
+        this.multiple = multiple;
+        this.nameQuery = nameQuery;
+    }
+
+    public String getResourceType() {
+        return resourceType;
+    }
+
+    public boolean isMultiple() {
+        return multiple;
+    }
+
+    public String getNameQuery() {
+        return nameQuery;
+    }
+
+    public String getMessage() {
+        return (multiple ? "Ambiguous " : "Unknown ") + resourceType + " reference (query=" + nameQuery + ")";
+    }
+}

Propchange: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/UnresolvedReferenceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java?rev=224435&r1=224434&r2=224435&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java (original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java Fri Jul 22 20:14:11 2005
@@ -31,6 +31,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.UnknownEJBRefException;
 import org.apache.geronimo.common.UnresolvedEJBRefException;
+import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
@@ -354,7 +355,7 @@
     private ObjectName locateUniqueName(ObjectName query, String type) throws DeploymentException {
         Set names = kernel.listGBeans(query);
         if (names.size() != 1) {
-            throw new DeploymentException("Unknown or ambiguous " + type + " name query: " + query + " match count: " + names.size());
+            throw new UnresolvedReferenceException(type, names.size() > 1, query.toString());
         }
         return (ObjectName) names.iterator().next();
     }

Modified: geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?rev=224435&r1=224434&r2=224435&view=diff
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java (original)
+++ geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java Fri Jul 22 20:14:11 2005
@@ -36,6 +36,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
@@ -195,10 +196,14 @@
                 } else {
                     j2eeType = NameFactory.JCA_MANAGED_CONNECTION_FACTORY;
                 }
-                String containerId = getResourceContainerId(name, j2eeType, uri, gerResourceRef, earContext);
+                try {
+                    String containerId = getResourceContainerId(name, j2eeType, uri, gerResourceRef, earContext);
 
-                ref = refContext.getConnectionFactoryRef(containerId, iface);
-                builder.bind(name, ref);
+                    ref = refContext.getConnectionFactoryRef(containerId, iface);
+                    builder.bind(name, ref);
+                } catch (UnresolvedReferenceException e) {
+                    throw new DeploymentException("Unable to resolve resource reference '"+name+"' ("+(e.isMultiple() ? "found multiple matching resources" : "no matching resources found")+")");
+                }
             }
         }
 
@@ -249,10 +254,14 @@
                 throw new DeploymentException("could not load class " + type, e);
             }
             GerResourceEnvRefType gerResourceEnvRef = (GerResourceEnvRefType) refMap.get(name);
-            String containerId = getAdminObjectContainerId(name, uri, gerResourceEnvRef, earContext);
-            Reference ref = earContext.getRefContext().getAdminObjectRef(containerId, iface);
+            try {
+                String containerId = getAdminObjectContainerId(name, uri, gerResourceEnvRef, earContext);
+                Reference ref = earContext.getRefContext().getAdminObjectRef(containerId, iface);
 
-            builder.bind(name, ref);
+                builder.bind(name, ref);
+            } catch (UnresolvedReferenceException e) {
+                throw new DeploymentException("Unable to resolve resource env reference '"+name+"' ("+(e.isMultiple() ? "found multiple matching resources" : "no matching resources found")+")");
+            }
         }
     }