org.springframework.batch.admin.jmx
Class BatchMBeanExporter

java.lang.Object
  extended by org.springframework.jmx.support.MBeanRegistrationSupport
      extended by org.springframework.jmx.export.MBeanExporter
          extended by org.springframework.batch.admin.jmx.BatchMBeanExporter
All Implemented Interfaces:
BeanClassLoaderAware, BeanFactoryAware, DisposableBean, InitializingBean, Lifecycle, Phased, SmartLifecycle, MBeanExportOperations

@ManagedResource
public class BatchMBeanExporter
extends MBeanExporter
implements SmartLifecycle


Field Summary
static String DEFAULT_DOMAIN
           
 
Fields inherited from class org.springframework.jmx.export.MBeanExporter
AUTODETECT_ALL, AUTODETECT_ASSEMBLER, AUTODETECT_MBEAN, AUTODETECT_NONE
 
Fields inherited from class org.springframework.jmx.support.MBeanRegistrationSupport
registeredBeans, REGISTRATION_FAIL_ON_EXISTING, REGISTRATION_IGNORE_EXISTING, REGISTRATION_REPLACE_EXISTING, server
 
Constructor Summary
BatchMBeanExporter()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void doStart()
           
protected  void doStop()
           
protected  String getBeanKeyForJobExecution(String jobName)
          Encode the job name into an ObjectName in the form [domain]:type=JobExecution,name=[jobName].
protected  String getBeanKeyForStepExecution(String jobName, String stepName)
          Encode the job and step name into an ObjectName in the form [domain]:type=JobExecution,name=[jobName],step=[stepName].
protected  String getDefaultDomain()
          Help method for extensions which need access to the default domain.
 int getJobCount()
           
 int getJobExecutionCount()
           
 int getJobExecutionFailureCount()
           
 String[] getJobNames()
           
 int getPhase()
           
 int getStepCount()
           
 String[] getStepNames()
           
 boolean isAutoStartup()
           
 boolean isRunning()
           
protected  void registerBeans()
           
 void setDefaultDomain(String domain)
          The JMX domain to use for MBeans registered.
 void setJobExecutionMetricsFactory(JobExecutionMetricsFactory jobExecutionMetricsFactory)
          Factory for StepExecutionMetrics.
 void setJobService(JobService jobService)
           
 void setObjectNameStaticProperties(Map<String,String> objectNameStaticProperties)
          Static properties that will be added to all object names.
 void setRegisterSteps(boolean registerSteps)
          Flag to determine if any metrics at all should be exposed for step executions (default true).
 void setStepExecutionMetricsFactory(StepExecutionMetricsFactory stepExecutionMetricsFactory)
          Factory for JobExecutionMetrics.
 void start()
           
 void stop()
           
 void stop(Runnable callback)
           
 
Methods inherited from class org.springframework.jmx.export.MBeanExporter
adaptMBeanIfPossible, createAndConfigureMBean, createModelMBean, destroy, getObjectName, isBeanDefinitionLazyInit, isMBean, onRegister, onUnregister, registerBeanNameOrInstance, registerManagedResource, registerManagedResource, setAllowEagerInit, setAssembler, setAutodetect, setAutodetectMode, setAutodetectModeName, setBeanClassLoader, setBeanFactory, setBeans, setEnsureUniqueRuntimeObjectNames, setExcludedBeans, setExposeManagedResourceClassLoader, setListeners, setNamingStrategy, setNotificationListenerMappings, setNotificationListeners, unregisterManagedResource
 
Methods inherited from class org.springframework.jmx.support.MBeanRegistrationSupport
doRegister, doUnregister, getRegisteredObjectNames, getServer, onRegister, setRegistrationBehavior, setRegistrationBehaviorName, setServer, unregisterBeans
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DOMAIN

public static final String DEFAULT_DOMAIN
See Also:
Constant Field Values
Constructor Detail

BatchMBeanExporter

public BatchMBeanExporter()
Method Detail

setRegisterSteps

public void setRegisterSteps(boolean registerSteps)
Flag to determine if any metrics at all should be exposed for step executions (default true). Set to fals eto only expose job-level metrics.

Parameters:
registerSteps - the flag to set

setDefaultDomain

public void setDefaultDomain(String domain)
The JMX domain to use for MBeans registered. Defaults to org.springframework.batch (which is useful in SpringSource HQ).

Parameters:
domain - the domain name to set

getDefaultDomain

protected String getDefaultDomain()
Help method for extensions which need access to the default domain.

Returns:
the default domain used to construct object names

setJobService

public void setJobService(JobService jobService)

setObjectNameStaticProperties

public void setObjectNameStaticProperties(Map<String,String> objectNameStaticProperties)
Static properties that will be added to all object names.

Parameters:
objectNameStaticProperties - the objectNameStaticProperties to set

setStepExecutionMetricsFactory

public void setStepExecutionMetricsFactory(StepExecutionMetricsFactory stepExecutionMetricsFactory)
Factory for JobExecutionMetrics. Can be used to customize and extend the metrics exposed.

Parameters:
stepExecutionMetricsFactory - the StepExecutionMetricsFactory to set

setJobExecutionMetricsFactory

public void setJobExecutionMetricsFactory(JobExecutionMetricsFactory jobExecutionMetricsFactory)
Factory for StepExecutionMetrics. Can be used to customize and extend the metrics exposed.

Parameters:
jobExecutionMetricsFactory - the JobExecutionMetricsFactory to set

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class MBeanExporter

registerBeans

protected void registerBeans()
Overrides:
registerBeans in class MBeanExporter

getBeanKeyForJobExecution

protected String getBeanKeyForJobExecution(String jobName)
Encode the job name into an ObjectName in the form [domain]:type=JobExecution,name=[jobName].

Parameters:
jobName - the name of the job
Returns:
a String representation of an ObjectName

getBeanKeyForStepExecution

protected String getBeanKeyForStepExecution(String jobName,
                                            String stepName)
Encode the job and step name into an ObjectName in the form [domain]:type=JobExecution,name=[jobName],step=[stepName].

Parameters:
jobName - the name of the job
stepName - the name of the step
Returns:
a String representation of an ObjectName

getStepCount

@ManagedMetric(metricType=COUNTER,
               displayName="Step Count")
public int getStepCount()

getJobCount

@ManagedMetric(metricType=COUNTER,
               displayName="Job Count")
public int getJobCount()

getJobNames

@ManagedAttribute
public String[] getJobNames()

getStepNames

@ManagedAttribute
public String[] getStepNames()

getJobExecutionFailureCount

@ManagedMetric(metricType=COUNTER,
               displayName="Job Execution Failure Count")
public int getJobExecutionFailureCount()

getJobExecutionCount

@ManagedMetric(metricType=COUNTER,
               displayName="Job Execution Count")
public int getJobExecutionCount()

isAutoStartup

public final boolean isAutoStartup()
Specified by:
isAutoStartup in interface SmartLifecycle

getPhase

public final int getPhase()
Specified by:
getPhase in interface Phased

isRunning

public final boolean isRunning()
Specified by:
isRunning in interface Lifecycle

start

public final void start()
Specified by:
start in interface Lifecycle

stop

public final void stop()
Specified by:
stop in interface Lifecycle

stop

public final void stop(Runnable callback)
Specified by:
stop in interface SmartLifecycle

doStop

protected void doStop()

doStart

protected void doStart()


Copyright © 2011. All Rights Reserved.