使用SPeL的Spring Integration过滤器表达式

时间:2011-07-06 11:43:08

标签: spring-integration spring-el

我有一个配置bean,其中包含允许值列表:

@Component
public class Conf {
    public List<String> getAllowedValues() {
        return Arrays.asList("A", "B", "C", "D");
}

我已使用名为“someValue”的字段填充了我的邮件标题,并且我想使用过滤器元素来排除someValue不在允许值列表中的邮件。

我的上下文如下:

<int:filter expression="#{conf.allowedValues}.contains(headers.get('someValue'))"/>

但我明白了:SpelParseException: EL1041E:(pos 1): After parsing a valid expression, there is still more data in the expression: 'comma(,)'

2 个答案:

答案 0 :(得分:2)

答案是here

<int:filter expression="@conf.allowedValues.contains(headers.get('someValue'))"/>

答案 1 :(得分:0)

我得到了一个更简单(也许不是最好)的解决方案。

---
files:  
  "c:\\init_scripts\\install_cert.ps1":  
   content: |  
    $env = $args[0]   
    $pwd = $args[1]
    $securePwd = ConvertTo-SecureString -String $pwd -Force -asplaintext
    $certName="$($env).auth.cert.pfx"
    $certFilePath = "C:\$($certName)"
    Read-S3Object -BucketName ourcertsbucket -Key $certName -File $certFilePath
    $cert = Import-PfxCertificate -FilePath $certFilePath cert:\localmachine\my -Password $securePwd
    # Now that we have the cert we need to grant access to the IIS user for the cert
    Try
    {
      $WorkingCert = Get-ChildItem CERT:\LocalMachine\My |where {$_.Subject -match $env} | sort $_.NotAfter -Descending | select -first 1 -erroraction STOP
      $TPrint = $WorkingCert.Thumbprint
      $rsaFile = $WorkingCert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
    }
    Catch
    {
      "        Error: unable to locate certificate for $($env)"
      Exit
    }
    $keyPath = "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\"
    $fullPath=$keyPath+$rsaFile
    $acl=Get-Acl -Path $fullPath
    $permission="IIS_IUSRS","Read","Allow"
    $accessRule=new-object System.Security.AccessControl.FileSystemAccessRule $permission
    $acl.AddAccessRule($accessRule)
    Try 
    {
     Set-Acl $fullPath $acl
      "        Success: ACL set on certificate"
    }
    Catch
    {
      "        Error: unable to set ACL on certificate"
        Exit
    }
container_commands:  
  01_install_cert:  
   command: powershell -ExecutionPolicy RemoteSigned -File .\\install_cert.ps1 %Environment% %CertPassword% 
   cwd: c:\\init_scripts  
   waitAfterCompletion: 0

reference