[#ftl attributes={"generated.type":"blueprint.fragment"}]
<!-- 
	config for 
	objectId: [=configured]
	type: [=configuredType]
	pid: [=configurationPid]
	prefix: [=placeholderPrefix]
	
	configurables:
    [#if configurables??]
    [#list configurables as key, value]
        [=key] = [#if value?is_boolean][=value?c][#else][=value][/#if]
    [/#list]
    [/#if]	

	immutables;
    [#if immutables??]
    [#list immutables as key, value]
        [=key] = [=value]
    [/#list]
    [/#if]	
-->


	<bean id="[=configurationPid].defaults" class="ru.entaxy.platform.base.config.DefaultPropertiesProviderWithImmutables" activation="eager">
    	<argument index="0" type="java.lang.String" value="[=configured]"></argument>
    	<argument index="1" type="java.lang.String" value="[=configuredType]"></argument>
    	<argument index="2" type="java.lang.String" value="[=configurationPid]"></argument>
    	<argument index="3" type="org.osgi.framework.BundleContext" ref="blueprintBundleContext"></argument>
    	<argument index="4" type="java.util.Map">
    		<map key-type="java.lang.String" value-type="java.lang.Object">
				[#if configurables??]
			    [#list configurables as key, value]
	   			<entry key="[=key]" value="[#if value?is_boolean][=value?c][#else][=value][/#if]"></entry>
			    [/#list]
			    [/#if]
    		</map>
    	</argument>

		[#if immutables??]
    	<argument index="5" type="java.util.Map">
    		<map key-type="java.lang.String" value-type="java.lang.Object">
			    [#list immutables as key, value]
	   			<entry key="[=key]" value="[#if value?is_boolean][=value?c][#else][=value][/#if]"></entry>
			    [/#list]
    		</map>
    	</argument>
	    [/#if]
    	
	</bean>

    <cm:property-placeholder persistent-id="[=configurationPid]" update-strategy="reload" id="[=configurationPid].placeholder" 
    		placeholder-prefix="[=placeholderPrefix]" placeholder-suffix="}"
    		defaults-ref="[=configurationPid].defaults" 
    		xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
    </cm:property-placeholder>


	<!-- BEGIN placeholders for Camel -->
	<!-- make property placeholder available in Camel context -->
	
	<bean id="[=configurationPid].placeholder.wrapper" class="ru.entaxy.platform.core.support.runtime.camel.CmPropertiesAccessorFunction" activation="eager">
    	<property name="bundleContext" ref="blueprintBundleContext"/>
    	<property name="persistentId" value="[=configurationPid]" />
    	<property name="prefix" value="[=placeholderPrefix[1..placeholderPrefix?length-2]]" />
    	<property name="wrappedPlaceholder" ref="[=configurationPid].placeholder" />
    </bean>
    
	<propertyPlaceholder id="propertiesForCamel">
		<propertiesFunction ref="[=configurationPid].placeholder.wrapper"/>
	</propertyPlaceholder>	    
	
	<!-- END placeholders for Camel -->
