Native vs. private constructor and static methods [message #1064484] |
Wed, 19 June 2013 13:12 |
Alex G Messages: 96 Registered: January 2012 |
Member |
|
|
Hi!
I have a Java class "mypackage.MyClass" which is singleton, i.e. a private constructor and a static getInstance() method.
I want to instantiate it in ETL, e.g.
var bla = new Native("mypackage.MyClass");
However I get of course an error due to visibility constraints:
Plug-in "..." was unable to instantiate class "mypackage.MyClass".
It works fine, if I make the constructor public.
Is there a nice solution to work with static objects without making the constructor explicitely public?
Best regards,
Alex.
[Updated on: Wed, 19 June 2013 13:13] Report message to a moderator
|
|
|
Re: Native vs. private constructor and static methods [message #1064562 is a reply to message #1064484] |
Wed, 19 June 2013 22:25 |
|
Hi Alex,
I'm afraid that this is not possible. Classes contributed through Eclipse extensions (as is the case with Epsilon tools) need to provide a parameter-less constructor so that they can be instantiated. If memory serves, you're launching your ETL transformation from Java in which case you could add the following line in your launching code:
module.getContext().getFrameStack().put(Variable.createReadOnlyVariable("myObject", MyClass.getInstance()));
and then use your object as "myObject" in your transformation.
Cheers,
Dimitris
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03198 seconds