2017-06-13 4 views
1

Ich versuche, einige Attribute mit Wert in Blueprint zu initialisieren. Die Eigenschaft cm: kann jedoch nur initialisiert werden, wenn die Route aufgerufen wird. Aber ich möchte initialisieren, wenn die Bean erstellt wird, ohne Route zu nennen. Was soll ich machen?Blueprint-Eigenschaften ohne Aufruf der Route

<?xml version="1.0" encoding="UTF-8"?> 
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:config="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"> 

    <!-- define configuration properties --> 
    <cm:property-placeholder persistent-id="com.tommyqu.common" update-strategy="reload"> 
     <cm:default-properties> 
      <cm:property name="activemq.group.name" value="edpDev" /> 
      <cm:property name="event.destinationQueue" value="edp-event" /> 
     </cm:default-properties> 
    </cm:property-placeholder> 

    <bean id="eventBean" class="com.tommyqu.EventBean"> 
     <property name="queueGroupName" value="${activemq.group.name}" /> 
     <property name="eventQueueName" value="${event.destinationQueue}" /> 
    </bean> 
</blueprint> 
+0

Können Sie besser erklären, was Ihr Problem ist, ist es unklar –

+0

@Claus Ibsen Ich versuche, den Wert von Eigenschaften in Java zu injizieren. Mit dem obigen Code wird der Java-Ausgabewert dieser Eigenschaften null sein. – TommyQu

+0

@Claus Ibsen Ich habe bereits die Setter-Funktionen erstellt. – TommyQu

Antwort

1

Ich denke, es ist nicht zwingend eine Route zu erklären, aber die Eigenschaft Injektion wird nur funktionieren, wenn Sie eine CamelContext einrichten.

Sie können versuchen, einen leeren Camel Kontext wie folgt zu erklären:

<?xml version="1.0" encoding="UTF-8"?> 
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:config="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"> 

    <!-- define configuration properties --> 
    <cm:property-placeholder persistent-id="com.tommyqu.common" update-strategy="reload"> 
     <cm:default-properties> 
      <cm:property name="activemq.group.name" value="edpDev" /> 
      <cm:property name="event.destinationQueue" value="edp-event" /> 
     </cm:default-properties> 
    </cm:property-placeholder> 

    <camelContext xmlns="http://camel.apache.org/schema/blueprint"> 
    <!-- No routes declared --> 
    </camelContext> 

    <bean id="eventBean" class="com.tommyqu.EventBean"> 
     <property name="queueGroupName" value="${activemq.group.name}" /> 
     <property name="eventQueueName" value="${event.destinationQueue}" /> 
    </bean> 
</blueprint> 

In diesem Fall müssen Sie nicht über eine Route, aber sie erklären den Kontext, so dass Eigentum Ersatz auftreten kann.

+0

Cool! Habe es einfach funktioniert. – TommyQu

Verwandte Themen