1

要求されたメソッドの引数で示されているように、ペイロードを基本クラスにキャストするメソッド エントリ ポイント リゾルバーを取得しようとしています。しかし、Mule はそうではありません。私は何が間違っているのでしょうか?

つまり、次の構成が与えられます。

<mule ...>
    <spring:bean id="FooBean" class="foo.Foo" />

    <flow name="test">
        <vm:inbound-endpoint name="test.Name" path="test.Path" exchange-pattern="request-response" />

        <component>
            <method-entry-point-resolver>
                <include-entry-point method="bar" />
            </method-entry-point-resolver>
            <spring-object bean="FooBean" />
        </component>        
    </flow>
</mule>

与えられた foo.Foo:

package foo;

public class Foo {

    public Foo() {
    }

    public String bar(final Object anObject) {
        return "bar";
    }

}

次のテストに合格することを期待していますが、そうではありません。つまり、フローに送信するペイロードは であり、IntegerMule がそれを引数として に渡すことを期待していますFoo::bar

@Test
public void methodEntryPointResolverUpcasts() throws MuleException {
    final MuleClient client = muleContext.getClient();
    final MuleMessage reply = client.send("vm://test.Path", new Integer(1), null, RECEIVE_TIMEOUT);
    assertEquals("bar", reply.getPayload());
}

代わりに、ログにエラーが表示されます。関連するスニペットは次のとおりです。


...
Message               : Failed to find entry point for component, the following resolvers tried but failed: [
ExplicitMethodEntryPointResolver: Could not find entry point on: "foo.Foo" with arguments: "{class java.lang.Integer}"
]
...
Exception stack is:
1. Failed to find entry point for component, the following resolvers tried but failed: [
ExplicitMethodEntryPointResolver: Could not find entry point on: "foo.Foo" with arguments: "{class java.lang.Integer}"

4

1 に答える 1

3

Mule のエントリ ポイント リゾルバーは、キャスト自体は実行しません。特定のペイロードを受け入れる可能性のあるメソッドを探します。

つまり、が機能するにmethod-entry-point-resolverは厳密なタイプ マッチングが必要です。バックグラウンドでは、ExplicitMethodEntryPointResolver.java で、それを支えるクラスである次の行を見つけます。

if (ClassUtils.compare(parameterTypes, classTypes, false, true))

there は、falseObject で一致しないことを意味します。これが、マッチングが機能しない理由です。残念ながら、これは設定できません。

エントリポイントリゾルバの明示的な設定を削除すると、Mule はreflection-entry-point-resolver. これは、ReflectionEntryPointResolver.java で Integer を Object 引数に喜んで渡すものです。

methods = ClassUtils.getSatisfiableMethods(component.getClass(), 
            ClassUtils.getClassTypes(payload), true, true, ignoredMethods);

2 番目の true は、オブジェクトに一致することを意味します。

したがって、構成で単一のエントリ ポイント リゾルバーを指定する場合は、これreflection-entry-point-resolverが友達です :)

于 2012-05-01T17:27:58.990 に答える