From: markt Date: Sat, 1 May 2010 17:44:26 +0000 (+0000) Subject: Remove the controller - MBean registration will always happen in init()/destroy(... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9e3e06557c555930a0d634c137093489e3768020;p=tomcat7.0 Remove the controller - MBean registration will always happen in init()/destroy() after Lifecycle refactoring Fix a handful of Eclipse/FindBugs warnings git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@940089 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/loader/LocalStrings.properties b/java/org/apache/catalina/loader/LocalStrings.properties index 4dcf73bfc..3d02dbe32 100644 --- a/java/org/apache/catalina/loader/LocalStrings.properties +++ b/java/org/apache/catalina/loader/LocalStrings.properties @@ -65,4 +65,5 @@ webappLoader.starting=Starting this Loader webappLoader.stopping=Stopping this Loader webappLoader.failModifiedCheck=Error tracking modifications webappLoader.copyFailure=Failed to copy resources +webappLoader.mkdirFailure=Failed to create destination directory to copy resources webappLoader.namingFailure=Failed to access resource {0} diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java index 7b798c5ba..97cb58f56 100644 --- a/java/org/apache/catalina/loader/WebappLoader.java +++ b/java/org/apache/catalina/loader/WebappLoader.java @@ -271,8 +271,8 @@ public class WebappLoader extends LifecycleBase boolean oldDelegate = this.delegate; this.delegate = delegate; - support.firePropertyChange("delegate", new Boolean(oldDelegate), - new Boolean(this.delegate)); + support.firePropertyChange("delegate", Boolean.valueOf(oldDelegate), + Boolean.valueOf(this.delegate)); } @@ -332,8 +332,8 @@ public class WebappLoader extends LifecycleBase boolean oldReloadable = this.reloadable; this.reloadable = reloadable; support.firePropertyChange("reloadable", - new Boolean(oldReloadable), - new Boolean(this.reloadable)); + Boolean.valueOf(oldReloadable), + Boolean.valueOf(this.reloadable)); } @@ -542,7 +542,6 @@ public class WebappLoader extends LifecycleBase oname=new ObjectName(ctx.getEngineName() + ":type=Loader,path=" + path + ",host=" + ctx.getParent().getName()); Registry.getRegistry(null, null).registerComponent(this, oname, null); - controller=oname; } catch (Exception e) { log.error("Error registering loader", e ); } @@ -558,11 +557,8 @@ public class WebappLoader extends LifecycleBase @Override protected void destroyInternal() { - if( controller==oname ) { - // Self-registration, undo it - Registry.getRegistry(null, null).unregisterComponent(oname); - oname = null; - } + Registry.getRegistry(null, null).unregisterComponent(oname); + oname = null; } /** @@ -813,6 +809,7 @@ public class WebappLoader extends LifecycleBase String path = libDir.getCanonicalPath(); classLoader.addPermission(path); } catch (IOException e) { + // Ignore } } @@ -825,6 +822,7 @@ public class WebappLoader extends LifecycleBase String path = libDir.getCanonicalPath(); classLoader.addPermission(path); } catch (IOException e) { + // Ignore } } if (classesURL != null) { @@ -833,6 +831,7 @@ public class WebappLoader extends LifecycleBase String path = classesDir.getCanonicalPath(); classLoader.addPermission(path); } catch (IOException e) { + // Ignore } } } @@ -840,6 +839,7 @@ public class WebappLoader extends LifecycleBase } } catch (MalformedURLException e) { + // Ignore } } @@ -903,7 +903,9 @@ public class WebappLoader extends LifecycleBase } else { classRepository = new File(workDir, classesPath); - classRepository.mkdirs(); + if (!classRepository.mkdirs()) + throw new IOException( + sm.getString("webappLoader.mkdirFailure")); if (!copyDir(classes, classRepository)) { throw new IOException( sm.getString("webappLoader.copyFailure")); @@ -951,7 +953,9 @@ public class WebappLoader extends LifecycleBase } else { copyJars = true; destDir = new File(workDir, libPath); - destDir.mkdirs(); + if (!destDir.mkdirs()) + throw new IOException( + sm.getString("webappLoader.mkdirFailure")); } // Looking up directory /WEB-INF/lib in the context @@ -1056,7 +1060,6 @@ public class WebappLoader extends LifecycleBase String cp=getClasspath( loader ); if( cp==null ) { log.info( "Unknown loader " + loader + " " + loader.getClass()); - break; } else { if (n > 0) classpath.append(File.pathSeparator); @@ -1141,7 +1144,8 @@ public class WebappLoader extends LifecycleBase if (!copy((InputStream) object, os)) return false; } else if (object instanceof DirContext) { - currentFile.mkdir(); + if (!currentFile.mkdir()) + return false; if (!copyDir((DirContext) object, currentFile)) return false; } @@ -1187,7 +1191,6 @@ public class WebappLoader extends LifecycleBase org.apache.juli.logging.LogFactory.getLog( WebappLoader.class ); private ObjectName oname; - private ObjectName controller; public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { @@ -1196,20 +1199,14 @@ public class WebappLoader extends LifecycleBase } public void postRegister(Boolean registrationDone) { + // NOOP } public void preDeregister() throws Exception { + // NOOP } public void postDeregister() { + // NOOP } - - public ObjectName getController() { - return controller; - } - - public void setController(ObjectName controller) { - this.controller = controller; - } - }