<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mule-configuration PUBLIC "-//MuleSource // DTD mule-configuration XML V1.0//EN" "http://mule.mulesource.org/dtds/mule-configuration.dtd">

<mule-configuration id="SWFRenderer" version="1.0">
  <connector name="TriggerFileConnector" className="org.mule.providers.file.FileConnector">
    <properties>
      <property name="pollingFrequency" value="5000" />
    </properties>
  </connector>

  <endpoint-identifiers>
    <endpoint-identifier name="LPSDrop"         value="http://localhost:8016/lpsdrop" />
    <endpoint-identifier name="SourceFiles"     value="file://./sources" />
    <endpoint-identifier name="CompiledFiles"   value="file://./triggers" />
    <endpoint-identifier name="CRXDrop"         value="http://authoring.pkg.com/" />
  </endpoint-identifiers>

  
  <transformers>
    <transformer name="POSTToHashMap" className="com.pkg.transformers.POSTToHashMap" returnClass="java.util.HashMap" />
  </transformers>
  

  <model name="SWFRenderingEngine">
    <mule-descriptor name="FileRetrievalService" implementation="com.pkg.services.FileRetriever">
      <inbound-router>
          <endpoint address="LPSDrop" synchronous="true" />
      </inbound-router>

      <properties>
        <!--
          These properties are specific to my custom UMO, FileRetriever.

          The FileRetriever component implements HttpClient to get the files from the remote server.  It
          uses the HttpClient that ships with Mule, since it's available in the lib/opt directory.  The
          FileRetriever gets a list of components in an HTTP POST request; the request may also contain
          other data that FileRetriever will ignore, but saved as key/value pairs to the targetDir, in 
          case Mule or some other application know the context for those data and need it.

          POST request sample:

          fileCount=2&file0=graphics.gif&file1=program.lzx&extraData1=42&extraData2=69

          Required properties: server, targetDir
          Optional properties: port, user, password

          The user and password credentials are used for the specific server.  These credentials will
          not apply if the service request provides file lists in other servers that require 
          authentication.
        -->
        <property name="server"      value="authoring.pkg.com" />
        <property name="port"        value="80" />
        <property name="user"        value="masterdude" />
        <property name="password"    value="gu3ssi++" />
        <property name="targetDir"   value="./sources" />
      </properties>
    </mule-descriptor>

    <mule-descriptor name="SWFCompilationService" implementation="com.pkg.services.SWFCompiler">
      <inbound-router>
        <endpoint address="SourceFiles">
          <filter pattern="program.lzx" className="org.mule.providers.file.filters.FilenameWildcardFilter" />
        </endpoint>
      </inbound-router>

      <properties>
        <!-- 
          The SWFCompiler UMO is invoked when the program.lzx file is found at the SourceFiles endpoint.
          This is independent of the FileRetriever, which is a separate service object.  This way we can
          have complete decoupling between file retrieval operations and compilation operations.

          Before compiling program.lzx, this UMO will rename it hero.lzx; this was an implementation
          decision based on the input parameters required by the OpenLaszlo compiler and to meet the
          Compiler mixin/interface spec discussed in the presentation slides.
        -->
        <property name="sourceDir"  value="./sources" />
        <property name="objectDir"  value="./triggers" />
        <property name="sourceFile" value="hero.lzx" />
        <property name="objectFile" value="hero.swf" />
        
        <!--
          These properties are required by the OpenLaszlo implementation and passed 1:1 to it by
          the UMO.  They have no semantics with regards to the SWFCompilationService UMO or the
          Mule model.  Garbage in, garbage out.
        -->
        <property name="cacheDir"   value="./cache" />
        <property name="LPSHome"    value="/home/mule/opt/vendor/lps-4.0.3" />
      </properties>
    </mule-descriptor>
  </model>
</mule-configuration>


