[
https://issues.apache.org/jira/browse/SLING-6021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15455891#comment-15455891
]
Ivo Leitão commented on SLING-6021:
-----------------------------------
Hi thank you for the detailed feedback.
I've managed to solve this with a ResourceTransformer that I've attached to the
issue. Bellow a snippet of the relevant areas. It was actually a little strange
since initially I thought that I had to set the TransformationResult attributes
property but I've managed to do it only by changing the dictionary directly (I
later discovered that the attributes are for another purpose). I don't know if
there is a better way (I'm changing the dictionary instance that I receive not
using the TransformationResult which seems a little odd :-S in api terms).
Taking into consideration the comments I plan to use this only in development
not in prodution so I think I can keep this solution for the local environment
of the developers.
{code:title=ResourceTransformer.java|borderStyle=solid}
private String replaceVariables(String key, String value,
Dictionary<String, Object> dictionary) {
...
}
private void transform(Dictionary<String, Object> dictionary) {
Enumeration<String> keys = dictionary.keys();
String key = null;
Object value = null;
while (keys.hasMoreElements()) {
key = keys.nextElement();
value = dictionary.get(key);
dictionary.put(key, value instanceof String ?
replaceVariables(key, (String) value, dictionary) : value);
}
}
@Override
public TransformationResult[] transform(RegisteredResource resource) {
if
(InstallableResource.TYPE_PROPERTIES.equals(resource.getType())) {
TransformationResult tr = new TransformationResult();
transform(resource.getDictionary());
return new TransformationResult[] { tr };
}
return null;
}
{code}
> Supporting variable substitution in sling installer configuration factory
> -------------------------------------------------------------------------
>
> Key: SLING-6021
> URL: https://issues.apache.org/jira/browse/SLING-6021
> Project: Sling
> Issue Type: New Feature
> Components: Installer
> Affects Versions: Installer Configuration Factory 1.0.14
> Reporter: Ivo Leitão
> Priority: Minor
> Attachments: PropertiesTransformer.java
>
>
> I'm not completely sure if this is a new feature or not but I've not find any
> documentation that explains how to perform variable transformation in
> configuration resources.
> In my use case I want to configure Apache Aries Transaction manager (snippet
> bellow) and I would like to use the ${sling.home} environment variable
> aries.transaction.recoverable=true
> aries.transaction.timeout=600
> aries.transaction.howl.maxBlocksPerFile=513
> aries.transaction.howl.maxLogFiles=2
> aries.transaction.howl.logFileDir=${sling.home}
> aries.transaction.howl.bufferSizeKBytes=4
> Is it possible or this is a completly new feature ? (I' ve tested and it does
> not work)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)