Author: markt
Date: Sun May 24 18:39:52 2009
New Revision: 778207
URL: http://svn.apache.org/viewvc?rev=778207&view=rev
Log:
Some more ServerFactory removal.
Modified:
tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
tomcat/trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java?rev=778207&r1=778206&r2=778207&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java Sun May 24
18:39:52 2009
@@ -97,11 +97,20 @@
// ------------------------------------------------------------- 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
@@ -202,17 +211,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 Service) {
+ Server server = ServerFactory.getServer();
+ Service[] services = server.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;
Modified:
tomcat/trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java?rev=778207&r1=778206&r2=778207&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
Sun May 24 18:39:52 2009
@@ -128,12 +128,14 @@
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);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]