<?xml version="1.0" encoding="UTF-8"?>
<caf:beans
   xmlns:caf="http://schemas.vmware.com/caf/schema/fx"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://schemas.vmware.com/caf/schema/fx http://10.25.57.32/caf-downloads/schema/fx/CafIntegration.xsd">

   <import resource="IntBeanConfigFile.xml"/>

   <!-- <channel id="logger"/> -->
   <!-- <int:logging-channel-adapter channel="logger" log-full-message="true" level="INFO"/> -->
   <!-- <int:wire-tap channel="logger" pattern="*"/> -->

   <!-- Listener Infrastructure -->

   <bean
      id="amqpIntegrationObjects"
      class="com.vmware.caf.comm.integration.objects" />

   <bean
      id="replyToResolver"
      class="com.vmware.caf.comm.integration.replytoresolver"/>

   <bean
      id="eventTopicCalculator"
      class="com.vmware.caf.comm.integration.eventtopiccalculator"/>

   <bean
      id="outgoingMessageHandler"
      class="com.vmware.caf.comm.integration.outgoingmessagehandler"/>

   <bean
      id="headerExprInvoker"
      class="com.vmware.commonagent.integration.headerexpressioninvoker" />

   <bean
      id="cmsMessageTransformerBean"
      class="com.vmware.caf.comm.integration.cmsmessagetransformer">
      <property name="cmsPolicy" value="${var:security:cms_policy}"/>
      <property name="isSigningEnforced" value="${var:security:is_signing_enforced}"/>
      <property name="isEncryptionEnforced" value="${var:security:is_encryption_enforced}"/>
   </bean>

   <bean
      id="incomingMessageHandlerBean"
      class="com.vmware.caf.comm.integration.incomingmessagehandler"/>

   <bean
      id="replyToCacherBean"
      class="com.vmware.caf.comm.integration.replytocacher"/>

   <bean
      id="payloadHeaderEnricherBean"
      class="com.vmware.commonagent.cafintegration.payloadheaderenricher" >
      <property name="includeFilename" value="false"/>
   </bean>

   <!-- Outbound messages -->
   <channel id="responseFileChannel" />
   <channel id="managementMessageOutboundAmqp" />

   <file-inbound-channel-adapter
      id="responseInboundChannel"
      auto-create-directory="true"
      filename-regex=".*\.xml"
      directory="${var:globals:response_dir}"
      channel="responseFileChannel" />

   <chain
      id="responseChain"
      input-channel="responseFileChannel"
      output-channel="managementMessageOutboundAmqp" >
      <file-to-string-transformer
         id="responseFileToString"
         charset="UTF-8"
         delete-files="true" />
      <transformer
         id="payloadHeaderEnricher"
         ref="payloadHeaderEnricherBean"/>
      <header-enricher
         id="responseHeaderEnricher">
         <header
            name="replyTo"
            expression="@replyToResolver.lookupReplyTo()"/>
         <header
            name="cafcomm.internal.msgflow"
            value="OUTGOING"/>
      </header-enricher>
      <transformer
         id="outgoingCmsMessageTransformerId"
         ref="cmsMessageTransformerBean"/>
      <service-activator
         id="outgoingMessageServiceActivator"
         ref="outgoingMessageHandler"/>
   </chain>

   <!-- proactive messages -->
   <channel id="eventFileChannel" />
   <channel id="eventOutFileChannel" />
   <file-inbound-channel-adapter
      id="eventInboundChannel"
      auto-create-directory="true"
      filename-regex=".*\.xml"
      directory="${var:globals:event_dir}"
      channel="eventFileChannel" />

   <chain
      id="eventChain"
      input-channel="eventFileChannel"
      output-channel="eventOutFileChannel">

      <file-to-string-transformer
         id="eventFileToString"
         charset="UTF-8"
         delete-files="true" />

      <transformer
         id="payloadHeaderEnricher"
         ref="payloadHeaderEnricherBean"/>

      <header-enricher
         id="eventHeaderEnricher">
         <header
            name="cafcomm.internal.msgflow"
            value="OUTGOING"/>

      </header-enricher>

      <transformer
         id="outgoingCmsMessageTransformerId"
         ref="cmsMessageTransformerBean"/>
   </chain>

   <!-- Inbound messages -->
   <channel id="managementInboundAmqp" />
   <channel id="managementInboundChannel" />

   <chain
      id="requestChain"
      input-channel="managementInboundAmqp"
      output-channel="managementInboundChannel">

      <header-enricher
         id="requestEnricher">
         <header
            name="cafcomm.internal.msgflow"
            value="INCOMING"/>
      </header-enricher>

      <transformer
         id="requestIncomingMessageHandler"
         ref="incomingMessageHandlerBean"/>

      <transformer
         id="payloadHeaderEnricher"
         ref="payloadHeaderEnricherBean"/>

      <transformer
         id="requestReplyToCacher"
         ref="replyToCacherBean"
         reply-to-resolver="replyToResolver"/>

      <transformer
         id="incomingCmsMessageTransformerId"
         ref="cmsMessageTransformerBean"/>
   </chain>

   <file-outbound-channel-adapter
      id="requestOutboundChannel"
      channel="managementInboundChannel"
      auto-create-directory="true"
      delete-source-files="true"
      charset="UTF-8"
      directory="${var:globals:request_dir}"
      temporary-file-suffix=".tmp" />

   <!-- Stores the error information from the default error channel into the respose directory. -->
   <channel id="fileSenderErrChannel"/>
   <bean
      id="errorToResponseTransformerBean"
      class="com.vmware.commonagent.cafintegration.errortoresponsetransformer" />
   <chain
      id="responseErrorChain"
      input-channel="errorChannel"
      output-channel="fileSenderErrChannel">

      <!-- Convert the error information into an error response message. -->
      <transformer
         id="errorToResponseTransformer"
         ref="errorToResponseTransformerBean"/>
   </chain>

   <!-- Store the response into the responses directory. In normal processing, the responses
          directory is monitored by the listener process, which sends the responses back to
          the client. -->
   <file-outbound-channel-adapter
      id="responseErrFileOutbound"
      channel="fileSenderErrChannel"
      directory="${var:globals:response_dir}"
      delete-source-files="true" />
</caf:beans>
