org.jboss.system
Class ServiceController

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceController
All Implemented Interfaces:
MBeanRegistration, NotificationBroadcaster, NotificationEmitter, ServiceControllerMBean

public class ServiceController
extends JBossNotificationBroadcasterSupport
implements ServiceControllerMBean, MBeanRegistration

This is the main Service Controller. A controller can deploy a service to a jboss.system It installs by delegating, it configures by delegating

This class has been rewritten to delegate to the microcontainer's generic controller. Like the original ServiceController, all state transitions must be handled manually, e.g. driven by the deployer invoking create, start, stop, etc. That is with one exception; we register ourselves an automatic context.

Version:
$Revision: 81485 $
Author:
Marc Fleury, David Jencks, Scott Stark, Dimitris Andreadis, Adrian Brock
See Also:
Service

Field Summary
static ObjectName DEFAULT_LOADER_REPOSITORY
          The ObjectName of the default loader repository
protected  Map<ObjectName,ServiceControllerContext> installed
          The contexts
protected  CopyOnWriteArrayList<ServiceControllerContext> installedOrder
          The contexts in installation order
static String JBOSS_INTERNAL_LIFECYCLE
          The operation name for lifecycle
static String[] JBOSS_INTERNAL_LIFECYCLE_SIG
          The signature for lifecycle operations
protected  org.jboss.kernel.Kernel kernel
          The kernel
protected  MBeanServer server
          A callback to the JMX MBeanServer
 
Fields inherited from interface org.jboss.system.ServiceControllerMBean
OBJECT_NAME
 
Constructor Summary
ServiceController()
           
 
Method Summary
 void create(ObjectName serviceName)
          Create a service
 void create(ObjectName serviceName, Collection<ObjectName> depends)
          Create a service with given dependencies
 void destroy(ObjectName serviceName)
          Destroy the indicated service
 org.jboss.kernel.Kernel getKernel()
          Get the kernel.
 MBeanServer getMBeanServer()
          Get the MBeanServer
 ServiceContext getServiceContext(ObjectName serviceName)
          Lookup the ServiceContext for the given serviceName
protected  Throwable getStackTrace()
          Get exception that will expose stacktrace.
 List<ObjectName> install(Element config, ObjectName loaderName)
          Deploy the beans; deploy means "instantiate and configure" so the MBean is created in the MBeanServer.
 List<ObjectName> install(List<ServiceMetaData> metaDatas, ObjectName loaderName)
           
 void install(ObjectName name, Object object)
          Install an MBean without any meta data
 ObjectName install(ServiceMetaData metaData, ObjectName loaderName)
           
 String listConfiguration(ObjectName[] objectNames)
          Gets the Configuration attribute of the ServiceController object
 List<ServiceContext> listDeployed()
          Lists the ServiceContexts of deployed mbeans
 List<ObjectName> listDeployedNames()
          lists ObjectNames of deployed mbeans deployed through serviceController.
 List<ServiceContext> listIncompletelyDeployed()
          The listIncompletelyDeployed method returns the service contexts for the mbeans whose status is not CREATED, RUNNING, STOPPED or DESTROYED.
 void postDeregister()
           
 void postRegister(Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void register(ObjectName serviceName)
          Register the mbean against the microkernel with no dependencies.
 void register(ObjectName serviceName, Collection<ObjectName> depends)
          Register the mbean against the microkernel with dependencies.
 void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle)
          Register the mbean against the microkernel with dependencies.
 void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle, Object target)
          Register the mbean against the microkernel with dependencies.
 void remove(ObjectName objectName)
          This MBean is going bye bye
 void restart(ObjectName serviceName)
          Stops and restarts the indicated service
static Exception rethrow(String context, Throwable t)
          Rethrow an error as an exception
 void sendControllerNotification(String type, ObjectName serviceName)
          Sends outs controller notifications about service lifecycle events
 void setKernel(org.jboss.kernel.Kernel kernel)
          Set the kernel.
 void setMBeanServer(MBeanServer server)
          Set the server.
 void shutdown()
          Describe shutdown method here.
 void start(ObjectName serviceName)
          Starts the indicated service
 void stop(ObjectName serviceName)
          Stop the indicated service
 void validateDeploymentState(DeploymentInfo di, DeploymentState state)
          Go through the mbeans of the DeploymentInfo and validate that they are in a state at least equal to that of the argument state
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOADER_REPOSITORY

public static final ObjectName DEFAULT_LOADER_REPOSITORY
The ObjectName of the default loader repository


JBOSS_INTERNAL_LIFECYCLE

public static final String JBOSS_INTERNAL_LIFECYCLE
The operation name for lifecycle

See Also:
Constant Field Values

JBOSS_INTERNAL_LIFECYCLE_SIG

public static final String[] JBOSS_INTERNAL_LIFECYCLE_SIG
The signature for lifecycle operations


kernel

protected org.jboss.kernel.Kernel kernel
The kernel


server

protected MBeanServer server
A callback to the JMX MBeanServer


installed

protected Map<ObjectName,ServiceControllerContext> installed
The contexts


installedOrder

protected CopyOnWriteArrayList<ServiceControllerContext> installedOrder
The contexts in installation order

Constructor Detail

ServiceController

public ServiceController()
Method Detail

rethrow

public static Exception rethrow(String context,
                                Throwable t)
                         throws Exception
Rethrow an error as an exception

Parameters:
context - the context
t - the original throwable
Returns:
never
Throws:
Exception - always

getStackTrace

protected Throwable getStackTrace()
Get exception that will expose stacktrace.

Returns:
the stracktrace exposing exception

getMBeanServer

public MBeanServer getMBeanServer()
Get the MBeanServer

Returns:
the server

setMBeanServer

public void setMBeanServer(MBeanServer server)
Set the server.

Parameters:
server - the server.

getKernel

public org.jboss.kernel.Kernel getKernel()
Get the kernel.

Returns:
the kernel.

setKernel

public void setKernel(org.jboss.kernel.Kernel kernel)
Set the kernel.

Parameters:
kernel - the kernel.

listDeployed

public List<ServiceContext> listDeployed()
Description copied from interface: ServiceControllerMBean
Lists the ServiceContexts of deployed mbeans

Specified by:
listDeployed in interface ServiceControllerMBean
Returns:
the list of ServiceContexts for mbeans deployed through ServiceController.

listIncompletelyDeployed

public List<ServiceContext> listIncompletelyDeployed()
Description copied from interface: ServiceControllerMBean
The listIncompletelyDeployed method returns the service contexts for the mbeans whose status is not CREATED, RUNNING, STOPPED or DESTROYED. An MBean that has reached one of the above states has its dependencies resolved.

Specified by:
listIncompletelyDeployed in interface ServiceControllerMBean
Returns:
a List

listDeployedNames

public List<ObjectName> listDeployedNames()
Description copied from interface: ServiceControllerMBean
lists ObjectNames of deployed mbeans deployed through serviceController.

Specified by:
listDeployedNames in interface ServiceControllerMBean
Returns:
a list of ObjectNames of deployed mbeans.

listConfiguration

public String listConfiguration(ObjectName[] objectNames)
                         throws Exception
Description copied from interface: ServiceControllerMBean
Gets the Configuration attribute of the ServiceController object

Specified by:
listConfiguration in interface ServiceControllerMBean
Parameters:
objectNames - Description of Parameter
Returns:
The Configuration value
Throws:
Exception - Description of Exception

validateDeploymentState

public void validateDeploymentState(DeploymentInfo di,
                                    DeploymentState state)
Description copied from interface: ServiceControllerMBean
Go through the mbeans of the DeploymentInfo and validate that they are in a state at least equal to that of the argument state

Specified by:
validateDeploymentState in interface ServiceControllerMBean
Parameters:
di - the deployment info
state - the deployment state

install

public List<ObjectName> install(List<ServiceMetaData> metaDatas,
                                ObjectName loaderName)
                         throws Exception
Throws:
Exception

install

public ObjectName install(ServiceMetaData metaData,
                          ObjectName loaderName)
                   throws Exception
Throws:
Exception

install

public List<ObjectName> install(Element config,
                                ObjectName loaderName)
                         throws Exception
Description copied from interface: ServiceControllerMBean
Deploy the beans; deploy means "instantiate and configure" so the MBean is created in the MBeanServer. You must call "create" and "start" separately on the MBean to affect the service lifecycle deploy doesn't bother with service lifecycle only MBean instanciation/registration/configuration.

Specified by:
install in interface ServiceControllerMBean
Returns:
Description of the Returned Value
Throws:
Exception - for any error

install

public void install(ObjectName name,
                    Object object)
             throws Exception
Install an MBean without any meta data

Parameters:
name - the object name
object - the mbean object
Throws:
Exception - for any error

register

public void register(ObjectName serviceName)
              throws Exception
Description copied from interface: ServiceControllerMBean
Register the mbean against the microkernel with no dependencies.

Specified by:
register in interface ServiceControllerMBean
Parameters:
serviceName - the object name
Throws:
Exception - for any error
See Also:
ServiceControllerMBean.register(ObjectName, java.util.Collection)

register

public void register(ObjectName serviceName,
                     Collection<ObjectName> depends)
              throws Exception
Description copied from interface: ServiceControllerMBean
Register the mbean against the microkernel with dependencies.

Specified by:
register in interface ServiceControllerMBean
Parameters:
serviceName - the object name
depends - the dependencies
Throws:
Exception - for any error

register

public void register(ObjectName serviceName,
                     Collection<ObjectName> depends,
                     boolean includeLifecycle)
              throws Exception
Register the mbean against the microkernel with dependencies.

Parameters:
serviceName - the object name
depends - the dependencies
includeLifecycle - the includes lifecycle flag
Throws:
Exception - for any error

register

public void register(ObjectName serviceName,
                     Collection<ObjectName> depends,
                     boolean includeLifecycle,
                     Object target)
              throws Exception
Register the mbean against the microkernel with dependencies.

Parameters:
serviceName - the object name
depends - the dependencies
includeLifecycle - the includes lifecycle flag
target - the target
Throws:
Exception - for any error

create

public void create(ObjectName serviceName)
            throws Exception
Description copied from interface: ServiceControllerMBean
Create a service

Specified by:
create in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
Throws:
Exception - Description of Exception

create

public void create(ObjectName serviceName,
                   Collection<ObjectName> depends)
            throws Exception
Description copied from interface: ServiceControllerMBean
Create a service with given dependencies

Specified by:
create in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
depends - the dependencies
Throws:
Exception - Description of Exception

start

public void start(ObjectName serviceName)
           throws Exception
Description copied from interface: ServiceControllerMBean
Starts the indicated service

Specified by:
start in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
Throws:
Exception - Description of Exception

restart

public void restart(ObjectName serviceName)
             throws Exception
Description copied from interface: ServiceControllerMBean
Stops and restarts the indicated service

Specified by:
restart in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
Throws:
Exception - Description of Exception

stop

public void stop(ObjectName serviceName)
          throws Exception
Description copied from interface: ServiceControllerMBean
Stop the indicated service

Specified by:
stop in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
Throws:
Exception - Description of Exception

destroy

public void destroy(ObjectName serviceName)
             throws Exception
Description copied from interface: ServiceControllerMBean
Destroy the indicated service

Specified by:
destroy in interface ServiceControllerMBean
Parameters:
serviceName - Description of Parameter
Throws:
Exception - Description of Exception

remove

public void remove(ObjectName objectName)
            throws Exception
Description copied from interface: ServiceControllerMBean
This MBean is going bye bye

Specified by:
remove in interface ServiceControllerMBean
Parameters:
objectName - Description of Parameter
Throws:
Exception - Description of Exception

getServiceContext

public ServiceContext getServiceContext(ObjectName serviceName)
Description copied from interface: ServiceControllerMBean
Lookup the ServiceContext for the given serviceName

Specified by:
getServiceContext in interface ServiceControllerMBean
Parameters:
serviceName - the service name
Returns:
the service context

shutdown

public void shutdown()
Description copied from interface: ServiceControllerMBean
Describe shutdown method here.

Specified by:
shutdown in interface ServiceControllerMBean

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

sendControllerNotification

public void sendControllerNotification(String type,
                                       ObjectName serviceName)
Sends outs controller notifications about service lifecycle events

Parameters:
type - the notification type
serviceName - the service name


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.