You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by nt...@apache.org on 2008/04/08 20:28:14 UTC
svn commit: r646022 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl:
LifecycleManagerImpl.java VMShutdownHook.java
Author: nthaker
Date: Tue Apr 8 11:28:13 2008
New Revision: 646022
URL: http://svn.apache.org/viewvc?rev=646022&view=rev
Log:
Adding check to make sure we dont register VMShutdownHook more than once with the Runtime object.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/VMShutdownHook.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java?rev=646022&r1=646021&r2=646022&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/LifecycleManagerImpl.java Tue Apr 8 11:28:13 2008
@@ -156,7 +156,10 @@
hook = (VMShutdownHook)AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws SecurityException, IllegalStateException, IllegalArgumentException {
VMShutdownHook hook = VMShutdownHook.hook();
- Runtime.getRuntime().addShutdownHook(hook);
+ if(!hook.isRegistered()){
+ Runtime.getRuntime().addShutdownHook(hook);
+ hook.setRegistered(true);
+ }
return hook;
}
});
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/VMShutdownHook.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/VMShutdownHook.java?rev=646022&r1=646021&r2=646022&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/VMShutdownHook.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/lifecycle/impl/VMShutdownHook.java Tue Apr 8 11:28:13 2008
@@ -36,11 +36,18 @@
private static final Log log = LogFactory.getLog(VMShutdownHook.class);
private static VMShutdownHook instance = null;
private static Set files = Collections.synchronizedSet(new HashSet());
+ private boolean isRegistered = false;
static VMShutdownHook hook() {
- if (instance == null)
- instance = new VMShutdownHook();
-
+ if (instance == null){
+ if(log.isDebugEnabled()){
+ log.debug("creating VMShutdownHook");
+ }
+ instance = new VMShutdownHook();
+ }
+ if(log.isDebugEnabled()){
+ log.debug("returning VMShutdownHook instance");
+ }
return instance;
}
@@ -59,7 +66,7 @@
public void run() {
if(log.isDebugEnabled()){
log.debug("JVM running VM Shutdown Hook");
- }
+ }
Iterator iter = files.iterator();
while(iter.hasNext()){
File file = (File)iter.next();
@@ -67,10 +74,24 @@
log.debug("Deleting File from Shutdown Hook Collection"+file.getAbsolutePath());
}
file.delete();
+ }
+ if(log.isDebugEnabled()){
+ log.debug("JVM Done running VM Shutdown Hook");
}
+ }
+ public boolean isRegistered() {
if(log.isDebugEnabled()){
- log.debug("JVM Done running VM Shutdown Hook");
+ if(!isRegistered){
+ log.debug("hook isRegistered= false");
+ }else{
+ log.debug("hook isRegistered= true");
+ }
}
+ return isRegistered;
+ }
+
+ public void setRegistered(boolean isRegistered) {
+ this.isRegistered = isRegistered;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org