<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
       	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       	http://www.springframework.org/schema/aop
 		http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
	<import resource="simple-job-launcher-context.xml" />
	
	<!--  For Java 1.4 we need to ceate teh mbean server explicitly -->
	<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
		<property name="locateExistingServerIfPossible" value="true" />
	</bean>
	<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
		<property name="port" value="1099" />
	</bean>
	<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean">
		<property name="objectName" value="connector:name=rmi" />
		<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/batch-samples" />
		<property name="server" ref="mbeanServer" />
	</bean>
	<bean class="org.springframework.jmx.export.MBeanExporter">
		<property name="server" ref="mbeanServer" />
		<property name="beans">
			<map>
				<entry key="spring:service=batch,bean=jobLauncher">
					<bean class="org.springframework.batch.core.launch.support.SimpleExportedJobLauncher">
						<property name="launcher" ref="jobLauncher" />
						<property name="jobLocator" ref="jobRegistry" />
					</bean>
				</entry>
				<entry key="spring:service=batch,bean=notificationPublisher" value-ref="notificationPublisher" />
				<entry key="spring:service=batch,bean=jobLoader" value-ref="loader" />
			</map>
		</property>
		<property name="assembler">
			<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
				<property name="interfaceMappings">
					<map>
						<entry key="spring:service=batch,bean=jobLauncher" value="org.springframework.batch.core.launch.support.ExportedJobLauncher" />
						<entry key="spring:service=batch,bean=jobLoader" value="org.springframework.batch.sample.launch.JobLoader" />
					</map>
				</property>
			</bean>
		</property>
	</bean>
	<bean id="notificationPublisher" class="org.springframework.batch.sample.advice.JobExecutionNotificationPublisher" />
	<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
		<property name="jobRepository" ref="jobRepository" />
		<property name="taskExecutor">
			<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
		</property>
	</bean>
	<bean id="loader" class="org.springframework.batch.sample.launch.DefaultJobLoader">
		<property name="registry" ref="jobRegistry" />
	</bean>
</beans>