? <!-- the JBI container -->
? <container id="jbi">
? <property name="useMBeanServer" value="true"/>
? <property name="createMBeanServer" value="true"/>
? <property name="dumpStats" value="true"/>
? <property name="statsInterval" value="10"/>
???? <components>
???? <!-- Write files to the outbox directory -->
????? <component id="fileSender"?? service="foo:fileSender"???? class="org.servicemix.components.file.FileWriter">
????? <property name="directory" value="outbox"/>
????? <property name="marshaler">
????? <bean? class="org.servicemix.components.util.DefaultFileMarshaler">
????? <property name="fileName">
????? <bean class="org.servicemix.expression.JaxenStringXPathExpression">
????? <constructor-arg value="concat('sample_', /sample/@id, '.xml')"/>
????? </bean>
????? </property>
?????? </bean>
????? </property>
?? </component>
?? <!-- Look for files in the inbox directory -->
??? <component id="filePoller" service="foo:filePoller"? class="org.servicemix.components.file.FilePoller"?? destinationService="foo:fileSender">
????? <property name="workManager"? ref="workManager"/>
????? <property name="file" value="inbox"/>
????? <property name="period" value="1000"/>
??? </component>??
?? </components>???
?</container>
? <!-- the work manager (thread pool)? for this container -->
? <bean id="workManager"? class="org.jencks.factory.WorkManagerFactoryBean">
????? <property name="threadPoolSize"? value="30"/>
? </bean>
</beans>
?
JBI規格說明書本身并沒有定義構件應該如何編碼。請注意,ServiceMix用XML風格的語法定義了兩個核心構件,關聯到特定的類和屬性。在把這種結構部署到ServiceMix以后,環境就會創建一種查詢構件,負責從系統和其它構件中讀取存檔信息,然后把讀取的值返回到文件系統。
該文件系統是JBI中非常基本的場景,因為信息就是從JBI環境(NMR)原樣集中的,然后被返回到同樣類型的綁定(文件系統)。但是很明顯,一旦JBI環境有能力把任何業務邏輯適配成數據,例如BPEL或schema validation,然后重定向到其它類型的綁定,例如HTTP或RSS,那么就不只是返回到文件系統了。
正如你意識到的一樣,當一用到JBI,操縱及分發數據的可能性就很大,但即使JBI用Java的方法實現了SOA,JSR-208規格說明書還是受到了批評。IBM和BEA是Java/J2EE領域的兩個主要推動者,他們就不支持這個新項目。盡管如此,還是有像ServiceMix這樣的小項目開發者和一些閉源開發組織打賭,一個培育良好的JBI市場將和J2EE的情況差不多。
假如你正在Java中使用Web services或者為了復雜的集成任務使用基于消息的設計,你應該對JBI的進展特別關心,因為它能為執行這樣的任務提供更健壯的平臺。就算你對JBI/ESB是否能加入J2EE協議棧還存有懷疑,繼續關注還是有幫助的,因為它可能會成為應用服務器領域像Spring那樣的事實上的“第三容器”或輕量級的容器擴展,為Java提供SOA能力。