2016-10-13 3 views
0

apiKitルーティングメッセージを処理する際に、検証コンポーネントを使用して、私のミュールメッセージの主要なデータを検証しています。Mule apiKitGlobalExceptionMapping ValidationExceptionがスローされない

例外クラスは、apiキットのグローバル例外コンポーネントでキャッチできますが、例外は常にカスタムクラスではなくorg.mule.api.MessagingExceptionになります。

私は、APIキットグローバル例外要素に分離することが検証コンポーネントから私の例外を取得するために何をすべきかが必要ですか?以下の私の検証例外コンポーネントです:

package com.comMyAppy.rules; 
import com.comMyAppy.rules.MyAppValidationException; 
import org.mule.api.MuleEvent; 
import org.mule.extension.validation.api.ExceptionFactory; 
import org.mule.extension.validation.api.ValidationResult; 

public class MyAppValidationExceptionFactory implements ExceptionFactory 
{ 

    @SuppressWarnings("unchecked") 
    @Override 
    public <T extends Exception> T createException(ValidationResult result, 
      Class<T> exceptionClass, MuleEvent event) 
    { 
     // TODO Auto-generated method stub 
     return (T) new MyAppValidationException(result, event); 
    } 

    @Override 
    public Exception createException(ValidationResult result, 
      String exceptionClassName, MuleEvent event) 
    { 
     // TODO Auto-generated method stub 
     return new MyAppValidationException(result, event); 
    } 

} 

ここでは、私の例外クラスです:私は間違っ

package com.comMyAppy.rules; 
import org.mule.api.MuleEvent; 
import org.mule.config.i18n.Message; 
import org.mule.extension.validation.api.ValidationException; 
import org.mule.extension.validation.api.ValidationResult; 
@SuppressWarnings("serial") 
public class MyAppValidationException extends ValidationException 
{ 

    public MyAppValidationException(ValidationResult validationResult, 
      MuleEvent event) 
    { 
     super(validationResult, event); 
     // TODO Auto-generated constructor stub 
    } 

    @Override 
    protected String generateMessage(Message message) 
    { 
     return "VALIDATION:" + message.getMessage(); 
    } 

} 

何をしているのですか?

+0

note検証:すべてのコンポーネントを使用しています –

+0

検証設定を共有できますか? –

+0

私はすべての検証者が私が投げたいカスタム例外を食べていることを理解しました –

答えて

0

私は私の問題が何であったかを考え出し:私は検証を使用していた。ちょうど別のバリデータの全ての間のメッセージのすべてを集約し、効率的に私の検証の設定を無視してmessageExceptionを投げたすべてのコンポーネントを、。私のアドバイス:すべてのバリデーターを避けてください。それは良いと思うが、カスタム例外能力を失う。

+0

どうやってそれを避けますか?あなたは何を代わりに使ったのですか? –

+0

ちょっと@ItzHoudini私はALLバリデーターに持っていたバリデーターをそれぞれ別々にリストアップしました。それはWISWIGエディタで恐ろしいxmlのフィンに見えますが、少なくとも期待どおりに動作します。 –

関連する問題