Creating a component that outputs static class to the output java code

One Star

Creating a component that outputs static class to the output java code

I have to generate a java program with:
1) one outer class
2) Two inner static class.
3) A main() which uses these static classes.
I am planning to create three components to do this. One for generating the first static class code, other for next static class code and finally one component to generate the main() code. Is my idea of component creation correct? Any one with good suggestions.
Thank you.
One Star

Re: Creating a component that outputs static class to the output java code

Hello,
why are you trying to do that?
Not saying you cannot, but what are you trying to achieve?
If, for any reason, you need a static class, then you probably better look into routines.
I wrote a tutorial on that topic, you can find it here : http://powerupbi.com/talend/routinesCreation_1.html
One Star

Re: Creating a component that outputs static class to the output java code

Thanks for the suggestion.
Routines are fine for me, but I want to try with components.
As I tried to run a code in tJavaFlex with static modifier before a class name, I am getting error from talend stating invalid prefix.
As per my knowledge of Java , all inner classes must be static ( correct me if I am wrong). Then how can talend limit that?
One Star

Re: Creating a component that outputs static class to the output java code

Uhm again, I cannot really figure out what you are trying to achieve.
I never created a static class in a component, however I did create classes in the begin section of the component.
A typical one I use is for logging purposes, when I need to debug.
First off : do you know how to create components in general? I mean without classes inside.
Are you aware that components are not classes (that's explained in lesson 1 of my tutorial)?
Inner classes must be static?
check here for details : http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
Second thing, IF you know that components are not classes AND you know how they work THEN you know that whatever code you write -included a class declaration- in a component is finally placed within a method of a class which is the subjob (ELSE you should probably try to get a better insight into components before attempting some "acrobatic coding" with them Smiley Tongue )
Hope it helps
One Star

Re: Creating a component that outputs static class to the output java code

Thanks for the info...
Also your component creation tutorial helped me alot. It is an excellent work.
What I was trying to achieve is to develop components with which I can develop map reduce programs. Since there are no built in components, I was trying to develop the components.
One Star

Re: Creating a component that outputs static class to the output java code

Map Reduce?
wow, that sounds pretty cool, just heard of it, never used, but looks like an interesting domain.
Yeah, would probably be cool to have something like that in Talend, maybe not using static classes defined within components...
In general, if you need to create your own classes, it's more efficient to create them separately from the component (it makes also way easier the debugging and testing), add them to a jar file and then use the jar in the component.
At that point you can have static or non static methods, no problem with that.
The main difference is that defining the classes in your jar file, they are "regular" classes and not inner classes defined in a method of the subjob class.
Good luck with the map reduce!
Francesco