How to make a user-defined operation available to all my templates? [message #843784] |
Fri, 13 April 2012 11:09 |
Maarten Bezemer Messages: 117 Registered: February 2012 |
Senior Member |
|
|
I have several user-defined operations that I use in multiple EGL templates. So I would like to have one central location that defines these operations, instead of a copy in each template. (For obvious reasons like fixing bugs in one place)
I found out about OperationContributor, so I created my own:
public class TestOperation extends OperationContributor
{
@Override
public boolean contributesTo(Object target) {
return truel;
}
public String getName() {
return "MyTestName";
}
}
And added it to my factory:
EglFileGeneratingTemplateFactory factory new EglFileGeneratingTemplateFactory()
OperationContributorRegistry operationContributorRegistry = ((EglContext) factory.getContext()).getOperationContributorRegistry();
operationContributorRegistry.add(new TestOperaion());
But it does not work...
After debugging, I found the EglModule.execute(Formatter postprocessor). It copies the context (containing the methodContibutor field) to the preprocessorModule context: context.copyInto(preprocessorModule.getContext());
But, the methodContributor field is not copied! So the original one is used, containing only the default OperationContributor objects that are instantiated in the OperationContributorRegistry constructor.
My questions are:
- Did I use the correct method to define new (default) operations?
- If so, whether I found a bug that needs reporting or not?
- Should this be documented in the Epsilon book, as it seems nice to define global available user-defined operations
[Updated on: Fri, 13 April 2012 11:12] Report message to a moderator
|
|
|
|
|
Re: How to make a user-defined operation available to all my templates? [message #843804 is a reply to message #843794] |
Fri, 13 April 2012 11:29 |
|
Hi Maarten,
Import also accepts full plugin-based URIs so sharing code between different plugins shouldn't be a problem. You're right regarding copyInto(). If you really need this I'll try to implement a quick fix for it otherwise I'm inclined to leave this until I'm back from holiday so that we can discuss with the rest of the team how we could get rid of copying contexts altogether (as hinted by the comment at line 170 of EglModule )
Cheers,
Dimitris
|
|
|
|
Powered by
FUDForum. Page generated in 0.03249 seconds