JAVA API

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

JAVA API

Post by reddy12 »

dear gurus,
i am given a java api archive which contains .jar file.

i have to set up java transformer to use one of the classes in the .jar file.
can any one tell me step by step process of cofiguring the java transformer???
like what goes in transformer class path, user class path and where i have to copy this .jar file one server(AIX) and client(WINDOWS).


i appreciate your suggestions and tips.

Regards.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

First, you need to get ahold of the source code to the class, an environment to work with it, or get to know the developer.....

The JavaTransformer allows you to have tight interaction with a class -- not just "call it".... You invoke it, and then it interacts with the DS engine to exchange meta data and rows of data at run time. It's simple to do, but does require that you make additions and edits/changes to your class......

The doc for Java Transformer is really good, and has some good examples......

I have to figure out how to put files up on my blog...I'll post some examples there....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Post by reddy12 »

thanks for your reply.
for now can you tell me how i can use the examples provided by datastage. i mean how to use the existing examples in datastage????

i went through the documentation but i am not so gud at understanding it. i think your blog may be useful to me in this regard.

Regards.
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

reddy12,
If you cannot even undertstand the examples demonstrated in the documentation, I think that you sholud tell your boss to assign the task to someone else who has experience with Java. It's not like just copy and paste the .jar file to somewhere, then the Java application works.
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...this is very true....even with fully documented examples of java code and DataStage Jobs, you will have to have the assistance of someone who knows java, is able to develop and compile a class, has an environment set up for doing so, is able to create a .jar, etc..... the learning curve for that alone has its challenges.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Post by reddy12 »

lstsaur wrote:reddy12,
If you cannot even undertstand the examples demonstrated in the documentation, I think that you sholud tell your boss to assign the task to someone else who has experience with Java. It's not like just copy and paste the .jar file to somewhere, then the Java application works.
istsaur,
thanks for your reply. you mean to say that every class that i am willing to use must be tweaked to work with datastage??? meaning except the core logic do we have to provide the same java program syntax datastage java transformer uses???

as your suggestion tells me that you have very good experience working with java... can you spare sometime and tell me the AtoZ procedure to make a simple class work with java transformer????.. other than suggesting me to go throught he doc from datastage..


i appreciate your help and suggestions.

Regards.
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

reddy12,
Sure, I will show you how to use Java to interact with DataStage.
First, try to compile the following Java program (LowerCase):

import com.ascentialsoftware.jds.Row;
import com.ascentialsoftware.jds.Stage;
public class LowerCase extends Stage
{
public int process()
{
// Read a row, convert all its columns to lower case,
// and write the result. If one column of the input row
// contains the character '*', the row is rejected.
Row inputRow = readRow();
if (inputRow == null) {
return OUTPUT_STATUS_END_OF_DATA;
}
boolean reject = false;
int columnCount = inputRow.getColumnCount();
Row outputRow = createOutputRow();
for (int columnNumber = 0; columnNumber < columnCount; columnNumber++) {
String value = inputRow.getValueAsString(columnNumber);
if ((value == null) || (value.indexOf('*') >= 0)) {
reject = true;
outputRow.setValueAsString(columnNumber, value);
} else {
outputRow.setValueAsString(columnNumber, value.toLowerCase());
}
}
if (reject) {
rejectRow(outputRow);
} else {
writeRow(outputRow);
}
return OUTPUT_STATUS_READY;
}
}

After the compilation, put the LowerCase class in your java_home/java/jre/bin directroy.
Then, create a job, Seq_01-->Java_Transformer_02-->Seq_03.
All columns' values in Seq_01 should be populated in upper cases.
Put LowerCase in Java_transformer stage's Transformer Class Name.
Populate your Java environment, /IBM/InformationServer/Server/DSEngine/java/jre/bin, in the User's Classpath.
Run the job.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

lstsaur - you forgot to add "And Bob's your uncle"
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

reddy12...

The point of this whole discussion is that JavaPack and the JavaTransformer/JavaClient stages are not for just "calling out" to any old Java class. The java pack was designed for something far greater ----- to allow you to extend DataStage, in any way necessary, into the realm of Java -- to re-use or exploit techniques, existing code, special java sources, etc. --- that you might find desirable to integrate with DataStage. The use case is the critical piece. You noted "you mean to say that every class that i am willing to use must be tweaked to work with datastage??? " ...and the answer is that "yes --- every class you'd like to use to enhance what you are doing in DataStage needs to be tweaked". And tweaking is indeed the key word here. Maybe 10 lines of code, if that, in the example above, needed to be added.

Start with a use case --- perhaps you need to make a call to a unique EJB in your site....or to update a BLOB as noted earlier...or read and write to/from a JMS queue..... things that are easy to do in Java and things that DataStage does not necessarily do, or things that you've already done in java.

In your case, is the class doing something unique? Or just doing some basic transforms? If it's just basic transforms, there is certainly a re-use issue, but the work to use it might be overkill. If it's something truly unique, someone with the requisite java skills will find that the "tweaks", while necessary, are trivial.

The learning curve for java (and perhaps more so, setting up the environment, working with classpaths, etc.) tends to NOT be trivial. Thus that's why you are hearing this guidance. If you expect to be doing many many of these in the near future, we can also point you to resources on the web to accelerate that curve. If not, then it's best to find someone with the java experience we're noting...they'll have this working for you in very short order.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Post by reddy12 »

lstsaur,
thanks a bunch for your step by step procedure...
i will try this. i see an example in the documentaion.but i didn't know that i have to comiple those example codes and put the classes in the mentioned directory.
your explanation in enlightening

Regards.
Post Reply