Thanks, it worked!!!!
thing is that I was using
Project project = getProject();
project.addReference(str,obj) and project.getReference(str)
I replaced it to
getProject().addReference(str,obj) and
getProject().getReference(str)
and it worked.....
Can you please explain !!!!
Thanks,
AbhiNandan
[EMAIL PROTECTED] wrote:
What does not work?
I did a little test and its ok....
import java.util.Date;
public class MyTask extends org.apache.tools.ant.Task {
public void execute() {
log("Date is: " + getDate());
}
private Date getDate() {
Date date = (Date)getProject().getReference("date");
if (date == null) {
log(" creating new date");
date = new Date();
getProject().addReference("date", date);
}
return date;
}
}
use:
[mytask] creating new date
[mytask] Date is: Fri Sep 14 12:10:12 CEST 2007
[mytask] Date is: Fri Sep 14 12:10:12 CEST 2007
[mytask] Date is: Fri Sep 14 12:10:12 CEST 2007
Jan
>-----Ursprüngliche Nachricht-----
>Von: aatankwadi aatankwadi [mailto:[EMAIL PROTECTED]
>Gesendet: Freitag, 14. September 2007 11:38
>An: Ant Users List
>Betreff: Re: AW: Need to add one generic get/set attribute in
>Project API
>
>I already Used it but it is not working
>
>[EMAIL PROTECTED] wrote: Use set/getReference ;-)
>
>Jan
>
>>-----Ursprüngliche Nachricht-----
>>Von: aatankwadi aatankwadi [mailto:[EMAIL PROTECTED]
>>Gesendet: Freitag, 14. September 2007 09:18
>>An: Ant Users List
>>Betreff: Need to add one generic get/set attribute in Project API
>>
>>Hi,
>>
>> I m facing a problem, I want to persist one object through
>>out my project, so I want to put it in some name/value pair,
>>so that I can access it anywhere in my project.
>>
>> I am developing a custom sql task that can reuse the
>>connection object created once, rather then using current sql
>>task which create the connection again and again,
>> I want to put this connection object in to project instance
>>so that I can access it any where in my project, but no such
>>method(set/get property or attribute) available in current API
>>which can hold an object.
>> set property only stores string, where as I need to put an object
>>
>> Can ANT Developer can override
>>method(setProperty,getProperty) in Project class which can
>>store an object so that this can act as a generic method for
>>all objects.
>> public void setProperty(String key, Object obj2)
>> public Object getProperty(String key)
>>
>> Please do the needfull as soon as possible or suggest some
>>alternate solution.
>>
>> Thanks,
>> AbhiNandan
>> "Abhi Nahi To Kabhi Nahi"
>>
>>
>>---------------------------------
>> Why delete messages? Unlimited storage is just a click away.
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>---------------------------------
> Did you know? You can CHAT without downloading messenger. Click here
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Download prohibited? No problem. CHAT from any browser, without download.