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:07 UTC
[1/3] tomee git commit: Don't initialize uninitialized resources when
destroying the application
Repository: tomee
Updated Branches:
refs/heads/master 1a0395118 -> ceaec93f9
Don't initialize uninitialized resources when destroying the application
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/268914bb
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/268914bb
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/268914bb
Branch: refs/heads/master
Commit: 268914bbe702ee8707831330c7ee0111490b5b50
Parents: 10d001e
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Fri Feb 5 13:45:49 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Feb 8 12:21:34 2016 +0000
----------------------------------------------------------------------
.../openejb/assembler/classic/Assembler.java | 44 ++++++++++++++++++--
1 file changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/268914bb/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 7546a33..10ec3fb 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
@@ -1245,7 +1245,8 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
}
}
} catch (final Exception e) {
- logger.fatal("Error calling @PostConstruct method on " + resourceInfo.id);
+ logger.fatal("Error calling PostConstruct method on " + resourceInfo.id);
+ logger.fatal("Resource " + resourceInfo.id + " could not be initialized. Application will be undeployed.");
throw new OpenEJBException(e);
}
}
@@ -2353,8 +2354,45 @@ 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 {
- final Object object = globalContext.lookup(name);
- 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);
+
+ // 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;
if (object == null) { // should it be possible?
clazz = "?";
} else {
[3/3] tomee git commit: Merge remote-tracking branch 'apache/master'
Posted by jg...@apache.org.
Merge remote-tracking branch 'apache/master'
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/ceaec93f
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/ceaec93f
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/ceaec93f
Branch: refs/heads/master
Commit: ceaec93f9a1eee80369018c4a3ea071722c8563a
Parents: 5306cd1 1a03951
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Mon Feb 8 13:34:53 2016 +0000
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Mon Feb 8 13:34:53 2016 +0000
----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
[2/3] tomee git commit: Refactor + spacing
Posted by jg...@apache.org.
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 {