cancel
Showing results for 
Search instead for 
Did you mean: 

Adding trace to a normal java class in Imported Archive

former_member200339
Participant
0 Kudos

Dear All,

I have developed a graphical mapping and has one UDF.

The UDF is calling a java class saved as Imported Archive.

I would like to add trace to the java class which will display in the sxi_monitor but unable to do so as it does not extends AbstarctTransformation or does not have access to the container object.

Please suggest if there is any way out.

Thanks and Regards,

Rana Brata De

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182412
Active Contributor
0 Kudos

Hi Rana,

You can add instance variable in the class and create getMessage() method to get the log message which is stored in the instance variable. In the method of external class you can assign the instance variable with required message which you want to log. In the UDF you can call this getMessage() to receice this log message and pass it to trace.


public class Math {

  private String message;

  public String getMessage() {

  return message;

  }

  public int add(int a, int b) {

  int c = a + b;

  message = "Add method successful";

  return c;

  }

}


public String sampleUDF(int a, int b, Container container) throws StreamTransformationException {

  Math math = new Math();

  String output = Integer.toString(math.add(a, b));

  container.getTrace().addInfo(math.getMessage());

  return output;

  }

Regards,

Praveen.

former_member200339
Participant
0 Kudos

Dear All,

I tried with sending a handler for the object AbstractTrace as an argument to a method and it is working.

Thanks to all for the suggestion.

Rana

Former Member
0 Kudos

Hi ,

You can  refer below blog for your requirement may be it can help you.

Regards,
Bhavin