Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Native vs. private constructor and static methods
Native vs. private constructor and static methods [message #1064484] Wed, 19 June 2013 13:12 Go to next message
Alex G is currently offline Alex GFriend
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 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

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
Re: Native vs. private constructor and static methods [message #1064591 is a reply to message #1064484] Thu, 20 June 2013 07:10 Go to previous messageGo to next message
Alex G is currently offline Alex GFriend
Messages: 96
Registered: January 2012
Member
Hi Dimitris!

Thank you for your advice. The detour with exended variables helped.

Is there some documentation available with all the fancy features one can get with the contexts on Epsilon (IEtlContext, IEolContext etc.)?

Best regards,
Alex.
Re: Native vs. private constructor and static methods [message #1064641 is a reply to message #1064591] Thu, 20 June 2013 11:20 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2162
Registered: July 2009
Location: York, UK
Senior Member

Hi Alex,

I'm afraid there's not much documentation on this part of the internals of Epsilon so any contributions (notes, code snippets - nothing too fancy) under [1] as you're exploring the API would be more than welcome!

Cheers,
Dimitris

[1] http://wiki.eclipse.org/Epsilon
Previous Topic:Problem with validating a hutn file
Next Topic:Standalone EvlValidator
Goto Forum:
  


Current Time: Fri Apr 19 00:49:56 GMT 2024

Powered by FUDForum. Page generated in 0.03188 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top