2016-03-22 9 views
2

Ich habe ein blueprint.xml für ein Kamel App in Karaf 3.5.6 unter ServiceMix eingesetzt, die etwas ähnlich sieht, was unten dargestellt: -Wie man eine große karaf blueprint.xml organisiert?

<?xml version="1.0" encoding="UTF-8"?> 
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
    license agreements. See the NOTICE file distributed with this work for additional 
    information regarding copyright ownership. The ASF licenses this file to 
    You under the Apache License, Version 2.0 (the "License"); you may not use 
    this file except in compliance with the License. You may obtain a copy of 
    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
    by applicable law or agreed to in writing, software distributed under the 
    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
    OF ANY KIND, either express or implied. See the License for the specific 
    language governing permissions and limitations under the License. --> 

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" 
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
    xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> 

    <bean id="jsonRPCProcessor" 
     class="com.orchestratorservice.basecomponent.processor.JSONRPCProcessor"> 
     <argument ref="myTemplate" /> 
     <argument> 
      <map> 

       <!-- Order Endpoints --> 
       <entry key="getMarketplaceOrders" value-ref="getOrdersWFInfo" /> 
       <entry key="setStatusToReadyToShip" value-ref="setStatusToReadyToShipWFInfo" /> 
       <entry key="getOrderItemStatus" value-ref="getOrderItemStatusWFInfo" /> 
       <entry key="updateItemStatus" value-ref="updateOrderItemStatusWFInfo" /> 
       <entry key="createForwardManifest" value-ref="createForwardManifestWFInfo" /> 

       <!-- ERP Endpoints --> 
       <entry key="ERP.insertSeller" value-ref="insertSellerWFInfo" /> 

      </map> 
     </argument> 
     <argument ref="exceptionHandler" /> 
    </bean> 

    <!-- Order Beans --> 

    <bean id="orderErrorResponseGenerator" 
     class="com.orchestratorservice.adapter.order.OrderErrorResponseGenerator"></bean> 

    <bean id="getOrdersWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:getMarketplaceOrders" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.request.GetMarketplaceOrdersRequest" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.response.OrderResponse" /> 
     <argument ref="orderErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>100</value> 
       <value>101</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="setStatusToReadyToShipWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:setStatusToReadyToShip" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.request.UpdateOrderStatusReadyShipRequest" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.response.OrderResponse" /> 
     <argument ref="orderErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>110</value> 
       <value>111</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="getOrderItemStatusWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:getOrderItemStatus" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.request.GetOrderItemStatusRequest" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.response.OrderResponse" /> 
     <argument ref="orderErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>120</value> 
       <value>131</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="updateOrderItemStatusWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:updateItemStatus" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.request.UpdateOrderItemStatusRequest" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.response.UpdateOrderItemStatusResp" /> 
     <argument ref="orderErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>140</value> 
       <value>151</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="createForwardManifestWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:createForwardManifest" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.request.CreateFwdManifestReq" /> 
     <argument 
      value="com.orchestratorservice.adapter.order.response.OrderResponse" /> 
     <argument ref="orderErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>151</value> 
       <value>160</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="orderHelper" 
     class="com.orchestratorservice.adapter.order.OrderHelper"> 
     <property name="producer" ref="myTemplate" /> 
    </bean> 



    <!-- ERP Beans --> 
    <bean id="erpErrorResponseGenerator" 
     class="com.orchestratorservice.adapter.erp.ERPErrorResponseGenerator"></bean> 

    <bean id="insertSellerWFInfo" 
     class="com.orchestratorservice.basecomponent.processor.WFInfo"> 
     <argument value="direct:insertSeller" /> 
     <argument 
      value="com.orchestratorservice.adapter.erp.request.InsertSellerRequest" /> 
     <argument 
      value="com.orchestratorservice.adapter.erp.response.InsertSellerResponse" /> 
     <argument ref="erpErrorResponseGenerator" /> 
     <argument> 
      <list> 
       <value>10</value> 
       <value>11</value> 
      </list> 
     </argument> 
    </bean> 

    <bean id="erpHelper" class="com.orchestratorservice.adapter.erp.ERPHelper"> 
     <property name="producer" ref="myTemplate" /> 
    </bean> 



    <cm:property-placeholder persistent-id="wf" 
     update-strategy="none"> 
     <cm:default-properties> 
      <cm:property name="order_update_item_status_sc_apiver" 
       value="1" /> 
      <cm:property name="target_image_width" value="1400" /> 
      <cm:property name="target_image_height" value="1025" /> 

     </cm:default-properties> 
    </cm:property-placeholder> 


    <!-- a bean that uses a blueprint property placeholder --> 

    <bean id="configBean" 
     class="com.orchestratorservice.basecomponent.config.ConfigBean"> 
     <property name="order_update_item_status_sc_apiver" value="${order_update_item_status_sc_apiver}" /> 
     <property name="target_image_width" value="${target_image_width}" /> 
     <property name="target_image_height" value="${target_image_height}" /> 
    </bean> 

    <camelContext xmlns="http://camel.apache.org/schema/blueprint" 
     useMDCLogging="true"> 
     <template id="myTemplate" /> 
     <route id="orchestrator-service-route"> 
      <from uri="jetty:http://0.0.0.0:8888/orchestratorservice" /> 
      <process ref="jsonRPCProcessor" /> 
     </route> 

     <!-- Order Routes --> 
     <route id="get-orders-workflow"> 
      <from uri="direct:getMarketplaceOrders" /> 
      <to uri="bean:orderHelper?method=getMarketplaceOrders" /> 
     </route> 
     <route id="set-status-readytoship-workflow"> 
      <from uri="direct:setStatusToReadyToShip" /> 
      <to uri="bean:orderHelper?method=setStatusToReadyToShip" /> 
     </route> 
     <route id="get-order-itemstatus-workflow"> 
      <from uri="direct:getOrderItemStatus" /> 
      <to uri="bean:orderHelper?method=getOrderItemStatus" /> 
     </route> 
     <route id="update-order-itemstatus-workflow"> 
      <from uri="direct:updateItemStatus" /> 
      <to uri="bean:orderHelper?method=updateItemStatus" /> 
     </route> 
     <route id="create-forward-manifest-workflow"> 
      <from uri="direct:createForwardManifest" /> 
      <to uri="bean:orderHelper?method=createForwardManifest" /> 
     </route> 

     <!-- ERP routes --> 
     <route id="insert-seller-workflow"> 
      <from uri="direct:insertSeller" /> 
      <to uri="bean:erpHelper?method=insertSeller" /> 
     </route> 
    </camelContext> 
</blueprint> 

Im Entwurf wir verschiedene Workflows Module definiert (zum Beispiel in der oben haben blueprint.xml - order & ERP). Im Moment haben wir eine einzige blueprint.xml, wo wir alle unsere Workflows definieren. Das ist ziemlich groß geworden (ungefähr 1000 Zeilen und wir werden mehr hinzufügen).

Kann jemand mir bitte wissen lassen

  1. Wie organisieren Menschen blueprint.xml groß wie oben?
  2. Ist es möglich, verschiedene xmls (zum Beispiel in meinem Fall eine andere xml für order & erp Modul) und eine einzige Mutter Xml, die alle Kind Xmls kombiniert?
+0

Wenn Ihre Blueprint-Datei so groß ist, dann denke ich, dass Ihr Bundle zu viele Dinge macht und geteilt werden sollte. –

Antwort

3

Alle Metadaten aus den Bauplan Dateien, die von dem Bundle referenziert werden geladen und miteinander verschmolzen:

  • Sie können dies mehrere kleine Dateien in Dateien aufgeteilt
  • ich in der Regel die Definitionen nach Themen aufgeteilt: In Ihrem Fall, wahrscheinlich eine Datei mit der Kamel-Route, eine andere mit der Konfiguration von ConfigurationAdmin, etc.
  • Widder-Blueprint hat eine Erweiterung mit Introspections/Anmerkungen, die mit der Größe solcher Dateien helfen können
+0

Können Sie einige Beispiele oder Links teilen, in denen das Beispiel der Dateiaufteilung gezeigt wird? Kannst du auch etwas mehr über die Introspektionen/Annotationen erklären? – tuk

+0

Ich spaltete die Datei nach Thema ... alle Kamel Routen in einer Datei, alle Prozessoren in einer Datei und separate Xml für alle Beans in einem Modul wie ein separates XML für alle 'Reihenfolge' Bohnen, etc, – tuk

Verwandte Themen