Author: remy.maucherat(a)jboss.com
Date: 2009-05-25 10:36:15 -0400 (Mon, 25 May 2009)
New Revision: 1063
Removed:
trunk/java/org/apache/catalina/ServerFactory.java
trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java
trunk/java/org/apache/catalina/mbeans/StandardEngineMBean.java
trunk/java/org/apache/catalina/mbeans/StandardHostMBean.java
trunk/java/org/apache/catalina/mbeans/StandardServerMBean.java
trunk/java/org/apache/catalina/mbeans/StandardServiceMBean.java
Modified:
trunk/PATCHES.txt
trunk/build.properties.default
trunk/java/org/apache/catalina/connector/Connector.java
trunk/java/org/apache/catalina/connector/MapperListener.java
trunk/java/org/apache/catalina/core/StandardServer.java
trunk/java/org/apache/catalina/core/StandardService.java
trunk/java/org/apache/catalina/deploy/NamingResources.java
trunk/java/org/apache/catalina/manager/ManagerServlet.java
trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
trunk/java/org/apache/catalina/realm/DataSourceRealm.java
trunk/java/org/apache/catalina/realm/RealmBase.java
trunk/java/org/apache/catalina/startup/Tomcat.java
trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
trunk/java/org/apache/coyote/http11/Http11Processor.java
trunk/java/org/apache/tomcat/util/res/StringManager.java
trunk/webapps/docs/changelog.xml
Log:
- Remove ServerFactory.
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2009-05-25 14:32:57 UTC (rev 1062)
+++ trunk/PATCHES.txt 2009-05-25 14:36:15 UTC (rev 1063)
@@ -62,8 +62,12 @@
763654
Specific hack to address some error condition in HTTP method
-765727
-ETag should be identical regardless of how the entity is encoded, this patch
"fixes" apparently broken proxies
+765727 (reverted)
+ETag should normally be different if the content encoding changes; content-encoding is
used because
+transfer-encoding does not work with IE, and is not normally appropriate for transparent
compression
-769979
-Does not hurt to unregister properly, but a JMX cleanup is redundant, so will see about
it later
+770809
+Fix 47080: NPE in RealmBase.findSecurityConstraints when uri is null (normally useless, a
redirection should always occur)
+
+770876
+Windows 64 bit stuff ... Zzzzz
Modified: trunk/build.properties.default
===================================================================
--- trunk/build.properties.default 2009-05-25 14:32:57 UTC (rev 1062)
+++ trunk/build.properties.default 2009-05-25 14:36:15 UTC (rev 1063)
@@ -59,12 +59,12 @@
commons-collections-src.loc=${base-commons.loc}/collections/source/commons-collections-3.2.1-src.tar.gz
# ----- NSIS, version 2.0 or later -----
-nsis.home=${base.path}/nsis-2.43
+nsis.home=${base.path}/nsis-2.44
nsis.exe=${nsis.home}/makensis.exe
nsis.installoptions.dll=${nsis.home}/Plugins/InstallOptions.dll
nsis.nsexec.dll=${nsis.home}/Plugins/nsExec.dll
nsis.nsisdl.dll=${nsis.home}/Plugins/NSISdl.dll
-nsis.loc=${base-sf.loc}/nsis/nsis-2.43.zip
+nsis.loc=${base-sf.loc}/nsis/nsis-2.44.zip
# ----- JBoss Native, version 2.0 or later -----
jbossnative.home=${base.path}/jboss-native-2.0.6
Deleted: trunk/java/org/apache/catalina/ServerFactory.java
===================================================================
--- trunk/java/org/apache/catalina/ServerFactory.java 2009-05-25 14:32:57 UTC (rev 1062)
+++ trunk/java/org/apache/catalina/ServerFactory.java 2009-05-25 14:36:15 UTC (rev 1063)
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.catalina;
-
-import org.apache.catalina.core.StandardServer;
-
-
-/**
- * <p><strong>ServerFactory</strong> allows the registration of the
- * (singleton) <code>Server</code> instance for this JVM, so that it
- * can be accessed independently of any existing reference to the
- * component hierarchy. This is important for administration tools
- * that are built around the internal component implementation classes.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ServerFactory {
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The singleton <code>Server</code> instance for this JVM.
- */
- private static Server server = null;
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return the singleton <code>Server</code> instance for this JVM.
- */
- public static Server getServer() {
- if( server==null )
- server=new StandardServer();
- return (server);
-
- }
-
-
- /**
- * Set the singleton <code>Server</code> instance for this JVM. This
- * method must <strong>only</strong> be called from a constructor of
- * the (singleton) <code>Server</code> instance that is created for
- * this execution of Catalina.
- *
- * @param theServer The new singleton instance
- */
- public static void setServer(Server theServer) {
-
- if (server == null)
- server = theServer;
-
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/connector/Connector.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Connector.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/connector/Connector.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -256,7 +256,7 @@
/**
* Mapper listener.
*/
- protected MapperListener mapperListener = new MapperListener(mapper);
+ protected MapperListener mapperListener = new MapperListener(mapper, this);
/**
Modified: trunk/java/org/apache/catalina/connector/MapperListener.java
===================================================================
--- trunk/java/org/apache/catalina/connector/MapperListener.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/connector/MapperListener.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -29,7 +29,6 @@
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
import org.apache.catalina.Host;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.core.StandardContext;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.mapper.Mapper;
@@ -58,6 +57,11 @@
protected Mapper mapper = null;
/**
+ * Associated connector
+ */
+ protected Connector connector = null;
+
+ /**
* MBean server.
*/
protected MBeanServer mBeanServer = null;
@@ -71,7 +75,6 @@
// It should be null - and fail if not set
private String domain="*";
- private String engine="*";
// ----------------------------------------------------------- Constructors
@@ -79,8 +82,9 @@
/**
* Create mapper listener.
*/
- public MapperListener(Mapper mapper) {
+ public MapperListener(Mapper mapper, Connector connector) {
this.mapper = mapper;
+ this.connector = connector;
}
@@ -94,14 +98,6 @@
this.domain = domain;
}
- public String getEngine() {
- return engine;
- }
-
- public void setEngine(String engine) {
- this.engine = engine;
- }
-
/**
* Initialize associated mapper.
*/
@@ -322,29 +318,32 @@
throws Exception {
String name=objectName.getKeyProperty("host");
if( name != null ) {
- Host host = (Host) ServerFactory.getServer().findService(
- domain).getContainer().findChild(name);
+ Host host = (Host) connector.getService().getContainer().findChild(name);
String[] aliases = host.findAliases();
mapper.addHost(name, aliases, objectName);
host.addContainerListener(this);
if(log.isDebugEnabled())
log.debug(sm.getString
("mapperListener.registerHost", name, domain));
-
}
}
- /**
- * Unregister host.
- */
private void unregisterHost(ObjectName objectName)
- throws Exception {
+ throws Exception {
String name=objectName.getKeyProperty("host");
- mapper.removeHost(name);
- if(log.isDebugEnabled())
- log.debug(sm.getString
- ("mapperListener.unregisterHost", name, domain));
+ if( name != null ) {
+ Host host =
+ (Host) connector.getService().getContainer().findChild(name);
+
+ mapper.removeHost(name);
+ if (host != null) {
+ host.removeContainerListener(this);
+ }
+ if(log.isDebugEnabled())
+ log.debug(sm.getString
+ ("mapperListener.unregisterHost", name, domain));
+ }
}
Modified: trunk/java/org/apache/catalina/core/StandardServer.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardServer.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/core/StandardServer.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -38,7 +38,6 @@
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.util.LifecycleSupport;
@@ -63,16 +62,6 @@
private static Logger log = Logger.getLogger(StandardServer.class);
- // -------------------------------------------------------------- Constants
-
-
- /**
- * ServerLifecycleListener classname.
- */
- private static String SERVER_LISTENER_CLASS_NAME =
- "org.apache.catalina.mbeans.ServerLifecycleListener";
-
-
// ------------------------------------------------------------ Constructor
@@ -81,9 +70,6 @@
*/
public StandardServer() {
- super();
- ServerFactory.setServer(this);
-
globalNamingResources = new NamingResources();
globalNamingResources.setContainer(this);
Modified: trunk/java/org/apache/catalina/core/StandardService.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardService.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/core/StandardService.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -21,25 +21,25 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+
import org.apache.catalina.Container;
import org.apache.catalina.Engine;
+import org.apache.catalina.Executor;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
import org.apache.catalina.Service;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.modeler.Registry;
-import java.util.ArrayList;
-import org.apache.catalina.Executor;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
@@ -670,10 +670,9 @@
}
if( server==null ) {
- // Register with the server
- // HACK: ServerFactory should be removed...
-
- ServerFactory.getServer().addService(this);
+ // If no server was defined - create one
+ server = new StandardServer();
+ server.addService(this);
}
Modified: trunk/java/org/apache/catalina/deploy/NamingResources.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/NamingResources.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/deploy/NamingResources.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -21,11 +21,15 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Hashtable;
-import java.io.Serializable;
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Server;
+
/**
* Holds and manages the naming resources defined in the J2EE Enterprise
* Naming Context and their associated JNDI context.
@@ -191,9 +195,26 @@
public void addEnvironment(ContextEnvironment environment) {
if (entries.containsKey(environment.getName())) {
- if (findEnvironment(environment.getName()).getOverride()) {
- removeEnvironment(environment.getName());
+ ContextEnvironment ce = findEnvironment(environment.getName());
+ ContextResourceLink rl = findResourceLink(environment.getName());
+ if (ce != null) {
+ if (ce.getOverride()) {
+ removeEnvironment(environment.getName());
+ } else {
+ return;
+ }
+ } else if (rl != null) {
+ // Link. Need to look at the global resources
+ NamingResources global = getServer().getGlobalNamingResources();
+ if (global.findEnvironment(rl.getGlobal()) != null) {
+ if (global.findEnvironment(rl.getGlobal()).getOverride()) {
+ removeResourceLink(environment.getName());
+ } else {
+ return;
+ }
+ }
} else {
+ // It exists but it isn't an env or a res link...
return;
}
}
@@ -208,6 +229,20 @@
}
+ // Container should be an instance of Server or Context. If it is anything
+ // else, return null which will trigger a NPE.
+ private Server getServer() {
+ if (container instanceof Server) {
+ return (Server) container;
+ }
+ if (container instanceof Context) {
+ // Could do this in one go. Lots of casts so split out for clarity
+ Engine engine =
+ (Engine) ((Context) container).getParent().getParent();
+ return engine.getService().getServer();
+ }
+ return null;
+ }
/**
* Add a local EJB resource reference for this web application.
Modified: trunk/java/org/apache/catalina/manager/ManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/ManagerServlet.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/manager/ManagerServlet.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -46,7 +46,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.Manager;
import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.Session;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.StandardServer;
@@ -462,7 +461,7 @@
}
// Acquire global JNDI resources if available
- Server server = ServerFactory.getServer();
+ Server server = ((Engine) host.getParent()).getService().getServer();
if ((server != null) && (server instanceof StandardServer)) {
global = ((StandardServer) server).getGlobalNamingContext();
}
@@ -521,7 +520,7 @@
*/
protected synchronized void save(PrintWriter writer, String path) {
- Server server = ServerFactory.getServer();
+ Server server = ((Engine) host.getParent()).getService().getServer();
if (!(server instanceof StandardServer)) {
writer.println(sm.getString("managerServlet.saveFail", server));
Modified: trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/MBeanFactory.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/mbeans/MBeanFactory.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -18,7 +18,6 @@
package org.apache.catalina.mbeans;
import java.io.File;
-import java.util.Vector;
import javax.management.MBeanException;
import javax.management.MBeanServer;
@@ -29,7 +28,6 @@
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.apache.catalina.Valve;
import org.apache.catalina.authenticator.SingleSignOn;
@@ -102,12 +100,22 @@
// ------------------------------------------------------------- Attributes
+ /**
+ * The container (Server/Service) for which this factory was created.
+ */
+ private Object container;
-
// ------------------------------------------------------------- Operations
+ /**
+ * Set the container that this factory was created for.
+ */
+ public void setContainer(Object container) {
+ this.container = container;
+ }
+
/**
* Return the managed bean definition for the specified bean type
*
@@ -206,18 +214,25 @@
private Service getService(ObjectName oname) throws Exception {
-
- String domain = oname.getDomain();
- Server server = ServerFactory.getServer();
- Service[] services = server.findServices();
+
+ if (container instanceof Service) {
+ // Don't bother checking the domain - this is the only option
+ return (Service) container;
+ }
+
StandardService service = null;
- for (int i = 0; i < services.length; i++) {
- service = (StandardService) services[i];
- if (domain.equals(service.getObjectName().getDomain())) {
- break;
+ String domain = oname.getDomain();
+ if (container instanceof Server) {
+ Service[] services = ((Server)container).findServices();
+ for (int i = 0; i < services.length; i++) {
+ service = (StandardService) services[i];
+ if (domain.equals(service.getObjectName().getDomain())) {
+ break;
+ }
}
}
- if (!service.getObjectName().getDomain().equals(domain)) {
+ if (service == null ||
+ !service.getObjectName().getDomain().equals(domain)) {
throw new Exception("Service with the domain is not found");
}
return service;
@@ -645,48 +660,6 @@
}
- /**
- * Create a new StandardEngine.
- *
- * @param parent MBean Name of the associated parent component
- * @param engineName Unique name of this Engine
- * @param defaultHost Default hostname of this Engine
- * @param serviceName Unique name of this Service
- *
- * @exception Exception if an MBean cannot be created or registered
- */
-
- public Vector createStandardEngineService(String parent,
- String engineName, String defaultHost, String serviceName)
- throws Exception {
-
- // Create a new StandardService instance
- StandardService service = new StandardService();
- service.setName(serviceName);
- // Create a new StandardEngine instance
- StandardEngine engine = new StandardEngine();
- engine.setName(engineName);
- engine.setDefaultHost(defaultHost);
- // Need to set engine before adding it to server in order to set domain
- service.setContainer(engine);
- // Add the new instance to its parent component
- Server server = ServerFactory.getServer();
- server.addService(service);
- Vector onames = new Vector();
- // FIXME service & engine.getObjectName
- //ObjectName oname = engine.getObjectName();
- ObjectName oname =
- MBeanUtils.createObjectName(engineName, engine);
- onames.add(0, oname);
- //oname = service.getObjectName();
- oname =
- MBeanUtils.createObjectName(engineName, service);
- onames.add(1, oname);
- return (onames);
-
- }
-
-
/**
* Create a new StandardHost.
*
@@ -767,32 +740,6 @@
/**
- * Create a new StandardService.
- *
- * @param parent MBean Name of the associated parent component
- * @param name Unique name of this StandardService
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createStandardService(String parent, String name, String domain)
- throws Exception {
-
- // Create a new StandardService instance
- StandardService service = new StandardService();
- service.setName(name);
-
- // Add the new instance to its parent component
- Server server = ServerFactory.getServer();
- server.addService(service);
-
- // Return the corresponding MBean name
- return (service.getObjectName().toString());
-
- }
-
-
-
- /**
* Create a new Web Application Loader.
*
* @param parent MBean Name of the associated parent component
@@ -831,7 +778,6 @@
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
- Server server = ServerFactory.getServer();
Service service = getService(oname);
String port = oname.getKeyProperty("port");
//String address = oname.getKeyProperty("address");
@@ -989,27 +935,6 @@
/**
- * Remove an existing Service.
- *
- * @param name MBean Name of the component to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeService(String name) throws Exception {
-
- // Acquire a reference to the component to be removed
- ObjectName oname = new ObjectName(name);
- String serviceName = oname.getKeyProperty("serviceName");
- Server server = ServerFactory.getServer();
- Service service = server.findService(serviceName);
-
- // Remove this component from its parent component
- server.removeService(service);
-
- }
-
-
- /**
* Remove an existing Valve.
*
* @param name MBean Name of the comonent to remove
Modified: trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/MBeanUtils.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/mbeans/MBeanUtils.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -19,6 +19,7 @@
import java.util.Hashtable;
+import java.util.Set;
import javax.management.DynamicMBean;
import javax.management.MBeanException;
@@ -43,11 +44,15 @@
import org.apache.catalina.deploy.ContextResourceLink;
import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.valves.ValveBase;
+import org.apache.coyote.ProtocolHandler;
+import org.apache.coyote.ajp.AjpAprProtocol;
+import org.apache.coyote.ajp.AjpProtocol;
+import org.apache.coyote.http11.Http11AprProtocol;
+import org.apache.coyote.http11.Http11Protocol;
import org.apache.tomcat.util.IntrospectionUtils;
import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
@@ -606,31 +611,26 @@
throws MalformedObjectNameException {
ObjectName name = null;
- if (connector.getClass().getName().indexOf("CoyoteConnector") >= 0 )
{
- try {
- String address = (String)
- IntrospectionUtils.getProperty(connector, "address");
- Integer port = (Integer)
- IntrospectionUtils.getProperty(connector, "port");
- Service service = connector.getService();
- String serviceName = null;
- if (service != null)
- serviceName = service.getName();
- StringBuffer sb = new StringBuffer(domain);
- sb.append(":type=Connector");
- sb.append(",port=" + port);
- if ((address != null) && (address.length()>0)) {
- sb.append(",address=" + address);
- }
- name = new ObjectName(sb.toString());
- return (name);
- } catch (Exception e) {
- throw new MalformedObjectNameException
- ("Cannot create object name for " + connector+e);
+ try {
+ String address = (String)
+ IntrospectionUtils.getProperty(connector, "address");
+ Integer port = (Integer)
+ IntrospectionUtils.getProperty(connector, "port");
+ Service service = connector.getService();
+ String serviceName = null;
+ if (service != null)
+ serviceName = service.getName();
+ StringBuffer sb = new StringBuffer(domain);
+ sb.append(":type=Connector");
+ sb.append(",port=" + port);
+ if ((address != null) && (address.length()>0)) {
+ sb.append(",address=" + address);
}
- } else {
+ name = new ObjectName(sb.toString());
+ return (name);
+ } catch (Exception e) {
throw new MalformedObjectNameException
- ("Cannot create object name for " + connector);
+ ("Cannot create object name for " + connector+e);
}
}
@@ -1205,6 +1205,24 @@
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
+ // Unregister associated request processor
+ String worker = null;
+ ProtocolHandler handler = connector.getProtocolHandler();
+ if (handler instanceof Http11Protocol) {
+ worker = ((Http11Protocol)handler).getName();
+ } else if (handler instanceof Http11AprProtocol) {
+ worker = ((Http11AprProtocol)handler).getName();
+ } else if (handler instanceof AjpProtocol) {
+ worker = ((AjpProtocol)handler).getName();
+ } else if (handler instanceof AjpAprProtocol) {
+ worker = ((AjpAprProtocol)handler).getName();
+ }
+ ObjectName query = new ObjectName(
+ domain + ":type=RequestProcessor,worker=" + worker +
",*");
+ Set<ObjectName> results = mserver.queryNames(query, null);
+ for(ObjectName result : results) {
+ mserver.unregisterMBean(result);
+ }
}
@@ -1490,6 +1508,16 @@
if( mserver.isRegistered(oname) )
mserver.unregisterMBean(oname);
+ // Global String cache - fixed name
+ oname = new ObjectName("Catalina:type=StringCache");
+ if( mserver.isRegistered(oname) )
+ mserver.unregisterMBean(oname);
+
+ // MBean Factory - fixed name
+ oname = new ObjectName("Catalina:type=MBeanFactory");
+ if( mserver.isRegistered(oname) )
+ mserver.unregisterMBean(oname);
+
}
Modified: trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java 2009-05-25 14:32:57
UTC (rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java 2009-05-25 14:36:15
UTC (rev 1063)
@@ -20,6 +20,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+
import javax.management.MBeanException;
import org.apache.catalina.Container;
@@ -36,7 +37,6 @@
import org.apache.catalina.Manager;
import org.apache.catalina.Realm;
import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.StandardContext;
@@ -49,7 +49,6 @@
import org.apache.catalina.deploy.ContextResourceLink;
import org.apache.catalina.deploy.NamingResources;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
@@ -125,19 +124,33 @@
Lifecycle lifecycle = event.getLifecycle();
if (Lifecycle.START_EVENT.equals(event.getType())) {
- if (lifecycle instanceof Server) {
- createMBeans();
- }
+ try {
- // We are embedded.
- if( lifecycle instanceof Service ) {
- try {
+ if (lifecycle instanceof Server) {
MBeanFactory factory = new MBeanFactory();
+ factory.setContainer(lifecycle);
createMBeans(factory);
+ createMBeans((Server) lifecycle);
+ }
+
+ if( lifecycle instanceof Service ) {
+ MBeanFactory factory = new MBeanFactory();
+ factory.setContainer(lifecycle);
+ createMBeans(factory);
createMBeans((Service)lifecycle);
- } catch( Exception ex ) {
- log.error("Create mbean factory");
}
+
+ } catch (MBeanException t) {
+
+ Exception e = t.getTargetException();
+ if (e == null)
+ e = t;
+ log.error("createMBeans: MBeanException", e);
+
+ } catch (Throwable t) {
+
+ log.error("createMBeans: Throwable", t);
+
}
/*
@@ -148,7 +161,7 @@
createMBeans();
*/
- } else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
+ } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
try {
if (lifecycle instanceof Server) {
destroyMBeans((Server)lifecycle);
@@ -267,33 +280,6 @@
/**
- * Create the MBeans that correspond to every existing node of our tree.
- */
- protected void createMBeans() {
-
- try {
-
- MBeanFactory factory = new MBeanFactory();
- createMBeans(factory);
- createMBeans(ServerFactory.getServer());
-
- } catch (MBeanException t) {
-
- Exception e = t.getTargetException();
- if (e == null)
- e = t;
- log.error("createMBeans: MBeanException", e);
-
- } catch (Throwable t) {
-
- log.error("createMBeans: Throwable", t);
-
- }
-
- }
-
-
- /**
* Create the MBeans for the specified Connector and its nested components.
*
* @param connector Connector for which to create MBeans
@@ -640,10 +626,6 @@
*/
protected void createMBeans(Service service) throws Exception {
- // Create the MBean for the Service itself
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Service " + service);
- //MBeanUtils.createMBean(service);
if (service instanceof StandardService) {
((StandardService) service).addPropertyChangeListener(this);
}
@@ -676,10 +658,10 @@
protected void destroyMBeans(Connector connector, Service service)
throws Exception {
-// // deregister the MBean for the Connector itself
-// if (log.isDebugEnabled())
-// log.debug("Destroying MBean for Connector " + connector);
-// MBeanUtils.destroyMBean(connector, service);
+ // deregister the MBean for the Connector itself
+ if (log.isDebugEnabled())
+ log.debug("Destroying MBean for Connector " + connector);
+ MBeanUtils.destroyMBean(connector, service);
}
@@ -727,7 +709,7 @@
// deregister the MBean for the Context itself
if (log.isDebugEnabled())
log.debug("Destroying MBean for Context " + context);
- //MBeanUtils.destroyMBean(context);
+ MBeanUtils.destroyMBean(context);
if (context instanceof StandardContext) {
((StandardContext) context).
removePropertyChangeListener(this);
@@ -865,7 +847,7 @@
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Engine " + engine);
}
- //MBeanUtils.destroyMBean(engine);
+ MBeanUtils.destroyMBean(engine);
}
@@ -902,7 +884,7 @@
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Host " + host);
}
- //MBeanUtils.destroyMBean(host);
+ MBeanUtils.destroyMBean(host);
}
@@ -979,7 +961,7 @@
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Server " + server);
}
- //MBeanUtils.destroyMBean(server);
+ MBeanUtils.destroyMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).removePropertyChangeListener(this);
}
@@ -1000,20 +982,15 @@
// Deregister the MBeans for the associated Engine
Engine engine = (Engine) service.getContainer();
if (engine != null) {
- //destroyMBeans(engine);
+ destroyMBeans(engine);
}
-// // Deregister the MBeans for the corresponding Connectors
-// Connector connectors[] = service.findConnectors();
-// for (int j = 0; j < connectors.length; j++) {
-// destroyMBeans(connectors[j], service);
-// }
-
- // Deregister the MBean for the Service itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for Service " + service);
+ // Deregister the MBeans for the corresponding Connectors
+ Connector connectors[] = service.findConnectors();
+ for (int j = 0; j < connectors.length; j++) {
+ destroyMBeans(connectors[j], service);
}
- //MBeanUtils.destroyMBean(service);
+
if (service instanceof StandardService) {
((StandardService) service).removePropertyChangeListener(this);
}
Deleted: trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java 2009-05-25 14:32:57
UTC (rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/StandardContextMBean.java 2009-05-25 14:36:15
UTC (rev 1063)
@@ -1,358 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.catalina.mbeans;
-
-import java.util.ArrayList;
-
-import javax.management.MBeanException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-import org.apache.tomcat.util.modeler.ManagedBean;
-import org.apache.tomcat.util.modeler.Registry;
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardContext</code>
component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class StandardContextMBean extends BaseModelMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public StandardContextMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The configuration information registry for our managed beans.
- */
- protected Registry registry = MBeanUtils.createRegistry();
-
- /**
- * The <code>ManagedBean</code> information describing this MBean.
- */
- protected ManagedBean managed =
- registry.findManagedBean("StandardContext");
-
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Return the naming resources associated with this web application.
- */
- private NamingResources getNamingResources() {
-
- return ((StandardContext)this.resource).getNamingResources();
-
- }
-
- /**
- * Return the naming resources associated with this web application.
- */
- public void reload() {
-
- ((StandardContext)this.resource).reload();
-
- }
-
-
- /**
- * Return the MBean Names of the set of defined environment entries for
- * this web application
- */
- public String[] getEnvironments() {
- ContextEnvironment[] envs = getNamingResources().findEnvironments();
- ArrayList results = new ArrayList();
- for (int i = 0; i < envs.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for environment " + envs[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
-
- /**
- * Return the MBean Names of all the defined resource references for this
- * application.
- */
- public String[] getResources() {
-
- ContextResource[] resources = getNamingResources().findResources();
- ArrayList results = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for resource " +
resources[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
-
- /**
- * Return the MBean Names of all the defined resource links for this
- * application
- */
- public String[] getResourceLinks() {
-
- ContextResourceLink[] links = getNamingResources().findResourceLinks();
- ArrayList results = new ArrayList();
- for (int i = 0; i < links.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), links[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for resource " + links[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
-
- /**
- * Return the naming resources associated with this web application.
- */
- public javax.naming.directory.DirContext getStaticResources() {
-
- return ((StandardContext)this.resource).getResources();
-
- }
-
-
- /**
- * Return the naming resources associated with this web application.
- */
- public String[] getWelcomeFiles() {
-
- return ((StandardContext)this.resource).findWelcomeFiles();
-
- }
-
-
- // ------------------------------------------------------------- Operations
-
-
- /**
- * Add an environment entry for this web application.
- *
- * @param envName New environment entry name
- */
- public String addEnvironment(String envName, String type)
- throws MalformedObjectNameException {
-
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return null;
- }
- ContextEnvironment env = nresources.findEnvironment(envName);
- if (env != null) {
- throw new IllegalArgumentException
- ("Invalid environment name - already exists '" + envName +
"'");
- }
- env = new ContextEnvironment();
- env.setName(envName);
- env.setType(type);
- nresources.addEnvironment(env);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextEnvironment");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), env);
- return (oname.toString());
-
- }
-
-
- /**
- * Add a resource reference for this web application.
- *
- * @param resourceName New resource reference name
- */
- public String addResource(String resourceName, String type)
- throws MalformedObjectNameException {
-
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return null;
- }
- ContextResource resource = nresources.findResource(resourceName);
- if (resource != null) {
- throw new IllegalArgumentException
- ("Invalid resource name - already exists'" + resourceName +
"'");
- }
- resource = new ContextResource();
- resource.setName(resourceName);
- resource.setType(type);
- nresources.addResource(resource);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextResource");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resource);
- return (oname.toString());
- }
-
-
- /**
- * Add a resource link for this web application.
- *
- * @param resourceLinkName New resource link name
- */
- public String addResourceLink(String resourceLinkName, String global,
- String name, String type) throws MalformedObjectNameException {
-
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return null;
- }
- ContextResourceLink resourceLink =
- nresources.findResourceLink(resourceLinkName);
- if (resourceLink != null) {
- throw new IllegalArgumentException
- ("Invalid resource link name - already exists'" +
- resourceLinkName +
"'");
- }
- resourceLink = new ContextResourceLink();
- resourceLink.setGlobal(global);
- resourceLink.setName(resourceLinkName);
- resourceLink.setType(type);
- nresources.addResourceLink(resourceLink);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextResourceLink");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
- return (oname.toString());
- }
-
-
- /**
- * Remove any environment entry with the specified name.
- *
- * @param envName Name of the environment entry to remove
- */
- public void removeEnvironment(String envName) {
-
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return;
- }
- ContextEnvironment env = nresources.findEnvironment(envName);
- if (env == null) {
- throw new IllegalArgumentException
- ("Invalid environment name '" + envName +
"'");
- }
- nresources.removeEnvironment(envName);
-
- }
-
-
- /**
- * Remove any resource reference with the specified name.
- *
- * @param resourceName Name of the resource reference to remove
- */
- public void removeResource(String resourceName) {
-
- resourceName = ObjectName.unquote(resourceName);
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return;
- }
- ContextResource resource = nresources.findResource(resourceName);
- if (resource == null) {
- throw new IllegalArgumentException
- ("Invalid resource name '" + resourceName +
"'");
- }
- nresources.removeResource(resourceName);
- }
-
-
- /**
- * Remove any resource link with the specified name.
- *
- * @param resourceLinkName Name of the resource reference to remove
- */
- public void removeResourceLink(String resourceLinkName) {
-
- resourceLinkName = ObjectName.unquote(resourceLinkName);
- NamingResources nresources = getNamingResources();
- if (nresources == null) {
- return;
- }
- ContextResourceLink resource = nresources.findResourceLink(resourceLinkName);
- if (resource == null) {
- throw new IllegalArgumentException
- ("Invalid resource name '" + resourceLinkName +
"'");
- }
- nresources.removeResourceLink(resourceLinkName);
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/StandardEngineMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/StandardEngineMBean.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/StandardEngineMBean.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.catalina.mbeans;
-
-
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardEngine</code> component.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class StandardEngineMBean extends BaseModelMBean {
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = MBeanUtils.createServer();
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public StandardEngineMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
-
-
- // ------------------------------------------------------------- Operations
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/StandardHostMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/StandardHostMBean.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/StandardHostMBean.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.catalina.mbeans;
-
-
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.catalina.Valve;
-import org.apache.catalina.core.StandardHost;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-import org.apache.tomcat.util.modeler.ManagedBean;
-import org.apache.tomcat.util.modeler.Registry;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardHost</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class StandardHostMBean extends BaseModelMBean {
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = MBeanUtils.createServer();
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public StandardHostMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
-
-
- // ------------------------------------------------------------- Operations
-
-
- /**
- * Add an alias name that should be mapped to this Host
- *
- * @param alias The alias to be added
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public void addAlias(String alias)
- throws Exception {
-
- StandardHost host = (StandardHost) this.resource;
- host.addAlias(alias);
-
- }
-
-
- /**
- * Return the set of alias names for this Host
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String [] findAliases()
- throws Exception {
-
- StandardHost host = (StandardHost) this.resource;
- return host.findAliases();
-
- }
-
-
- /**
- * Return the MBean Names of the Valves assoicated with this Host
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String [] getValves()
- throws Exception {
-
- Registry registry = MBeanUtils.createRegistry();
- StandardHost host = (StandardHost) this.resource;
- String mname = MBeanUtils.createManagedName(host);
- ManagedBean managed = registry.findManagedBean(mname);
- String domain = null;
- if (managed != null) {
- domain = managed.getDomain();
- }
- if (domain == null)
- domain = mserver.getDefaultDomain();
- Valve [] valves = host.getValves();
- String [] mbeanNames = new String[valves.length];
- for (int i = 0; i < valves.length; i++) {
- mbeanNames[i] =
- MBeanUtils.createObjectName(domain, valves[i]).toString();
- }
-
- return mbeanNames;
-
- }
-
-
- /**
- * Return the specified alias name from the aliases for this Host
- *
- * @param alias Alias name to be removed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public void removeAlias(String alias)
- throws Exception {
-
- StandardHost host = (StandardHost) this.resource;
- host.removeAlias(alias);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/StandardServerMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/StandardServerMBean.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/StandardServerMBean.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.catalina.mbeans;
-
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.RuntimeOperationsException;
-import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
-import org.apache.catalina.core.StandardServer;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardServer</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class StandardServerMBean extends BaseModelMBean {
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = MBeanUtils.createServer();
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public StandardServerMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
-
- // ------------------------------------------------------------- Operations
-
-
- /**
- * Write the configuration information for this entire
<code>Server</code>
- * out to the server.xml configuration file.
- *
- * @exception InstanceNotFoundException if the managed resource object
- * cannot be found
- * @exception MBeanException if the initializer of the object throws
- * an exception, or persistence is not supported
- * @exception RuntimeOperationsException if an exception is reported
- * by the persistence mechanism
- */
- public synchronized void store() throws InstanceNotFoundException,
- MBeanException, RuntimeOperationsException {
-
- Server server = ServerFactory.getServer();
- if (server instanceof StandardServer) {
- try {
- ((StandardServer) server).storeConfig();
- } catch (Exception e) {
- throw new MBeanException(e, "Error updating conf/server.xml");
- }
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/StandardServiceMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/StandardServiceMBean.java 2009-05-25 14:32:57
UTC (rev 1062)
+++ trunk/java/org/apache/catalina/mbeans/StandardServiceMBean.java 2009-05-25 14:36:15
UTC (rev 1063)
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.catalina.mbeans;
-
-
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardService</code>
component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class StandardServiceMBean extends BaseModelMBean {
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = MBeanUtils.createServer();
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public StandardServiceMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
-
-
- // ------------------------------------------------------------- Operations
-
-
-}
Modified: trunk/java/org/apache/catalina/realm/DataSourceRealm.java
===================================================================
--- trunk/java/org/apache/catalina/realm/DataSourceRealm.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/realm/DataSourceRealm.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -29,11 +29,10 @@
import javax.naming.Context;
import javax.sql.DataSource;
-import org.apache.naming.ContextBindings;
import org.apache.catalina.LifecycleException;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.util.StringManager;
+import org.apache.naming.ContextBindings;
/**
*
@@ -396,9 +395,7 @@
context = ContextBindings.getClassLoader();
context = (Context) context.lookup("comp/env");
} else {
- StandardServer server =
- (StandardServer) ServerFactory.getServer();
- context = server.getGlobalNamingContext();
+ context = ((StandardServer) getServer()).getGlobalNamingContext();
}
DataSource dataSource = (DataSource)context.lookup(dataSourceName);
return dataSource.getConnection();
Modified: trunk/java/org/apache/catalina/realm/RealmBase.java
===================================================================
--- trunk/java/org/apache/catalina/realm/RealmBase.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/catalina/realm/RealmBase.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -37,24 +37,27 @@
import org.apache.catalina.Container;
import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
import org.apache.catalina.Globals;
+import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Realm;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.core.ContainerBase;
import org.apache.catalina.deploy.LoginConfig;
+import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
-import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.util.HexUtils;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.MD5Encoder;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
* Simple implementation of <b>Realm</b> that reads an XML file to configure
@@ -1212,6 +1215,30 @@
protected abstract Principal getPrincipal(String username);
+ /**
+ * Return the Server object that is the ultimate parent for the container
+ * with which this Realm is associated. If the server cannot be found (eg
+ * because the container hierarchy is not complete), <code>null</code>
is
+ * returned.
+ */
+ protected Server getServer() {
+ Container c = container;
+ if (c instanceof Context) {
+ c = c.getParent();
+ }
+ if (c instanceof Host) {
+ c = c.getParent();
+ }
+ if (c instanceof Engine) {
+ Service s = ((Engine)c).getService();
+ if (s != null) {
+ return s.getServer();
+ }
+ }
+ return null;
+ }
+
+
// --------------------------------------------------------- Static Methods
Modified: trunk/java/org/apache/catalina/startup/Tomcat.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Tomcat.java 2009-05-25 14:32:57 UTC (rev 1062)
+++ trunk/java/org/apache/catalina/startup/Tomcat.java 2009-05-25 14:36:15 UTC (rev 1063)
@@ -178,6 +178,10 @@
* ctx.addErrorPage(ep);
*
* ctx.addMimeMapping("ext", "type");
+ *
+ * Note: If you reload the Context, all your configuration will be lost. If
+ * you need reload support, consider using a LifecycleListener to provide
+ * your configuration.
*
* TODO: add the rest
*
@@ -212,7 +216,7 @@
*
* wrapper.addInitParameter("name", "value");
*/
- public StandardWrapper addServlet(StandardContext ctx,
+ public static StandardWrapper addServlet(StandardContext ctx,
String servletName,
String servletClass) {
// will do class for name and set init params
@@ -227,7 +231,7 @@
/** Use an existing servlet, no class.forName or initialization will be
* performed
*/
- public StandardWrapper addServlet(StandardContext ctx,
+ public static StandardWrapper addServlet(StandardContext ctx,
String servletName,
Servlet servlet) {
// will do class for name and set init params
@@ -525,7 +529,7 @@
* TODO: in normal tomcat, if default-web.xml is not found, use this
* method
*/
- protected void initWebappDefaults(StandardContext ctx) {
+ public static void initWebappDefaults(StandardContext ctx) {
// Default servlet
StandardWrapper servlet =
addServlet(ctx, "default",
Modified: trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2009-05-25 14:32:57 UTC
(rev 1062)
+++ trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 2009-05-25 14:36:15 UTC
(rev 1063)
@@ -1482,7 +1482,7 @@
/**
* Parse host.
*/
- public void parseHost(MessageBytes valueMB) {
+ protected void parseHost(MessageBytes valueMB) {
if (valueMB == null || valueMB.isNull()) {
// HTTP/1.0
Modified: trunk/java/org/apache/coyote/http11/Http11Processor.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11Processor.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/coyote/http11/Http11Processor.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -778,12 +778,11 @@
}
/**
- * Process pipelined HTTP requests using the specified input and output
- * streams.
+ * Process pipelined HTTP requests on the specified socket.
*
- * @param input stream from which the HTTP requests will be read
- * @param output stream which will be used to output the HTTP
- * responses
+ * @param socket Socket from which the HTTP requests will be read
+ * and the HTTP responses will be written.
+ *
* @throws IOException error during an I/O operation
*/
public SocketState process(Socket socket)
@@ -1389,7 +1388,7 @@
/**
* Parse host.
*/
- public void parseHost(MessageBytes valueMB) {
+ protected void parseHost(MessageBytes valueMB) {
if (valueMB == null || valueMB.isNull()) {
// HTTP/1.0
Modified: trunk/java/org/apache/tomcat/util/res/StringManager.java
===================================================================
--- trunk/java/org/apache/tomcat/util/res/StringManager.java 2009-05-25 14:32:57 UTC (rev
1062)
+++ trunk/java/org/apache/tomcat/util/res/StringManager.java 2009-05-25 14:36:15 UTC (rev
1063)
@@ -67,24 +67,13 @@
*
* @param packageName Name of package to create StringManager for.
*/
-
private StringManager(String packageName) {
- this( packageName, Locale.getDefault() );
- }
-
- private StringManager(String packageName, Locale loc) {
String bundleName = packageName + ".LocalStrings";
- bundle = ResourceBundle.getBundle(bundleName, loc);
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
// Get the actual locale, which may be different from the requested one
locale = bundle.getLocale();
}
- private StringManager(ResourceBundle bundle )
- {
- this.bundle=bundle;
- locale = bundle.getLocale();
- }
-
/**
Get a string from the underlying resource bundle or return
null if the String is not found.
@@ -163,33 +152,4 @@
return mgr;
}
- /**
- * Get the StringManager for a particular package. If a manager for
- * a package already exists, it will be reused, else a new
- * StringManager will be created and returned.
- *
- * @param bundle The resource bundle
- */
- public synchronized static StringManager getManager(ResourceBundle bundle) {
- return new StringManager( bundle );
- }
-
- /**
- * Get the StringManager for a particular package and Locale. If a manager for
- * a package already exists, it will be reused, else a new
- * StringManager will be created for that Locale and returned.
- *
- * @param packageName The package name
- * @param loc The locale
- */
-
- public synchronized static StringManager getManager(String packageName,Locale loc) {
- StringManager mgr =
(StringManager)managers.get(packageName+"_"+loc.toString());
- if (mgr == null) {
- mgr = new StringManager(packageName,loc);
- managers.put(packageName+"_"+loc.toString(), mgr);
- }
- return mgr;
- }
-
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-05-25 14:32:57 UTC (rev 1062)
+++ trunk/webapps/docs/changelog.xml 2009-05-25 14:36:15 UTC (rev 1063)
@@ -84,6 +84,15 @@
<bug>46925</bug>: Improve search for nested roles in JNDIRealm by
replacing recursive search with
iterative search. Patch provided by Stefan Zoerner. (rjung)
</fix>
+ <fix>
+ Close stream after error in the classloader. (pero)
+ </fix>
+ <fix>
+ <bug>47046</bug>: JMX unregistration. (markt)
+ </fix>
+ <update>
+ Remove ServerFactory. (markt)
+ </update>
</changelog>
</subsection>
<subsection name="Coyote">
@@ -108,11 +117,10 @@
<bug>46909</bug>: The ';' should really only be used if there
is a following parameter. (markt)
</fix>
<fix>
- <bug>42390</bug>: Correct JSP compilation error with nested tagfile
tags with variables with "AT_BEGIN" scope.
- Patch provided by Konstantin Kolinko. (markt)
+ <bug>37929</bug>: Fix session access to an invalidated session.
(markt)
</fix>
<fix>
- <bug>37929</bug>: Fix session access to an invalidated session.
(markt)
+ Removed some casts in ELResolverImpl. Patch suggested by kkolinko. (markt)
</fix>
</changelog>
</subsection>