[Jboss-cvs] JBossAS SVN: r55434 - in branches/MC_VDF_WORK/system-jmx/src/main/org/jboss: deployment system/server system/server/jmx
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 9 08:02:33 EDT 2006
Author: scott.stark at jboss.org
Date: 2006-08-09 08:02:30 -0400 (Wed, 09 Aug 2006)
New Revision: 55434
Modified:
branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/deployment/SARDeployer.java
branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/ServerImplMBean.java
branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java
Log:
Move all of the jmx initialization to the JMXKernel and have the SADeployer depend on the JMXKernel for the MBeanServer and ServiceController
Modified: branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/deployment/SARDeployer.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/deployment/SARDeployer.java 2006-08-09 12:01:57 UTC (rev 55433)
+++ branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/deployment/SARDeployer.java 2006-08-09 12:02:30 UTC (rev 55434)
@@ -89,7 +89,7 @@
/** The MBeanServer for the jmx bus of the ServiceController */
private MBeanServer server;
/** The ServiceController. */
- private ServiceController serviceController;
+ private ServiceControllerMBean serviceController;
/** The server configuration base URL. For example,
file:/<jboss_dist_root>/server/default. Relative service
@@ -142,6 +142,10 @@
{
return serviceController;
}
+ public void setServiceController(ServiceControllerMBean controller)
+ {
+ this.serviceController = controller;
+ }
public MBeanServer getServer()
{
return server;
@@ -175,10 +179,6 @@
// Locate the jboss domain server
server = MBeanServerLocator.locateJBoss();
}
- // Create the ServiceController
- serviceController = new ServiceController();
- serviceController.setKernel(getKernelContext().getKernel());
- serviceController.setMBeanServer(server);
}
/**
Modified: branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/ServerImplMBean.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/ServerImplMBean.java 2006-08-09 12:01:57 UTC (rev 55433)
+++ branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/ServerImplMBean.java 2006-08-09 12:02:30 UTC (rev 55434)
@@ -21,8 +21,6 @@
*/
package org.jboss.system.server;
-import java.util.Date;
-
import javax.management.ObjectName;
import org.jboss.mx.util.ObjectNameFactory;
@@ -30,77 +28,14 @@
/**
* MBean interface.
*/
-public interface ServerImplMBean
+public interface ServerImplMBean extends Server
{
/** The default object name */
ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.system:type=Server");
// Attributes ----------------------------------------------------
- /** The server start date */
- Date getStartDate();
-
- /** The server version */
- String getVersion();
-
- /** The server version code name */
- String getVersionName();
-
- /** The date the server was build (compiled) */
- String getBuildNumber();
-
- /** The JVM used to build the server */
- String getBuildJVM();
-
- /** The Operating System used to build the server */
- String getBuildOS();
-
- /** The build id */
- String getBuildID();
-
- /** The date the server was build */
- String getBuildDate();
-
- /** The server state, true if started, false otherwise */
- boolean isStarted();
-
- /** A flag indicating if shutdown has been called */
- boolean isInShutdown();
-
- // Operations ----------------------------------------------------
-
/**
- * Shutdown the Server instance and run shutdown hooks.
- *
- * If the exit on shutdown flag is true, then {@link #exit} is called,
- * else only the shutdown hook is run.
- * @throws IllegalStateException No started.
- */
- void shutdown() throws IllegalStateException;
-
- /**
- * Shutdown the server, the JVM and run shutdown hooks.
- * @param exitcode The exit code returned to the operating system.
- */
- void exit(int exitcode);
-
- /**
- * Shutdown the server, the JVM and run shutdown hooks. Exits with code 1.
- */
- void exit();
-
- /**
- * Forcibly terminates the currently running Java virtual machine.
- * @param exitcode The exit code returned to the operating system.
- */
- void halt(int exitcode);
-
- /**
- * Forcibly terminates the currently running Java virtual machine. Exits with code 1.
- */
- void halt();
-
- /**
* Hint to the JVM to run the garbage collector.
*/
void runGarbageCollector();
Modified: branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java
===================================================================
--- branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java 2006-08-09 12:01:57 UTC (rev 55433)
+++ branches/MC_VDF_WORK/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java 2006-08-09 12:02:30 UTC (rev 55434)
@@ -28,6 +28,7 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.logging.LogManager;
import javax.management.ListenerNotFoundException;
@@ -40,6 +41,8 @@
import javax.management.ObjectInstance;
import javax.management.ObjectName;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.logging.JBossJDKLogManager;
import org.jboss.mx.loading.RepositoryClassLoader;
import org.jboss.mx.server.ServerConstants;
@@ -47,11 +50,11 @@
import org.jboss.mx.util.JMXExceptionDecoder;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceController;
import org.jboss.system.ServiceControllerMBean;
import org.jboss.system.server.Server;
import org.jboss.system.server.ServerConfig;
import org.jboss.system.server.ServerConfigImplMBean;
-import org.jboss.system.server.ServerConfigLocator;
import org.jboss.system.server.ServerImplMBean;
import org.jboss.util.JBossObject;
import org.jboss.util.file.FileSuffixFilter;
@@ -64,16 +67,18 @@
* @version $Revision:$
*/
public class JMXKernel extends JBossObject
- implements JMXKernelMBean
+ implements JMXKernelMBean, KernelControllerContextAware
{
private final static ObjectName DEFAULT_LOADER_NAME =
ObjectNameFactory.create(ServerConstants.DEFAULT_LOADER_NAME);
+ /** The MC kernel context */
+ protected KernelControllerContext kernelContext;
/** The JMX MBeanServer which will serve as our communication bus. */
- private MBeanServer server;
- private ServerImplMBean serverImpl;
- private ServiceControllerMBean controller;
- private ServerConfig config;
+ private MBeanServer mbeanServer;
+ private Server serverImpl;
+ private ServiceController controller;
+ private ServerConfig serverConfig;
/** The NotificationBroadcaster implementation delegate */
private JBossNotificationBroadcasterSupport broadcasterSupport;
@@ -83,11 +88,11 @@
/** A flag indicating if shutdown has been called */
private boolean isInShutdown;
- public ServerImplMBean getServerImpl()
+ public Server getServerImpl()
{
return serverImpl;
}
- public void setServerImpl(ServerImplMBean serverImpl)
+ public void setServerImpl(Server serverImpl)
{
this.serverImpl = serverImpl;
}
@@ -96,9 +101,9 @@
{
return this.controller;
}
- public void setServiceController(final ServiceControllerMBean controller)
+ public MBeanServer getMbeanServer()
{
- this.controller = controller;
+ return mbeanServer;
}
public void start() throws Exception
@@ -110,10 +115,9 @@
ServerConstants.DEFAULT_MBEAN_SERVER_BUILDER_CLASS);
System.setProperty(ServerConstants.MBEAN_SERVER_BUILDER_CLASS_PROPERTY, builder);
- if( config == null )
- config = ServerConfigLocator.locate();
+ serverConfig = serverImpl.getConfig();
// Check if we'll use the platform MBeanServer or instantiate our own
- if (config.getPlatformMBeanServer() == true)
+ if (serverConfig.getPlatformMBeanServer() == true)
{
// jdk1.5+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -121,40 +125,43 @@
Class[] sig = null;
Method method = clazz.getMethod("getPlatformMBeanServer", sig);
Object[] args = null;
- server = (MBeanServer) method.invoke(null, args);
- // Tell the MBeanServerLocator to point to this server
- MBeanServerLocator.setJBoss(server);
+ mbeanServer = (MBeanServer) method.invoke(null, args);
+ // Tell the MBeanServerLocator to point to this mbeanServer
+ MBeanServerLocator.setJBoss(mbeanServer);
/* If the LazyMBeanServer was used, we need to reset to the jboss
MBeanServer to use our implementation for the jboss services.
*/
- server = LazyMBeanServer.resetToJBossServer(server);
+ mbeanServer = LazyMBeanServer.resetToJBossServer(mbeanServer);
}
else
{
// Create our own MBeanServer
- server = MBeanServerFactory.createMBeanServer("jboss");
+ mbeanServer = MBeanServerFactory.createMBeanServer("jboss");
}
- log.debug("Created MBeanServer: " + server);
+ log.debug("Created MBeanServer: " + mbeanServer);
- // Register server components
- server.registerMBean(this, ServerImplMBean.OBJECT_NAME);
- server.registerMBean(config, ServerConfigImplMBean.OBJECT_NAME);
+ // Register mbeanServer components
+ mbeanServer.registerMBean(this, ServerImplMBean.OBJECT_NAME);
+ mbeanServer.registerMBean(serverConfig, ServerConfigImplMBean.OBJECT_NAME);
// Initialize spine boot libraries
RepositoryClassLoader ucl = initBootLibraries();
bootstrapUCLName = ucl.getObjectName();
- server.registerMBean(ucl, bootstrapUCLName);
+ mbeanServer.registerMBean(ucl, bootstrapUCLName);
// Set ServiceClassLoader as classloader for the construction of
// the basic system
Thread.currentThread().setContextClassLoader(ucl);
// General Purpose Architecture information
- createMBean("org.jboss.system.server.ServerInfo",
+ createMBean("org.jboss.system.mbeanServer.ServerInfo",
"jboss.system:type=ServerInfo");
// Service Controller
- server.registerMBean(controller, new ObjectName("jboss.system:service=ServiceController"));
+ controller = new ServiceController();
+ controller.setKernel(kernelContext.getKernel());
+ controller.setMBeanServer(mbeanServer);
+ mbeanServer.registerMBean(controller, new ObjectName("jboss.system:service=ServiceController"));
log.info("Legacy JMX core initialized");
started = true;
@@ -223,7 +230,26 @@
broadcasterSupport.sendNotification(notification);
}
+ // KernelControllerContextAware implements -----------------------------
+ public void setKernelControllerContext(KernelControllerContext kernelContext)
+ throws Exception
+ {
+ log.debug("Setting kernel kernelContext " + kernelContext);
+ this.kernelContext = kernelContext;
+ }
+
+ public void unsetKernelControllerContext(KernelControllerContext kernelContext) throws Exception
+ {
+ log.debug("Unsetting kernel kernelContext " + kernelContext);
+ this.kernelContext = null;
+ }
+
// ServerImplMBean delegation
+ public void init(Properties props) throws Exception
+ {
+ serverImpl.init(props);
+ }
+
public void exit()
{
serverImpl.exit();
@@ -234,6 +260,10 @@
serverImpl.exit(exitcode);
}
+ public ServerConfig getConfig()
+ {
+ return serverConfig;
+ }
public String getBuildDate()
{
return serverImpl.getBuildDate();
@@ -296,22 +326,22 @@
public void runFinalization()
{
- serverImpl.runFinalization();
+
}
public void runGarbageCollector()
{
- serverImpl.runGarbageCollector();
+
}
public void traceInstructions(Boolean flag)
{
- serverImpl.traceInstructions(flag);
+
}
public void traceMethodCalls(Boolean flag)
{
- serverImpl.traceMethodCalls(flag);
+
}
public void shutdown()
@@ -335,7 +365,7 @@
else
isInShutdown = true;
- // Send a notification that server stop is initiated
+ // Send a notification that mbeanServer stop is initiated
Notification msg = new Notification(Server.STOP_NOTIFICATION_TYPE, this, 2);
sendNotification(msg);
@@ -370,16 +400,16 @@
}
/**
- * The <code>removeMBeans</code> method uses the mbean server to unregister
+ * The <code>removeMBeans</code> method uses the mbean mbeanServer to unregister
* all the mbeans registered here.
*/
protected void removeMBeans()
{
try
{
- server.unregisterMBean(ServiceControllerMBean.OBJECT_NAME);
- server.unregisterMBean(ServerConfigImplMBean.OBJECT_NAME);
- server.unregisterMBean(ServerImplMBean.OBJECT_NAME);
+ mbeanServer.unregisterMBean(ServiceControllerMBean.OBJECT_NAME);
+ mbeanServer.unregisterMBean(ServerConfigImplMBean.OBJECT_NAME);
+ mbeanServer.unregisterMBean(ServerImplMBean.OBJECT_NAME);
}
catch (Exception e)
{
@@ -388,15 +418,15 @@
}
try
{
- MBeanServer registeredServer = server;
- if (config.getPlatformMBeanServer() == true)
- registeredServer = LazyMBeanServer.getRegisteredMBeanServer(server);
+ MBeanServer registeredServer = mbeanServer;
+ if (serverConfig.getPlatformMBeanServer() == true)
+ registeredServer = LazyMBeanServer.getRegisteredMBeanServer(mbeanServer);
MBeanServerFactory.releaseMBeanServer(registeredServer);
}
catch (Exception e)
{
Throwable t = JMXExceptionDecoder.decode(e);
- log.error("Failed to release mbean server", t);
+ log.error("Failed to release mbean mbeanServer", t);
}
}
@@ -411,7 +441,7 @@
// Add the patch URL. If the url protocol is file, then
// add the contents of the directory it points to
- URL patchURL = config.getPatchURL();
+ URL patchURL = serverConfig.getPatchURL();
if (patchURL != null)
{
if (patchURL.getProtocol().equals("file"))
@@ -437,8 +467,8 @@
}
}
- // Add the server configuration directory to be able to load config files as resources
- list.add(config.getServerConfigURL());
+ // Add the mbeanServer configuration directory to be able to load serverConfig files as resources
+ list.add(serverConfig.getServerConfigURL());
log.debug("Boot url list: " + list);
// Create loaders for each URL
@@ -451,13 +481,13 @@
// This is a boot URL, so key it on itself.
Object[] args = {url, Boolean.TRUE};
String[] sig = {"java.net.URL", "boolean"};
- loader = (RepositoryClassLoader) server.invoke(DEFAULT_LOADER_NAME, "newClassLoader", args, sig);
+ loader = (RepositoryClassLoader) mbeanServer.invoke(DEFAULT_LOADER_NAME, "newClassLoader", args, sig);
}
return loader;
}
/**
- * Instantiate and register a service for the given classname into the MBean server.
+ * Instantiate and register a service for the given classname into the MBean mbeanServer.
*/
private ObjectName createMBean(final String classname, String name)
throws Exception
@@ -469,11 +499,11 @@
{
// See if there is an xmbean descriptor for the bootstrap mbean
URL xmbeanDD = new URL("resource:xmdesc/"+classname+"-xmbean.xml");
- Object resource = server.instantiate(classname);
+ Object resource = mbeanServer.instantiate(classname);
// Create the XMBean
Object[] args = {resource, xmbeanDD};
String[] sig = {Object.class.getName(), URL.class.getName()};
- ObjectInstance instance = server.createMBean("org.jboss.mx.modelmbean.XMBean",
+ ObjectInstance instance = mbeanServer.createMBean("org.jboss.mx.modelmbean.XMBean",
mbeanName,
bootstrapUCLName,
args,
@@ -484,7 +514,7 @@
catch(Exception e)
{
log.debug("Failed to create xmbean for: "+classname);
- mbeanName = server.createMBean(classname, mbeanName).getObjectName();
+ mbeanName = mbeanServer.createMBean(classname, mbeanName).getObjectName();
log.debug("Created system MBean: " + mbeanName);
}
More information about the jboss-cvs-commits
mailing list