<?xml version="1.0"?>

<beans
	default-destroy-method="destroy"
	default-init-method="afterPropertiesSet"
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"
>

	<!-- Advice -->

	<aop:config>
		<aop:aspect ref="messagingProxyAdvice">
			<aop:around pointcut="bean(com.liferay.portal.scripting.ScriptingProxyBean)" method="invoke" />
		</aop:aspect>
	</aop:config>

	<!-- Proxy -->

	<bean id="com.liferay.portal.scripting.ScriptingProxyBean" class="com.liferay.portal.scripting.ScriptingProxyBean">
		<property name="singleDestinationSynchronousMessageSender">
			<bean class="com.liferay.portal.kernel.messaging.sender.DefaultSingleDestinationSynchronousMessageSender">
				<property name="destinationName" value="liferay/scripting" />
				<property name="synchronousMessageSender" ref="com.liferay.portal.kernel.messaging.sender.DirectSynchronousMessageSender" />
			</bean>
		</property>
		<property name="singleDestinationMessageSender">
			<bean class="com.liferay.portal.kernel.messaging.sender.DefaultSingleDestinationMessageSender">
				<property name="destinationName" value="liferay/scripting" />
				<property name="messageSender" ref="com.liferay.portal.kernel.messaging.sender.MessageSender" />
			</bean>
		</property>
	</bean>

	<!-- Util -->

	<bean class="com.liferay.portal.kernel.scripting.ScriptingUtil">
		<property name="scripting" ref="com.liferay.portal.scripting.ScriptingProxyBean" />
	</bean>

	<!-- Implementation  -->

	<bean id="com.liferay.portal.scripting.ScriptingImpl" class="com.liferay.portal.scripting.ScriptingImpl">
		<property name="scriptingExecutors">
			<map>
				<entry key="beanshell">
					<bean class="com.liferay.portal.scripting.beanshell.BeanShellExecutor" />
				</entry>
				<entry key="groovy">
					<bean class="com.liferay.portal.scripting.groovy.GroovyExecutor" />
				</entry>
				<entry key="javascript">
					<bean class="com.liferay.portal.scripting.javascript.JavaScriptExecutor" />
				</entry>
				<entry key="python">
					<bean class="com.liferay.portal.scripting.python.PythonExecutor" />
				</entry>
				<entry key="ruby">
					<bean class="com.liferay.portal.scripting.ruby.RubyExecutor" />
				</entry>
			</map>
		</property>
	</bean>

	<!-- Messaging -->

	<bean id="destination.scripting" class="com.liferay.portal.kernel.messaging.SynchronousDestination">
		<property name="name" value="liferay/scripting" />
	</bean>
	<bean id="messageListener.scripting" class="com.liferay.portal.kernel.messaging.proxy.ProxyMessageListener">
		<property name="manager" ref="com.liferay.portal.scripting.ScriptingImpl" />
	</bean>
	<bean id="messageListener.scripting_cluster" class="com.liferay.portal.kernel.cluster.messaging.ClusterBridgeMessageListener">
		<property name="priority">
			<util:constant static-field="com.liferay.portal.kernel.cluster.Priority.LEVEL5" />
		</property>
	</bean>
	<bean id="messagingConfigurator.scripting" class="com.liferay.portal.kernel.messaging.config.DefaultMessagingConfigurator">
		<property name="destinations">
			<list>
				<ref bean="destination.scripting" />
			</list>
		</property>
		<property name="messageBus">
			<ref bean="com.liferay.portal.kernel.messaging.MessageBus" />
		</property>
		<property name="messageListeners">
			<map key-type="java.lang.String" value-type="java.util.List">
				<entry key="liferay/scripting">
					<list value-type="com.liferay.portal.kernel.messaging.MessageListener">
						<ref bean="messageListener.scripting" />
						<!--<ref bean="messageListener.scripting_cluster" />-->
					</list>
				</entry>
			</map>
		</property>
	</bean>
</beans>