registering a time provider [message #612910] |
Wed, 19 December 2007 19:45 |
Jean-Claude Cote Messages: 56 Registered: July 2009 |
Member |
|
|
Hi,
I'm working on an EMFT project called Temporality. This project focuses on
keeping a historical record of the state of modeled instances.
A central concept of this feature is the current date. I'd rather not hard
code access to the current time like this System.currentMilliseconds() but
rather hide access to the current time behind an interface and provide a way
to plug different time provider implementations.
That way I could have a testing time provider and a runtime etc.
What is the best way to plug this type of provider in EMF? The idea would be
to give developers a way to plug the implemenation of an interface. Can I
register such a class in an EPackage?
interface TemporalDate {
setNow(Date d);
Date now();
boolean areEqual(Date a, Date b, int granularity);
}
class RuntimeTemporalDate{
...
Date now(){
return new Date(System.currentMili);
}
}
class DebugTemporalDate{
Date now;
...
void setNow(Date d){
now = d;
}
}
Thanks
Jean-Claude
|
|
|
Powered by
FUDForum. Page generated in 0.02681 seconds