Lazy concatenation of strings and Ant
"Hal Hildebrand" <[email protected]> Mon, 27 Mar 2006 12:32:28 -0800
| Newsgroups | gmane.comp.java.smartfrog.devel |
|---|---|
| Message-ID | <20060327123228071.00000003600@Hellblazer> |
I have a need to lazily concatenate strings - i.e. concatenate values
that may not be available until after deployment. These strings are
then to be used in various places in the SF Ant integration - usually in
Java execution.
Here's a scenario I've put together which demonstrates the problem I
have.
The script reads in properties from a property file, using the
org.smartfrog.services.os.java.propertyfile.sf mechanism. One of these
properties will then be used in a concatenation and then fed as an
argument to an Ant task - in the example below, simply echoing out the
message.
The contents of the property file, "test.properties" is simply:
OH=d:/projects/lilly-pads/iAS/oc4j
The result of running this test is a class cast exception (see stack
trace at end of email - note, code has been altered, so it won't match
your line numbers. See below for code context).
The question is whether this is easy to fix in the Ant integration
components, or if this is a kind of general problem that may not be easy
to overcome. If it's an easy fix to the Ant integration, just point me
in the general direction and I can probably take it from there. My
concern, however, is that this is a general issue that components will
have to be modified in order for them to work with this kind of lazy
system. While I'm using the property file mechanism as an example, it
is merely a convenient mechanism to demonstrate the problem - it is not
emblematic of all the use cases where I need this lazy concatenation.
Thanks.
#include "org/smartfrog/components.sf"
#include "org/smartfrog/services/ant/components.sf";
#include "org/smartfrog/services/utils/concat/components.sf"
#include "org/smartfrog/services/os/java/propertyfile.sf"
sfConfig extends Compound {
testProps extends LoadPropertyFile {
filename "test.properties";
}
oracle_home LAZY testProps:OH;
mash extends LazyConcat {
debug true;
string extends {
-- oracle_home;
-- " ";
-- "foo";
}
}
test extends Compound {
foo LAZY mash:concat;
t extends Ant {
out extends echo {
message foo;
}
}
}
}
Caused by: java.lang.ClassCastException:
org.smartfrog.sfcore.reference.Reference
at
org.smartfrog.services.ant.AntProject.setAttribute(AntProject.java:241)
at
org.smartfrog.services.ant.AntProject.getElement(AntProject.java:205)
at
org.smartfrog.services.ant.AntProject.getTask(AntProject.java:488)
at
org.smartfrog.services.ant.AntImpl.executeNestedAntTasks(AntImpl.java:82
)
// May need for type conversion
if (!ptypes[0].equals(value.getClass())) {
value = convType((String) value, ptypes[0]); <<<<<-----
AntProject.java:241
}