You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ke...@apache.org on 2007/05/24 17:24:18 UTC
svn commit: r541321 - in
/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic:
Assembler.java JndiBuilder.java
Author: kevan
Date: Thu May 24 08:24:17 2007
New Revision: 541321
URL: http://svn.apache.org/viewvc?view=rev&rev=541321
Log:
Make sure JNDI bindings are properly unbound. Otherwise, we leak Object references and ClassLoaders
Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?view=diff&rev=541321&r1=541320&r2=541321
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Thu May 24 08:24:17 2007
@@ -539,12 +539,7 @@
JndiBuilder.Bindings bindings = deployment.get(JndiBuilder.Bindings.class);
for (String name : bindings.getBindings()) {
try {
- globalContext.unbind("/openejb/ejb/" + name);
- try {
- globalContext.lookup("openejb/ejb/" + name);
- throw new OpenEJBException("Unbind failed: " + name);
- } catch (NamingException goodAndExpected) {
- }
+ globalContext.unbind(name);
} catch (Throwable t) {
undeployException.getCauses().add(new Exception("bean: " + deploymentID + ": " + t.getMessage(), t));
}
Modified: incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?view=diff&rev=541321&r1=541320&r2=541321
==============================================================================
--- incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java (original)
+++ incubator/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java Thu May 24 08:24:17 2007
@@ -186,12 +186,13 @@
try {
Class homeInterface = deployment.getHomeInterface();
if (homeInterface != null) {
- String name = strategy.getName(deployment, deploymentInfo.getRemoteInterface(), JndiNameStrategy.Interface.REMOTE_HOME);
- bindings.add(name);
+ String name = "openejb/ejb/" + strategy.getName(deployment, deploymentInfo.getRemoteInterface(), JndiNameStrategy.Interface.REMOTE_HOME);
ObjectReference ref = new ObjectReference(deployment.getEJBHome());
- context.bind("openejb/ejb/" + name, ref);
- name = deployment.getDeploymentID() + "/" + deployment.getRemoteInterface().getName();
- context.bind("openejb/Deployment/" + name, ref);
+ context.bind(name, ref);
+ bindings.add(name);
+ name = "openejb/Deployment/" + deployment.getDeploymentID() + "/" + deployment.getRemoteInterface().getName();
+ context.bind(name, ref);
+ bindings.add(name);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind home interface for deployment " + id, e);
@@ -200,11 +201,13 @@
try {
Class localHomeInterface = deployment.getLocalHomeInterface();
if (localHomeInterface != null) {
- String name = strategy.getName(deployment, deploymentInfo.getLocalInterface(), JndiNameStrategy.Interface.LOCAL_HOME);
- bindings.add(name);
+ String name = "openejb/ejb/" + strategy.getName(deployment, deploymentInfo.getLocalInterface(), JndiNameStrategy.Interface.LOCAL_HOME);
ObjectReference ref = new ObjectReference(deployment.getEJBLocalHome());
- context.bind("openejb/ejb/" + name, ref);
- context.bind("openejb/Deployment/" + deployment.getDeploymentID() + "/" + deployment.getLocalInterface().getName(), ref);
+ context.bind(name, ref);
+ bindings.add(name);
+ name = "openejb/Deployment/" + deployment.getDeploymentID() + "/" + deployment.getLocalInterface().getName();
+ context.bind(name, ref);
+ bindings.add(name);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind local interface for deployment " + id, e);
@@ -213,18 +216,21 @@
try {
Class businessLocalInterface = deployment.getBusinessLocalInterface();
if (businessLocalInterface != null) {
- String name = strategy.getName(deployment, businessLocalInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
+ String name = "openejb/ejb/" + strategy.getName(deployment, businessLocalInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
DeploymentInfo.BusinessLocalHome businessLocalHome = deployment.getBusinessLocalHome();
+ context.bind(name, new BusinessLocalReference(businessLocalHome));
bindings.add(name);
- context.bind("openejb/ejb/" + name, new BusinessLocalReference(businessLocalHome));
for (Class interfce : deployment.getBusinessLocalInterfaces()) {
DeploymentInfo.BusinessLocalHome home = deployment.getBusinessLocalHome(asList(interfce));
BusinessLocalReference ref = new BusinessLocalReference(home);
- context.bind("openejb/Deployment/" + deployment.getDeploymentID() + "/" + interfce.getName(), ref);
+ name = "openejb/Deployment/" + deployment.getDeploymentID() + "/" + interfce.getName();
+ context.bind(name, ref);
+ bindings.add(name);
try {
- name = strategy.getName(deployment, interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL);
- context.bind("openejb/ejb/" + name, ref);
+ name = "openejb/ejb/" + strategy.getName(deployment, interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL);
+ context.bind(name, ref);
+ bindings.add(name);
} catch (NamingException dontCareJustYet) {
}
}
@@ -236,20 +242,23 @@
try {
Class businessRemoteInterface = deployment.getBusinessRemoteInterface();
if (businessRemoteInterface != null) {
- String name = strategy.getName(deployment, businessRemoteInterface, JndiNameStrategy.Interface.BUSINESS_REMOTE);
+ String name = "openejb/ejb/" + strategy.getName(deployment, businessRemoteInterface, JndiNameStrategy.Interface.BUSINESS_REMOTE);
DeploymentInfo.BusinessRemoteHome businessRemoteHome = deployment.getBusinessRemoteHome();
- bindings.add(name);
BusinessRemoteReference ref = new BusinessRemoteReference(businessRemoteHome);
- context.bind("openejb/ejb/" + name, ref);
+ context.bind(name, ref);
+ bindings.add(name);
for (Class interfce : deployment.getBusinessRemoteInterfaces()) {
DeploymentInfo.BusinessRemoteHome home = deployment.getBusinessRemoteHome(asList(interfce));
ref = new BusinessRemoteReference(home);
- context.bind("openejb/Deployment/" + deployment.getDeploymentID() + "/" + interfce.getName(), ref);
+ name = "openejb/Deployment/" + deployment.getDeploymentID() + "/" + interfce.getName();
+ context.bind(name, ref);
+ bindings.add(name);
try {
- name = strategy.getName(deployment, interfce, JndiNameStrategy.Interface.BUSINESS_REMOTE);
- context.bind("openejb/ejb/" + name, ref);
+ name = "openejb/ejb/" + strategy.getName(deployment, interfce, JndiNameStrategy.Interface.BUSINESS_REMOTE);
+ context.bind(name, ref);
+ bindings.add(name);
} catch (NamingException dontCareJustYet) {
}
}
@@ -260,14 +269,14 @@
try {
if (MessageListener.class.equals(deployment.getMdbInterface())) {
- String name = deployment.getDeploymentID().toString();
+ String name = "openejb/ejb/" + deployment.getDeploymentID().toString();
String destinationId = deployment.getDestinationId();
String jndiName = "java:openejb/Resource/" + destinationId;
Reference reference = new IntraVmJndiReference(jndiName);
+ context.bind(name, reference);
bindings.add(name);
- context.bind("openejb/ejb/" + name, reference);
}
} catch (NamingException e) {
throw new RuntimeException("Unable to bind mdb destination in jndi.", e);