aspose file tools*
The moose likes Beginning Java and the fly likes Confused about Inheritance (I think) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Confused about Inheritance (I think)" Watch "Confused about Inheritance (I think)" New topic
Author

Confused about Inheritance (I think)

Al Bert
Greenhorn

Joined: Mar 30, 2006
Posts: 5
DISCLAIMER: I am a Java beginner so I am really ignorant about a LOT of stuff. You've been warned.
----------------------------
I have been thrown "into the fire" by my boss and have to code Java class for data acquisition ("ETL") off of our different databases. I am using "Clover.ETL" (cloveretl.berlios.de) to execute ETL logic contained in a XML layout file.

We use a Quartz server (www.opensymphony.com/quartz) to fire many jobs based on a pre-defined schedule: I have written classes that launch my ETL jobs on schedule like this



It works great but it is poor design (the paths among other things). I got the JavaDoc for "Clover.ETL" and discovered this

org.jetel.main.runGraph has only one method static void main(java.lang.String[] args) and a unique constructor runGraph()

What I'm wondering is how to do I call runGraph() to run "ETL_job1.grf". I got to this point



but I am stuck. How do I pass arguments i.e. the name of my graph layout?

Thanks in advance for any help (advice, IQ points you can spare...) you can provide.

Al.

----------------------------
DISCLAIMER: I am a Java beginner so I am really ignorant about a LOT of stuff. You've been warned.
----------------------------


I wish I knew.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

Does runGraph contain any fields? And do you know what's in the body of main?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi Al,

Welcome to JavaRanch!

This isn't a very friendly API you're using is it? The public constructor actually just looks like a mistake if there are no other public instance methods; extending the class or creating an instance of the class isn't going to do anything useful.

Instead, what you could do is actually call the "main" method directly:



if, and this is a big "if", this class doesn't try to exit by calling System.exit(), or if the Quartz server can tolerate tasks that try to do so.

If it turns out that System.exit() is a problem, and you do have to keep using Runtime.exec(), you can make this solution less bad by reading the paths and things from a configuration file at runtime; that would allow an adminstrator to change them without recompiling your code.


[Jess in Action][AskingGoodQuestions]
Al Bert
Greenhorn

Joined: Mar 30, 2006
Posts: 5
Originally posted by marc weber:
Welcome to JavaRanch!

Does runGraph contain any fields? And do you know what's in the body of main?


Hi Marc!

Only one field for runGraph(): it is not helping me. Here's the URL to the page http://cloveretl.berlios.de/docs/JavaDoc/org/jetel/main/runGraph.html

Yes, I do know what's in the body of main (I got the source code):

*outside body of main*
1) Six(6) types are declared (one per command line argument)
1.1) no type is declared for where my XML layout file would go....weird?

*in body of main*
2) a Properties() object is created to grab the name of the XML layout file via FileInputStream()
3) All 6 types are parsed, initialized or the whole thing dies with "System.exit(-1);"
4) the name of the XML layout file seems to get captured with "new FileInputStream(args[args.length - 1]);"
5) the XML layout file is parsed and run.

That's it.

Al.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Well, Ernest was right: This isn't a very friendly API. And it sounds like his suggestion of calling main directly is your best bet.

Do you know what it's expecting for those 6 parameters? If not, maybe posting the source code would help.
Al Bert
Greenhorn

Joined: Mar 30, 2006
Posts: 5
Originally posted by marc weber:
Well, Ernest was right: This isn't a very friendly API. And it sounds like his suggestion of calling main directly is your best bet.

Do you know what it's expecting for those 6 parameters? If not, maybe posting the source code would help.


Marc, Ernest et al:

Here's the source code


Hope this helps...

Al.
Al Bert
Greenhorn

Joined: Mar 30, 2006
Posts: 5
Originally posted by Ernest Friedman-Hill:
Hi Al,

Welcome to JavaRanch!

This isn't a very friendly API you're using is it? The public constructor actually just looks like a mistake if there are no other public instance methods; extending the class or creating an instance of the class isn't going to do anything useful.

Instead, what you could do is actually call the "main" method directly:



if, and this is a big "if", this class doesn't try to exit by calling System.exit(), or if the Quartz server can tolerate tasks that try to do so.

If it turns out that System.exit() is a problem, and you do have to keep using Runtime.exec(), you can make this solution less bad by reading the paths and things from a configuration file at runtime; that would allow an adminstrator to change them without recompiling your code.


Ernest, you are 100% correct. The class runGraph() does a "System.exit(0)" on successful completion. Argh!

Al.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

OK, Based on that source code, it looks like you can just ignore runGraph and use the other classes like TransformationGraphXMLReaderWriter directly; basically follow what runGraph does, except of course you don't need to check the arguments (since you know what you're passing!) and you don't want to call exit().

Now, of course, this depends on the classes like TransformationGraphXMLReaderWriter being public. Otherwise, I think it's time to start hacking their source code!
Al Bert
Greenhorn

Joined: Mar 30, 2006
Posts: 5
Based on the source code (not posted here), I need to use "TransformationGraph". So, here's what I did...



It runs but I am p-o-ed. I get the feeling the app I am using is designed in a quick and dirty sorta way.

I want re-design it but I know nothing about that topic. Can you guys suggest a good book? Thanks in advance!

I thank all of you help for your support and help.

Al.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Confused about Inheritance (I think)