public class ServiceMBeanSupport extends NotificationBroadcasterSupport implements ServiceMBean, MBeanRegistration
getName()
method and should override startService()
, and stopService()
as
approriate.ServiceMBean
Modifier and Type | Field and Description |
---|---|
protected Logger |
log |
protected MBeanServer |
server
The MBeanServer which we have been register with.
|
protected ObjectName |
serviceName
The object name which we are registered under.
|
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
Constructor and Description |
---|
ServiceMBeanSupport()
Construct a
|
ServiceMBeanSupport(Class<?> type)
Construct a
|
ServiceMBeanSupport(Logger log)
Construct a
|
ServiceMBeanSupport(String category)
Construct a
|
Modifier and Type | Method and Description |
---|---|
void |
create()
create the service, do expensive operations etc
|
protected void |
createService()
Sub-classes should override this method to provide custum 'create' logic.
|
void |
destroy()
destroy the service, tear down
|
protected void |
destroyService()
Sub-classes should override this method to provide custum 'destroy' logic.
|
Logger |
getLog() |
String |
getName()
Use the short class name as the default for the service name.
|
protected long |
getNextNotificationSequenceNumber()
The
getNextNotificationSequenceNumber method returns the next sequence number for use in notifications. |
protected ObjectName |
getObjectName(MBeanServer server,
ObjectName name)
Sub-classes should override this method if they only need to set their object name during MBean pre-registration.
|
MBeanServer |
getServer() |
ObjectName |
getServiceName() |
int |
getState() |
String |
getStateString() |
protected void |
jbossInternalCreate() |
protected String |
jbossInternalDescription() |
protected void |
jbossInternalDestroy() |
void |
jbossInternalLifecycle(String method)
Detyped lifecycle invocation
|
protected void |
jbossInternalStart() |
protected void |
jbossInternalStop() |
long |
nextNotificationSequenceNumber()
The
nextNotificationSequenceNumber method returns the next sequence number for use in notifications. |
void |
postDeregister() |
void |
postRegister(Boolean registrationDone) |
void |
preDeregister() |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Callback method of
MBeanRegistration before the MBean is registered at the JMX Agent. |
void |
start()
start the service, create is already called
|
protected void |
startService()
Sub-classes should override this method to provide custum 'start' logic.
|
void |
stop()
stop the service
|
protected void |
stopService()
Sub-classes should override this method to provide custum 'stop' logic.
|
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
protected Logger log
protected MBeanServer server
protected ObjectName serviceName
public ServiceMBeanSupport()
Sets up logging.
public ServiceMBeanSupport(Class<?> type)
Sets up logging.
type
- The class type to determine category name from.public ServiceMBeanSupport(String category)
Sets up logging.
category
- The logger category name.public ServiceMBeanSupport(Logger log)
log
- The logger to use.public String getName()
getName
in interface ServiceMBean
public ObjectName getServiceName()
public MBeanServer getServer()
public int getState()
getState
in interface ServiceMBean
public String getStateString()
getStateString
in interface ServiceMBean
public Logger getLog()
public void create() throws Exception
Service
public void start() throws Exception
Service
public void stop()
Service
public void destroy()
Service
protected String jbossInternalDescription()
public void jbossInternalLifecycle(String method) throws Exception
ServiceMBean
jbossInternalLifecycle
in interface ServiceMBean
Exception
protected void jbossInternalStop()
protected void jbossInternalDestroy()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
MBeanRegistration
before the MBean is registered at the JMX Agent.
Attention: Always call this method when you overwrite it in a subclass because it saves the Object Name of the MBean.
preRegister
in interface MBeanRegistration
server
- Reference to the JMX Agent this MBean is registered onname
- Name specified by the creator of the MBean. Note that you can overwrite it when the given ObjectName is null
otherwise the change is discarded (maybe a bug in JMX-RI).Exception
- for any errorpublic void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
protected ObjectName getObjectName(MBeanServer server, ObjectName name) throws MalformedObjectNameException
server
- the mbeanservername
- the suggested name, maybe nullMalformedObjectNameException
- for a bad object nameprotected void createService() throws Exception
This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
Exception
- for any errorprotected void startService() throws Exception
This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
Exception
- for any errorprotected void stopService() throws Exception
This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
Exception
- for any errorprotected void destroyService() throws Exception
This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
Exception
- for any errorpublic long nextNotificationSequenceNumber()
nextNotificationSequenceNumber
method returns the next sequence number for use in notifications.long
valueprotected long getNextNotificationSequenceNumber()
getNextNotificationSequenceNumber
method returns the next sequence number for use in notifications.long
valueCopyright © 2019 JBoss by Red Hat. All rights reserved.