Class ServiceMBeanSupport
- All Implemented Interfaces:
MBeanRegistration,NotificationBroadcaster,NotificationEmitter,Service,ServiceMBean
getName() method and should override startService(), and stopService() as
approriate.- Author:
- Rickard Öberg, Scott.Stark@jboss.org, Andreas Schaefer, Jason Dillon, Eduardo Martins (AS7)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jboss.logging.Loggerprotected MBeanServerThe MBeanServer which we have been register with.protected ObjectNameThe object name which we are registered under.Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED -
Constructor Summary
ConstructorsConstructorDescriptionConstruct aServiceMBeanSupport. ServiceMBeanSupport(Class<?> type) Construct aServiceMBeanSupport. ServiceMBeanSupport(String category) Construct aServiceMBeanSupport. ServiceMBeanSupport(org.jboss.logging.Logger log) Construct aServiceMBeanSupport. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()create the service, do expensive operations etcprotected voidSub-classes should override this method to provide custum 'create' logic.voiddestroy()destroy the service, tear downprotected voidSub-classes should override this method to provide custum 'destroy' logic.org.jboss.logging.LoggergetLog()getName()Use the short class name as the default for the service name.protected longThegetNextNotificationSequenceNumbermethod returns the next sequence number for use in notifications.protected ObjectNamegetObjectName(MBeanServer server, ObjectName name) Sub-classes should override this method if they only need to set their object name during MBean pre-registration.intgetState()protected voidprotected Stringprotected voidvoidjbossInternalLifecycle(String method) Detyped lifecycle invocationprotected voidprotected voidlongThenextNotificationSequenceNumbermethod returns the next sequence number for use in notifications.voidvoidpostRegister(Boolean registrationDone) voidpreRegister(MBeanServer server, ObjectName name) Callback method ofMBeanRegistrationbefore the MBean is registered at the JMX Agent.voidstart()start the service, create is already calledprotected voidSub-classes should override this method to provide custum 'start' logic.voidstop()stop the serviceprotected voidSub-classes should override this method to provide custum 'stop' logic.Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
-
Field Details
-
log
protected org.jboss.logging.Logger log -
server
The MBeanServer which we have been register with. -
serviceName
The object name which we are registered under.
-
-
Constructor Details
-
ServiceMBeanSupport
public ServiceMBeanSupport()Construct aServiceMBeanSupport. Sets up logging.
-
ServiceMBeanSupport
Construct aServiceMBeanSupport. Sets up logging.
- Parameters:
type- The class type to determine category name from.
-
ServiceMBeanSupport
Construct aServiceMBeanSupport. Sets up logging.
- Parameters:
category- The logger category name.
-
ServiceMBeanSupport
public ServiceMBeanSupport(org.jboss.logging.Logger log) Construct aServiceMBeanSupport. - Parameters:
log- The logger to use.
-
-
Method Details
-
getName
Use the short class name as the default for the service name.- Specified by:
getNamein interfaceServiceMBean- Returns:
- a description of the mbean
-
getServiceName
-
getServer
-
getState
public int getState()- Specified by:
getStatein interfaceServiceMBean
-
getStateString
- Specified by:
getStateStringin interfaceServiceMBean
-
getLog
public org.jboss.logging.Logger getLog() -
create
Description copied from interface:Servicecreate the service, do expensive operations etc -
start
Description copied from interface:Servicestart the service, create is already called -
stop
public void stop()Description copied from interface:Servicestop the service -
destroy
public void destroy()Description copied from interface:Servicedestroy the service, tear down -
jbossInternalDescription
-
jbossInternalLifecycle
Description copied from interface:ServiceMBeanDetyped lifecycle invocation- Specified by:
jbossInternalLifecyclein interfaceServiceMBean- Throws:
Exception
-
jbossInternalCreate
- Throws:
Exception
-
jbossInternalStart
- Throws:
Exception
-
jbossInternalStop
protected void jbossInternalStop() -
jbossInternalDestroy
protected void jbossInternalDestroy() -
preRegister
Callback method ofMBeanRegistrationbefore 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.
- Specified by:
preRegisterin interfaceMBeanRegistration- Parameters:
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).- Returns:
- the ObjectName
- Throws:
Exception- for any error
-
postRegister
- Specified by:
postRegisterin interfaceMBeanRegistration
-
preDeregister
- Specified by:
preDeregisterin interfaceMBeanRegistration- Throws:
Exception
-
postDeregister
public void postDeregister()- Specified by:
postDeregisterin interfaceMBeanRegistration
-
getObjectName
protected ObjectName getObjectName(MBeanServer server, ObjectName name) throws MalformedObjectNameException Sub-classes should override this method if they only need to set their object name during MBean pre-registration.- Parameters:
server- the mbeanservername- the suggested name, maybe null- Returns:
- the object name
- Throws:
MalformedObjectNameException- for a bad object name
-
createService
Sub-classes should override this method to provide custum 'create' logic.This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
- Throws:
Exception- for any error
-
startService
Sub-classes should override this method to provide custum 'start' logic.This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
- Throws:
Exception- for any error
-
stopService
Sub-classes should override this method to provide custum 'stop' logic.This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
- Throws:
Exception- for any error
-
destroyService
Sub-classes should override this method to provide custum 'destroy' logic.This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.
- Throws:
Exception- for any error
-
nextNotificationSequenceNumber
public long nextNotificationSequenceNumber()ThenextNotificationSequenceNumbermethod returns the next sequence number for use in notifications.- Returns:
- a
longvalue
-
getNextNotificationSequenceNumber
protected long getNextNotificationSequenceNumber()ThegetNextNotificationSequenceNumbermethod returns the next sequence number for use in notifications.- Returns:
- a
longvalue
-