<?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:context="http://www.springframework.org/schema/context"
	   xmlns:int-jmx="http://www.springframework.org/schema/integration/jmx"
	   xmlns:int="http://www.springframework.org/schema/integration"
	   xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/integration/jmx https://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

	<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>

	<context:mbean-export default-domain="foo" />

	<bean id="test" class="org.springframework.integration.monitor.RemoteMBeanServerTests$Tester" />

	<int-jmx:attribute-polling-channel-adapter
			server="clientConnector"
			attribute-name="Foo"
			object-name="foo:name=test,type=RemoteMBeanServerTests.Tester"
			channel="attrChannel">
		<int:poller fixed-rate="2000" />
	</int-jmx:attribute-polling-channel-adapter>

	<int:channel id="attrChannel">
		<int:queue />
	</int:channel>

	<int:channel id="opChannel" />

	<int-jmx:operation-invoking-outbound-gateway
		server="clientConnector"
		operation-name="fooBar"
		object-name="foo:name=test,type=RemoteMBeanServerTests.Tester"
		request-channel="opChannel"
		reply-channel="opOutChannel" />

	<int:channel id="opOutChannel">
		<int:queue />
	</int:channel>

	<int:channel id="publishChannel" />

	<int-jmx:notification-publishing-channel-adapter
		channel="publishChannel"
		object-name="foo:name=pub"
		default-notification-type="foo" />

	<int-jmx:notification-listening-channel-adapter
		server="clientConnector"
		channel="publishInChannel"
		object-name="foo:name=pub"/>

	<int:channel id="publishInChannel">
		<int:queue />
	</int:channel>

	<!--
		To test against the MBeanServerConnection instead of the (default) MBeanServer, use
			 -Dspring.profiles.active=remote
			 -Dcom.sun.management.jmxremote.port=11099<p/>
			 -Dcom.sun.management.jmxremote.authenticate=false<p/>
			 -Dcom.sun.management.jmxremote.ssl=false<p/>

		The CI build runs with the default profile.
	 -->

	<!-- 	Commented out for Spring 3.0.x backwards compatibility

			<beans profile="remote">
				<bean id="clientConnector" class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
					<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:11099/jmxrmi"/>
				</bean>
			</beans>

			<beans profile="default">
				<context:mbean-server id="clientConnector"/>
			</beans>
	-->

	<context:mbean-server id="clientConnector"/>

</beans>
