2012-03-20 7 views
0

ラクダのコンテキストで定義されたルート内で、サードパーティのライブラリに含まれる抽象クラスのメソッドにアクセスしたいのですが、私は使用しています。Spring DSLのCamel Contextバージョン(2.9.1)の抽象クラスのメソッドへのアクセス

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:camel="http://camel.apache.org/schema/spring" 
    xmlns:osgi="http://www.springframework.org/schema/osgi" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd 
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 


<bean id="objectFactory" class="org.example.Factory" abstract="true"/> 

<camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <route> 
     ... 
     <marshal> 
      <rss/> 
    </marshal> 
    <marshal> 
     <string/> 
    </marshal> 
     <to uri="jms:feeds"/> 
     <to uri="file:/tmp/output"/> 
     <!-- That is the point in the route where I would like to pass the URL of 
      the folder the files have been written to a static method of an abstract 
      class in order to instantiate an object 
     --> 
    </route> 
     ... 

上記のスニペットは、Spring DSLのルート定義と抽象Beanの定義を示しています。私は<bean>タグを使って私が望むことを達成しようとしましたが、これはいつもorg.springframework.beans.factory.BeanIsAbstractExceptionで終わります。 camelcontext内の抽象クラスの静的メソッドに単にアクセスする方法はありませんか?

答えて

1

メソッドは静的メソッドである場合は、これは我々が直接静的メソッドを呼び出すためのサポートを追加したキャメルのごく最近のバージョンを必要とすることがキャメルDSL直接

<bean type="org.example.Factory" method="myMethod"/> 

心でそれを可能に参照することができます。

+0

非常に迅速な回答ありがとうございます。メソッドの参照< ':私はキャメル春-DMの原型を使用していることを試してみました= "helloBean" ... "/> <ログメッセージ=" ... "/> <豆タイプ=" java.arrays」METHOD = "のtoString" /> 'これは私に 'org.xml.sax.SAXParseException'を与えます:' cvc-complex-type.3.2.2:属性 'type'は要素 'bean'に現れません。 '私はそれが仮定されている方法を誤解しましたか?使用するか? – user1281204

+0

はい内にはCamel名前空間があり、タグはルートからBeanを呼び出します。 –

1

抽象クラスを使用する最も簡単な方法は、抽象クラスを拡張する独自のクラスを定義してから呼び出すことです。次に、Clausのような通常のBean構文を使用できます。この場合、非静的メソッドも機能します。

関連する問題