You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2016/02/08 14:35:08 UTC

[2/3] tomee git commit: Refactor + spacing

Refactor + spacing


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5306cd11
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5306cd11
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5306cd11

Branch: refs/heads/master
Commit: 5306cd11d6ae1786b51c6d78d8e444cb524cece2
Parents: 268914b
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Feb 8 11:04:40 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Feb 8 12:21:42 2016 +0000

----------------------------------------------------------------------
 .../openejb/assembler/classic/Assembler.java    | 70 +++++++++-----------
 1 file changed, 31 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/5306cd11/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 10ec3fb..01b0d00 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1952,6 +1952,10 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
             logger.debug("Not processing resource on destroy: " + className);
         }
 
+        removeResourceInfo(name);
+    }
+
+    public void removeResourceInfo(final String name) {
         try {
             //Ensure ResourceInfo for this resource is removed
             final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
@@ -2354,45 +2358,33 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
     }
 
     private void destroyLookedUpResource(final Context globalContext, final String id, final String name) throws NamingException {
-    	
-    	Object object = null;
-    	
-    	try {
-			object = globalContext.lookup(name);
-		} catch (NamingException e) {
-			// if we catch a NamingException, check to see if the resource is a LaztObjectReference that has not been initialized correctly
-			final String ctx = name.substring(0, name.lastIndexOf("/"));
-			final String objName = name.substring(ctx.length() + 1);
-			final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
-			while (bindings.hasMoreElements()) {
-				final Binding binding = bindings.nextElement();
-				if (!binding.getName().equals(objName)) continue;
-				if (!LazyObjectReference.class.isInstance(binding.getObject())) continue;
-				
-				final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
-				if (! ref.isInitialized()) {
-					globalContext.unbind(name);
-
-					// TODO: refactor this method out
-					//Ensure ResourceInfo for this resource is removed
-		            final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
-		            final Iterator<ResourceInfo> iterator = configuration.facilities.resources.iterator();
-		            while (iterator.hasNext()) {
-		                final ResourceInfo info = iterator.next();
-		                if (name.equals(OPENEJB_RESOURCE_JNDI_PREFIX + info.id)) {
-		                    iterator.remove();
-		                    break;
-		                }
-		            }
-					
-					return;
-				}
-			}
-			
-			throw e;
-		}
-    	
-		final String clazz;
+        
+        Object object = null;
+        
+        try {
+            object = globalContext.lookup(name);
+        } catch (NamingException e) {
+            // if we catch a NamingException, check to see if the resource is a LaztObjectReference that has not been initialized correctly
+            final String ctx = name.substring(0, name.lastIndexOf("/"));
+            final String objName = name.substring(ctx.length() + 1);
+            final NamingEnumeration<Binding> bindings = globalContext.listBindings(ctx);
+            while (bindings.hasMoreElements()) {
+                final Binding binding = bindings.nextElement();
+                if (!binding.getName().equals(objName)) continue;
+                if (!LazyObjectReference.class.isInstance(binding.getObject())) continue;
+                
+                final LazyObjectReference<?> ref = LazyObjectReference.class.cast(binding.getObject());
+                if (! ref.isInitialized()) {
+                    globalContext.unbind(name);
+                    removeResourceInfo(name);
+                    return;
+                }
+            }
+            
+            throw e;
+        }
+        
+        final String clazz;
         if (object == null) { // should it be possible?
             clazz = "?";
         } else {